From 38900e0b291d5e0f59afaaa239cd237f733b6588 Mon Sep 17 00:00:00 2001 From: Joel Kronqvist Date: Tue, 26 Nov 2024 14:03:23 +0200 Subject: Dying properly --- src/scalevalapokalypsi/Model/Action.scala | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'src/scalevalapokalypsi/Model/Action.scala') 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)) -- cgit v1.2.3