diff options
Diffstat (limited to 'src/scalevalapokalypsi/Model/Action.scala')
-rw-r--r-- | src/scalevalapokalypsi/Model/Action.scala | 11 |
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)) |