Exemplo n.º 1
0
 public static bool GameEndScoring(GameState gs)
 {
     if (TilebagLessThanSeven(gs))
     {
         if (ExistsPlayerNoTiles(gs))
         {
             foreach (Player p in gs.ListOfPlayers)
             {
                 if (p != p0)
                 {
                     foreach (Tile t in p.PlayingTiles)
                     {
                         p0.Score += AllTiles.ScoreOfLetter(t.TileChar);
                         p.Score  -= AllTiles.ScoreOfLetter(t.TileChar);
                     }
                 }
             }
         }
         else
         {
             foreach (Player p in gs.ListOfPlayers)
             {
                 foreach (Tile t in p.PlayingTiles)
                 {
                     p.Score -= AllTiles.ScoreOfLetter(t.TileChar);
                 }
             }
         }
         return(true);
     }
     return(false);
 }
Exemplo n.º 2
0
        public char Swap(char c)
        {
            int  rNum = rnd.Next(0, GameState.GSInstance.TilesBag.ListTiles.Count);
            Tile t    = GameState.GSInstance.TilesBag.ListTiles[rNum];

            GameState.GSInstance.TilesBag.ListTiles.RemoveAt(rNum);
            foreach (Tile tmp in GameState.GSInstance.ListOfPlayers[GameState.GSInstance.PlayerNow].PlayingTiles)
            {
                if (tmp.TileChar == c)
                {
                    GameState.GSInstance.ListOfPlayers[GameState.GSInstance.PlayerNow].PlayingTiles.Remove(tmp);
                    GameState.GSInstance.ListOfPlayers[GameState.GSInstance.PlayerNow].PlayingTiles.Add(t);
                    break;
                }
            }
            GameState.GSInstance.TilesBag.ListTiles.Add(new Tile(c, AllTiles.ScoreOfLetter(c)));
            return(t.TileChar);
        }
Exemplo n.º 3
0
        public GameState()
        {
            this.ListOfPlayers = new List <Player>();
            this.TilesBag      = new AllTiles();
            this.playerManager = new PlayerManager();

            this.WordsAppeared             = new List <string>();
            this.WordsAppearedInValidation = new List <string>();
            this.BoardChar    = new char[15, 15];
            this.boardTiles   = new BoardTiles();
            this.CorrectWords = new Dictionary <string, int>();
            this.FirstMove    = true;
            this.ListOfViews  = new List <IView>();
            for (int i = 0; i < BoardChar.GetLength(0); ++i)
            {
                for (int j = 0; j < BoardChar.GetLength(1); ++j)
                {
                    BoardChar[i, j] = '\0';
                }
            }
        }