Appendix 2: Adding Rooms to the Game
Find extra challenges to the game you developed.
We'll cover the following...
A game where you only face an enemy and find an exit isn’t that interesting. A game should have more challenges and places to explore. You can use your imagination to create additional interesting ideas for the game you built in Chapter 7, Designing Your Elixir Applications. Here are some suggestions that you can implement in your game.
Trap trigger
Press + to interact
defmodule DungeonCrawl.Room.Triggers.Trap doalias DungeonCrawl.Room.Actionalias Mix.Shell.IO, as: Shell@behaviour DungeonCrawl.Room.Triggerdef run(character, %Action{id: :forward}) doShell.info("You're walking cautiously and can see the next room."){character, :forward}enddef run(character, %Action{id: :search}) dodamage = 3Shell.info("You search the room looking for something useful.")Shell.info("You step on a false floor and fall into a trap.")Shell.info("You are hit by an arrow, losing #{damage} hit points."){DungeonCrawl.Character.take_damage(character, damage),:forward}endend
The ...