diff options
author | Joel Kronqvist <joel.kronqvist@iki.fi> | 2024-11-26 14:03:23 +0200 |
---|---|---|
committer | Joel Kronqvist <joel.kronqvist@iki.fi> | 2024-11-26 14:10:45 +0200 |
commit | 38900e0b291d5e0f59afaaa239cd237f733b6588 (patch) | |
tree | ee04f697ab17a75c9563ee87763cbcdcde8d297b /src/scalevalapokalypsi/Model/Action.scala | |
parent | 27dd937617cce1e43df1c16e12050f6e88763d54 (diff) | |
download | scalevalapokalypsi-38900e0b291d5e0f59afaaa239cd237f733b6588.tar.gz scalevalapokalypsi-38900e0b291d5e0f59afaaa239cd237f733b6588.zip |
Dying properly
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)) |