programgames/trek-adventure/play.xtl

source · imports t: games/trek-adventure/TrekAdventure.xtl; p: lib/Play.xtl

ᵘl̲ist : Num a => Int -> a

function · line 11

The items here as the TAKE menu lists them, " 3=TOOLKIT".

ᵘl̲ist ← { v →
  0 = t̲ally v ? 0
  shown ← p̲rint! @ f̲ormat< "  {f_irst v}={d_isclose (f_irst v) s_elect t:i_tems @}"
  1 + ᵘl̲ist 1 d̲rop v
}
f̲ormat< expands to
("  " c̲at (f̲ormat (f̲irst v)) c̲at "=" c̲at (f̲ormat (d̲isclose (f̲irst v) s̲elect ᵗi̲tems @)))

ᵘa̲rg : (Num a, Num b) => a -> b -> Int

function · line 19

The argument a command asks for: a room for GO, an item for TAKE (0 when there is nothing to take) and USE, else none.

ᵘa̲rg ← { s c →
  c = 3 ? ᵖn̲umber "GO TO ROOM# ?"
  c = 4 ? ᵘt̲akeWhat s
  c = 5 ? ᵘu̲seWhat s
  0
}
Used in: ᵘt̲urn

ᵘt̲akeWhat : Num a => a -> Int

function · line 25
ᵘt̲akeWhat ← { s →
  said ← p̲rint! "TAKE WHAT?"
  here ← ᵗp̲resent s
  0 = t̲ally here ? 0
  listed ← ᵘl̲ist here
  ᵖn̲umber "ITEM# ?"
}
Used in: ᵘa̲rg

ᵘu̲seWhat : Num a => a -> Int

function · line 32
ᵘu̲seWhat ← { s →
  said ← p̲rint! "USE WHAT?"
  said ← p̲rint! "1=TOOLKIT 2=COUPLER 3=COMPUTER"
  ᵖn̲umber "ITEM# ?"
}
Used in: ᵘa̲rg

ᵘt̲urn : Num a => Int -> a

function · line 39

A turn: the room, the menu, a command, what it says, the clock.

ᵘt̲urn ← { s →
  0 < ᵗs̲tatus s ? s ᵗs̲ay 200 + ᵗs̲tatus s
  said ← p̲rint! "----------------------------------------"
  said ← p̲rint! @ f̲ormat< "TURNS LEFT {t:t_urns s}"
  said ← p̲rint! ""
  said ← s ᵗs̲ay ᵗr̲oom s
  said ← p̲rint! ""
  said ← p̲rint! "1=LOOK 2=INV  3=GO    4=TAKE"
  said ← p̲rint! "5=USE  6=THROW 7=FIRE 8=HELP 0=QUIT"
  c ← ᵖn̲umber "COMMAND ?"
  c = 0 ? s ᵗs̲ay 204
  next ← s ᵗm̲ove c c̲at s ᵘa̲rg c
  said ← next ᵗs̲ay ᵗs̲aid next
  later ← ᵗc̲lock next
  said ← later ᵗs̲ay ᵗa̲larms later
  ᵘt̲urn later
}
f̲ormat< expands to
("TURNS LEFT " c̲at (f̲ormat (ᵗt̲urns s)))
Used in: ᵘt̲urn, done

s : Int

value · line 56
s ← ᵗn̲ew 0
Used in: ᵘt̲urn, said, done

said : Int

value · line 57
said ← s ᵗs̲ay 300

done : Int

value · line 58
done ← ᵘt̲urn s