RCRPG/Nim: Difference between revisions

no edit summary
(Created page with "{{collection|RCRPG}} This Nim version proposes the following commands: – alias <alias name> <command>: define an alias. – aliases: list aliases. – attack <direction>:...")
 
No edit summary
Line 4:
 
– alias <alias name> <command>: define an alias.
 
– aliases: list aliases.
 
– attack <direction>: use sledge to dig a tunnel in the given direction.
 
– drop all | <item>: drop all items or a specified item.
 
– east: move to East.
 
– equip <item>: equip an item present in inventory.
 
– help: display the list of commands and directions.
 
– inventory: list items in the inventory.
 
– look: display location, items and exits.
 
– name <name>: give a name to the current room.
 
– north: move to North.
 
– south: move to South.
 
– quit: quit game.
 
– take all | <item>: take all items or a specified item.
 
– unequip: unequip the equipped item.
 
– west: move to West.
 
 
Directions are: north, east, south, west, up, down.
 
==Code==
Line 57 ⟶ 75:
 
# Command names and number of tokens required for this command.
Commands = [({"alias",: 3), ("aliases",: 1), ("quit",: 1), ("name",: 2), ("look",: 1),
("help",: 1), ("north",: 1), ("east",: 1), ("south",: 1), ("west",: 1),
("up",: 1), ("down",: 1), ("attack",: 2), ("inventory",: 1),
("take",: 2), ("drop",: 2), ("equip",: 2), ("unequip",: 1)]}.toTable()
 
StartRoomPos: Position = (0, 0, 0)
Line 69 ⟶ 87:
# Miscellaneous.
 
func nextPos(oldCoordsoldPos: Position; direction: Direction): Position =
## Compute new coordinates from current position and direction.
(oldCoordsoldPos.x + IncPos[direction].x,
oldCoordsoldPos.y + IncPos[direction].y,
oldCoordsoldPos.z + IncPos[direction].z)
 
#___________________________________________________________________________________________________
Line 169 ⟶ 187:
items: @[gold, gold, gold, gold, gold])
# Create room names.
result.roomNames = [({StartRoomPos,: "the starting room"),
(PrizeRoomPos,: "the prize room")]}. toTable()
# Create aliases.
result.aliases = [({"n",: "north"), ("e",: "east"), ("s",: "south"), "w": "west", "u": "up",
("wd",: "westdown"), ("ua",: "upattack"), ("di": "inventory", "downl": "look"}.toTable(),
("a", "attack"), ("i", "inventory"), ("l", "look")].toTable()
 
#___________________________________________________________________________________________________
Anonymous user