Esempio n. 1
0
        public UsedHomeCard(GameUserInfo gameUserInfo, HomeCardType homeCardType)
        {
            this.GameUserInfo = gameUserInfo;

            this.Step          = gameUserInfo.Step;
            this.Game          = gameUserInfo.Game;
            this.HomeCardType  = homeCardType.Name;
            this.HomeCardType1 = homeCardType;

            gameUserInfo.UsedHomeCard.Add(this);
        }
Esempio n. 2
0
        public UsedHomeCard(GameUserInfo gameUserInfo, HomeCardType homeCardType)
        {
            if (gameUserInfo.Step1.GameUser1.HomeType != homeCardType.HomeType ||
                gameUserInfo.UsedHomeCard.Any(p => p.HomeCardType == homeCardType.Name))
            {
                return;
            }

            this.GameUserInfo = gameUserInfo;

            this.Step          = gameUserInfo.Step;
            this.Game          = gameUserInfo.Game;
            this.HomeCardType  = homeCardType.Name;
            this.HomeCardType1 = homeCardType;

            gameUserInfo.UsedHomeCard.Add(this);
        }
Esempio n. 3
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");
            }
        }