Commit before implementing positional inventory

This commit is contained in:
2023-05-18 09:52:46 +01:00
parent 7df81559d9
commit 2f0bb5115b
12 changed files with 132 additions and 78 deletions
+50 -35
View File
@@ -1,16 +1,17 @@
module Dodge.Item.Info where
import StringHelp
import Dodge.Module.Info
import Data.Char
import Dodge.Data.Item
import qualified Data.Map.Strict as M
import Dodge.Data.Item
import Dodge.Module.Info
import LensHelp
import StringHelp
itemInfo :: Item -> String
itemInfo itm = itmBaseInfo itm ++ " " ++ itmUsageInfo itm
++ itmSpaceInfo itm
++ itmModuleInfo (itm ^. itType . iyModules)
itemInfo itm =
itmBaseInfo itm ++ " " ++ itmUsageInfo itm
++ itmSpaceInfo itm
++ itmModuleInfo (itm ^. itType . iyModules)
itmSpaceInfo :: Item -> String
itmSpaceInfo itm = case ceiling $ _itInvSize itm of
@@ -43,20 +44,34 @@ showInt i = case i of
12 -> "a dozen"
_ -> "more than a dozen"
showIntKMG :: Int -> String
showIntKMG x
| x < 1000 = show x
| x < 1000000 = show (x `div` 1000) ++ "K"
| x < 1000000000 = show (x `div` 1000000) ++ "M"
| otherwise = show (x `div` 1000000000) ++ "G"
showIntKMG' :: Int -> String
showIntKMG' x
| x < 1000 = show x
| x < 1000000 = take 3 (show ((fromIntegral x :: Float) / 1000)) ++ "K"
| x < 1000000000 = take 3 (show ((fromIntegral x :: Float) / 1000000)) ++ "M"
| otherwise = take 3 (show ((fromIntegral x :: Float) / 1000000000)) ++ "G"
heldInfo :: HeldItemType -> String
heldInfo hit = case hit of
BANGSTICK 1 -> "A firearm with a short barrel that requires reloading after each shot."
BANGSTICK i -> over _head toUpper (showInt i)++" small gun barrels strapped together. Each barrel must be individually loaded, but not all need be loaded for the weapon to fire. All loaded barrels discharge simultaneously, with significant spread."
BANGSTICK i -> over _head toUpper (showInt i) ++ " small gun barrels strapped together. Each barrel must be individually loaded, but not all need be loaded for the weapon to fire. All loaded barrels discharge simultaneously, with significant spread."
PISTOL -> "A small firearm fed by a magazine. The entire magazine must be replaced when reloading the weapon."
REVOLVER -> "A small firearm fed by a revolving cylinder. Single shot and load."
REVOLVERX i -> "A small firearm fed by "++ showInt i++ "revolving cylinders."
REVOLVERX i -> "A small firearm fed by " ++ showInt i ++ "revolving cylinders."
MACHINEPISTOL -> "A small firearm automatically, and extremely rapidly, fed by a magazine. The entire magazine must be replaced when reloading the weapon."
AUTOPISTOL -> "A small firearm automatically fed by a magazine. The entire magazine must be replaced when reloading the weapon."
SMG -> "A small firearm with an attached stock for stability."
BANGCONE -> "A container for debris. Exposive action propels the debris away from the user. Quite unweildy."
BLUNDERBUSS -> "A container for debris on the end of a stick. Explosive action propels the debris away from the user."
GRAPECANNON 1 -> "A large container for debris on the end of a stick. Explosive action propels the debris away from the user."
GRAPECANNON i -> "An "++ replicate (i-1) 'X' ++"L container for debris on the end of a stick. Explosive action propels the debris away from the user."
GRAPECANNON i -> "An " ++ replicate (i -1) 'X' ++ "L container for debris on the end of a stick. Explosive action propels the debris away from the user."
MINIGUNX i -> over _head toUpper (showInt i) ++ " gun barrels that revolve rapidly around a central stick. Requires considerable time to warm up, but has an extremely rapid rate of fire. It is also extremely difficult to stabilise."
VOLLEYGUN i -> over _head toUpper (showInt i) ++ " gun barrels lined up to be roughly parallel. Each barrel must be individually loaded, but not all need be loaded for the weapon to fire. All loaded barrels discharge simultaneously."
RIFLE -> "A firearm with a mid length barrel that requires reloading after each shot."
@@ -82,17 +97,17 @@ heldInfo hit = case hit of
LASWIDE _ -> "A weapon that continuously emits photons in a narrow beam. The beam expands as the weapon heats up."
TRACTORGUN -> "An item that produces a beam of gravitons."
LAUNCHER -> "A large tube that can launch self propelled projectiles. Moving the tube after launch will cause the projectile to spin."
LAUNCHERX i -> over _head toUpper (showInt i)++" tubes that can launch self propelled projectiles. Tubes that do not face forward launch their projecitles at an angle."
LAUNCHERX i -> over _head toUpper (showInt i) ++ " tubes that can launch self propelled projectiles. Tubes that do not face forward launch their projecitles at an angle."
REMOTELAUNCHER -> "A large tube that can launch self propelled projectiles. Contains a transmitter allowing for remote control of launched projectiles."
POISONSPRAYER -> "A weapon that releases noxious gases."
DRONELAUNCHER -> "A device for launching drones."
SHATTERGUN -> "A seismic device that shatters hard items in its line of fire."
FORCEFIELDGUN -> "A device that produces a durable forcefield."
HELDDETECTOR d -> "A device that detects "++detectorInfo d ++" in an expanding radius."
HELDDETECTOR d -> "A device that detects " ++ detectorInfo d ++ " in an expanding radius."
TORCH -> "A stick with a light on the end."
BINOCULARS -> "Two cylinders with lenses. Scroll to zoom."
FLATSHIELD -> "A panel of metal that blocks unwanted objects from the front of the user."
KEYCARD i -> "A keycard. It is labelled " ++ show i++ "."
KEYCARD i -> "A keycard. It is labelled " ++ show i ++ "."
leftInfo :: LeftItemType -> String
leftInfo lit = case lit of
@@ -114,18 +129,17 @@ equipInfo eit = case eit of
INVISIBILITYEQUIPMENT _ -> "A device that bends light around its user."
BRAINHAT -> "An iq enhancer. Useless."
HAT -> "A hat."
TARGETINGHAT tt -> "Headwear that "++ targetingInfo tt
TARGETINGHAT tt -> "Headwear that " ++ targetingInfo tt
HEADLAMP -> "A torch strapped to a hat."
POWERLEGS -> "Strength enhancing legs."
SPEEDLEGS -> "Speed enhancing legs."
JUMPLEGS -> "Jump enhancing legs."
JETPACK -> "A device enabling flight."
FUELPACK -> "A liquid container with attached hose."
BULLETBELTPACK -> "A container holding a long belt of bullets."
BULLETBELTBRACER -> "A container holding a long belt of bullets."
BATTERYPACK -> "A collection of batteries with a universal adapter."
AUTODETECTOR d -> "A device that detects "++detectorInfo d ++" in an expanding radius. Pulses automatically. "
AUTODETECTOR d -> "A device that detects " ++ detectorInfo d ++ " in an expanding radius. Pulses automatically. "
targetingInfo :: TargetType -> String
targetingInfo tt = case tt of
@@ -146,10 +160,8 @@ craftInfo fit = case fit of
TUBE -> "A wide rigid cylinder."
HARDWARE -> "A collection of equipment and devices useful for general construction."
SPRING -> "An object that exerts an opposing force when compressed or stretched."
HOSE -> "A flexible cylinder."
TAPE -> "A strip of material with an adhesive side."
CAN -> "A small metal cylindrical container."
TIN -> "A small metal continer."
STEELDRUM -> "A metal cylindrical container."
@@ -193,12 +205,9 @@ craftInfo fit = case fit of
TIMEMODULE -> "A device that can affect temporality."
SIZEMODULE -> "A device that can affect physical size."
GRAVITYMODULE -> "A device that can affect gravitational fields."
TARGETMODULE _ -> "A targeting module."
FLAKCRAFT -> "Creates flak bullets."
FRAGCRAFT -> "Creates fragmentation bullets."
detectorInfo :: Detector -> String
detectorInfo d = case d of
@@ -209,8 +218,9 @@ detectorInfo d = case d of
itmUsageInfo :: Item -> String
itmUsageInfo itm = case itm ^. itType . iyBase of
HELD _ -> heldPositionInfo itm
LEFT _ -> "This item can be equipped" ++ itmEquipSiteInfo itm
++ ". When equipped, it can be activated."
LEFT _ ->
"This item can be equipped" ++ itmEquipSiteInfo itm
++ ". When equipped, it can be activated."
EQUIP _ -> "This item can be equipped " ++ itmEquipSiteInfo itm ++ "."
Consumable _ -> "This item can be consumed."
CRAFT _ -> ""
@@ -221,9 +231,10 @@ heldPositionInfo = maybe undefined aimStanceInfo . (^? itUse . heldAim . aimStan
aimStanceInfo :: AimStance -> String
aimStanceInfo as = case as of
TwoHandTwist -> "It is held in two hands along its length."
TwoHandTwist -> "It is held in two hands along its length."
TwoHandFlat -> "It is held in two hands at its sides."
OneHand -> "It is held in one hand."
-- LeaveHolstered -> "It is to be left holstered."
itmEquipSiteInfo :: Item -> String
@@ -238,23 +249,27 @@ equipSiteInfo es = case es of
GoesOnLegs -> " on both legs"
itmModuleInfo :: M.Map ModuleSlot ItemModuleType -> String
itmModuleInfo m
itmModuleInfo m
| m == mempty = ""
| otherwise = mms ++ ems
| otherwise = mms ++ ems
where
(mademods,emptymods) = M.partition (/= EMPTYMODULE) m
mms | mademods == mempty = ""
| otherwise = " Modifications have been made "
++ makeCommaList (map moduleInfo $ M.keys mademods)
ems | emptymods == mempty = ""
| otherwise = " Modifications can be made "
++ makeCommaList (map moduleInfo $ M.keys emptymods)
(mademods, emptymods) = M.partition (/= EMPTYMODULE) m
mms
| mademods == mempty = ""
| otherwise =
" Modifications have been made "
++ makeCommaList (map moduleInfo $ M.keys mademods)
ems
| emptymods == mempty = ""
| otherwise =
" Modifications can be made "
++ makeCommaList (map moduleInfo $ M.keys emptymods)
makeCommaList :: [String] -> String
makeCommaList [] = ""
makeCommaList [x] = x ++ "."
makeCommaList [x,y] = x ++ " and " ++ y ++ "."
makeCommaList (x:xs) = x ++ ", " ++ makeCommaList xs
makeCommaList [x, y] = x ++ " and " ++ y ++ "."
makeCommaList (x : xs) = x ++ ", " ++ makeCommaList xs
moduleInfo :: ModuleSlot -> String
moduleInfo imt = case imt of