Ejemplo n.º 1
0
 public static void PlayerHasPrivate(GameState state, Player player, PrivateCompany company)
 {
     Assert.Contains(company, state.GetPlayerState(player).PrivateCompanies);
 }
Ejemplo n.º 2
0
 public static void PlayerHasMoney(GameState state, Player player, int money)
 {
     Assert.Equal(money, state.GetPlayerState(player).Money);
 }
Ejemplo n.º 3
0
        public override IEnumerable<IChoice> GetChoices(GameState gameState)
        {
            var choices = new List<IChoice>();
            choices.Add(new PassChoice());

            var playerState = gameState.GetPlayerState(ActivePlayer);

            if (CurrentAuction != null)
            {                    
                choices.Add(GetLegalBid(playerState, CurrentAuction.Selection));
            }
            else
            {                
                foreach (var company in Privates)
                    choices.Add(GetLegalBid(playerState, company));
            }

            return choices.Where(c => c != null);
        }
Ejemplo n.º 4
0
        private static void PrintState(GameState state, PendingAction pendingAction)
        {
            Console.Clear();

            Console.WriteLine($"Current Round: {state.Round.Description}");

            Console.WriteLine();
            Console.WriteLine("Players:");
            foreach (var p in state.Game.Players)
            {
                if (p == pendingAction.ActivePlayer)
                    Console.ForegroundColor = ConsoleColor.Yellow;

                var playerState = state.GetPlayerState(p);
                var privates = string.Join(", ", playerState.PrivateCompanies.Select(x => x.Name));
                var biddingPower = playerState.PrivateCompanies.Sum(x => x.Value) + playerState.Money;
                Console.WriteLine($"{p.Name.PadRight(10, ' ')} Cash: {playerState.Money}\t Bidding Power: {biddingPower}\t Privates: {privates} ");

                Console.ResetColor();
            }

            var privateAuctionRound = state.Round as PrivateAuctionRound;

            if(privateAuctionRound != null)
            {
                Console.WriteLine();
                Console.WriteLine($"Seed money: {privateAuctionRound.SeedMoney}");

                var currentAuction = (state.Round as PrivateAuctionRound)?.CurrentAuction;
                if (currentAuction != null)
                {
                    Console.WriteLine($"Current Auction: {currentAuction.Selection.Name}");
                    Console.WriteLine($"High bid: {currentAuction.HighBid} ({currentAuction.HighBidder.Name})");
                }
            }

            Console.WriteLine();
            Console.WriteLine("Select an action - pass, undo, or pick a number:");
            foreach (var c in pendingAction.Choices)
            {
                Console.WriteLine($"{pendingAction.Choices.IndexOf(c)}. {c.Description}");
            }
        }
Ejemplo n.º 5
0
        private static GameState CompleteAuction(GameState gameState, PrivateAuctionRound round)
        {
            var currentAuction = round.CurrentAuction;
            var stateForWinningPlayer = gameState.GetPlayerState(currentAuction.HighBidder);
            var winningPlayerPrivates = stateForWinningPlayer.PrivateCompanies.Add(currentAuction.Selection);

            var newPlayerStates = gameState.PlayerStates.Replace(stateForWinningPlayer, 
                new PlayerState(stateForWinningPlayer.Player, stateForWinningPlayer.Money - currentAuction.HighBid, winningPlayerPrivates));                

            var seedFunding = currentAuction.Selection.Value - currentAuction.HighBid;
            var remainingPrivates = round.Privates.Remove(currentAuction.Selection);
            var nextPlayer = round.Players.GetPlayerAfter(round.LastToAct);

            Round newRound;            
            if (remainingPrivates.IsEmpty)
            {
                newRound = StockRound.StartOfRound(round.Players, 1, nextPlayer);
                return new GameState(gameState.Game, newRound, nextPlayer, newPlayerStates, gameState.CompanyStates);
            }
            else
            {
                newRound = new PrivateAuctionRound(round.Players, remainingPrivates, null, nextPlayer, round.LastToAct, round.SeedMoney - seedFunding);
                return new GameState(gameState.Game, newRound, gameState.PlayerWithPriority, newPlayerStates, gameState.CompanyStates);
            }
            
            
        }