diff options
author | Joel Kronqvist <joel.kronqvist@iki.fi> | 2024-11-07 22:52:25 +0200 |
---|---|---|
committer | Joel Kronqvist <joel.kronqvist@iki.fi> | 2024-11-07 22:52:25 +0200 |
commit | 239571e3408a3187953bef1dd5d516461bad0e31 (patch) | |
tree | 67c062a635affc90c08a92ac61adfed2445985d8 /src/main/scala/Model/Action.scala | |
parent | def8975617e5c6da431e41cc889d167b0f2e2bb0 (diff) | |
download | scalevalapokalypsi-239571e3408a3187953bef1dd5d516461bad0e31.tar.gz scalevalapokalypsi-239571e3408a3187953bef1dd5d516461bad0e31.zip |
Added turns, time limits and turn order randomization (feature/bug?)
Diffstat (limited to 'src/main/scala/Model/Action.scala')
-rw-r--r-- | src/main/scala/Model/Action.scala | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/main/scala/Model/Action.scala b/src/main/scala/Model/Action.scala index 84704ce..11b0bc8 100644 --- a/src/main/scala/Model/Action.scala +++ b/src/main/scala/Model/Action.scala @@ -10,6 +10,14 @@ class Action(input: String): private val verb = commandText.takeWhile( _ != ' ' ) private val modifiers = commandText.drop(verb.length).trim + def takesATurnFor(actor: Entity): Boolean = + this.verb match + case "rest" => true + case "go" => actor.location.hasNeighbor(modifiers) + case "get" => actor.location.hasItem(this.modifiers) + case "drop" => actor.canDrop(this.modifiers) + case other => false + /** Causes the given player to take the action represented by this object, assuming * that the command was understood. Returns a description of what happened as a result * of the action (such as “You go west.”). The description is returned in an `Option` |