Ejemplo n.º 1
0
        public static List <IAssetVO> GetBattleRecordPreloads(BattleRecord battleRecord)
        {
            List <IAssetVO> list = new List <IAssetVO>();

            if (battleRecord == null)
            {
                Service.Logger.Error("Battle Record is null in MapDataLoaderUtils.GetBattleRecordPreloads.");
                return(list);
            }
            StaticDataController staticDataController   = Service.StaticDataController;
            SkinController       skinController         = Service.SkinController;
            BattleDeploymentData attackerDeploymentData = battleRecord.AttackerDeploymentData;

            if (attackerDeploymentData != null)
            {
                MapDataLoaderUtils.AddDeployablesToList <TroopTypeVO>(attackerDeploymentData.TroopData, list, battleRecord.AttackerEquipment, staticDataController, skinController);
                MapDataLoaderUtils.AddDeployablesToList <SpecialAttackTypeVO>(attackerDeploymentData.SpecialAttackData, list, battleRecord.AttackerEquipment, staticDataController, skinController);
                MapDataLoaderUtils.AddDeployablesToList <TroopTypeVO>(attackerDeploymentData.HeroData, list, battleRecord.AttackerEquipment, staticDataController, skinController);
                MapDataLoaderUtils.AddDeployablesToList <TroopTypeVO>(attackerDeploymentData.ChampionData, list, battleRecord.AttackerEquipment, staticDataController, skinController);
            }
            BattleDeploymentData defenderDeploymentData = battleRecord.DefenderDeploymentData;

            if (defenderDeploymentData != null)
            {
                MapDataLoaderUtils.AddDeployablesToList <TroopTypeVO>(defenderDeploymentData.TroopData, list, battleRecord.DefenderEquipment, staticDataController, skinController);
                MapDataLoaderUtils.AddDeployablesToList <SpecialAttackTypeVO>(defenderDeploymentData.SpecialAttackData, list, battleRecord.DefenderEquipment, staticDataController, skinController);
                MapDataLoaderUtils.AddDeployablesToList <TroopTypeVO>(defenderDeploymentData.HeroData, list, battleRecord.DefenderEquipment, staticDataController, skinController);
                MapDataLoaderUtils.AddDeployablesToList <TroopTypeVO>(defenderDeploymentData.ChampionData, list, battleRecord.DefenderEquipment, staticDataController, skinController);
            }
            MapDataLoaderUtils.AddFXPreloads(list);
            return(list);
        }
Ejemplo n.º 2
0
        public EatResponse OnEvent(EventId id, object cookie)
        {
            IState currentState = Service.Get <GameStateMachine>().CurrentState;

            if (id != EventId.WorldLoadComplete)
            {
                if (id == EventId.GameStateChanged)
                {
                    Type type = (Type)cookie;
                    if (currentState is BattleStartState || currentState is BattlePlayState)
                    {
                        this.Stop(false);
                    }
                    else if (currentState is EditBaseState)
                    {
                        this.Stop(true);
                    }
                    else if (currentState is HomeState && type == typeof(EditBaseState))
                    {
                        this.Start();
                    }
                }
            }
            else if (currentState is BattlePlaybackState)
            {
                BattleRecord currentBattleRecord = Service.Get <BattlePlaybackController>().CurrentBattleRecord;
                this.FastForwardTrackingAfterWorldLoad(currentBattleRecord.ViewTimePassedPreBattle);
            }
            else
            {
                this.Start();
            }
            return(EatResponse.NotEaten);
        }
Ejemplo n.º 3
0
        public static void GoToBattlePlaybackState(BattleRecord battleRecord, BattleEntry battleEntry, IMapDataLoader mapDataLoader)
        {
            BattlePlaybackState battlePlaybackState = new BattlePlaybackState();

            Service.Get <BattlePlaybackController>().InitPlayback(battleRecord, battleEntry);
            battlePlaybackState.Setup(battleRecord, battleEntry, mapDataLoader);
        }
Ejemplo n.º 4
0
        public static List <IAssetVO> GetBattleRecordProjectileAssets(Map map, BattleRecord battleRecord, List <string> attackerWarBuffs, List <string> defenderWarBuffs, List <string> attackerEquipment, List <string> defenderEquipment)
        {
            IDataController      dc   = Service.Get <IDataController>();
            List <IAssetVO>      list = new List <IAssetVO>();
            BattleDeploymentData attackerDeploymentData = battleRecord.AttackerDeploymentData;

            if (attackerDeploymentData != null)
            {
                ProjectileUtils.AddTroopProjectileAssets(attackerDeploymentData.TroopData, list, dc);
                ProjectileUtils.AddSpecialAttackProjectileAssets(attackerDeploymentData.SpecialAttackData, list, dc);
                ProjectileUtils.AddTroopProjectileAssets(attackerDeploymentData.HeroData, list, dc);
                ProjectileUtils.AddTroopProjectileAssets(attackerDeploymentData.ChampionData, list, dc);
            }
            BattleDeploymentData defenderDeploymentData = battleRecord.DefenderDeploymentData;

            if (defenderDeploymentData != null)
            {
                ProjectileUtils.AddTroopProjectileAssets(defenderDeploymentData.TroopData, list, dc);
                ProjectileUtils.AddSpecialAttackProjectileAssets(defenderDeploymentData.SpecialAttackData, list, dc);
                ProjectileUtils.AddTroopProjectileAssets(defenderDeploymentData.HeroData, list, dc);
                ProjectileUtils.AddTroopProjectileAssets(defenderDeploymentData.ChampionData, list, dc);
            }
            Dictionary <string, int> attackerGuildTroops = battleRecord.AttackerGuildTroops;

            ProjectileUtils.AddTroopProjectileAssets(attackerGuildTroops, list, dc);
            Dictionary <string, int> defenderGuildTroops = battleRecord.DefenderGuildTroops;

            ProjectileUtils.AddTroopProjectileAssets(defenderGuildTroops, list, dc);
            Dictionary <string, int> defenderChampions = battleRecord.DefenderChampions;

            ProjectileUtils.AddTroopProjectileAssets(defenderChampions, list, dc);
            ProjectileUtils.AddBattleProjectileAssets(map, null, null, attackerWarBuffs, defenderWarBuffs, attackerEquipment, defenderEquipment, list, dc);
            return(list);
        }
Ejemplo n.º 5
0
 private void RegisterButton_Click(object sender, EventArgs e)
 {
     using (var dbManager = new DBManager())
     {
         try
         {
             var record = new BattleRecord(
                 dbManager.executeQuery <int>("SELECT TOP(1) id FROM battle_records ORDER BY id DESC").FirstOrDefault() + 1,
                 ((Nationality)NationalityComboBox.SelectedItem).id,
                 ((PokemonModel)PartyComboBox1.SelectedItem).id,
                 ((PokemonModel)PartyComboBox2.SelectedItem).id,
                 ((PokemonModel)PartyComboBox3.SelectedItem).id,
                 ((PokemonModel)PartyComboBox4.SelectedItem).id,
                 ((PokemonModel)PartyComboBox5.SelectedItem).id,
                 ((PokemonModel)PartyComboBox6.SelectedItem).id,
                 ((PokemonModel)ElectComboBox1.SelectedItem).id,
                 ((PokemonModel)ElectComboBox2.SelectedItem).id,
                 ((PokemonModel)ElectComboBox3.SelectedItem).id,
                 WinRadioButton.Checked ? "null" : ((DefeatReason)DefeatReasonComboBox.SelectedItem).id.ToString(),
                 BattleMemoTextBox.Text,
                 BattleStyleFreeRadioButton.Checked ? 0 : 1,
                 WinRadioButton.Checked ? 0 : 1
                 );
             dbManager.insertSQL(record);
             MessageBox.Show("登録完了");
         }
         catch (Exception ex)
         {
             MessageBox.Show($"システムエラーが発生しました{ex}");
         }
     }
 }
        public void InitPlayback(BattleRecord battleRecord, BattleEntry battleEntry)
        {
            this.CurrentBattleRecord = battleRecord;
            this.CurrentBattleEntry  = battleEntry;
            BattleInitializationData battleInitializationData = BattleInitializationData.CreateFromReplay(this.CurrentBattleRecord, this.CurrentBattleEntry);

            this.battleController.InitializeCurrentBattle(battleInitializationData);
        }
Ejemplo n.º 7
0
    public void CreateRecord( )
    {
        BattleRecord record = new BattleRecord( );

        PBattleRecords.Add(record);

        CurrentIdx = PBattleRecords.Count - 1;
    }
Ejemplo n.º 8
0
        public void insertSQL(BattleRecord record)
        {
            var sql = $"INSERT INTO battle_records VALUES ({record.id},{record.nationality},{record.partyPokemon1},{record.partyPokemon2},{record.partyPokemon3}," +
                      $"{record.partyPokemon4},{record.partyPokemon5},{record.partyPokemon6},{record.electedPokemon1},{record.electedPokemon2},{record.electedPokemon3}," +
                      $"{record.defeatReason},'{record.memo}',{record.battleRule},{record.result})";

            executeSQL(sql);
        }
Ejemplo n.º 9
0
 public ReplayMapDataLoader InitializeFromData(BattleEntry battleEntry, BattleRecord battleRecord)
 {
     this.replayResponseData            = new GetReplayResponse();
     this.replayResponseData.EntryData  = battleEntry;
     this.replayResponseData.ReplayData = battleRecord;
     this.defender            = battleEntry.Defender;
     this.replayOwnerPlayerId = null;
     return(this);
 }
Ejemplo n.º 10
0
    public static void RecordTurn(int turn)
    {
        BattleRecord record = BattleRecordController.Instance.GetCurrentRecord();

        if (record != null)
        {
            record.Turn = turn;
        }
    }
Ejemplo n.º 11
0
    public static void RecrodIsLeft(bool isLeft)
    {
        BattleRecord record = BattleRecordController.Instance.GetCurrentRecord();

        if (record != null)
        {
            record.IsLeft = isLeft;
        }
    }
Ejemplo n.º 12
0
        public override BattleRecord applyWhenTurnOver()
        {
            AffectedRounds -= 1;

            Owner.HP += 2;
            BattleRecord msg = new BattleRecord(Owner, Target, "#from# was healed by 2 HP");

            return(msg);
        }
Ejemplo n.º 13
0
    public static void RecordSlot(Slot attackerSlot, Slot defenderSlot)
    {
        BattleRecord record = BattleRecordController.Instance.GetCurrentRecord();

        if (record != null)
        {
            record.AttackerSlot.Update(attackerSlot);
            record.DefenderSlot.Update(defenderSlot);
        }
    }
Ejemplo n.º 14
0
        public void LoadMapData(MapLoadedDelegate onMapLoaded, MapLoadFailDelegate onMapLoadFail)
        {
            BattleRecord battleRecord = this.replayResponseData.GetOriginalReplayRecord();

            if (battleRecord == null)
            {
                battleRecord = this.replayResponseData.ReplayData;
            }
            onMapLoaded(battleRecord.CombatEncounter.map);
        }
Ejemplo n.º 15
0
        public List <IAssetVO> GetPreloads()
        {
            BattleRecord battleRecord = null;

            if (this.replayResponseData != null)
            {
                battleRecord = this.replayResponseData.ReplayData;
            }
            return(MapDataLoaderUtils.GetBattleRecordPreloads(battleRecord));
        }
Ejemplo n.º 16
0
        public override BattleRecord applyAfterAttack(BattleRecord record)
        {
            int suck = record.Damage / 4;
            int hp   = record.From.HP;

            record.From.HP += suck;

            Console.WriteLine("{0} sucked {1} HP and healed {2} HP.", record.From.Name, suck, record.From.HP - hp);

            return(base.applyAfterAttack(record));
        }
Ejemplo n.º 17
0
 protected void Setup(BattleRecord battleRecord, BattleEntry battleEntry, IMapDataLoader mapDataLoader)
 {
     this.battleRecord = battleRecord;
     this.battleEntry  = battleEntry;
     if (battleRecord != null)
     {
         Service.Get <EventManager>().SendEvent(EventId.BattleReplaySetup, battleRecord);
     }
     Service.Get <EventManager>().RegisterObserver(this, EventId.MapDataProcessingStart, EventPriority.Default);
     Service.Get <WorldTransitioner>().StartTransition(new WorldToWorldTransition(this, mapDataLoader, new TransitionCompleteDelegate(this.OnWorldTransitionComplete), false, true));
 }
        private void ReplayLastBattleOrReplay()
        {
            CurrentBattle       currentBattle       = Service.Get <BattleController>().GetCurrentBattle();
            ReplayMapDataLoader replayMapDataLoader = Service.Get <ReplayMapDataLoader>();
            BattleRecord        battleRecord        = Service.Get <BattleRecordController>().BattleRecord;
            BattleEntry         battleEntry         = currentBattle.Clone();

            replayMapDataLoader.InitializeFromData(battleEntry, battleRecord);
            BattlePlaybackState.GoToBattlePlaybackState(battleRecord, battleEntry, replayMapDataLoader);
            this.LogReplayViewed(battleEntry.RecordID, battleEntry.Defender.PlayerId, battleEntry.SharerPlayerId);
        }
Ejemplo n.º 19
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);
        }
Ejemplo n.º 20
0
    public static void RecordAttackInfo(int damage, bool dodge, bool blocked, bool crit)
    {
        BattleRecord record = BattleRecordController.Instance.GetCurrentRecord();

        if (record != null)
        {
            record.Damage  = damage;
            record.Dodged  = dodge;
            record.Blocked = blocked;
            record.Crit    = crit;
        }
    }
Ejemplo n.º 21
0
        public void OnReplayLoaded(GetReplayResponse response, object cookie)
        {
            ProcessingScreen.Hide();
            this.replayResponseData = response;
            BattlePlaybackState.GoToBattlePlaybackState(this);
            BattleRecord replayData = response.ReplayData;
            BattleEntry  entryData  = response.EntryData;

            replayData.RecordId      = entryData.RecordID;
            entryData.SharerPlayerId = this.replayOwnerPlayerId;
            bool flag = Service.Get <CurrentPlayer>().PlayerId == entryData.AttackerID || this.replayOwnerPlayerId == entryData.AttackerID;

            entryData.Won = (flag ? (entryData.EarnedStars > 0) : (entryData.EarnedStars == 0));
            Service.Get <EventManager>().SendEvent(EventId.BattleRecordRetrieved, this.replayResponseData);
        }
Ejemplo n.º 22
0
 public BattleEndRequest(CurrentBattle battle, Dictionary <string, int> seededTroopsDeployed, Dictionary <string, int> defendingUnitsKilled, Dictionary <string, int> attackingUnitsKilled, Dictionary <string, int> defenderGuildUnitsSpent, Dictionary <string, int> attackerGuildUnitsSpent, Dictionary <string, int> lootEarned, Dictionary <string, int> buildingHealthMap, Dictionary <string, string> buildingUids, List <string> unarmedTraps, BattleRecord replayData)
 {
     this.battle = battle;
     this.seededTroopsDeployed    = seededTroopsDeployed;
     this.defendingUnitsKilled    = defendingUnitsKilled;
     this.attackingUnitsKilled    = attackingUnitsKilled;
     this.defenderGuildUnitsSpent = ((defenderGuildUnitsSpent == null) ? new Dictionary <string, int>() : defenderGuildUnitsSpent);
     this.attackerGuildUnitsSpent = ((attackerGuildUnitsSpent == null) ? new Dictionary <string, int>() : attackerGuildUnitsSpent);
     this.lootEarned        = ((lootEarned == null) ? new Dictionary <string, int>() : lootEarned);
     this.buildingHealthMap = buildingHealthMap;
     this.buildingUids      = buildingUids;
     this.unarmedTraps      = ((unarmedTraps == null) ? new List <string>() : unarmedTraps);
     this.replayData        = replayData;
     this.planetId          = Service.CurrentPlayer.PlanetId;
 }
Ejemplo n.º 23
0
 public EatResponse OnEvent(EventId id, object cookie)
 {
     if (id != EventId.MapDataProcessingStart)
     {
         if (id == EventId.BattleRecordRetrieved)
         {
             GetReplayResponse getReplayResponse = (GetReplayResponse)cookie;
             this.battleRecord = getReplayResponse.ReplayData;
             this.battleEntry  = getReplayResponse.EntryData;
             Service.Get <BattlePlaybackController>().InitPlayback(this.battleRecord, this.battleEntry);
         }
     }
     else
     {
         this.OnMapProcessingStart();
         Service.Get <EventManager>().UnregisterObserver(this, EventId.MapDataProcessingStart);
     }
     return(EatResponse.NotEaten);
 }
Ejemplo n.º 24
0
    public void ShowDamage( )
    {
        BattleRecord record = UIBattleController.Instance.GetCurrentRecord();

        ShowText(record.Damage);

        //Reduce health
        UIHealthBar hpBar = CurrentDefender.GetComponent <UIHealthBar>();

        hpBar.updateHP(record.DefenderSlot.CharHealth);

        if (record.DefenderSlot.CharHealth <= 0)
        {
            // PLay die animation
            StartCoroutine(WaitToDie(CurrentDefender.gameObject));
        }

        StartCoroutine(WaitForNextTurn());
    }
Ejemplo n.º 25
0
    public void NextAction( )
    {
        if (CurrentRecordIndex >= Records.Count)
        {
            //on END GAME
            return;
        }

        BattleRecord record = Records[CurrentRecordIndex];

        Transform attackerDeployment = record.IsLeft ? DeploymentLeft : DeploymentRight;
        Transform defenderDeployment = record.IsLeft ? DeploymentRight : DeploymentLeft;

        Transform attacker = GetCharacterInCell(attackerDeployment, record.AttackerSlot.Index,
                                                record.AttackerSlot.Charname);

        Transform defender = GetCharacterInCell(defenderDeployment, record.DefenderSlot.Index,
                                                record.DefenderSlot.Charname);

        BattleActionController.Instance.StartAction(attacker, defender, record.IsLeft);
    }
Ejemplo n.º 26
0
 public EatResponse OnEvent(EventId id, object cookie)
 {
     if (id <= EventId.BattleEndFullyProcessed)
     {
         if (id != EventId.BattleLoadStart)
         {
             if (id != EventId.BattleEndFullyProcessed)
             {
                 return(EatResponse.NotEaten);
             }
         }
         else
         {
             if (this.controller.WarManager.CurrentSquadWar != null)
             {
                 CurrentBattle currentBattle = Service.Get <BattleController>().GetCurrentBattle();
                 SquadWarBuffManager.AddWarBuffs(currentBattle.Type, currentBattle.AttackerWarBuffs, currentBattle.DefenderWarBuffs);
                 return(EatResponse.NotEaten);
             }
             return(EatResponse.NotEaten);
         }
     }
     else
     {
         if (id == EventId.BattleReplaySetup)
         {
             BattleRecord battleRecord = (BattleRecord)cookie;
             SquadWarBuffManager.AddWarBuffs(battleRecord.BattleType, battleRecord.AttackerWarBuffs, battleRecord.DefenderWarBuffs);
             return(EatResponse.NotEaten);
         }
         if (id != EventId.BattleLeftBeforeStarting)
         {
             return(EatResponse.NotEaten);
         }
     }
     Service.Get <BuffController>().ClearWarBuffs();
     return(EatResponse.NotEaten);
 }
Ejemplo n.º 27
0
        public EatResponse OnEvent(EventId id, object cookie)
        {
            switch (id)
            {
            case EventId.BattleReplaySetup:
            {
                BattleRecord battleRecord = (BattleRecord)cookie;
                SquadWarBuffManager.AddWarBuffs(battleRecord.BattleType, battleRecord.AttackerWarBuffs, battleRecord.DefenderWarBuffs);
                return(EatResponse.NotEaten);
            }

            case EventId.BattleRecordRetrieved:
IL_18:
                if (id == EventId.BattleLoadStart)
                {
                    if (this.controller.WarManager.CurrentSquadWar != null)
                    {
                        CurrentBattle currentBattle = Service.BattleController.GetCurrentBattle();
                        SquadWarBuffManager.AddWarBuffs(currentBattle.Type, currentBattle.AttackerWarBuffs, currentBattle.DefenderWarBuffs);
                    }
                    return(EatResponse.NotEaten);
                }
                if (id != EventId.BattleEndFullyProcessed)
                {
                    return(EatResponse.NotEaten);
                }
                goto IL_92;

            case EventId.BattleLeftBeforeStarting:
                goto IL_92;
            }
            goto IL_18;
IL_92:
            Service.BuffController.ClearWarBuffs();
            return(EatResponse.NotEaten);
        }
Ejemplo n.º 28
0
        public List <BattleRecord> SelectBattleRecords()
        {
            StringBuilder query = new StringBuilder();

            query.AppendLine("SELECT");
            query.AppendLine("record.battle_record_id,");
            query.AppendLine("my_party.battle_result_id AS result,");
            query.AppendLine("CASE WHEN");
            query.AppendLine("  EXISTS (SELECT * FROM trainer_master WHERE trainer_id = my_party.trainer_id)");
            query.AppendLine("  THEN (SELECT name FROM trainer_master WHERE trainer_id = my_party.trainer_id)");
            query.AppendLine("  ELSE ''");
            query.AppendLine("  END my_trainer_name,");

            query.AppendLine("(");
            query.AppendLine("  SELECT");
            query.AppendLine("  GROUP_CONCAT(pokemon_id)");
            query.AppendLine("  FROM battle_pokemons");
            query.AppendLine("  WHERE battle_party_id = my_party.battle_party_id");
            query.AppendLine(") AS my_pokemon_id,");

            query.AppendLine("(");
            query.AppendLine("  SELECT");
            query.AppendLine("  GROUP_CONCAT(pokemon_icon_id)");
            query.AppendLine("  FROM battle_pokemons");
            query.AppendLine("  WHERE battle_party_id = my_party.battle_party_id");
            query.AppendLine(") AS my_pokemon_icon_id,");

            query.AppendLine("(");
            query.AppendLine("  SELECT");
            query.AppendLine("  GROUP_CONCAT(election)");
            query.AppendLine("  FROM battle_pokemons");
            query.AppendLine("  WHERE battle_party_id = my_party.battle_party_id");
            query.AppendLine(") AS my_election,");

            query.AppendLine("CASE WHEN");
            query.AppendLine("  EXISTS (SELECT * FROM trainer_master WHERE trainer_id = opponent_party.trainer_id)");
            query.AppendLine("  THEN (SELECT name FROM trainer_master WHERE trainer_id = opponent_party.trainer_id)");
            query.AppendLine("  ELSE ''");
            query.AppendLine("  END my_trainer_name,");

            query.AppendLine("(");
            query.AppendLine("  SELECT");
            query.AppendLine("  GROUP_CONCAT(pokemon_id)");
            query.AppendLine("  FROM battle_pokemons");
            query.AppendLine("  WHERE battle_party_id = opponent_party.battle_party_id");
            query.AppendLine(") AS opponent_pokemon_id,");

            query.AppendLine("(");
            query.AppendLine("  SELECT");
            query.AppendLine("  GROUP_CONCAT(pokemon_icon_id)");
            query.AppendLine("  FROM battle_pokemons");
            query.AppendLine("  WHERE battle_party_id = opponent_party.battle_party_id");
            query.AppendLine(") AS opponent_pokemon_icon_id,");
            query.AppendLine("(");
            query.AppendLine("  SELECT");
            query.AppendLine("  GROUP_CONCAT(election)");
            query.AppendLine("  FROM battle_pokemons");
            query.AppendLine("  WHERE battle_party_id = opponent_party.battle_party_id");
            query.AppendLine(") AS opponent_election,");
            query.AppendLine("record.insert_at");
            query.AppendLine("FROM");
            query.AppendLine(" battle_records AS record");
            query.AppendLine(" INNER JOIN battle_parties AS my_party");
            query.AppendLine(" ON record.battle_record_id = my_party.battle_record_id");
            query.AppendLine(" INNER JOIN battle_parties AS opponent_party");
            query.AppendLine(" ON record.battle_record_id = opponent_party.battle_record_id AND");
            query.AppendLine(" opponent_party.battle_party_id <> my_party.battle_party_id");
            query.AppendLine("WHERE (1=1)");



            string query1 = @"
                SELECT
                record.battle_record_id,
                my_party.battle_result_id AS result,

                CASE WHEN
                    EXISTS (SELECT * FROM trainer_master WHERE trainer_id = my_party.trainer_id)
                    THEN (SELECT name FROM trainer_master WHERE trainer_id = my_party.trainer_id)
                    ELSE ''
                    END my_trainer_name,

                (
                    SELECT
                    GROUP_CONCAT(pokemon_icon_id)
                    FROM battle_pokemons
                    WHERE battle_party_id = my_party.battle_party_id
                ) AS my_pokemon_icon_id,

                (
                    SELECT
                    GROUP_CONCAT(election)
                    FROM battle_pokemons
                    WHERE battle_party_id = my_party.battle_party_id
                ) AS my_election,

                CASE WHEN
                    EXISTS (SELECT * FROM trainer_master WHERE trainer_id = opponent_party.trainer_id)
                    THEN (SELECT name FROM trainer_master WHERE trainer_id = opponent_party.trainer_id)
                    ELSE ''
                    END opponent_trainer_name,

                (
                    SELECT
                    GROUP_CONCAT(pokemon_icon_id)
                    FROM battle_pokemons
                    WHERE battle_party_id = opponent_party.battle_party_id
                ) AS opponent_pokemon_icon_id,

                (
                    SELECT
                    GROUP_CONCAT(election)
                    FROM battle_pokemons
                    WHERE battle_party_id = opponent_party.battle_party_id
                ) AS opponent_election,

                record.insert_at

                FROM
                    battle_records AS record
                    INNER JOIN battle_parties AS my_party
                    ON record.battle_record_id = my_party.battle_record_id
                    INNER JOIN battle_parties AS opponent_party
                    ON record.battle_record_id = opponent_party.battle_record_id AND
                    opponent_party.battle_party_id <> my_party.battle_party_id
                WHERE (1=1)
            ";

            // トレーナー指定
            if (IsWhereTrainerId)
            {
                string addQuery = string.Format(" AND my_party.trainer_id = {0} ", TrainerId);
                query.AppendLine(addQuery);
            }

            // 勝敗条件
            if (IsWhereBattleResultId)
            {
                string addQuery = string.Format(" AND my_party.battle_result_id = {0} ", BattleResultId);
                query.AppendLine(addQuery);
            }

            // having
            StringBuilder havingQuery = new StringBuilder();

            // 自分のパーティー
            foreach (int myPokemonId in MyPokemonIdList)
            {
                // 存在しなければ飛ばす
                if (!ImageFactoryModel.ExistPokemonImage(myPokemonId))
                {
                    continue;
                }

                havingQuery.AppendLine("AND FIND_IN_SET(");
                havingQuery.AppendLine("   (SELECT");
                havingQuery.AppendLine("       pokemon_id");
                havingQuery.AppendLine("   FROM");
                havingQuery.AppendLine("       pokemon_icon_master");
                havingQuery.AppendLine("   WHERE");
                havingQuery.AppendLine(string.Format("pokemon_icon_id = {0}),", myPokemonId));
                havingQuery.AppendLine("my_pokemon_id)");
            }

            // 相手のパーティー
            foreach (int opponentPokemonId in OpponentPokemonIdList)
            {
                // 存在しなければ飛ばす
                if (!ImageFactoryModel.ExistPokemonImage(opponentPokemonId))
                {
                    continue;
                }

                havingQuery.AppendLine("AND FIND_IN_SET(");
                havingQuery.AppendLine("   (SELECT");
                havingQuery.AppendLine("       pokemon_id");
                havingQuery.AppendLine("   FROM");
                havingQuery.AppendLine("       pokemon_icon_master");
                havingQuery.AppendLine("   WHERE");
                havingQuery.AppendLine(string.Format("pokemon_icon_id = {0}),", opponentPokemonId));
                havingQuery.AppendLine("opponent_pokemon_id)");
            }

            // having句追加
            if (havingQuery.Length > 0)
            {
                query.AppendLine("HAVING (1=1)");
                query.AppendLine(havingQuery.ToString());
            }

            //// レコードが重複するので削除
            //query.AppendLine("GROUP BY record.battle_record_id");

            // ソート
            query.AppendLine("ORDER BY record.insert_at DESC");

            // 取得件数
            query.AppendLine(string.Format(" LIMIT {0} ", BattleRecordNumber));

            var data = Select(query.ToString());

            List <BattleRecord> BattleRecordList = new List <BattleRecord>();

            foreach (DataRow dataRow in data.Rows)
            {
                // 構造体に入れる
                BattleRecord battleRecord = new BattleRecord();

                battleRecord.BattleRecordId = ObjectConverter.ToInt(dataRow[0]);
                battleRecord.BattleResultId = ObjectConverter.ToInt(dataRow[1]);

                // 自分のトレーナー名
                battleRecord.MyTrainerName = ObjectConverter.ToString(dataRow[2]);

                // 自分のパーティー
                ObjectConverter.ToString(dataRow[4])
                .Split(',')
                .Select((id, index) => new { Id = ObjectConverter.ToInt(id), Index = index })
                .ToList().ForEach(e => battleRecord.ChangeMyPokemonId(e.Index, e.Id));

                // 自分のオーダー
                ObjectConverter.ToString(dataRow[5])
                .Split(',')
                .Select((order, index) => new { Order = ObjectConverter.ToInt(order), Index = index })
                .ToList().ForEach(e => battleRecord.ChangeMyPokemonOrder(e.Index, e.Order));

                // 相手のトレーナー名
                battleRecord.OpponentTrainerName = ObjectConverter.ToString(dataRow[6]);


                // 相手のパーティー
                ObjectConverter.ToString(dataRow[8])
                .Split(',')
                .Select((id, index) => new { Id = ObjectConverter.ToInt(id), Index = index })
                .ToList().ForEach(e => battleRecord.ChangeOpponentPokemonId(e.Index, e.Id));

                // 相手のオーダー
                ObjectConverter.ToString(dataRow[9])
                .Split(',')
                .Select((order, index) => new { Order = ObjectConverter.ToInt(order), Index = index })
                .ToList().ForEach(e => battleRecord.ChangeOpponentPokemonOrder(e.Index, e.Order));

                BattleRecordList.Add(battleRecord);
            }

            return(BattleRecordList);
        }
Ejemplo n.º 29
0
        protected override void SetupView()
        {
            base.GetElement <UXElement>("ReplayResults").Visible     = false;
            base.GetElement <UXButton>("ButtonReplayBattle").Visible = false;
            this.lastBattle = null;
            this.battleType = BattleType.ClientBattle;
            if (this.isReplay)
            {
                this.lastBattle = Service.Get <BattlePlaybackController>().CurrentBattleEntry;
                BattleRecord currentBattleRecord = Service.Get <BattlePlaybackController>().CurrentBattleRecord;
                this.battleType = ((currentBattleRecord != null) ? currentBattleRecord.BattleType : BattleType.ClientBattle);
            }
            else
            {
                CurrentBattle currentBattle = Service.Get <BattleController>().GetCurrentBattle();
                this.lastBattle = currentBattle;
                this.battleType = ((currentBattle != null) ? currentBattle.Type : BattleType.ClientBattle);
            }
            if (this.lastBattle == null)
            {
                Service.Get <StaRTSLogger>().Error("Last battle is null");
                return;
            }
            base.GetElement <UXLabel>("LabelPercentageSquadWar").Text = this.lang.Get("PERCENTAGE", new object[]
            {
                this.lastBattle.DamagePercent
            });
            bool    flag    = this.battleType == BattleType.PvpAttackSquadWar;
            UXLabel element = base.GetElement <UXLabel>("LabelResultsSquadWar");

            if (flag)
            {
                int num = Service.Get <SquadController>().WarManager.CalculateVictoryPointsTaken(this.lastBattle);
                element.Text = this.lang.Get("VICTORY_POINTS_EARNED", new object[]
                {
                    num
                });
            }
            else
            {
                bool   flag2 = this.lastBattle.Defender.PlayerFaction != FactionType.Smuggler;
                bool   won   = this.lastBattle.Won;
                string text  = (this.lastBattle.Defender.PlayerFaction == FactionType.Empire) ? "squadwars_end_celeb_empire" : "squadwars_end_celeb_rebel";
                string text2 = (this.lastBattle.Attacker.PlayerFaction == FactionType.Empire) ? "squadwars_end_celeb_empire" : "squadwars_end_celeb_rebel";
                this.currentOwnerTexture = base.GetElement <UXTexture>("TextureFactionIconCurrent");
                this.currentOwnerTexture.LoadTexture((!flag2 & won) ? text2 : text);
                this.newOwnerTexture = base.GetElement <UXTexture>("TextureFactionIconNew");
                this.newOwnerTexture.LoadTexture(won ? text2 : text);
                if (won)
                {
                    SquadWarManager      warManager = Service.Get <SquadController>().WarManager;
                    string               currentlyScoutedBuffBaseId = warManager.GetCurrentlyScoutedBuffBaseId();
                    WarBuffVO            warBuffVO = Service.Get <IDataController>().Get <WarBuffVO>(currentlyScoutedBuffBaseId);
                    SquadWarBuffBaseData currentlyScoutedBuffBaseData = warManager.GetCurrentlyScoutedBuffBaseData();
                    string               text3 = this.lang.Get(warBuffVO.BuffBaseName, new object[0]);
                    string               text4 = currentlyScoutedBuffBaseData.GetDisplayBaseLevel().ToString();
                    this.buffBaseUpgradeLabel.Visible = true;
                    this.buffBaseUpgradeLabel.Text    = this.lang.Get("WAR_BUFF_BASE_UPGRADED", new object[]
                    {
                        text3,
                        text4
                    });
                    this.labelBuffBaseCapturedSquadWar.Visible = true;
                    this.labelBuffBaseCapturedSquadWar.Text    = this.lang.Get("WAR_BATTLE_END_BUFF_BASE_CAPTURED", new object[]
                    {
                        text3
                    });
                }
            }
            element.Visible = flag;
            UXLabel element2 = base.GetElement <UXLabel>("LabelAttacksLeftSquadWar");
            bool    visible  = false;

            if (this.lastBattle.AttackerID == Service.Get <CurrentPlayer>().PlayerId)
            {
                SquadWarParticipantState currentParticipantState = Service.Get <SquadController>().WarManager.GetCurrentParticipantState();
                if (currentParticipantState != null)
                {
                    element2.Text = this.lang.Get("WAR_PLAYER_DETAILS_TURNS_LEFT", new object[]
                    {
                        currentParticipantState.TurnsLeft
                    });
                    visible = true;
                }
            }
            element2.Visible = visible;
            this.InitVictoryPoints(this.lastBattle);
            this.attackerBuffsGrid = base.GetElement <UXGrid>("GridBuffsRightSquadWar");
            SquadWarBuffIconHelper.SetupBuffIcons(this.attackerBuffsGrid, "SpriteIconBuffRightSquadWar", this.lastBattle.AttackerWarBuffs);
            this.defenderBuffsGrid = base.GetElement <UXGrid>("GridBuffsLeftSquadWar");
            SquadWarBuffIconHelper.SetupBuffIcons(this.defenderBuffsGrid, "SpriteIconBuffLeftSquadWar", this.lastBattle.DefenderWarBuffs);
            if (this.lastBattle.Won)
            {
                base.AnimateStars(this.lastBattle.EarnedStars);
            }
            base.InitTroopGrid("GridTroopsExpendedSquadWar", "TemplateTroopsExpendedSquadWar", this.lastBattle);
        }
Ejemplo n.º 30
0
 private void EraseRecord()
 {
     this.battleRecord = new BattleRecord();
 }
Ejemplo n.º 31
0
		public static void recordBattleTeamRecord(BattleTeam battleTeam, BattleRecord record)
		{
			BattleTeamInfoRecord _teamInfoRecord = record.OrCreateTeamRecord;
			_teamInfoRecord.Side = battleTeam.BattleSide.Index;
			foreach (BattleFighter _fighter in battleTeam.AllAliveFighter)
			{
				updateBattleFighterRecord(_fighter, _teamInfoRecord);
			}
		}