Remove creature records

This commit is contained in:
2025-06-06 14:52:52 +01:00
parent 05f250f928
commit 467f241d7a
15 changed files with 37 additions and 28 deletions
+1 -1
View File
File diff suppressed because one or more lines are too long
+5 -4
View File
@@ -3,7 +3,7 @@
-- | Actions performed by creatures within the world
module Dodge.Creature.Action (
performActions,
setMinInvSize,
-- setMinInvSize,
dropExcept,
dropItem,
blinkActionMousePos,
@@ -140,8 +140,8 @@ performAction cr w ac = case ac of
(imps, _) -> (imps, Just $ DoReplicatePartial startac (t -1) startac)
NoAction -> ([], Nothing)
setMinInvSize :: Int -> Creature -> World -> World
setMinInvSize n cr = cWorld . lWorld . creatures . ix (_crID cr) . crInvCapacity .~ n
--setMinInvSize :: Int -> Creature -> World -> World
--setMinInvSize n cr = cWorld . lWorld . creatures . ix (_crID cr) . crInvCapacity .~ n
---- maybe this should be removed...
--stripNoItems :: Creature -> World -> World
@@ -191,7 +191,8 @@ youDropItem w = fromMaybe w $ do
curpos <-
cr ^? crManipulation . manObject . imSelectedItem
<|> fmap fst (IM.lookupMax (cr ^. crInv))
guard $ not $ _crInvLock cr
--guard $ not $ _crInvLock cr
guard $ not $ w ^. cWorld . lWorld . lInvLock
return $ case cr ^. crStance . posture of
Aiming -> throwItem w
AtEase -> dropItem cr curpos w
+2 -1
View File
@@ -2,13 +2,14 @@ module Dodge.Creature.Info (
yourInfo,
) where
import Dodge.Inventory.CheckSlots
import Dodge.Data.Creature
import LensHelp
yourInfo :: Creature -> String
yourInfo cr =
yourStatsInfo cr
++ " You can carry a maximum of " ++ show (cr ^. crInvCapacity) ++ " individual items. "
++ " You can carry a maximum of " ++ show maxInvSlots ++ " individual items. "
++ " You can't remember your name."
statsModifier :: Int -> String -> String -> String -> String
+1 -2
View File
@@ -43,8 +43,7 @@ data Creature = Creature
, _crHP :: Int
, _crInv :: IM.IntMap Item
, _crManipulation :: Manipulation
, _crInvCapacity :: Int
, _crInvLock :: Bool
-- , _crInvLock :: Bool
, _crEquipment :: M.Map EquipSite Int
, _crState :: CreatureState
, _crPastDamage :: Int
+1
View File
@@ -149,6 +149,7 @@ data LWorld = LWorld
, _hotkeys :: M.Map Hotkey (NewInt ItmInt)
, _imHotkeys :: NewIntMap ItmInt Hotkey
, _lAimPos :: Point2
, _lInvLock :: Bool
}
--data WorldBeams = WorldBeams
+1 -1
View File
@@ -24,7 +24,7 @@ data WdWd
| WorldEffects [WdWd]
| SetLSCol Point3 Int
| AccessTerminal (Maybe Int)
| UnlockInv Int
| UnlockInv
| SoundStart SoundOrigin Point2 SoundID (Maybe Int)
| MakeStartCloudAt Point3
| TorqueCr Float Int
+3 -3
View File
@@ -31,8 +31,8 @@ applyTerminalCommand s = case s of
['L', x] ->
(uvWorld . cWorld . lWorld %~ initSpecificCrItemLocations 0)
. (uvWorld . cWorld . lWorld . creatures . ix 0 . crInv .~ IM.fromList (zip [0 ..] $ inventoryX x))
. (uvWorld . cWorld . lWorld . creatures . ix 0 . crInvCapacity .~ 50)
['I','S',x,y] -> uvWorld . cWorld . lWorld . creatures . ix 0 . crInvCapacity .~ read [x,y]
-- . (uvWorld . cWorld . lWorld . creatures . ix 0 . crInvCapacity .~ 50)
-- ['I','S',x,y] -> uvWorld . cWorld . lWorld . creatures . ix 0 . crInvCapacity .~ read [x,y]
"GODON" -> uvWorld . cWorld . lWorld . creatures . ix 0 . crType . avatarMaterial .~ Crystal
"GODOFF" -> uvWorld . cWorld . lWorld . creatures . ix 0 . crType . avatarMaterial .~ Flesh
x -> fromMaybe id $ do
@@ -83,7 +83,7 @@ applySetTerminalString [] = id
applySetTerminalString var = case key' of
"" -> showTerminalError ("set " ++ var) ("Unable to read as argument as float: " ++ val)
"hp" -> uvWorld . cWorld . lWorld . creatures . ix 0 . crHP .~ round (fromJust val')
"invcap" -> uvWorld . cWorld . lWorld . creatures . ix 0 . crInvCapacity .~ round (fromJust val')
-- "invcap" -> uvWorld . cWorld . lWorld . creatures . ix 0 . crInvCapacity .~ round (fromJust val')
-- "mass" -> uvWorld . cWorld . lWorld . creatures . ix 0 . crMass .~ fromJust val'
"mvspeed" -> uvWorld . cWorld . lWorld . creatures . ix 0 . crMvType . mvSpeed .~ fromJust val'
_ -> showTerminalError ("set " ++ var) ("Invalid set command: " ++ key) -- never reached?
+1 -2
View File
@@ -25,8 +25,7 @@ defaultCreature =
-- , _crMaxHP = 150
, _crInv = IM.empty
, _crManipulation = Manipulator SelNothing
, _crInvCapacity = 25
, _crInvLock = False
-- , _crInvCapacity = 25
, _crState = defaultState
-- , _crCorpse = MakeDefaultCorpse
-- , _crMaterial = Flesh
+1
View File
@@ -149,6 +149,7 @@ defaultLWorld =
, _hotkeys = mempty
, _imHotkeys = mempty
, _lAimPos = 0
, _lInvLock = False
}
defaultHUD :: HUD
+4 -4
View File
@@ -425,9 +425,9 @@ itemSidePush = \case
applyInvLock :: Item -> Creature -> World -> World
applyInvLock itm cr = case itemInvLock itm of
i
| i > 0 ->
(cWorld . lWorld . delayedEvents .:~ (i, UnlockInv cid))
. lockInv cid
| i > 0 && cid == 0 ->
(cWorld . lWorld . delayedEvents .:~ (i, UnlockInv))
. lockInv
_ -> id
where
cid = _crID cr
@@ -441,7 +441,7 @@ heldItemInvLock :: HeldItemType -> Int
heldItemInvLock = \case
FLAMESPITTER -> 10
VOLLEYGUN i -> i + 1
BURSTRIFLE -> 7
BURSTRIFLE -> 70
_ -> 0
applySoundCME :: Item -> Creature -> World -> World
+6 -1
View File
@@ -1,6 +1,7 @@
module Dodge.Inventory.CheckSlots (
checkInvSlotsYou,
crNumFreeSlots,
maxInvSlots,
) where
import Control.Monad
@@ -20,7 +21,11 @@ checkInvSlotsYou it w = do
Just . IM.newKey $ _crInv ycr
crNumFreeSlots :: Creature -> Int
crNumFreeSlots cr = _crInvCapacity cr - invSize (_crInv cr)
--crNumFreeSlots cr = _crInvCapacity cr - invSize (_crInv cr)
crNumFreeSlots cr = maxInvSlots - invSize (_crInv cr)
maxInvSlots :: Int
maxInvSlots = 25
invSize :: IM.IntMap Item -> Int
invSize = alaf Sum foldMap itInvHeight
+6 -4
View File
@@ -6,8 +6,10 @@ module Dodge.Inventory.Lock (
import Control.Lens
import Dodge.Data.World
lockInv :: Int -> World -> World
lockInv cid = cWorld . lWorld . creatures . ix cid . crInvLock ||~ True
lockInv :: World -> World
--lockInv cid = cWorld . lWorld . creatures . ix cid . crInvLock ||~ True
lockInv = cWorld . lWorld . lInvLock .~ True
unlockInv :: Int -> World -> World
unlockInv cid = cWorld . lWorld . creatures . ix cid . crInvLock &&~ False
--unlockInv :: Int -> World -> World
unlockInv :: World -> World
unlockInv = cWorld . lWorld . lInvLock .~ False
+2 -1
View File
@@ -28,7 +28,8 @@ updateWheelEvent yi w = case w ^. hud . hudElement . subInventory of
-- yi should be nonzero
updateBaseWheelEvent :: Int -> World -> World
updateBaseWheelEvent yi w
| Just True <- w ^? cWorld . lWorld . creatures . ix 0 . crInvLock = w
-- | Just True <- w ^? cWorld . lWorld . creatures . ix 0 . crInvLock = w
| Just True <- w ^? cWorld . lWorld . lInvLock = w
| bdown ButtonRight = case _rbOptions w of
EquipOptions{} -> w & rbOptions . opSel %~ scrollRBOption yi rbscrollmax
NoRightButtonOptions -> fromMaybe w (selectedItemScroll yi w)
+1 -1
View File
@@ -33,7 +33,7 @@ doWdWd we = case we of
SetLSCol col lsid -> cWorld . lWorld . lightSources . ix lsid . lsParam . lsCol .~ col
AccessTerminal mtmid -> accessTerminal mtmid
WorldEffects wes -> \w -> foldr doWdWd w wes
UnlockInv cid -> unlockInv cid
UnlockInv -> unlockInv
MakeStartCloudAt p -> makeStartCloudAt p
TorqueCr x cid -> torqueCr x cid
SoundStart so p sid mi -> soundStart so p sid mi
+2 -3
View File
@@ -2424,7 +2424,6 @@ _crHP src/Dodge/Data/Creature.hs 43;" f
_crID src/Dodge/Data/Creature.hs 42;" f
_crIntention src/Dodge/Data/Creature.hs 59;" f
_crInv src/Dodge/Data/Creature.hs 44;" f
_crInvCapacity src/Dodge/Data/Creature.hs 46;" f
_crInvLock src/Dodge/Data/Creature.hs 47;" f
_crManipulation src/Dodge/Data/Creature.hs 45;" f
_crMemory src/Dodge/Data/Creature.hs 55;" f
@@ -4663,7 +4662,7 @@ invSetSelection src/Dodge/Inventory.hs 185;" f
invSetSelectionPos src/Dodge/Inventory.hs 193;" f
invShiftPointBy src/Dodge/ShiftPoint.hs 8;" f
invSideEff src/Dodge/Creature/State.hs 167;" f
invSize src/Dodge/Inventory/CheckSlots.hs 25;" f
invSize src/Dodge/Inventory/CheckSlots.hs 29;" f
inventoryX src/Dodge/Creature.hs 113;" f
inverseSelNumPos src/Dodge/SelectionSections.hs 228;" f
inverseSelSecYint src/Dodge/SelectionSections.hs 201;" f
@@ -4956,6 +4955,7 @@ makeTypeCraftNum src/Dodge/Item/Craftable.hs 12;" f
mapper src/Dodge/Item/Scope.hs 70;" f
maxAmmo src/Dodge/Item/MaxAmmo.hs 6;" f
maxDamageType src/Dodge/Damage.hs 37;" f
maxInvSlots src/Dodge/Inventory/CheckSlots.hs 26;" f
maxShowX src/Dodge/Combine/Graph.hs 49;" f
maxViewDistance src/Dodge/Viewpoints.hs 26;" f
maybeBlockedPassage src/Dodge/Room/RezBox.hs 69;" f
@@ -5696,7 +5696,6 @@ setInvPosFromSS src/Dodge/Inventory/Location.hs 82;" f
setLayer src/Picture/Base.hs 139;" f
setLinkType src/Dodge/RoomLink.hs 60;" f
setLinkTypePD src/Dodge/RoomLink.hs 67;" f
setMinInvSize src/Dodge/Creature/Action.hs 143;" f
setMusicVolume src/Sound.hs 162;" f
setMvPos src/Dodge/Creature/ReaderUpdate.hs 52;" f
setOldPos src/Dodge/Update.hs 467;" f