Skip to content

Commit b7a9d7e

Browse files
committedNov 29, 2022
Remove ElixirFM dep, rip out Lua-related nonsense.
The GameState type and such are now gone.
1 parent 1dc6498 commit b7a9d7e

File tree

6 files changed

+188
-346
lines changed

6 files changed

+188
-346
lines changed
 

‎babel-cards.cabal

+2-4
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ cabal-version: 1.12
44
--
55
-- see: https://github.com/sol/hpack
66
--
7-
-- hash: 8a344dcc26aef96c7290cf75ca42ad8bcfb97dbaef4eed426e446c9ea3d8be76
7+
-- hash: 6f7185888cb6f6b8d75f48b073a27cc2471605c905e4bef74ae01af8f7dd6ac1
88

99
name: babel-cards
1010
version: 0.1.0
@@ -43,7 +43,6 @@ library
4343
Model
4444
Settings
4545
Types
46-
Types.Free
4746
Types.Review
4847
Types.TUI
4948
Util.String
@@ -53,8 +52,7 @@ library
5352
src
5453
ghc-options: -Wall -Wcompat -Widentities -Wincomplete-record-updates -Wincomplete-uni-patterns -Wpartial-fields -Wredundant-constraints
5554
build-depends:
56-
ElixirFM
57-
, aeson
55+
aeson
5856
, base >=4.11 && <10
5957
, brick
6058
, bytestring

‎package.yaml

-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ library:
5454
- bytestring
5555
- containers
5656
- directory
57-
- ElixirFM
5857
- edit-distance
5958
- esqueleto
6059
- file-embed

‎src/Application/TUI.hs

+178-225
Large diffs are not rendered by default.

‎src/Types/Free.hs

-60
This file was deleted.

‎src/Types/TUI.hs

+8-52
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,7 @@ module Types.TUI where
77
import Brick.BChan (BChan)
88
import Brick.Forms (Form)
99
import Brick.Widgets.List (GenericList)
10-
import Data.IntMap.Strict (IntMap)
11-
import Data.Map.Strict (Map)
12-
import Data.Sequence (Seq)
13-
import Data.Text (Text)
10+
import RIO.Time (UTCTime)
1411
import Database.Persist.Types (Entity)
1512
import Lens.Micro.TH
1613
import Model
@@ -22,7 +19,13 @@ data BabelTUI = BabelTUI
2219
, babelTUIView :: !BabelView
2320
, babelTUIChan :: !(BChan BabelEvent)
2421

25-
, babelTUIGameState :: !(Maybe GameState)
22+
-- Review state
23+
, babelTUIMatchMode :: !(Maybe BabelMode)
24+
, babelTUIActiveCard :: !(Maybe (Entity Card))
25+
, babelTUIUserAnswer :: !(Maybe Text)
26+
, babelTUIAnswerDistance :: !(Maybe Int)
27+
, babelTUIReviewStartTimestamp :: !(Maybe UTCTime)
28+
, babelTUIReviewEndTimestamp :: !(Maybe UTCTime)
2629

2730
, babelTUIFocusX :: !Int
2831
-- ^ Left-to-right focus.
@@ -81,28 +84,10 @@ data BabelEvent =
8184
| LoadTagCards
8285

8386

84-
-- TODO: we can't delegate quite as much responsibility to Lua
85-
-- as we thought.
86-
-- - init will have to get a few constants: number of cards
87-
-- to draw, what display mode (once implemented)
88-
-- - state transition will have to be managed by haskell. Lua
89-
-- will provide hooks into it, such as how to compare user
90-
-- input to the card to ascertain correctness
91-
-- - I don't know how to make many types of game possible! thus
92-
-- LUA is on hold until this is hammered out through the
93-
-- built-in modes!
9487
data BabelMode =
9588
Standard
9689
| Reverse
9790
deriving Show
98-
-- NOTE: Lua scripting is on hold until I learn the requirements
99-
-- of modes of operation in order to better architect the
100-
-- interface
101-
-- | BabelMode
102-
-- { babelModeInitGame :: !(Lua ())
103-
-- , babelModeStateTransition :: !(Lua ())
104-
-- , babelModeDetermineEnd :: !(Lua Bool)
105-
-- }
10691

10792
data BabelView =
10893
Start
@@ -126,24 +111,6 @@ data BabelView =
126111
| TagManagement
127112
| Credits
128113

129-
-- | TODO
130-
data GameState = GameState
131-
{ gameStateMode :: !BabelMode
132-
, gameStateCards :: ![Maybe (Entity Card)]
133-
-- ^ Cards in play. A @Nothing@ indicates an empty
134-
-- slot for purposes where many cards are shown at
135-
-- once.
136-
, gameStateScore :: !Int
137-
-- ^ Fun! :D
138-
, gameStateDict :: !(Map Text Text)
139-
-- ^ A dictionary for more complex scripts to store
140-
-- and retrieve data.
141-
, gameStateUserInputStack :: ![UserInput]
142-
-- ^ User input. This will be consulted to determine
143-
-- whether the user answered correctly.
144-
, gameStateMessagesStack :: ![String]
145-
}
146-
147114
data CardFormState = CardFormState
148115
{ cardFormStateObverse :: Text
149116
, cardFormStateReverse :: Text
@@ -158,15 +125,4 @@ data UserInput =
158125
makeFields ''CardFormState
159126
makeFields ''CardMetadata
160127
makeFields ''DeckMetadata
161-
makeFields ''GameState
162128
makeFields ''BabelTUI
163-
164-
-- emptyGameState :: GameState
165-
-- emptyGameState = GameState
166-
-- { gameStateMode = Standard
167-
-- , gameStateCards = mempty
168-
-- , gameStateScore = 0
169-
-- , gameStateDict = mempty
170-
-- , gameStateUserInputStack = mempty
171-
-- , gameStateMessagesStack = mempty
172-
-- }

‎stack.yaml

-4
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,6 @@ packages:
4040
# commit: e7b331f14bcffb8367cd58fbfc8b40ec7642100a
4141
#
4242
extra-deps:
43-
- git: https://github.com/otakar-smrz/elixir-fm.git
44-
commit: 08bc422191d2d376015109207cbf82bf5196adae
45-
subdirs:
46-
- Haskell/ElixirFM
4743
- Encode-1.3.8@sha256:a93798e8ae38b3616468249eee4ce15b7cc995a04b182213bfe1292e1a0baf33,7757
4844
- wl-pprint-1.2.1@sha256:aea676cff4a062d7d912149d270e33f5bb0c01b68a9db46ff13b438141ff4b7c,734
4945

0 commit comments

Comments
 (0)
Please sign in to comment.