feat(grfn/xanthous): Use dual-wielding to calculate damage
When dual-wielding weapons, do damage from both weapons and use both weapons' attack messages. Change-Id: I3c404946d0167c9b5c2bcf58ab5c3429cc5269fc Reviewed-on: https://cl.tvl.fyi/c/depot/+/5605 Autosubmit: grfn <grfn@gws.fyi> Tested-by: BuildkiteCI Reviewed-by: grfn <grfn@gws.fyi>
This commit is contained in:
parent
194007b020
commit
af31da8cfc
6 changed files with 33 additions and 17 deletions
|
@ -467,19 +467,24 @@ attackAt pos =
|
|||
attackCreature creature = do
|
||||
charDamage <- uses character characterDamage
|
||||
creature' <- damageCreature creature charDamage
|
||||
msg <- uses character getAttackMessage
|
||||
unless (Creature.isDead creature')
|
||||
. message msg $ object ["creature" A..= creature']
|
||||
unless (Creature.isDead creature') $ writeAttackMessage creature'
|
||||
whenM (uses character $ isNothing . weapon) handleFists
|
||||
stepGame
|
||||
weapon chr = chr ^? inventory . wielded . wieldedItems . wieldableItem
|
||||
getAttackMessage chr =
|
||||
case weapon chr of
|
||||
Just wi ->
|
||||
fromMaybe (Messages.lookup ["combat", "hit", "generic"])
|
||||
$ wi ^. attackMessage
|
||||
Nothing ->
|
||||
Messages.lookup ["combat", "hit", "fists"]
|
||||
writeAttackMessage creature = do
|
||||
let params = object ["creature" A..= creature]
|
||||
attackMessages <- uses character getAttackMessages
|
||||
msg <- intercalate " and " <$> for attackMessages (`Messages.render` params)
|
||||
writeMessage $ "You " <> msg
|
||||
getAttackMessages chr =
|
||||
case chr ^.. inventory . wielded . wieldedItems . wieldableItem of
|
||||
[] -> [Messages.lookup ["combat", "hit", "fists"]]
|
||||
is ->
|
||||
is
|
||||
<&> \wi ->
|
||||
fromMaybe (Messages.lookup ["combat", "hit", "generic"])
|
||||
$ wi ^. attackMessage
|
||||
|
||||
|
||||
handleFists = do
|
||||
damageChance <- use $ character . body . knuckles . to fistDamageChance
|
||||
|
|
|
@ -218,7 +218,9 @@ defaultCharacterDamage = 1
|
|||
characterDamage :: Character -> Hitpoints
|
||||
characterDamage
|
||||
= fromMaybe defaultCharacterDamage
|
||||
. preview (inventory . wielded . wieldedItems . wieldableItem . Raw.damage)
|
||||
. filter (/= 0)
|
||||
. Just
|
||||
. sumOf (inventory . wielded . wieldedItems . wieldableItem . Raw.damage)
|
||||
|
||||
-- | Is the character fully healed up to or past their initial hitpoints?
|
||||
isFullyHealed :: Character -> Bool
|
||||
|
|
|
@ -200,6 +200,15 @@ makeFieldsNoPrefix ''EdibleItem
|
|||
|
||||
data WieldableItem = WieldableItem
|
||||
{ _damage :: !Hitpoints
|
||||
-- | Message to use when the character is using this item to attack a
|
||||
-- creature.
|
||||
--
|
||||
-- Grammatically, this should be of the form "slash at the
|
||||
-- {{creature.creatureType.name}} with your dagger"
|
||||
--
|
||||
-- = Parameters
|
||||
--
|
||||
-- [@creature@ (type: 'Creature')] The creature being attacked
|
||||
, _attackMessage :: !(Maybe Message)
|
||||
-- | Message to use when a creature is using this item to attack the
|
||||
-- character.
|
||||
|
|
|
@ -9,8 +9,8 @@ Item:
|
|||
wieldable:
|
||||
damage: 3
|
||||
attackMessage:
|
||||
- You slash at the {{creature.creatureType.name}} with your dagger.
|
||||
- You stab the {{creature.creatureType.name}} with your dagger.
|
||||
- slash at the {{creature.creatureType.name}} with your dagger
|
||||
- stab the {{creature.creatureType.name}} with your dagger
|
||||
creatureAttackMessage:
|
||||
- The {{creature.creatureType.name}} slashes at you with its dagger.
|
||||
- The {{creature.creatureType.name}} stabs you with its dagger.
|
||||
|
|
|
@ -5,6 +5,6 @@ Item:
|
|||
char: .
|
||||
wieldable:
|
||||
damage: 1
|
||||
attackMessage: you hit the {{creature.creatureType.name}} in the head with your rock.
|
||||
attackMessage: hit the {{creature.creatureType.name}} in the head with your rock
|
||||
density: [ 1500000, 2500000 ]
|
||||
volume: [ 0.000125, 0.001 ]
|
||||
|
|
|
@ -9,9 +9,9 @@ Item:
|
|||
wieldable:
|
||||
damage: 2
|
||||
attackMessage:
|
||||
- You bonk the {{creature.creatureType.name}} over the head with your stick.
|
||||
- You bash the {{creature.creatureType.name}} on the noggin with your stick.
|
||||
- You whack the {{creature.creatureType.name}} with your stick.
|
||||
- bonk the {{creature.creatureType.name}} over the head with your stick
|
||||
- bash the {{creature.creatureType.name}} on the noggin with your stick
|
||||
- whack the {{creature.creatureType.name}} with your stick
|
||||
creatureAttackMessage:
|
||||
- The {{creature.creatureType.name}} bonks you over the head with its stick.
|
||||
- The {{creature.creatureType.name}} bashes you on the noggin with its stick.
|
||||
|
|
Loading…
Reference in a new issue