Gormlaks attack back
When gormlaks see the character, they step towards them and attack dealing 1 damage when adjacent. Characters have hitpoints now, displayed at the bottom of the game screen, and when the game is over they die.
This commit is contained in:
parent
ec39dc0a5b
commit
05da490185
11 changed files with 163 additions and 22 deletions
|
|
@ -14,11 +14,13 @@ import Xanthous.Data (Position(Position), x, y, loc)
|
|||
import Xanthous.Data.EntityMap (EntityMap, atPosition)
|
||||
import qualified Xanthous.Data.EntityMap as EntityMap
|
||||
import Xanthous.Entities
|
||||
import Xanthous.Entities.Character
|
||||
import Xanthous.Game
|
||||
( GameState(..)
|
||||
, entities
|
||||
, revealedPositions
|
||||
, characterPosition
|
||||
, character
|
||||
, MessageHistory(..)
|
||||
, messageHistory
|
||||
, GamePromptState(..)
|
||||
|
|
@ -42,8 +44,8 @@ drawPromptState (WaitingPrompt msg (Prompt _ pt ps _)) =
|
|||
case (pt, ps) of
|
||||
(SStringPrompt, StringPromptState edit) ->
|
||||
txt msg <+> renderEditor (txt . fold) True edit
|
||||
(SDirectionPrompt, DirectionPromptState) ->
|
||||
txt msg
|
||||
(SDirectionPrompt, DirectionPromptState) -> txt msg
|
||||
(SContinue, _) -> txt msg
|
||||
_ -> undefined
|
||||
|
||||
drawEntities
|
||||
|
|
@ -79,6 +81,17 @@ drawMap game
|
|||
-- character can't see them
|
||||
(game ^. entities)
|
||||
|
||||
drawCharacterInfo :: Character -> Widget Name
|
||||
drawCharacterInfo ch = txt " " <+> charName <+> charHitpoints
|
||||
where
|
||||
charName | Just n <- ch ^. characterName
|
||||
= txt n <+> txt " "
|
||||
| otherwise
|
||||
= emptyWidget
|
||||
charHitpoints
|
||||
= txt "Hitpoints: "
|
||||
<+> txt (tshow $ ch ^. characterHitpoints)
|
||||
|
||||
drawGame :: GameState -> [Widget Name]
|
||||
drawGame game
|
||||
= pure
|
||||
|
|
@ -86,3 +99,4 @@ drawGame game
|
|||
$ drawMessages (game ^. messageHistory)
|
||||
<=> drawPromptState (game ^. promptState)
|
||||
<=> border (drawMap game)
|
||||
<=> drawCharacterInfo (game ^. character)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue