public void AwayPlayersTotal_WhenFaceOff_ItIsOffensiveAttribute()
        {
            var homePlayers = Factory.GetPlayers(1);
            var awayPlayers = Factory.GetPlayers(1);

            var result = new BattleResult(homePlayers, awayPlayers, BattleType.FaceOff, true);

            result.AwayPlayersTotal.ShouldEqual(3);
        }
        public void AwayPlayersTotal_WhenHomeAttacksAndOnePlayer_ItIsDefensiveAttribute()
        {
            var homePlayers = Factory.GetPlayers(1);
            var awayPlayers = Factory.GetPlayers(1);

            var result = new BattleResult(homePlayers, awayPlayers, BattleType.Scramble, true);

            result.AwayPlayersTotal.ShouldEqual(2);
        }
        public void AwayPlayersTotal_WhenAwayAttacksAndManyPlayers_ItIsSumOfOffensiveAttribute()
        {
            var homePlayers = Factory.GetPlayers(1);
            var awayPlayers = Factory.GetPlayers(2);

            var result = new BattleResult(homePlayers, awayPlayers, BattleType.Scramble, false);

            result.AwayPlayersTotal.ShouldEqual(3 * 2);
        }
        public void AwayPlayersTotal_WhenAwayShoots_ItIsOffensiveAttribute()
        {
            var shooter = Factory.GetPlayers(1);
            var goalie = Factory.GetPlayers(1, "G");
            var area = Factory.GetArea(0, 0);

            var result = new BattleResult(goalie, shooter, BattleType.Shot, area, false);

            result.AwayPlayersTotal.ShouldEqual(3);
        }
Пример #5
0
 public BattleResult GetHomeResult()
 {
     var result = new BattleResult {
         HomeModifier = HomeModifier,
         HomePlayers = HomePlayers,
         HomePlayersTotal = HomePlayersTotal,
         HomeTotal = HomeTotal,
         IsHomePlayer = true,
         AwayModifier = AwayModifier,
         AwayPlayers = AwayPlayers,
         AwayPlayersTotal = AwayPlayersTotal,
         AwayTotal = AwayTotal,
         IsHomeAttacking = IsHomeAttacking,
         Area = Area,
         Type = Type,
         Success = IsHomeAttacking ? IsHomeWinner : !IsHomeWinner
     };
     return result;
 }
Пример #6
0
 public BattleResult GetAwayResult()
 {
     var result = new BattleResult {
         HomeModifier = HomeModifier,
         HomePlayers = HomePlayers,
         HomePlayersTotal = HomePlayersTotal,
         HomeTotal = HomeTotal,
         IsHomePlayer = false,
         AwayModifier = AwayModifier,
         AwayPlayers = AwayPlayers,
         AwayPlayersTotal = AwayPlayersTotal,
         AwayTotal = AwayTotal,
         IsHomeAttacking = IsHomeAttacking,
         Area = Area != null ? Area.Opposite : null,
         Type = Type,
         Success = IsHomeAttacking ? !IsHomeWinner : IsHomeWinner
     };
     return result;
 }
        public void AwayPlayersTotal_WhenHomeShootsFromRight_ItIsGoaliesDefensiceAttribute()
        {
            var homePlayers = Factory.GetPlayers(1);
            var awayPlayers = Factory.GetPlayers(1, "G");
            var area = Factory.GetArea(1, 0);

            var result = new BattleResult(homePlayers, awayPlayers, BattleType.Shot, area, true);

            result.AwayPlayersTotal.ShouldEqual(2);
        }
            public void GetHomeResultHasCorrectValue()
            {
                var homePlayers = Factory.GetPlayers(2);
                var awayPlayers = Factory.GetPlayers(1);

                var result = new BattleResult(homePlayers, awayPlayers, BattleType.Scramble, false).GetHomeResult();

                result.IsHomeAttacking.ShouldBeFalse();
            }
            public void BonusIsNotResettedWhenGameBoardIsCleared()
            {
                var home = Factory.GetPlayers(1, "LW").First();
                home.Bonus = Bonus.Offense;
                var away = Factory.GetPlayers(1);
                var result = new BattleResult(new List<Player> {home}, away, BattleType.Scramble, true);

                home.Bonus = Bonus.None;

                result.HomePlayers.First().Bonus.ShouldEqual(Bonus.Offense);
            }
Пример #10
0
            public void AwayTotal_OffensiveEqualsOffensivePlayerAttributeWhenAwayTeamAttacks()
            {
                var homePlayers = Factory.GetPlayers(1);
                var awayPlayers = Factory.GetPlayers(1);

                var result = new BattleResult(homePlayers, awayPlayers, BattleType.Scramble, false, new FakeGenerator());

                result.AwayTotal.ShouldEqual(6);
            }
Пример #11
0
            public void AwayTotal_AwayTotal_WhenHomeTeamAttacks_DefensiveEqualsAllAwayPlayers()
            {
                var homePlayers = Factory.GetPlayers(1);
                var awayPlayers = Factory.GetPlayers(2);

                var result = new BattleResult(homePlayers, awayPlayers, BattleType.Scramble, true, new FakeGenerator());

                result.AwayTotal.ShouldEqual(7);
            }
Пример #12
0
            public void AwayTotal_AwayPlayerShotIsCorrect()
            {
                var shooter = Factory.GetPlayers(1);
                var goalie = Factory.GetPlayers(1, "G");
                var area = Factory.GetArea(1, 3);

                var result = new BattleResult(goalie, shooter, BattleType.Shot, area, false, new FakeGenerator());

                result.AwayTotal.ShouldEqual(6);
            }
Пример #13
0
        public void HomePlayersTotal_WhenHomeShoots_ItIsOffensiveAttribute()
        {
            var shooter = Factory.GetPlayers(1);
            var goalie = Factory.GetPlayers(1, "G");
            var area = Factory.GetArea(0, 0);

            var result = new BattleResult(shooter, goalie, BattleType.Shot, area, true);

            result.HomePlayersTotal.ShouldEqual(3);
        }
Пример #14
0
        public void HomePlayersTotal_WhenAwayShootsFromLeft_ItIsGoaliesOffensiveAttribute()
        {
            var homePlayers = Factory.GetPlayers(1, "G");
            var awayPlayers = Factory.GetPlayers(1);
            var area = Factory.GetArea(1, 3);

            var result = new BattleResult(homePlayers, awayPlayers, BattleType.Shot, area, false);

            result.HomePlayersTotal.ShouldEqual(3);
        }
Пример #15
0
        public void AwayTotal_WhenHomeAttacksAndOnePlayer_ItIsSumOfDefensiveAttributeAndModifier()
        {
            var homePlayers = Factory.GetPlayers(1);
            var awayPlayers = Factory.GetPlayers(1);

            var result = new BattleResult(homePlayers, awayPlayers, BattleType.Scramble, true, new FakeGenerator());

            result.AwayTotal.ShouldEqual(5);
        }
Пример #16
0
        public List<BattleResult> ExecuteTactic(TacticCard tacticCard, bool homePlayerAttacks)
        {
            if (!homePlayerAttacks) {
                //Reverse tactic
                tacticCard = tacticCard.Reverse();
            }
            var battles = new List<BattleResult>();
            var area = Areas.Single(x => x.X == tacticCard.StartNode.X && x.Y == tacticCard.StartNode.Y);
            var result = new BattleResult(area.HomePlayers, area.AwayPlayers, BattleType.Scramble, area, homePlayerAttacks);
            if(result.Success)
                Movement(tacticCard, homePlayerAttacks, area, tacticCard.StartNode);
            battles.Add(result);
            if (!result.Success)
                return battles;

            foreach (var pass in tacticCard.Passes) {
                var node = pass.End;
                area = Areas.Single(x => x.X == node.X && x.Y == node.Y);

                var homePlayers = new List<Player>(area.HomePlayers);
                var awayPlayers = new List<Player>(area.AwayPlayers);

                result = new BattleResult(homePlayers, awayPlayers, BattleType.Scramble, area, homePlayerAttacks) {
                    Area = area
                };

                if (result.Success) {
                    // Is there any player movin to that area?
                    Movement(tacticCard, homePlayerAttacks, area, node);
                }
                battles.Add(result);
                if (!result.Success)
                    return battles;
            }

            //Shot
            area = Areas.Single(x => x.X == tacticCard.Shot.X && x.Y == tacticCard.Shot.Y);

            if (homePlayerAttacks) {
                var shooter = area.HomePlayers.First();
                var goalie = AwayGoalie;

                var battleResult = new BattleResult(new List<Player> {shooter}, new List<Player> {goalie}, BattleType.Shot, area, true);
                battles.Add(battleResult);

            } else {
                var shooter = area.AwayPlayers.First();
                var goalie = HomeGoalie;

                var battleResult = new BattleResult(new List<Player> { goalie }, new List<Player> { shooter }, BattleType.Shot, area, false);
                battles.Add(battleResult);
            }
            return battles;
        }