Example #1
0
        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);
        }
Example #2
0
        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);
        }
Example #3
0
        public static BattleInitializationData CreateFromBattleTypeVO(string id)
        {
            BattleTypeVO             battleTypeVO             = Service.StaticDataController.Get <BattleTypeVO>(id);
            BattleInitializationData battleInitializationData = new BattleInitializationData();

            battleInitializationData.BattleType = BattleType.PveFue;
            CurrentPlayer currentPlayer = Service.CurrentPlayer;

            battleInitializationData.Attacker = new BattleParticipant(currentPlayer.PlayerId, currentPlayer.PlayerName, currentPlayer.Faction);
            battleInitializationData.Defender = new BattleParticipant(battleTypeVO.DefenderId, battleTypeVO.DefenderId, FactionType.Invalid);
            battleInitializationData.BattleVO = battleTypeVO;
            battleInitializationData.AttackerDeployableData   = BattleDeploymentData.Copy(battleTypeVO);
            battleInitializationData.DefenderDeployableData   = BattleDeploymentData.CreateEmpty();
            battleInitializationData.AllowMultipleHeroDeploys = false;
            battleInitializationData.OverrideDeployables      = false;
            battleInitializationData.PlanetId     = battleTypeVO.Planet;
            battleInitializationData.BattleLength = battleTypeVO.BattleTime;
            if (battleInitializationData.BattleLength == 0)
            {
                battleInitializationData.BattleLength = GameConstants.PVP_MATCH_DURATION;
            }
            battleInitializationData.VictoryConditions       = Service.VictoryConditionController.GetDefaultConditions();
            battleInitializationData.IsReplay                = false;
            battleInitializationData.IsRevenge               = false;
            battleInitializationData.DefenseEncounterProfile = battleTypeVO.EncounterProfile;
            battleInitializationData.BattleScript            = battleTypeVO.BattleScript;
            battleInitializationData.AllowReplay             = true;
            battleInitializationData.DisabledBuildings       = new List <string>();
            return(battleInitializationData);
        }
Example #4
0
        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);
        }
Example #5
0
        public static BattleInitializationData CreateFromCampaignMissionVO(string id)
        {
            StaticDataController staticDataController = Service.StaticDataController;
            CampaignMissionVO    campaignMissionVO    = staticDataController.Get <CampaignMissionVO>(id);

            return(BattleInitializationData.CreateFromCampaignMissionAndBattle(id, campaignMissionVO.Map));
        }
Example #6
0
        public static BattleInitializationData CreateFromDefensiveCampaignMissionVO(string id)
        {
            StaticDataController staticDataController = Service.StaticDataController;
            CampaignMissionVO    vo = staticDataController.Get <CampaignMissionVO>(id);

            return(BattleInitializationData.CreateFromDefensiveCampaignMissionVO(vo));
        }
Example #7
0
        public static BattleInitializationData CreateFromReplay(BattleRecord battleRecord, BattleEntry battleEntry)
        {
            BattleInitializationData battleInitializationData = new BattleInitializationData();

            battleInitializationData.RecordId                  = battleRecord.RecordId;
            battleInitializationData.BattleType                = battleRecord.BattleType;
            battleInitializationData.AttackerDeployableData    = battleRecord.AttackerDeploymentData;
            battleInitializationData.DefenderDeployableData    = battleRecord.DefenderDeploymentData;
            battleInitializationData.AllowMultipleHeroDeploys  = false;
            battleInitializationData.OverrideDeployables       = true;
            battleInitializationData.LootCreditsAvailable      = battleRecord.LootCreditsAvailable;
            battleInitializationData.LootMaterialsAvailable    = battleRecord.LootMaterialsAvailable;
            battleInitializationData.LootContrabandAvailable   = battleRecord.LootContrabandAvailable;
            battleInitializationData.BuildingLootCreditsMap    = battleRecord.BuildingLootCreditsMap;
            battleInitializationData.BuildingLootMaterialsMap  = battleRecord.BuildingLootMaterialsMap;
            battleInitializationData.BuildingLootContrabandMap = battleRecord.BuildingLootContrabandMap;
            battleInitializationData.LootCreditsEarned         = battleEntry.LootCreditsEarned;
            battleInitializationData.LootMaterialsEarned       = battleEntry.LootMaterialsEarned;
            battleInitializationData.LootContrabandEarned      = battleEntry.LootContrabandEarned;
            battleInitializationData.LootCreditsDeducted       = battleEntry.LootCreditsDeducted;
            battleInitializationData.LootMaterialsDeducted     = battleEntry.LootMaterialsDeducted;
            battleInitializationData.LootContrabandDeducted    = battleEntry.LootContrabandDeducted;
            battleInitializationData.Attacker                  = battleEntry.Attacker;
            battleInitializationData.Defender                  = battleEntry.Defender;
            battleInitializationData.PlanetId                  = battleRecord.PlanetId;
            battleInitializationData.BattleLength              = battleRecord.BattleLength;
            StaticDataController staticDataController = Service.StaticDataController;

            battleInitializationData.VictoryConditions = new List <ConditionVO>();
            int i     = 0;
            int count = battleRecord.victoryConditionsUids.Count;

            while (i < count)
            {
                battleInitializationData.VictoryConditions.Add(staticDataController.Get <ConditionVO>(battleRecord.victoryConditionsUids[i]));
                i++;
            }
            battleInitializationData.FailureCondition             = ((!string.IsNullOrEmpty(battleRecord.failureConditionUid)) ? staticDataController.Get <ConditionVO>(battleRecord.failureConditionUid) : null);
            battleInitializationData.DefenderGuildTroopsAvailable = battleRecord.DefenderGuildTroops;
            battleInitializationData.AttackerGuildTroopsAvailable = battleRecord.AttackerGuildTroops;
            battleInitializationData.DefenderChampionsAvailable   = battleRecord.DefenderChampions;
            battleInitializationData.DisabledBuildings            = battleRecord.DisabledBuildings;
            battleInitializationData.IsReplay  = true;
            battleInitializationData.IsRevenge = false;
            battleInitializationData.DefenseEncounterProfile = battleRecord.DefenseEncounterProfile;
            battleInitializationData.BattleScript            = battleRecord.BattleScript;
            battleInitializationData.AllowReplay             = false;
            battleInitializationData.AttackerWarBuffs        = battleRecord.AttackerWarBuffs;
            battleInitializationData.DefenderWarBuffs        = battleRecord.DefenderWarBuffs;
            battleInitializationData.AttackerEquipment       = battleRecord.AttackerEquipment;
            battleInitializationData.DefenderEquipment       = battleRecord.DefenderEquipment;
            return(battleInitializationData);
        }
Example #8
0
        public static BattleInitializationData CreateBuffBaseBattleFromCampaignMissionVO(CampaignMissionVO vo, SquadWarBuffBaseData buffBaseData)
        {
            StaticDataController     staticDataController     = Service.StaticDataController;
            BattleInitializationData battleInitializationData = BattleInitializationData.CreateBuffBaseBattleFromBattleTypeVO(vo.Map, buffBaseData);

            battleInitializationData.MissionUid        = vo.Uid;
            battleInitializationData.BattleMusic       = vo.BattleMusic;
            battleInitializationData.AmbientMusic      = vo.AmbientMusic;
            battleInitializationData.VictoryConditions = vo.Conditions;
            if (!string.IsNullOrEmpty(vo.FailureCondition))
            {
                battleInitializationData.FailureCondition = staticDataController.Get <ConditionVO>(vo.FailureCondition);
            }
            return(battleInitializationData);
        }
Example #9
0
        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);
        }
Example #10
0
        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);
        }