public void ReturnToStackTest() { TilesStack ts = new TilesStack(new TileRepository(config)); int i = 1000; while (i > 0) { Tile t = ts.Pop(); Assert.NotNull(t); ts.ReturnToStack(t); Tile s = ts.Pop(); Assert.NotNull(s); if (t != s) { return; } } Assert.Fail(); }
public void Update() { Vector2 move = players.Move(new BoardState(this), TileInHand.Type); if (move.Equals(new Vector2(-2, -2))) { //He needs more time! return; } else if (move.Equals(new Vector2(-1, -1))) { //He wants another tile! if (changedTile) { Debug.Log("Player: " + players.GetPlayerOnMove().Name + " is trying to change tile he got, but changed already! Invalid!!"); } else { changedTile = true; stack.ReturnToStack(TileInHand); TileInHand = stack.Pop(); } } else if (IsValidMove(move, TileInHand.Type)) { //It is valid changedTile = false; DoMove(move, TileInHand); TileInHand = stack.Pop(); players.IncrementPlayer(); Debug.Log("Player to move: " + players.GetPlayerOnMove().Name + " to put tile " + TileInHand.Type); } else { Debug.Log("Player: " + players.GetPlayerOnMove().Name + " is trying to do an invalid move! " + move + " with tile: " + TileInHand.Type); } TileController.Instance.DisplayTileInHand(TileInHand.Type, players.GetPlayerOnMove().Color); }