generated from liam-ilan/crumb-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrewordle.crumb
54 lines (46 loc) · 1.42 KB
/
rewordle.crumb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
// state access constants
APP_XY = 0
GAME = 1
WORD_INDEX = 2
ANSWER = 3
STATUS = 4
INPLAY = 5
USED = 6
RESULTS = 7
STREAK = 8
X = 0
Y = 1
state = (use "./usables/tui.crumb" "./usables/colors.crumb" "./src/elements.crumb" "./src/storage.crumb" {
// game rules
valid_words = (read_file "./data/valid.txt")
play_words = (read_file "./data/play.txt")
from_storage = (read)
// app pos
x = (integer (divide (subtract (columns) app_width) 2)) // center position on x
y = (integer (divide (subtract (rows) app_height) 2)) // center position on y
// last word played
word_index = (integer (get from_storage 2))
// stats from storage
stats_results = (map (split (get from_storage 0) ":") { item _ -> <- (integer item)})
stats_streak = (map (split (get from_storage 1) ":") { item _ -> <- (integer item)})
// set state
state = (list
(list x y) // screen anchor
0 // the game status: 0 = in play, 1 = win, 2 = lose
word_index // the index of the played from the list of words
(get play_words (multiply word_index 6) (add (multiply word_index 6) 5)) // word in play
(list // board state
(list " " " " " " " " " ")
(list " " " " " " " " " ")
(list " " " " " " " " " ")
(list " " " " " " " " " ")
(list " " " " " " " " " ")
(list " " " " " " " " " ")
)
0 // index of line in play
(list)
stats_results
stats_streak
)
<- (start state elements void)
})