nskins / goby

Command-line role-playing game framework
MIT License
122 stars 56 forks source link

Prevent empty set of Battle Commands #126

Closed nskins closed 6 years ago

nskins commented 6 years ago

Weird things happen in battle when a Fighter does not have any battle commands. In the case of Player, the battle cannot proceed as there is no command to select. In the case of Monster, the game crashes.

One option to fix this would be to force the Fighter to have the default Attack (created via Attack.new) when no BattleCommands are given to the constructor. Additionally, we would need to enforce that the battle_commands array could not be empty (throw an exception when trying to remove the last BattleCommand).

We should also verify that battle_commands is read-only. I think it is already.

nskins commented 6 years ago

Forget it - this is going to be too complex due to equipping weapons. I suppose we can just pass on this.

EDIT: an alternative solution might be to just throw an exception during battle if someone doesn't have any BattleCommands.