programgames/trek/play.xtl
ᵘa̲rgs : (Num a, Num b) => a -> b -> Int
A command's arguments, asked for as the BASIC asks: a factor or a number of sectors only after a good course; nothing to fire with when there is nothing to fire at, or no torpedoes.
ᵘa̲rgs ← { s c → c = 3 ? ᵘc̲ourseAnd "WARP FACTOR 1-8 ?" c = 4 ? ᵘc̲ourseAnd "SECTORS 1-8 ?" (c = 5) ∧ 0 < ᵗh̲ere s ? ᵖn̲umber "ENERGY TO FIRE ?" (c = 6) ∧ 0 < ᵗt̲orps s ? ᵖn̲umber "TORPEDO COURSE 1-8 ?" c = 7 ? ᵖn̲umber "ENERGY TO SHIELDS (NEG=DRAIN) ?" 0 }
Used in: ᵘt̲urn
ᵘc̲ourseAnd : Char -> Int
ᵘc̲ourseAnd ← { prompt → c ← ᵖn̲umber "COURSE 1-8 ?" (c < 1) ∨ c > 8 ? c c̲at 0 c c̲at ᵖn̲umber prompt }
Used in: ᵘa̲rgs
ᵘt̲urn : Int -> Char
A turn: the menu, a command, its result, until the game is over.
ᵘt̲urn ← { s → 0 < ᵗs̲tatus s ? p̲rint! ᵗe̲nd s said ← p̲rint! "" said ← p̲rint! "1=SRS 2=LRS 3=WAR 4=IMP 5=PHA 6=TOR 7=SHE 8=STA 9=HEL 0=QUI" c ← ᵖn̲umber "COMMAND ?" ᵘt̲urn s ᵗc̲ommand c c̲at s ᵘa̲rgs c }