about summary refs log tree commit diff
path: root/src/Xanthous/Game.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/Xanthous/Game.hs')
-rw-r--r--src/Xanthous/Game.hs12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/Xanthous/Game.hs b/src/Xanthous/Game.hs
index 39066c23b622..dffd0a9c6a6d 100644
--- a/src/Xanthous/Game.hs
+++ b/src/Xanthous/Game.hs
@@ -14,6 +14,8 @@ module Xanthous.Game
 
   , MessageHistory(..)
   , pushMessage
+  , popMessage
+  , hideMessage
   ) where
 
 import           Data.List.NonEmpty ( NonEmpty((:|)))
@@ -43,6 +45,16 @@ pushMessage :: Text -> MessageHistory -> MessageHistory
 pushMessage msg NoMessageHistory = MessageHistory (msg :| []) True
 pushMessage msg (MessageHistory msgs _) = MessageHistory (NonEmpty.cons msg msgs) True
 
+popMessage :: MessageHistory -> MessageHistory
+popMessage NoMessageHistory = NoMessageHistory
+popMessage (MessageHistory msgs False) = MessageHistory msgs True
+popMessage (MessageHistory msgs@(_ :| []) _) = MessageHistory msgs True
+popMessage (MessageHistory (_ :| (msg : msgs)) True) = MessageHistory (msg :| msgs) True
+
+hideMessage :: MessageHistory -> MessageHistory
+hideMessage NoMessageHistory = NoMessageHistory
+hideMessage (MessageHistory msgs _) = MessageHistory msgs False
+
 data GameState = GameState
   { _entities          :: EntityMap SomeEntity
   , _characterEntityID :: EntityID