Exemple #1
0
        //Play the Round, and return whether the round was a wash (0 coins exchange hands) or not
        public bool PlayRound()
        {
            bool isWash = true;

            //OnShareBought?.Invoke(null, Shares);

            //Allow turns to be taken until 3 turns have been passed in a row
            while (TurnPassCount < 3)
            {
                NonBlockingSleep(1);

                //Round needs to end if there are no more shares
                if (Shares.Count < 1)
                {
                    break;
                }

                //let the current player take their turn, and switch on if they bought the current share or not
                if (Players[0].TakeTurn(Shares[0]))
                {
                    OnShareBought?.Invoke(Players[0], Shares[0]);
                    //increase the pot by the value and remove the share
                    Pot += Shares.Pull(0);
                    if (Shares.Count > 0)
                    {
                        OnNewShareAvailable?.Invoke(Shares[0]);
                    }
                    //record that the current player bought a share
                    Buyers.Add(Players[0]);
                    //reset the pass counter
                    TurnPassCount = 0;
                }
                //if they passed, increase the counter
                else
                {
                    TurnPassCount++;
                }

                NonBlockingSleep(1500);
                //move the current player to the end of the line
                Players.Add(Players.Pull(0));
            }

            //if there's money in the pot and more than one player purchased, the round wasn't a wash;
            //there's currently an uncertainty in the rules: if shares are purchased by multiple players in a way that causes everyone to break even, is the round a wash?  current rules say no.
            if ((Pot > 0) && (Buyers.Distinct().Count() > 1))
            {
                isWash = false;
            }

            //divy up the money to end the round
            Payout();

            //Wait for 5 seconds before ending the round
            NonBlockingSleep(5000);

            //let the game know if the round was a wash
            return(isWash);
        }
Exemple #2
0
        //Set the initial conditions at the start of the round
        public void Setup()
        {
            //Each player active in the game should start active in the round
            foreach (Player p in Players)
            {
                p.BoughtShares  = new List <int>();
                p.ActiveInRound = p.ActiveInGame;
            }

            OnNewShareAvailable?.Invoke(Shares[0]);
        }
Exemple #3
0
 void PostNewShare(int shareValue)
 {
     OnNewShareAvailable?.Invoke(shareValue);
 }