33 lines
1.5 KiB
Fennel
33 lines
1.5 KiB
Fennel
(fn wrap [str limit indent indent1]
|
|
(let [indent (or indent "")
|
|
indent1 (or indent1 indent)
|
|
limit (or limit 72)
|
|
]
|
|
(var here (- 1 (# indent1)))
|
|
(fn check [sp st word fi]
|
|
(when (> (- fi here) limit)
|
|
(set here (- st (# indent)))
|
|
(.. "\n" indent word)))
|
|
(.. indent1 (: str :gsub "(%s+)()(%S+)()" check))
|
|
)
|
|
)
|
|
|
|
|
|
(fn reflow [str limit indent indent1]
|
|
(doto (str:gsub "%s*\n%s+" "\n")
|
|
(: :gsub "%s%s+" " ")
|
|
(: :gsub "[^\n]+" (fn [line] (wrap line limit indent indent1)))
|
|
)
|
|
)
|
|
|
|
|
|
(local words "Okay ceelo is a fun dice game. It is a point-set gambling game, kind of like craps, but is more simple, and you play it with three six-sided dice.\n\n== ROLLS ==\n\nFirst, here's what the rolls mean.\n\n1. Win conditions:\n\n- n n n (triples) = instant win.\n example: 3 3 3\n\n- 4 5 6 = instant win\n\n- n n 6 (any doubles + 6) = instant win. e.g.\n example: 2 2 6\n\n2. Loss conditions:\n\n- n n 1 (any doubles + 1) = instant loss\n example: 6 6 1\n\n- 1 2 3 = instant loss\n\n3. Points:\n\n- n n x (doubles + not 6, not 1) = establish a POINT\n example: 3 3 4\n\n\nReroll:\n\n- anything else = reroll\n\n== PLAY ==\n\nNow, here's how to play.\n\n1. Make a bet against the Bank.\n\n2. The Bank will roll and will either win, lose, or establish a point.\n\n3. If a point is established, you get to roll until you win outright or beat the point, or lose, or draw.\n\nThat's it! Go play!\n\nPress Enter to continue.\n")
|
|
|
|
(print (wrap words))
|
|
|
|
|
|
{
|
|
:wrap wrap
|
|
:reflow reflow
|
|
}
|