287 lines
15 KiB
Haskell
287 lines
15 KiB
Haskell
module Dodge.Item.Info where
|
|
|
|
import Data.Char
|
|
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)
|
|
|
|
itmSpaceInfo :: Item -> String
|
|
itmSpaceInfo itm = case ceiling $ _itInvSize itm of
|
|
1 -> " It takes up one inventory slot. "
|
|
x -> " It takes up " ++ showInt x ++ " inventory slots. "
|
|
|
|
itmBaseInfo :: Item -> String
|
|
itmBaseInfo itm = case itm ^. itType . iyBase of
|
|
HELD hit -> heldInfo hit
|
|
LEFT lit -> leftInfo lit
|
|
EQUIP eit -> equipInfo eit
|
|
CONSUMABLE cit -> consumableInfo cit
|
|
CRAFT fit -> craftInfo fit
|
|
_ -> "THIS SHOULD NOT BE DISPLAYED"
|
|
|
|
showInt :: Int -> String
|
|
showInt i = case i of
|
|
0 -> "zero"
|
|
1 -> "one"
|
|
2 -> "two"
|
|
3 -> "three"
|
|
4 -> "four"
|
|
5 -> "five"
|
|
6 -> "six"
|
|
7 -> "seven"
|
|
8 -> "eight"
|
|
9 -> "nine"
|
|
10 -> "ten"
|
|
11 -> "eleven"
|
|
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."
|
|
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."
|
|
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."
|
|
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."
|
|
REPEATER -> "A firearm fed by a magazine. The entire magazine must be replaced when reloading the weapon."
|
|
AUTORIFLE -> "A firearm automatically fed by a magazine. The entire magazine must be replaced when reloading the weapon."
|
|
BURSTRIFLE -> "A firearm that rapidly fires three projectiles from its magazine. The entire magazine must be replaced when reloading the weapon."
|
|
BANGROD -> "A firearm with a long barrel that requires reloading after each shot."
|
|
ELEPHANTGUN -> "A firearm with a long barrel that requires reloading after each shot. Its stopping power is only nominal."
|
|
AMR -> "An antimateriel rifle, designed to disable military equipment. Its long barrel is fed by a magazine that must be replaced when reloading the weapon."
|
|
AUTOAMR -> "An automatic antimateriel rifle, designed to disable military equipment. Its long barrel is fed by a magazine that must be replaced when reloading the weapon."
|
|
SNIPERRIFLE -> "A firearm designed with long range capability in mind. Its long barrel requires reloading after each shot."
|
|
MACHINEGUN -> "A heavy firearm whose rate of fire increases during a barrage."
|
|
FLAMESPITTER -> "A weapon that globs out burning fuel."
|
|
FLAMETHROWER -> "A weapon that squirts out burning fuel."
|
|
FLAMETORRENT -> "A weapon that streams out burning fuel in a torrent."
|
|
FLAMEWALL -> "A weapon that squirts out burning fuel all around the user."
|
|
BLOWTORCH -> "A weapon that produces a concentrated flame."
|
|
SPARKGUN -> "A weapon that produces an arc of electricity. The arc will attempt to discharge at a nearby object."
|
|
TESLAGUN -> "A weapon that discharges a sustained arc of electricity. The arc will attempt to discharge at a nearby object."
|
|
LASGUN -> "A weapon that continuously emits photons in a narrow beam."
|
|
LASCIRCLE -> "A extensive configuration of prisms and mirrors that produces multiple laser beams around its user."
|
|
DUALBEAM -> "A weapon that emits two beams that converge at a selectable point in front of the user."
|
|
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."
|
|
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."
|
|
TORCH -> "A stick with a light on the end."
|
|
FLATSHIELD -> "A panel of metal that blocks unwanted objects from the front of the user."
|
|
KEYCARD i -> "A keycard. It is labelled " ++ show i ++ "."
|
|
|
|
leftInfo :: LeftItemType -> String
|
|
leftInfo lit = case lit of
|
|
BOOSTER -> "A device that allows travel at speed."
|
|
STOPWATCH -> "A device that temporarily pauses time."
|
|
REWINDWATCH -> "A device that rewinds time a short amount."
|
|
SCROLLWATCH -> "A device that can be used to scroll through recent events."
|
|
BLINKER -> "A device that allows local teleportation."
|
|
BLINKERUNSAFE -> "A device that allows local teleportation. Potentially hazardous around walls."
|
|
SHRINKER -> "A device that shrinks the user."
|
|
SPAWNER -> "A device that spawns creatures."
|
|
|
|
equipInfo :: EquipItemType -> String
|
|
equipInfo eit = case eit of
|
|
MAGSHIELD -> "A device designed to repulse nearby metallic objects."
|
|
FLAMESHIELD -> "A device designed to repulse nearby flames."
|
|
FRONTARMOUR -> "A device designed to shield from the front."
|
|
WRISTARMOUR -> "A device that projects a forcefield."
|
|
INVISIBILITYEQUIPMENT _ -> "A device that bends light around its user."
|
|
BRAINHAT -> "An iq enhancer. Useless."
|
|
HAT -> "A hat."
|
|
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. "
|
|
|
|
targetingInfo :: TargetType -> String
|
|
targetingInfo tt = case tt of
|
|
TargetLaser -> "creates a laser, the end of which becomes the target."
|
|
TargetRBPress -> "creates a fixed target."
|
|
TargetRBLine -> "creates a line target."
|
|
TargetRBCreature -> "targets a creature."
|
|
TargetCursor -> "creates a moving target."
|
|
|
|
consumableInfo :: ConsumableItemType -> String
|
|
consumableInfo cit = case cit of
|
|
MEDKIT _ -> "A self-use healing kit."
|
|
EXPLOSIVES -> "Explosives."
|
|
|
|
craftInfo :: CraftType -> String
|
|
craftInfo fit = case fit of
|
|
PIPE -> "A rigid cylinder."
|
|
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."
|
|
PLANK -> "A sturdy piece of wood."
|
|
GLASSSHARD -> "A broken piece of glass."
|
|
SCRAPMETAL -> "A broken piece of metal."
|
|
PUMP -> "A device that can create pressure."
|
|
MOTOR -> "A device that can create rotational force."
|
|
TRANSFORMER -> "A device that can step up or down voltage and current."
|
|
PRISM -> "An object that refracts light."
|
|
THERMOMETER -> "An object that measures temperature."
|
|
LIGHTER -> "A device that can create a small flame."
|
|
MAGNET -> "A device that attracts according to its dipoles."
|
|
ANTIMATTER -> "A collection of material with inverse quantum values."
|
|
PLATE -> "A flat rigid sheet."
|
|
TRANSMITTER -> "A device that can emit radio signals."
|
|
MICROCHIP -> "A miniturized collection of electronic circuits."
|
|
HARDDRIVE -> "A device designed to store data when unpowered."
|
|
RAM -> "A device that can store data when powered."
|
|
AIUNIT -> "A general purpose artificial intelligence unit."
|
|
CAMERA -> "A device designed to capture light signals."
|
|
MINIDISPLAY -> "A device designed to display pictures."
|
|
LED -> "A light emitting diode."
|
|
NAILBOX -> "A box of wood fastenings."
|
|
IRONBAR -> "A rigid piece of metal."
|
|
LIGHTSENSOR -> "A device that detects photons."
|
|
HEATSENSOR -> "An object that detects temperature."
|
|
SOUNDSENSOR -> "A device that detects air vibration."
|
|
MICROPHONE -> "A device that measures air vibration."
|
|
CREATURESENSOR -> "A device for detecting living beings."
|
|
WIRE -> "A small thin object that conducts electricity."
|
|
BATTERY -> "A store of electical potential energy."
|
|
FUELCELL -> "A devices that converts chemical energy into electricity."
|
|
PORTABLEFUSION -> "A miniature nuclear reactor."
|
|
GASINJECTOR -> "A device that can inject small quantities of gas into objects."
|
|
ENERGYBALLCRAFT ebt -> "A device that can create " ++ addIndefiniteArticle (displayEnergyBallType ebt) ++ " effect."
|
|
FRAGMODULE -> "A device that converts projectiles into fragmentation projectiles."
|
|
FLASHMODULE -> "A device that converts projectiles into flashbang projectiles."
|
|
BULBODYCRAFT be -> "A device that converts bullets into " ++ displayBulletBody be ++ " projectiles."
|
|
TELEPORTMODULE -> "A device that allows for near-instant translocation across space."
|
|
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
|
|
ITEMDETECTOR -> "items"
|
|
CREATUREDETECTOR -> "creatures"
|
|
WALLDETECTOR -> "walls"
|
|
|
|
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."
|
|
EQUIP _ -> "This item can be equipped " ++ itmEquipSiteInfo itm ++ "."
|
|
CONSUMABLE _ -> "This item can be consumed."
|
|
CRAFT _ -> ""
|
|
_ -> "THIS SHOULD NOT BE DISPLAYED"
|
|
|
|
heldPositionInfo :: Item -> String
|
|
heldPositionInfo = maybe undefined aimStanceInfo . (^? itUse . heldAim . aimStance)
|
|
|
|
aimStanceInfo :: AimStance -> String
|
|
aimStanceInfo as = case as of
|
|
TwoHandUnder -> "It is held in two hands and tucked under the shoulder."
|
|
TwoHandOver -> "It is held in two hands and over the shoulder."
|
|
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
|
|
itmEquipSiteInfo = maybe "" equipSiteInfo . (^? itUse . equipEffect . eeSite)
|
|
|
|
equipSiteInfo :: EquipSite -> String
|
|
equipSiteInfo es = case es of
|
|
GoesOnHead -> " on the head"
|
|
GoesOnChest -> " on the chest"
|
|
GoesOnBack -> " on the back"
|
|
GoesOnWrist -> " on a wrist"
|
|
GoesOnLegs -> " on both legs"
|
|
|
|
itmModuleInfo :: M.Map ModuleSlot ItemModuleType -> String
|
|
itmModuleInfo m
|
|
| m == mempty = ""
|
|
| 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)
|
|
|
|
makeCommaList :: [String] -> String
|
|
makeCommaList [] = ""
|
|
makeCommaList [x] = x ++ "."
|
|
makeCommaList [x, y] = x ++ " and " ++ y ++ "."
|
|
makeCommaList (x : xs) = x ++ ", " ++ makeCommaList xs
|
|
|
|
moduleInfo :: ModuleSlot -> String
|
|
moduleInfo imt = case imt of
|
|
ModBulletCollision -> "to affect how fired bullets collide with objects"
|
|
ModBulletPayload -> "to bullet payloads"
|
|
ModRifleMag -> "to the magazine"
|
|
ModAutoMag -> "to the magazine"
|
|
ModTarget -> "to add a targeting system or scope"
|
|
ModBulletTrajectory -> "to utilize any installed targeting system to affect the trajectory of fired bullets"
|
|
ModLauncherHoming -> "to add a homing system"
|
|
ModBattery -> "to its battery system"
|
|
ModTeleport -> "to add a teleporation system"
|
|
ModDualBeam -> "to the dual beams"
|
|
ModHeldAttach -> "to add an attachment that may have any number of effects"
|