public void DoSelectBuildingForBuild_True()
        {
            var status = new PlayerStatus(1, "Test");
            status.ReceiveDoubloons(10);
            var mainBoardController = new MainBoardController(4);
            var playerController = new PlayerController(mainBoardController, status);

            var university = new University();
            university.ReceiveColonist();

            status.Board.BuildBuilding(university);

            var result = playerController.DoSelectBuildingToBuild(mainBoardController.Status.Buildings.First().Key, true);

            Assert.IsTrue(result);
        }
Esempio n. 2
0
        private void DoBuilderAction(IPlayerConnection connection, bool isHasPrivilage, PlayerStatus status,
            MainBoardStatus board, List<PlayerStatus> opponents, PlayerController controller)
        {
            var isSuccessfull = false;
            IBuilding selectedBuilding = null;
            while (!isSuccessfull)
            {
                var building = connection.SelectBuildingToBuild(isHasPrivilage, status, board,
                    opponents);

                isSuccessfull = controller.DoSelectBuildingToBuild(building, isHasPrivilage);
                if (isSuccessfull && building != null)
                {
                    selectedBuilding = status.Board.Buildings.Single(x => x.GetType() == building.GetType());
                }
            }

            if (selectedBuilding == null)
            {
                return;
            }

            var param = new BuilderParameters();
            status.Board.Buildings.OfType<BuildingBase<BuilderParameters>>().Where(x=>x.IsActive).ToList().ForEach(x=>x.DoAction(ref param));

            if (param.TakeAdditionalColonist && board.Colonists.CurrentColonistsCount > 0)
            {
                var isTakeAdditionalColonist = connection.IsTakeAdditionalColonist(isHasPrivilage, status, board,
                    opponents);

                if (isTakeAdditionalColonist)
                {
                    board.Colonists.Move(selectedBuilding);
                }
            }
        }
Esempio n. 3
0
        private void DoTradeAction(IPlayerConnection connection, bool isHasPrivilage, PlayerStatus status,
            List<PlayerStatus> opponents, PlayerController controller)
        {
            var goodsForTrade = connection.SelectGoodsToTrade(isHasPrivilage, status, _mainBoardController.Status,
                opponents);

            if (goodsForTrade.HasValue)
            {
                controller.DoTradeAction(goodsForTrade.Value, isHasPrivilage);
            }
        }
Esempio n. 4
0
 private void DoSettlerAction(IPlayerConnection connection, bool isHasPrivilage, PlayerStatus status,
     List<PlayerStatus> opponents, PlayerController controller)
 {
     var islandObjects = connection.SelectISlandObjects(isHasPrivilage, status, _mainBoardController.Status,
         opponents);
     controller.DoSettlerAction(islandObjects.ToList(), isHasPrivilage);
 }
Esempio n. 5
0
        private void DoMayorAction(bool isHasPrivilage, IPlayerConnection connection, PlayerStatus status,
            List<PlayerStatus> opponents,
            PlayerController controller)
        {
            if (isHasPrivilage)
            {
                var usePrivilage = connection.IsUsePrivilage(status, _mainBoardController.Status,
                    opponents);
                controller.DoMayorActionTakeAdditionalColinists(usePrivilage);
            }

            Func<MoveDirection> moveDirectionAction =
                () => connection.MoveColonist(isHasPrivilage, status, _mainBoardController.Status,
                    opponents);
            var moveDirection = moveDirectionAction();
            while (moveDirection != null)
            {
                controller.DoMoveColonistAction(moveDirection);
                moveDirection = moveDirectionAction();
            }
        }
Esempio n. 6
0
        private void DoCraftsmanAction(IPlayerConnection currentConnection, PlayerController currentPlayerController,
            MainBoardStatus boardStatus, IEnumerable<PlayerStatus> currentOpponents, PlayerStatus currentPlayerStatus)
        {
            var players = GeneratePlayersOrder(_governor);

            foreach (var player in players)
            {
                var status = _players[player].Status;

                var param = new CraftsmanParameters();
                status.Board.Buildings.OfType<GoodsFactoryBase>().ToList().ForEach(x => x.DoAction(ref param));

                var plantations =
                    status.Board.Plantations.Where(x => x.IsActive).Select(x => x.Type).GroupBy(x => x);

                var production = plantations.ToDictionary(plantation => plantation.Key,
                    plantation => Math.Min(plantation.Count(), param.GoodsProduction[plantation.Key]));

                currentPlayerController.DoCraftsmanAction(production);
            }

            var additionalGoods = currentConnection.SelectAdditionalGoods(currentPlayerStatus, boardStatus,
                currentOpponents);

            currentPlayerController.DoCraftsmanActionReceiveAdditionalGoods(additionalGoods);
        }
Esempio n. 7
0
 private void DoCaptainAction(PlayerStatus status, IPlayerConnection connection, PlayerController controller,
     bool isHasPrivilage, List<PlayerStatus> opponents)
 {
     var goodsToShip = connection.SelectGoodsToShip(status, _mainBoardController.Status, opponents);
     controller.DoCaptainAction(goodsToShip);
 }