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); }
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); }
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'; } } }