Exemple #1
0
        public int MakeChoice(Fort enemyFrontFort)
        {
            int choice = play.Next(0, 3);

            Choices[choice]++;

            return(choice);
        }
Exemple #2
0
 public void AddFort(Fort fort)
 {
     Forts.Add(fort);
 }
Exemple #3
0
        private void FactionAttack(int factionId)
        {
            List <int> redDiceRolls  = new List <int>();
            List <int> blueDiceRolls = new List <int>();

            // The attacking Faction loses one force
            int redAttackerPenalty  = (1 - factionId);
            int blueAttackerPenalty = factionId;

            int redForcesLost  = 0;
            int blueForcesLost = 0;

            for (int force = 0; force < (RedFaction.GetFrontFort().GetForces() - redAttackerPenalty); force++)
            {
                var roll = diceRoll.Next(1, 7);

                redDiceRolls.Add(roll);
            }

            for (int force = 0; force < (BlueFaction.GetFrontFort().GetForces() - blueAttackerPenalty); force++)
            {
                var roll = diceRoll.Next(1, 7);

                blueDiceRolls.Add(roll);
            }

            redDiceRolls.Sort();
            blueDiceRolls.Sort();

            int additionalRedForces  = 0;
            int additionalBlueForces = 0;

            if (redDiceRolls.Count() > blueDiceRolls.Count())
            {
                additionalRedForces = redDiceRolls.Count() - blueDiceRolls.Count();
            }
            else if (blueDiceRolls.Count() > redDiceRolls.Count())
            {
                additionalBlueForces = blueDiceRolls.Count() - redDiceRolls.Count();
            }

            int lesserForceAmount = Math.Min(redDiceRolls.Count(), blueDiceRolls.Count());

            for (int force = 0; force < lesserForceAmount; force++)
            {
                if (redDiceRolls[force + additionalRedForces] > blueDiceRolls[force + additionalBlueForces])
                {
                    blueForcesLost++;
                }
                else if (redDiceRolls[force + additionalRedForces] < blueDiceRolls[force + additionalBlueForces])
                {
                    redForcesLost++;
                }
            }

            RedFaction.GetFrontFort().DecreaseForce(redForcesLost);
            BlueFaction.GetFrontFort().DecreaseForce(blueForcesLost);

            if (factionId == 0)
            {
                if (BlueFaction.GetFrontFort().GetForces() <= 0)
                {
                    int redForcesToFront = RedFaction.GetFrontFort().GetForces() - 1;
                    int blueFrontFortId  = BlueFaction.GetFrontFort().GetId();

                    BlueFaction.RemoveFrontFort();

                    Fort newRedFort = new Fort(blueFrontFortId, redForcesToFront - 1);

                    RedFaction.GetFrontFort().DecreaseForceToOne();

                    RedFaction.AddFort(newRedFort);
                }
            }
            else
            {
                if (RedFaction.GetFrontFort().GetForces() <= 0)
                {
                    int blueForcesToFront = BlueFaction.GetFrontFort().GetForces() - 1;
                    int redFrontFortId    = RedFaction.GetFrontFort().GetId();

                    RedFaction.RemoveFrontFort();

                    Fort newBlueFort = new Fort(redFrontFortId, blueForcesToFront - 1);

                    BlueFaction.GetFrontFort().DecreaseForceToOne();

                    BlueFaction.AddFort(newBlueFort);
                }
            }
        }