Skip to content

Instantly share code, notes, and snippets.

@JeremyLikness
Created July 30, 2016 14:48
Show Gist options
  • Select an option

  • Save JeremyLikness/cf861efa68da1d9f2d208b122c5c4439 to your computer and use it in GitHub Desktop.

Select an option

Save JeremyLikness/cf861efa68da1d9f2d208b122c5c4439 to your computer and use it in GitHub Desktop.
const checkGet: (dungeon: Dungeon) => IAction = (dungeon: Dungeon) => {
if (dungeon.currentRoom.things.length < 1) {
return {
type: ACTION_TEXT,
text: 'You get down.'
} as ITextAction;
}
let invCount = dungeon.inventory.length + 1;
if (dungeon.trophyCount === invCount) {
return {
type: ACTION_WON,
item: dungeon.currentRoom.things[0],
room: dungeon.currentRoom
} as IWonAction;
}
return {
type: ACTION_GET,
item: dungeon.currentRoom.things[0],
room: dungeon.currentRoom
} as IInventoryAction;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment