Пример #1
0
        private void MaceTyrell()
        {
            GameUser maceTyrellHolder = BattleUsers.SingleOrDefault(p =>
                                                                    p.LastStep.BattleUser.HomeCardType == "Мейс_Тирелл" &&
                                                                    p.LastStep.BattleUser.AdditionalEffect == null);

            if (maceTyrellHolder != null)
            {
                //ход потерпевшего
                GameUser opponent = maceTyrellHolder == this.LocalAttackUser
                    ? this.LocalDefenceUser
                    : this.LocalAttackUser;

                if (opponent.LastStep.BattleUser.HomeCardType == "Бринден_Чёрная_Рыба" &&
                    opponent.LastStep.BattleUser.AdditionalEffect == null)
                {
                    return;
                }

                //уничтожение пешего
                if (opponent.LastStep.GameUserInfo.Unit.Any(p => p.Terrain == this.DefenceTerrain && p.UnitType == "Пеший_воин"))
                {
                    Step maceStep = maceTyrellHolder.LastStep.CopyStep("Default", true);
                    maceStep.BattleUser.AdditionalEffect = string.Empty;
                    maceStep.NewMessage("dynamic_heroRage*hero_Мейс_Тирелл*rageEffect_6");

                    Step step = opponent.LastStep.CopyStep("Default", true);
                    step.NewMessage("dynamic_unitRemove1*unitType_Пеший_воин*unitRemoveType_destroyed*hero_Мейс_Тирелл");
                    step.GameUserInfo.Unit.Remove(opponent.LastStep.GameUserInfo.Unit.OrderBy(p => p.IsWounded).First(p => p.Terrain == this.DefenceTerrain && p.UnitType == "Пеший_воин"));
                }
            }
        }
Пример #2
0
        public bool Patchface()
        {
            var holder = BattleUsers.SingleOrDefault(p => p.LastStep.BattleUser.HomeCardType == "Пестряк" &&
                                                     p.LastStep.BattleUser.AdditionalEffect == null);

            if (holder != null)
            {
                Step newStep = holder.LastStep.CopyStep("Пестряк", false);
                newStep.NewMessage("dynamic_heroRage*hero_Пестряк*rageEffect_15");
                return(true);
            }

            return(false);
        }
Пример #3
0
        public bool dragon_Melisandre()
        {
            var holder = BattleUsers.SingleOrDefault(p => p.LastStep.BattleUser.HomeCardType == "dragon_Melisandre" &&
                                                     p.LastStep.BattleUser.AdditionalEffect == null);

            if (holder == null)
            {
                return(false);
            }

            Step newStep = holder.LastStep.CopyStep("dragon_Melisandre", false);

            newStep.NewMessage(string.Format("dynamic_heroRage*hero_dragon_Melisandre*dynamic_homeCardReturn*?"));
            return(true);
        }
Пример #4
0
        private void dragon_Doran_Martell(ref int killedUserCount)
        {
            var holder = BattleUsers.SingleOrDefault(p => p.LastStep.BattleUser.HomeCardType == "dragon_Doran_Martell" &&
                                                     p.LastStep.BattleUser.AdditionalEffect == null);

            if (holder != null)
            {
                if (holder == WinnerUser)
                {
                    killedUserCount += 6 - holder.LastStep.GameUserInfo.UsedHomeCard.Count();
                    holder.LastStep.NewMessage(string.Format("dynamic_heroRage*hero_dragon_Doran_Martell*rageEffect_2*{0}", killedUserCount));
                }
                else
                {
                    killedUserCount -= 6 - holder.LastStep.GameUserInfo.UsedHomeCard.Count();
                    holder.LastStep.NewMessage(string.Format("dynamic_heroRage*hero_dragon_Doran_Martell*rageEffect_1*{0}", killedUserCount));
                }
            }
        }
Пример #5
0
        private bool dragon_Aeron_Damphair()
        {
            GameUser holder = BattleUsers.SingleOrDefault(p => p.LastStep.BattleUser.HomeCardType == "dragon_Aeron_Damphair" &&
                                                          p.LastStep.BattleUser.AdditionalEffect == null);

            if (holder != null)
            {
                if (holder.LastStep.GameUserInfo.Power == 0)
                {
                    return(false);
                }

                Step newStep = holder.LastStep.CopyStep("dragon_Aeron_Damphair", false);
                newStep.NewMessage("dynamic_planning*stepType_dragon_Aeron_Damphair");
                new Voting(newStep, "dragon_Aeron_Damphair");
                return(true);
            }

            return(false);
        }
Пример #6
0
        private void dragon_Stannis_Baratheon()
        {
            var holder = BattleUsers.SingleOrDefault(p => p.LastStep.BattleUser.HomeCardType == "dragon_Stannis_Baratheon" &&
                                                     p.LastStep.BattleUser.AdditionalEffect == null);

            if (holder == null)
            {
                return;
            }

            holder.LastStep.GetStrength();
            if (!holder.LastStep.IsSupport)
            {
                var supportOrders = _Game.LastHomeSteps.SelectMany(p => p.GameUserInfo.Order.Where(p1 => p1.OrderType1.DoType == "Подмога" && p1.Terrain1.TerrainTerrain1.Any(p2 => p2.Terrain == DefenceTerrain))).ToList();
                var steps         = supportOrders.Select(p => p.GameUserInfo.Step1.CopyStep("Default", true)).ToList();
                steps.ForEach(p => supportOrders.ForEach(p1 =>
                {
                    if (p.GameUserInfo.Order.Remove(p.GameUserInfo.Order.SingleOrDefault(p2 => p2.FirstId == p1.FirstId)))
                    {
                        p.NewMessage(string.Format("dynamic_heroRage*hero_dragon_Stannis_Baratheon*rageEffect_23*orderType_{0}", p1.OrderType));
                    }
                }));
            }
        }
Пример #7
0
        public void UpdateBattle()
        {
            BattleUsers.ForEach(p => p.LastStep.CopyStep("Сражение", true));

            //До боя
            if (TyrionLannister() || dragon_Queen_of_Thorns() || AeronDamphair() || dragon_Aeron_Damphair() || dragon_Qyburn() || DoranMartell() || QueenofThornes())
            {
                BattleUsers.ForEach(p => p.LastStep.GetStrength());
                return;
            }

            MaceTyrell();
            dragon_Stannis_Baratheon();
            dragon_Walder_Frey();

            //Меч и карты перевеса
            GameUser bladeUser = BattleUsers.SingleOrDefault(p => p.LastStep.GameUserInfo.BladeInfluence == 1);

            if (bladeUser != null)
            {
                if (!Blade(bladeUser))
                {
                    return;
                }
            }
            else
            {
                Random();
            }

            SalladhorSaan();
            BattleUsers.ForEach(p => p.LastStep.GetStrength(true));
            dragon_Margaery_Tyrell();

            //определяем победителя и проигравшего
            _BattleUsers = BattleUsers.OrderByDescending(p => p.LastStep.BattleUser.Strength.Value).ThenBy(p => p.LastStep.GameUserInfo.BladeInfluence).ToList();

            foreach (var item in BattleUsers)
            {
                item.LastStep.BattleUser.IsWinner = item == BattleUsers[0];
            }

            #region потери и ранения
            //Карты домов
            int          killedUserCount = 0;
            HomeCardType winHomeCard     = BattleUsers[0].LastStep.BattleUser.LocalHomeCardType;
            if (winHomeCard != null)
            {
                killedUserCount += winHomeCard.Attack;
            }
            HomeCardType losHomeCard = BattleUsers[1].LastStep.BattleUser.LocalHomeCardType;
            if (losHomeCard != null)
            {
                killedUserCount -= losHomeCard.Defence;
            }

            //карты перевеса
            RandomDesk winRandomCard = BattleUsers[0].LastStep.BattleUser.LocalRandomCard;
            if (winRandomCard != null)
            {
                if (winRandomCard.Attack)
                {
                    killedUserCount++;
                }
            }
            RandomDesk losRandomCard = BattleUsers[1].LastStep.BattleUser.LocalRandomCard;
            if (losRandomCard != null)
            {
                if (losRandomCard.Defence)
                {
                    killedUserCount--;
                }
            }

            //специализация
            NymeriaSand(ref killedUserCount);
            SerDavosSeaworth(ref killedUserCount);
            TheonGreyjoy(ref killedUserCount);
            AshaGreyjoy(ref killedUserCount);
            TheBlackfish(ref killedUserCount);
            dragon_Ramsay_Bolton(ref killedUserCount);
            dragon_Doran_Martell(ref killedUserCount);

            UpdateUsedHomeCard();

            bool        isAutoRetreat = false;
            List <Unit> loserUnit     = BattleUsers[1].LastStep.GameUserInfo.Unit.Where(p => p.Terrain == this.DefenceTerrain).OrderBy(p => p.UnitType1.Strength).ToList();
            foreach (var item in loserUnit)
            {
                if (item.IsWounded || item.UnitType == "Осадная_башня")
                {
                    BattleUsers[1].LastStep.GameUserInfo.Unit.Remove(item);
                    BattleUsers[1].LastStep.NewMessage(string.Format("dynamic_unitRemove0*unitType_{0}*unitRemoveType_{1}",
                                                                     item.UnitType,
                                                                     item.IsWounded ? "finished" : "thrown"));
                }
                else
                {
                    if (killedUserCount > 0)
                    {
                        BattleUsers[1].LastStep.GameUserInfo.Unit.Remove(item);
                        BattleUsers[1].LastStep.NewMessage(string.Format("dynamic_unitRemove0*unitType_{0}*unitRemoveType_destroyed",
                                                                         item.UnitType));
                        killedUserCount--;
                    }
                    else
                    {
                        item.IsWounded = true;
                    }
                }
            }

            //Черепа
            if (winRandomCard != null && winRandomCard.Skull &&
                (losHomeCard == null || LoserUser.LastStep.BattleUser.AdditionalEffect == "Block" || losHomeCard.Name != "Бринден_Чёрная_Рыба"))
            {
                Unit skullUnite = BattleUsers[1].LastStep.GameUserInfo.Unit.Where(p => p.Terrain == (isAutoRetreat ? this.AttackTerrain : this.DefenceTerrain)).OrderBy(p => p.UnitType1.Strength).FirstOrDefault();
                if (skullUnite != null)
                {
                    BattleUsers[1].LastStep.GameUserInfo.Unit.Remove(skullUnite);
                    BattleUsers[1].LastStep.NewMessage(string.Format("dynamic_unitRemove1*unitType_{0}*unitRemoveType_destroyed*text_skull",
                                                                     skullUnite.UnitType));
                }
            }

            if (losRandomCard != null && losRandomCard.Skull &&
                (winHomeCard == null || WinnerUser.LastStep.BattleUser.AdditionalEffect == "Block" || winHomeCard.Name != "Бринден_Чёрная_Рыба"))
            {
                Unit skullUnite = BattleUsers[0].LastStep.GameUserInfo.Unit.Where(p => p.Terrain == this.DefenceTerrain).OrderBy(p => p.UnitType1.Strength).FirstOrDefault();
                if (skullUnite != null)
                {
                    BattleUsers[0].LastStep.GameUserInfo.Unit.Remove(skullUnite);
                    BattleUsers[0].LastStep.NewMessage(string.Format("dynamic_unitRemove1*unitType_{0}*unitRemoveType_destroyed*text_skull",
                                                                     skullUnite.UnitType));
                }
            }
            #endregion

            TywinLannister();
            dragon_Qarl_the_Maid();
            if (!ArianneMartell())
            {
                SerLorasTyrell();
            }

            //Удаляем отыгравшие приказы и гарнизон
            this.LocalAttackUser.LastStep.GameUserInfo.Order.Remove(this.LocalAttackUser.LastStep.GameUserInfo.Order.SingleOrDefault(p => p.Terrain == this.AttackTerrain));
            BattleUsers[1].LastStep.GameUserInfo.Order.Remove(BattleUsers[1].LastStep.GameUserInfo.Order.SingleOrDefault(p => p.Terrain == this.DefenceTerrain));
            if (BattleUsers[1] == this.LocalDefenceUser)
            {
                if (_Game.GameInfo.Garrison.Any(p => p.Terrain1 == this.LocalDefenceTerrain))
                {
                    Step newVesterosStep = _Game.Vesteros.LastStep.CopyStep("Default", true);
                    newVesterosStep.NewMessage("dynamic_garrisonRemove*terrain_" + this.DefenceTerrain);
                    _Game.GameInfo.Garrison.Remove(_Game.GameInfo.Garrison.Single(p => p.Terrain1 == this.LocalDefenceTerrain));
                }
            }

            //Автоматическое отступление оставшихся неудачников (Робб перехватывает отступление противника)
            if ((WinnerUser.LastStep.BattleUser.AdditionalEffect == "Block" || BattleUsers[0].LastStep.BattleUser.HomeCardType != "Робб_Старк") && BattleUsers[1] == this.LocalAttackUser)
            {
                foreach (var item in BattleUsers[1].LastStep.GameUserInfo.Unit.Where(p => p.Terrain == this.DefenceTerrain).OrderByDescending(p => p.UnitType1.Strength).ToList())
                {
                    AutoRetreatUnit(BattleUsers[1], item, this.LocalAttackTerrain);
                }
            }

            //Смена владений
            TerrainHold(BattleUsers[0], this.LocalDefenceTerrain);
            TerrainHold(this.LocalAttackUser, this.LocalAttackTerrain);

            if (_Game.LastHomeSteps.All(p => p.IsFull))
            {
                AfterBattle();
            }
            else
            {
                _Game.LastHomeSteps.Where(p => !p.IsFull && p.StepType == "Роспуск_войск").ToList().ForEach(p => p.March.SourceOrder = "AfterBattle");
            }
        }