Allow eating edible items
Add menu support to the prompt system, and an "Eat" command that prompts for an item to eat and eats the item the character specifies, restoring an amount of hitpoints configurable via the item raw type.
This commit is contained in:
parent
262fc7fb41
commit
de8052cef8
16 changed files with 289 additions and 73 deletions
|
|
@ -37,13 +37,19 @@ drawMessages = txt . (<> " ") . unwords . oextract
|
|||
|
||||
drawPromptState :: GamePromptState m -> Widget Name
|
||||
drawPromptState NoPrompt = emptyWidget
|
||||
drawPromptState (WaitingPrompt msg (Prompt _ pt ps _)) =
|
||||
case (pt, ps) of
|
||||
(SStringPrompt, StringPromptState edit) ->
|
||||
drawPromptState (WaitingPrompt msg (Prompt _ pt ps pri _)) =
|
||||
case (pt, ps, pri) of
|
||||
(SStringPrompt, StringPromptState edit, _) ->
|
||||
txt msg <+> renderEditor (txt . fold) True edit
|
||||
(SDirectionPrompt, DirectionPromptState) -> txt msg
|
||||
(SContinue, _) -> txt msg
|
||||
(SDirectionPrompt, DirectionPromptState, _) -> txt msg
|
||||
(SContinue, _, _) -> txt msg
|
||||
(SMenu, _, menuItems) ->
|
||||
txt msg
|
||||
<=> foldl' (<=>) emptyWidget (map drawMenuItem $ itoList menuItems)
|
||||
_ -> undefined
|
||||
where
|
||||
drawMenuItem (chr, MenuOption m _) =
|
||||
str ("[" <> pure chr <> "] ") <+> txt m
|
||||
|
||||
drawEntities
|
||||
:: (Position -> Bool)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue