mirror of
https://github.com/nolen777/eagle0.git
synced 2026-07-29 00:55:43 +00:00
Use keyed lookups for unaffiliated hero action (#7942)
This commit is contained in:
+8
-3
@@ -25,11 +25,16 @@ case class EndUnaffiliatedHeroActionsPhaseAction(
|
||||
heroes: Vector[HeroT],
|
||||
factions: Vector[FactionT]
|
||||
) extends ProtolessSequentialResultsAction {
|
||||
private lazy val factionsById: Map[FactionId, FactionT] =
|
||||
factions.map(faction => faction.id -> faction).toMap
|
||||
private lazy val heroesById: Map[HeroId, HeroT] =
|
||||
heroes.map(hero => hero.id -> hero).toMap
|
||||
|
||||
private def requiredFaction(fid: FactionId): FactionT =
|
||||
factions.find(_.id == fid).getOrElse(throw new IllegalArgumentException(s"No faction found for id $fid"))
|
||||
factionsById.getOrElse(fid, throw new IllegalArgumentException(s"No faction found for id $fid"))
|
||||
|
||||
private def requiredHero(hid: HeroId): HeroT =
|
||||
heroes.find(_.id == hid).getOrElse(throw new IllegalArgumentException(s"No hero found for id $hid"))
|
||||
heroesById.getOrElse(hid, throw new IllegalArgumentException(s"No hero found for id $hid"))
|
||||
|
||||
private def heroRejoinResults: Vector[ActionResultT] =
|
||||
(for {
|
||||
@@ -78,7 +83,7 @@ case class EndUnaffiliatedHeroActionsPhaseAction(
|
||||
)
|
||||
}
|
||||
}
|
||||
.getOrElse(Vector())
|
||||
.getOrElse(Vector.empty)
|
||||
|
||||
override def results: Vector[ActionResultT] = {
|
||||
val cpsAndLlmRequests = provinces.map { p =>
|
||||
|
||||
Reference in New Issue
Block a user