mirror of
https://github.com/nolen777/eagle0.git
synced 2026-07-29 08:55:42 +00:00
Compare commits
10
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c691dc481a | ||
|
|
77cb1d8168 | ||
|
|
8ac81891d3 | ||
|
|
af3209e2b3 | ||
|
|
aa62555735 | ||
|
|
f3d09770ee | ||
|
|
83d81dc033 | ||
|
|
3b05bc3f0b | ||
|
|
c6c22778a7 | ||
|
|
11e81a639a |
@@ -0,0 +1,5 @@
|
||||
//src/test/scala/net/eagle0/eagle/ai:ai_client_utils_test ✓ FIXED
|
||||
//src/test/scala/net/eagle0/eagle/ai:faction_leader_province_ranker_test ✓ FIXED
|
||||
//src/test/scala/net/eagle0/eagle/ai:fix_leader_alone_command_selector_test ✓ FIXED
|
||||
//src/test/scala/net/eagle0/eagle/ai:invitation_command_selector_test ✓ FIXED
|
||||
//src/test/scala/net/eagle0/eagle/ai:mid_game_ai_client_test
|
||||
@@ -8,7 +8,7 @@ import net.eagle0.eagle.{FactionId, HeroId, ProvinceId}
|
||||
|
||||
object AIClientUtils {
|
||||
def extraHeroCount(pid: ProvinceId, fid: FactionId, gs: GameState): Int =
|
||||
(gs.provinces(pid).rulingFactionHeroIds.size - desiredHeroCount(
|
||||
(gs.provinces(pid.value).rulingFactionHeroIds.size - desiredHeroCount(
|
||||
pid,
|
||||
fid,
|
||||
gs
|
||||
@@ -16,7 +16,7 @@ object AIClientUtils {
|
||||
|
||||
def desiredHeroCount(pid: ProvinceId, fid: FactionId, gs: GameState): Int = {
|
||||
if LegacyFactionUtils.hostileNeighbors(pid, fid, gs).nonEmpty then 3
|
||||
else if gs.provinces(pid).support < 65 then 2
|
||||
else if gs.provinces(pid.value).support < 65 then 2
|
||||
else 1
|
||||
}
|
||||
|
||||
@@ -55,8 +55,11 @@ object AIClientUtils {
|
||||
originProvince = originProvince,
|
||||
destinationProvince = destinationProvince,
|
||||
availableHeroIds = availableHeroIds,
|
||||
factionLeaders =
|
||||
gs.factions(originProvince.rulingFactionId.get).leaders.toVector,
|
||||
factionLeaders = gs
|
||||
.factions(originProvince.rulingFactionId.get)
|
||||
.leaders
|
||||
.toVector
|
||||
.map(HeroId(_)),
|
||||
favorLeaders = favorLeaders
|
||||
),
|
||||
gs,
|
||||
@@ -71,20 +74,21 @@ object AIClientUtils {
|
||||
favorLeaders: Boolean
|
||||
): Vector[HeroId] = {
|
||||
val availableHeroes = availableHeroIds
|
||||
.map(gs.heroes)
|
||||
.map(hid => gs.heroes(hid.value))
|
||||
|
||||
if availableHeroes.size <= desiredCount then availableHeroes.map(_.id)
|
||||
if availableHeroes.size <= desiredCount then
|
||||
availableHeroes.map(h => HeroId(h.id))
|
||||
else
|
||||
availableHeroes
|
||||
.sortBy(hero =>
|
||||
(
|
||||
if favorLeaders then
|
||||
!LegacyFactionUtils.isFactionLeader(hero.id, gs)
|
||||
else LegacyFactionUtils.isFactionLeader(hero.id, gs),
|
||||
!LegacyFactionUtils.isFactionLeader(HeroId(hero.id), gs)
|
||||
else LegacyFactionUtils.isFactionLeader(HeroId(hero.id), gs),
|
||||
-LegacyHeroUtils.power(hero)
|
||||
)
|
||||
)
|
||||
.map(_.id)
|
||||
.map(h => HeroId(h.id))
|
||||
.take(desiredCount)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ object FactionLeaderProvinceRanker {
|
||||
): Ordering[Province] = Ordering.by((p: Province) =>
|
||||
ProvinceDistances.distanceThroughFriendliesOption(
|
||||
fromProvinceId,
|
||||
p.id,
|
||||
ProvinceId(p.id),
|
||||
factionId,
|
||||
gameState
|
||||
)
|
||||
@@ -76,7 +76,7 @@ object FactionLeaderProvinceRanker {
|
||||
LegacyFactionUtils
|
||||
.provinces(factionId, gameState)
|
||||
.sorted(ordering)
|
||||
.map(_.id)
|
||||
.map(p => ProvinceId(p.id))
|
||||
}
|
||||
|
||||
def bestProvinceId(
|
||||
@@ -90,7 +90,7 @@ object FactionLeaderProvinceRanker {
|
||||
LegacyFactionUtils
|
||||
.provinces(factionId, gameState)
|
||||
.minOption(ordering)
|
||||
.map(_.id)
|
||||
.map(p => ProvinceId(p.id))
|
||||
}
|
||||
|
||||
def bestProvinceId(
|
||||
@@ -106,7 +106,7 @@ object FactionLeaderProvinceRanker {
|
||||
LegacyFactionUtils
|
||||
.provinces(factionId, gameState)
|
||||
.minOption(ordering)
|
||||
.map(_.id)
|
||||
.map(p => ProvinceId(p.id))
|
||||
}
|
||||
|
||||
def rankedProvinceIds(
|
||||
@@ -122,7 +122,7 @@ object FactionLeaderProvinceRanker {
|
||||
LegacyFactionUtils
|
||||
.provinces(factionId, gameState)
|
||||
.sorted(ordering)
|
||||
.map(_.id)
|
||||
.map(p => ProvinceId(p.id))
|
||||
}
|
||||
|
||||
def bestSettlementPidForFactionLeader(
|
||||
@@ -133,7 +133,7 @@ object FactionLeaderProvinceRanker {
|
||||
val ordering = factionLeaderProvinceOrdering(
|
||||
factionId = factionId,
|
||||
gameState = gameState,
|
||||
fromProvinceId = currentProvince.id
|
||||
fromProvinceId = ProvinceId(currentProvince.id)
|
||||
)
|
||||
|
||||
LegacyFactionUtils
|
||||
@@ -141,7 +141,7 @@ object FactionLeaderProvinceRanker {
|
||||
.filter(ordering.lt(_, currentProvince))
|
||||
.filterNot(LegacyProvinceUtils.ruledByFactionLeader(_, gameState))
|
||||
.minOption(ordering)
|
||||
.map(_.id)
|
||||
.map(p => ProvinceId(p.id))
|
||||
}
|
||||
|
||||
def bestSettlementPidForFactionLeader(
|
||||
@@ -151,7 +151,7 @@ object FactionLeaderProvinceRanker {
|
||||
): Option[ProvinceId] =
|
||||
bestSettlementPidForFactionLeader(
|
||||
factionId = factionId,
|
||||
currentProvince = gameState.provinces(currentProvinceId),
|
||||
currentProvince = gameState.provinces(currentProvinceId.value),
|
||||
gameState = gameState
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package net.eagle0.eagle.ai
|
||||
|
||||
import net.eagle0.common.{FunctionalRandom, RandomState}
|
||||
import net.eagle0.eagle.FactionId
|
||||
import net.eagle0.eagle.{FactionId, HeroId, ProvinceId}
|
||||
import net.eagle0.eagle.api.available_command.{
|
||||
AvailableCommand,
|
||||
MarchAvailableCommand
|
||||
@@ -30,7 +30,9 @@ object FixLeaderAloneCommandSelector {
|
||||
gameState
|
||||
.provinces(opmc.originProvinceId)
|
||||
.rulingFactionHeroIds
|
||||
.filterNot(LegacyFactionUtils.isFactionLeader(_, gameState))
|
||||
.filterNot(hid =>
|
||||
LegacyFactionUtils.isFactionLeader(HeroId(hid), gameState)
|
||||
)
|
||||
.size > 1
|
||||
)
|
||||
) { opmc => fr =>
|
||||
@@ -42,18 +44,21 @@ object FixLeaderAloneCommandSelector {
|
||||
.filter(_.rulingFactionHeroIds.size == 1)
|
||||
.filter(dest =>
|
||||
LegacyFactionUtils
|
||||
.isFactionLeader(dest.rulingFactionHeroIds.head, gameState)
|
||||
.isFactionLeader(
|
||||
HeroId(dest.rulingFactionHeroIds.head),
|
||||
gameState
|
||||
)
|
||||
)
|
||||
.map { destination =>
|
||||
fr.nextRandomElement(opmc.availableHeroIds)
|
||||
.map { hid =>
|
||||
CombatUnit(factionId = actingFactionId, heroId = hid)
|
||||
CombatUnit(factionId = actingFactionId.value, heroId = hid)
|
||||
}
|
||||
.map { combatUnit =>
|
||||
Some(
|
||||
CommandSelection(
|
||||
actingFactionId = actingFactionId,
|
||||
actingProvinceId = ac.actingProvinceId,
|
||||
actingProvinceId = ProvinceId(ac.actingProvinceId),
|
||||
available = ac,
|
||||
selected = MarchSelectedCommand(
|
||||
gold = 0,
|
||||
|
||||
@@ -13,7 +13,7 @@ import net.eagle0.eagle.library.util.command_choice_helpers.{
|
||||
ProvinceGoldSurplusCalculator,
|
||||
TrustForDiplomacy
|
||||
}
|
||||
import net.eagle0.eagle.FactionId
|
||||
import net.eagle0.eagle.{FactionId, ProvinceId}
|
||||
import net.eagle0.eagle.library.settings.MinChanceForAIInvite
|
||||
|
||||
object InvitationCommandSelector {
|
||||
@@ -34,13 +34,13 @@ object InvitationCommandSelector {
|
||||
.filter { invitationOption =>
|
||||
TrustForDiplomacy.meetsConditionsForInvitation(
|
||||
actingFactionId = actingFactionId,
|
||||
targetFactionId = invitationOption.targetFactionId,
|
||||
targetFactionId = FactionId(invitationOption.targetFactionId),
|
||||
gameState = gameState
|
||||
)
|
||||
}
|
||||
.filter { invitationOption =>
|
||||
ProvinceGoldSurplusCalculator.provinceGoldSurplus(
|
||||
diplomacyAvailableCommand.actingProvinceId,
|
||||
ProvinceId(diplomacyAvailableCommand.actingProvinceId),
|
||||
gameState
|
||||
) >= invitationOption.goldCost
|
||||
}
|
||||
@@ -50,7 +50,7 @@ object InvitationCommandSelector {
|
||||
acceptanceChance =
|
||||
ResolveDiplomacyCommandSelector.invitationAcceptanceChance(
|
||||
actingFactionId,
|
||||
invitationOption.targetFactionId,
|
||||
FactionId(invitationOption.targetFactionId),
|
||||
gameState
|
||||
)
|
||||
)
|
||||
@@ -60,7 +60,8 @@ object InvitationCommandSelector {
|
||||
.map { iowc =>
|
||||
CommandSelection(
|
||||
actingFactionId = actingFactionId,
|
||||
actingProvinceId = diplomacyAvailableCommand.actingProvinceId,
|
||||
actingProvinceId =
|
||||
ProvinceId(diplomacyAvailableCommand.actingProvinceId),
|
||||
available = diplomacyAvailableCommand,
|
||||
selected = DiplomacySelectedCommand(
|
||||
selectedOption = iowc.invitationOption,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package net.eagle0.eagle.ai
|
||||
|
||||
import net.eagle0.eagle.{FactionId, ProvinceId}
|
||||
import net.eagle0.eagle.{FactionId, HeroId, ProvinceId}
|
||||
import net.eagle0.eagle.api.available_command.{
|
||||
MarchAvailableCommand,
|
||||
MarchCommandFromOneProvince
|
||||
@@ -32,7 +32,7 @@ object MarchTowardProvinceCommandChooser {
|
||||
ProvinceDistances
|
||||
.distanceThroughFriendliesOption(
|
||||
destinationProvinceId,
|
||||
p.id,
|
||||
ProvinceId(p.id),
|
||||
fid,
|
||||
gs
|
||||
)
|
||||
@@ -44,7 +44,7 @@ object MarchTowardProvinceCommandChooser {
|
||||
|
||||
bestCommand.flatMap { case (opmc, dest, _) =>
|
||||
internalRequire(
|
||||
opmc.originProvinceId != destinationProvinceId,
|
||||
ProvinceId(opmc.originProvinceId) != destinationProvinceId,
|
||||
s"Marching away from $destinationProvinceId in an effort to get to that province"
|
||||
)
|
||||
|
||||
@@ -54,7 +54,7 @@ object MarchTowardProvinceCommandChooser {
|
||||
AIClientUtils.takenHeroIdsForMarchTowardFocus(
|
||||
originProvince = originProvince,
|
||||
destinationProvince = dest,
|
||||
availableHeroIds = opmc.availableHeroIds.toVector,
|
||||
availableHeroIds = opmc.availableHeroIds.toVector.map(HeroId(_)),
|
||||
favorLeaders = favorLeaders,
|
||||
gs = gs
|
||||
)
|
||||
@@ -72,33 +72,38 @@ object MarchTowardProvinceCommandChooser {
|
||||
val takenUnits = takenHeroIds
|
||||
.zipAll(
|
||||
takenBattalions.map(batt => Some(batt.id)),
|
||||
0,
|
||||
HeroId(0),
|
||||
None
|
||||
)
|
||||
.map { case (hid, bid) =>
|
||||
CombatUnit(factionId = fid, heroId = hid, battalionId = bid)
|
||||
CombatUnit(
|
||||
factionId = fid.value,
|
||||
heroId = hid.value,
|
||||
battalionId = bid
|
||||
)
|
||||
}
|
||||
|
||||
val foodToTake = 2 * LegacyBattalionUtils.monthlyConsumedFood(
|
||||
takenBattalions,
|
||||
gs.battalionTypes.toVector
|
||||
)
|
||||
val goldToTake = provinceGoldSurplus(originProvince.id, gs)
|
||||
val goldToTake = provinceGoldSurplus(ProvinceId(originProvince.id), gs)
|
||||
CommandSelection(
|
||||
actingFactionId = fid,
|
||||
actingProvinceId = actingProvinceId,
|
||||
actingProvinceId = ProvinceId(actingProvinceId),
|
||||
available = ac,
|
||||
selected = MarchSelectedCommand(
|
||||
marchingUnits = takenUnits, // Check the food cost here?
|
||||
destinationProvinceId = dest.id,
|
||||
originProvince = opmc.originProvinceId,
|
||||
gold = Math.min(goldToTake, opmc.goldAvailable),
|
||||
food = Math.min(foodToTake, opmc.foodAvailable)
|
||||
food = Math.min(foodToTake, opmc.foodAvailable),
|
||||
unknownFields = scalapb.UnknownFieldSet.empty
|
||||
),
|
||||
reason = if favorLeaders then
|
||||
s"marching leaders toward ${gs.provinces(destinationProvinceId).name}"
|
||||
s"marching leaders toward ${gs.provinces(destinationProvinceId.value).name}"
|
||||
else
|
||||
s"marching heroes toward ${gs.provinces(destinationProvinceId).name}"
|
||||
s"marching heroes toward ${gs.provinces(destinationProvinceId.value).name}"
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package net.eagle0.eagle.ai
|
||||
|
||||
import net.eagle0.common.{FunctionalRandom, RandomState}
|
||||
import net.eagle0.eagle.FactionId
|
||||
import net.eagle0.eagle.{FactionId, ProvinceId}
|
||||
import net.eagle0.eagle.api.available_command.{
|
||||
AvailableCommand,
|
||||
ResolveAllianceOfferAvailableCommand,
|
||||
@@ -59,10 +59,10 @@ object ResolveDiplomacyCommandSelector {
|
||||
gameState = gameState,
|
||||
availableCommands = availableCommands,
|
||||
rankedChoosers = Vector[CommandChooser](
|
||||
resolveInvitationSelectedCommand _,
|
||||
resolveAllianceOfferSelectedCommand _,
|
||||
resolveBreakAllianceSelectedCommand _,
|
||||
resolveTruceOfferSelectedCommand _,
|
||||
resolveInvitationSelectedCommand,
|
||||
resolveAllianceOfferSelectedCommand,
|
||||
resolveBreakAllianceSelectedCommand,
|
||||
resolveTruceOfferSelectedCommand,
|
||||
resolveRansomOfferSelectedCommand _
|
||||
),
|
||||
functionalRandom = functionalRandom
|
||||
@@ -87,7 +87,7 @@ object ResolveDiplomacyCommandSelector {
|
||||
Some(
|
||||
CommandSelection(
|
||||
actingFactionId = actingFactionId,
|
||||
actingProvinceId = 0,
|
||||
actingProvinceId = ProvinceId(0),
|
||||
available = resolveInvitationAc,
|
||||
selected = resolveInviteSelection,
|
||||
reason = "resolving invitation"
|
||||
@@ -105,7 +105,11 @@ object ResolveDiplomacyCommandSelector {
|
||||
val invitedFid = actingFactionId
|
||||
val bestInvitation = ac.invitations
|
||||
.maxBy(inv =>
|
||||
invitationAcceptanceChance(inv.originatingFactionId, invitedFid, gs)
|
||||
invitationAcceptanceChance(
|
||||
FactionId(inv.originatingFactionId),
|
||||
invitedFid,
|
||||
gs
|
||||
)
|
||||
)
|
||||
|
||||
internalRequire(
|
||||
@@ -123,7 +127,7 @@ object ResolveDiplomacyCommandSelector {
|
||||
originatingFactionId = bestOriginatingFid,
|
||||
resolution =
|
||||
if 100.0 * roll < invitationAcceptanceChance(
|
||||
bestOriginatingFid,
|
||||
FactionId(bestOriginatingFid),
|
||||
invitedFid,
|
||||
gs
|
||||
)
|
||||
@@ -160,7 +164,7 @@ object ResolveDiplomacyCommandSelector {
|
||||
Some(
|
||||
CommandSelection(
|
||||
actingFactionId = actingFactionId,
|
||||
actingProvinceId = 0,
|
||||
actingProvinceId = ProvinceId(0),
|
||||
available = resolveTruceAc,
|
||||
selected = resolveTruceOfferSelection,
|
||||
reason = "resolving truce offer"
|
||||
@@ -178,7 +182,11 @@ object ResolveDiplomacyCommandSelector {
|
||||
val actingFid = actingFactionId
|
||||
val bestOffer = ac.offers
|
||||
.maxBy(inv =>
|
||||
truceOfferAcceptanceChance(inv.originatingFactionId, actingFid, gs)
|
||||
truceOfferAcceptanceChance(
|
||||
FactionId(inv.originatingFactionId),
|
||||
actingFid,
|
||||
gs
|
||||
)
|
||||
)
|
||||
|
||||
internalRequire(
|
||||
@@ -196,7 +204,7 @@ object ResolveDiplomacyCommandSelector {
|
||||
originatingFactionId = bestOriginatingFid,
|
||||
resolution =
|
||||
if 100.0 * roll < truceOfferAcceptanceChance(
|
||||
originatingFid = bestOriginatingFid,
|
||||
originatingFid = FactionId(bestOriginatingFid),
|
||||
targetFid = actingFid,
|
||||
gs = gs
|
||||
)
|
||||
@@ -228,7 +236,7 @@ object ResolveDiplomacyCommandSelector {
|
||||
): Int = {
|
||||
// Always reject if the faction already has an alliance
|
||||
if gs
|
||||
.factions(targetFid)
|
||||
.factions(targetFid.value)
|
||||
.factionRelationships
|
||||
.exists(_.relationshipLevel == ALLY)
|
||||
then 0
|
||||
@@ -265,7 +273,7 @@ object ResolveDiplomacyCommandSelector {
|
||||
resolveRansomAc =>
|
||||
CommandSelection(
|
||||
actingFactionId = actingFactionId,
|
||||
actingProvinceId = 0,
|
||||
actingProvinceId = ProvinceId(0),
|
||||
available = resolveRansomAc,
|
||||
selected = selectionForResolveRansomOfferSelectedCommand(
|
||||
actingFactionId = actingFactionId,
|
||||
@@ -310,7 +318,7 @@ object ResolveDiplomacyCommandSelector {
|
||||
Some(
|
||||
CommandSelection(
|
||||
actingFactionId = actingFactionId,
|
||||
actingProvinceId = 0,
|
||||
actingProvinceId = ProvinceId(0),
|
||||
available = resolveAllianceAc,
|
||||
selected = resolveAllianceOfferSelection,
|
||||
reason = "resolving alliance offer"
|
||||
@@ -338,7 +346,7 @@ object ResolveDiplomacyCommandSelector {
|
||||
Some(
|
||||
CommandSelection(
|
||||
actingFactionId = actingFactionId,
|
||||
actingProvinceId = 0,
|
||||
actingProvinceId = ProvinceId(0),
|
||||
available = resolveBreakAllianceAc,
|
||||
selected = resolveBreakAllianceSelection,
|
||||
reason = "resolving break alliance"
|
||||
@@ -356,7 +364,11 @@ object ResolveDiplomacyCommandSelector {
|
||||
val actingFid = actingFactionId
|
||||
val bestOffer = ac.offers
|
||||
.maxBy(inv =>
|
||||
allianceOfferAcceptanceChance(inv.originatingFactionId, actingFid, gs)
|
||||
allianceOfferAcceptanceChance(
|
||||
FactionId(inv.originatingFactionId),
|
||||
actingFid,
|
||||
gs
|
||||
)
|
||||
)
|
||||
|
||||
internalRequire(
|
||||
@@ -374,7 +386,7 @@ object ResolveDiplomacyCommandSelector {
|
||||
originatingFactionId = bestOriginatingFid,
|
||||
resolution =
|
||||
if 100.0 * roll < allianceOfferAcceptanceChance(
|
||||
originatingFid = bestOriginatingFid,
|
||||
originatingFid = FactionId(bestOriginatingFid),
|
||||
targetFid = actingFid,
|
||||
gs = gs
|
||||
)
|
||||
|
||||
@@ -38,24 +38,25 @@ case class ClientTextStoreImpl(
|
||||
requestedAfterHistoryCount: Int
|
||||
): ClientTextStore = {
|
||||
internalRequire(
|
||||
pregenerated.getText(id).isEmpty,
|
||||
pregenerated.getText(id.value).isEmpty,
|
||||
s"Text with id $id is pregenerated"
|
||||
)
|
||||
|
||||
if completeTexts.contains(id) then {
|
||||
if completeTexts.contains(id.value) then {
|
||||
println(s"Text with id $id already exists")
|
||||
this
|
||||
} else if incompleteTexts.contains(id) then {
|
||||
} else if incompleteTexts.contains(id.value) then {
|
||||
println(s"Incomplete text with id $id already exists")
|
||||
this
|
||||
} else {
|
||||
copy(
|
||||
unrequestedTexts = unrequestedTexts + (id -> UnrequestedClientText(
|
||||
id = id,
|
||||
requestedAfterHistoryCount = requestedAfterHistoryCount,
|
||||
llmRequest = llmRequest
|
||||
)),
|
||||
accessibleTo = this.accessibleTo + (id -> accessibleTo),
|
||||
unrequestedTexts =
|
||||
unrequestedTexts + (id.value -> UnrequestedClientText(
|
||||
id = id,
|
||||
requestedAfterHistoryCount = requestedAfterHistoryCount,
|
||||
llmRequest = llmRequest
|
||||
)),
|
||||
accessibleTo = this.accessibleTo + (id.value -> accessibleTo),
|
||||
accessibleToIsSaved = false,
|
||||
incompleteTextsAreSaved = false
|
||||
)
|
||||
@@ -64,10 +65,10 @@ case class ClientTextStoreImpl(
|
||||
|
||||
def withMarkedRequested(id: ClientTextId): ClientTextStore =
|
||||
unrequestedTexts
|
||||
.get(id)
|
||||
.get(id.value)
|
||||
.map { unrequested =>
|
||||
copy(
|
||||
incompleteTexts = incompleteTexts + (id ->
|
||||
incompleteTexts = incompleteTexts + (id.value ->
|
||||
IncompleteClientText(
|
||||
id = id,
|
||||
partialText = "",
|
||||
@@ -75,7 +76,7 @@ case class ClientTextStoreImpl(
|
||||
requestedAfterHistoryCount =
|
||||
unrequested.requestedAfterHistoryCount
|
||||
)),
|
||||
unrequestedTexts = unrequestedTexts - id,
|
||||
unrequestedTexts = unrequestedTexts - id.value,
|
||||
incompleteTextsAreSaved = false
|
||||
)
|
||||
}
|
||||
@@ -87,7 +88,7 @@ case class ClientTextStoreImpl(
|
||||
|
||||
def withBypassed(id: ClientTextId): ClientTextStore =
|
||||
copy(
|
||||
unrequestedTexts = unrequestedTexts - id,
|
||||
unrequestedTexts = unrequestedTexts - id.value,
|
||||
incompleteTextsAreSaved = false
|
||||
)
|
||||
|
||||
@@ -95,18 +96,18 @@ case class ClientTextStoreImpl(
|
||||
pregenerated
|
||||
.getText(id)
|
||||
.orElse {
|
||||
completeTexts.get(id).map(_.text)
|
||||
completeTexts.get(id.value).map(_.text)
|
||||
}
|
||||
.map { text => TextGenerationSuccess(text) }
|
||||
.getOrElse {
|
||||
incompleteTexts
|
||||
.get(id)
|
||||
.get(id.value)
|
||||
.map { ict =>
|
||||
TextGenerationDependencyInProgress(ict.id, ict.text)
|
||||
}
|
||||
.getOrElse {
|
||||
unrequestedTexts
|
||||
.get(id)
|
||||
.get(id.value)
|
||||
.map { ut =>
|
||||
TextGenerationDependencyWaiting(ut.id)
|
||||
}
|
||||
@@ -122,19 +123,19 @@ case class ClientTextStoreImpl(
|
||||
complete: Boolean
|
||||
): ClientTextStoreWithUpdate = {
|
||||
internalRequire(
|
||||
!unrequestedTexts.contains(id),
|
||||
!unrequestedTexts.contains(id.value),
|
||||
s"Text with id $id is unrequested"
|
||||
)
|
||||
internalRequire(
|
||||
!completeTexts.contains(id),
|
||||
!completeTexts.contains(id.value),
|
||||
s"Text with id $id is already complete"
|
||||
)
|
||||
internalRequire(
|
||||
pregenerated.getText(id).isEmpty,
|
||||
pregenerated.getText(id.value).isEmpty,
|
||||
s"Text with id $id is pregenerated"
|
||||
)
|
||||
val update = incompleteTexts
|
||||
.get(id)
|
||||
.get(id.value)
|
||||
.map(t => t.append(newText))
|
||||
.getOrElse {
|
||||
throw new EagleInternalException(s"Text with id $id not found")
|
||||
@@ -149,8 +150,8 @@ case class ClientTextStoreImpl(
|
||||
|
||||
ClientTextStoreWithUpdate(
|
||||
copy(
|
||||
completeTexts = completeTexts + (id -> updatedText),
|
||||
incompleteTexts = incompleteTexts - id,
|
||||
completeTexts = completeTexts + (id.value -> updatedText),
|
||||
incompleteTexts = incompleteTexts - id.value,
|
||||
incompleteTextsAreSaved = false
|
||||
),
|
||||
updatedText
|
||||
@@ -158,7 +159,7 @@ case class ClientTextStoreImpl(
|
||||
} else {
|
||||
ClientTextStoreWithUpdate(
|
||||
copy(
|
||||
incompleteTexts = incompleteTexts + (id -> update),
|
||||
incompleteTexts = incompleteTexts + (id.value -> update),
|
||||
incompleteTextsAreSaved = false
|
||||
),
|
||||
update
|
||||
@@ -177,22 +178,24 @@ case class ClientTextStoreImpl(
|
||||
if updatedFactionIds == originalFactionIds then this
|
||||
else
|
||||
copy(
|
||||
accessibleTo = accessibleTo + (id -> updatedFactionIds),
|
||||
accessibleTo = accessibleTo + (id.value -> updatedFactionIds),
|
||||
accessibleToIsSaved = false
|
||||
)
|
||||
}
|
||||
|
||||
def withMovedBackToUnrequested(id: ClientTextId): ClientTextStore =
|
||||
incompleteTexts
|
||||
.get(id)
|
||||
.get(id.value)
|
||||
.map { incomplete =>
|
||||
copy(
|
||||
unrequestedTexts = unrequestedTexts + (id -> UnrequestedClientText(
|
||||
id = id,
|
||||
requestedAfterHistoryCount = incomplete.requestedAfterHistoryCount,
|
||||
llmRequest = incomplete.llmRequest
|
||||
)),
|
||||
incompleteTexts = incompleteTexts - id,
|
||||
unrequestedTexts =
|
||||
unrequestedTexts + (id.value -> UnrequestedClientText(
|
||||
id = id,
|
||||
requestedAfterHistoryCount =
|
||||
incomplete.requestedAfterHistoryCount,
|
||||
llmRequest = incomplete.llmRequest
|
||||
)),
|
||||
incompleteTexts = incompleteTexts - id.value,
|
||||
incompleteTextsAreSaved = false
|
||||
)
|
||||
}
|
||||
|
||||
+14
-8
@@ -8,12 +8,16 @@ import net.eagle0.eagle.{FactionId, HeroId, ProvinceId}
|
||||
object AvailableAlmsCommandFactory extends AvailableCommandsFactoryForType {
|
||||
|
||||
def availableHeroIds(gs: GameState, pid: ProvinceId): Vector[HeroId] =
|
||||
gs.provinces(pid)
|
||||
gs.provinces(pid.value)
|
||||
.rulingFactionHeroIds
|
||||
.toVector
|
||||
.filter(hid => gs.heroes(hid).vigor >= MinVigorForAlms.doubleValue)
|
||||
.map(HeroId(_))
|
||||
.filter(hid => gs.heroes(hid.value).vigor >= MinVigorForAlms.doubleValue)
|
||||
.sortBy(hid =>
|
||||
(!gs.heroes(hid).profession.isPaladin, -gs.heroes(hid).vigor)
|
||||
(
|
||||
!gs.heroes(hid.value).profession.isPaladin,
|
||||
-gs.heroes(hid.value).vigor
|
||||
)
|
||||
)
|
||||
|
||||
override def availableCommand(
|
||||
@@ -22,14 +26,16 @@ object AvailableAlmsCommandFactory extends AvailableCommandsFactoryForType {
|
||||
provinceId: ProvinceId
|
||||
): Option[AlmsAvailableCommand] = {
|
||||
val hids = availableHeroIds(gameState, provinceId)
|
||||
val province = gameState.provinces(provinceId)
|
||||
val province = gameState.provinces(provinceId.value)
|
||||
|
||||
Option.when(hids.nonEmpty && province.food > 0) {
|
||||
AlmsAvailableCommand(
|
||||
availableHeroIds = hids,
|
||||
actingProvinceId = provinceId,
|
||||
foodAvailable =
|
||||
Math.min(MaxAlmsFood.intValue, gameState.provinces(provinceId).food)
|
||||
availableHeroIds = hids.map(_.value),
|
||||
actingProvinceId = provinceId.value,
|
||||
foodAvailable = Math.min(
|
||||
MaxAlmsFood.intValue,
|
||||
gameState.provinces(provinceId.value).food
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -35,13 +35,13 @@ object AvailableApprehendOutlawCommandFactory
|
||||
factionId: FactionId,
|
||||
provinceId: ProvinceId
|
||||
): Option[ApprehendOutlawAvailableCommand] = {
|
||||
val province = gameState.provinces(provinceId)
|
||||
val province = gameState.provinces(provinceId.value)
|
||||
val outlaws = availableToCapture(province)
|
||||
val actors = availableActors(gameState, province)
|
||||
|
||||
Option.when(outlaws.nonEmpty && actors.nonEmpty) {
|
||||
ApprehendOutlawAvailableCommand(
|
||||
actingProvinceId = provinceId,
|
||||
actingProvinceId = provinceId.value,
|
||||
availableHeroIds = actors.map(_.id),
|
||||
outlaws = outlaws.map(outlaw =>
|
||||
ResidentOutlaw(
|
||||
|
||||
+2
-2
@@ -16,7 +16,7 @@ object AvailableArmTroopsCommandFactory
|
||||
factionId: FactionId,
|
||||
provinceId: ProvinceId
|
||||
): Option[ArmTroopsAvailableCommand] = {
|
||||
val province = gameState.provinces(provinceId)
|
||||
val province = gameState.provinces(provinceId.value)
|
||||
|
||||
if !province.rulerIsTraveling then return None
|
||||
|
||||
@@ -56,7 +56,7 @@ object AvailableArmTroopsCommandFactory
|
||||
|
||||
Some(
|
||||
ArmTroopsAvailableCommand(
|
||||
actingProvinceId = provinceId,
|
||||
actingProvinceId = provinceId.value,
|
||||
availableBattalions = affordableBattalions.map(_.id),
|
||||
armamentCosts = armamentCosts,
|
||||
maxArmament =
|
||||
|
||||
+27
-21
@@ -28,7 +28,7 @@ object AvailableAttackDecisionCommandFactory
|
||||
pid: ProvinceId,
|
||||
gs: GameState
|
||||
): Vector[MovingArmy] =
|
||||
gs.provinces(pid)
|
||||
gs.provinces(pid.value)
|
||||
.hostileArmies
|
||||
.flatMap(_.armies)
|
||||
.sortBy(ma => (ma.getArmy.factionId, ma.getArmy.units.head.heroId))
|
||||
@@ -39,9 +39,9 @@ object AvailableAttackDecisionCommandFactory
|
||||
fid: FactionId,
|
||||
gs: GameState
|
||||
): Option[HostileArmyGroup] =
|
||||
gs.provinces(pid)
|
||||
gs.provinces(pid.value)
|
||||
.hostileArmies
|
||||
.find(_.factionId == fid)
|
||||
.find(ha => FactionId(ha.factionId) == fid)
|
||||
.filter(_.status.asMessage.sealedValue.isAwaitingDecision)
|
||||
|
||||
private def defendingArmyStats(
|
||||
@@ -49,7 +49,7 @@ object AvailableAttackDecisionCommandFactory
|
||||
pid: ProvinceId,
|
||||
gs: GameState
|
||||
): Option[ArmyStats] = {
|
||||
val province = gs.provinces(pid)
|
||||
val province = gs.provinces(pid.value)
|
||||
|
||||
val heroCount = province.rulingFactionHeroIds.size + province.defendingArmy
|
||||
.map(_.units.size)
|
||||
@@ -72,9 +72,9 @@ object AvailableAttackDecisionCommandFactory
|
||||
factionId = defenderFid,
|
||||
heroCount = heroCount,
|
||||
troopCount = troopCount,
|
||||
hostility =
|
||||
LegacyFactionUtils.hostilityStatus(defenderFid, attackerFid, gs),
|
||||
originProvinceId = pid
|
||||
hostility = LegacyFactionUtils
|
||||
.hostilityStatus(FactionId(defenderFid), attackerFid, gs),
|
||||
originProvinceId = pid.value
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -85,7 +85,8 @@ object AvailableAttackDecisionCommandFactory
|
||||
gs: GameState
|
||||
): Vector[ArmyStats] =
|
||||
relevantArmies(pid, gs).map(ia =>
|
||||
IncomingArmyUtils.stats(toFid, ia.getArmy, gs, ia.originProvince)
|
||||
IncomingArmyUtils
|
||||
.stats(toFid, ia.getArmy, gs, ProvinceId(ia.originProvince))
|
||||
) ++ defendingArmyStats(
|
||||
toFid,
|
||||
pid,
|
||||
@@ -112,9 +113,9 @@ object AvailableAttackDecisionCommandFactory
|
||||
fid: FactionId
|
||||
): Option[AttackDecisionType] =
|
||||
Option.when(
|
||||
gs.provinces(pid).rulingFactionId.isEmpty ||
|
||||
gs.provinces(pid.value).rulingFactionId.isEmpty ||
|
||||
IncomingArmyUtils.isHostileProvince(
|
||||
gs.provinces(pid),
|
||||
gs.provinces(pid.value),
|
||||
fid,
|
||||
gs
|
||||
)
|
||||
@@ -126,9 +127,9 @@ object AvailableAttackDecisionCommandFactory
|
||||
fid: FactionId
|
||||
): Option[AttackDecisionType] =
|
||||
Option.when(
|
||||
hasResourcesToDemand(gs.provinces(pid))
|
||||
hasResourcesToDemand(gs.provinces(pid.value))
|
||||
&& IncomingArmyUtils.isHostileProvince(
|
||||
gs.provinces(pid),
|
||||
gs.provinces(pid.value),
|
||||
fid,
|
||||
gs
|
||||
) && allArmiesCanFlee(gs, pid, fid)
|
||||
@@ -136,8 +137,8 @@ object AvailableAttackDecisionCommandFactory
|
||||
DemandTributeDecision(
|
||||
Some(
|
||||
TributeAmount(
|
||||
food = gs.provinces(pid).food,
|
||||
gold = gs.provinces(pid).gold
|
||||
food = gs.provinces(pid.value).food,
|
||||
gold = gs.provinces(pid.value).gold
|
||||
)
|
||||
)
|
||||
)
|
||||
@@ -160,7 +161,7 @@ object AvailableAttackDecisionCommandFactory
|
||||
MoreOption.flatWhen(
|
||||
!allArmiesCanFlee(gs, pid, fid) &&
|
||||
!IncomingArmyUtils.isHostileProvince(
|
||||
gs.provinces(pid),
|
||||
gs.provinces(pid.value),
|
||||
fid,
|
||||
gs
|
||||
)
|
||||
@@ -174,14 +175,19 @@ object AvailableAttackDecisionCommandFactory
|
||||
.map(_.id)
|
||||
.toVector match {
|
||||
case items if items.isEmpty => None
|
||||
case emptyProvinces =>
|
||||
case emptyProvinceIds =>
|
||||
ProvinceDistances
|
||||
.closestProvinceOption(
|
||||
pid,
|
||||
emptyProvinces,
|
||||
p => gs.provinces(p).neighbors.map(_.provinceId).toVector
|
||||
emptyProvinceIds.map(ProvinceId(_)),
|
||||
p =>
|
||||
gs.provinces(p.value)
|
||||
.neighbors
|
||||
.map(_.provinceId)
|
||||
.map(ProvinceId(_))
|
||||
.toVector
|
||||
)
|
||||
.map(pwd => gs.provinces(pwd.provinceId))
|
||||
.map(pwd => gs.provinces(pwd.provinceId.value))
|
||||
}
|
||||
}
|
||||
.map { returnProvince =>
|
||||
@@ -213,7 +219,7 @@ object AvailableAttackDecisionCommandFactory
|
||||
): Option[AttackDecisionAvailableCommand] = {
|
||||
internalRequire(
|
||||
IncomingArmyUtils.incomingArmiesAreMutuallyAllied(
|
||||
gameState.provinces(provinceId),
|
||||
gameState.provinces(provinceId.value),
|
||||
gameState
|
||||
),
|
||||
s"Incoming armies in attack decision phase are not mutually allied in province $provinceId"
|
||||
@@ -226,7 +232,7 @@ object AvailableAttackDecisionCommandFactory
|
||||
case nonemptyDecisionOptions =>
|
||||
Some(
|
||||
AttackDecisionAvailableCommand(
|
||||
actingProvinceId = provinceId,
|
||||
actingProvinceId = provinceId.value,
|
||||
armies = armyStats(factionId, provinceId, gameState),
|
||||
actingUnits = hostileArmyGroup.armies
|
||||
.flatMap(_.getArmy.units)
|
||||
|
||||
+4
-5
@@ -60,9 +60,8 @@ object AvailableControlWeatherCommandsFactory
|
||||
gameState: GameState,
|
||||
factionId: FactionId,
|
||||
provinceId: ProvinceId
|
||||
): Option[ControlWeatherAvailableCommand] =
|
||||
makeControlWeatherCommand(
|
||||
gameState,
|
||||
gameState.provinces(provinceId)
|
||||
)
|
||||
): Option[ControlWeatherAvailableCommand] = makeControlWeatherCommand(
|
||||
gameState,
|
||||
gameState.provinces(provinceId.value)
|
||||
)
|
||||
}
|
||||
|
||||
+2
-2
@@ -15,7 +15,7 @@ object AvailableDeclineQuestCommandsFactory
|
||||
factionId: FactionId,
|
||||
provinceId: ProvinceId
|
||||
): Option[DeclineQuestAvailableCommand] = {
|
||||
val province = gameState.provinces(provinceId)
|
||||
val province = gameState.provinces(provinceId.value)
|
||||
|
||||
MoreOption.flatWhen(
|
||||
province.rulerIsTraveling
|
||||
@@ -26,7 +26,7 @@ object AvailableDeclineQuestCommandsFactory
|
||||
|
||||
Option.when(withQuests.nonEmpty) {
|
||||
DeclineQuestAvailableCommand(
|
||||
actingProvinceId = provinceId,
|
||||
actingProvinceId = provinceId.value,
|
||||
declinableHeroes = withQuests.map(uh =>
|
||||
expandedUnaffiliatedHero(gs = gameState, uh = uh)
|
||||
)
|
||||
|
||||
+9
-6
@@ -24,7 +24,7 @@ object AvailableDefendCommandsFactory extends AvailableCommandsFactoryForType {
|
||||
): Vector[ProvinceId] =
|
||||
if LegacyFactionUtils
|
||||
.provinces(
|
||||
factionId = from.rulingFactionId.get,
|
||||
factionId = FactionId(from.rulingFactionId.get),
|
||||
gameState = gs
|
||||
)
|
||||
.map(_.id)
|
||||
@@ -43,6 +43,7 @@ object AvailableDefendCommandsFactory extends AvailableCommandsFactoryForType {
|
||||
)
|
||||
.toVector
|
||||
.map(_.id)
|
||||
.map(ProvinceId(_))
|
||||
|
||||
private def makeDefendCommand(
|
||||
gameState: GameState,
|
||||
@@ -93,15 +94,17 @@ object AvailableDefendCommandsFactory extends AvailableCommandsFactoryForType {
|
||||
.toVector
|
||||
.map(_.id),
|
||||
actingProvinceId = province.id,
|
||||
suitableBattalionsForHeroes =
|
||||
BattalionSuitability.suitableBattalionsForHeroes(
|
||||
suitableBattalionsForHeroes = BattalionSuitability
|
||||
.suitableBattalionsForHeroes(
|
||||
hs = availableHeroes.toVector,
|
||||
bs = availableBattalions.toVector,
|
||||
bts = gameState.battalionTypes.toVector
|
||||
),
|
||||
)
|
||||
.map { case (hid, suitability) => (hid.value, suitability) },
|
||||
availableBattalions = availableBattalionsWithCosts,
|
||||
availableFleeProvinceIds =
|
||||
sortedFleeProvinces(from = province, gs = gameState),
|
||||
sortedFleeProvinces(from = province, gs = gameState)
|
||||
.map(_.value),
|
||||
recommendedUnits = recommendedUnits,
|
||||
hostileFactionIds = hostileArmies.toVector.map(_.factionId).distinct,
|
||||
hostileHeroCount = hostileUnits.size,
|
||||
@@ -123,6 +126,6 @@ object AvailableDefendCommandsFactory extends AvailableCommandsFactoryForType {
|
||||
): Option[DefendAvailableCommand] =
|
||||
makeDefendCommand(
|
||||
gameState,
|
||||
gameState.provinces(provinceId)
|
||||
gameState.provinces(provinceId.value)
|
||||
)
|
||||
}
|
||||
|
||||
+42
-35
@@ -35,15 +35,19 @@ object AvailableDiplomacyCommandsFactory
|
||||
extends AvailableCommandsFactoryForType {
|
||||
|
||||
def availableHeroIds(gs: GameState, pid: ProvinceId): Vector[HeroId] =
|
||||
gs.provinces(pid)
|
||||
gs.provinces(pid.value)
|
||||
.rulingFactionHeroIds
|
||||
.filter(hid => gs.heroes(hid).vigor >= MinVigorForDiplomacy.doubleValue)
|
||||
.map(HeroId(_))
|
||||
.toVector
|
||||
|
||||
def recommendedHeroId(gs: GameState, availableHids: Seq[HeroId]): HeroId =
|
||||
availableHids
|
||||
.sortBy(hid =>
|
||||
(LegacyHeroUtils.fatigue(gs.heroes(hid)), -gs.heroes(hid).vigor)
|
||||
(
|
||||
LegacyHeroUtils.fatigue(gs.heroes(hid.value)),
|
||||
-gs.heroes(hid.value).vigor
|
||||
)
|
||||
) match {
|
||||
case sortedHeroes =>
|
||||
sortedHeroes
|
||||
@@ -61,19 +65,19 @@ object AvailableDiplomacyCommandsFactory
|
||||
targetFid: FactionId
|
||||
): Option[DiplomacyOption] =
|
||||
Option.when(
|
||||
gs.provinces(pid).gold >= TruceGoldCost.intValue
|
||||
gs.provinces(pid.value).gold >= TruceGoldCost.intValue
|
||||
&& LegacyProvinceUtils.ruledByFactionLeader(
|
||||
province = gs.provinces(pid),
|
||||
province = gs.provinces(pid.value),
|
||||
gameState = gs
|
||||
)
|
||||
&& !LegacyFactionUtils.hasAlliance(
|
||||
fid1 = gs.provinces(pid).rulingFactionId.get,
|
||||
fid1 = FactionId(gs.provinces(pid.value).rulingFactionId.get),
|
||||
fid2 = targetFid,
|
||||
gs = gs
|
||||
)
|
||||
)(
|
||||
TruceOption(
|
||||
targetFactionId = targetFid,
|
||||
targetFactionId = targetFid.value,
|
||||
goldCost = TruceGoldCost.intValue
|
||||
)
|
||||
)
|
||||
@@ -85,15 +89,15 @@ object AvailableDiplomacyCommandsFactory
|
||||
targetFid: FactionId
|
||||
): Option[DiplomacyOption] =
|
||||
Option.when(
|
||||
gs.provinces(pid).gold >= AllianceGoldCost.intValue
|
||||
gs.provinces(pid.value).gold >= AllianceGoldCost.intValue
|
||||
&& LegacyProvinceUtils.ruledByFactionLeader(
|
||||
province = gs.provinces(pid),
|
||||
province = gs.provinces(pid.value),
|
||||
gameState = gs
|
||||
) && !LegacyFactionUtils
|
||||
.hasAlliance(fid1 = actingFid, fid2 = targetFid, gs = gs)
|
||||
)(
|
||||
AllianceOption(
|
||||
targetFactionId = targetFid,
|
||||
targetFactionId = targetFid.value,
|
||||
goldCost = AllianceGoldCost.intValue
|
||||
)
|
||||
)
|
||||
@@ -105,15 +109,15 @@ object AvailableDiplomacyCommandsFactory
|
||||
targetFid: FactionId
|
||||
): Option[DiplomacyOption] =
|
||||
Option.when(
|
||||
gs.provinces(pid).gold >= BreakAllianceGoldCost.intValue
|
||||
gs.provinces(pid.value).gold >= BreakAllianceGoldCost.intValue
|
||||
&& LegacyProvinceUtils.ruledByFactionLeader(
|
||||
province = gs.provinces(pid),
|
||||
province = gs.provinces(pid.value),
|
||||
gameState = gs
|
||||
) && LegacyFactionUtils
|
||||
.hasAlliance(fid1 = actingFid, fid2 = targetFid, gs = gs)
|
||||
)(
|
||||
BreakAllianceOption(
|
||||
targetFactionId = targetFid,
|
||||
targetFactionId = targetFid.value,
|
||||
goldCost = BreakAllianceGoldCost.intValue
|
||||
)
|
||||
)
|
||||
@@ -128,7 +132,7 @@ object AvailableDiplomacyCommandsFactory
|
||||
targetProvince =>
|
||||
val eligibleNeighbors: ProvinceId => Vector[ProvinceId] =
|
||||
p =>
|
||||
gs.provinces(p)
|
||||
gs.provinces(p.value)
|
||||
.neighbors
|
||||
.map(_.provinceId)
|
||||
.map(gs.provinces)
|
||||
@@ -142,16 +146,17 @@ object AvailableDiplomacyCommandsFactory
|
||||
// inviting across your ally's province
|
||||
LegacyFactionUtils
|
||||
.hasAlliance(
|
||||
neighborProvince.rulingFactionId.get,
|
||||
FactionId(neighborProvince.rulingFactionId.get),
|
||||
actingFid,
|
||||
gs
|
||||
)
|
||||
)
|
||||
.map(_.id)
|
||||
.map(ProvinceId(_))
|
||||
.toVector
|
||||
|
||||
ProvinceDistances
|
||||
.distance(pid, targetProvince.id, eligibleNeighbors)
|
||||
.distance(pid, ProvinceId(targetProvince.id), eligibleNeighbors)
|
||||
.isDefined
|
||||
}
|
||||
}
|
||||
@@ -163,8 +168,10 @@ object AvailableDiplomacyCommandsFactory
|
||||
targetFid: FactionId
|
||||
): Option[DiplomacyOption] =
|
||||
Option.when(
|
||||
gs.currentRoundId >= gs.factions(actingFid).earliestRoundForInvitation &&
|
||||
gs.provinces(pid).gold >= InviteGoldCost.intValue
|
||||
gs.currentRoundId >= gs
|
||||
.factions(actingFid.value)
|
||||
.earliestRoundForInvitation &&
|
||||
gs.provinces(pid.value).gold >= InviteGoldCost.intValue
|
||||
&& LegacyFactionUtils
|
||||
.provinceCount(
|
||||
targetFid,
|
||||
@@ -173,13 +180,13 @@ object AvailableDiplomacyCommandsFactory
|
||||
&& LegacyFactionUtils.provinceCount(actingFid, gs) > LegacyFactionUtils
|
||||
.provinceCount(targetFid, gs)
|
||||
&& LegacyProvinceUtils.ruledByFactionLeader(
|
||||
province = gs.provinces(pid),
|
||||
province = gs.provinces(pid.value),
|
||||
gameState = gs
|
||||
)
|
||||
&& hasClearPath(gs, pid, actingFid, targetFid)
|
||||
)(
|
||||
InvitationOption(
|
||||
targetFactionId = targetFid,
|
||||
targetFactionId = targetFid.value,
|
||||
goldCost = InviteGoldCost.intValue
|
||||
)
|
||||
)
|
||||
@@ -190,9 +197,9 @@ object AvailableDiplomacyCommandsFactory
|
||||
actingFid: FactionId,
|
||||
targetFid: FactionId
|
||||
): Vector[DiplomacyOption] = {
|
||||
val prisonersAvailableToOffer = availablePrisoners(gs.provinces(pid))
|
||||
val prisonersAvailableToOffer = availablePrisoners(gs.provinces(pid.value))
|
||||
val hostagesAvailableToOffer = availableHostages(gs, pid)
|
||||
val goldAvailableToOffer = gs.provinces(pid).gold
|
||||
val goldAvailableToOffer = gs.provinces(pid.value).gold
|
||||
|
||||
if prisonersAvailableToOffer.nonEmpty || hostagesAvailableToOffer.nonEmpty || goldAvailableToOffer > 0
|
||||
then
|
||||
@@ -203,7 +210,7 @@ object AvailableDiplomacyCommandsFactory
|
||||
)
|
||||
.map { prisonerToBeRansomed =>
|
||||
RansomOfferOption(
|
||||
targetFactionId = targetFid,
|
||||
targetFactionId = targetFid.value,
|
||||
ransomOffer = Some(
|
||||
RansomOfferDetails(
|
||||
prisonerToBeRansomed = Some(prisonerToBeRansomed),
|
||||
@@ -256,9 +263,9 @@ object AvailableDiplomacyCommandsFactory
|
||||
gameState: GameState
|
||||
): Boolean =
|
||||
gameState
|
||||
.factions(toFid)
|
||||
.factions(toFid.value)
|
||||
.incomingDiplomacyOffers
|
||||
.exists(_.originatingFactionId == fromFid)
|
||||
.exists(dof => FactionId(dof.originatingFactionId) == fromFid)
|
||||
|
||||
override def availableCommand(
|
||||
gameState: GameState,
|
||||
@@ -266,14 +273,14 @@ object AvailableDiplomacyCommandsFactory
|
||||
provinceId: ProvinceId
|
||||
): Option[DiplomacyAvailableCommand] = {
|
||||
if availableHeroIds(gameState, provinceId).isEmpty then None
|
||||
else if gameState.provinces(provinceId).rulingFactionHeroIds.size < 2 then
|
||||
None
|
||||
else if gameState.provinces(provinceId.value).rulingFactionHeroIds.size < 2
|
||||
then None
|
||||
else {
|
||||
gameState.factions.keys
|
||||
.filterNot(_ == factionId)
|
||||
.filterNot(fid => FactionId(fid) == factionId)
|
||||
.filterNot(fid =>
|
||||
hasIncomingDiplomacyOffer(
|
||||
toFid = fid,
|
||||
toFid = FactionId(fid),
|
||||
fromFid = factionId,
|
||||
gameState = gameState
|
||||
)
|
||||
@@ -283,7 +290,7 @@ object AvailableDiplomacyCommandsFactory
|
||||
gs = gameState,
|
||||
pid = provinceId,
|
||||
actingFid = factionId,
|
||||
targetFid = targetFid
|
||||
targetFid = FactionId(targetFid)
|
||||
)
|
||||
)
|
||||
.toVector
|
||||
@@ -320,10 +327,10 @@ object AvailableDiplomacyCommandsFactory
|
||||
|
||||
Some(
|
||||
DiplomacyAvailableCommand(
|
||||
availableHeroIds = heroIds,
|
||||
availableHeroIds = heroIds.map(_.value),
|
||||
options = options,
|
||||
actingProvinceId = provinceId,
|
||||
recommendedHeroId = recommendedHeroId(gameState, heroIds)
|
||||
actingProvinceId = provinceId.value,
|
||||
recommendedHeroId = recommendedHeroId(gameState, heroIds).value
|
||||
)
|
||||
)
|
||||
}
|
||||
@@ -349,14 +356,14 @@ object AvailableDiplomacyCommandsFactory
|
||||
provinceId: ProvinceId
|
||||
): Vector[HostageOfferedInExchange] =
|
||||
gameState
|
||||
.provinces(provinceId)
|
||||
.provinces(provinceId.value)
|
||||
.rulingFactionHeroIds
|
||||
.map(heroId => gameState.heroes(heroId))
|
||||
.filter(_.vigor >= MinVigorForDiplomacy.doubleValue)
|
||||
.map(hero =>
|
||||
HostageOfferedInExchange(
|
||||
heroId = hero.id,
|
||||
provinceIdWithHero = provinceId
|
||||
provinceIdWithHero = provinceId.value
|
||||
)
|
||||
)
|
||||
.toVector
|
||||
@@ -374,7 +381,7 @@ object AvailableDiplomacyCommandsFactory
|
||||
_.`type` == UNAFFILIATED_HERO_PRISONER
|
||||
)
|
||||
if prisoner.lastFaction.contains(factionId)
|
||||
if LegacyFactionUtils.isFactionLeader(prisoner.heroId, gameState)
|
||||
if LegacyFactionUtils.isFactionLeader(HeroId(prisoner.heroId), gameState)
|
||||
} yield PrisonerToBeRansomed(
|
||||
prisonerHeroId = prisoner.heroId,
|
||||
provinceIdForPrisoner = province.id
|
||||
|
||||
+3
-3
@@ -17,7 +17,7 @@ object AvailableFeastCommandFactory extends AvailableCommandsFactoryForType {
|
||||
.map(gameState.heroes)
|
||||
.exists(h =>
|
||||
h.vigor < h.constitution || LegacyHeroUtils
|
||||
.effectiveLoyalty(h.id, gameState) < 100.0
|
||||
.effectiveLoyalty(HeroId(h.id), gameState) < 100.0
|
||||
)
|
||||
|
||||
def feastGoldCost(province: Province): Int =
|
||||
@@ -28,7 +28,7 @@ object AvailableFeastCommandFactory extends AvailableCommandsFactoryForType {
|
||||
factionId: FactionId,
|
||||
provinceId: ProvinceId
|
||||
): Option[FeastAvailableCommand] = {
|
||||
val province = gameState.provinces(provinceId)
|
||||
val province = gameState.provinces(provinceId.value)
|
||||
val goldCost = feastGoldCost(province)
|
||||
|
||||
Option.when(
|
||||
@@ -36,7 +36,7 @@ object AvailableFeastCommandFactory extends AvailableCommandsFactoryForType {
|
||||
) {
|
||||
FeastAvailableCommand(
|
||||
goldCost = goldCost,
|
||||
actingProvinceId = provinceId
|
||||
actingProvinceId = provinceId.value
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -14,7 +14,7 @@ object AvailableHandleRiotGiveCommandFactory
|
||||
factionId: FactionId,
|
||||
provinceId: ProvinceId
|
||||
): Option[HandleRiotGiveAvailableCommand] = {
|
||||
val province = gameState.provinces(provinceId)
|
||||
val province = gameState.provinces(provinceId.value)
|
||||
|
||||
val food = Math.min(province.food, RiotMaxFood.intValue)
|
||||
val gold = Math.min(province.gold, RiotMaxGold.intValue)
|
||||
@@ -26,7 +26,7 @@ object AvailableHandleRiotGiveCommandFactory
|
||||
) && !province.hasActed && (food > 0 || gold > 0)
|
||||
) {
|
||||
HandleRiotGiveAvailableCommand(
|
||||
actingProvinceId = provinceId,
|
||||
actingProvinceId = provinceId.value,
|
||||
foodAvailable = food,
|
||||
goldAvailable = gold
|
||||
)
|
||||
|
||||
+5
-3
@@ -8,7 +8,7 @@ import net.eagle0.eagle.internal.game_state.GameState
|
||||
import net.eagle0.eagle.internal.province.Province
|
||||
import net.eagle0.eagle.library.settings.MaxGiftGold
|
||||
import net.eagle0.eagle.library.util.faction_utils.LegacyFactionUtils
|
||||
import net.eagle0.eagle.{FactionId, ProvinceId}
|
||||
import net.eagle0.eagle.{FactionId, HeroId, ProvinceId}
|
||||
|
||||
object AvailableHeroGiftCommandFactory extends AvailableCommandsFactoryForType {
|
||||
import net.eagle0.eagle.library.util.hero.LegacyHeroUtils.*
|
||||
@@ -18,7 +18,9 @@ object AvailableHeroGiftCommandFactory extends AvailableCommandsFactoryForType {
|
||||
gameState: GameState
|
||||
): Seq[EligibleGift] =
|
||||
province.rulingFactionHeroIds
|
||||
.filterNot(hid => LegacyFactionUtils.isFactionLeader(hid, gameState))
|
||||
.filterNot(hid =>
|
||||
LegacyFactionUtils.isFactionLeader(HeroId(hid), gameState)
|
||||
)
|
||||
.map(hid =>
|
||||
EligibleGift(
|
||||
recipientHeroId = hid,
|
||||
@@ -40,7 +42,7 @@ object AvailableHeroGiftCommandFactory extends AvailableCommandsFactoryForType {
|
||||
Some(
|
||||
HeroGiftAvailableCommand(
|
||||
eligibleGifts = eg,
|
||||
actingProvinceId = provinceId
|
||||
actingProvinceId = provinceId.value
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
+2
-2
@@ -30,7 +30,7 @@ object AvailableImproveCommandsFactory extends AvailableCommandsFactoryForType {
|
||||
factionId: FactionId,
|
||||
provinceId: ProvinceId
|
||||
): Option[ImproveAvailableCommand] = {
|
||||
val province = gameState.provinces(provinceId)
|
||||
val province = gameState.provinces(provinceId.value)
|
||||
|
||||
internalRequire(
|
||||
province.rulingFactionId.contains(factionId),
|
||||
@@ -55,7 +55,7 @@ object AvailableImproveCommandsFactory extends AvailableCommandsFactoryForType {
|
||||
ImproveAvailableCommand(
|
||||
availableHeroIds = availableHeroes.map(_.id),
|
||||
availableTypes = availableTypes.toVector,
|
||||
actingProvinceId = provinceId,
|
||||
actingProvinceId = provinceId.value,
|
||||
recommendedHeroId = availableHeroes.maxBy(heroSorting).id,
|
||||
lockedType = province.lockedImprovementType
|
||||
)
|
||||
|
||||
+4
-4
@@ -17,15 +17,15 @@ object AvailableIssueOrdersCommandFactory
|
||||
): Option[IssueOrdersAvailableCommand] =
|
||||
Option.when(
|
||||
gameState
|
||||
.provinces(provinceId)
|
||||
.provinces(provinceId.value)
|
||||
.rulingHeroId
|
||||
.exists(gameState.factions(factionId).leaders.contains) &&
|
||||
.exists(gameState.factions(factionId.value).leaders.contains) &&
|
||||
LegacyFactionUtils.provinceCount(factionId, gameState) > 1
|
||||
) {
|
||||
IssueOrdersAvailableCommand(
|
||||
actingProvinceId = provinceId,
|
||||
actingProvinceId = provinceId.value,
|
||||
currentOrders = gameState.provinces.values
|
||||
.filter(_.rulingFactionId.contains(factionId))
|
||||
.filter(_.rulingFactionId.contains(factionId.value))
|
||||
.toVector
|
||||
.sortBy(_.name)
|
||||
.map(p =>
|
||||
|
||||
+11
-9
@@ -3,7 +3,7 @@ package net.eagle0.eagle.library.actions.availability
|
||||
import net.eagle0.eagle.api.available_command.ReconAvailableCommand
|
||||
import net.eagle0.eagle.internal.game_state.GameState
|
||||
import net.eagle0.eagle.library.settings.MinVigorForRecon
|
||||
import net.eagle0.eagle.{FactionId, ProvinceId}
|
||||
import net.eagle0.eagle.{FactionId, HeroId, ProvinceId}
|
||||
|
||||
object AvailableReconCommandFactory extends AvailableCommandsFactoryForType {
|
||||
override def availableCommand(
|
||||
@@ -11,7 +11,7 @@ object AvailableReconCommandFactory extends AvailableCommandsFactoryForType {
|
||||
factionId: FactionId,
|
||||
provinceId: ProvinceId
|
||||
): Option[ReconAvailableCommand] = {
|
||||
val province = gameState.provinces(provinceId)
|
||||
val province = gameState.provinces(provinceId.value)
|
||||
|
||||
if province.rulingFactionHeroIds.size < 2 then None
|
||||
else {
|
||||
@@ -19,23 +19,25 @@ object AvailableReconCommandFactory extends AvailableCommandsFactoryForType {
|
||||
.map(heroId => gameState.heroes(heroId))
|
||||
.filter(_.profession.isRanger)
|
||||
.filter(_.vigor >= MinVigorForRecon.doubleValue)
|
||||
.map(_.id)
|
||||
.map(h => HeroId(h.id))
|
||||
|
||||
val availableTargets = gameState.provinces.values
|
||||
.filterNot(_.rulingFactionId.contains(factionId))
|
||||
.filterNot(_.rulingFactionId.contains(factionId.value))
|
||||
.filterNot(
|
||||
_.incomingEndTurnActions
|
||||
.exists(eta => eta.action.isRecon && eta.fromFactionId == factionId)
|
||||
.exists(eta =>
|
||||
eta.action.isRecon && eta.fromFactionId == factionId.value
|
||||
)
|
||||
)
|
||||
.toVector
|
||||
.sortBy(_.name)
|
||||
.map(_.id)
|
||||
.map(p => ProvinceId(p.id))
|
||||
|
||||
Option.when(availableHeroes.nonEmpty && availableTargets.nonEmpty) {
|
||||
ReconAvailableCommand(
|
||||
availableHeroIds = availableHeroes,
|
||||
availableTargetProvinces = availableTargets,
|
||||
actingProvinceId = provinceId
|
||||
availableHeroIds = availableHeroes.map(_.value),
|
||||
availableTargetProvinces = availableTargets.map(_.value),
|
||||
actingProvinceId = provinceId.value
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -14,7 +14,7 @@ object AvailableResolveAllianceOfferCommandFactory {
|
||||
factionId: FactionId
|
||||
): Vector[DiplomacyOffer] =
|
||||
gameState
|
||||
.factions(factionId)
|
||||
.factions(factionId.value)
|
||||
.incomingDiplomacyOffers
|
||||
.filter(_.status == DIPLOMACY_OFFER_STATUS_UNRESOLVED)
|
||||
.collect { diploOffer =>
|
||||
@@ -47,7 +47,7 @@ object AvailableResolveAllianceOfferCommandFactory {
|
||||
) =>
|
||||
DiplomacyOffer(
|
||||
originatingFactionId = originatingFactionId,
|
||||
targetFactionId = factionId,
|
||||
targetFactionId = factionId.value,
|
||||
offerDetails = AllianceOfferDetails(),
|
||||
messengerHeroId = messengerHeroId,
|
||||
messengerOriginProvinceId = messengerOriginProvinceId,
|
||||
|
||||
+4
-4
@@ -18,7 +18,7 @@ object AvailableResolveBreakAllianceCommandFactory {
|
||||
factionId: FactionId
|
||||
): Vector[DiplomacyOffer] =
|
||||
gameState
|
||||
.factions(factionId)
|
||||
.factions(factionId.value)
|
||||
.incomingDiplomacyOffers
|
||||
.filter(_.status == DIPLOMACY_OFFER_STATUS_UNRESOLVED)
|
||||
.collect { diploOffer =>
|
||||
@@ -41,8 +41,8 @@ object AvailableResolveBreakAllianceCommandFactory {
|
||||
case DiplomacyOffer(
|
||||
originatingFactionId: FactionId,
|
||||
_ /* targetFactionId */,
|
||||
messengerHeroId: FactionId,
|
||||
messengerOriginProvinceId: FactionId,
|
||||
messengerHeroId: Int,
|
||||
messengerOriginProvinceId: Int,
|
||||
status: DiplomacyOfferStatus,
|
||||
_ /* eligibleStatuses */,
|
||||
offerTextId: String,
|
||||
@@ -51,7 +51,7 @@ object AvailableResolveBreakAllianceCommandFactory {
|
||||
) =>
|
||||
DiplomacyOffer(
|
||||
originatingFactionId = originatingFactionId,
|
||||
targetFactionId = factionId,
|
||||
targetFactionId = factionId.value,
|
||||
offerDetails = details,
|
||||
messengerHeroId = messengerHeroId,
|
||||
messengerOriginProvinceId = messengerOriginProvinceId,
|
||||
|
||||
+1
-1
@@ -73,7 +73,7 @@ object AvailableResolveRansomOfferCommandFactory {
|
||||
factionId: FactionId
|
||||
): Option[ResolveRansomOfferAvailableCommand] =
|
||||
gameState
|
||||
.factions(factionId)
|
||||
.factions(factionId.value)
|
||||
.incomingDiplomacyOffers
|
||||
.collect { diplomacyOffer =>
|
||||
diplomacyOffer.offerDetails match {
|
||||
|
||||
+1
-1
@@ -52,5 +52,5 @@ object AvailableResolveTributeCommandsFactory
|
||||
factionId: FactionId,
|
||||
provinceId: ProvinceId
|
||||
): Option[ResolveTributeAvailableCommand] =
|
||||
makeResolveTributeCommand(gameState.provinces(provinceId), gameState)
|
||||
makeResolveTributeCommand(gameState.provinces(provinceId.value), gameState)
|
||||
}
|
||||
|
||||
+2
-2
@@ -17,7 +17,7 @@ object AvailableResolveTruceOfferCommandFactory {
|
||||
factionId: FactionId
|
||||
): Vector[DiplomacyOffer] =
|
||||
gameState
|
||||
.factions(factionId)
|
||||
.factions(factionId.value)
|
||||
.incomingDiplomacyOffers
|
||||
.filter(_.status == DIPLOMACY_OFFER_STATUS_UNRESOLVED)
|
||||
.collect { diploOffer =>
|
||||
@@ -50,7 +50,7 @@ object AvailableResolveTruceOfferCommandFactory {
|
||||
) =>
|
||||
DiplomacyOffer(
|
||||
originatingFactionId = originatingFactionId,
|
||||
targetFactionId = factionId,
|
||||
targetFactionId = factionId.value,
|
||||
offerDetails = TruceOfferDetails(
|
||||
endDate = Some(
|
||||
gameState.currentDate.get.addMonths(TruceMonths.intValue)
|
||||
|
||||
+1
-1
@@ -12,7 +12,7 @@ object AvailableRestCommandsFactory extends AvailableCommandsFactoryForType {
|
||||
): Option[RestAvailableCommand] =
|
||||
Some(
|
||||
RestAvailableCommand(
|
||||
actingProvinceId = provinceId
|
||||
actingProvinceId = provinceId.value
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
+2
-2
@@ -10,7 +10,7 @@ object AvailableReturnCommandsFactory extends AvailableCommandsFactoryForType {
|
||||
factionId: FactionId,
|
||||
provinceId: ProvinceId
|
||||
): Option[ReturnAvailableCommand] = {
|
||||
val province = gameState.provinces(provinceId)
|
||||
val province = gameState.provinces(provinceId.value)
|
||||
|
||||
require(
|
||||
province.rulingFactionId.contains(factionId),
|
||||
@@ -18,7 +18,7 @@ object AvailableReturnCommandsFactory extends AvailableCommandsFactoryForType {
|
||||
)
|
||||
|
||||
Option.when(province.rulerIsTraveling)(
|
||||
ReturnAvailableCommand(actingProvinceId = provinceId)
|
||||
ReturnAvailableCommand(actingProvinceId = provinceId.value)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -53,6 +53,6 @@ object AvailableStartEpidemicCommandFactory
|
||||
): Option[StartEpidemicAvailableCommand] =
|
||||
makeStartEpidemicCommand(
|
||||
gameState,
|
||||
gameState.provinces(provinceId)
|
||||
gameState.provinces(provinceId.value)
|
||||
)
|
||||
}
|
||||
|
||||
+11
-9
@@ -14,7 +14,7 @@ object AvailableSwearBrotherhoodCommandFactory
|
||||
|
||||
def canHaveMoreLeaders(gameState: GameState, factionId: FactionId): Boolean =
|
||||
gameState
|
||||
.factions(factionId)
|
||||
.factions(factionId.value)
|
||||
.leaders
|
||||
.length < MaximumFactionLeaders.intValue
|
||||
|
||||
@@ -24,9 +24,9 @@ object AvailableSwearBrotherhoodCommandFactory
|
||||
provinceId: ProvinceId
|
||||
): Boolean =
|
||||
gameState
|
||||
.provinces(provinceId)
|
||||
.provinces(provinceId.value)
|
||||
.rulingFactionHeroIds
|
||||
.contains(gameState.factions(factionId).factionHeadId)
|
||||
.contains(gameState.factions(factionId.value).factionHeadId)
|
||||
|
||||
private def eligibleHeroes(
|
||||
gameState: GameState,
|
||||
@@ -34,12 +34,14 @@ object AvailableSwearBrotherhoodCommandFactory
|
||||
provinceId: ProvinceId
|
||||
): Vector[HeroId] =
|
||||
gameState
|
||||
.provinces(provinceId)
|
||||
.provinces(provinceId.value)
|
||||
.rulingFactionHeroIds
|
||||
.map(gameState.heroes)
|
||||
.filter(_.loyalty >= MinimumLoyaltyForSwearBrotherhood.doubleValue)
|
||||
.filterNot(h => gameState.factions(factionId).leaders.contains(h.id))
|
||||
.map(_.id)
|
||||
.filterNot(h =>
|
||||
gameState.factions(factionId.value).leaders.contains(h.id)
|
||||
)
|
||||
.map(h => HeroId(h.id))
|
||||
.toVector
|
||||
|
||||
override def availableCommand(
|
||||
@@ -60,16 +62,16 @@ object AvailableSwearBrotherhoodCommandFactory
|
||||
SwearBrotherhoodAvailableCommand(
|
||||
availableHeroes = hs.map { hid =>
|
||||
HeroAndBackstory(
|
||||
heroId = hid,
|
||||
heroId = hid.value,
|
||||
backstoryTextId = gameState
|
||||
.heroes(hid)
|
||||
.heroes(hid.value)
|
||||
.backstoryVersions
|
||||
.lastOption
|
||||
.map(_.textId)
|
||||
.getOrElse("")
|
||||
)
|
||||
},
|
||||
actingProvinceId = provinceId
|
||||
actingProvinceId = provinceId.value
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
+2
-2
@@ -12,7 +12,7 @@ object AvailableTradeCommandFactory extends AvailableCommandsFactoryForType {
|
||||
factionId: FactionId,
|
||||
provinceId: ProvinceId
|
||||
): Option[TradeAvailableCommand] = {
|
||||
val province = gameState.provinces(provinceId)
|
||||
val province = gameState.provinces(provinceId.value)
|
||||
|
||||
Option.when(
|
||||
province.rulerIsTraveling && (province.gold > 0 || province.food > 0)
|
||||
@@ -22,7 +22,7 @@ object AvailableTradeCommandFactory extends AvailableCommandsFactoryForType {
|
||||
goldAvailable = province.gold,
|
||||
foodSellPrice = BaseFoodSellPrice.doubleValue * province.priceIndex,
|
||||
foodBuyPrice = BaseFoodBuyPrice.doubleValue * province.priceIndex,
|
||||
actingProvinceId = provinceId
|
||||
actingProvinceId = provinceId.value
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -23,7 +23,7 @@ object AvailableTrainCommandsFactory extends AvailableCommandsFactoryForType {
|
||||
factionId: FactionId,
|
||||
provinceId: ProvinceId
|
||||
): Option[TrainAvailableCommand] = {
|
||||
val province = gameState.provinces(provinceId)
|
||||
val province = gameState.provinces(provinceId.value)
|
||||
val availableHeroes = province.rulingFactionHeroIds
|
||||
.map(heroId => gameState.heroes(heroId))
|
||||
.filter(_.vigor >= MinVigorForTrain.doubleValue)
|
||||
@@ -35,7 +35,7 @@ object AvailableTrainCommandsFactory extends AvailableCommandsFactoryForType {
|
||||
Option.when(availableHeroes.nonEmpty && hasTrainableBattalion) {
|
||||
TrainAvailableCommand(
|
||||
availableHeroIds = availableHeroes.map(_.id),
|
||||
actingProvinceId = provinceId,
|
||||
actingProvinceId = provinceId.value,
|
||||
recommendedHeroId = availableHeroes.maxBy(heroSorting).id
|
||||
)
|
||||
}
|
||||
|
||||
+2
-2
@@ -13,7 +13,7 @@ object AvailableTravelCommandsFactory extends AvailableCommandsFactoryForType {
|
||||
factionId: FactionId,
|
||||
provinceId: ProvinceId
|
||||
): Option[TravelAvailableCommand] = {
|
||||
val province = gameState.provinces(provinceId)
|
||||
val province = gameState.provinces(provinceId.value)
|
||||
|
||||
require(
|
||||
province.rulingFactionId.contains(factionId),
|
||||
@@ -28,7 +28,7 @@ object AvailableTravelCommandsFactory extends AvailableCommandsFactoryForType {
|
||||
.exists(_ >= MinVigorForTravel.doubleValue)
|
||||
) {
|
||||
TravelAvailableCommand(
|
||||
actingProvinceId = provinceId
|
||||
actingProvinceId = provinceId.value
|
||||
)
|
||||
|
||||
}
|
||||
|
||||
+1
-1
@@ -50,7 +50,7 @@ case class SafePassageArmiesProceedAction(
|
||||
provinceId = toProvinceId,
|
||||
newIncomingArmies = ha.armies.map(ma =>
|
||||
ma.copy(
|
||||
arrivalRound = currentRoundId + 1,
|
||||
arrivalRound = currentRoundId.value + 1,
|
||||
destinationProvinceId = toProvinceId,
|
||||
originProvinceId = p.id,
|
||||
army = ma.army.copy(
|
||||
|
||||
+2
-2
@@ -15,7 +15,7 @@ import net.eagle0.eagle.model.state.hero.concrete.HeroC
|
||||
import net.eagle0.eagle.model.state.unaffiliated_hero.RecruitmentInfo
|
||||
import net.eagle0.eagle.model.state.unaffiliated_hero.UnaffiliatedHeroType.Traveler
|
||||
import net.eagle0.eagle.model.state.unaffiliated_hero.concrete.UnaffiliatedHeroC
|
||||
import net.eagle0.eagle.{FactionId, GameId, ProvinceId, RoundId}
|
||||
import net.eagle0.eagle.{ClientTextId, FactionId, GameId, ProvinceId, RoundId}
|
||||
|
||||
case class UnaffiliatedHeroAppearedAction(
|
||||
hero: HeroC,
|
||||
@@ -39,7 +39,7 @@ case class UnaffiliatedHeroAppearedAction(
|
||||
if hero.backstoryVersions.isEmpty then
|
||||
Vector(
|
||||
BackstoryVersion(
|
||||
textId = newBackstoryTextId,
|
||||
textId = ClientTextId(newBackstoryTextId),
|
||||
date = currentDate
|
||||
)
|
||||
)
|
||||
|
||||
+1
-1
@@ -73,7 +73,7 @@ object ApprehendOutlawCommand {
|
||||
changedProvinces = Vector(
|
||||
ChangedProvinceC(
|
||||
provinceId = province.id,
|
||||
removedUnaffiliatedHeroIds = Vector(targetedHeroId),
|
||||
removedUnaffiliatedHeroIds = Vector(targetedHeroId.value),
|
||||
newUnaffiliatedHeroes = Vector(
|
||||
province.unaffiliatedHeroes
|
||||
.find(_.heroId == targetedHeroId)
|
||||
|
||||
@@ -55,7 +55,7 @@ object DefendCommand {
|
||||
defendingPlayer = actingFactionId,
|
||||
province = actingProvince,
|
||||
defendingUnits = defendingUnits,
|
||||
fleeProvinceId = selectedCommand.fleeProvinceId
|
||||
fleeProvinceId = selectedCommand.fleeProvinceId.map(ProvinceId(_))
|
||||
)
|
||||
}
|
||||
|
||||
@@ -79,9 +79,9 @@ object DefendCommand {
|
||||
|
||||
ActionResult(
|
||||
`type` = DEFEND,
|
||||
player = Some(defendingPlayer),
|
||||
province = Some(province.id),
|
||||
provinceActed = Some(province.id),
|
||||
player = Some(defendingPlayer.value),
|
||||
province = Some(province.id.value),
|
||||
provinceActed = Some(province.id.value),
|
||||
changedProvinces = Vector(
|
||||
ChangedProvince(
|
||||
id = province.id,
|
||||
|
||||
+33
-30
@@ -52,11 +52,14 @@ object DiplomacyCommand {
|
||||
option: DiplomacyOption.NonEmpty
|
||||
): FactionId =
|
||||
option match {
|
||||
case TruceOption(tfid, _, _ /* unknownFieldSet */ ) => tfid
|
||||
case InvitationOption(tfid, _, _ /* unknownFieldSet */ ) => tfid
|
||||
case RansomOfferOption(tfid, _, _ /* unknownFieldSet */ ) => tfid
|
||||
case AllianceOption(tfid, _, _ /* unknownFieldSet */ ) => tfid
|
||||
case BreakAllianceOption(tfid, _, _ /* unknownFieldSet */ ) => tfid
|
||||
case TruceOption(tfid, _, _ /* unknownFieldSet */ ) => FactionId(tfid)
|
||||
case InvitationOption(tfid, _, _ /* unknownFieldSet */ ) =>
|
||||
FactionId(tfid)
|
||||
case RansomOfferOption(tfid, _, _ /* unknownFieldSet */ ) =>
|
||||
FactionId(tfid)
|
||||
case AllianceOption(tfid, _, _ /* unknownFieldSet */ ) => FactionId(tfid)
|
||||
case BreakAllianceOption(tfid, _, _ /* unknownFieldSet */ ) =>
|
||||
FactionId(tfid)
|
||||
}
|
||||
|
||||
def make(
|
||||
@@ -102,8 +105,8 @@ object DiplomacyCommand {
|
||||
sc = selectedCommand,
|
||||
actingProvince = actingProvince,
|
||||
fid = actingFactionId,
|
||||
targetFid = targetFid,
|
||||
actingHero = actingHeroId,
|
||||
targetFid = FactionId(targetFid),
|
||||
actingHero = HeroId(actingHeroId),
|
||||
goldCost = goldCost,
|
||||
gameId = gameId,
|
||||
currentRoundId = currentRoundId
|
||||
@@ -125,8 +128,8 @@ object DiplomacyCommand {
|
||||
sc = selectedCommand,
|
||||
actingProvince = actingProvince,
|
||||
fid = actingFactionId,
|
||||
targetFid = targetFid,
|
||||
actingHero = actingHeroId,
|
||||
targetFid = FactionId(targetFid),
|
||||
actingHero = HeroId(actingHeroId),
|
||||
goldCost = goldCost,
|
||||
gameId = gameId,
|
||||
currentRoundId = currentRoundId,
|
||||
@@ -337,12 +340,12 @@ object DiplomacyCommand {
|
||||
_.`type` := TRUCE_OFFERED,
|
||||
_.changedFactions := Vector(
|
||||
ChangedFaction(
|
||||
id = targetFid,
|
||||
id = targetFid.value,
|
||||
addedIncomingDiplomacyOffers = Vector(truceOffer)
|
||||
),
|
||||
ChangedFaction(
|
||||
id = fid,
|
||||
addedOutgoingTruceOfferPartners = Vector(targetFid)
|
||||
id = fid.value,
|
||||
addedOutgoingTruceOfferPartners = Vector(targetFid.value)
|
||||
)
|
||||
),
|
||||
_.newGeneratedTextRequests :+= GeneratedTextRequest(
|
||||
@@ -391,12 +394,12 @@ object DiplomacyCommand {
|
||||
_.`type` := ALLIANCE_OFFERED,
|
||||
_.changedFactions := Vector(
|
||||
ChangedFaction(
|
||||
id = targetFid,
|
||||
id = targetFid.value,
|
||||
addedIncomingDiplomacyOffers = Vector(allianceOffer)
|
||||
),
|
||||
ChangedFaction(
|
||||
id = fid,
|
||||
addedOutgoingAllianceOfferPartners = Vector(targetFid)
|
||||
id = fid.value,
|
||||
addedOutgoingAllianceOfferPartners = Vector(targetFid.value)
|
||||
)
|
||||
),
|
||||
_.newGeneratedTextRequests :+= GeneratedTextRequest(
|
||||
@@ -445,7 +448,7 @@ object DiplomacyCommand {
|
||||
_.`type` := ALLIANCE_BROKEN,
|
||||
_.changedFactions := Vector(
|
||||
ChangedFaction(
|
||||
id = targetFid,
|
||||
id = targetFid.value,
|
||||
addedIncomingDiplomacyOffers = Vector(breakAllianceOffer)
|
||||
)
|
||||
),
|
||||
@@ -494,23 +497,23 @@ object DiplomacyCommand {
|
||||
_.`type` := FACTION_INVITED,
|
||||
_.changedFactions := Vector(
|
||||
ChangedFaction(
|
||||
id = targetFid,
|
||||
id = targetFid.value,
|
||||
addedIncomingDiplomacyOffers = Vector(invitation)
|
||||
),
|
||||
ChangedFaction(
|
||||
id = fid,
|
||||
addedOutgoingInvitationPartners = Vector(targetFid)
|
||||
id = fid.value,
|
||||
addedOutgoingInvitationPartners = Vector(targetFid.value)
|
||||
)
|
||||
),
|
||||
_.newGeneratedTextRequests :+= GeneratedTextRequest(
|
||||
id = textId,
|
||||
eagleGameId = gameId,
|
||||
eagleGameId = gameId.value,
|
||||
details = InvitationMessage(
|
||||
offeringFactionId = fid,
|
||||
targetFactionId = targetFid,
|
||||
messengerHeroId = actingHero
|
||||
offeringFactionId = fid.value,
|
||||
targetFactionId = targetFid.value,
|
||||
messengerHeroId = actingHero.value
|
||||
),
|
||||
recipientFactionIds = Vector(targetFid)
|
||||
recipientFactionIds = Vector(targetFid.value)
|
||||
)
|
||||
)
|
||||
}
|
||||
@@ -535,12 +538,12 @@ object DiplomacyCommand {
|
||||
override def immediateExecute: ActionResult =
|
||||
ActionResult(
|
||||
`type` = RANSOM_STARTED,
|
||||
province = Some(pid),
|
||||
player = Some(fid),
|
||||
provinceActed = Some(pid),
|
||||
province = Some(pid.value),
|
||||
player = Some(fid.value),
|
||||
provinceActed = Some(pid.value),
|
||||
changedFactions = Vector(
|
||||
ChangedFaction(
|
||||
id = targetFid,
|
||||
id = targetFid.value,
|
||||
addedIncomingDiplomacyOffers = Vector(
|
||||
DiplomacyOffer(
|
||||
originatingFactionId = fid,
|
||||
@@ -554,8 +557,8 @@ object DiplomacyCommand {
|
||||
)
|
||||
),
|
||||
ChangedFaction(
|
||||
id = fid,
|
||||
addedOutgoingRansomOfferPartners = Vector(targetFid)
|
||||
id = fid.value,
|
||||
addedOutgoingRansomOfferPartners = Vector(targetFid.value)
|
||||
)
|
||||
),
|
||||
newGeneratedTextRequests = Vector(
|
||||
|
||||
+10
-10
@@ -31,15 +31,15 @@ object FreeForAllDecisionCommand {
|
||||
override def immediateExecute: ActionResult =
|
||||
ActionResult(
|
||||
`type` = ARMY_ADVANCED_TO_FREE_FOR_ALL,
|
||||
player = Some(attackingFactionId),
|
||||
province = Some(provinceId),
|
||||
player = Some(attackingFactionId.value),
|
||||
province = Some(provinceId.value),
|
||||
changedProvinces = Vector(
|
||||
ChangedProvince(
|
||||
id = provinceId,
|
||||
id = provinceId.value,
|
||||
// set the new status on the hostile army
|
||||
hostileArmyStatusChanges = Vector(
|
||||
HostileArmyGroupStatusChange(
|
||||
factionId = attackingFactionId,
|
||||
factionId = attackingFactionId.value,
|
||||
newStatus = AwaitingFreeForAll()
|
||||
)
|
||||
)
|
||||
@@ -56,15 +56,15 @@ object FreeForAllDecisionCommand {
|
||||
override def immediateExecute: ActionResult =
|
||||
ActionResult(
|
||||
`type` = ARMY_WITHDREW_FROM_FREE_FOR_ALL,
|
||||
player = Some(attackingFactionId),
|
||||
province = Some(provinceId),
|
||||
player = Some(attackingFactionId.value),
|
||||
province = Some(provinceId.value),
|
||||
changedProvinces = Vector(
|
||||
ChangedProvince(
|
||||
id = provinceId,
|
||||
id = provinceId.value,
|
||||
// set the new status on the hostile army
|
||||
hostileArmyStatusChanges = Vector(
|
||||
HostileArmyGroupStatusChange(
|
||||
factionId = attackingFactionId,
|
||||
factionId = attackingFactionId.value,
|
||||
newStatus = Withdrawing()
|
||||
)
|
||||
)
|
||||
@@ -94,13 +94,13 @@ object FreeForAllDecisionCommand {
|
||||
FreeForAllAttackCommand(
|
||||
sc = selectedCommand,
|
||||
attackingFactionId = actingFactionId,
|
||||
provinceId = availableCommand.provinceId
|
||||
provinceId = ProvinceId(availableCommand.provinceId)
|
||||
)
|
||||
case WithdrawDecision(_ /* unknownFieldSet */ ) =>
|
||||
FreeForAllWithdrawCommand(
|
||||
sc = selectedCommand,
|
||||
attackingFactionId = actingFactionId,
|
||||
provinceId = availableCommand.provinceId
|
||||
provinceId = ProvinceId(availableCommand.provinceId)
|
||||
)
|
||||
case DemandTributeDecision(_, _ /* unknownFieldSet */ ) =>
|
||||
throw new EagleCommandException(
|
||||
|
||||
+7
-7
@@ -325,14 +325,14 @@ object OrganizeTroopsCommand {
|
||||
|
||||
// Merge in moved troops to existing battalions
|
||||
val afterChangingBattalions =
|
||||
afterAddingBattalions ++ changedBattalions
|
||||
(afterAddingBattalions ++ changedBattalions
|
||||
.map { cb =>
|
||||
mergeInMultiple(
|
||||
afterAddingBattalions(cb.id),
|
||||
cb.troopsFromOtherBattalion
|
||||
)
|
||||
}
|
||||
.map(b => b.id -> b)
|
||||
.map(b => b.id -> b)).toMap
|
||||
|
||||
// Add new troops to new battalions
|
||||
val afterAddingForNew =
|
||||
@@ -356,14 +356,14 @@ object OrganizeTroopsCommand {
|
||||
|
||||
ActionResult(
|
||||
`type` = ORGANIZE_TROOPS,
|
||||
player = Some(factionId),
|
||||
player = Some(factionId.value),
|
||||
changedBattalions = changedBatt.filterNot(_.size == 0).toVector,
|
||||
newBattalions = newBatt.toVector,
|
||||
destroyedBattalionIds =
|
||||
changedBatt.filter(_.size == 0).map(_.id).toVector,
|
||||
changedBatt.filter(_.size == 0).map(_.id.value).toVector,
|
||||
changedProvinces = Vector(
|
||||
ChangedProvince(
|
||||
id = province.id,
|
||||
id = province.id.value,
|
||||
goldDelta = Some(-afterAddingForChanged.cost),
|
||||
newPriceIndex = PriceIndexUtils.maybeNewPriceIndexFromGoldSpend(
|
||||
province.priceIndex,
|
||||
@@ -371,8 +371,8 @@ object OrganizeTroopsCommand {
|
||||
)
|
||||
)
|
||||
),
|
||||
provinceActed = Some(province.id),
|
||||
province = Some(province.id)
|
||||
provinceActed = Some(province.id.value),
|
||||
province = Some(province.id.value)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
+11
-8
@@ -25,7 +25,7 @@ import net.eagle0.eagle.library.actions.impl.common.SimpleAction
|
||||
import net.eagle0.eagle.library.actions.generated_text_request_generators.diplomacy_llm_helpers.DiplomacyResolutionLlmRequestGenerator
|
||||
import net.eagle0.eagle.library.util.EagleRequire.commandRequire
|
||||
import net.eagle0.eagle.library.{EagleCommandException, EagleInternalException}
|
||||
import net.eagle0.eagle.{FactionId, GameId, RoundId}
|
||||
import net.eagle0.eagle.{FactionId, GameId, HeroId, RoundId}
|
||||
|
||||
object ResolveBreakAllianceCommand {
|
||||
private case class ResolveBreakAllianceCommand(
|
||||
@@ -38,11 +38,12 @@ object ResolveBreakAllianceCommand {
|
||||
override def immediateExecute: ActionResult = {
|
||||
val llmRequest =
|
||||
DiplomacyResolutionLlmRequestGenerator.breakAllianceResolutionRequest(
|
||||
gameId = gameId,
|
||||
currentRoundId = currentRoundId,
|
||||
originatingFactionId = breakAllianceOffer.originatingFactionId,
|
||||
targetFactionId = breakAllianceOffer.targetFactionId,
|
||||
messengerHeroId = breakAllianceOffer.messengerHeroId,
|
||||
gameId = gameId.value,
|
||||
currentRoundId = currentRoundId.value,
|
||||
originatingFactionId =
|
||||
FactionId(breakAllianceOffer.originatingFactionId),
|
||||
targetFactionId = FactionId(breakAllianceOffer.targetFactionId),
|
||||
messengerHeroId = HeroId(breakAllianceOffer.messengerHeroId),
|
||||
resolution = resolution
|
||||
)
|
||||
|
||||
@@ -64,7 +65,8 @@ object ResolveBreakAllianceCommand {
|
||||
case DIPLOMACY_OFFER_STATUS_ACCEPTED =>
|
||||
BreakAllianceAcceptedDetails(
|
||||
offeringFactionId = breakAllianceOffer.originatingFactionId,
|
||||
targetFactionId = breakAllianceOffer.targetFactionId,
|
||||
targetFactionId =
|
||||
FactionId(breakAllianceOffer.targetFactionId),
|
||||
ambassadorHeroId = breakAllianceOffer.messengerHeroId
|
||||
)
|
||||
|
||||
@@ -76,7 +78,8 @@ object ResolveBreakAllianceCommand {
|
||||
case DIPLOMACY_OFFER_STATUS_IMPRISONED =>
|
||||
BreakAllianceAmbassadorImprisonedDetails(
|
||||
offeringFactionId = breakAllianceOffer.originatingFactionId,
|
||||
targetFactionId = breakAllianceOffer.targetFactionId,
|
||||
targetFactionId =
|
||||
FactionId(breakAllianceOffer.targetFactionId),
|
||||
ambassadorHeroId = breakAllianceOffer.messengerHeroId
|
||||
)
|
||||
|
||||
|
||||
+4
-4
@@ -26,7 +26,7 @@ import net.eagle0.eagle.library.actions.impl.common.SimpleAction
|
||||
import net.eagle0.eagle.library.actions.generated_text_request_generators.diplomacy_llm_helpers.DiplomacyResolutionLlmRequestGenerator
|
||||
import net.eagle0.eagle.library.util.EagleRequire.commandRequire
|
||||
import net.eagle0.eagle.library.{EagleCommandException, EagleInternalException}
|
||||
import net.eagle0.eagle.{GameId, RoundId}
|
||||
import net.eagle0.eagle.{GameId, RoundId, FactionId, HeroId}
|
||||
|
||||
object ResolveTruceOfferCommand {
|
||||
private case class ResolveTruceOfferCommand(
|
||||
@@ -41,9 +41,9 @@ object ResolveTruceOfferCommand {
|
||||
DiplomacyResolutionLlmRequestGenerator.truceResolutionRequest(
|
||||
gameId = gameId,
|
||||
currentRoundId = currentRoundId,
|
||||
originatingFactionId = truceOffer.originatingFactionId,
|
||||
targetFactionId = truceOffer.targetFactionId,
|
||||
messengerHeroId = truceOffer.messengerHeroId,
|
||||
originatingFactionId = FactionId(truceOffer.originatingFactionId),
|
||||
targetFactionId = FactionId(truceOffer.targetFactionId),
|
||||
messengerHeroId = HeroId(truceOffer.messengerHeroId),
|
||||
resolution = resolution
|
||||
)
|
||||
|
||||
|
||||
+2
-2
@@ -10,7 +10,7 @@ object FactionInfoUtilities {
|
||||
gameState: GameState
|
||||
): Faction =
|
||||
gameState.factions.getOrElse(
|
||||
factionId,
|
||||
gameState.destroyedFactions(factionId)
|
||||
factionId.value,
|
||||
gameState.destroyedFactions(factionId.value)
|
||||
)
|
||||
}
|
||||
|
||||
+3
-2
@@ -1,5 +1,6 @@
|
||||
package net.eagle0.eagle.library.actions.llm_prompt_generators
|
||||
|
||||
import net.eagle0.eagle.ClientTextId
|
||||
import net.eagle0.eagle.client_text.{
|
||||
ClientTextStore,
|
||||
TextGenerationDependencyInProgress,
|
||||
@@ -50,12 +51,12 @@ object GeneratorUtilities {
|
||||
|
||||
val academyName = "The Academy of Arcane and Occult Arts"
|
||||
|
||||
private def factionHeadNameIds(gameState: GameState): Vector[String] =
|
||||
private def factionHeadNameIds(gameState: GameState): Vector[ClientTextId] =
|
||||
gameState.factions.values.toVector
|
||||
.sortBy(_.id)
|
||||
.map(_.factionHeadId)
|
||||
.map(hid => gameState.heroes.getOrElse(hid, gameState.killedHeroes(hid)))
|
||||
.map(_.nameTextId)
|
||||
.map(hero => ClientTextId(hero.nameTextId))
|
||||
|
||||
private def factionHeadsNamesResult(
|
||||
gameState: GameState,
|
||||
|
||||
+4
-1
@@ -6,5 +6,8 @@ import net.eagle0.eagle.internal.hero.Hero
|
||||
|
||||
object HeroInfoUtilities {
|
||||
def getHero(heroId: HeroId, gameState: GameState): Hero =
|
||||
gameState.heroes.getOrElse(heroId, gameState.killedHeroes(heroId))
|
||||
gameState.heroes.getOrElse(
|
||||
heroId.value,
|
||||
gameState.killedHeroes(heroId.value)
|
||||
)
|
||||
}
|
||||
|
||||
+20
-20
@@ -23,11 +23,11 @@ object DiplomacyResolutionLlmRequestGenerator {
|
||||
GeneratedTextRequest(
|
||||
id =
|
||||
s"$currentRoundId truce offer $originatingFactionId $targetFactionId resolution $resolution",
|
||||
eagleGameId = gameId,
|
||||
eagleGameId = gameId.value,
|
||||
details = TruceResolutionMessage(
|
||||
offeringFactionId = originatingFactionId,
|
||||
targetFactionId = targetFactionId,
|
||||
messengerHeroId = messengerHeroId,
|
||||
offeringFactionId = originatingFactionId.value,
|
||||
targetFactionId = targetFactionId.value,
|
||||
messengerHeroId = messengerHeroId.value,
|
||||
resolutionStatus = resolution
|
||||
)
|
||||
)
|
||||
@@ -43,11 +43,11 @@ object DiplomacyResolutionLlmRequestGenerator {
|
||||
GeneratedTextRequest(
|
||||
id =
|
||||
s"$currentRoundId alliance offer $originatingFactionId $targetFactionId resolution $resolution",
|
||||
eagleGameId = gameId,
|
||||
eagleGameId = gameId.value,
|
||||
details = AllianceOfferResolutionMessage(
|
||||
offeringFactionId = originatingFactionId,
|
||||
targetFactionId = targetFactionId,
|
||||
messengerHeroId = messengerHeroId,
|
||||
offeringFactionId = originatingFactionId.value,
|
||||
targetFactionId = targetFactionId.value,
|
||||
messengerHeroId = messengerHeroId.value,
|
||||
resolutionStatus = resolution
|
||||
)
|
||||
)
|
||||
@@ -63,11 +63,11 @@ object DiplomacyResolutionLlmRequestGenerator {
|
||||
GeneratedTextRequest(
|
||||
id =
|
||||
s"$currentRoundId break alliance $originatingFactionId $targetFactionId resolution $resolution",
|
||||
eagleGameId = gameId,
|
||||
eagleGameId = gameId.value,
|
||||
details = BreakAllianceResolutionMessage(
|
||||
breakingFactionId = originatingFactionId,
|
||||
targetFactionId = targetFactionId,
|
||||
messengerHeroId = messengerHeroId,
|
||||
breakingFactionId = originatingFactionId.value,
|
||||
targetFactionId = targetFactionId.value,
|
||||
messengerHeroId = messengerHeroId.value,
|
||||
resolutionStatus = resolution
|
||||
)
|
||||
)
|
||||
@@ -83,11 +83,11 @@ object DiplomacyResolutionLlmRequestGenerator {
|
||||
GeneratedTextRequest(
|
||||
id =
|
||||
s"$currentRoundId invitation resolution $originatingFactionId $invitedFactionId resolution $resolution",
|
||||
eagleGameId = gameId,
|
||||
eagleGameId = gameId.value,
|
||||
details = InvitationResolutionMessage(
|
||||
offeringFactionId = originatingFactionId,
|
||||
targetFactionId = invitedFactionId,
|
||||
messengerHeroId = messengerHeroId,
|
||||
offeringFactionId = originatingFactionId.value,
|
||||
targetFactionId = invitedFactionId.value,
|
||||
messengerHeroId = messengerHeroId.value,
|
||||
resolutionStatus = resolution
|
||||
)
|
||||
)
|
||||
@@ -103,11 +103,11 @@ object DiplomacyResolutionLlmRequestGenerator {
|
||||
GeneratedTextRequest(
|
||||
id =
|
||||
s"$currentRoundId ransom resolution $originatingFactionId $targetFactionId resolution $resolution",
|
||||
eagleGameId = gameId,
|
||||
eagleGameId = gameId.value,
|
||||
details = RansomResolutionMessage(
|
||||
offeringFactionId = originatingFactionId,
|
||||
targetFactionId = targetFactionId,
|
||||
ransomedHeroId = ransomedHeroId,
|
||||
offeringFactionId = originatingFactionId.value,
|
||||
targetFactionId = targetFactionId.value,
|
||||
ransomedHeroId = ransomedHeroId.value,
|
||||
resolutionStatus = resolution
|
||||
)
|
||||
)
|
||||
|
||||
@@ -56,7 +56,7 @@ object ShatteredArmyUtils {
|
||||
province: ProvinceT
|
||||
): Vector[MovingArmy] =
|
||||
province.incomingArmies
|
||||
.filter(_.arrivalRound == currentRoundId)
|
||||
.filter(_.arrivalRound == currentRoundId.value)
|
||||
|
||||
private def outlaw(cu: CombatUnit): UnaffiliatedHeroT = UnaffiliatedHeroC(
|
||||
heroId = cu.heroId,
|
||||
|
||||
@@ -18,7 +18,7 @@ object BattalionPower {
|
||||
BattalionTypeId.Undead -> 0.25
|
||||
)
|
||||
|
||||
private def powerForInfo(
|
||||
private inline def powerForInfo(
|
||||
battalionTypeId: BattalionTypeId,
|
||||
size: Int,
|
||||
armament: Double,
|
||||
@@ -30,7 +30,7 @@ object BattalionPower {
|
||||
}
|
||||
|
||||
// Calculate unit power using Shardok's formula
|
||||
def power(battalion: BattalionT): Double = powerForInfo(
|
||||
inline def power(battalion: BattalionT): Double = powerForInfo(
|
||||
battalionTypeId = battalion.typeId,
|
||||
size = battalion.size,
|
||||
armament = battalion.armament,
|
||||
@@ -38,7 +38,10 @@ object BattalionPower {
|
||||
)
|
||||
|
||||
// Calculate power assuming baseline stats for enemy units (50/50 training/armament, 100 morale)
|
||||
def powerWithBaseline(battalionType: BattalionTypeId, size: Int): Double =
|
||||
inline def powerWithBaseline(
|
||||
battalionType: BattalionTypeId,
|
||||
size: Int
|
||||
): Double =
|
||||
powerForInfo(
|
||||
battalionTypeId = battalionType,
|
||||
size = size,
|
||||
@@ -48,7 +51,7 @@ object BattalionPower {
|
||||
|
||||
// Calculate power per troop for unknown enemy composition
|
||||
// Uses baseline unit type multiplier and 50/50 stats
|
||||
def baselinePowerPerTroop: Double = {
|
||||
inline def baselinePowerPerTroop: Double = {
|
||||
// Power for 1 troop with baseline type (1.5) and baseline stats (50/50)
|
||||
// Formula: typeMultiplier * (0.5 + armament/100) * (0.5 + training/100) * size
|
||||
// = 1.5 * (0.5 + 0.5) * (0.5 + 0.5) * 1 = 1.5 * 1.0 * 1.0 * 1 = 1.5
|
||||
|
||||
@@ -61,5 +61,5 @@ object BattalionSuitability {
|
||||
bs: Vector[Battalion],
|
||||
bts: Vector[BattalionType]
|
||||
): Map[HeroId, SuitableBattalions] =
|
||||
hs.map(h => h.id -> suitableBattalions(h, bs, bts)).toMap
|
||||
hs.map(h => HeroId(h.id) -> suitableBattalions(h, bs, bts)).toMap
|
||||
}
|
||||
|
||||
@@ -7,11 +7,12 @@ import net.eagle0.eagle.internal.province.Province
|
||||
import net.eagle0.eagle.{BattalionId, FactionId, HeroId, ProvinceId}
|
||||
|
||||
object IDable {
|
||||
def mapifyHeroes(hs: Hero*): Map[HeroId, Hero] = hs.map(h => h.id -> h).toMap
|
||||
def mapifyHeroes(hs: Hero*): Map[HeroId, Hero] =
|
||||
hs.map(h => HeroId(h.id) -> h).toMap
|
||||
def mapifyBattalions(hs: Battalion*): Map[BattalionId, Battalion] =
|
||||
hs.map(h => h.id -> h).toMap
|
||||
hs.map(h => BattalionId(h.id) -> h).toMap
|
||||
def mapifyFactions(fs: Faction*): Map[FactionId, Faction] =
|
||||
fs.map(h => h.id -> h).toMap
|
||||
fs.map(h => FactionId(h.id) -> h).toMap
|
||||
def mapifyProvinces(hs: Province*): Map[ProvinceId, Province] =
|
||||
hs.map(h => h.id -> h).toMap
|
||||
hs.map(h => ProvinceId(h.id) -> h).toMap
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ object IncomingArmyUtils {
|
||||
currentRoundId: RoundId
|
||||
): Boolean =
|
||||
province.incomingArmies.exists(ia =>
|
||||
ia.getArmy.factionId == factionId && ia.arrivalRound == currentRoundId
|
||||
ia.getArmy.factionId == factionId.value && ia.arrivalRound == currentRoundId.value
|
||||
)
|
||||
|
||||
def relevantIncomingArmies(
|
||||
@@ -26,7 +26,7 @@ object IncomingArmyUtils {
|
||||
): Vector[MovingArmy] =
|
||||
province.incomingArmies
|
||||
.filter(ia =>
|
||||
ia.getArmy.factionId == factionId && ia.arrivalRound == currentRoundId
|
||||
ia.getArmy.factionId == factionId.value && ia.arrivalRound == currentRoundId.value
|
||||
)
|
||||
.toVector
|
||||
|
||||
@@ -37,10 +37,10 @@ object IncomingArmyUtils {
|
||||
LegacyFactionUtils.factionsAreMutuallyAllied(
|
||||
fids = province.incomingArmies
|
||||
.filter(_.arrivalRound == gameState.currentRoundId)
|
||||
.map(_.getArmy.factionId)
|
||||
.map(ma => FactionId(ma.getArmy.factionId))
|
||||
.toVector ++ province.hostileArmies
|
||||
.flatMap(_.armies)
|
||||
.map(_.getArmy.factionId)
|
||||
.map(ha => FactionId(ha.getArmy.factionId))
|
||||
.toVector,
|
||||
gs = gameState
|
||||
)
|
||||
@@ -51,14 +51,18 @@ object IncomingArmyUtils {
|
||||
gameState: GameState
|
||||
): Boolean =
|
||||
province.rulingFactionId.exists(targetFid =>
|
||||
LegacyFactionUtils.factionsAreHostile(targetFid, factionId, gameState)
|
||||
LegacyFactionUtils.factionsAreHostile(
|
||||
FactionId(targetFid),
|
||||
factionId,
|
||||
gameState
|
||||
)
|
||||
)
|
||||
|
||||
def isUnderAttack(
|
||||
provinceId: ProvinceId,
|
||||
gameState: GameState
|
||||
): Boolean =
|
||||
isUnderAttack(gameState.provinces(provinceId), gameState)
|
||||
isUnderAttack(gameState.provinces(provinceId.value), gameState)
|
||||
|
||||
def isUnderAttack(
|
||||
province: Province,
|
||||
@@ -68,7 +72,11 @@ object IncomingArmyUtils {
|
||||
.filter(_.arrivalRound == gameState.currentRoundId)
|
||||
.exists(ma =>
|
||||
IncomingArmyUtils
|
||||
.isHostileProvince(province, ma.getArmy.factionId, gameState)
|
||||
.isHostileProvince(
|
||||
province,
|
||||
FactionId(ma.getArmy.factionId),
|
||||
gameState
|
||||
)
|
||||
)
|
||||
|
||||
def stats(
|
||||
@@ -84,8 +92,9 @@ object IncomingArmyUtils {
|
||||
factionId = army.factionId,
|
||||
heroCount = army.units.size,
|
||||
troopCount = troopCount,
|
||||
hostility = LegacyFactionUtils.hostilityStatus(toFid, army.factionId, gs),
|
||||
originProvinceId = originProvinceId
|
||||
hostility = LegacyFactionUtils
|
||||
.hostilityStatus(toFid, FactionId(army.factionId), gs),
|
||||
originProvinceId = originProvinceId.value
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -41,7 +41,9 @@ object ProvinceDistances {
|
||||
): Option[ProvinceAndDistance] =
|
||||
closestProvinceOption(
|
||||
to,
|
||||
candidates.filter(pid => gs.provinces(pid).rulingFactionId.contains(fid)),
|
||||
candidates.filter(pid =>
|
||||
gs.provinces(pid.value).rulingFactionId.contains(fid.value)
|
||||
),
|
||||
LegacyFactionUtils.ownedNeighbors(gs, fid)
|
||||
)
|
||||
|
||||
@@ -87,8 +89,8 @@ object ProvinceDistances {
|
||||
provinces: Map[ProvinceId, Province]
|
||||
): Option[ProvinceId] = {
|
||||
val factionProvinceIds = provinces.values
|
||||
.filter(_.rulingFactionId.contains(factionId))
|
||||
.map(_.id)
|
||||
.filter(_.rulingFactionId.contains(factionId.value))
|
||||
.map(p => ProvinceId(p.id))
|
||||
.toVector
|
||||
|
||||
if factionProvinceIds.isEmpty then None
|
||||
@@ -98,15 +100,16 @@ object ProvinceDistances {
|
||||
.toVector
|
||||
.minByOption { neighborPid =>
|
||||
closestProvinceOption(
|
||||
to = neighborPid,
|
||||
to = ProvinceId(neighborPid),
|
||||
candidates = factionProvinceIds,
|
||||
eligibleNeighbors = pid =>
|
||||
provinces
|
||||
.get(pid)
|
||||
.map(_.neighbors.map(_.provinceId).toVector)
|
||||
.map(_.neighbors.map(n => ProvinceId(n.provinceId)).toVector)
|
||||
.getOrElse(Vector())
|
||||
).map(_.distance).getOrElse(Int.MaxValue)
|
||||
}
|
||||
.map(ProvinceId(_))
|
||||
end if
|
||||
}
|
||||
|
||||
|
||||
@@ -58,7 +58,7 @@ object ShardokMapInfo {
|
||||
Vector[ExpandedShardokMapInfo](null) ++ provinceMapInfo.map { pmi =>
|
||||
val smi = extracted.find(smi => pmi.hexMapName == smi.name).get
|
||||
ExpandedShardokMapInfo(
|
||||
provinceId = pmi.id,
|
||||
provinceId = ProvinceId(pmi.id),
|
||||
castleCount = smi.castleCount,
|
||||
waterCrossingRequirementsByPosition = smi.positions
|
||||
)
|
||||
|
||||
+11
-10
@@ -13,7 +13,7 @@ import net.eagle0.eagle.internal.game_state.GameState
|
||||
import net.eagle0.eagle.library.util.CommandSelection
|
||||
import net.eagle0.eagle.library.util.command_choice_helpers.AvailableCommandSelector.ofType
|
||||
import net.eagle0.eagle.library.util.faction_utils.LegacyFactionUtils
|
||||
import net.eagle0.eagle.{FactionId, HeroId}
|
||||
import net.eagle0.eagle.{FactionId, HeroId, ProvinceId}
|
||||
|
||||
object AllianceOfferCommandSelector {
|
||||
private def usableHeroIds(
|
||||
@@ -28,7 +28,7 @@ object AllianceOfferCommandSelector {
|
||||
): Option[AllianceOption] =
|
||||
options.collectFirst {
|
||||
case x @ AllianceOption(tfid, _, _ /* unknownFieldSet */ )
|
||||
if tfid == targetFactionId =>
|
||||
if FactionId(tfid) == targetFactionId =>
|
||||
x
|
||||
}
|
||||
|
||||
@@ -44,26 +44,27 @@ object AllianceOfferCommandSelector {
|
||||
ac.options.toVector,
|
||||
targetFactionId
|
||||
).isDefined && usableHeroIds(
|
||||
ac.availableHeroIds.toVector,
|
||||
ac.availableHeroIds.toVector.map(HeroId(_)),
|
||||
gameState
|
||||
).nonEmpty
|
||||
}
|
||||
.map { ac =>
|
||||
CommandSelection(
|
||||
actingFactionId = actingFactionId,
|
||||
actingProvinceId = ac.actingProvinceId,
|
||||
actingProvinceId = ProvinceId(ac.actingProvinceId),
|
||||
available = ac,
|
||||
selected = DiplomacySelectedCommand(
|
||||
selectedOption = allianceOptionWithTarget(
|
||||
ac.options.toVector,
|
||||
targetFactionId
|
||||
).get,
|
||||
targetFactionId = targetFactionId,
|
||||
sentHeroId =
|
||||
usableHeroIds(ac.availableHeroIds.toVector, gameState).maxBy {
|
||||
hid =>
|
||||
gameState.heroes(hid).vigor
|
||||
}
|
||||
targetFactionId = targetFactionId.value,
|
||||
sentHeroId = usableHeroIds(
|
||||
ac.availableHeroIds.map(HeroId(_)).toVector,
|
||||
gameState
|
||||
).maxBy { hid =>
|
||||
gameState.heroes(hid.value).vigor
|
||||
}.value
|
||||
),
|
||||
reason = "chosenAllianceWithFactionCommand"
|
||||
)
|
||||
|
||||
+4
-4
@@ -38,10 +38,10 @@ object AlmsCommandSelector {
|
||||
Math.max(
|
||||
0,
|
||||
province.food - foodConsumptionMonthsToHold(
|
||||
provinceId = province.id,
|
||||
provinceId = ProvinceId(province.id),
|
||||
gameState = gameState
|
||||
) * LegacyProvinceUtils
|
||||
.monthlyFoodConsumption(province.id, gameState)
|
||||
.monthlyFoodConsumption(ProvinceId(province.id), gameState)
|
||||
)
|
||||
|
||||
def chosenAlmsForSupportCommand(
|
||||
@@ -67,7 +67,7 @@ object AlmsCommandSelector {
|
||||
val province = gameState
|
||||
.provinces(availableCommand.actingProvinceId)
|
||||
|
||||
if availableCommand.actingProvinceId == provinceId then
|
||||
if ProvinceId(availableCommand.actingProvinceId) == provinceId then
|
||||
maybeAlmsCommandForProvince(
|
||||
actingFactionId = actingFactionId,
|
||||
gameState = gameState,
|
||||
@@ -148,7 +148,7 @@ object AlmsCommandSelector {
|
||||
.toInt
|
||||
CommandSelection(
|
||||
actingFactionId = actingFactionId,
|
||||
actingProvinceId = availableCommand.actingProvinceId,
|
||||
actingProvinceId = ProvinceId(availableCommand.actingProvinceId),
|
||||
available = availableCommand,
|
||||
selected = AlmsSelectedCommand(
|
||||
amount = foodToUse,
|
||||
|
||||
+10
-4
@@ -1,5 +1,6 @@
|
||||
package net.eagle0.eagle.library.util.command_choice_helpers
|
||||
|
||||
import net.eagle0.eagle.HeroId
|
||||
import net.eagle0.eagle.api.command.util.appropriate_battalions.SuitableBattalions.SuitabilityLevel
|
||||
import net.eagle0.eagle.api.command.util.appropriate_battalions.SuitableBattalions.SuitabilityLevel.RESTRICTIVE
|
||||
import net.eagle0.eagle.common.battalion_type.BattalionType
|
||||
@@ -29,20 +30,25 @@ object CombatUnitSelector {
|
||||
bts = battalionTypes
|
||||
)
|
||||
|
||||
def suitability(h: Hero, b: Battalion): SuitabilityLevel =
|
||||
suitableBattalionsMap(h.id).battalionIdsWithSuitability
|
||||
def suitability(hid: HeroId, b: Battalion): SuitabilityLevel =
|
||||
suitableBattalionsMap(hid).battalionIdsWithSuitability
|
||||
.find(_.battalionId == b.id)
|
||||
.get
|
||||
.level
|
||||
|
||||
def chooseOne(hs: Vector[Hero], bs: Vector[Battalion]): CombatUnit = {
|
||||
val bestBattalionOpt = bs
|
||||
.filter(b => hs.exists(h => suitability(h, b) != RESTRICTIVE))
|
||||
.filter(b =>
|
||||
hs.exists(h => suitability(HeroId(h.id), b) != RESTRICTIVE)
|
||||
)
|
||||
.maxByOption(LegacyBattalionUtils.power)
|
||||
bestBattalionOpt
|
||||
.map { bestBattalion =>
|
||||
val bestHero = hs.minBy(h =>
|
||||
(suitability(h, bestBattalion).index, -LegacyHeroUtils.power(h))
|
||||
(
|
||||
suitability(HeroId(h.id), bestBattalion).index,
|
||||
-LegacyHeroUtils.power(h)
|
||||
)
|
||||
)
|
||||
CombatUnit(
|
||||
heroId = bestHero.id,
|
||||
|
||||
+4
-3
@@ -23,15 +23,16 @@ object ExileVassalCommandSelector {
|
||||
.find(exileVassalCommand =>
|
||||
exileVassalCommand.exilableHeroIds
|
||||
.contains(
|
||||
dismissedHeroId
|
||||
) && exileVassalCommand.actingProvinceId == actingProvinceId
|
||||
dismissedHeroId.value
|
||||
) && exileVassalCommand.actingProvinceId == actingProvinceId.value
|
||||
)
|
||||
.map { exileVassalCommand =>
|
||||
CommandSelection(
|
||||
actingFactionId = actingFactionId,
|
||||
actingProvinceId = actingProvinceId,
|
||||
available = exileVassalCommand,
|
||||
selected = ExileVassalSelectedCommand(exiledHeroId = dismissedHeroId),
|
||||
selected =
|
||||
ExileVassalSelectedCommand(exiledHeroId = dismissedHeroId.value),
|
||||
reason = reason
|
||||
)
|
||||
}
|
||||
|
||||
+43
-32
@@ -39,8 +39,8 @@ object ExpandCommandSelector {
|
||||
val randomNone = RandomState(None, functionalRandom)
|
||||
|
||||
if (rulingFactionHeroIds.size < 2) // Don't abandon this province
|
||||
|| (rulingFactionHeroIds.size - rulingFactionHeroIds.count(
|
||||
LegacyFactionUtils.isFactionLeader(_, gameState)
|
||||
|| (rulingFactionHeroIds.size - rulingFactionHeroIds.count(hid =>
|
||||
LegacyFactionUtils.isFactionLeader(HeroId(hid), gameState)
|
||||
) < 2) // Don't leave a faction leader alone
|
||||
then randomNone
|
||||
else
|
||||
@@ -50,11 +50,12 @@ object ExpandCommandSelector {
|
||||
val (adjacentEnemyProvinces, safeProvinces) =
|
||||
expansionCandidateProvinces(
|
||||
gameState,
|
||||
oneProvinceCommand.originProvinceId,
|
||||
ProvinceId(oneProvinceCommand.originProvinceId),
|
||||
oneProvinceCommand.availableDestinationProvinces.toVector
|
||||
.map(ProvinceId(_))
|
||||
).partition(p =>
|
||||
LegacyProvinceUtils
|
||||
.isAdjacentEnemy(p.id, actingFactionId, gameState)
|
||||
.isAdjacentEnemy(ProvinceId(p.id), actingFactionId, gameState)
|
||||
)
|
||||
|
||||
// First try to expand into a "safe" province
|
||||
@@ -93,7 +94,7 @@ object ExpandCommandSelector {
|
||||
eligibleDestinations: Vector[ProvinceId]
|
||||
): Vector[Province] =
|
||||
eligibleDestinations
|
||||
.map(gameState.provinces)
|
||||
.map(pid => gameState.provinces(pid.value))
|
||||
.filterNot(_.rulingFactionId.isDefined)
|
||||
.filterNot(
|
||||
_.incomingArmies.exists(ma =>
|
||||
@@ -101,7 +102,7 @@ object ExpandCommandSelector {
|
||||
.map(_.factionId)
|
||||
.contains(
|
||||
gameState
|
||||
.provinces(fromProvince)
|
||||
.provinces(fromProvince.value)
|
||||
.rulingFactionId
|
||||
.get
|
||||
)
|
||||
@@ -177,7 +178,7 @@ object ExpandCommandSelector {
|
||||
// If the originating province is safe, only leave two heroes behind
|
||||
val heroCountToSend = (
|
||||
if LegacyProvinceUtils.isAdjacentEnemy(
|
||||
oneProvinceCommand.originProvinceId,
|
||||
ProvinceId(oneProvinceCommand.originProvinceId),
|
||||
actingFactionId,
|
||||
gameState
|
||||
)
|
||||
@@ -217,7 +218,7 @@ object ExpandCommandSelector {
|
||||
)
|
||||
|
||||
heroIdsToMarch(
|
||||
availableHeroIds = opmc.availableHeroIds.toVector,
|
||||
availableHeroIds = opmc.availableHeroIds.toVector.map(HeroId(_)),
|
||||
heroCount = heroCount,
|
||||
factionLeaders = factionLeaders,
|
||||
otherCountLeftBehind = otherCountLeftBehind,
|
||||
@@ -233,12 +234,12 @@ object ExpandCommandSelector {
|
||||
battalionIdsWithFoodCosts.map(_.battalionId).sorted.map(Option(_))
|
||||
|
||||
val combatUnits = heroIds
|
||||
.zipAll(battalionIds, 0, None)
|
||||
.map { pair =>
|
||||
.zipAll(battalionIds, HeroId(0), None)
|
||||
.map { case (heroId, battalionId) =>
|
||||
CombatUnit(
|
||||
heroId = pair._1,
|
||||
battalionId = pair._2,
|
||||
factionId = fid
|
||||
heroId = heroId.value,
|
||||
battalionId = battalionId,
|
||||
factionId = fid.value
|
||||
)
|
||||
}
|
||||
|
||||
@@ -269,7 +270,7 @@ object ExpandCommandSelector {
|
||||
|
||||
// Don't leave a faction leader alone in the origin province
|
||||
if heroCountLeftBehind == 1 && notAvailableHeroes.size == 1 && LegacyFactionUtils
|
||||
.isFactionLeader(notAvailableHeroes.head, gameState)
|
||||
.isFactionLeader(HeroId(notAvailableHeroes.head), gameState)
|
||||
then {
|
||||
return randomNone
|
||||
}
|
||||
@@ -297,18 +298,20 @@ object ExpandCommandSelector {
|
||||
battalionCount = battalionCountToSend.min(heroCountToSend),
|
||||
fid = actingFactionId,
|
||||
factionLeaders = gameState
|
||||
.factions(actingFactionId)
|
||||
.factions(actingFactionId.value)
|
||||
.leaders
|
||||
.intersect(originatingProvince.rulingFactionHeroIds)
|
||||
.toVector,
|
||||
.toVector
|
||||
.map(HeroId(_)),
|
||||
otherCountLeftBehind =
|
||||
originatingProvince.rulingFactionHeroIds.length - oneProvinceCommand.availableHeroIds.length,
|
||||
functionalRandom = innerFr
|
||||
).map { marchingUnitsWithFood =>
|
||||
val takenHeroes =
|
||||
marchingUnitsWithFood.units.map(_.heroId)
|
||||
marchingUnitsWithFood.units.map(cu => HeroId(cu.heroId))
|
||||
val leftHeroes =
|
||||
rulingFactionHeroIds.filterNot(takenHeroes.contains)
|
||||
rulingFactionHeroIds
|
||||
.filterNot(hid => takenHeroes.contains(HeroId(hid)))
|
||||
|
||||
internalRequire(
|
||||
takenHeroes.length > 1 || !LegacyFactionUtils
|
||||
@@ -322,7 +325,7 @@ object ExpandCommandSelector {
|
||||
internalRequire(
|
||||
leftHeroes.length > 1 || !LegacyFactionUtils
|
||||
.isFactionLeader(
|
||||
heroId = leftHeroes.head,
|
||||
heroId = HeroId(leftHeroes.head),
|
||||
gameState = gameState
|
||||
),
|
||||
"trying to leave a faction leader alone!"
|
||||
@@ -342,7 +345,7 @@ object ExpandCommandSelector {
|
||||
)
|
||||
val foodToHoldBack = monthlyFoodConsumptionInOrigin *
|
||||
FoodConsumptionUtils.foodConsumptionMonthsToHold(
|
||||
originatingProvince.id,
|
||||
ProvinceId(originatingProvince.id),
|
||||
gameState
|
||||
)
|
||||
|
||||
@@ -354,21 +357,23 @@ object ExpandCommandSelector {
|
||||
val minFoodToSend =
|
||||
monthlyFoodConsumptionInDestination * FoodConsumptionUtils
|
||||
.foodConsumptionMonthsToHold(
|
||||
chosenCandidateProvince.id,
|
||||
ProvinceId(chosenCandidateProvince.id),
|
||||
gameState
|
||||
)
|
||||
|
||||
Option.when(minFoodToSend <= foodAvailableToSend) {
|
||||
CommandSelection(
|
||||
actingFactionId = actingFactionId,
|
||||
actingProvinceId = availableCommand.actingProvinceId,
|
||||
actingProvinceId =
|
||||
ProvinceId(availableCommand.actingProvinceId),
|
||||
available = availableCommand,
|
||||
selected = MarchSelectedCommand(
|
||||
marchingUnits = marchingUnitsWithFood.units,
|
||||
destinationProvinceId = chosenCandidateProvince.id,
|
||||
originProvince = oneProvinceCommand.originProvinceId,
|
||||
gold = goldToSend,
|
||||
food = (minFoodToSend + foodAvailableToSend) / 2
|
||||
food = (minFoodToSend + foodAvailableToSend) / 2,
|
||||
unknownFields = scalapb.UnknownFieldSet.empty
|
||||
),
|
||||
reason = "expandSelectedCommand"
|
||||
)
|
||||
@@ -389,13 +394,15 @@ object ExpandCommandSelector {
|
||||
.flatMap { opmc =>
|
||||
spreadHeroesMarchCandidates(
|
||||
gameState,
|
||||
opmc.originProvinceId,
|
||||
opmc.availableDestinationProvinces.toVector
|
||||
ProvinceId(opmc.originProvinceId),
|
||||
opmc.availableDestinationProvinces.toVector.map(ProvinceId(_))
|
||||
).map(
|
||||
(opmc, _)
|
||||
)
|
||||
}
|
||||
.minByOption(_._2.rulingFactionHeroIds.length)
|
||||
.minByOption { case (opmc, province) =>
|
||||
province.rulingFactionHeroIds.length
|
||||
}
|
||||
.map { case (opmc, destinationProvince) =>
|
||||
val originProvince =
|
||||
gameState.provinces(opmc.originProvinceId)
|
||||
@@ -409,7 +416,7 @@ object ExpandCommandSelector {
|
||||
Math.min(
|
||||
opmc.goldAvailable,
|
||||
(provinceGoldSurplus(
|
||||
originProvince.id,
|
||||
ProvinceId(originProvince.id),
|
||||
gameState: GameState
|
||||
) - destinationProvince.gold) / 2
|
||||
)
|
||||
@@ -425,7 +432,11 @@ object ExpandCommandSelector {
|
||||
heroCount = heroCountToSend,
|
||||
battalionCount = battalionCountToSend,
|
||||
fid = actingFactionId,
|
||||
factionLeaders = gameState.factions(actingFactionId).leaders.toVector,
|
||||
factionLeaders = gameState
|
||||
.factions(actingFactionId.value)
|
||||
.leaders
|
||||
.toVector
|
||||
.map(HeroId(_)),
|
||||
otherCountLeftBehind =
|
||||
originProvince.rulingFactionHeroIds.length - opmc.availableHeroIds.length,
|
||||
functionalRandom = functionalRandom
|
||||
@@ -433,7 +444,7 @@ object ExpandCommandSelector {
|
||||
Some(
|
||||
CommandSelection(
|
||||
actingFactionId = actingFactionId,
|
||||
actingProvinceId = availableCommand.actingProvinceId,
|
||||
actingProvinceId = ProvinceId(availableCommand.actingProvinceId),
|
||||
available = availableCommand,
|
||||
selected = MarchSelectedCommand(
|
||||
marchingUnits = marchingUnitsWithFood.units,
|
||||
@@ -454,9 +465,9 @@ object ExpandCommandSelector {
|
||||
fromProvince: ProvinceId,
|
||||
eligibleDestinations: Vector[ProvinceId]
|
||||
): Vector[Province] = {
|
||||
val p = gameState.provinces(fromProvince)
|
||||
val p = gameState.provinces(fromProvince.value)
|
||||
eligibleDestinations
|
||||
.map(gameState.provinces)
|
||||
.map(pid => gameState.provinces(pid.value))
|
||||
.filter(_.rulingFactionId == p.rulingFactionId)
|
||||
.filter(_.rulingFactionHeroIds.length + 1 < p.rulingFactionHeroIds.length)
|
||||
.filter(x => x.rulingFactionHeroIds.length < x.heroCap)
|
||||
@@ -483,7 +494,7 @@ object ExpandCommandSelector {
|
||||
case RandomState(shuffledHeroIds, fr) =>
|
||||
val heroIds = shuffledHeroIds
|
||||
.take(heroCount)
|
||||
.sorted
|
||||
.sortBy(_.value)
|
||||
|
||||
val sentFactionLeaders = heroIds.intersect(relevantFactionLeaders)
|
||||
val keptFactionLeaders = relevantFactionLeaders.diff(sentFactionLeaders)
|
||||
|
||||
+3
-1
@@ -25,7 +25,9 @@ object FoodConsumptionUtils {
|
||||
provinceId: ProvinceId,
|
||||
gameState: GameState
|
||||
): Int =
|
||||
if gameState.provinces(provinceId).support >= MinSupportForTaxes.doubleValue
|
||||
if gameState
|
||||
.provinces(provinceId.value)
|
||||
.support >= MinSupportForTaxes.doubleValue
|
||||
then foodConsumptionMonthsRemainingInYear(gameState)
|
||||
else foodConsumptionMonthsRemainingInYear(gameState).max(6)
|
||||
}
|
||||
|
||||
+7
-5
@@ -21,7 +21,7 @@ object HeroGiftCommandSelector {
|
||||
flatSelectionForType[HeroGiftAvailableCommand](availableCommands) {
|
||||
heroGiftAvailableCommand =>
|
||||
heroGiftAvailableCommand.eligibleGifts
|
||||
.filter(_.recipientProvinceId == provinceId)
|
||||
.filter(g => ProvinceId(g.recipientProvinceId) == provinceId)
|
||||
.minByOption(eligibleGift =>
|
||||
gameState.heroes(eligibleGift.recipientHeroId).loyalty
|
||||
)
|
||||
@@ -29,7 +29,8 @@ object HeroGiftCommandSelector {
|
||||
CommandSelection(
|
||||
actingFactionId = actingFactionId,
|
||||
available = heroGiftAvailableCommand,
|
||||
actingProvinceId = heroGiftAvailableCommand.actingProvinceId,
|
||||
actingProvinceId =
|
||||
ProvinceId(heroGiftAvailableCommand.actingProvinceId),
|
||||
selected = HeroGiftSelectedCommand(
|
||||
recipientHeroId = eligibleGift.recipientHeroId,
|
||||
amount = eligibleGift.goldAvailable.min(maxAmount)
|
||||
@@ -50,14 +51,15 @@ object HeroGiftCommandSelector {
|
||||
flatSelectionForType[HeroGiftAvailableCommand](availableCommands) {
|
||||
heroGiftAvailableCommand =>
|
||||
heroGiftAvailableCommand.eligibleGifts
|
||||
.find(_.recipientHeroId == heroId)
|
||||
.find(g => HeroId(g.recipientHeroId) == heroId)
|
||||
.map { eligibleGift =>
|
||||
CommandSelection(
|
||||
actingFactionId = actingFactionId,
|
||||
available = heroGiftAvailableCommand,
|
||||
actingProvinceId = heroGiftAvailableCommand.actingProvinceId,
|
||||
actingProvinceId =
|
||||
ProvinceId(heroGiftAvailableCommand.actingProvinceId),
|
||||
selected = HeroGiftSelectedCommand(
|
||||
recipientHeroId = heroId,
|
||||
recipientHeroId = heroId.value,
|
||||
amount = eligibleGift.goldAvailable
|
||||
),
|
||||
reason = reason
|
||||
|
||||
+6
-4
@@ -49,12 +49,14 @@ object ImproveCommandSelector {
|
||||
improveCommand =>
|
||||
val actingPid = improveCommand.actingProvinceId
|
||||
Option.when(
|
||||
actingPid == actingProvinceId && improveCommand.availableTypes
|
||||
ProvinceId(
|
||||
actingPid
|
||||
) == actingProvinceId && improveCommand.availableTypes
|
||||
.contains(improvementType)
|
||||
) {
|
||||
CommandSelection(
|
||||
actingFactionId = actingFactionId,
|
||||
actingProvinceId = actingPid,
|
||||
actingProvinceId = ProvinceId(actingPid),
|
||||
available = improveCommand,
|
||||
selected = ImproveSelectedCommand(
|
||||
improvementType = improvementType,
|
||||
@@ -77,7 +79,7 @@ object ImproveCommandSelector {
|
||||
Option.when(improveCommand.availableTypes.contains(improvementType)) {
|
||||
CommandSelection(
|
||||
actingFactionId = actingFactionId,
|
||||
actingProvinceId = actingPid,
|
||||
actingProvinceId = ProvinceId(actingPid),
|
||||
available = improveCommand,
|
||||
selected = ImproveSelectedCommand(
|
||||
improvementType = improvementType,
|
||||
@@ -99,7 +101,7 @@ object ImproveCommandSelector {
|
||||
): CommandSelection =
|
||||
CommandSelection(
|
||||
actingFactionId = actingFactionId,
|
||||
actingProvinceId = improveAvailableCommand.actingProvinceId,
|
||||
actingProvinceId = ProvinceId(improveAvailableCommand.actingProvinceId),
|
||||
available = improveAvailableCommand,
|
||||
selected = ImproveSelectedCommand(
|
||||
improvementType = chosenType(
|
||||
|
||||
+2
-2
@@ -11,7 +11,7 @@ object ProvinceGoldSurplusCalculator {
|
||||
gameState: GameState
|
||||
): Int =
|
||||
(GoldPerHeroHeldBack.doubleValue * gameState
|
||||
.provinces(provinceId)
|
||||
.provinces(provinceId.value)
|
||||
.rulingFactionHeroIds
|
||||
.length).ceil.toInt
|
||||
|
||||
@@ -19,7 +19,7 @@ object ProvinceGoldSurplusCalculator {
|
||||
provinceId: ProvinceId,
|
||||
gameState: GameState
|
||||
): Int =
|
||||
(gameState.provinces(provinceId).gold - goldToHoldBack(
|
||||
(gameState.provinces(provinceId.value).gold - goldToHoldBack(
|
||||
provinceId,
|
||||
gameState
|
||||
)).max(0)
|
||||
|
||||
+4
-4
@@ -8,7 +8,7 @@ import net.eagle0.eagle.common.diplomacy_offer_status.DiplomacyOfferStatus.{
|
||||
}
|
||||
import net.eagle0.eagle.internal.faction.Faction.OutgoingOfferRound
|
||||
import net.eagle0.eagle.internal.game_state.GameState
|
||||
import net.eagle0.eagle.FactionId
|
||||
import net.eagle0.eagle.{FactionId, HeroId}
|
||||
import net.eagle0.eagle.library.settings.{
|
||||
MinimumMonthsBeforeRepeatRansomOffer,
|
||||
MinimumTrustToOfferRansom,
|
||||
@@ -49,7 +49,7 @@ object RansomOfferHelpers {
|
||||
gameState: GameState
|
||||
): Boolean =
|
||||
!gameState
|
||||
.factions(offeringFactionId)
|
||||
.factions(offeringFactionId.value)
|
||||
.lastOutgoingRansomOfferRounds
|
||||
.exists {
|
||||
case OutgoingOfferRound(
|
||||
@@ -57,7 +57,7 @@ object RansomOfferHelpers {
|
||||
roundId,
|
||||
_ /* unknownFieldSet */
|
||||
) =>
|
||||
toFactionId == targetFactionId && roundId + MinimumMonthsBeforeRepeatRansomOffer.intValue > gameState.currentRoundId
|
||||
toFactionId == targetFactionId.value && roundId + MinimumMonthsBeforeRepeatRansomOffer.intValue > gameState.currentRoundId
|
||||
}
|
||||
|
||||
def chosenOffer(
|
||||
@@ -75,7 +75,7 @@ object RansomOfferHelpers {
|
||||
) =>
|
||||
val nonFactionLeaderHostages =
|
||||
hostagesOffered.filterNot(hoie =>
|
||||
LegacyFactionUtils.isFactionLeader(hoie.heroId, gameState)
|
||||
LegacyFactionUtils.isFactionLeader(HeroId(hoie.heroId), gameState)
|
||||
)
|
||||
|
||||
Option.when(
|
||||
|
||||
+5
-4
@@ -1,6 +1,6 @@
|
||||
package net.eagle0.eagle.library.util.command_choice_helpers
|
||||
|
||||
import net.eagle0.eagle.{FactionId, HeroId}
|
||||
import net.eagle0.eagle.{FactionId, HeroId, ProvinceId}
|
||||
import net.eagle0.eagle.api.available_command.{
|
||||
AvailableCommand,
|
||||
SwearBrotherhoodAvailableCommand
|
||||
@@ -27,10 +27,11 @@ object SwearBrotherhoodCommandSelector {
|
||||
CommandSelection(
|
||||
actingFactionId = actingFactionId,
|
||||
actingProvinceId =
|
||||
swearBrotherhoodAvailableCommand.actingProvinceId,
|
||||
ProvinceId(swearBrotherhoodAvailableCommand.actingProvinceId),
|
||||
available = swearBrotherhoodAvailableCommand,
|
||||
selected =
|
||||
SwearBrotherhoodSelectedCommand(newBrotherHeroId = desiredHeroId),
|
||||
selected = SwearBrotherhoodSelectedCommand(newBrotherHeroId =
|
||||
desiredHeroId.value
|
||||
),
|
||||
reason = "chose swear brotherhood"
|
||||
)
|
||||
}
|
||||
|
||||
+11
-10
@@ -13,7 +13,7 @@ import net.eagle0.eagle.internal.game_state.GameState
|
||||
import net.eagle0.eagle.library.util.CommandSelection
|
||||
import net.eagle0.eagle.library.util.command_choice_helpers.AvailableCommandSelector.ofType
|
||||
import net.eagle0.eagle.library.util.faction_utils.LegacyFactionUtils
|
||||
import net.eagle0.eagle.{FactionId, HeroId}
|
||||
import net.eagle0.eagle.{FactionId, HeroId, ProvinceId}
|
||||
|
||||
object TruceOfferCommandSelector {
|
||||
private def usableHeroIds(
|
||||
@@ -28,7 +28,7 @@ object TruceOfferCommandSelector {
|
||||
): Option[TruceOption] =
|
||||
options.collectFirst {
|
||||
case x @ TruceOption(tfid, _, _ /* unknownFieldSet */ )
|
||||
if tfid == targetFactionId =>
|
||||
if FactionId(tfid) == targetFactionId =>
|
||||
x
|
||||
}
|
||||
|
||||
@@ -44,24 +44,25 @@ object TruceOfferCommandSelector {
|
||||
ac.options.toVector,
|
||||
targetFactionId
|
||||
).isDefined && usableHeroIds(
|
||||
ac.availableHeroIds.toVector,
|
||||
ac.availableHeroIds.map(HeroId(_)).toVector,
|
||||
gameState
|
||||
).nonEmpty
|
||||
}
|
||||
.map { ac =>
|
||||
CommandSelection(
|
||||
actingFactionId = actingFactionId,
|
||||
actingProvinceId = ac.actingProvinceId,
|
||||
actingProvinceId = ProvinceId(ac.actingProvinceId),
|
||||
available = ac,
|
||||
selected = DiplomacySelectedCommand(
|
||||
selectedOption =
|
||||
truceOptionWithTarget(ac.options.toVector, targetFactionId).get,
|
||||
targetFactionId = targetFactionId,
|
||||
sentHeroId =
|
||||
usableHeroIds(ac.availableHeroIds.toVector, gameState).maxBy {
|
||||
hid =>
|
||||
gameState.heroes(hid).vigor
|
||||
}
|
||||
targetFactionId = targetFactionId.value,
|
||||
sentHeroId = usableHeroIds(
|
||||
ac.availableHeroIds.map(HeroId(_)).toVector,
|
||||
gameState
|
||||
).maxBy { hid =>
|
||||
gameState.heroes(hid.value).vigor
|
||||
}.value
|
||||
),
|
||||
reason = "chosenTruceWithFactionCommand"
|
||||
)
|
||||
|
||||
+6
-6
@@ -71,7 +71,7 @@ object TrustForDiplomacy {
|
||||
gameState: GameState
|
||||
): Boolean =
|
||||
!gameState
|
||||
.factions(actingFactionId)
|
||||
.factions(actingFactionId.value)
|
||||
.lastOutgoingTruceOfferRounds
|
||||
.exists {
|
||||
case OutgoingOfferRound(
|
||||
@@ -79,7 +79,7 @@ object TrustForDiplomacy {
|
||||
roundId,
|
||||
_ /* unknownFieldSet */
|
||||
) =>
|
||||
toFactionId == targetFactionId && roundId + MinimumMonthsBeforeRepeatTruceOffer.intValue > gameState.currentRoundId
|
||||
toFactionId == targetFactionId.value && roundId + MinimumMonthsBeforeRepeatTruceOffer.intValue > gameState.currentRoundId
|
||||
}
|
||||
|
||||
private def hasBeenLongEnoughForTruce(
|
||||
@@ -88,7 +88,7 @@ object TrustForDiplomacy {
|
||||
gameState: GameState
|
||||
): Boolean =
|
||||
!gameState
|
||||
.factions(actingFactionId)
|
||||
.factions(actingFactionId.value)
|
||||
.lastOutgoingTruceOfferRounds
|
||||
.exists {
|
||||
case OutgoingOfferRound(
|
||||
@@ -96,7 +96,7 @@ object TrustForDiplomacy {
|
||||
roundId,
|
||||
_ /* unknownFieldSet */
|
||||
) =>
|
||||
toFactionId == targetFactionId && roundId + MinimumMonthsBeforeRepeatTruceOffer.intValue > gameState.currentRoundId
|
||||
toFactionId == targetFactionId.value && roundId + MinimumMonthsBeforeRepeatTruceOffer.intValue > gameState.currentRoundId
|
||||
}
|
||||
|
||||
def meetsConditionsForInvitation(
|
||||
@@ -131,7 +131,7 @@ object TrustForDiplomacy {
|
||||
gameState: GameState
|
||||
): Boolean =
|
||||
!gameState
|
||||
.factions(actingFactionId)
|
||||
.factions(actingFactionId.value)
|
||||
.lastOutgoingInvitationRounds
|
||||
.exists {
|
||||
case OutgoingOfferRound(
|
||||
@@ -139,6 +139,6 @@ object TrustForDiplomacy {
|
||||
roundId,
|
||||
_ /* unknownFieldSet */
|
||||
) =>
|
||||
toFactionId == targetFactionId && roundId + MinimumMonthsBeforeRepeatInvitation.intValue > gameState.currentRoundId
|
||||
toFactionId == targetFactionId.value && roundId + MinimumMonthsBeforeRepeatInvitation.intValue > gameState.currentRoundId
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -40,12 +40,12 @@ object DismissSpecificVassalCommandChooser
|
||||
) =>
|
||||
MoreOption.flatWhen(
|
||||
// Don't exile a vassal that would leave the faction leader here by themselves
|
||||
gameState.provinces(pid).rulingFactionHeroIds.size > 2 &&
|
||||
gameState.provinces(pid.value).rulingFactionHeroIds.size > 2 &&
|
||||
// Don't exile a vassal unless they're much less powerful than the hero that would replace them
|
||||
LegacyHeroUtils.power(gameState.heroes(uh.heroId)) >=
|
||||
RequiredPowerMultiplierForDismiss.doubleValue * LegacyHeroUtils
|
||||
.power(
|
||||
gameState.heroes(targetHeroId)
|
||||
gameState.heroes(targetHeroId.value)
|
||||
)
|
||||
) {
|
||||
ExileVassalCommandSelector
|
||||
|
||||
+3
-3
@@ -1,5 +1,5 @@
|
||||
package net.eagle0.eagle.library.util.command_choice_helpers.quest_command_selectors
|
||||
import net.eagle0.eagle.FactionId
|
||||
import net.eagle0.eagle.{FactionId, ProvinceId}
|
||||
import net.eagle0.eagle.api.available_command.AvailableCommand
|
||||
import net.eagle0.eagle.common.unaffiliated_hero_quest.{
|
||||
GiveToHeroesAcrossRealmQuest,
|
||||
@@ -41,12 +41,12 @@ object GiveToHeroesAcrossRealmQuestCommandChooser
|
||||
gameState = gameState,
|
||||
availableCommands = availableCommands,
|
||||
maxAmount = desiredAmount,
|
||||
provinceId = p.id
|
||||
provinceId = ProvinceId(p.id)
|
||||
)
|
||||
}
|
||||
// Of available commands, choose the one for the province with the largest amount of gold
|
||||
.maxByOption { commandSelection =>
|
||||
gameState.provinces(commandSelection.actingProvinceId).gold
|
||||
gameState.provinces(commandSelection.actingProvinceId.value).gold
|
||||
}
|
||||
|
||||
override def chosenDeterministicCommand(
|
||||
|
||||
+20
-15
@@ -24,11 +24,11 @@ object LegacyFactionUtils {
|
||||
gameState: GameState
|
||||
): FactionRelationship =
|
||||
gameState.factions
|
||||
.get(by)
|
||||
.flatMap(_.factionRelationships.find(_.targetFactionId == of))
|
||||
.get(by.value)
|
||||
.flatMap(_.factionRelationships.find(_.targetFactionId == of.value))
|
||||
.getOrElse(
|
||||
FactionRelationship(
|
||||
targetFactionId = of,
|
||||
targetFactionId = of.value,
|
||||
relationshipLevel = FactionRelationship.RelationshipLevel.HOSTILE,
|
||||
resetDate = None,
|
||||
trustValue = 0
|
||||
@@ -50,7 +50,7 @@ object LegacyFactionUtils {
|
||||
// ???
|
||||
|
||||
fromSupportedProvinces + gameState
|
||||
.factions(factionId)
|
||||
.factions(factionId.value)
|
||||
.prestigeModifiers
|
||||
.map(_.value)
|
||||
.sum
|
||||
@@ -67,31 +67,35 @@ object LegacyFactionUtils {
|
||||
def factionHead(factionId: FactionId, gameState: GameState): Option[Hero] =
|
||||
factionHeadId(factionId, gameState).map(hid =>
|
||||
// Check in killed heroes as well for the edge case that a hero was executed in the same phase
|
||||
gameState.heroes.getOrElse(hid, gameState.killedHeroes(hid))
|
||||
gameState.heroes.getOrElse(hid.value, gameState.killedHeroes(hid.value))
|
||||
)
|
||||
|
||||
def factionHeadId(
|
||||
factionId: FactionId,
|
||||
gameState: GameState
|
||||
): Option[HeroId] =
|
||||
gameState.factions.get(factionId).map(_.factionHeadId)
|
||||
gameState.factions.get(factionId.value).map(f => HeroId(f.factionHeadId))
|
||||
|
||||
def isFactionHead(heroId: HeroId, gameState: GameState): Boolean =
|
||||
gameState.factions.values.map(_.factionHeadId).exists(_ == heroId)
|
||||
gameState.factions.values
|
||||
.map(f => HeroId(f.factionHeadId))
|
||||
.exists(_ == heroId)
|
||||
|
||||
def leadersBesidesHead(
|
||||
factionId: FactionId,
|
||||
gameState: GameState
|
||||
): Vector[HeroId] =
|
||||
gameState
|
||||
.factions(factionId)
|
||||
.factions(factionId.value)
|
||||
.leaders
|
||||
.filterNot(_ == gameState.factions(factionId).factionHeadId)
|
||||
.filterNot(_ == gameState.factions(factionId.value).factionHeadId)
|
||||
.map(HeroId(_))
|
||||
.toVector
|
||||
|
||||
def isFactionLeader(heroId: HeroId, gameState: GameState): Boolean =
|
||||
gameState.factions.values
|
||||
.flatMap(_.leaders)
|
||||
.map(HeroId(_))
|
||||
.exists(_ == heroId)
|
||||
|
||||
def provinces(factionId: FactionId, gameState: GameState): Vector[Province] =
|
||||
@@ -105,10 +109,11 @@ object LegacyFactionUtils {
|
||||
): ProvinceId => Vector[ProvinceId] =
|
||||
pid =>
|
||||
gameState
|
||||
.provinces(pid)
|
||||
.provinces(pid.value)
|
||||
.neighbors
|
||||
.map(_.provinceId)
|
||||
.filter(n => gameState.provinces(n).rulingFactionId.contains(fid))
|
||||
.map(ProvinceId(_))
|
||||
.toVector
|
||||
|
||||
def hasProvinces(factionId: FactionId, gameState: GameState): Boolean =
|
||||
@@ -130,7 +135,7 @@ object LegacyFactionUtils {
|
||||
fid: FactionId,
|
||||
gs: GameState
|
||||
): Vector[Province] =
|
||||
hostileNeighbors(gs.provinces(pid), fid, gs)
|
||||
hostileNeighbors(gs.provinces(pid.value), fid, gs)
|
||||
|
||||
def hostileNeighbors(
|
||||
province: Province,
|
||||
@@ -139,11 +144,11 @@ object LegacyFactionUtils {
|
||||
): Vector[Province] =
|
||||
province.neighbors
|
||||
.map(_.provinceId)
|
||||
.map(gs.provinces)
|
||||
.map(n => gs.provinces(n))
|
||||
.filter(_.rulingFactionId.isDefined)
|
||||
.filterNot(_.rulingFactionId.contains(fid))
|
||||
.filterNot(neighbor =>
|
||||
hasTruceOrAlliance(fid, neighbor.rulingFactionId.get, gs)
|
||||
hasTruceOrAlliance(fid, FactionId(neighbor.rulingFactionId.get), gs)
|
||||
)
|
||||
.toVector
|
||||
|
||||
@@ -154,7 +159,7 @@ object LegacyFactionUtils {
|
||||
): Vector[Province] =
|
||||
province.neighbors
|
||||
.map(_.provinceId)
|
||||
.map(gs.provinces)
|
||||
.map(n => gs.provinces(n))
|
||||
.filterNot(_.rulingFactionId.isDefined)
|
||||
.toVector
|
||||
|
||||
@@ -202,7 +207,7 @@ object LegacyFactionUtils {
|
||||
|
||||
def alliedFactions(toFid: FactionId, gs: GameState): Vector[FactionId] =
|
||||
gs
|
||||
.factions(toFid)
|
||||
.factions(toFid.value)
|
||||
.factionRelationships
|
||||
.collect {
|
||||
case FactionRelationship(
|
||||
|
||||
@@ -24,7 +24,7 @@ object LegacyHeroUtils {
|
||||
includePower: Boolean = true
|
||||
): Vector[Int] =
|
||||
gameState.heroes
|
||||
.get(heroId)
|
||||
.get(heroId.value)
|
||||
.map { hero =>
|
||||
val factionHeadScore =
|
||||
if !includePower then 0
|
||||
@@ -44,7 +44,7 @@ object LegacyHeroUtils {
|
||||
factionHeadScore,
|
||||
professionScore,
|
||||
powerScore,
|
||||
heroId // just to make the sort stable
|
||||
heroId.value // just to make the sort stable
|
||||
)
|
||||
}
|
||||
.getOrElse(Vector())
|
||||
@@ -92,12 +92,12 @@ object LegacyHeroUtils {
|
||||
provinceId: ProvinceId
|
||||
): Vector[Province] =
|
||||
if gameState
|
||||
.provinces(provinceId)
|
||||
.provinces(provinceId.value)
|
||||
.rulingHeroId
|
||||
.exists(hid => LegacyFactionUtils.isFactionHead(hid, gameState))
|
||||
.exists(hid => LegacyFactionUtils.isFactionHead(HeroId(hid), gameState))
|
||||
then
|
||||
gameState.provinces.values
|
||||
.filter(_.rulingFactionId.contains(factionId))
|
||||
.filter(_.rulingFactionId.contains(factionId.value))
|
||||
.filterNot(p =>
|
||||
p.rulingFactionHeroIds.exists(
|
||||
LegacyFactionUtils.leadersBesidesHead(factionId, gameState).contains
|
||||
@@ -107,16 +107,16 @@ object LegacyHeroUtils {
|
||||
)
|
||||
)
|
||||
.toVector
|
||||
.sortBy(p => if p.id == provinceId then 0 else p.id)
|
||||
else Vector(gameState.provinces(provinceId))
|
||||
.sortBy(p => if p.id == provinceId.value then 0 else p.id)
|
||||
else Vector(gameState.provinces(provinceId.value))
|
||||
|
||||
def faction(hid: HeroId, gs: GameState): Option[Faction] =
|
||||
gs.heroes(hid).factionId.map(gs.factions)
|
||||
gs.heroes(hid.value).factionId.map(gs.factions)
|
||||
|
||||
def effectiveLoyalty(hid: HeroId, gs: GameState): Double =
|
||||
if LegacyFactionUtils.isFactionLeader(gameState = gs, heroId = hid) then
|
||||
100.0
|
||||
else gs.heroes(hid).loyalty
|
||||
else gs.heroes(hid.value).loyalty
|
||||
|
||||
def loyaltyAsStatWithCondition(
|
||||
hid: HeroId,
|
||||
@@ -126,7 +126,7 @@ object LegacyHeroUtils {
|
||||
!LegacyFactionUtils.isFactionLeader(gameState = gs, heroId = hid)
|
||||
)(
|
||||
scWithRanges(
|
||||
gs.heroes(hid).loyalty.floor.toInt,
|
||||
gs.heroes(hid.value).loyalty.floor.toInt,
|
||||
minMedium = 50,
|
||||
minHigh = 80
|
||||
)
|
||||
@@ -138,7 +138,7 @@ object LegacyHeroUtils {
|
||||
): Option[StatWithCondition] =
|
||||
Some(
|
||||
scWithRanges(
|
||||
gs.heroes(hid).vigor.floor.toInt,
|
||||
gs.heroes(hid.value).vigor.floor.toInt,
|
||||
minMedium = 40,
|
||||
minHigh = 70
|
||||
)
|
||||
|
||||
+4
-4
@@ -1,7 +1,7 @@
|
||||
package net.eagle0.eagle.library.util.hero_generator.random_hero_generator
|
||||
|
||||
import net.eagle0.common.{FunctionalRandom, RandomState}
|
||||
import net.eagle0.eagle.HeroId
|
||||
import net.eagle0.eagle.{HeroId, ClientTextId}
|
||||
import net.eagle0.eagle.library.EagleInternalException
|
||||
import net.eagle0.eagle.library.util.hero_generator.hero_generation_response.HeroGenerationResponse
|
||||
import net.eagle0.eagle.library.util.hero_generator.name_info.NameRequest
|
||||
@@ -102,7 +102,7 @@ object RandomHeroGenerator {
|
||||
RandomHeroPersonalities.randomPersonalityWords(3, innerFr).map {
|
||||
personalityWords =>
|
||||
HeroC(
|
||||
id = -1,
|
||||
id = HeroId(-1),
|
||||
strength = strength,
|
||||
agility = agility,
|
||||
constitution = constitution,
|
||||
@@ -180,7 +180,7 @@ object RandomHeroGenerator {
|
||||
nameTextId = nameTextId,
|
||||
backstoryVersions = Vector(
|
||||
BackstoryVersion(
|
||||
textId = s"hero_${hid}_backstory_0",
|
||||
textId = ClientTextId(s"hero_${hid}_backstory_0"),
|
||||
date = date
|
||||
)
|
||||
)
|
||||
@@ -222,7 +222,7 @@ object RandomHeroGenerator {
|
||||
nameTextId = nameTextId,
|
||||
backstoryVersions = Vector(
|
||||
BackstoryVersion(
|
||||
textId = s"hero_${hid}_backstory_0",
|
||||
textId = ClientTextId(s"hero_${hid}_backstory_0"),
|
||||
date = date
|
||||
)
|
||||
)
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package net.eagle0.eagle.library.util.province
|
||||
|
||||
import net.eagle0.eagle.{ProvinceId, HeroId, RoundId}
|
||||
import net.eagle0.eagle.common.battalion_type.{BattalionType, BattalionTypeId}
|
||||
import net.eagle0.eagle.common.beast_info.BeastInfo
|
||||
import net.eagle0.eagle.common.province_event.ProvinceEvent
|
||||
@@ -42,7 +43,7 @@ object LegacyProvinceUtils {
|
||||
provinceId: ProvinceId,
|
||||
gameState: GameState
|
||||
): Vector[Province] = {
|
||||
val baseProvince = gameState.provinces(provinceId)
|
||||
val baseProvince = gameState.provinces(provinceId.value)
|
||||
|
||||
baseProvince.neighbors
|
||||
.map(_.provinceId)
|
||||
@@ -58,13 +59,13 @@ object LegacyProvinceUtils {
|
||||
gameState: GameState
|
||||
): Boolean =
|
||||
gameState
|
||||
.provinces(provinceId)
|
||||
.provinces(provinceId.value)
|
||||
.neighbors
|
||||
.map(_.provinceId)
|
||||
.map(gameState.provinces)
|
||||
.exists(
|
||||
_.rulingFactionId
|
||||
.exists(_ != factionId)
|
||||
.exists(_ != factionId.value)
|
||||
)
|
||||
|
||||
def foodCap(province: Province): Int =
|
||||
@@ -89,10 +90,12 @@ object LegacyProvinceUtils {
|
||||
gameState: GameState
|
||||
): Option[Int] = {
|
||||
Option.when(
|
||||
gameState.provinces(provinceId).support >= MinSupportForTaxes.doubleValue
|
||||
gameState
|
||||
.provinces(provinceId.value)
|
||||
.support >= MinSupportForTaxes.doubleValue
|
||||
)(
|
||||
(effectiveEconomy(
|
||||
gameState.provinces(provinceId)
|
||||
gameState.provinces(provinceId.value)
|
||||
) * GoldIncreasePerEconomy.doubleValue).toInt
|
||||
)
|
||||
}
|
||||
@@ -103,7 +106,7 @@ object LegacyProvinceUtils {
|
||||
val monthsRemaining = 12 - gameState.currentDate.get.month
|
||||
val monthlyAvailable =
|
||||
if monthsRemaining == 0 then Int.MaxValue
|
||||
else gameState.provinces(provinceId).food / monthsRemaining
|
||||
else gameState.provinces(provinceId.value).food / monthsRemaining
|
||||
val monthlyProduction = annualFoodProduction(provinceId, gameState)
|
||||
.getOrElse(0) / 12
|
||||
|
||||
@@ -116,7 +119,7 @@ object LegacyProvinceUtils {
|
||||
): Int =
|
||||
LegacyBattalionUtils.monthlyConsumedFood(
|
||||
gameState
|
||||
.provinces(provinceId)
|
||||
.provinces(provinceId.value)
|
||||
.battalionIds
|
||||
.map(gameState.battalions),
|
||||
gameState.battalionTypes.toVector
|
||||
@@ -126,12 +129,14 @@ object LegacyProvinceUtils {
|
||||
provinceId: ProvinceId,
|
||||
gameState: GameState
|
||||
): Option[Int] =
|
||||
if gameState.provinces(provinceId).support < MinSupportForTaxes.doubleValue
|
||||
if gameState
|
||||
.provinces(provinceId.value)
|
||||
.support < MinSupportForTaxes.doubleValue
|
||||
then None
|
||||
else
|
||||
Some(
|
||||
(effectiveAgriculture(
|
||||
gameState.provinces(provinceId)
|
||||
gameState.provinces(provinceId.value)
|
||||
) * FoodIncreasePerAgriculture.doubleValue).toInt
|
||||
)
|
||||
|
||||
@@ -144,7 +149,7 @@ object LegacyProvinceUtils {
|
||||
)
|
||||
then 0
|
||||
else
|
||||
(gameState.provinces(provinceId).food - monthlyFoodConsumption(
|
||||
(gameState.provinces(provinceId.value).food - monthlyFoodConsumption(
|
||||
provinceId,
|
||||
gameState
|
||||
) * (12 - gameState.currentDate.get.month)).max(0)
|
||||
@@ -164,9 +169,10 @@ object LegacyProvinceUtils {
|
||||
.intersect(faction.leaders)
|
||||
.map(gameState.heroes)
|
||||
} yield {
|
||||
if rulingFactionHeroIds.contains(factionHead) then factionHead
|
||||
else if presentLeaders.nonEmpty then preferredLeader(presentLeaders).id
|
||||
else preferredLeader(rulingPlayerHeroes).id
|
||||
if rulingFactionHeroIds.contains(factionHead) then HeroId(factionHead)
|
||||
else if presentLeaders.nonEmpty then
|
||||
HeroId(preferredLeader(presentLeaders).id)
|
||||
else HeroId(preferredLeader(rulingPlayerHeroes).id)
|
||||
}
|
||||
|
||||
private def preferredLeader(heroes: Iterable[Hero]): Hero =
|
||||
@@ -194,7 +200,7 @@ object LegacyProvinceUtils {
|
||||
province.incomingArmies
|
||||
.flatMap(_.army)
|
||||
.flatMap(_.units)
|
||||
.map(_.heroId)
|
||||
.map(u => HeroId(u.heroId))
|
||||
.toVector
|
||||
|
||||
def provinceLeaderSeniority(province: Province, gameState: GameState): Int =
|
||||
@@ -232,7 +238,7 @@ object LegacyProvinceUtils {
|
||||
(p.rulingFactionHeroIds ++ p.unaffiliatedHeroes.map(_.heroId))
|
||||
.contains(heroId)
|
||||
)
|
||||
.map(_.id)
|
||||
.map(p => ProvinceId(p.id))
|
||||
|
||||
def clearRulingFaction(
|
||||
province: Province,
|
||||
@@ -332,17 +338,17 @@ object LegacyProvinceUtils {
|
||||
p.activeEvents.flatMap(ProvinceEventUtils.beastInfo).headOption
|
||||
|
||||
def containsFactionLeader(pid: ProvinceId, gs: GameState): Boolean =
|
||||
gs.provinces(pid)
|
||||
gs.provinces(pid.value)
|
||||
.rulingFactionId
|
||||
.exists(fid =>
|
||||
gs.provinces(pid)
|
||||
gs.provinces(pid.value)
|
||||
.rulingFactionHeroIds
|
||||
.contains(gs.factions(fid).factionHeadId)
|
||||
)
|
||||
|
||||
def incomingOthers(p: Province, arrivalRound: RoundId): Vector[MovingArmy] =
|
||||
p.incomingArmies
|
||||
.filter(_.arrivalRound == arrivalRound)
|
||||
.filter(ma => RoundId(ma.arrivalRound) == arrivalRound)
|
||||
.filterNot(ma => p.rulingFactionId.contains(ma.getArmy.factionId))
|
||||
.toVector
|
||||
|
||||
|
||||
@@ -188,18 +188,26 @@ object RuntimeValidator extends Validator {
|
||||
val rph = for {
|
||||
p <- gameState.provinces.values
|
||||
hid <- p.rulingFactionHeroIds
|
||||
} yield HeroProvincePair(hid = hid, pid = p.id, pos = 0)
|
||||
} yield HeroProvincePair(hid = HeroId(hid), pid = ProvinceId(p.id), pos = 0)
|
||||
|
||||
val uafh = for {
|
||||
p <- gameState.provinces.values
|
||||
uh <- p.unaffiliatedHeroes
|
||||
} yield HeroProvincePair(hid = uh.heroId, pid = p.id, pos = 1)
|
||||
} yield HeroProvincePair(
|
||||
hid = HeroId(uh.heroId),
|
||||
pid = ProvinceId(p.id),
|
||||
pos = 1
|
||||
)
|
||||
|
||||
val iah = for {
|
||||
p <- gameState.provinces.values
|
||||
ia <- p.incomingArmies
|
||||
u <- ia.getArmy.units
|
||||
} yield HeroProvincePair(hid = u.heroId, pid = p.id, pos = 2)
|
||||
} yield HeroProvincePair(
|
||||
hid = HeroId(u.heroId),
|
||||
pid = ProvinceId(p.id),
|
||||
pos = 2
|
||||
)
|
||||
|
||||
val accountedForHeroes = rph ++ uafh ++ iah
|
||||
|
||||
@@ -219,7 +227,7 @@ object RuntimeValidator extends Validator {
|
||||
val accountedForBattalions = gameState.provinces.values.flatMap(p =>
|
||||
(p.battalionIds ++ p.incomingArmies
|
||||
.flatMap(_.getArmy.units.flatMap(_.battalionId)))
|
||||
.map((p.id, _))
|
||||
.map((ProvinceId(p.id), _))
|
||||
)
|
||||
|
||||
accountedForBattalions.groupBy(_._2).foreach { case (bid, tups) =>
|
||||
@@ -237,7 +245,7 @@ object RuntimeValidator extends Validator {
|
||||
.filter(_.rulingFactionId.isDefined)
|
||||
.foreach { province =>
|
||||
val mismatchedHero = province.rulingFactionHeroIds
|
||||
.map(gameState.heroes)
|
||||
.map(h => gameState.heroes(h))
|
||||
.find(!_.factionId.contains(province.rulingFactionId.get))
|
||||
|
||||
validationRequireNot(
|
||||
@@ -264,27 +272,27 @@ object RuntimeValidator extends Validator {
|
||||
private def validateHeroExistence(gs: GameState): Unit = {
|
||||
gs.provinces.values
|
||||
.flatMap(_.rulingFactionHeroIds)
|
||||
.foreach(validateHidExists(_, gs))
|
||||
.foreach(h => validateHidExists(HeroId(h), gs))
|
||||
gs.provinces.values
|
||||
.flatMap(_.unaffiliatedHeroes.map(_.heroId))
|
||||
.flatMap(_.unaffiliatedHeroes.map(uh => HeroId(uh.heroId)))
|
||||
.foreach(validateHidExists(_, gs))
|
||||
}
|
||||
|
||||
private def validateHidExists(hid: HeroId, gs: GameState): Unit =
|
||||
validationRequireNot(
|
||||
!gs.heroes.contains(hid),
|
||||
!gs.heroes.contains(hid.value),
|
||||
s"HeroId $hid is not present in game state"
|
||||
)
|
||||
|
||||
private def validateBattalionExistence(gs: GameState): Unit = {
|
||||
gs.provinces.values
|
||||
.flatMap(_.battalionIds)
|
||||
.foreach(validateBidExists(_, gs))
|
||||
.foreach(b => validateBidExists(BattalionId(b), gs))
|
||||
}
|
||||
|
||||
private def validateBidExists(bid: BattalionId, gs: GameState): Unit =
|
||||
validationRequireNot(
|
||||
!gs.battalions.contains(bid),
|
||||
!gs.battalions.contains(bid.value),
|
||||
s"BattalionId $bid is not present in game state"
|
||||
)
|
||||
|
||||
@@ -352,7 +360,7 @@ object RuntimeValidator extends Validator {
|
||||
): Unit = {
|
||||
for ia <- province.incomingArmies do {
|
||||
validationRequireNot(
|
||||
currentRoundId > ia.arrivalRound,
|
||||
currentRoundId.value > ia.arrivalRound,
|
||||
s"MovingArmy ${ia.id} was supposed to arrive in round ${ia.arrivalRound}, but it is round $currentRoundId"
|
||||
)
|
||||
}
|
||||
|
||||
@@ -14,11 +14,15 @@ object ArmyFilter {
|
||||
ArmyView(
|
||||
factionId = army.factionId,
|
||||
units =
|
||||
if factionId.forall(_ == army.factionId) then army.units
|
||||
if factionId.forall(_ == FactionId(army.factionId)) then army.units
|
||||
else Vector.empty,
|
||||
unitCount = army.units.length,
|
||||
troopCount =
|
||||
army.units.flatMap(_.battalionId).map(battalions).map(_.size).sum
|
||||
troopCount = army.units
|
||||
.flatMap(_.battalionId)
|
||||
.map(BattalionId(_))
|
||||
.map(battalions)
|
||||
.map(_.size)
|
||||
.sum
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ object BattleFilter {
|
||||
fid: Option[FactionId]
|
||||
): ShardokBattleView = {
|
||||
val shardokPlayer = {
|
||||
battle.players.find(sp => fid.contains(sp.eagleFid))
|
||||
battle.players.find(sp => fid.map(_.value).contains(sp.eagleFid))
|
||||
}
|
||||
shardokPlayer
|
||||
.map { sp =>
|
||||
@@ -51,7 +51,9 @@ object BattleFilter {
|
||||
playerId = i,
|
||||
eagleFactionId = sp.eagleFid,
|
||||
hostility = fid
|
||||
.map(f => LegacyFactionUtils.hostilityStatus(f, sp.eagleFid, gs))
|
||||
.map(f =>
|
||||
LegacyFactionUtils.hostilityStatus(f, FactionId(sp.eagleFid), gs)
|
||||
)
|
||||
.getOrElse(Hostility.UNKNOWN_HOSTILITY)
|
||||
)
|
||||
}.toVector
|
||||
|
||||
@@ -40,13 +40,18 @@ object FactionViewFilter {
|
||||
gs: GameState,
|
||||
fid: Option[FactionId]
|
||||
): FactionView =
|
||||
if fid.isEmpty || Visibility.hasFullVisibility(fid, faction.id, gs) then
|
||||
if fid.isEmpty || Visibility.hasFullVisibility(
|
||||
fid,
|
||||
FactionId(faction.id),
|
||||
gs
|
||||
)
|
||||
then
|
||||
FactionView(
|
||||
id = faction.id,
|
||||
factionHeadId = faction.factionHeadId,
|
||||
leaders = faction.leaders,
|
||||
name = faction.name,
|
||||
prestige = LegacyFactionUtils.prestige(faction.id, gs).toInt,
|
||||
prestige = LegacyFactionUtils.prestige(FactionId(faction.id), gs).toInt,
|
||||
factionRelationships =
|
||||
faction.factionRelationships.map(filteredFactionRelationshipView),
|
||||
// You can see *your incoming diplomacy offers on them*, but they cannot
|
||||
|
||||
@@ -34,10 +34,10 @@ object HeroViewFilter {
|
||||
): Boolean =
|
||||
gs.currentPhase == DIPLOMACY_RESOLUTION &&
|
||||
gs.factions
|
||||
.get(destinationFactionId)
|
||||
.get(destinationFactionId.value)
|
||||
.toVector
|
||||
.flatMap(_.incomingDiplomacyOffers)
|
||||
.exists(_.messengerHeroId == heroId)
|
||||
.exists(x => HeroId(x.messengerHeroId) == heroId)
|
||||
|
||||
private def heroIsOfferedInRansom(
|
||||
heroId: HeroId,
|
||||
@@ -46,7 +46,7 @@ object HeroViewFilter {
|
||||
): Boolean =
|
||||
gs.currentPhase == DIPLOMACY_RESOLUTION &&
|
||||
gs.factions
|
||||
.get(destinationFactionId)
|
||||
.get(destinationFactionId.value)
|
||||
.toVector
|
||||
.flatMap(_.incomingDiplomacyOffers)
|
||||
.exists { (ro: DiplomacyOffer) =>
|
||||
@@ -58,8 +58,8 @@ object HeroViewFilter {
|
||||
_ /* goldOffered */,
|
||||
_ /* unknownFieldSet */
|
||||
) =>
|
||||
hostagesOffered.exists(_.heroId == heroId) ||
|
||||
prisonersOffered.exists(_.heroId == heroId)
|
||||
hostagesOffered.exists(ho => HeroId(ho.heroId) == heroId) ||
|
||||
prisonersOffered.exists(po => HeroId(po.heroId) == heroId)
|
||||
case _ => false
|
||||
}
|
||||
}
|
||||
@@ -72,23 +72,25 @@ object HeroViewFilter {
|
||||
factionId.isEmpty
|
||||
|| (Visibility.hasFullVisibility(
|
||||
factionId,
|
||||
hero.factionId,
|
||||
hero.factionId.map(FactionId(_)),
|
||||
gs
|
||||
) && !heroIsPrisoner(hero, gs))
|
||||
|| Visibility.hasFullVisibility(
|
||||
factionId,
|
||||
heroUnaffiliatedInProvince(hero = hero, gs = gs).flatMap(
|
||||
_.rulingFactionId
|
||||
),
|
||||
heroUnaffiliatedInProvince(hero = hero, gs = gs)
|
||||
.flatMap(
|
||||
_.rulingFactionId
|
||||
)
|
||||
.map(FactionId(_)),
|
||||
gs
|
||||
)
|
||||
|| heroIsAmbassadorToFaction(
|
||||
heroId = hero.id,
|
||||
heroId = HeroId(hero.id),
|
||||
destinationFactionId = factionId.get,
|
||||
gs = gs
|
||||
)
|
||||
|| heroIsOfferedInRansom(
|
||||
heroId = hero.id,
|
||||
heroId = HeroId(hero.id),
|
||||
destinationFactionId = factionId.get,
|
||||
gs = gs
|
||||
)
|
||||
@@ -119,13 +121,15 @@ object HeroViewFilter {
|
||||
ambition = hero.ambition,
|
||||
gregariousness = hero.gregariousness,
|
||||
bravery = hero.bravery,
|
||||
vigor = LegacyHeroUtils.vigorAsStatWithCondition(hero.id, gs),
|
||||
loyalty = LegacyHeroUtils.loyaltyAsStatWithCondition(hero.id, gs),
|
||||
vigor = LegacyHeroUtils.vigorAsStatWithCondition(HeroId(hero.id), gs),
|
||||
loyalty =
|
||||
LegacyHeroUtils.loyaltyAsStatWithCondition(HeroId(hero.id), gs),
|
||||
archeryCapable = LegacyHeroUtils.archeryCapable(hero),
|
||||
startFireCapable = LegacyHeroUtils.startFireCapable(hero),
|
||||
isFactionLeader = LegacyFactionUtils.isFactionLeader(hero.id, gs),
|
||||
isFactionLeader =
|
||||
LegacyFactionUtils.isFactionLeader(HeroId(hero.id), gs),
|
||||
sortKeys = LegacyHeroUtils
|
||||
.sortKeys(gameState = gs, heroId = hero.id)
|
||||
.sortKeys(gameState = gs, heroId = HeroId(hero.id))
|
||||
.map(keyInt => HeroSortKey(keyInt)),
|
||||
imagePath = hero.imagePath,
|
||||
backstoryTextId =
|
||||
@@ -138,7 +142,11 @@ object HeroViewFilter {
|
||||
nameTextId = hero.nameTextId,
|
||||
profession = hero.profession,
|
||||
sortKeys = LegacyHeroUtils
|
||||
.sortKeys(gameState = gs, heroId = hero.id, includePower = false)
|
||||
.sortKeys(
|
||||
gameState = gs,
|
||||
heroId = HeroId(hero.id),
|
||||
includePower = false
|
||||
)
|
||||
.map(keyInt => HeroSortKey(keyInt)),
|
||||
imagePath = hero.imagePath,
|
||||
pronounGender = hero.pronounGender
|
||||
|
||||
+6
-4
@@ -23,7 +23,8 @@ import net.eagle0.eagle.{
|
||||
FactionId,
|
||||
HeroId,
|
||||
MovingSuppliesId,
|
||||
ProvinceId
|
||||
ProvinceId,
|
||||
MovingArmyId
|
||||
}
|
||||
|
||||
sealed trait NewLockedImprovementType
|
||||
@@ -76,9 +77,9 @@ case class ChangedProvinceC(
|
||||
newProvinceEvents: Option[Vector[ProvinceEvent]] = None,
|
||||
/* incoming army changes */
|
||||
newIncomingArmies: Vector[MovingArmy] = Vector.empty,
|
||||
removedIncomingArmyIds: Vector[Int] = Vector.empty,
|
||||
removedIncomingArmyIds: Vector[MovingArmyId] = Vector.empty,
|
||||
newWithdrawingArmies: Vector[MovingArmy] = Vector.empty,
|
||||
removedWithdrawingArmyIds: Vector[Int] = Vector.empty,
|
||||
removedWithdrawingArmyIds: Vector[MovingArmyId] = Vector.empty,
|
||||
newHostileArmies: Vector[HostileArmyGroup] = Vector.empty,
|
||||
removedHostileArmyFactionIds: Vector[FactionId] = Vector.empty,
|
||||
hostileArmyStatusChanges: Vector[HostileArmyStatusChange] = Vector.empty,
|
||||
@@ -127,7 +128,8 @@ case class ChangedProvinceC(
|
||||
heroIds: Vector[HeroId]
|
||||
): ChangedProvinceC = {
|
||||
copy(
|
||||
removedUnaffiliatedHeroIds = removedUnaffiliatedHeroIds ++ heroIds
|
||||
removedUnaffiliatedHeroIds =
|
||||
removedUnaffiliatedHeroIds ++ heroIds.map(_.value)
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ package net.eagle0.eagle.model.action_result.concrete
|
||||
|
||||
import net.eagle0.eagle.model.action_result.ChangedHeroT
|
||||
import net.eagle0.eagle.model.state.hero.EventForHeroBackstoryT
|
||||
import net.eagle0.eagle.{ClientTextId, HeroId}
|
||||
import net.eagle0.eagle.{ClientTextId, HeroId, FactionId}
|
||||
|
||||
sealed trait StatChange
|
||||
case class StatDelta(value: Double) extends StatChange
|
||||
@@ -13,7 +13,7 @@ case class ChangedHeroC(
|
||||
heroId: HeroId,
|
||||
/* faction changes */
|
||||
clearFactionId: Boolean = false,
|
||||
newFactionId: Option[Int] = None,
|
||||
newFactionId: Option[FactionId] = None,
|
||||
/* stat changes */
|
||||
loyaltyChange: StatChange = StatNoChange,
|
||||
vigorChange: StatChange = StatNoChange,
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package net.eagle0.eagle.model.proto_converters
|
||||
|
||||
import net.eagle0.eagle.{FactionId, MovingArmyId, ProvinceId, RoundId}
|
||||
import net.eagle0.eagle.internal.army.HostileArmyGroupStatus.Empty
|
||||
import net.eagle0.eagle.internal.army.{
|
||||
Army as ArmyProto,
|
||||
@@ -26,25 +27,25 @@ import net.eagle0.eagle.model.state.{
|
||||
object ArmyConverter {
|
||||
def toProto(army: Army): ArmyProto =
|
||||
ArmyProto(
|
||||
factionId = army.factionId,
|
||||
factionId = army.factionId.value,
|
||||
units = army.units.map(CombatUnitConverter.toProto),
|
||||
fleeProvinceId = army.fleeProvinceId
|
||||
fleeProvinceId = army.fleeProvinceId.map(_.value)
|
||||
)
|
||||
|
||||
def fromProto(armyProto: ArmyProto): Army =
|
||||
Army(
|
||||
factionId = armyProto.factionId,
|
||||
factionId = FactionId(armyProto.factionId),
|
||||
units = armyProto.units.map(CombatUnitConverter.fromProto).toVector,
|
||||
fleeProvinceId = armyProto.fleeProvinceId
|
||||
fleeProvinceId = armyProto.fleeProvinceId.map(ProvinceId.apply)
|
||||
)
|
||||
|
||||
def toProto(movingArmy: MovingArmy): MovingArmyProto =
|
||||
MovingArmyProto(
|
||||
id = movingArmy.id,
|
||||
id = movingArmy.id.value,
|
||||
army = Some(toProto(movingArmy.army)),
|
||||
arrivalRound = movingArmy.arrivalRound,
|
||||
destinationProvince = movingArmy.destinationProvinceId,
|
||||
originProvince = movingArmy.originProvinceId,
|
||||
arrivalRound = movingArmy.arrivalRound.value,
|
||||
destinationProvince = movingArmy.destinationProvinceId.value,
|
||||
originProvince = movingArmy.originProvinceId.value,
|
||||
supplies = SuppliesConverter.toProto(movingArmy.supplies),
|
||||
suppliesLoss = movingArmy.suppliesLoss,
|
||||
startingPositionIndex = movingArmy.startingPositionIndex
|
||||
@@ -52,11 +53,11 @@ object ArmyConverter {
|
||||
|
||||
def fromProto(movingArmyProto: MovingArmyProto): MovingArmy =
|
||||
MovingArmy(
|
||||
id = movingArmyProto.id,
|
||||
id = MovingArmyId(movingArmyProto.id),
|
||||
army = fromProto(movingArmyProto.army.get),
|
||||
arrivalRound = movingArmyProto.arrivalRound,
|
||||
destinationProvinceId = movingArmyProto.destinationProvince,
|
||||
originProvinceId = movingArmyProto.originProvince,
|
||||
arrivalRound = RoundId(movingArmyProto.arrivalRound),
|
||||
destinationProvinceId = ProvinceId(movingArmyProto.destinationProvince),
|
||||
originProvinceId = ProvinceId(movingArmyProto.originProvince),
|
||||
supplies = movingArmyProto.supplies
|
||||
.map(SuppliesConverter.fromProto)
|
||||
.getOrElse(Supplies(0, 0)),
|
||||
@@ -66,7 +67,7 @@ object ArmyConverter {
|
||||
|
||||
def toProto(hostileArmyGroup: HostileArmyGroup): HostileArmyGroupProto =
|
||||
HostileArmyGroupProto(
|
||||
factionId = hostileArmyGroup.factionId,
|
||||
factionId = hostileArmyGroup.factionId.value,
|
||||
armies = hostileArmyGroup.armies.map(toProto),
|
||||
status = toProto(hostileArmyGroup.status)
|
||||
)
|
||||
@@ -75,7 +76,7 @@ object ArmyConverter {
|
||||
hostileArmyGroupProto: HostileArmyGroupProto
|
||||
): HostileArmyGroup =
|
||||
HostileArmyGroup(
|
||||
factionId = hostileArmyGroupProto.factionId,
|
||||
factionId = FactionId(hostileArmyGroupProto.factionId),
|
||||
armies = hostileArmyGroupProto.armies.map(fromProto).toVector,
|
||||
status = fromProto(hostileArmyGroupProto.status)
|
||||
)
|
||||
@@ -92,7 +93,7 @@ object ArmyConverter {
|
||||
case HostileArmyGroupStatus.Attacking => AttackingProto()
|
||||
case HostileArmyGroupStatus.Withdrawing => WithdrawingProto()
|
||||
case HostileArmyGroupStatus.SafePassageGranted(destinationProvinceId) =>
|
||||
SafePassageGrantedProto(destinationProvinceId)
|
||||
SafePassageGrantedProto(destinationProvinceId.value)
|
||||
}
|
||||
|
||||
def fromProto(
|
||||
@@ -111,7 +112,9 @@ object ArmyConverter {
|
||||
case _: AttackingProto => HostileArmyGroupStatus.Attacking
|
||||
case _: WithdrawingProto => HostileArmyGroupStatus.Withdrawing
|
||||
case SafePassageGrantedProto(destinationProvinceId, _) =>
|
||||
HostileArmyGroupStatus.SafePassageGranted(destinationProvinceId)
|
||||
HostileArmyGroupStatus.SafePassageGranted(
|
||||
ProvinceId(destinationProvinceId)
|
||||
)
|
||||
case Empty =>
|
||||
throw new ProtoConversionException(
|
||||
"hostile army group status cannot be empty"
|
||||
|
||||
@@ -18,7 +18,7 @@ object BattalionConverter {
|
||||
name
|
||||
) =>
|
||||
BattalionProto(
|
||||
id = id,
|
||||
id = id.value,
|
||||
`type` = BattalionTypeIdConverter.toProto(typeId),
|
||||
size = size,
|
||||
training = training,
|
||||
@@ -32,7 +32,7 @@ object BattalionConverter {
|
||||
def fromProto(battalionProto: BattalionProto): BattalionT =
|
||||
battalionProto match {
|
||||
case BattalionProto(
|
||||
id: BattalionId,
|
||||
id: Int,
|
||||
tp: BattalionTypeIdProto,
|
||||
size: Int,
|
||||
training: Double,
|
||||
@@ -41,7 +41,7 @@ object BattalionConverter {
|
||||
_ /* unknownFields */
|
||||
) =>
|
||||
BattalionC(
|
||||
id = id,
|
||||
id = BattalionId(id),
|
||||
typeId = BattalionTypeIdConverter.fromProto(tp),
|
||||
size = size,
|
||||
training = training,
|
||||
|
||||
+6
-4
@@ -1,5 +1,6 @@
|
||||
package net.eagle0.eagle.model.proto_converters
|
||||
|
||||
import net.eagle0.eagle.{FactionId, ProvinceId}
|
||||
import net.eagle0.eagle.internal.battle_revelation.BattleRevelation.RevelationType as BattleRevelationTypeProto
|
||||
import net.eagle0.eagle.internal.battle_revelation.BattleRevelation as BattleRevelationProto
|
||||
import net.eagle0.eagle.model.proto_converters.ProtoConversionException
|
||||
@@ -36,8 +37,8 @@ object BattleRevelationConverter {
|
||||
|
||||
def toProto(battleRevelation: BattleRevelation): BattleRevelationProto =
|
||||
BattleRevelationProto(
|
||||
provinceId = battleRevelation.provinceId,
|
||||
revealedToFactionId = battleRevelation.revealedToFactionId,
|
||||
provinceId = battleRevelation.provinceId.value,
|
||||
revealedToFactionId = battleRevelation.revealedToFactionId.value,
|
||||
revelationType = toProto(battleRevelation.revelationType)
|
||||
)
|
||||
|
||||
@@ -45,8 +46,9 @@ object BattleRevelationConverter {
|
||||
battleRevelationProto: BattleRevelationProto
|
||||
): BattleRevelation =
|
||||
BattleRevelation(
|
||||
provinceId = battleRevelationProto.provinceId,
|
||||
revealedToFactionId = battleRevelationProto.revealedToFactionId,
|
||||
provinceId = ProvinceId(battleRevelationProto.provinceId),
|
||||
revealedToFactionId =
|
||||
FactionId(battleRevelationProto.revealedToFactionId),
|
||||
revelationType = fromProto(battleRevelationProto.revelationType)
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1,25 +1,27 @@
|
||||
package net.eagle0.eagle.model.proto_converters
|
||||
|
||||
import net.eagle0.eagle.{ClientTextId, FactionId, HeroId}
|
||||
import net.eagle0.eagle.internal.unaffiliated_hero.CapturedHero as CapturedHeroProto
|
||||
import net.eagle0.eagle.model.state.CapturedHero
|
||||
|
||||
object CapturedHeroConverter {
|
||||
def toProto(capturedHero: CapturedHero): CapturedHeroProto =
|
||||
CapturedHeroProto(
|
||||
heroId = capturedHero.heroId,
|
||||
heroId = capturedHero.heroId.value,
|
||||
recruitmentAttempted = capturedHero.recruitmentAttempted,
|
||||
previousFactionId = capturedHero.previousFactionId,
|
||||
messageId = capturedHero.messageId,
|
||||
recruitmentRefusedMessageId = capturedHero.recruitmentRefusedMessageId
|
||||
previousFactionId = capturedHero.previousFactionId.value,
|
||||
messageId = capturedHero.messageId.value,
|
||||
recruitmentRefusedMessageId =
|
||||
capturedHero.recruitmentRefusedMessageId.value
|
||||
)
|
||||
|
||||
def fromProto(capturedHeroProto: CapturedHeroProto): CapturedHero =
|
||||
CapturedHero(
|
||||
heroId = capturedHeroProto.heroId,
|
||||
heroId = HeroId(capturedHeroProto.heroId),
|
||||
recruitmentAttempted = capturedHeroProto.recruitmentAttempted,
|
||||
previousFactionId = capturedHeroProto.previousFactionId,
|
||||
messageId = capturedHeroProto.messageId,
|
||||
previousFactionId = FactionId(capturedHeroProto.previousFactionId),
|
||||
messageId = ClientTextId(capturedHeroProto.messageId),
|
||||
recruitmentRefusedMessageId =
|
||||
capturedHeroProto.recruitmentRefusedMessageId
|
||||
ClientTextId(capturedHeroProto.recruitmentRefusedMessageId)
|
||||
)
|
||||
}
|
||||
|
||||
+15
-15
@@ -63,10 +63,10 @@ object ChangedFactionConverter {
|
||||
clearLastActedProvinceId: Boolean
|
||||
) =>
|
||||
ChangedFactionProto(
|
||||
id = factionId,
|
||||
newFactionHeadId = newFactionHeadHeroId,
|
||||
addedLeaders = newLeaderHeroIds,
|
||||
removedLeaders = removedLeaderHeroIds,
|
||||
id = factionId.value,
|
||||
newFactionHeadId = newFactionHeadHeroId.map(_.value),
|
||||
addedLeaders = newLeaderHeroIds.map(_.value),
|
||||
removedLeaders = removedLeaderHeroIds.map(_.value),
|
||||
addedPrestigeModifiers =
|
||||
newPrestigeModifiers.map(FactionConverter.toProto),
|
||||
removedPrestigeModifiers =
|
||||
@@ -74,30 +74,30 @@ object ChangedFactionConverter {
|
||||
changedFactionRelationships =
|
||||
changedFactionRelationships.map(FactionConverter.toProto),
|
||||
removedFactionRelationshipPartners =
|
||||
removedFactionRelationshipFactionIds,
|
||||
removedFactionRelationshipFactionIds.map(_.value),
|
||||
addedIncomingDiplomacyOffers =
|
||||
newIncomingDiplomacyOffers.map(DiplomacyOfferConverter.toProto),
|
||||
removedIncomingDiplomacyOfferFactionIds =
|
||||
removedIncomingDiplomacyOfferFactionIds,
|
||||
removedIncomingDiplomacyOfferFactionIds.map(_.value),
|
||||
addedOutgoingTruceOfferPartners =
|
||||
newOutgoingTruceOfferFactionIds.map(_.fid),
|
||||
newOutgoingTruceOfferFactionIds.map(_.fid).map(_.value),
|
||||
addedOutgoingAllianceOfferPartners =
|
||||
newOutgoingAllianceOfferFactionIds.map(_.fid),
|
||||
newOutgoingAllianceOfferFactionIds.map(_.fid).map(_.value),
|
||||
addedOutgoingInvitationPartners =
|
||||
newOutgoingInvitationFactionIds.map(_.fid),
|
||||
newOutgoingInvitationFactionIds.map(_.fid).map(_.value),
|
||||
addedOutgoingRansomOfferPartners =
|
||||
newOutgoingRansomOfferFactionIds.map(_.fid),
|
||||
newFocusProvinceId = newFocusProvinceId,
|
||||
newOutgoingRansomOfferFactionIds.map(_.fid).map(_.value),
|
||||
newFocusProvinceId = newFocusProvinceId.map(_.value),
|
||||
clearFocusProvinceId = clearFocusProvinceId,
|
||||
updatedReconnedProvinces = updatedReconnedProvinces,
|
||||
removedReconnedProvinceIds = removedReconnedProvinceIds,
|
||||
removedReconnedProvinceIds = removedReconnedProvinceIds.map(_.value),
|
||||
trustLevelUpdates = trustLevelUpdates.map { tlu =>
|
||||
TrustLevelUpdateProto(
|
||||
targetFactionId = tlu.targetFactionId,
|
||||
targetFactionId = tlu.targetFactionId.value,
|
||||
delta = tlu.delta
|
||||
)
|
||||
},
|
||||
newLastActedProvinceId = newLastActedProvinceId,
|
||||
newLastActedProvinceId = newLastActedProvinceId.map(_.value),
|
||||
clearLastActedProvinceId = clearLastActedProvinceId
|
||||
)
|
||||
}
|
||||
@@ -166,7 +166,7 @@ object ChangedFactionConverter {
|
||||
removedReconnedProvinceIds = removedReconnedProvinceIds.toVector,
|
||||
trustLevelUpdates = trustLevelUpdates.map { tlu =>
|
||||
TrustLevelUpdate(
|
||||
targetFactionId = tlu.targetFactionId,
|
||||
targetFactionId = FactionId(tlu.targetFactionId),
|
||||
delta = tlu.delta
|
||||
)
|
||||
}.toVector,
|
||||
|
||||
@@ -37,7 +37,7 @@ object ChangedHeroConverter {
|
||||
clearEventsForHeroBackstory
|
||||
) =>
|
||||
ChangedHeroProto(
|
||||
id = heroId,
|
||||
id = heroId.value,
|
||||
clearFactionId = clearFactionId,
|
||||
newFactionId = newFactionId,
|
||||
loyalty = loyaltyChange match {
|
||||
@@ -55,7 +55,7 @@ object ChangedHeroConverter {
|
||||
charismaXpDelta = charismaXpDelta,
|
||||
wisdomXpDelta = wisdomXpDelta,
|
||||
constitutionXpDelta = constitutionXpDelta,
|
||||
newBackstoryTextId = newBackstoryTextId,
|
||||
newBackstoryTextId = newBackstoryTextId.map(_.value),
|
||||
newBackstoryEvents =
|
||||
newEventsForHeroBackstory.map(EventForHeroBackstoryConverter.toProto),
|
||||
clearBackstoryEvents = clearEventsForHeroBackstory
|
||||
|
||||
+2
-2
@@ -91,7 +91,7 @@ object ChangedProvinceConverter {
|
||||
removedBattleRevelations: Vector[BattleRevelation]
|
||||
) =>
|
||||
ChangedProvinceProto(
|
||||
id = provinceId,
|
||||
id = provinceId.value,
|
||||
goldDelta = goldDelta,
|
||||
foodDelta = foodDelta,
|
||||
newPriceIndex = newPriceIndex,
|
||||
@@ -119,7 +119,7 @@ object ChangedProvinceConverter {
|
||||
recruitmentAtteptedCapturedHeroIds,
|
||||
removedCapturedHeroIds = removedCapturedHeroIds,
|
||||
clearRulingFactionId = clearRulingFactionId,
|
||||
newRulingFactionId = newRulingFactionId,
|
||||
newRulingFactionId = newRulingFactionId.map(_.value),
|
||||
addedRulingPlayerHeroIds = newRulingFactionHeroIds,
|
||||
removedRulingPlayerHeroIds = removedRulingFactionHeroIds,
|
||||
addedBattalionIds = newBattalionIds,
|
||||
|
||||
@@ -2,19 +2,20 @@ package net.eagle0.eagle.model.proto_converters
|
||||
|
||||
import net.eagle0.eagle.common.combat_unit.CombatUnit as CombatUnitProto
|
||||
import net.eagle0.eagle.model.state.CombatUnit
|
||||
import net.eagle0.eagle.{FactionId, HeroId, BattalionId}
|
||||
|
||||
object CombatUnitConverter {
|
||||
def toProto(combatUnit: CombatUnit): CombatUnitProto =
|
||||
CombatUnitProto(
|
||||
factionId = combatUnit.factionId,
|
||||
heroId = combatUnit.heroId,
|
||||
battalionId = combatUnit.battalionId
|
||||
factionId = combatUnit.factionId.value,
|
||||
heroId = combatUnit.heroId.value,
|
||||
battalionId = combatUnit.battalionId.map(_.value)
|
||||
)
|
||||
|
||||
def fromProto(combatUnitProto: CombatUnitProto): CombatUnit =
|
||||
CombatUnit(
|
||||
factionId = combatUnitProto.factionId,
|
||||
heroId = combatUnitProto.heroId,
|
||||
battalionId = combatUnitProto.battalionId
|
||||
factionId = FactionId(combatUnitProto.factionId),
|
||||
heroId = HeroId(combatUnitProto.heroId),
|
||||
battalionId = combatUnitProto.battalionId.map(BattalionId(_))
|
||||
)
|
||||
}
|
||||
|
||||
+108
-102
@@ -31,25 +31,25 @@ object DeferredChangeConverter {
|
||||
deferredChange match {
|
||||
case DeferredChange.BlizzardStarted(responsibleFaction, durationMonths) =>
|
||||
BlizzardStarted(
|
||||
responsibleFaction = responsibleFaction,
|
||||
responsibleFaction = responsibleFaction.value,
|
||||
durationMonths = durationMonths
|
||||
)
|
||||
case DeferredChange.BlizzardEnded(responsibleFaction) =>
|
||||
BlizzardEnded(responsibleFaction)
|
||||
BlizzardEnded(responsibleFaction.value)
|
||||
case DeferredChange.EpidemicStarted(responsibleFaction) =>
|
||||
EpidemicStarted(responsibleFaction)
|
||||
EpidemicStarted(responsibleFaction.value)
|
||||
case DeferredChange.DroughtStarted(responsibleFaction, durationMonths) =>
|
||||
DroughtStarted(
|
||||
responsibleFaction = responsibleFaction,
|
||||
responsibleFaction = responsibleFaction.value,
|
||||
durationMonths = durationMonths
|
||||
)
|
||||
case DeferredChange.DroughtEnded(responsibleFaction) =>
|
||||
DroughtEnded(responsibleFaction)
|
||||
DroughtEnded(responsibleFaction.value)
|
||||
case DeferredChange.PrisonerMoved(heroId, fromProvinceId, toProvinceId) =>
|
||||
PrisonerMoved(
|
||||
heroId = heroId,
|
||||
fromProvinceId = fromProvinceId,
|
||||
toProvinceId = toProvinceId
|
||||
heroId = heroId.value,
|
||||
fromProvinceId = fromProvinceId.value,
|
||||
toProvinceId = toProvinceId.value
|
||||
)
|
||||
case DeferredChange.PrisonerReturned(
|
||||
heroId,
|
||||
@@ -59,11 +59,11 @@ object DeferredChangeConverter {
|
||||
toFactionId
|
||||
) =>
|
||||
PrisonerReturned(
|
||||
heroId,
|
||||
fromProvinceId,
|
||||
fromFactionId,
|
||||
toProvinceId,
|
||||
toFactionId
|
||||
heroId.value,
|
||||
fromProvinceId.value,
|
||||
fromFactionId.value,
|
||||
toProvinceId.value,
|
||||
toFactionId.value
|
||||
)
|
||||
case DeferredChange.CapturedHeroExecuted(
|
||||
heroId,
|
||||
@@ -73,11 +73,11 @@ object DeferredChangeConverter {
|
||||
prisonerFactionId
|
||||
) =>
|
||||
CapturedHeroExecuted(
|
||||
heroId,
|
||||
provinceId,
|
||||
executingHeroId,
|
||||
executingFactionId,
|
||||
prisonerFactionId
|
||||
heroId.value,
|
||||
provinceId.value,
|
||||
executingHeroId.value,
|
||||
executingFactionId.value,
|
||||
prisonerFactionId.value
|
||||
)
|
||||
case DeferredChange.CapturedHeroExiled(
|
||||
heroId,
|
||||
@@ -87,11 +87,11 @@ object DeferredChangeConverter {
|
||||
prisonerFactionId
|
||||
) =>
|
||||
CapturedHeroExiled(
|
||||
heroId,
|
||||
provinceId,
|
||||
exilingHeroId,
|
||||
exilingFactionId,
|
||||
prisonerFactionId
|
||||
heroId.value,
|
||||
provinceId.value,
|
||||
exilingHeroId.value,
|
||||
exilingFactionId.value,
|
||||
prisonerFactionId.value
|
||||
)
|
||||
case DeferredChange.CapturedHeroImprisoned(
|
||||
heroId,
|
||||
@@ -101,11 +101,11 @@ object DeferredChangeConverter {
|
||||
prisonerFactionId
|
||||
) =>
|
||||
CapturedHeroImprisoned(
|
||||
heroId,
|
||||
provinceId,
|
||||
imprisoningHeroId,
|
||||
imprisoningFactionId,
|
||||
prisonerFactionId
|
||||
heroId.value,
|
||||
provinceId.value,
|
||||
imprisoningHeroId.value,
|
||||
imprisoningFactionId.value,
|
||||
prisonerFactionId.value
|
||||
)
|
||||
case DeferredChange.CapturedHeroReturned(
|
||||
heroId,
|
||||
@@ -116,137 +116,143 @@ object DeferredChangeConverter {
|
||||
toFactionId
|
||||
) =>
|
||||
CapturedHeroReturned(
|
||||
heroId,
|
||||
actingHeroId,
|
||||
fromProvinceId,
|
||||
fromFactionId,
|
||||
toProvinceId,
|
||||
toFactionId
|
||||
heroId.value,
|
||||
actingHeroId.value,
|
||||
fromProvinceId.value,
|
||||
fromFactionId.value,
|
||||
toProvinceId.value,
|
||||
toFactionId.value
|
||||
)
|
||||
}
|
||||
|
||||
def fromProto(deferredChangeProto: DeferredChangeProto): DeferredChangeT =
|
||||
deferredChangeProto match {
|
||||
case BlizzardStarted(
|
||||
responsibleFaction: FactionId,
|
||||
responsibleFaction: Int,
|
||||
durationMonths: Int,
|
||||
_ /* unknownFields */
|
||||
) =>
|
||||
DeferredChange.BlizzardStarted(
|
||||
responsibleFaction = responsibleFaction,
|
||||
responsibleFaction = FactionId(responsibleFaction),
|
||||
durationMonths = durationMonths
|
||||
)
|
||||
case BlizzardEnded(
|
||||
responsibleFaction: FactionId,
|
||||
responsibleFaction: Int,
|
||||
_ /* unknownFields */
|
||||
) =>
|
||||
DeferredChange.BlizzardEnded(responsibleFaction = responsibleFaction)
|
||||
DeferredChange.BlizzardEnded(responsibleFaction =
|
||||
FactionId(responsibleFaction)
|
||||
)
|
||||
case EpidemicStarted(
|
||||
responsibleFaction: FactionId,
|
||||
responsibleFaction: Int,
|
||||
_ /* unknownFields */
|
||||
) =>
|
||||
DeferredChange.EpidemicStarted(responsibleFaction = responsibleFaction)
|
||||
DeferredChange.EpidemicStarted(responsibleFaction =
|
||||
FactionId(responsibleFaction)
|
||||
)
|
||||
case DroughtStarted(
|
||||
responsibleFaction: FactionId,
|
||||
responsibleFaction: Int,
|
||||
durationMonths: Int,
|
||||
_ /* unknownFields */
|
||||
) =>
|
||||
DeferredChange.DroughtStarted(
|
||||
responsibleFaction = responsibleFaction,
|
||||
responsibleFaction = FactionId(responsibleFaction),
|
||||
durationMonths = durationMonths
|
||||
)
|
||||
case DroughtEnded(
|
||||
responsibleFaction: FactionId,
|
||||
responsibleFaction: Int,
|
||||
_ /* unknownFields */
|
||||
) =>
|
||||
DeferredChange.DroughtEnded(responsibleFaction = responsibleFaction)
|
||||
DeferredChange.DroughtEnded(responsibleFaction =
|
||||
FactionId(responsibleFaction)
|
||||
)
|
||||
case PrisonerMoved(
|
||||
heroId: HeroId,
|
||||
fromProvinceId: ProvinceId,
|
||||
toProvinceId: ProvinceId,
|
||||
heroId: Int,
|
||||
fromProvinceId: Int,
|
||||
toProvinceId: Int,
|
||||
_ /* unknownFields */
|
||||
) =>
|
||||
DeferredChange.PrisonerMoved(
|
||||
heroId = heroId,
|
||||
fromProvinceId = fromProvinceId,
|
||||
toProvinceId = toProvinceId
|
||||
heroId = HeroId(heroId),
|
||||
fromProvinceId = ProvinceId(fromProvinceId),
|
||||
toProvinceId = ProvinceId(toProvinceId)
|
||||
)
|
||||
case PrisonerReturned(
|
||||
heroId: HeroId,
|
||||
fromProvinceId: ProvinceId,
|
||||
fromFactionId: FactionId,
|
||||
toProvinceId: ProvinceId,
|
||||
toFactionId: FactionId,
|
||||
heroId: Int,
|
||||
fromProvinceId: Int,
|
||||
fromFactionId: Int,
|
||||
toProvinceId: Int,
|
||||
toFactionId: Int,
|
||||
_ /* unknownFields */
|
||||
) =>
|
||||
DeferredChange.PrisonerReturned(
|
||||
heroId = heroId,
|
||||
fromProvinceId = fromProvinceId,
|
||||
fromFactionId = fromFactionId,
|
||||
toProvinceId = toProvinceId,
|
||||
toFactionId = toFactionId
|
||||
heroId = HeroId(heroId),
|
||||
fromProvinceId = ProvinceId(fromProvinceId),
|
||||
fromFactionId = FactionId(fromFactionId),
|
||||
toProvinceId = ProvinceId(toProvinceId),
|
||||
toFactionId = FactionId(toFactionId)
|
||||
)
|
||||
case CapturedHeroExecuted(
|
||||
heroId: HeroId,
|
||||
provinceId: ProvinceId,
|
||||
executingHeroId: HeroId,
|
||||
executingFactionId: FactionId,
|
||||
prisonerFactionId: FactionId,
|
||||
heroId: Int,
|
||||
provinceId: Int,
|
||||
executingHeroId: Int,
|
||||
executingFactionId: Int,
|
||||
prisonerFactionId: Int,
|
||||
_ /* unknownFields */
|
||||
) =>
|
||||
DeferredChange.CapturedHeroExecuted(
|
||||
heroId = heroId,
|
||||
provinceId = provinceId,
|
||||
executingHeroId = executingHeroId,
|
||||
executingFactionId = executingFactionId,
|
||||
prisonerFactionId = prisonerFactionId
|
||||
heroId = HeroId(heroId),
|
||||
provinceId = ProvinceId(provinceId),
|
||||
executingHeroId = HeroId(executingHeroId),
|
||||
executingFactionId = FactionId(executingFactionId),
|
||||
prisonerFactionId = FactionId(prisonerFactionId)
|
||||
)
|
||||
case CapturedHeroExiled(
|
||||
heroId: HeroId,
|
||||
provinceId: ProvinceId,
|
||||
exilingHeroId: HeroId,
|
||||
exilingFactionId: FactionId,
|
||||
prisonerFactionId: FactionId,
|
||||
heroId: Int,
|
||||
provinceId: Int,
|
||||
exilingHeroId: Int,
|
||||
exilingFactionId: Int,
|
||||
prisonerFactionId: Int,
|
||||
_ /* unknownFields */
|
||||
) =>
|
||||
DeferredChange.CapturedHeroExiled(
|
||||
heroId = heroId,
|
||||
provinceId = provinceId,
|
||||
exilingHeroId = exilingHeroId,
|
||||
exilingFactionId = exilingFactionId,
|
||||
prisonerFactionId = prisonerFactionId
|
||||
heroId = HeroId(heroId),
|
||||
provinceId = ProvinceId(provinceId),
|
||||
exilingHeroId = HeroId(exilingHeroId),
|
||||
exilingFactionId = FactionId(exilingFactionId),
|
||||
prisonerFactionId = FactionId(prisonerFactionId)
|
||||
)
|
||||
case CapturedHeroImprisoned(
|
||||
heroId: HeroId,
|
||||
provinceId: ProvinceId,
|
||||
imprisoningHeroId: HeroId,
|
||||
imprisoningFactionId: FactionId,
|
||||
prisonerFactionId: FactionId,
|
||||
heroId: Int,
|
||||
provinceId: Int,
|
||||
imprisoningHeroId: Int,
|
||||
imprisoningFactionId: Int,
|
||||
prisonerFactionId: Int,
|
||||
_ /* unknownFields */
|
||||
) =>
|
||||
DeferredChange.CapturedHeroImprisoned(
|
||||
heroId = heroId,
|
||||
provinceId = provinceId,
|
||||
imprisoningHeroId = imprisoningHeroId,
|
||||
imprisoningFactionId = imprisoningFactionId,
|
||||
prisonerFactionId = prisonerFactionId
|
||||
heroId = HeroId(heroId),
|
||||
provinceId = ProvinceId(provinceId),
|
||||
imprisoningHeroId = HeroId(imprisoningHeroId),
|
||||
imprisoningFactionId = FactionId(imprisoningFactionId),
|
||||
prisonerFactionId = FactionId(prisonerFactionId)
|
||||
)
|
||||
case CapturedHeroReturned(
|
||||
heroId: HeroId,
|
||||
actingHeroId: HeroId,
|
||||
fromProvinceId: ProvinceId,
|
||||
fromFactionId: FactionId,
|
||||
toProvinceId: ProvinceId,
|
||||
toFactionId: FactionId,
|
||||
heroId: Int,
|
||||
actingHeroId: Int,
|
||||
fromProvinceId: Int,
|
||||
fromFactionId: Int,
|
||||
toProvinceId: Int,
|
||||
toFactionId: Int,
|
||||
_ /* unknownFields */
|
||||
) =>
|
||||
DeferredChange.CapturedHeroReturned(
|
||||
heroId = heroId,
|
||||
actingHeroId = actingHeroId,
|
||||
fromProvinceId = fromProvinceId,
|
||||
fromFactionId = fromFactionId,
|
||||
toProvinceId = toProvinceId,
|
||||
toFactionId = toFactionId
|
||||
heroId = HeroId(heroId),
|
||||
actingHeroId = HeroId(actingHeroId),
|
||||
fromProvinceId = ProvinceId(fromProvinceId),
|
||||
fromFactionId = FactionId(fromFactionId),
|
||||
toProvinceId = ProvinceId(toProvinceId),
|
||||
toFactionId = FactionId(toFactionId)
|
||||
)
|
||||
case Empty =>
|
||||
throw new ProtoConversionException("Empty DeferredChangeProto")
|
||||
|
||||
+9
-6
@@ -1,5 +1,6 @@
|
||||
package net.eagle0.eagle.model.proto_converters
|
||||
|
||||
import net.eagle0.eagle.{FactionId, HeroId, ProvinceId}
|
||||
import net.eagle0.eagle.internal.province.IncomingEndTurnAction.Action.Empty
|
||||
import net.eagle0.eagle.internal.province.IncomingEndTurnAction.IncomingRecon as IncomingReconProto
|
||||
import net.eagle0.eagle.internal.province.IncomingEndTurnAction as IncomingEndTurnActionProto
|
||||
@@ -14,11 +15,13 @@ object IncomingEndTurnActionConverter {
|
||||
incomingEndTurnAction: IncomingEndTurnAction
|
||||
): IncomingEndTurnActionProto =
|
||||
IncomingEndTurnActionProto(
|
||||
fromFactionId = incomingEndTurnAction.fromFactionId,
|
||||
fromProvinceId = incomingEndTurnAction.fromProvinceId,
|
||||
fromFactionId = incomingEndTurnAction.fromFactionId.value,
|
||||
fromProvinceId = incomingEndTurnAction.fromProvinceId.value,
|
||||
action = incomingEndTurnAction.details match {
|
||||
case IncomingRecon(heroId) =>
|
||||
IncomingEndTurnActionProto.Action.Recon(IncomingReconProto(heroId))
|
||||
IncomingEndTurnActionProto.Action.Recon(
|
||||
IncomingReconProto(heroId.value)
|
||||
)
|
||||
}
|
||||
)
|
||||
|
||||
@@ -26,13 +29,13 @@ object IncomingEndTurnActionConverter {
|
||||
incomingEndTurnActionProto: IncomingEndTurnActionProto
|
||||
): IncomingEndTurnAction =
|
||||
IncomingEndTurnAction(
|
||||
fromFactionId = incomingEndTurnActionProto.fromFactionId,
|
||||
fromProvinceId = incomingEndTurnActionProto.fromProvinceId,
|
||||
fromFactionId = FactionId(incomingEndTurnActionProto.fromFactionId),
|
||||
fromProvinceId = ProvinceId(incomingEndTurnActionProto.fromProvinceId),
|
||||
details = incomingEndTurnActionProto.action match {
|
||||
case IncomingEndTurnActionProto.Action.Recon(
|
||||
IncomingReconProto(heroId, _ /* unknown fields */ )
|
||||
) =>
|
||||
IncomingRecon(heroId)
|
||||
IncomingRecon(HeroId(heroId))
|
||||
case Empty =>
|
||||
throw new ProtoConversionException("Empty action is not allowed")
|
||||
}
|
||||
|
||||
+101
-101
@@ -60,9 +60,9 @@ object NotificationConverter {
|
||||
(
|
||||
NotificationProto(
|
||||
details = toProto(details),
|
||||
targetFactions = targetFactionIds.map(x => TargetFaction(x)),
|
||||
affectedProvinceIds = affectedProvinceIds,
|
||||
affectedHeroIds = affectedHeroIds,
|
||||
targetFactions = targetFactionIds.map(x => TargetFaction(x.value)),
|
||||
affectedProvinceIds = affectedProvinceIds.map(_.value),
|
||||
affectedHeroIds = affectedHeroIds.map(_.value),
|
||||
llm = llm match {
|
||||
case Llm.Empty => NotificationProto.Llm.Empty
|
||||
case Llm.Id(id) => NotificationProto.Llm.LlmId(id)
|
||||
@@ -89,9 +89,9 @@ object NotificationConverter {
|
||||
ambassadorHeroId
|
||||
) =>
|
||||
AllianceAcceptedDetails(
|
||||
offeringFactionId = offeringFactionId,
|
||||
targetFactionId = targetFactionId,
|
||||
ambassadorHeroId = ambassadorHeroId
|
||||
offeringFactionId = offeringFactionId.value,
|
||||
targetFactionId = targetFactionId.value,
|
||||
ambassadorHeroId = ambassadorHeroId.value
|
||||
)
|
||||
case NotificationDetails.AllianceAmbassadorImprisoned(
|
||||
offeringFactionId,
|
||||
@@ -99,9 +99,9 @@ object NotificationConverter {
|
||||
ambassadorHeroId
|
||||
) =>
|
||||
AllianceAmbassadorImprisonedDetails(
|
||||
offeringFactionId = offeringFactionId,
|
||||
targetFactionId = targetFactionId,
|
||||
ambassadorHeroId = ambassadorHeroId
|
||||
offeringFactionId = offeringFactionId.value,
|
||||
targetFactionId = targetFactionId.value,
|
||||
ambassadorHeroId = ambassadorHeroId.value
|
||||
)
|
||||
case NotificationDetails.AllianceRejected(
|
||||
offeringFactionId,
|
||||
@@ -109,9 +109,9 @@ object NotificationConverter {
|
||||
ambassadorHeroId
|
||||
) =>
|
||||
AllianceRejectedDetails(
|
||||
offeringFactionId = offeringFactionId,
|
||||
targetFactionId = targetFactionId,
|
||||
ambassadorHeroId = ambassadorHeroId
|
||||
offeringFactionId = offeringFactionId.value,
|
||||
targetFactionId = targetFactionId.value,
|
||||
ambassadorHeroId = ambassadorHeroId.value
|
||||
)
|
||||
case NotificationDetails.BreakAllianceAccepted(
|
||||
offeringFactionId,
|
||||
@@ -119,9 +119,9 @@ object NotificationConverter {
|
||||
ambassadorHeroId
|
||||
) =>
|
||||
BreakAllianceAcceptedDetails(
|
||||
offeringFactionId = offeringFactionId,
|
||||
targetFactionId = targetFactionId,
|
||||
ambassadorHeroId = ambassadorHeroId
|
||||
offeringFactionId = offeringFactionId.value,
|
||||
targetFactionId = targetFactionId.value,
|
||||
ambassadorHeroId = ambassadorHeroId.value
|
||||
)
|
||||
case NotificationDetails.BreakAllianceAmbassadorImprisoned(
|
||||
offeringFactionId,
|
||||
@@ -129,9 +129,9 @@ object NotificationConverter {
|
||||
ambassadorHeroId
|
||||
) =>
|
||||
BreakAllianceAmbassadorImprisonedDetails(
|
||||
offeringFactionId = offeringFactionId,
|
||||
targetFactionId = targetFactionId,
|
||||
ambassadorHeroId = ambassadorHeroId
|
||||
offeringFactionId = offeringFactionId.value,
|
||||
targetFactionId = targetFactionId.value,
|
||||
ambassadorHeroId = ambassadorHeroId.value
|
||||
)
|
||||
case NotificationDetails.CapturedHeroExecuted(
|
||||
capturedFromFactionId,
|
||||
@@ -141,7 +141,7 @@ object NotificationConverter {
|
||||
) =>
|
||||
CapturedHeroExecutedDetails(
|
||||
capturedFromFactionId = capturedFromFactionId,
|
||||
provinceId = provinceId,
|
||||
provinceId = provinceId.value,
|
||||
executedHeroId = executedHeroId,
|
||||
executingFactionId = executingFactionId
|
||||
)
|
||||
@@ -153,7 +153,7 @@ object NotificationConverter {
|
||||
) =>
|
||||
CapturedHeroExiledDetails(
|
||||
capturedFromFactionId = capturedFromFactionId,
|
||||
provinceId = provinceId,
|
||||
provinceId = provinceId.value,
|
||||
exiledHeroId = exiledHeroId,
|
||||
exilingFactionId = exilingFactionId
|
||||
)
|
||||
@@ -165,7 +165,7 @@ object NotificationConverter {
|
||||
) =>
|
||||
CapturedHeroImprisonedDetails(
|
||||
capturedFromFactionId = capturedFromFactionId,
|
||||
provinceId = provinceId,
|
||||
provinceId = provinceId.value,
|
||||
imprisonedHeroId = imprisonedHeroId,
|
||||
imprisoningFactionId = imprisoningFactionId
|
||||
)
|
||||
@@ -177,7 +177,7 @@ object NotificationConverter {
|
||||
) =>
|
||||
CapturedHeroReturnedDetails(
|
||||
capturedFromFactionId = capturedFromFactionId,
|
||||
provinceId = provinceId,
|
||||
provinceId = provinceId.value,
|
||||
returnedHeroId = returnedHeroId,
|
||||
returningFactionId = returningFactionId
|
||||
)
|
||||
@@ -197,7 +197,7 @@ object NotificationConverter {
|
||||
invitedFactionId
|
||||
) =>
|
||||
InvitationAcceptedDetails(
|
||||
offeringFactionId = offeringFactionId,
|
||||
offeringFactionId = offeringFactionId.value,
|
||||
invitedFactionId = invitedFactionId
|
||||
)
|
||||
case NotificationDetails.InvitationAmbassadorImprisoned(
|
||||
@@ -206,16 +206,16 @@ object NotificationConverter {
|
||||
ambassadorHeroId
|
||||
) =>
|
||||
InvitationAmbassadorImprisonedDetails(
|
||||
offeringFactionId = offeringFactionId,
|
||||
offeringFactionId = offeringFactionId.value,
|
||||
invitedFactionId = invitedFactionId,
|
||||
ambassadorHeroId = ambassadorHeroId
|
||||
ambassadorHeroId = ambassadorHeroId.value
|
||||
)
|
||||
case NotificationDetails.InvitationRejected(
|
||||
offeringFactionId,
|
||||
invitedFactionId
|
||||
) =>
|
||||
InvitationRejectedDetails(
|
||||
offeringFactionId = offeringFactionId,
|
||||
offeringFactionId = offeringFactionId.value,
|
||||
invitedFactionId = invitedFactionId
|
||||
)
|
||||
case NotificationDetails.OutlawApprehended(
|
||||
@@ -224,8 +224,8 @@ object NotificationConverter {
|
||||
apprehendedHeroId
|
||||
) =>
|
||||
OutlawApprehendedDetails(
|
||||
factionId = factionId,
|
||||
provinceId = provinceId,
|
||||
factionId = factionId.value,
|
||||
provinceId = provinceId.value,
|
||||
apprehendedHeroId = apprehendedHeroId
|
||||
)
|
||||
case NotificationDetails.OutlawSpotted(outlawHeroId, provinceId) =>
|
||||
@@ -235,8 +235,8 @@ object NotificationConverter {
|
||||
)
|
||||
case NotificationDetails.QuestFailed(heroId, provinceId, failedQuest) =>
|
||||
QuestFailedDetails(
|
||||
heroId = heroId,
|
||||
provinceId = provinceId,
|
||||
heroId = heroId.value,
|
||||
provinceId = provinceId.value,
|
||||
failedQuest = Some(QuestConverter.toProto(failedQuest))
|
||||
)
|
||||
case NotificationDetails.QuestFulfilled(
|
||||
@@ -245,14 +245,14 @@ object NotificationConverter {
|
||||
fulfilledQuest
|
||||
) =>
|
||||
QuestFulfilledDetails(
|
||||
heroId = heroId,
|
||||
provinceId = provinceId,
|
||||
heroId = heroId.value,
|
||||
provinceId = provinceId.value,
|
||||
fulfilledQuest = Some(QuestConverter.toProto(fulfilledQuest))
|
||||
)
|
||||
case NotificationDetails.ShatteredArmy(factionId, provinceId, reason) =>
|
||||
ShatteredArmyDetails(
|
||||
factionId = factionId,
|
||||
provinceId = provinceId,
|
||||
factionId = factionId.value,
|
||||
provinceId = provinceId.value,
|
||||
reason = reason match {
|
||||
case NotificationDetails.ShatteredArmy.Reason.Blizzard =>
|
||||
ShatteredArmyDetails.Reason.SHATTERED_ARMY_REASON_BLIZZARD
|
||||
@@ -262,7 +262,7 @@ object NotificationConverter {
|
||||
)
|
||||
case NotificationDetails.SwearBrotherhood(factionId, newBrotherHeroId) =>
|
||||
SwearBrotherhoodDetails(
|
||||
factionId = factionId,
|
||||
factionId = factionId.value,
|
||||
newBrotherHeroId = newBrotherHeroId
|
||||
)
|
||||
case NotificationDetails.SuppressedBeasts(
|
||||
@@ -274,8 +274,8 @@ object NotificationConverter {
|
||||
goldGained
|
||||
) =>
|
||||
SuppressedBeastsDetails(
|
||||
heroId = heroId,
|
||||
provinceId = provinceId,
|
||||
heroId = heroId.value,
|
||||
provinceId = provinceId.value,
|
||||
beastTypeNameSingular = beastTypeNameSingular,
|
||||
beastTypeNamePlural = beastTypeNamePlural,
|
||||
foodGained = foodGained,
|
||||
@@ -288,8 +288,8 @@ object NotificationConverter {
|
||||
beastTypeNamePlural
|
||||
) =>
|
||||
SuppressBeastsFailedDetails(
|
||||
heroId = heroId,
|
||||
provinceId = provinceId,
|
||||
heroId = heroId.value,
|
||||
provinceId = provinceId.value,
|
||||
beastTypeNameSingular = beastTypeNameSingular,
|
||||
beastTypeNamePlural = beastTypeNamePlural
|
||||
)
|
||||
@@ -317,7 +317,7 @@ object NotificationConverter {
|
||||
) =>
|
||||
PrisonerExecutedDetails(
|
||||
lastFactionId = lastFactionId,
|
||||
provinceId = provinceId,
|
||||
provinceId = provinceId.value,
|
||||
executedHeroId = executedHeroId,
|
||||
executingFactionId = executingFactionId
|
||||
)
|
||||
@@ -328,7 +328,7 @@ object NotificationConverter {
|
||||
defendingFactionId
|
||||
) =>
|
||||
ProvinceConqueredDetails(
|
||||
provinceId = provinceId,
|
||||
provinceId = provinceId.value,
|
||||
conqueringFactionId = conqueringFactionId,
|
||||
otherAttackingFactionIds = otherAttackingFactionIds,
|
||||
defendingFactionId = defendingFactionId
|
||||
@@ -338,7 +338,7 @@ object NotificationConverter {
|
||||
expandingFactionId
|
||||
) =>
|
||||
ProvinceExpansionDetails(
|
||||
provinceId = provinceId,
|
||||
provinceId = provinceId.value,
|
||||
expandingFactionId = expandingFactionId
|
||||
)
|
||||
case NotificationDetails.ProvinceHeld(
|
||||
@@ -347,7 +347,7 @@ object NotificationConverter {
|
||||
defendingFactionId
|
||||
) =>
|
||||
ProvinceHeldDetails(
|
||||
provinceId = provinceId,
|
||||
provinceId = provinceId.value,
|
||||
attackingFactionIds = attackingFactionIds,
|
||||
defendingFactionId = defendingFactionId
|
||||
)
|
||||
@@ -377,9 +377,9 @@ object NotificationConverter {
|
||||
ambassadorHeroId
|
||||
) =>
|
||||
TruceAcceptedDetails(
|
||||
offeringFactionId = offeringFactionId,
|
||||
targetFactionId = targetFactionId,
|
||||
ambassadorHeroId = ambassadorHeroId
|
||||
offeringFactionId = offeringFactionId.value,
|
||||
targetFactionId = targetFactionId.value,
|
||||
ambassadorHeroId = ambassadorHeroId.value
|
||||
)
|
||||
case NotificationDetails.TruceRejected(
|
||||
offeringFactionId,
|
||||
@@ -387,9 +387,9 @@ object NotificationConverter {
|
||||
ambassadorHeroId
|
||||
) =>
|
||||
TruceRejectedDetails(
|
||||
offeringFactionId = offeringFactionId,
|
||||
targetFactionId = targetFactionId,
|
||||
ambassadorHeroId = ambassadorHeroId
|
||||
offeringFactionId = offeringFactionId.value,
|
||||
targetFactionId = targetFactionId.value,
|
||||
ambassadorHeroId = ambassadorHeroId.value
|
||||
)
|
||||
case NotificationDetails.TruceAmbassadorImprisoned(
|
||||
offeringFactionId,
|
||||
@@ -397,9 +397,9 @@ object NotificationConverter {
|
||||
ambassadorHeroId
|
||||
) =>
|
||||
TruceAmbassadorImprisonedDetails(
|
||||
offeringFactionId = offeringFactionId,
|
||||
targetFactionId = targetFactionId,
|
||||
ambassadorHeroId = ambassadorHeroId
|
||||
offeringFactionId = offeringFactionId.value,
|
||||
targetFactionId = targetFactionId.value,
|
||||
ambassadorHeroId = ambassadorHeroId.value
|
||||
)
|
||||
case NotificationDetails.VassalExiled(
|
||||
exilingFactionId,
|
||||
@@ -463,9 +463,9 @@ object NotificationConverter {
|
||||
_ /* unknownFields */
|
||||
) =>
|
||||
NotificationDetails.AllianceAccepted(
|
||||
offeringFactionId = offeringFactionId,
|
||||
targetFactionId = targetFactionId,
|
||||
ambassadorHeroId = ambassadorHeroId
|
||||
offeringFactionId = offeringFactionId.value,
|
||||
targetFactionId = targetFactionId.value,
|
||||
ambassadorHeroId = ambassadorHeroId.value
|
||||
)
|
||||
|
||||
case AllianceAmbassadorImprisonedDetails(
|
||||
@@ -475,9 +475,9 @@ object NotificationConverter {
|
||||
_ /* unknownFields */
|
||||
) =>
|
||||
NotificationDetails.AllianceAmbassadorImprisoned(
|
||||
offeringFactionId = offeringFactionId,
|
||||
targetFactionId = targetFactionId,
|
||||
ambassadorHeroId = ambassadorHeroId
|
||||
offeringFactionId = offeringFactionId.value,
|
||||
targetFactionId = targetFactionId.value,
|
||||
ambassadorHeroId = ambassadorHeroId.value
|
||||
)
|
||||
|
||||
case AllianceRejectedDetails(
|
||||
@@ -487,9 +487,9 @@ object NotificationConverter {
|
||||
_ /* unknownFields */
|
||||
) =>
|
||||
NotificationDetails.AllianceRejected(
|
||||
offeringFactionId = offeringFactionId,
|
||||
targetFactionId = targetFactionId,
|
||||
ambassadorHeroId = ambassadorHeroId
|
||||
offeringFactionId = offeringFactionId.value,
|
||||
targetFactionId = targetFactionId.value,
|
||||
ambassadorHeroId = ambassadorHeroId.value
|
||||
)
|
||||
|
||||
case BreakAllianceAcceptedDetails(
|
||||
@@ -499,9 +499,9 @@ object NotificationConverter {
|
||||
_ /* unknownFields */
|
||||
) =>
|
||||
NotificationDetails.BreakAllianceAccepted(
|
||||
offeringFactionId = offeringFactionId,
|
||||
targetFactionId = targetFactionId,
|
||||
ambassadorHeroId = ambassadorHeroId
|
||||
offeringFactionId = offeringFactionId.value,
|
||||
targetFactionId = targetFactionId.value,
|
||||
ambassadorHeroId = ambassadorHeroId.value
|
||||
)
|
||||
|
||||
case BreakAllianceAmbassadorImprisonedDetails(
|
||||
@@ -511,9 +511,9 @@ object NotificationConverter {
|
||||
_ /* unknownFields */
|
||||
) =>
|
||||
NotificationDetails.BreakAllianceAmbassadorImprisoned(
|
||||
offeringFactionId = offeringFactionId,
|
||||
targetFactionId = targetFactionId,
|
||||
ambassadorHeroId = ambassadorHeroId
|
||||
offeringFactionId = offeringFactionId.value,
|
||||
targetFactionId = targetFactionId.value,
|
||||
ambassadorHeroId = ambassadorHeroId.value
|
||||
)
|
||||
|
||||
case CapturedHeroExecutedDetails(
|
||||
@@ -525,7 +525,7 @@ object NotificationConverter {
|
||||
) =>
|
||||
NotificationDetails.CapturedHeroExecuted(
|
||||
capturedFromFactionId = capturedFromFactionId,
|
||||
provinceId = provinceId,
|
||||
provinceId = provinceId.value,
|
||||
executedHeroId = executedHeroId,
|
||||
executingFactionId = executingFactionId
|
||||
)
|
||||
@@ -539,7 +539,7 @@ object NotificationConverter {
|
||||
) =>
|
||||
NotificationDetails.CapturedHeroExiled(
|
||||
capturedFromFactionId = capturedFromFactionId,
|
||||
provinceId = provinceId,
|
||||
provinceId = provinceId.value,
|
||||
exiledHeroId = exiledHeroId,
|
||||
exilingFactionId = exilingFactionId
|
||||
)
|
||||
@@ -553,7 +553,7 @@ object NotificationConverter {
|
||||
) =>
|
||||
NotificationDetails.CapturedHeroImprisoned(
|
||||
capturedFromFactionId = capturedFromFactionId,
|
||||
provinceId = provinceId,
|
||||
provinceId = provinceId.value,
|
||||
imprisonedHeroId = imprisonedHeroId,
|
||||
imprisoningFactionId = imprisoningFactionId
|
||||
)
|
||||
@@ -567,7 +567,7 @@ object NotificationConverter {
|
||||
) =>
|
||||
NotificationDetails.CapturedHeroReturned(
|
||||
capturedFromFactionId = capturedFromFactionId,
|
||||
provinceId = provinceId,
|
||||
provinceId = provinceId.value,
|
||||
returnedHeroId = returnedHeroId,
|
||||
returningFactionId = returningFactionId
|
||||
)
|
||||
@@ -592,7 +592,7 @@ object NotificationConverter {
|
||||
_ /* unknownFields */
|
||||
) =>
|
||||
NotificationDetails.InvitationAccepted(
|
||||
offeringFactionId = offeringFactionId,
|
||||
offeringFactionId = offeringFactionId.value,
|
||||
invitedFactionId = invitedFactionId
|
||||
)
|
||||
|
||||
@@ -603,9 +603,9 @@ object NotificationConverter {
|
||||
_ /* unknownFields */
|
||||
) =>
|
||||
NotificationDetails.InvitationAmbassadorImprisoned(
|
||||
offeringFactionId = offeringFactionId,
|
||||
offeringFactionId = offeringFactionId.value,
|
||||
invitedFactionId = invitedFactionId,
|
||||
ambassadorHeroId = ambassadorHeroId
|
||||
ambassadorHeroId = ambassadorHeroId.value
|
||||
)
|
||||
|
||||
case InvitationRejectedDetails(
|
||||
@@ -614,7 +614,7 @@ object NotificationConverter {
|
||||
_ /* unknownFields */
|
||||
) =>
|
||||
NotificationDetails.InvitationRejected(
|
||||
offeringFactionId = offeringFactionId,
|
||||
offeringFactionId = offeringFactionId.value,
|
||||
invitedFactionId = invitedFactionId
|
||||
)
|
||||
|
||||
@@ -625,8 +625,8 @@ object NotificationConverter {
|
||||
_ /* unknownFields */
|
||||
) =>
|
||||
NotificationDetails.OutlawApprehended(
|
||||
factionId = factionId,
|
||||
provinceId = provinceId,
|
||||
factionId = factionId.value,
|
||||
provinceId = provinceId.value,
|
||||
apprehendedHeroId = apprehendedHeroId
|
||||
)
|
||||
|
||||
@@ -666,7 +666,7 @@ object NotificationConverter {
|
||||
) =>
|
||||
NotificationDetails.PrisonerExecuted(
|
||||
lastFactionId = lastFactionId,
|
||||
provinceId = provinceId,
|
||||
provinceId = provinceId.value,
|
||||
executedHeroId = executedHeroId,
|
||||
executingFactionId = executingFactionId
|
||||
)
|
||||
@@ -679,7 +679,7 @@ object NotificationConverter {
|
||||
_ /* unknownFields */
|
||||
) =>
|
||||
NotificationDetails.ProvinceConquered(
|
||||
provinceId = provinceId,
|
||||
provinceId = provinceId.value,
|
||||
conqueringFactionId = conqueringFactionId,
|
||||
otherAttackingFactionIds = otherAttackingFactionIds.toVector,
|
||||
defendingFactionId = defendingFactionId
|
||||
@@ -691,7 +691,7 @@ object NotificationConverter {
|
||||
_ /* unknownFields */
|
||||
) =>
|
||||
NotificationDetails.ProvinceExpansion(
|
||||
provinceId = provinceId,
|
||||
provinceId = provinceId.value,
|
||||
expandingFactionId = expandingFactionId
|
||||
)
|
||||
|
||||
@@ -702,7 +702,7 @@ object NotificationConverter {
|
||||
_ /* unknownFields */
|
||||
) =>
|
||||
NotificationDetails.ProvinceHeld(
|
||||
provinceId = provinceId,
|
||||
provinceId = provinceId.value,
|
||||
attackingFactionIds = attackingFactionIds.toVector,
|
||||
defendingFactionId = defendingFactionId
|
||||
)
|
||||
@@ -714,8 +714,8 @@ object NotificationConverter {
|
||||
_ /* unknownFields */
|
||||
) =>
|
||||
NotificationDetails.QuestFailed(
|
||||
heroId = heroId,
|
||||
provinceId = provinceId,
|
||||
heroId = heroId.value,
|
||||
provinceId = provinceId.value,
|
||||
failedQuest = failedQuest match {
|
||||
case Some(value) => QuestConverter.fromProto(value)
|
||||
case None =>
|
||||
@@ -730,8 +730,8 @@ object NotificationConverter {
|
||||
_ /* unknownFields */
|
||||
) =>
|
||||
NotificationDetails.QuestFulfilled(
|
||||
heroId = heroId,
|
||||
provinceId = provinceId,
|
||||
heroId = heroId.value,
|
||||
provinceId = provinceId.value,
|
||||
fulfilledQuest = fulfilledQuest match {
|
||||
case Some(value) => QuestConverter.fromProto(value)
|
||||
case None =>
|
||||
@@ -770,8 +770,8 @@ object NotificationConverter {
|
||||
_ /* unknownFields */
|
||||
) =>
|
||||
NotificationDetails.ShatteredArmy(
|
||||
factionId = factionId,
|
||||
provinceId = provinceId,
|
||||
factionId = factionId.value,
|
||||
provinceId = provinceId.value,
|
||||
reason = reason match {
|
||||
case ShatteredArmyDetails.Reason.SHATTERED_ARMY_REASON_BLIZZARD =>
|
||||
NotificationDetails.ShatteredArmy.Reason.Blizzard
|
||||
@@ -798,8 +798,8 @@ object NotificationConverter {
|
||||
_ /* unknownFields */
|
||||
) =>
|
||||
NotificationDetails.SuppressedBeasts(
|
||||
heroId = heroId,
|
||||
provinceId = provinceId,
|
||||
heroId = heroId.value,
|
||||
provinceId = provinceId.value,
|
||||
beastTypeNameSingular = beastTypeNameSingular,
|
||||
beastTypeNamePlural = beastTypeNamePlural,
|
||||
foodGained = foodGained,
|
||||
@@ -814,8 +814,8 @@ object NotificationConverter {
|
||||
_ /* unknownFields */
|
||||
) =>
|
||||
NotificationDetails.SuppressBeastsFailed(
|
||||
heroId = heroId,
|
||||
provinceId = provinceId,
|
||||
heroId = heroId.value,
|
||||
provinceId = provinceId.value,
|
||||
beastTypeNameSingular = beastTypeNameSingular,
|
||||
beastTypeNamePlural = beastTypeNamePlural
|
||||
)
|
||||
@@ -826,7 +826,7 @@ object NotificationConverter {
|
||||
_ /* unknownFields */
|
||||
) =>
|
||||
NotificationDetails.SwearBrotherhood(
|
||||
factionId = factionId,
|
||||
factionId = factionId.value,
|
||||
newBrotherHeroId = newBrotherHeroId
|
||||
)
|
||||
|
||||
@@ -837,9 +837,9 @@ object NotificationConverter {
|
||||
_ /* unknownFields */
|
||||
) =>
|
||||
NotificationDetails.TruceAccepted(
|
||||
offeringFactionId = offeringFactionId,
|
||||
targetFactionId = targetFactionId,
|
||||
ambassadorHeroId = ambassadorHeroId
|
||||
offeringFactionId = offeringFactionId.value,
|
||||
targetFactionId = targetFactionId.value,
|
||||
ambassadorHeroId = ambassadorHeroId.value
|
||||
)
|
||||
|
||||
case TruceAmbassadorImprisonedDetails(
|
||||
@@ -849,9 +849,9 @@ object NotificationConverter {
|
||||
_ /* unknownFields */
|
||||
) =>
|
||||
NotificationDetails.TruceAmbassadorImprisoned(
|
||||
offeringFactionId = offeringFactionId,
|
||||
targetFactionId = targetFactionId,
|
||||
ambassadorHeroId = ambassadorHeroId
|
||||
offeringFactionId = offeringFactionId.value,
|
||||
targetFactionId = targetFactionId.value,
|
||||
ambassadorHeroId = ambassadorHeroId.value
|
||||
)
|
||||
|
||||
case TruceRejectedDetails(
|
||||
@@ -861,9 +861,9 @@ object NotificationConverter {
|
||||
_ /* unknownFields */
|
||||
) =>
|
||||
NotificationDetails.TruceRejected(
|
||||
offeringFactionId = offeringFactionId,
|
||||
targetFactionId = targetFactionId,
|
||||
ambassadorHeroId = ambassadorHeroId
|
||||
offeringFactionId = offeringFactionId.value,
|
||||
targetFactionId = targetFactionId.value,
|
||||
ambassadorHeroId = ambassadorHeroId.value
|
||||
)
|
||||
|
||||
case VassalExiledDetails(
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package net.eagle0.eagle.model.proto_converters
|
||||
|
||||
import net.eagle0.eagle.{FactionId, HeroId, ProvinceId}
|
||||
import net.eagle0.eagle.common.battalion_type.BattalionTypeId as BattalionTypeIdProto
|
||||
import net.eagle0.eagle.common.unaffiliated_hero_quest.{
|
||||
AllianceQuest as AllianceQuestProto,
|
||||
@@ -69,35 +70,37 @@ object QuestConverter {
|
||||
case q: AlmsToProvinceQuest =>
|
||||
QuestProto(
|
||||
details = AlmsToProvinceQuestProto(
|
||||
provinceId = q.provinceId,
|
||||
provinceId = q.provinceId.value,
|
||||
totalFood = q.totalFood
|
||||
),
|
||||
componentCount = q.componentCount,
|
||||
componentsFulfilled = q.componentsFulfilled
|
||||
)
|
||||
case q: DefeatFactionQuest =>
|
||||
QuestProto(details = DefeatFactionQuestProto(q.targetFactionId))
|
||||
QuestProto(details = DefeatFactionQuestProto(q.targetFactionId.value))
|
||||
case q: DismissSpecificVassalQuest =>
|
||||
QuestProto(details = DismissSpecificVassalQuestProto(q.targetHeroId))
|
||||
QuestProto(details =
|
||||
DismissSpecificVassalQuestProto(q.targetHeroId.value)
|
||||
)
|
||||
case q: ExecutePrisonerQuest =>
|
||||
QuestProto(
|
||||
details = ExecutePrisonerQuestProto(
|
||||
prisonerHeroId = q.prisonerHeroId,
|
||||
provinceId = q.prisonerProvinceId
|
||||
prisonerHeroId = q.prisonerHeroId.value,
|
||||
provinceId = q.prisonerProvinceId.value
|
||||
)
|
||||
)
|
||||
case q: ExilePrisonerQuest =>
|
||||
QuestProto(
|
||||
details = ExilePrisonerQuestProto(
|
||||
prisonerHeroId = q.prisonerHeroId,
|
||||
provinceId = q.prisonerProvinceId
|
||||
prisonerHeroId = q.prisonerHeroId.value,
|
||||
provinceId = q.prisonerProvinceId.value
|
||||
)
|
||||
)
|
||||
case q: ReleasePrisonerQuest =>
|
||||
QuestProto(
|
||||
details = ReleasePrisonerQuestProto(
|
||||
prisonerHeroId = q.prisonerHeroId,
|
||||
provinceId = q.prisonerProvinceId
|
||||
prisonerHeroId = q.prisonerHeroId.value,
|
||||
provinceId = q.prisonerProvinceId.value
|
||||
)
|
||||
)
|
||||
case q: GiveToHeroesAcrossRealmQuest =>
|
||||
@@ -109,7 +112,7 @@ object QuestConverter {
|
||||
case q: GiveToHeroesInProvinceQuest =>
|
||||
QuestProto(
|
||||
details = GiveToHeroesInProvinceQuestProto(
|
||||
provinceId = q.provinceId,
|
||||
provinceId = q.provinceId.value,
|
||||
totalGold = q.totalGold
|
||||
),
|
||||
componentCount = q.componentCount,
|
||||
@@ -120,42 +123,44 @@ object QuestConverter {
|
||||
case q: ImproveAgricultureQuest =>
|
||||
QuestProto(
|
||||
details = ImproveAgricultureQuestProto(
|
||||
provinceId = q.provinceId,
|
||||
provinceId = q.provinceId.value,
|
||||
desiredValue = q.desiredValue
|
||||
)
|
||||
)
|
||||
case q: ImproveEconomyQuest =>
|
||||
QuestProto(
|
||||
details = ImproveEconomyQuestProto(
|
||||
provinceId = q.provinceId,
|
||||
provinceId = q.provinceId.value,
|
||||
desiredValue = q.desiredValue
|
||||
)
|
||||
)
|
||||
case q: ImproveInfrastructureQuest =>
|
||||
QuestProto(
|
||||
details = ImproveInfrastructureQuestProto(
|
||||
provinceId = q.provinceId,
|
||||
provinceId = q.provinceId.value,
|
||||
desiredValue = q.desiredValue
|
||||
)
|
||||
)
|
||||
case q: ReturnPrisonerQuest =>
|
||||
QuestProto(
|
||||
details = ReturnPrisonerQuestProto(
|
||||
prisonerHeroId = q.prisonerHeroId,
|
||||
provinceId = q.prisonerProvinceId,
|
||||
toFactionId = q.toFactionId
|
||||
prisonerHeroId = q.prisonerHeroId.value,
|
||||
provinceId = q.prisonerProvinceId.value,
|
||||
toFactionId = q.toFactionId.value
|
||||
)
|
||||
)
|
||||
case q: SpecificExpansionQuest =>
|
||||
QuestProto(details = SpecificExpansionQuestProto(q.provinceId))
|
||||
QuestProto(details = SpecificExpansionQuestProto(q.provinceId.value))
|
||||
case q: TruceCountQuest =>
|
||||
QuestProto(details = TruceCountQuestProto(q.truceCount))
|
||||
case q: TruceWithFactionQuest =>
|
||||
QuestProto(details = TruceWithFactionQuestProto(q.targetFactionId))
|
||||
QuestProto(details =
|
||||
TruceWithFactionQuestProto(q.targetFactionId.value)
|
||||
)
|
||||
case q: UpgradeBattalionQuest =>
|
||||
QuestProto(
|
||||
details = UpgradeBattalionQuestProto(
|
||||
provinceId = q.provinceId,
|
||||
provinceId = q.provinceId.value,
|
||||
battalionTypeId =
|
||||
BattalionTypeIdProto.fromValue(q.battalionTypeId.value),
|
||||
minimumArmament = q.minimumArmament,
|
||||
@@ -187,34 +192,34 @@ object QuestConverter {
|
||||
AlmsToProvinceQuest(
|
||||
componentCount = questProto.componentCount,
|
||||
componentsFulfilled = questProto.componentsFulfilled,
|
||||
provinceId = provinceId,
|
||||
provinceId = ProvinceId(provinceId),
|
||||
totalFood = totalFood
|
||||
)
|
||||
case DefeatFactionQuestProto(targetFactionId, _ /* unknownFieldSet */ ) =>
|
||||
DefeatFactionQuest(targetFactionId)
|
||||
DefeatFactionQuest(FactionId(targetFactionId))
|
||||
case DismissSpecificVassalQuestProto(
|
||||
targetHeroId,
|
||||
_ /* unknownFieldSet */
|
||||
) =>
|
||||
DismissSpecificVassalQuest(targetHeroId)
|
||||
DismissSpecificVassalQuest(HeroId(targetHeroId))
|
||||
case ExecutePrisonerQuestProto(
|
||||
prisonerHeroId,
|
||||
provinceId,
|
||||
_ /* unknownFieldSet */
|
||||
) =>
|
||||
ExecutePrisonerQuest(prisonerHeroId, provinceId)
|
||||
ExecutePrisonerQuest(HeroId(prisonerHeroId), ProvinceId(provinceId))
|
||||
case ExilePrisonerQuestProto(
|
||||
prisonerHeroId,
|
||||
provinceId,
|
||||
_ /* unknownFieldSet */
|
||||
) =>
|
||||
ExilePrisonerQuest(prisonerHeroId, provinceId)
|
||||
ExilePrisonerQuest(HeroId(prisonerHeroId), ProvinceId(provinceId))
|
||||
case ReleasePrisonerQuestProto(
|
||||
prisonerHeroId,
|
||||
provinceId,
|
||||
_ /* unknownFieldSet */
|
||||
) =>
|
||||
ReleasePrisonerQuest(prisonerHeroId, provinceId)
|
||||
ReleasePrisonerQuest(HeroId(prisonerHeroId), ProvinceId(provinceId))
|
||||
case GiveToHeroesAcrossRealmQuestProto(
|
||||
totalGold,
|
||||
_ /* unknownFieldSet */
|
||||
@@ -232,7 +237,7 @@ object QuestConverter {
|
||||
GiveToHeroesInProvinceQuest(
|
||||
componentCount = questProto.componentCount,
|
||||
componentsFulfilled = questProto.componentsFulfilled,
|
||||
provinceId = provinceId,
|
||||
provinceId = ProvinceId(provinceId),
|
||||
totalGold = totalGold
|
||||
)
|
||||
case GrandArmyQuestProto(totalTroopCount, _ /* unknownFieldSet */ ) =>
|
||||
@@ -242,35 +247,39 @@ object QuestConverter {
|
||||
desiredValue,
|
||||
_ /* unknownFieldSet */
|
||||
) =>
|
||||
ImproveAgricultureQuest(provinceId, desiredValue)
|
||||
ImproveAgricultureQuest(ProvinceId(provinceId), desiredValue)
|
||||
case ImproveEconomyQuestProto(
|
||||
provinceId,
|
||||
desiredValue,
|
||||
_ /* unknownFieldSet */
|
||||
) =>
|
||||
ImproveEconomyQuest(provinceId, desiredValue)
|
||||
ImproveEconomyQuest(ProvinceId(provinceId), desiredValue)
|
||||
case ImproveInfrastructureQuestProto(
|
||||
provinceId,
|
||||
desiredValue,
|
||||
_ /* unknownFieldSet */
|
||||
) =>
|
||||
ImproveInfrastructureQuest(provinceId, desiredValue)
|
||||
ImproveInfrastructureQuest(ProvinceId(provinceId), desiredValue)
|
||||
case ReturnPrisonerQuestProto(
|
||||
prisonerHeroId,
|
||||
provinceId,
|
||||
toFactionId,
|
||||
_ /* unknownFieldSet */
|
||||
) =>
|
||||
ReturnPrisonerQuest(prisonerHeroId, provinceId, toFactionId)
|
||||
ReturnPrisonerQuest(
|
||||
HeroId(prisonerHeroId),
|
||||
ProvinceId(provinceId),
|
||||
FactionId(toFactionId)
|
||||
)
|
||||
case SpecificExpansionQuestProto(provinceId, _ /* unknownFieldSet */ ) =>
|
||||
SpecificExpansionQuest(provinceId)
|
||||
SpecificExpansionQuest(ProvinceId(provinceId))
|
||||
case TruceCountQuestProto(truceCount, _ /* unknownFieldSet */ ) =>
|
||||
TruceCountQuest(truceCount)
|
||||
case TruceWithFactionQuestProto(
|
||||
targetFactionId,
|
||||
_ /* unknownFieldSet */
|
||||
) =>
|
||||
TruceWithFactionQuest(targetFactionId)
|
||||
TruceWithFactionQuest(FactionId(targetFactionId))
|
||||
case UpgradeBattalionQuestProto(
|
||||
provinceId,
|
||||
battalionTypeId,
|
||||
@@ -279,7 +288,7 @@ object QuestConverter {
|
||||
_ /* unknownFieldSet */
|
||||
) =>
|
||||
UpgradeBattalionQuest(
|
||||
provinceId,
|
||||
ProvinceId(provinceId),
|
||||
BattalionTypeId.fromInt(battalionTypeId.value),
|
||||
minimumArmament,
|
||||
minimumTraining
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package net.eagle0.eagle.model.proto_converters
|
||||
|
||||
import net.eagle0.eagle.{FactionId, MovingSuppliesId, ProvinceId, RoundId}
|
||||
import net.eagle0.eagle.internal.supplies.{
|
||||
Supplies as SuppliesProto,
|
||||
MovingSupplies as MovingSuppliesProto
|
||||
@@ -23,23 +24,25 @@ object SuppliesConverter {
|
||||
|
||||
def toProto(movingSupplies: MovingSupplies): MovingSuppliesProto =
|
||||
MovingSuppliesProto(
|
||||
id = movingSupplies.id,
|
||||
id = movingSupplies.id.value,
|
||||
supplies = toProto(movingSupplies.supplies),
|
||||
arrivalRound = movingSupplies.arrivalRound,
|
||||
destinationProvinceId = movingSupplies.destinationProvinceId,
|
||||
originProvinceId = movingSupplies.originProvinceId,
|
||||
factionId = movingSupplies.factionId,
|
||||
arrivalRound = movingSupplies.arrivalRound.value,
|
||||
destinationProvinceId = movingSupplies.destinationProvinceId.value,
|
||||
originProvinceId = movingSupplies.originProvinceId.map(_.value),
|
||||
factionId = movingSupplies.factionId.value,
|
||||
suppliesLoss = movingSupplies.suppliesLoss
|
||||
)
|
||||
|
||||
def fromProto(movingSuppliesProto: MovingSuppliesProto): MovingSupplies =
|
||||
MovingSupplies(
|
||||
id = movingSuppliesProto.id,
|
||||
id = MovingSuppliesId(movingSuppliesProto.id),
|
||||
supplies = fromProto(movingSuppliesProto.supplies.get),
|
||||
arrivalRound = movingSuppliesProto.arrivalRound,
|
||||
destinationProvinceId = movingSuppliesProto.destinationProvinceId,
|
||||
originProvinceId = movingSuppliesProto.originProvinceId,
|
||||
factionId = movingSuppliesProto.factionId,
|
||||
arrivalRound = RoundId(movingSuppliesProto.arrivalRound),
|
||||
destinationProvinceId =
|
||||
ProvinceId(movingSuppliesProto.destinationProvinceId),
|
||||
originProvinceId =
|
||||
movingSuppliesProto.originProvinceId.map(ProvinceId.apply),
|
||||
factionId = FactionId(movingSuppliesProto.factionId),
|
||||
suppliesLoss = movingSuppliesProto.suppliesLoss
|
||||
)
|
||||
}
|
||||
|
||||
+8
-6
@@ -1,5 +1,6 @@
|
||||
package net.eagle0.eagle.model.proto_converters
|
||||
|
||||
import net.eagle0.eagle.{ClientTextId, FactionId, HeroId}
|
||||
import net.eagle0.eagle.common.recruitment_info.{
|
||||
RecruitmentInfo as RecruitmentInfoProto,
|
||||
RecruitmentStatus as RecruitmentStatusProto
|
||||
@@ -133,12 +134,13 @@ object UnaffiliatedHeroConverter {
|
||||
|
||||
def fromProto(uhProto: UnaffiliatedHeroProto): UnaffiliatedHeroT =
|
||||
UnaffiliatedHeroC(
|
||||
heroId = uhProto.heroId,
|
||||
heroId = HeroId(uhProto.heroId),
|
||||
unaffiliatedHeroType = unaffiliatedHeroTypeMap(uhProto.`type`),
|
||||
roundsInType = uhProto.roundsInType,
|
||||
recruitmentAttempted = uhProto.recruitmentAttempted,
|
||||
factionBiases = uhProto.factionBiases,
|
||||
lastFactionId = uhProto.lastFaction,
|
||||
factionBiases =
|
||||
uhProto.factionBiases.map { case (k, v) => (FactionId(k), v) },
|
||||
lastFactionId = uhProto.lastFaction.map(FactionId.apply),
|
||||
recruitmentInfo = recruitmentInfoFromProto(uhProto.recruitmentInfo.get),
|
||||
divinedTextId = uhProto.divinedTextId,
|
||||
pleaseRecruitMeRejectionDate =
|
||||
@@ -150,13 +152,13 @@ object UnaffiliatedHeroConverter {
|
||||
|
||||
def toProto(uh: UnaffiliatedHeroT): UnaffiliatedHeroProto = {
|
||||
UnaffiliatedHeroProto(
|
||||
heroId = uh.heroId,
|
||||
heroId = uh.heroId.value,
|
||||
`type` =
|
||||
unaffiliatedHeroTypeMap.find(_._2 == uh.unaffiliatedHeroType).get._1,
|
||||
roundsInType = uh.roundsInType,
|
||||
recruitmentAttempted = uh.recruitmentAttempted,
|
||||
factionBiases = uh.factionBiases,
|
||||
lastFaction = uh.lastFactionId,
|
||||
factionBiases = uh.factionBiases.map { case (k, v) => (k.value, v) },
|
||||
lastFaction = uh.lastFactionId.map(_.value),
|
||||
recruitmentInfo = Some(recruitmentInfoToProto(uh.recruitmentInfo)),
|
||||
divinedTextId = uh.divinedTextId,
|
||||
pleaseRecruitMeRejectionDate = uh.pleaseRecruitMeRejectionDate.map {
|
||||
|
||||
+52
-44
@@ -28,14 +28,14 @@ import net.eagle0.eagle.model.state.diplomacy_offer.{
|
||||
RansomOffer,
|
||||
TruceOffer
|
||||
}
|
||||
import net.eagle0.eagle.{FactionId, HeroId, ProvinceId}
|
||||
import net.eagle0.eagle.{ClientTextId, FactionId, HeroId, ProvinceId}
|
||||
|
||||
object DiplomacyOfferConverter {
|
||||
def toProto(offer: DiplomacyOffer): DiplomacyOfferProto = DiplomacyOfferProto(
|
||||
originatingFactionId = offer.originatingFactionId,
|
||||
targetFactionId = offer.targetFactionId,
|
||||
messengerHeroId = offer.messengerHeroId,
|
||||
messengerOriginProvinceId = offer.messengerOriginProvinceId,
|
||||
originatingFactionId = offer.originatingFactionId.value,
|
||||
targetFactionId = offer.targetFactionId.value,
|
||||
messengerHeroId = offer.messengerHeroId.value,
|
||||
messengerOriginProvinceId = offer.messengerOriginProvinceId.value,
|
||||
status = StatusConverter.toProto(offer.status),
|
||||
eligibleStatuses = offer.eligibleStatuses.map(StatusConverter.toProto),
|
||||
offerTextId = offer.offerTextId,
|
||||
@@ -63,8 +63,8 @@ object DiplomacyOfferConverter {
|
||||
provinceIdForPrisoner: ProvinceId
|
||||
) =>
|
||||
PrisonerToBeRansomedProto(
|
||||
prisonerHeroId = prisonerHeroId,
|
||||
provinceIdForPrisoner = provinceIdForPrisoner
|
||||
prisonerHeroId = prisonerHeroId.value,
|
||||
provinceIdForPrisoner = provinceIdForPrisoner.value
|
||||
)
|
||||
}
|
||||
|
||||
@@ -77,9 +77,9 @@ object DiplomacyOfferConverter {
|
||||
provinceIdWithHero: ProvinceId
|
||||
) =>
|
||||
PrisonerOfferedInExchangeProto(
|
||||
heroId = heroId,
|
||||
factionIdForPrisoner = factionIdForPrisoner,
|
||||
provinceIdWithHero = provinceIdWithHero
|
||||
heroId = heroId.value,
|
||||
factionIdForPrisoner = factionIdForPrisoner.value,
|
||||
provinceIdWithHero = provinceIdWithHero.value
|
||||
)
|
||||
}
|
||||
|
||||
@@ -87,18 +87,19 @@ object DiplomacyOfferConverter {
|
||||
hostageOfferedInExchange: HostageOfferedInExchange
|
||||
): HostageOfferedInExchangeProto = hostageOfferedInExchange match {
|
||||
case HostageOfferedInExchange(heroId, provinceIdWithHero) =>
|
||||
HostageOfferedInExchangeProto(heroId, provinceIdWithHero)
|
||||
HostageOfferedInExchangeProto(heroId.value, provinceIdWithHero.value)
|
||||
}
|
||||
|
||||
def fromProto(diplomacyOfferProto: DiplomacyOfferProto): DiplomacyOffer =
|
||||
diplomacyOfferProto.offerDetails match {
|
||||
case TruceOfferDetails(endDate, _) =>
|
||||
TruceOffer(
|
||||
originatingFactionId = diplomacyOfferProto.originatingFactionId,
|
||||
targetFactionId = diplomacyOfferProto.targetFactionId,
|
||||
messengerHeroId = diplomacyOfferProto.messengerHeroId,
|
||||
originatingFactionId =
|
||||
FactionId(diplomacyOfferProto.originatingFactionId),
|
||||
targetFactionId = FactionId(diplomacyOfferProto.targetFactionId),
|
||||
messengerHeroId = HeroId(diplomacyOfferProto.messengerHeroId),
|
||||
messengerOriginProvinceId =
|
||||
diplomacyOfferProto.messengerOriginProvinceId,
|
||||
ProvinceId(diplomacyOfferProto.messengerOriginProvinceId),
|
||||
status = StatusConverter.fromProto(diplomacyOfferProto.status),
|
||||
eligibleStatuses = diplomacyOfferProto.eligibleStatuses
|
||||
.map(StatusConverter.fromProto)
|
||||
@@ -108,11 +109,12 @@ object DiplomacyOfferConverter {
|
||||
)
|
||||
case AllianceOfferDetails(_) =>
|
||||
AllianceOffer(
|
||||
originatingFactionId = diplomacyOfferProto.originatingFactionId,
|
||||
targetFactionId = diplomacyOfferProto.targetFactionId,
|
||||
messengerHeroId = diplomacyOfferProto.messengerHeroId,
|
||||
originatingFactionId =
|
||||
FactionId(diplomacyOfferProto.originatingFactionId),
|
||||
targetFactionId = FactionId(diplomacyOfferProto.targetFactionId),
|
||||
messengerHeroId = HeroId(diplomacyOfferProto.messengerHeroId),
|
||||
messengerOriginProvinceId =
|
||||
diplomacyOfferProto.messengerOriginProvinceId,
|
||||
ProvinceId(diplomacyOfferProto.messengerOriginProvinceId),
|
||||
status = StatusConverter.fromProto(diplomacyOfferProto.status),
|
||||
eligibleStatuses = diplomacyOfferProto.eligibleStatuses
|
||||
.map(StatusConverter.fromProto)
|
||||
@@ -121,11 +123,12 @@ object DiplomacyOfferConverter {
|
||||
)
|
||||
case BreakAllianceDetails(_) =>
|
||||
BreakAlliance(
|
||||
originatingFactionId = diplomacyOfferProto.originatingFactionId,
|
||||
targetFactionId = diplomacyOfferProto.targetFactionId,
|
||||
messengerHeroId = diplomacyOfferProto.messengerHeroId,
|
||||
originatingFactionId =
|
||||
FactionId(diplomacyOfferProto.originatingFactionId),
|
||||
targetFactionId = FactionId(diplomacyOfferProto.targetFactionId),
|
||||
messengerHeroId = HeroId(diplomacyOfferProto.messengerHeroId),
|
||||
messengerOriginProvinceId =
|
||||
diplomacyOfferProto.messengerOriginProvinceId,
|
||||
ProvinceId(diplomacyOfferProto.messengerOriginProvinceId),
|
||||
status = StatusConverter.fromProto(diplomacyOfferProto.status),
|
||||
eligibleStatuses = diplomacyOfferProto.eligibleStatuses
|
||||
.map(StatusConverter.fromProto)
|
||||
@@ -134,11 +137,12 @@ object DiplomacyOfferConverter {
|
||||
)
|
||||
case InvitationDetails(_) =>
|
||||
Invitation(
|
||||
originatingFactionId = diplomacyOfferProto.originatingFactionId,
|
||||
targetFactionId = diplomacyOfferProto.targetFactionId,
|
||||
messengerHeroId = diplomacyOfferProto.messengerHeroId,
|
||||
originatingFactionId =
|
||||
FactionId(diplomacyOfferProto.originatingFactionId),
|
||||
targetFactionId = FactionId(diplomacyOfferProto.targetFactionId),
|
||||
messengerHeroId = HeroId(diplomacyOfferProto.messengerHeroId),
|
||||
messengerOriginProvinceId =
|
||||
diplomacyOfferProto.messengerOriginProvinceId,
|
||||
ProvinceId(diplomacyOfferProto.messengerOriginProvinceId),
|
||||
status = StatusConverter.fromProto(diplomacyOfferProto.status),
|
||||
eligibleStatuses = diplomacyOfferProto.eligibleStatuses
|
||||
.map(StatusConverter.fromProto)
|
||||
@@ -153,11 +157,12 @@ object DiplomacyOfferConverter {
|
||||
_
|
||||
) =>
|
||||
RansomOffer(
|
||||
originatingFactionId = diplomacyOfferProto.originatingFactionId,
|
||||
targetFactionId = diplomacyOfferProto.targetFactionId,
|
||||
messengerHeroId = diplomacyOfferProto.messengerHeroId,
|
||||
originatingFactionId =
|
||||
FactionId(diplomacyOfferProto.originatingFactionId),
|
||||
targetFactionId = FactionId(diplomacyOfferProto.targetFactionId),
|
||||
messengerHeroId = HeroId(diplomacyOfferProto.messengerHeroId),
|
||||
messengerOriginProvinceId =
|
||||
diplomacyOfferProto.messengerOriginProvinceId,
|
||||
ProvinceId(diplomacyOfferProto.messengerOriginProvinceId),
|
||||
status = StatusConverter.fromProto(diplomacyOfferProto.status),
|
||||
eligibleStatuses = diplomacyOfferProto.eligibleStatuses
|
||||
.map(StatusConverter.fromProto)
|
||||
@@ -176,11 +181,14 @@ object DiplomacyOfferConverter {
|
||||
prisonerToBeRansomedProto: PrisonerToBeRansomedProto
|
||||
): PrisonerToBeRansomed = prisonerToBeRansomedProto match {
|
||||
case PrisonerToBeRansomedProto(
|
||||
prisonerHeroId: HeroId,
|
||||
provinceIdForPrisoner: ProvinceId,
|
||||
prisonerHeroId: Int,
|
||||
provinceIdForPrisoner: Int,
|
||||
_
|
||||
) =>
|
||||
PrisonerToBeRansomed(prisonerHeroId, provinceIdForPrisoner)
|
||||
PrisonerToBeRansomed(
|
||||
HeroId(prisonerHeroId),
|
||||
ProvinceId(provinceIdForPrisoner)
|
||||
)
|
||||
}
|
||||
|
||||
def fromProto(
|
||||
@@ -188,15 +196,15 @@ object DiplomacyOfferConverter {
|
||||
): PrisonerOfferedInExchange =
|
||||
prisonerOfferedInExchangeProto match {
|
||||
case PrisonerOfferedInExchangeProto(
|
||||
heroId: HeroId,
|
||||
factionIdForPrisoner: FactionId,
|
||||
provinceIdWithHero: ProvinceId,
|
||||
heroId: Int,
|
||||
factionIdForPrisoner: Int,
|
||||
provinceIdWithHero: Int,
|
||||
_
|
||||
) =>
|
||||
PrisonerOfferedInExchange(
|
||||
heroId = heroId,
|
||||
factionIdForPrisoner = factionIdForPrisoner,
|
||||
provinceIdWithHero = provinceIdWithHero
|
||||
heroId = HeroId(heroId),
|
||||
factionIdForPrisoner = FactionId(factionIdForPrisoner),
|
||||
provinceIdWithHero = ProvinceId(provinceIdWithHero)
|
||||
)
|
||||
}
|
||||
|
||||
@@ -205,13 +213,13 @@ object DiplomacyOfferConverter {
|
||||
): HostageOfferedInExchange =
|
||||
hostageOfferedInExchangeProto match {
|
||||
case HostageOfferedInExchangeProto(
|
||||
heroId: HeroId,
|
||||
provinceIdWithHero: ProvinceId,
|
||||
heroId: Int,
|
||||
provinceIdWithHero: Int,
|
||||
_
|
||||
) =>
|
||||
HostageOfferedInExchange(
|
||||
heroId = heroId,
|
||||
provinceIdWithHero = provinceIdWithHero
|
||||
heroId = HeroId(heroId),
|
||||
provinceIdWithHero = ProvinceId(provinceIdWithHero)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
+26
-29
@@ -42,17 +42,17 @@ object FactionConverter {
|
||||
earliestRoundForInvitation: RoundId
|
||||
) =>
|
||||
FactionProto(
|
||||
id = id,
|
||||
factionHeadId = factionHeadId,
|
||||
id = id.value,
|
||||
factionHeadId = factionHeadId.value,
|
||||
name = name,
|
||||
leaders = leaderIds,
|
||||
leaders = leaderIds.map(_.value),
|
||||
prestigeModifiers = prestigeModifiers.map(toProto),
|
||||
factionRelationships = factionRelationships.map(toProto),
|
||||
incomingDiplomacyOffers =
|
||||
incomingDiplomacyOffers.map(DiplomacyOfferConverter.toProto),
|
||||
focusProvinceId = focusProvinceId,
|
||||
focusProvinceId = focusProvinceId.map(_.value),
|
||||
reconnedProvinces = reconnedProvinces,
|
||||
lastActedProvinceIdThisRound = lastActedProvinceIdThisRound,
|
||||
lastActedProvinceIdThisRound = lastActedProvinceIdThisRound.value,
|
||||
lastOutgoingTruceOfferRounds =
|
||||
lastOutgoingTruceOfferRounds.map(toProto),
|
||||
lastOutgoingAllianceOfferRounds =
|
||||
@@ -61,7 +61,7 @@ object FactionConverter {
|
||||
lastOutgoingInvitationRounds.map(toProto),
|
||||
lastOutgoingRansomOfferRounds =
|
||||
lastOutgoingRansomOfferRounds.map(toProto),
|
||||
earliestRoundForInvitation = earliestRoundForInvitation
|
||||
earliestRoundForInvitation = earliestRoundForInvitation.value
|
||||
)
|
||||
|
||||
case _ =>
|
||||
@@ -87,10 +87,10 @@ object FactionConverter {
|
||||
targetFactionId: FactionId,
|
||||
relationshipLevel: FactionRelationship.RelationshipLevel,
|
||||
resetDate: Option[Date],
|
||||
trustValue: FactionId
|
||||
trustValue: Int
|
||||
) =>
|
||||
FactionRelationshipProto(
|
||||
targetFactionId = targetFactionId,
|
||||
targetFactionId = targetFactionId.value,
|
||||
relationshipLevel = relationshipLevel match {
|
||||
case FactionRelationship.RelationshipLevel.Unknown =>
|
||||
FactionRelationshipProto.RelationshipLevel.UNKNOWN
|
||||
@@ -109,48 +109,45 @@ object FactionConverter {
|
||||
def toProto(
|
||||
outgoingOfferRound: OutgoingOfferRound
|
||||
): OutgoingOfferRoundProto = outgoingOfferRound match {
|
||||
case OutgoingOfferRound(
|
||||
roundId: RoundId,
|
||||
toFactionId: FactionId
|
||||
) =>
|
||||
case OutgoingOfferRound(roundId, toFactionId) =>
|
||||
OutgoingOfferRoundProto(
|
||||
roundId = roundId,
|
||||
toFactionId = toFactionId
|
||||
roundId = roundId.value,
|
||||
toFactionId = toFactionId.value
|
||||
)
|
||||
}
|
||||
|
||||
def fromProto(factionProto: FactionProto): FactionT = factionProto match {
|
||||
case FactionProto(
|
||||
id: FactionId,
|
||||
factionHeadId: HeroId,
|
||||
id: Int,
|
||||
factionHeadId: Int,
|
||||
name: String,
|
||||
leaders: Seq[HeroId],
|
||||
leaders: Seq[Int],
|
||||
prestigeModifiers: Seq[PrestigeModifierProto],
|
||||
factionRelationships: Seq[FactionRelationshipProto],
|
||||
incomingDiplomacyOffers: Seq[DiplomacyOfferProto],
|
||||
focusProvinceId: Option[ProvinceId],
|
||||
focusProvinceId: Option[Int],
|
||||
reconnedProvinces: Seq[ProvinceView],
|
||||
lastActedProvinceIdThisRound: ProvinceId,
|
||||
lastActedProvinceIdThisRound: Int,
|
||||
lastOutgoingTruceOfferRounds: Seq[OutgoingOfferRoundProto],
|
||||
lastOutgoingAllianceOfferRounds: Seq[OutgoingOfferRoundProto],
|
||||
lastOutgoingInvitationRounds: Seq[OutgoingOfferRoundProto],
|
||||
lastOutgoingRansomOfferRounds: Seq[OutgoingOfferRoundProto],
|
||||
earliestRoundForInvitation: RoundId,
|
||||
earliestRoundForInvitation: Int,
|
||||
_ /* unknownFields */
|
||||
) =>
|
||||
FactionC(
|
||||
id = id,
|
||||
factionHeadId = factionHeadId,
|
||||
id = FactionId(id),
|
||||
factionHeadId = HeroId(factionHeadId),
|
||||
name = name,
|
||||
leaderIds = leaders.toVector,
|
||||
leaderIds = leaders.map(HeroId(_)).toVector,
|
||||
prestigeModifiers = prestigeModifiers.map(fromProto).toVector,
|
||||
factionRelationships = factionRelationships.map(fromProto).toVector,
|
||||
incomingDiplomacyOffers = incomingDiplomacyOffers
|
||||
.map(DiplomacyOfferConverter.fromProto)
|
||||
.toVector,
|
||||
focusProvinceId = focusProvinceId,
|
||||
focusProvinceId = focusProvinceId.map(ProvinceId(_)),
|
||||
reconnedProvinces = reconnedProvinces.toVector,
|
||||
lastActedProvinceIdThisRound = lastActedProvinceIdThisRound,
|
||||
lastActedProvinceIdThisRound = ProvinceId(lastActedProvinceIdThisRound),
|
||||
lastOutgoingTruceOfferRounds =
|
||||
lastOutgoingTruceOfferRounds.map(fromProto).toVector,
|
||||
lastOutgoingAllianceOfferRounds =
|
||||
@@ -159,7 +156,7 @@ object FactionConverter {
|
||||
lastOutgoingInvitationRounds.map(fromProto).toVector,
|
||||
lastOutgoingRansomOfferRounds =
|
||||
lastOutgoingRansomOfferRounds.map(fromProto).toVector,
|
||||
earliestRoundForInvitation = earliestRoundForInvitation
|
||||
earliestRoundForInvitation = RoundId(earliestRoundForInvitation)
|
||||
)
|
||||
}
|
||||
|
||||
@@ -174,7 +171,7 @@ object FactionConverter {
|
||||
_ /* unknownFields */
|
||||
) =>
|
||||
FactionRelationship(
|
||||
targetFactionId = targetFactionId,
|
||||
targetFactionId = FactionId(targetFactionId),
|
||||
relationshipLevel = relationshipLevel match {
|
||||
case FactionRelationshipProto.RelationshipLevel.UNKNOWN =>
|
||||
FactionRelationship.RelationshipLevel.Unknown
|
||||
@@ -221,8 +218,8 @@ object FactionConverter {
|
||||
_ /* unknownFields */
|
||||
) =>
|
||||
OutgoingOfferRound(
|
||||
roundId = roundId,
|
||||
toFactionId = toFactionId
|
||||
roundId = RoundId(roundId),
|
||||
toFactionId = FactionId(toFactionId)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
+57
-57
@@ -90,8 +90,8 @@ object EventForHeroBackstoryConverter {
|
||||
outcome: Status
|
||||
) =>
|
||||
AllianceAmbassadorBackstoryEventProto(
|
||||
fromFactionId = fromFactionId,
|
||||
toFactionId = toFactionId,
|
||||
fromFactionId = fromFactionId.value,
|
||||
toFactionId = toFactionId.value,
|
||||
outcome = StatusConverter.toProto(outcome)
|
||||
)
|
||||
case BreakAllianceAmbassadorBackstoryEvent(
|
||||
@@ -101,8 +101,8 @@ object EventForHeroBackstoryConverter {
|
||||
outcome: Status
|
||||
) =>
|
||||
BreakAllianceAmbassadorBackstoryEventProto(
|
||||
fromFactionId = fromFactionId,
|
||||
toFactionId = toFactionId,
|
||||
fromFactionId = fromFactionId.value,
|
||||
toFactionId = toFactionId.value,
|
||||
outcome = StatusConverter.toProto(outcome)
|
||||
)
|
||||
case CapturedHeroExecutedBackstoryEvent(
|
||||
@@ -112,9 +112,9 @@ object EventForHeroBackstoryConverter {
|
||||
provinceId: ProvinceId
|
||||
) =>
|
||||
CapturedHeroExecutedBackstoryEventProto(
|
||||
capturingFactionId = capturingFactionId,
|
||||
capturingHeroId = capturingHeroId,
|
||||
provinceId = provinceId
|
||||
capturingFactionId = capturingFactionId.value,
|
||||
capturingHeroId = capturingHeroId.value,
|
||||
provinceId = provinceId.value
|
||||
)
|
||||
case CapturedHeroExiledBackstoryEvent(
|
||||
_ /* date: Date */,
|
||||
@@ -123,9 +123,9 @@ object EventForHeroBackstoryConverter {
|
||||
provinceId: ProvinceId
|
||||
) =>
|
||||
CapturedHeroExiledBackstoryEventProto(
|
||||
capturingFactionId = capturingFactionId,
|
||||
capturingHeroId = capturingHeroId,
|
||||
provinceId = provinceId
|
||||
capturingFactionId = capturingFactionId.value,
|
||||
capturingHeroId = capturingHeroId.value,
|
||||
provinceId = provinceId.value
|
||||
)
|
||||
case CapturedHeroImprisonedBackstoryEvent(
|
||||
_ /* date: Date */,
|
||||
@@ -134,9 +134,9 @@ object EventForHeroBackstoryConverter {
|
||||
provinceId: ProvinceId
|
||||
) =>
|
||||
CapturedHeroImprisonedBackstoryEventProto(
|
||||
capturingFactionId = capturingFactionId,
|
||||
capturingHeroId = capturingHeroId,
|
||||
provinceId = provinceId
|
||||
capturingFactionId = capturingFactionId.value,
|
||||
capturingHeroId = capturingHeroId.value,
|
||||
provinceId = provinceId.value
|
||||
)
|
||||
case CapturedHeroRecruitedBackstoryEvent(
|
||||
_ /* date: Date */,
|
||||
@@ -145,9 +145,9 @@ object EventForHeroBackstoryConverter {
|
||||
provinceId: ProvinceId
|
||||
) =>
|
||||
CapturedHeroRecruitedBackstoryEventProto(
|
||||
capturingFactionId = capturingFactionId,
|
||||
capturingHeroId = capturingHeroId,
|
||||
provinceId = provinceId
|
||||
capturingFactionId = capturingFactionId.value,
|
||||
capturingHeroId = capturingHeroId.value,
|
||||
provinceId = provinceId.value
|
||||
)
|
||||
case CapturedHeroReturnedBackstoryEvent(
|
||||
_ /* date: Date */,
|
||||
@@ -156,9 +156,9 @@ object EventForHeroBackstoryConverter {
|
||||
provinceId
|
||||
) =>
|
||||
CapturedHeroReturnedBackstoryEventProto(
|
||||
capturingFactionId = capturingFactionId,
|
||||
capturingHeroId = capturingHeroId,
|
||||
provinceId = provinceId
|
||||
capturingFactionId = capturingFactionId.value,
|
||||
capturingHeroId = capturingHeroId.value,
|
||||
provinceId = provinceId.value
|
||||
)
|
||||
case ExchangedInRansomBackstoryEvent(
|
||||
_ /* date: Date */,
|
||||
@@ -168,10 +168,10 @@ object EventForHeroBackstoryConverter {
|
||||
imprisonedInProvinceId: ProvinceId
|
||||
) =>
|
||||
ExchangedInRansomBackstoryEventProto(
|
||||
ransomPaidByFactionId = ransomPaidByFactionId,
|
||||
ransomPaidToFactionId = ransomPaidToFactionId,
|
||||
ransomedHeroId = ransomedHeroId,
|
||||
imprisonedInProvinceId = imprisonedInProvinceId
|
||||
ransomPaidByFactionId = ransomPaidByFactionId.value,
|
||||
ransomPaidToFactionId = ransomPaidToFactionId.value,
|
||||
ransomedHeroId = ransomedHeroId.value,
|
||||
imprisonedInProvinceId = imprisonedInProvinceId.value
|
||||
)
|
||||
case ExiledBackstoryEvent(
|
||||
_ /* date: Date */,
|
||||
@@ -179,8 +179,8 @@ object EventForHeroBackstoryConverter {
|
||||
exiledFromProvinceId: ProvinceId
|
||||
) =>
|
||||
ExiledBackstoryEventProto(
|
||||
exiledByFactionId = exiledByFactionId,
|
||||
exiledFromProvinceId = exiledFromProvinceId
|
||||
exiledByFactionId = exiledByFactionId.value,
|
||||
exiledFromProvinceId = exiledFromProvinceId.value
|
||||
)
|
||||
case FoughtInBattleBackstoryEvent(
|
||||
_ /* date: Date */,
|
||||
@@ -192,11 +192,11 @@ object EventForHeroBackstoryConverter {
|
||||
status: FoughtInBattleBackstoryEvent.BattalionStatus
|
||||
) =>
|
||||
FoughtInBattleBackstoryEventProto(
|
||||
provinceId = provinceId,
|
||||
provinceId = provinceId.value,
|
||||
battalion = battalion.map(BattalionViewConverter.toProto),
|
||||
isVictorious = isVictorious,
|
||||
isAttacker = isAttacker,
|
||||
enemyFactionIds = enemyFactionIds,
|
||||
enemyFactionIds = enemyFactionIds.map(_.value),
|
||||
status = toProto(status)
|
||||
)
|
||||
case HeroDepartedBackstoryEvent(
|
||||
@@ -205,8 +205,8 @@ object EventForHeroBackstoryConverter {
|
||||
departedFromProvinceId: ProvinceId
|
||||
) =>
|
||||
HeroDepartedBackstoryEventProto(
|
||||
departedFromFactionId = departedFromFactionId,
|
||||
departedFromProvinceId = departedFromProvinceId
|
||||
departedFromFactionId = departedFromFactionId.value,
|
||||
departedFromProvinceId = departedFromProvinceId.value
|
||||
)
|
||||
case InvitationAmbassadorBackstoryEvent(
|
||||
_ /* date: Date */,
|
||||
@@ -215,8 +215,8 @@ object EventForHeroBackstoryConverter {
|
||||
outcome: Status
|
||||
) =>
|
||||
InvitationAmbassadorBackstoryEventProto(
|
||||
fromFactionId = fromFactionId,
|
||||
toFactionId = toFactionId,
|
||||
fromFactionId = fromFactionId.value,
|
||||
toFactionId = toFactionId.value,
|
||||
outcome = StatusConverter.toProto(outcome)
|
||||
)
|
||||
case JoinedByInvitationBackstoryEvent(
|
||||
@@ -227,10 +227,10 @@ object EventForHeroBackstoryConverter {
|
||||
previousFactionHeadHeroId: HeroId
|
||||
) =>
|
||||
JoinedByInvitationBackstoryEventProto(
|
||||
invitedByFactionId = invitedByFactionId,
|
||||
invitedByHeroId = invitedByHeroId,
|
||||
previousFactionId = previousFactionId,
|
||||
previousFactionHeadHeroId = previousFactionHeadHeroId
|
||||
invitedByFactionId = invitedByFactionId.value,
|
||||
invitedByHeroId = invitedByHeroId.value,
|
||||
previousFactionId = previousFactionId.value,
|
||||
previousFactionHeadHeroId = previousFactionHeadHeroId.value
|
||||
)
|
||||
case PleaseRecruitMeBackstoryEvent(
|
||||
_ /* date: Date */,
|
||||
@@ -239,8 +239,8 @@ object EventForHeroBackstoryConverter {
|
||||
accepted: Boolean
|
||||
) =>
|
||||
PleaseRecruitMeBackstoryEventProto(
|
||||
desiredFactionId = desiredFactionId,
|
||||
provinceId = provinceId,
|
||||
desiredFactionId = desiredFactionId.value,
|
||||
provinceId = provinceId.value,
|
||||
accepted = accepted
|
||||
)
|
||||
case QuestFailedBackstoryEvent(
|
||||
@@ -250,8 +250,8 @@ object EventForHeroBackstoryConverter {
|
||||
quest: QuestT
|
||||
) =>
|
||||
QuestFailedBackstoryEventProto(
|
||||
provinceId = provinceId,
|
||||
factionId = factionId,
|
||||
provinceId = provinceId.value,
|
||||
factionId = factionId.value,
|
||||
quest = Some(QuestConverter.toProto(quest))
|
||||
)
|
||||
case QuestFulfilledBackstoryEvent(
|
||||
@@ -261,8 +261,8 @@ object EventForHeroBackstoryConverter {
|
||||
quest: QuestT
|
||||
) =>
|
||||
QuestFulfilledBackstoryEventProto(
|
||||
provinceId = provinceId,
|
||||
factionId = factionId,
|
||||
provinceId = provinceId.value,
|
||||
factionId = factionId.value,
|
||||
quest = Some(QuestConverter.toProto(quest))
|
||||
)
|
||||
case RansomedBackstoryEvent(
|
||||
@@ -274,11 +274,11 @@ object EventForHeroBackstoryConverter {
|
||||
heroIdsExchanged: Vector[HeroId]
|
||||
) =>
|
||||
RansomedBackstoryEventProto(
|
||||
ransomPaidByFactionId = ransomPaidByFactionId,
|
||||
ransomPaidToFactionId = ransomPaidToFactionId,
|
||||
imprisonedInProvinceId = imprisonedInProvinceId,
|
||||
ransomPaidByFactionId = ransomPaidByFactionId.value,
|
||||
ransomPaidToFactionId = ransomPaidToFactionId.value,
|
||||
imprisonedInProvinceId = imprisonedInProvinceId.value,
|
||||
goldPaid = goldPaid,
|
||||
heroIdsExchanged = heroIdsExchanged
|
||||
heroIdsExchanged = heroIdsExchanged.map(_.value)
|
||||
)
|
||||
case RecruitedBackstoryEvent(
|
||||
_ /* date: Date */,
|
||||
@@ -287,9 +287,9 @@ object EventForHeroBackstoryConverter {
|
||||
recruitedInProvinceId: ProvinceId
|
||||
) =>
|
||||
RecruitedBackstoryEventProto(
|
||||
recruitedByFactionId = recruitedByFactionId,
|
||||
recruitedByHeroId = recruitedByHeroId,
|
||||
recruitedInProvinceId = recruitedInProvinceId
|
||||
recruitedByFactionId = recruitedByFactionId.value,
|
||||
recruitedByHeroId = recruitedByHeroId.value,
|
||||
recruitedInProvinceId = recruitedInProvinceId.value
|
||||
)
|
||||
case ReleasedByAllianceBackstoryEvent(
|
||||
_ /* date: Date */,
|
||||
@@ -297,8 +297,8 @@ object EventForHeroBackstoryConverter {
|
||||
releasedFromProvinceId: ProvinceId
|
||||
) =>
|
||||
ReleasedByAllianceBackstoryEventProto(
|
||||
releasingFactionId = releasingFactionId,
|
||||
releasedFromProvinceId = releasedFromProvinceId
|
||||
releasingFactionId = releasingFactionId.value,
|
||||
releasedFromProvinceId = releasedFromProvinceId.value
|
||||
)
|
||||
case ReleasedByProvinceCaptureBackstoryEvent(
|
||||
_ /* date: Date */,
|
||||
@@ -306,8 +306,8 @@ object EventForHeroBackstoryConverter {
|
||||
releasedInProvinceId: ProvinceId
|
||||
) =>
|
||||
ReleasedByProvinceCaptureBackstoryEventProto(
|
||||
capturingFactionId = capturingFactionId,
|
||||
releasedInProvinceId = releasedInProvinceId
|
||||
capturingFactionId = capturingFactionId.value,
|
||||
releasedInProvinceId = releasedInProvinceId.value
|
||||
)
|
||||
case SuppressedBeastsBackstoryEvent(
|
||||
_ /* date: Date */,
|
||||
@@ -318,7 +318,7 @@ object EventForHeroBackstoryConverter {
|
||||
succeeded: Boolean
|
||||
) =>
|
||||
SuppressedBeastsBackstoryEventProto(
|
||||
provinceId = provinceId,
|
||||
provinceId = provinceId.value,
|
||||
beastType = beastType,
|
||||
beastCount = beastCount,
|
||||
battalion = battalion.map(BattalionViewConverter.toProto),
|
||||
@@ -330,8 +330,8 @@ object EventForHeroBackstoryConverter {
|
||||
sworeInProvinceId: ProvinceId
|
||||
) =>
|
||||
SworeBrotherhoodBackstoryEventProto(
|
||||
sworeWithFactionId = sworeWithFactionId,
|
||||
sworeInProvinceId = sworeInProvinceId
|
||||
sworeWithFactionId = sworeWithFactionId.value,
|
||||
sworeInProvinceId = sworeInProvinceId.value
|
||||
)
|
||||
case TruceAmbassadorBackstoryEvent(
|
||||
_ /* date: Date */,
|
||||
@@ -340,8 +340,8 @@ object EventForHeroBackstoryConverter {
|
||||
outcome: Status
|
||||
) =>
|
||||
TruceAmbassadorBackstoryEventProto(
|
||||
fromFactionId = fromFactionId,
|
||||
toFactionId = toFactionId,
|
||||
fromFactionId = fromFactionId.value,
|
||||
toFactionId = toFactionId.value,
|
||||
outcome = StatusConverter.toProto(outcome)
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package net.eagle0.eagle.model.proto_converters.hero
|
||||
|
||||
import net.eagle0.eagle.{FactionId, HeroId, RoundId}
|
||||
import net.eagle0.eagle.{ClientTextId, FactionId, HeroId, RoundId}
|
||||
import net.eagle0.eagle.internal.hero.Hero as HeroProto
|
||||
import net.eagle0.eagle.common.hero_backstory_version.BackstoryVersion as BackstoryVersionProto
|
||||
import net.eagle0.eagle.model.proto_converters.date.DateConverter
|
||||
@@ -44,9 +44,9 @@ object HeroConverter {
|
||||
backstoryEvents: Vector[EventForHeroBackstoryT]
|
||||
) =>
|
||||
HeroProto(
|
||||
id = id,
|
||||
factionId = factionId,
|
||||
roundIdJoined = roundIdJoined,
|
||||
id = id.value,
|
||||
factionId = factionId.map(_.value),
|
||||
roundIdJoined = roundIdJoined.map(_.value),
|
||||
nameTextId = nameTextId,
|
||||
profession = ProfessionConverter.toProto(profession),
|
||||
pronounGender = GenderConverter.toProto(pronounGender),
|
||||
@@ -70,7 +70,10 @@ object HeroConverter {
|
||||
personalityWords = personalityWords,
|
||||
backstoryVersions =
|
||||
backstoryVersions.map { case BackstoryVersion(textId, date) =>
|
||||
BackstoryVersionProto(textId, Some(DateConverter.toProto(date)))
|
||||
BackstoryVersionProto(
|
||||
textId.value,
|
||||
Some(DateConverter.toProto(date))
|
||||
)
|
||||
},
|
||||
newBackstoryEvents =
|
||||
backstoryEvents.map(EventForHeroBackstoryConverter.toProto)
|
||||
@@ -108,9 +111,9 @@ object HeroConverter {
|
||||
_ /* unknownFields */
|
||||
) =>
|
||||
HeroC(
|
||||
id = id,
|
||||
factionId = factionId,
|
||||
roundIdJoined = roundIdJoined,
|
||||
id = HeroId(id),
|
||||
factionId = factionId.map(FactionId(_)),
|
||||
roundIdJoined = roundIdJoined.map(RoundId(_)),
|
||||
nameTextId = nameTextId,
|
||||
profession = ProfessionConverter.fromProto(profession),
|
||||
pronounGender = GenderConverter.fromProto(pronounGender),
|
||||
@@ -134,7 +137,10 @@ object HeroConverter {
|
||||
personalityWords = personalityWords.toVector,
|
||||
backstoryVersions = backstoryVersions.map {
|
||||
case BackstoryVersionProto(textId, date, _ /* unknownFields */ ) =>
|
||||
BackstoryVersion(textId, DateConverter.fromProto(date))
|
||||
BackstoryVersion(
|
||||
ClientTextId(textId),
|
||||
DateConverter.fromProto(date)
|
||||
)
|
||||
}.toVector,
|
||||
backstoryEvents = newBackstoryEvents
|
||||
.map(EventForHeroBackstoryConverter.fromProto)
|
||||
|
||||
+46
-46
@@ -72,9 +72,9 @@ object ChronicleEventConverter {
|
||||
ambassadorHeroId: HeroId
|
||||
) =>
|
||||
AllianceAcceptedEventProto(
|
||||
offeringFactionId = offeringFactionId,
|
||||
targetFactionId = targetFactionId,
|
||||
ambassadorHeroId = ambassadorHeroId
|
||||
offeringFactionId = offeringFactionId.value,
|
||||
targetFactionId = targetFactionId.value,
|
||||
ambassadorHeroId = ambassadorHeroId.value
|
||||
)
|
||||
case BreakAllianceChronicleEvent(
|
||||
_: Date /* date */,
|
||||
@@ -83,9 +83,9 @@ object ChronicleEventConverter {
|
||||
ambassadorHeroId
|
||||
) =>
|
||||
BreakAllianceEventProto(
|
||||
offeringFactionId = offeringFactionId,
|
||||
targetFactionId = targetFactionId,
|
||||
ambassadorHeroId = ambassadorHeroId
|
||||
offeringFactionId = offeringFactionId.value,
|
||||
targetFactionId = targetFactionId.value,
|
||||
ambassadorHeroId = ambassadorHeroId.value
|
||||
)
|
||||
case BreakAllianceAmbassadorImprisonedChronicleEvent(
|
||||
_: Date /* date */,
|
||||
@@ -94,9 +94,9 @@ object ChronicleEventConverter {
|
||||
ambassadorHeroId: HeroId
|
||||
) =>
|
||||
BreakAllianceAmbassadorImprisonedEventProto(
|
||||
offeringFactionId = offeringFactionId,
|
||||
targetFactionId = targetFactionId,
|
||||
ambassadorHeroId = ambassadorHeroId
|
||||
offeringFactionId = offeringFactionId.value,
|
||||
targetFactionId = targetFactionId.value,
|
||||
ambassadorHeroId = ambassadorHeroId.value
|
||||
)
|
||||
case CapturedHeroExecutedChronicleEvent(
|
||||
_: Date /* date */,
|
||||
@@ -106,10 +106,10 @@ object ChronicleEventConverter {
|
||||
executingFactionId: FactionId
|
||||
) =>
|
||||
CapturedHeroExecutedEventProto(
|
||||
capturedFromFactionId = capturedFromFactionId,
|
||||
provinceId = provinceId,
|
||||
executedHeroId = executedHeroId,
|
||||
executingFactionId = executingFactionId
|
||||
capturedFromFactionId = capturedFromFactionId.value,
|
||||
provinceId = provinceId.value.value,
|
||||
executedHeroId = executedHeroId.value,
|
||||
executingFactionId = executingFactionId.value
|
||||
)
|
||||
case CapturedHeroExiledChronicleEvent(
|
||||
_: Date /* date */,
|
||||
@@ -119,10 +119,10 @@ object ChronicleEventConverter {
|
||||
exilingFactionId: FactionId
|
||||
) =>
|
||||
CapturedHeroExiledEventProto(
|
||||
capturedFromFactionId = capturedFromFactionId,
|
||||
provinceId = provinceId,
|
||||
exiledHeroId = exiledHeroId,
|
||||
exilingFactionId = exilingFactionId
|
||||
capturedFromFactionId = capturedFromFactionId.value,
|
||||
provinceId = provinceId.value.value,
|
||||
exiledHeroId = exiledHeroId.value,
|
||||
exilingFactionId = exilingFactionId.value
|
||||
)
|
||||
case CapturedHeroImprisonedChronicleEvent(
|
||||
_: Date /* date */,
|
||||
@@ -132,16 +132,16 @@ object ChronicleEventConverter {
|
||||
imprisoningFactionId: FactionId
|
||||
) =>
|
||||
CapturedHeroImprisonedEventProto(
|
||||
capturedFromFactionId = capturedFromFactionId,
|
||||
provinceId = provinceId,
|
||||
imprisonedHeroId = imprisonedHeroId,
|
||||
imprisoningFactionId = imprisoningFactionId
|
||||
capturedFromFactionId = capturedFromFactionId.value,
|
||||
provinceId = provinceId.value.value,
|
||||
imprisonedHeroId = imprisonedHeroId.value,
|
||||
imprisoningFactionId = imprisoningFactionId.value
|
||||
)
|
||||
case FactionDestroyedChronicleEvent(
|
||||
_: Date /* date */,
|
||||
factionId: FactionId
|
||||
) =>
|
||||
FactionDestroyedEventProto(factionId = factionId)
|
||||
FactionDestroyedEventProto(factionId = factionId.value)
|
||||
case HeroDepartedChronicleEvent(
|
||||
_: Date /* date */,
|
||||
departingHeroId: HeroId,
|
||||
@@ -149,9 +149,9 @@ object ChronicleEventConverter {
|
||||
provinceId: ProvinceId
|
||||
) =>
|
||||
HeroDepartedEventProto(
|
||||
departingHeroId = departingHeroId,
|
||||
fromFactionId = fromFactionId,
|
||||
provinceId = provinceId
|
||||
departingHeroId = departingHeroId.value,
|
||||
fromFactionId = fromFactionId.value,
|
||||
provinceId = provinceId.value
|
||||
)
|
||||
case InvitationAcceptedChronicleEvent(
|
||||
_: Date /* date */,
|
||||
@@ -159,8 +159,8 @@ object ChronicleEventConverter {
|
||||
invitedFactionId: FactionId
|
||||
) =>
|
||||
InvitationAcceptedEventProto(
|
||||
offeringFactionId = offeringFactionId,
|
||||
invitedFactionId = invitedFactionId
|
||||
offeringFactionId = offeringFactionId.value,
|
||||
invitedFactionId = invitedFactionId.value
|
||||
)
|
||||
case InvitationAmbassadorImprisonedChronicleEvent(
|
||||
_: Date /* date */,
|
||||
@@ -169,9 +169,9 @@ object ChronicleEventConverter {
|
||||
ambassadorHeroId: HeroId
|
||||
) =>
|
||||
InvitationAmbassadorImprisonedEventProto(
|
||||
offeringFactionId = offeringFactionId,
|
||||
invitedFactionId = invitedFactionId,
|
||||
ambassadorHeroId = ambassadorHeroId
|
||||
offeringFactionId = offeringFactionId.value,
|
||||
invitedFactionId = invitedFactionId.value,
|
||||
ambassadorHeroId = ambassadorHeroId.value
|
||||
)
|
||||
case OutlawApprehendedChronicleEvent(
|
||||
_: Date /* date */,
|
||||
@@ -181,7 +181,7 @@ object ChronicleEventConverter {
|
||||
) =>
|
||||
OutlawApprehendedEventProto(
|
||||
factionId = factionId,
|
||||
provinceId = provinceId,
|
||||
provinceId = provinceId.value.value,
|
||||
apprehendedHeroId = apprehendedHeroId
|
||||
)
|
||||
case PrisonerExecutedChronicleEvent(
|
||||
@@ -193,9 +193,9 @@ object ChronicleEventConverter {
|
||||
) =>
|
||||
PrisonerExecutedEventProto(
|
||||
lastFactionId = lastFactionId,
|
||||
provinceId = provinceId,
|
||||
executedHeroId = executedHeroId,
|
||||
executingFactionId = executingFactionId
|
||||
provinceId = provinceId.value.value,
|
||||
executedHeroId = executedHeroId.value,
|
||||
executingFactionId = executingFactionId.value
|
||||
)
|
||||
case PrisonersExchangedChronicleEvent(
|
||||
_: Date /* date */,
|
||||
@@ -222,7 +222,7 @@ object ChronicleEventConverter {
|
||||
defendingFactionId: FactionId
|
||||
) =>
|
||||
ProvinceConqueredEventProto(
|
||||
provinceId = provinceId,
|
||||
provinceId = provinceId.value.value,
|
||||
conqueringFactionId = conqueringFactionId,
|
||||
otherAttackingFactionIds = otherAttackingFactionIds,
|
||||
defendingFactionId = defendingFactionId
|
||||
@@ -233,7 +233,7 @@ object ChronicleEventConverter {
|
||||
expandingFactionId: FactionId
|
||||
) =>
|
||||
ProvinceExpansionEventProto(
|
||||
provinceId = provinceId,
|
||||
provinceId = provinceId.value.value,
|
||||
expandingFactionId = expandingFactionId
|
||||
)
|
||||
case ProvinceHeldChronicleEvent(
|
||||
@@ -243,7 +243,7 @@ object ChronicleEventConverter {
|
||||
defendingFactionId: FactionId
|
||||
) =>
|
||||
ProvinceHeldEventProto(
|
||||
provinceId = provinceId,
|
||||
provinceId = provinceId.value.value,
|
||||
attackingFactionIds = attackingFactionIds,
|
||||
defendingFactionId = defendingFactionId
|
||||
)
|
||||
@@ -277,7 +277,7 @@ object ChronicleEventConverter {
|
||||
) =>
|
||||
ShatteredArmyEventProto(
|
||||
factionId = factionId,
|
||||
provinceId = provinceId,
|
||||
provinceId = provinceId.value.value,
|
||||
reason = reason match {
|
||||
case ShatteredArmyChronicleEvent.Blizzard =>
|
||||
ShatteredArmyEventProto.Reason.SHATTERED_ARMY_EVENT_REASON_BLIZZARD
|
||||
@@ -294,7 +294,7 @@ object ChronicleEventConverter {
|
||||
) =>
|
||||
SuppressBeastsFailedEventProto(
|
||||
heroId = heroId,
|
||||
provinceId = provinceId,
|
||||
provinceId = provinceId.value.value,
|
||||
singularName = singularName,
|
||||
pluralName = pluralName
|
||||
)
|
||||
@@ -314,9 +314,9 @@ object ChronicleEventConverter {
|
||||
ambassadorHeroId: HeroId
|
||||
) =>
|
||||
TruceAcceptedEventProto(
|
||||
offeringFactionId = offeringFactionId,
|
||||
targetFactionId = targetFactionId,
|
||||
ambassadorHeroId = ambassadorHeroId
|
||||
offeringFactionId = offeringFactionId.value,
|
||||
targetFactionId = targetFactionId.value,
|
||||
ambassadorHeroId = ambassadorHeroId.value
|
||||
)
|
||||
case TruceAmbassadorImprisonedChronicleEvent(
|
||||
_: Date /* date */,
|
||||
@@ -325,9 +325,9 @@ object ChronicleEventConverter {
|
||||
ambassadorHeroId: HeroId
|
||||
) =>
|
||||
TruceAmbassadorImprisonedEventProto(
|
||||
offeringFactionId = offeringFactionId,
|
||||
targetFactionId = targetFactionId,
|
||||
ambassadorHeroId = ambassadorHeroId
|
||||
offeringFactionId = offeringFactionId.value,
|
||||
targetFactionId = targetFactionId.value,
|
||||
ambassadorHeroId = ambassadorHeroId.value
|
||||
)
|
||||
case VassalExiledChronicleEvent(
|
||||
_: Date /* date */,
|
||||
@@ -337,7 +337,7 @@ object ChronicleEventConverter {
|
||||
) =>
|
||||
VassalExiledEventProto(
|
||||
factionId = factionId,
|
||||
provinceId = provinceId,
|
||||
provinceId = provinceId.value.value,
|
||||
exiledHeroId = exiledHeroId
|
||||
)
|
||||
}
|
||||
|
||||
+12
-12
@@ -103,15 +103,15 @@ object ProvinceConverter {
|
||||
lastCommand: Any
|
||||
) =>
|
||||
ProvinceProto(
|
||||
id = id,
|
||||
id = id.value,
|
||||
name = name,
|
||||
neighbors = neighbors.map { case Neighbor(provinceId, distance) =>
|
||||
NeighborProto(provinceId, distance)
|
||||
NeighborProto(provinceId.value, distance)
|
||||
},
|
||||
rulingFactionId = rulingFactionId,
|
||||
rulingHeroId = rulingHeroId,
|
||||
rulingFactionHeroIds = rulingFactionHeroIds,
|
||||
battalionIds = battalionIds,
|
||||
rulingFactionId = rulingFactionId.map(_.value),
|
||||
rulingHeroId = rulingHeroId.map(_.value),
|
||||
rulingFactionHeroIds = rulingFactionHeroIds.map(_.value),
|
||||
battalionIds = battalionIds.map(_.value),
|
||||
specialBattalionTypes =
|
||||
specialBattalionTypeIds.map(BattalionTypeIdConverter.toProto),
|
||||
gold = gold,
|
||||
@@ -202,16 +202,16 @@ object ProvinceConverter {
|
||||
_ /* unknownFields */
|
||||
) =>
|
||||
ProvinceC(
|
||||
id = id,
|
||||
id = ProvinceId(id),
|
||||
name = name,
|
||||
neighbors = neighbors.map {
|
||||
case NeighborProto(provinceId, distance, _ /* unknownFields */ ) =>
|
||||
Neighbor(provinceId, distance)
|
||||
Neighbor(ProvinceId(provinceId), distance)
|
||||
}.toVector,
|
||||
rulingFactionId = rulingFactionId,
|
||||
rulingHeroId = rulingHeroId,
|
||||
rulingFactionHeroIds = rulingFactionHeroIds.toVector,
|
||||
battalionIds = battalionIds.toVector,
|
||||
rulingFactionId = rulingFactionId.map(FactionId(_)),
|
||||
rulingHeroId = rulingHeroId.map(HeroId(_)),
|
||||
rulingFactionHeroIds = rulingFactionHeroIds.map(HeroId(_)).toVector,
|
||||
battalionIds = battalionIds.map(BattalionId(_)).toVector,
|
||||
specialBattalionTypeIds = specialBattalionTypes
|
||||
.map(BattalionTypeIdConverter.fromProto)
|
||||
.toVector,
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user