Exemple #1
0
 public void Clear()
 {
     LogManager.Debug("Clearing Model");
     PlayerStore.Clear();
     ActingPlayer.Clear();
     BlockDice.Clear();
     SquareInformation.Clear();
 }
Exemple #2
0
 public void Clear()
 {
     LogManager.Debug("Clearing Model");
     Players.Clear();
     ActingPlayer.Clear();
     PushbackSquares.Clear();
     TrackNumbers.Clear();
     BlockDice.Clear();
 }
Exemple #3
0
 public Core()
 {
     //ModelChangeFactory = new ModelChangeFactory();
     ModelChangeFactory = new ReflectedFactory <ModelUpdater <Ffb.Dto.ModelChange>, Type>();
     ActingPlayer       = new ActingPlayer();
     PlayerStore        = new PlayerStore();
     Ball              = new Ball();
     BlockDice         = new List <View.BlockDie>();
     Positions         = new Dictionary <string, Position>();
     SquareInformation = new SquareInformation(26, 15);
 }
Exemple #4
0
 public Core()
 {
     //ModelChangeFactory = new ModelChangeFactory();
     ModelChangeFactory = new ReflectedFactory <ModelUpdater <Ffb.Dto.ModelChange>, Type>();
     ActingPlayer       = new ActingPlayer();
     Players            = new Dictionary <string, Player>();
     Ball            = new Ball();
     PushbackSquares = new Dictionary <int, View.PushbackSquare>();
     TrackNumbers    = new Dictionary <int, View.TrackNumber>();
     BlockDice       = new List <View.BlockDie>();
     Positions       = new Dictionary <string, Position>();
 }
Exemple #5
0
        /// <summary>
        /// Progresses the game loop within the bout.
        /// </summary>
        public virtual void Continue()
        {
            // Decide whose turn it is, if not already decided
            if (ActingPlayer == null)
            {
                // Attacker's "turn".
                if (AttackCardsPlayed.Count <= DefenseCardsPlayed.Count)
                {
                    ActingPlayer = Attacker;
                    OnReport(new GameLogEventArgs(string.Format("Attacker's turn - {0}", Attacker.Name)));
                    // Rebuild AI player decision matrix based on current game state
                    if (Attacker is AIPlayer)
                    {
                        (Attacker as AIPlayer).InitializeMatrix(AttackCardsPlayed.Count == 0);  // The player MUST play at least one attack
                        List <int> validAttacks = new List <int>();
                        foreach (Card card in Attacker.Hand)
                        {
                            if (IsValidAttack(card))
                            {
                                validAttacks.Add(Attacker.Hand.IndexOf(card));
                            }
                        }
                        (Attacker as AIPlayer).AddDecisionsToMatrix(validAttacks.ToArray());
                    }

                    // Prompt attacker to select an option.
                    //Attacker.PromptAction();
                }
                // Defender's "turn".
                else
                {
                    ActingPlayer = Defender;
                    OnReport(new GameLogEventArgs(string.Format("Defender's turn - {0}", Defender.Name)));
                    // Rebuild AI player decision matrix based on current game state
                    if (Defender is AIPlayer)
                    {
                        (Defender as AIPlayer).InitializeMatrix();
                        List <int> validDefends = new List <int>();
                        foreach (Card card in Defender.Hand)
                        {
                            if (card.CanDefendAgainst(AttackCardsPlayed.Last(), this.Game.TrumpSuit))
                            {
                                validDefends.Add(Defender.Hand.IndexOf(card));
                            }
                        }
                        (Defender as AIPlayer).AddDecisionsToMatrix(validDefends.ToArray());
                    }

                    //Defender.PromptAction();
                }
            }
            // If the acting player was already known, prompt them to act.
            else
            {
                ActingPlayer.PromptAction();
                ActingPlayer = null;
            }

            // Check if "end of bout" conditions have been met
            // If the defender has defended up to the maximum number of attacks, they win
            if (DefenseCardsPlayed.Count >= MaximumAttacks)
            {
                Winner = Defender;
            }
            // If a winner has been declared, the bout is concluded.
            if (Winner != null)
            {
                OnEnd(new GameLogEventArgs(string.Format("{0} won the bout!", Winner.Name)));
                // If the defender lost, they have to pick up all of the cards.
                if (Winner == Attacker)
                {
                    Defender.TakeCards(AttackCardsPlayed.Union(DefenseCardsPlayed).ToArray(), "the table");
                }

                // Remove all cards from the table.
                AttackCardsPlayed.Clear();
                DefenseCardsPlayed.Clear();
            }
        }