aboutsummaryrefslogtreecommitdiff
path: root/src/scalevalapokalypsi/Model/Action.scala
diff options
context:
space:
mode:
authorJoel Kronqvist <joel.kronqvist@iki.fi>2024-11-26 14:03:23 +0200
committerJoel Kronqvist <joel.kronqvist@iki.fi>2024-11-26 14:10:45 +0200
commit38900e0b291d5e0f59afaaa239cd237f733b6588 (patch)
treeee04f697ab17a75c9563ee87763cbcdcde8d297b /src/scalevalapokalypsi/Model/Action.scala
parent27dd937617cce1e43df1c16e12050f6e88763d54 (diff)
downloadscalevalapokalypsi-38900e0b291d5e0f59afaaa239cd237f733b6588.tar.gz
scalevalapokalypsi-38900e0b291d5e0f59afaaa239cd237f733b6588.zip
Dying properly
Diffstat (limited to 'src/scalevalapokalypsi/Model/Action.scala')
-rw-r--r--src/scalevalapokalypsi/Model/Action.scala11
1 files changed, 5 insertions, 6 deletions
diff --git a/src/scalevalapokalypsi/Model/Action.scala b/src/scalevalapokalypsi/Model/Action.scala
index c7c8a65..21e1286 100644
--- a/src/scalevalapokalypsi/Model/Action.scala
+++ b/src/scalevalapokalypsi/Model/Action.scala
@@ -40,15 +40,14 @@ class Action(input: String):
case "inventory" => Some((false, actor.inventory))
case "sano" =>
val entityNames = actor.location.getEntityNames.map(_.toLowerCase)
- val recipientNamePair = entityNames.map(name =>
+ val recipientNamePair = entityNames.flatMap(name =>
val possibleNamesWithSuffix = (0 to "ille".length).map(i =>
- modifiers.takeRight(name.length + i)
+ modifiers.takeRight(name.length + i)
)
possibleNamesWithSuffix.find(s =>
- s.take(name.length) == name
- )
- .map(_.splitAt(name.length))
- ).flatten.headOption
+ s.take(name.length) == name
+ )
+ .map(_.splitAt(name.length))).headOption
val recipient = recipientNamePair.flatMap(p =>
actor.location.getEntity(p(0))