예제 #1
0
        private bool TyrionLannister()
        {
            GameUser holder = BattleUsers.FirstOrDefault(p => p.LastStep.BattleUser.HomeCardType == "Тирион_Ланнистер");

            if (holder != null)
            {
                if (holder.LastStep.BattleUser.AdditionalEffect == null)
                {
                    Step newStep = holder.LastStep.CopyStep("Тирион_Ланнистер", false);
                    newStep.NewMessage("dynamic_planning*stepType_Тирион_Ланнистер");
                    return(true);
                }
                else if (holder.LastStep.BattleUser.AdditionalEffect != string.Empty &&
                         holder.LastStep.BattleUser.AdditionalEffect != "Block")
                {
                    //разблокировка карты соперника
                    GameUser     opponent     = BattleUsers.First(p => p != holder);
                    UsedHomeCard usedHomeCard = opponent.LastStep.GameUserInfo.UsedHomeCard.SingleOrDefault(p => p.HomeCardType == holder.LastStep.BattleUser.AdditionalEffect);
                    if (usedHomeCard != null)
                    {
                        opponent.LastStep.GameUserInfo.UsedHomeCard.Remove(usedHomeCard);
                    }
                }
            }

            return(false);
        }
예제 #2
0
        //Меч
        private bool Blade(GameUser bladeUser)
        {
            //Мечь не использовали
            if (_Game.LastHomeSteps.All(p => !p.GameUserInfo.IsBladeUse) && bladeUser.LastStep.Raven == null)
            {
                BattleUsers.ForEach(p => p.LastStep.GetStrength());
                Random();

                Step newStep = bladeUser.LastStep.CopyStep("Валирийский_меч", false);
                newStep.NewRaven();
                newStep.NewMessage("dynamic_planning*stepType_Валирийский_меч");
                return(false);
            }
            //Меч использовали для замены карты перевеса
            else if (bladeUser.LastStep.Raven != null && bladeUser.LastStep.Raven.StepType == "Карта_перевеса")
            {
                Random();
                bladeUser.LastStep.BattleUser.RandomDeskId = randomDesk.GetRandomCardId();
            }
            //Меч использовали раньше
            else if (bladeUser.LastStep.BattleUser.RandomDeskId == null)
            {
                Random();
            }

            return(true);
        }
예제 #3
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 == "Пеший_воин"));
                }
            }
        }
예제 #4
0
        private void SalladhorSaan()
        {
            GameUser holder = BattleUsers.FirstOrDefault(p => p.LastStep.BattleUser.HomeCardType == "Салладор_Саан" &&
                                                         p.LastStep.BattleUser.AdditionalEffect == null);

            if (holder != null)
            {
                holder.LastStep.GetStrength();
            }
        }
예제 #5
0
        private bool DoranMartell()
        {
            GameUser holder = BattleUsers.FirstOrDefault(p => p.LastStep.BattleUser.HomeCardType == "Доран_Мартелл" &&
                                                         p.LastStep.BattleUser.AdditionalEffect == null);

            if (holder != null)
            {
                Step newStep = holder.LastStep.CopyStep("Доран_Мартелл", false);
                newStep.NewMessage("dynamic_planning*stepType_Доран_Мартелл");
                return(true);
            }

            return(false);
        }
예제 #6
0
        private bool QueenofThornes()
        {
            GameUser holder = BattleUsers.FirstOrDefault(p => p.LastStep.BattleUser.HomeCardType == "Королева_Шипов" &&
                                                         p.LastStep.BattleUser.AdditionalEffect == null);

            if (holder != null)
            {
                Step newStep = holder.LastStep.CopyStep("Королева_Шипов", false);
                newStep.NewMessage("dynamic_planning*stepType_Королева_Шипов");
                return(true);
            }

            return(false);
        }
예제 #7
0
        private bool dragon_Queen_of_Thorns()
        {
            var holder = BattleUsers.FirstOrDefault(p => p.LastStep.BattleUser.HomeCardType == "dragon_Queen_of_Thorns" &&
                                                    p.LastStep.BattleUser.AdditionalEffect == null);

            if (holder != null)
            {
                holder.LastStep.NewMessage("dynamic_heroRage*hero_dragon_Queen_of_Thorns*rageEffect_30");
                var opponent = BattleUsers.Single(p => p != holder);
                opponent.LastStep.BattleUser.AdditionalEffect = "Block";
            }

            return(false);
        }
예제 #8
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);
        }
예제 #9
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);
        }
예제 #10
0
        private void dragon_Walder_Frey()
        {
            GameUser holder = BattleUsers.FirstOrDefault(p => p.LastStep.BattleUser.HomeCardType == "dragon_Walder_Frey" &&
                                                         p.LastStep.BattleUser.AdditionalEffect == null);

            if (holder != null)
            {
                _Game.LastHomeSteps.Where(p => p.Support != null && p.Support.BattleId == this.Id)
                .Where(p => BattleUsers.All(p1 => p1.Id != p.GameUser))
                .ToList().ForEach(p =>
                {
                    var newStep = p.CopyStep("Default", true);
                    newStep.NewMessage("dynamic_heroRage*hero_dragon_Walder_Frey*rageEffect_0");
                    newStep.Support.SupportUser = holder.Id;
                });
            }
        }
예제 #11
0
        private bool AeronDamphair()
        {
            GameUser holder = BattleUsers.FirstOrDefault(p => p.LastStep.BattleUser.HomeCardType == "Эйерон_Сыровласый" &&
                                                         p.LastStep.BattleUser.AdditionalEffect == null);

            if (holder != null)
            {
                if (holder.LastStep.GameUserInfo.Power < 2 || holder.LastStep.GameUserInfo.UsedHomeCard.Count >= 6)
                {
                    return(false);
                }

                Step newStep = holder.LastStep.CopyStep("Эйерон_Сыровласый", false);
                newStep.NewMessage("dynamic_planning*stepType_Эйерон_Сыровласый");
                return(true);
            }

            return(false);
        }
예제 #12
0
        private bool dragon_Qyburn()
        {
            GameUser holder = BattleUsers.FirstOrDefault(p => p.LastStep.BattleUser.HomeCardType == "dragon_Qyburn" &&
                                                         p.LastStep.BattleUser.AdditionalEffect == null);

            if (holder != null)
            {
                if (holder.LastStep.GameUserInfo.Power < 2 || _Game.LastHomeSteps.All(p => p.GameUserInfo.UsedHomeCard.Count == 0))
                {
                    return(false);
                }

                Step newStep = holder.LastStep.CopyStep("dragon_Qyburn", false);
                newStep.NewMessage("dynamic_planning*stepType_dragon_Qyburn");
                return(true);
            }

            return(false);
        }
예제 #13
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));
                }
            }
        }
예제 #14
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);
        }
예제 #15
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));
                    }
                }));
            }
        }
예제 #16
0
        //карты перевеса
        private void Random()
        {
            if (_Game.RandomIndex > 0 || _Game.IsRandomSkull)
            {
                IEnumerable <RandomDesk> desk = _Game.DbContext.RandomDesk.Where(p => p.Strength <= _Game.RandomIndex);
                if (!_Game.IsRandomSkull)
                {
                    desk = desk.Where(p => p.Skull == _Game.IsRandomSkull);
                }
                randomDesk = desk.ToList();

                BattleUsers.ForEach((p) =>
                {
                    if (!p.LastStep.BattleUser.RandomDeskId.HasValue)
                    {
                        p.LastStep.BattleUser.RandomDeskId = randomDesk.GetRandomCardId();
                    }
                    else
                    {
                        randomDesk.Remove(randomDesk.Single(p1 => p1.Id == p.LastStep.BattleUser.RandomDeskId.Value));
                    }
                });
            }
        }
예제 #17
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");
            }
        }