Skip to content

Commit

Permalink
fix monsters unable to attack selected hero
Browse files Browse the repository at this point in the history
I misuderstood how the action monad "abort" propagates through nested actions.
  • Loading branch information
Mikolaj committed Feb 4, 2011
1 parent 4f4fa31 commit 790861c
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/Actions.hs
Original file line number Diff line number Diff line change
Expand Up @@ -328,9 +328,9 @@ swapCurrentHero (ni, np) =
player <- gets splayer
let i = heroNumber player
upd hs = IM.insert i player $ IM.delete ni hs
when (ni == i) abort
modify (updateLevel (updateHeroes upd))
modify (updatePlayer (const np))
when (ni /= i) (do
modify (updateLevel (updateHeroes upd))
modify (updatePlayer (const np)))

-- | Calculate loot's worth. TODO: move to another module, and refine significantly. TODO: calculate for all heroes on the current level.
calculateTotal :: Hero -> Int
Expand Down

0 comments on commit 790861c

Please sign in to comment.