private static BattleInitializationData CreateBuffBaseBattleFromBattleTypeVO(string id, SquadWarBuffBaseData buffBaseData) { BattleInitializationData battleInitializationData = BattleInitializationData.CreateFromBattleTypeVO(id); battleInitializationData.BattleType = BattleType.PveBuffBase; battleInitializationData.Attacker.GuildId = Service.SquadController.StateManager.GetCurrentSquad().SquadID; battleInitializationData.AttackerGuildTroopsAvailable = BattleInitializationData.GetCurrentPlayerGuildTroops(); SquadWarManager warManager = Service.SquadController.WarManager; battleInitializationData.AttackerWarBuffs = warManager.GetBuffBasesOwnedBySquad(battleInitializationData.Attacker.GuildId); battleInitializationData.DefenderWarBuffs = null; SquadWarSquadData squadData = warManager.GetSquadData(SquadWarSquadType.PLAYER_SQUAD); SquadWarSquadData squadData2 = warManager.GetSquadData(SquadWarSquadType.OPPONENT_SQUAD); string ownerId = buffBaseData.OwnerId; if (!string.IsNullOrEmpty(ownerId)) { if (ownerId == squadData2.SquadId) { battleInitializationData.Defender.PlayerFaction = squadData2.Faction; } else if (ownerId == squadData.SquadId) { battleInitializationData.Defender.PlayerFaction = squadData.Faction; } } else { battleInitializationData.Defender.PlayerFaction = FactionType.Smuggler; } battleInitializationData.AttackerEquipment = BattleInitializationData.GetCurrentPlayerEquipment(battleInitializationData.PlanetId); battleInitializationData.DefenderEquipment = null; return(battleInitializationData); }
public static BattleInitializationData CreateFromMemberWarData(SquadMemberWarData memberWarData, Dictionary <string, int> donatedSquadTroops, Dictionary <string, int> champions, FactionType faction, string participantSquadId, List <string> equipment) { BattleInitializationData battleInitializationData = new BattleInitializationData(); battleInitializationData.BattleType = BattleType.PvpAttackSquadWar; CurrentPlayer currentPlayer = Service.CurrentPlayer; battleInitializationData.Attacker = new BattleParticipant(currentPlayer.PlayerId, currentPlayer.PlayerName, currentPlayer.Faction); battleInitializationData.Attacker.GuildId = Service.SquadController.StateManager.GetCurrentSquad().SquadID; battleInitializationData.Defender = new BattleParticipant(memberWarData.SquadMemberId, memberWarData.SquadMemberName, faction); battleInitializationData.Defender.GuildId = participantSquadId; battleInitializationData.AttackerDeployableData = BattleDeploymentData.CreateEmpty(); battleInitializationData.DefenderDeployableData = BattleDeploymentData.CreateEmpty(); battleInitializationData.AllowMultipleHeroDeploys = false; battleInitializationData.OverrideDeployables = false; battleInitializationData.BattleLength = GameConstants.PVP_MATCH_DURATION; battleInitializationData.PlanetId = memberWarData.BaseMap.Planet.Uid; battleInitializationData.MemberWarData = memberWarData; battleInitializationData.VictoryConditions = Service.VictoryConditionController.GetDefaultConditions(); battleInitializationData.DefenderGuildTroopsAvailable = donatedSquadTroops; battleInitializationData.DefenderChampionsAvailable = champions; battleInitializationData.AttackerGuildTroopsAvailable = BattleInitializationData.GetCurrentPlayerGuildTroops(); battleInitializationData.DisabledBuildings = null; battleInitializationData.IsReplay = false; battleInitializationData.IsRevenge = false; battleInitializationData.AllowReplay = true; SquadWarManager warManager = Service.SquadController.WarManager; battleInitializationData.AttackerWarBuffs = warManager.GetBuffBasesOwnedBySquad(battleInitializationData.Attacker.GuildId); battleInitializationData.DefenderWarBuffs = warManager.GetBuffBasesOwnedBySquad(battleInitializationData.Defender.GuildId); battleInitializationData.AttackerEquipment = BattleInitializationData.GetCurrentPlayerEquipment(battleInitializationData.PlanetId); battleInitializationData.DefenderEquipment = equipment; return(battleInitializationData); }
public static BattleInitializationData CreateFromCampaignMissionAndBattle(string id, string battleUid) { StaticDataController staticDataController = Service.StaticDataController; CampaignMissionVO campaignMissionVO = staticDataController.Get <CampaignMissionVO>(id); BattleInitializationData battleInitializationData = BattleInitializationData.CreateFromBattleTypeVO(battleUid); CampaignProgress campaignProgress = Service.CurrentPlayer.CampaignProgress; int missionLootCreditsRemaining = campaignProgress.GetMissionLootCreditsRemaining(campaignMissionVO); int missionLootMaterialsRemaining = campaignProgress.GetMissionLootMaterialsRemaining(campaignMissionVO); int missionLootContrabandRemaining = campaignProgress.GetMissionLootContrabandRemaining(campaignMissionVO); battleInitializationData.MissionUid = campaignMissionVO.Uid; battleInitializationData.LootCreditsAvailable = missionLootCreditsRemaining; battleInitializationData.LootMaterialsAvailable = missionLootMaterialsRemaining; battleInitializationData.LootContrabandAvailable = missionLootContrabandRemaining; battleInitializationData.BattleType = BattleType.PveAttack; battleInitializationData.BattleMusic = campaignMissionVO.BattleMusic; battleInitializationData.AmbientMusic = campaignMissionVO.AmbientMusic; battleInitializationData.BattleVO = staticDataController.Get <BattleTypeVO>(battleUid); battleInitializationData.AllowMultipleHeroDeploys = battleInitializationData.BattleVO.MultipleHeroDeploys; battleInitializationData.OverrideDeployables = battleInitializationData.BattleVO.OverridePlayerUnits; battleInitializationData.VictoryConditions = campaignMissionVO.Conditions; if (!string.IsNullOrEmpty(campaignMissionVO.FailureCondition)) { battleInitializationData.FailureCondition = staticDataController.Get <ConditionVO>(campaignMissionVO.FailureCondition); } battleInitializationData.IsReplay = false; battleInitializationData.IsRevenge = false; battleInitializationData.AllowReplay = false; battleInitializationData.AttackerEquipment = BattleInitializationData.GetCurrentPlayerEquipment(battleInitializationData.PlanetId); battleInitializationData.DefenderEquipment = null; return(battleInitializationData); }
public static BattleInitializationData CreateFromPvpTargetData(PvpTarget target, bool isRevenge) { BattleInitializationData battleInitializationData = new BattleInitializationData(); battleInitializationData.RecordId = target.BattleId; battleInitializationData.BattleType = BattleType.Pvp; CurrentPlayer currentPlayer = Service.CurrentPlayer; battleInitializationData.Attacker = new BattleParticipant(currentPlayer.PlayerId, currentPlayer.PlayerName, currentPlayer.Faction); battleInitializationData.Attacker.AttackRating = currentPlayer.AttackRating; battleInitializationData.Attacker.DefenseRating = currentPlayer.DefenseRating; battleInitializationData.Defender = new BattleParticipant(target.PlayerId, target.PlayerName, target.PlayerFaction); battleInitializationData.Defender.AttackRating = target.PlayerAttackRating; battleInitializationData.Defender.DefenseRating = target.PlayerDefenseRating; battleInitializationData.AttackerDeployableData = BattleDeploymentData.CreateEmpty(); battleInitializationData.DefenderDeployableData = BattleDeploymentData.CreateEmpty(); battleInitializationData.AllowMultipleHeroDeploys = false; battleInitializationData.OverrideDeployables = false; battleInitializationData.BattleLength = GameConstants.PVP_MATCH_DURATION; battleInitializationData.PlanetId = target.BaseMap.Planet.Uid; battleInitializationData.LootCreditsAvailable = target.AvailableCredits; battleInitializationData.LootMaterialsAvailable = target.AvailableMaterials; battleInitializationData.LootContrabandAvailable = target.AvailableContraband; battleInitializationData.BuildingLootCreditsMap = target.BuildingLootCreditsMap; battleInitializationData.BuildingLootMaterialsMap = target.BuildingLootMaterialsMap; battleInitializationData.BuildingLootContrabandMap = target.BuildingLootContrabandMap; battleInitializationData.PvpTarget = target; battleInitializationData.VictoryConditions = Service.VictoryConditionController.GetDefaultConditions(); battleInitializationData.DefenderGuildTroopsAvailable = target.GuildDonatedTroops; battleInitializationData.DefenderChampionsAvailable = target.Champions; battleInitializationData.AttackerGuildTroopsAvailable = BattleInitializationData.GetCurrentPlayerGuildTroops(); battleInitializationData.DisabledBuildings = new List <string>(); for (int i = 0; i < target.Contracts.Count; i++) { if (target.Contracts[i].ContractType == ContractType.Build || target.Contracts[i].ContractType == ContractType.Upgrade) { battleInitializationData.DisabledBuildings.Add(target.Contracts[i].BuildingKey); } } battleInitializationData.IsReplay = false; battleInitializationData.IsRevenge = isRevenge; battleInitializationData.AllowReplay = true; battleInitializationData.AttackerEquipment = BattleInitializationData.GetCurrentPlayerEquipment(battleInitializationData.PlanetId); battleInitializationData.DefenderEquipment = target.Equipment; return(battleInitializationData); }
public static BattleInitializationData CreateFromDefensiveCampaignMissionVO(CampaignMissionVO vo) { StaticDataController staticDataController = Service.StaticDataController; string uid = vo.Uid; BattleInitializationData battleInitializationData = new BattleInitializationData(); CurrentPlayer currentPlayer = Service.CurrentPlayer; battleInitializationData.Attacker = new BattleParticipant(vo.OpponentName, vo.OpponentName, FactionType.Invalid); battleInitializationData.Defender = new BattleParticipant(currentPlayer.PlayerId, currentPlayer.PlayerName, currentPlayer.Faction); battleInitializationData.PlanetId = currentPlayer.Map.Planet.Uid; battleInitializationData.BattleType = BattleType.PveDefend; battleInitializationData.MissionUid = vo.Uid; BattleDeploymentData battleDeploymentData = new BattleDeploymentData(); battleDeploymentData.TroopData = new Dictionary <string, int>(); List <DefenseWave> list = DefensiveBattleController.ParseWaves(vo.Waves); foreach (DefenseWave current in list) { List <DefenseTroopGroup> list2 = DefensiveBattleController.ParseTroopGroups(uid, current.Encounter.WaveGroup, 0); foreach (DefenseTroopGroup current2 in list2) { if (battleDeploymentData.TroopData.ContainsKey(current2.TroopUid)) { Dictionary <string, int> dictionary; string troopUid; (dictionary = battleDeploymentData.TroopData)[troopUid = current2.TroopUid] = dictionary[troopUid] + current2.Quantity; } else { battleDeploymentData.TroopData.Add(current2.TroopUid, current2.Quantity); } } } battleInitializationData.AttackerDeployableData = battleDeploymentData; if (vo.Map != null) { battleInitializationData.BattleVO = staticDataController.Get <BattleTypeVO>(vo.Map); battleInitializationData.AllowMultipleHeroDeploys = (battleInitializationData.BattleVO.MultipleHeroDeploys || vo.IsRaidDefense()); battleInitializationData.OverrideDeployables = battleInitializationData.BattleVO.OverridePlayerUnits; battleInitializationData.BattleLength = battleInitializationData.BattleVO.BattleTime; battleInitializationData.DefenderDeployableData = BattleDeploymentData.Copy(battleInitializationData.BattleVO); } else { battleInitializationData.DefenderDeployableData = BattleDeploymentData.CreateEmpty(); battleInitializationData.AllowMultipleHeroDeploys = vo.IsRaidDefense(); battleInitializationData.OverrideDeployables = false; } Inventory inventory = currentPlayer.Inventory; battleInitializationData.LootCreditsAvailable = inventory.GetItemAmount("credits"); battleInitializationData.LootMaterialsAvailable = inventory.GetItemAmount("materials"); battleInitializationData.LootContrabandAvailable = inventory.GetItemAmount("contraband"); if (battleInitializationData.BattleLength == 0) { battleInitializationData.BattleLength = GameConstants.PVP_MATCH_DURATION; } battleInitializationData.BattleMusic = vo.BattleMusic; battleInitializationData.AmbientMusic = vo.AmbientMusic; battleInitializationData.VictoryConditions = vo.Conditions; if (!string.IsNullOrEmpty(vo.FailureCondition)) { battleInitializationData.FailureCondition = staticDataController.Get <ConditionVO>(vo.FailureCondition); } battleInitializationData.DisabledBuildings = new List <string>(); List <Contract> list3 = Service.ISupportController.FindAllContractsThatConsumeDroids(); for (int i = 0; i < list3.Count; i++) { if (list3[i].DeliveryType != DeliveryType.ClearClearable) { battleInitializationData.DisabledBuildings.Add(list3[i].ContractTO.BuildingKey); } } battleInitializationData.IsReplay = false; battleInitializationData.IsRevenge = false; battleInitializationData.AllowReplay = false; if (vo.IsRaidDefense() && Service.RaidDefenseController.SquadTroopDeployAllowed()) { battleInitializationData.DefenderGuildTroopsAvailable = new Dictionary <string, int>(); List <SquadDonatedTroop> troops = Service.SquadController.StateManager.Troops; for (int j = 0; j < troops.Count; j++) { string troopUid2 = troops[j].TroopUid; int totalAmount = troops[j].GetTotalAmount(); if (battleInitializationData.DefenderGuildTroopsAvailable.ContainsKey(troopUid2)) { Dictionary <string, int> dictionary; string key; (dictionary = battleInitializationData.DefenderGuildTroopsAvailable)[key = troopUid2] = dictionary[key] + totalAmount; } else { battleInitializationData.DefenderGuildTroopsAvailable.Add(troopUid2, totalAmount); } } } battleInitializationData.AttackerEquipment = null; battleInitializationData.DefenderEquipment = BattleInitializationData.GetCurrentPlayerEquipment(battleInitializationData.PlanetId); return(battleInitializationData); }