private Queue<ICard> CreateChanceCards(Banker banker, Board board, PrisonGuard guard, UtilityRentStrategy utilityRentStrtegy, RailroadRentStrategy railroadRentStrategy)
        {
            var bankDividend = new Collect(banker, 50);
            var maturedLoan = new Collect(banker, 150);
            var poorTax = new Pay(banker, 15);

            var moveToBoardwalk = new Advance(board, banker, 39);
            var rideTheReading = new Advance(board, banker, 5);
            var moveToIllinois = new Advance(board, banker, 24);
            var moveToStCharles = new Advance(board, banker, 11);
            var moveToNearestRailroad = new AdvanceToNearest(board, new[] { 5, 15, 25, 35 }, railroadRentStrategy);
            var MoveToNearest = new AdvanceToNearest(board, new[] { 12, 28 }, utilityRentStrtegy);
            var goBack3Spaces = new GoBackSpaces(board, 3);

            var chairmanOfTheboard = new PayEachPlayer(banker, 50);
            var goToJail = new AdvanceTo(board, 30);
            var advanceToGo = new AdvanceTo(board, 0);
            var getOutofJailFree = new GetOutOfJailFree(guard);

            var cards = new Queue<ICard>();
            cards.Enqueue(bankDividend);
            cards.Enqueue(maturedLoan);
            cards.Enqueue(poorTax);
            cards.Enqueue(moveToNearestRailroad);
            cards.Enqueue(moveToBoardwalk);
            cards.Enqueue(chairmanOfTheboard);
            cards.Enqueue(moveToNearestRailroad);
            cards.Enqueue(rideTheReading);
            cards.Enqueue(moveToIllinois);
            cards.Enqueue(moveToStCharles);
            cards.Enqueue(goToJail);
            cards.Enqueue(advanceToGo);
            cards.Enqueue(getOutofJailFree);

            return cards;
        }
Esempio n. 2
0
        public void MoveToTheNextRailroadDoublesRent()
        {
            banker = new Banker(players, 1500);

            var railroads = new List<RealEstate>();
            var railroadRentStrategy = new RailroadRentStrategy(railroads);
            var readingRailroad = new RealEstate(banker, 200, 25, railroadRentStrategy);
            var pennsylvaniaRailroad = new RealEstate(banker, 200, 25, railroadRentStrategy);
            var bORailroad = new RealEstate(banker, 200, 25, railroadRentStrategy);
            var shortLineRailroad = new RealEstate(banker, 200, 25, railroadRentStrategy);
            railroads.AddRange(new[] { readingRailroad, pennsylvaniaRailroad, bORailroad, shortLineRailroad });

            var spaces = new Dictionary<Int32, IBoardSpace>
            {
                { 5, readingRailroad },
                { 15, pennsylvaniaRailroad },
                { 25, bORailroad },
                { 35, shortLineRailroad }
            };

            var moveToNearestRailroad = new AdvanceToNearest(board, new[] { 5, 15, 25, 35 }, railroadRentStrategy);
            board.SetSpaces(spaces);
            board.MoveTo(player2, 15);
            board.MoveTo(player1, 7);
            var previousBalance = banker.GetBalance(player1);

            moveToNearestRailroad.Play(player1);

            Assert.That(banker.GetBalance(player1), Is.EqualTo(previousBalance - 50));
        }
Esempio n. 3
0
        public void MoveToTheNextRailroadWrapsAroundTheBoard()
        {
            banker = new Banker(players, 1500);
            var railroads = new List<RealEstate>();
            var railroadRentStrategy = new RailroadRentStrategy(railroads);
            var moveToNearestRailroad = new AdvanceToNearest(board, new[] { 5, 15, 25, 35 }, railroadRentStrategy);
            board.MoveTo(player1, 36);

            moveToNearestRailroad.Play(player1);

            Assert.That(board.GetPosition(player1), Is.EqualTo(5));
        }
Esempio n. 4
0
        public void MoveToNearestGivesTheOwner10TimesDiceAmount()
        {
            banker = new Banker(players, 1500);
            board = boardFactory.Create(banker, players, dice, guard);

            var utilities = new List<RealEstate>();
            var utilityRentStrategy = new UtilityRentStrategy(utilities, dice);
            var electric = new RealEstate(banker, 150, 0, utilityRentStrategy);
            var water = new RealEstate(banker, 150, 0, utilityRentStrategy);
            utilities.AddRange(new[] { electric, water });

            var spaces = new Dictionary<Int32, IBoardSpace>
            {
                { 12, electric },
                { 28, water }
            };

            board.SetSpaces(spaces);
            board.MoveTo(player2, 12);
            board.MoveTo(player1, 7);
            var previousBalance = banker.GetBalance(player2);

            dice.SetNumberToRoll(new[] { 4, 1 });
            dice.Roll();
            var MoveToNearest = new AdvanceToNearest(board, new[] { 12, 28 }, utilityRentStrategy);

            MoveToNearest.Play(player1);

            Assert.That(banker.GetBalance(player2), Is.EqualTo(previousBalance + 50));
        }