Permalink
Browse files

a bugfix and a few tweaks to items and effects

  • Loading branch information...
Mikolaj committed Mar 29, 2011
1 parent 50ed98f commit 273aa668cb5b7ea4dd2ddcf30f62e1d0bbf0c4f6
Showing with 17 additions and 14 deletions.
  1. +2 −2 src/Effect.hs
  2. +3 −3 src/EffectAction.hs
  3. +8 −5 src/Item.hs
  4. +3 −3 src/ItemAction.hs
  5. +1 −1 src/ItemKind.hs
View
@@ -2,7 +2,7 @@ module Effect where
data Effect =
NoEffect
- | Heal Int
+ | Heal -- healing strength in ipower
| Wound Int -- base damage, to-dam bonus in ipower
| Dominate
| SummonFriend
@@ -12,7 +12,7 @@ data Effect =
effectToName :: Effect -> String
effectToName NoEffect = ""
-effectToName (Heal n) = "of healing (" ++ show n ++ ")"
+effectToName Heal = "of healing"
effectToName (Wound n) = "(" ++ show n ++ "d1)"
effectToName Dominate = "of domination"
effectToName SummonFriend = "of aid calling"
View
@@ -46,13 +46,13 @@ effectToAction Effect.NoEffect source target power msg = do
pl <- gets splayer
when (source == pl) $ messageAdd "Nothing happens."
return False
-effectToAction (Effect.Heal n) source target power msg = do
+effectToAction Effect.Heal source target power msg = do
m <- gets (getActor target)
- if mhp m >= nhpMax (mkind m) || n + power <= 0
+ if mhp m >= nhpMax (mkind m) || power <= 0
then return False
else do
focusIfAHero target
- let upd m = m { mhp = min (nhpMax (mkind m)) (mhp m + n + power) }
+ let upd m = m { mhp = min (nhpMax (mkind m)) (mhp m + power) }
updateAnyActor target upd
pl <- gets splayer
when (target == pl) $ messageAdd "You feel better." -- TODO: use msg, if perceived, etc.
View
@@ -12,6 +12,7 @@ import Control.Monad
import Random
import ItemKind
import qualified Color
+import qualified Effect -- TODO: get rid of ASAP
data Item = Item
{ ikind :: !Int,
@@ -62,11 +63,13 @@ viewItem ik assocs = (jsymbol (getIK ik), flavourToColor $ getFlavour assocs ik)
-- Not really satisfactory. Should be configurable, not hardcoded.
itemStrength :: Int -> ItemKind -> Rnd Int
itemStrength n ik =
- if jname ik /= "sword"
- then return 0
- else do
- r <- d (2 + n `div` 2)
- return $ (n + 1) `div` 3 + r
+ case jname ik of
+ "sword" -> do
+ r <- d (2 + n `div` 2)
+ return $ (n + 1) `div` 3 + r
+ "potion" | jeffect ik == Effect.Heal ->
+ return 10
+ _ -> return 0
itemLetter :: ItemKind -> Maybe Char
itemLetter ik = if jsymbol ik == '$' then Just '$' else Nothing
View
@@ -60,7 +60,7 @@ getGroupItem :: [Item] -> -- all objects in question
String -> -- how to refer to the collection of objects
Action (Maybe Item)
getGroupItem is groupName prompt packName =
- let choice i = packName == ItemKind.jname (ItemKind.getIK (ikind i))
+ let choice i = groupName == ItemKind.jname (ItemKind.getIK (ikind i))
header = capitalize $ suffixS groupName
in getItem prompt choice header is packName
@@ -81,7 +81,7 @@ applyGroupItem groupName verb = do
-- only one item consumed, even if several in inventory
let v = if ItemKind.jname (ItemKind.getIK ik) == groupName
then verb
- else "somehow apply"
+ else "creatively apply"
consumed = item { icount = 1 }
message (subjectVerbIObject state pbody v consumed "")
pl <- gets splayer
@@ -110,7 +110,7 @@ zapGroupItem groupName verb = do
-- only one item consumed, even if several in inventory
let v = if ItemKind.jname (ItemKind.getIK ik) == groupName
then verb
- else "somehow zap"
+ else "furiously zap"
consumed = item { icount = 1 }
removeFromInventory consumed
case targetToLoc (ptvisible per) state of
View
@@ -106,7 +106,7 @@ potion_water = potion
{ jeffect = ApplyWater
}
potion_healing = potion
- { jeffect = Heal 10
+ { jeffect = Heal
}
potion_wounding = potion
{ jeffect = Wound 10

0 comments on commit 273aa66

Please sign in to comment.