public void EvaluateGameState()
        {
            // Don't switch from a lost game to an open game
            if (IsGameCompletelyLost)
            {
                return;
            }

            var ownArmies = new Armies(0);

            foreach (var territory in BotState.VisibleMap.GetOwnedTerritories())
            {
                ownArmies = ownArmies.Add(territory.Armies);
            }

            var opponents = BotState.Opponents.Where(o => o.State == GamePlayerState.Playing).Select(o => new OpponentInfo(BotState, o)).ToList();

            // int opponentIncome =
            // BotState.getGuessedOpponentIncome(BotState.VisibleMap);

            if (opponents.Count == 1 && BotState.MyIncome.Total == BotState.Settings.MinimumArmyBonus && opponents[0].Income >= BotState.MyIncome.Total * 2.4 && opponents[0].TotalArmies.NumArmies * 3 > ownArmies.NumArmies)
            {
                IsGameCompletelyLost = true;
            }
        }
        internal void CopyArmy()
        {
            PlanArmy army = SelectedArmy.PlanArmy;

            army.PlanUnits.Clear();

            var armyItems = new List <PlanUnit>();

            foreach (PlanUnitViewModel armyItemVM in SelectedArmy.PlanUnits)
            {
                PlanUnit armyItem = armyItemVM.PlanUnit;

                armyItem.Options = armyItemVM.Options.Select(option => option.Option).ToList();

                army.PlanUnits.Add(armyItemVM.PlanUnit);
            }

            var copiedArmy = new PlanArmyViewModel()
            {
                PlanArmy = StaticHelper.DeepClone(army)
            };

            Armies.Add(copiedArmy);

            SelectedArmy = copiedArmy;
        }
Esempio n. 3
0
        public Armies GetSurroundingIdleArmies()
        {
            var idleArmies = new Armies(0);

            foreach (var neighbor in this.GetOwnedNeighbors())
            {
                idleArmies = idleArmies.Add(neighbor.GetIdleArmies());
            }
            return(idleArmies);
        }
Esempio n. 4
0
        public Armies GetIncomingArmies()
        {
            var incomingArmies = new Armies(0);

            foreach (var atm in this.IncomingMoves)
            {
                incomingArmies = incomingArmies.Add(atm.Armies);
            }

            return(incomingArmies);
        }
Esempio n. 5
0
        public IResponse AddArmy(Army army)
        {
            if (Started)
            {
                return(new ErrorResponse("Battle already started"));
            }

            Armies.Add(army);

            return(new SuccessResponse());
        }
        public void CreateNewArmy()
        {
            var newArmy = new PlanArmyViewModel()
            {
                PlanArmy = new PlanArmy()
            };

            Armies.Add(newArmy);

            SelectedArmy = newArmy;
        }
        private async void InitiliseMainPage()
        {
            IEnumerable <PlanArmy> armies = await _armyProvider.GetArmies();

            foreach (PlanArmy army in armies)
            {
                Armies.Add(new PlanArmyViewModel {
                    PlanArmy = army
                });
            }
        }
            public OpponentInfo(BotMain state, GamePlayer opponent)
            {
                this.Territories = state.VisibleMap.OpponentTerritories(opponent.ID);
                var opponentArmies = new Armies(0);

                foreach (var territory in Territories)
                {
                    opponentArmies = opponentArmies.Add(territory.Armies);
                }
                TotalArmies = opponentArmies;

                this.Income = state.HistoryTracker.OpponentDeployment(opponent.ID);
            }
Esempio n. 9
0
        private static Armies CalculateOpponentAttackingArmies(BotTerritory territory, Moves opponentAttacks)
        {
            var attackingArmies = new Armies(0);

            foreach (var atm in opponentAttacks.Orders.OfType <BotOrderAttackTransfer>())
            {
                if (atm.To.ID == territory.ID)
                {
                    attackingArmies = attackingArmies.Add(atm.Armies);
                }
            }
            return(attackingArmies);
        }
Esempio n. 10
0
        public void AddArmyFromBorderBattle(VisualArmy armyPrefab, Army army)
        {
            Armies.Add(army);
            SupportOnly = Armies.All(x => x.Type == ArmyType.Support);

            if (!Territories.Contains(army.TargetTerritory))
            {
                Territories.Add(army.TargetTerritory);
            }
            if (!Players.Contains(army.SourcePlayer))
            {
                Players.Add(army.SourcePlayer);
            }
            if (!Players.Contains(army.TargetPlayer))
            {
                Players.Add(army.TargetPlayer);
            }


            // Visual
            List <Vector2> walkPath = new List <Vector2>();

            if (army.IsWaterArmy)
            {
                WaterConnection wc = army.SourceTerritory.Region.GetWaterConnectionTo(army.TargetTerritory.Region);
                System.Tuple <Vector2, float> center = new System.Tuple <Vector2, float>(wc.Center, wc.FromRegion == army.SourceTerritory.Region ? wc.Angle - 90 : wc.Angle + 90);
                Vector2 borderCenter     = center.Item1;
                float   targetAngle      = center.Item2 + 180;
                float   approachDistance = wc.Length / 2f;
                float   xTarget          = Mathf.Sin(Mathf.Deg2Rad * targetAngle) * approachDistance;
                float   yTarget          = Mathf.Cos(Mathf.Deg2Rad * targetAngle) * approachDistance;
                Vector2 coastPos         = borderCenter + new Vector2(xTarget, yTarget);
                walkPath.Add(borderCenter);
                walkPath.Add(coastPos);
            }
            else
            {
                System.Tuple <Vector2, float> center = army.SourceTerritory.Region.GetBorderCenterPositionTo(army.TargetTerritory.Region);
                Vector2 borderCenter = center.Item1;
                walkPath.Add(borderCenter);
            }
            Vector2 targetPos = army.TargetTerritory.Region.CenterPoi;

            walkPath.Add(targetPos);

            VisualArmy visualArmy = GameObject.Instantiate(armyPrefab);

            visualArmy.Init(army, walkPath, ParriskGame.ArmyApproachTime);
        }