about summary refs log tree commit diff
path: root/src/Xanthous/Resource.hs
diff options
context:
space:
mode:
authorGriffin Smith <root@gws.fyi>2019-12-01T03·43-0500
committerGriffin Smith <root@gws.fyi>2019-12-01T03·43-0500
commit65b1352ef2e463393d0504c32b73bdcf7c99491a (patch)
tree9bbd627db18babdeff099d7a248103e2148a93f8 /src/Xanthous/Resource.hs
parent71b628c604556bc2d829f12980db99c9a526ec84 (diff)
Add a very basic inventory panel
Add a very basic inventory panel to the game opened by pressing `i`,
which displays the contents of the player's inventory in a basic list.
Diffstat (limited to 'src/Xanthous/Resource.hs')
-rw-r--r--src/Xanthous/Resource.hs35
1 files changed, 21 insertions, 14 deletions
diff --git a/src/Xanthous/Resource.hs b/src/Xanthous/Resource.hs
index 5350e7646e..cc2fc97a14 100644
--- a/src/Xanthous/Resource.hs
+++ b/src/Xanthous/Resource.hs
@@ -1,24 +1,31 @@
 --------------------------------------------------------------------------------
 module Xanthous.Resource
-  ( Name(..)
+  ( Panel(..)
+  , Name(..)
   ) where
 --------------------------------------------------------------------------------
 import Xanthous.Prelude
 --------------------------------------------------------------------------------
 import Test.QuickCheck
-import Test.QuickCheck.Arbitrary.Generic
+import Data.Aeson (ToJSON, FromJSON)
+--------------------------------------------------------------------------------
+import Xanthous.Util.QuickCheck
 --------------------------------------------------------------------------------
 
-data Name = MapViewport
-            -- ^ The main viewport where we display the game content
-          | Character
-            -- ^ The character
-          | MessageBox
-            -- ^ The box where we display messages to the user
-          | Prompt
-            -- ^ The game's prompt
-  deriving stock (Show, Eq, Ord, Generic)
-  deriving anyclass (NFData, CoArbitrary, Function)
+-- | Enum for "panels" displayed in the game's UI.
+data Panel
+  = InventoryPanel -- ^ A panel displaying the character's inventory
+  deriving stock (Show, Eq, Ord, Generic, Enum, Bounded)
+  deriving anyclass (NFData, CoArbitrary, Function, ToJSON, FromJSON)
+  deriving Arbitrary via GenericArbitrary Panel
 
-instance Arbitrary Name where
-  arbitrary = genericArbitrary
+
+data Name
+  = MapViewport -- ^ The main viewport where we display the game content
+  | Character   -- ^ The character
+  | MessageBox  -- ^ The box where we display messages to the user
+  | Prompt      -- ^ The game's prompt
+  | Panel Panel -- ^ A panel in the game
+  deriving stock (Show, Eq, Ord, Generic)
+  deriving anyclass (NFData, CoArbitrary, Function, ToJSON, FromJSON)
+  deriving Arbitrary via GenericArbitrary Name