public void ChainedExplosions() { Board board = CreateBoard(4, 3, new[] { // 0 1 2 3 Cube(1), Cube(1), Cube(3), Cube(1), // 0 Cube(1), Cube(1), Bomb(2), Cube(1), // 1 Ball(1), Ball(1), Cube(3), Bomb(1), // 2 }); var game = new Game(board); // IAction[] actions = game.Swap(new Point(2, 2), new Point(3, 2)); // Console.Out.WriteLine(game.Dump()); var dAct = (DestroyAction)actions[1]; var matchBomb = new Point(2, 2); var chainBomb = new Point(2, 1); // Assert.False(dAct.MatchDestroyedPos.Any(p => p.Pos == chainBomb)); Assert.AreEqual(3, dAct.MatchDestroyedPos.Length); Assert.True(dAct.MatchDestroyedPos.Any(p => p.Pos == new Point(0, 2))); Assert.True(dAct.MatchDestroyedPos.Any(p => p.Pos == new Point(1, 2))); Assert.True(dAct.MatchDestroyedPos.Any(p => p.Pos == matchBomb)); Assert.True(dAct.DestroyedBy.Keys.Any(p => p.Pos == matchBomb)); Assert.True(dAct.DestroyedBy.Keys.Any(p => p.Pos == chainBomb)); // Chain bomb explosion ItemPos matchBombPos = dAct.DestroyedBy .Keys .First(p => p.Pos == matchBomb); ItemPos chainBombPos = dAct.DestroyedBy .Keys .First(p => p.Pos == chainBomb); ItemPos[] byMatchBombPos = dAct.DestroyedBy[matchBombPos]; ItemPos[] byChainBombPos = dAct.DestroyedBy[chainBombPos]; // Assert.AreEqual(4, byMatchBombPos.Length); Assert.True(byMatchBombPos.Any(p => p.Pos == new Point(1, 1))); Assert.True(byMatchBombPos.Any(p => p.Pos == new Point(2, 1))); Assert.True(byMatchBombPos.Any(p => p.Pos == new Point(3, 1))); Assert.True(byMatchBombPos.Any(p => p.Pos == new Point(3, 2))); Assert.AreEqual(3, byChainBombPos.Length); Assert.True(byChainBombPos.Any(p => p.Pos == new Point(1, 0))); Assert.True(byChainBombPos.Any(p => p.Pos == new Point(2, 0))); Assert.True(byChainBombPos.Any(p => p.Pos == new Point(3, 0))); }
public void Reset() { var game = new Game(new Board()); // game.Reset(); // Assert.AreEqual(0, game.Scores); foreach (Item item in game.Items) { Assert.NotNull(item); } Console.Out.WriteLine(game.Dump()); }
public void SpawnBonusBombCross() { Board board = CreateBoard(4, 3, new[] { // 0 1 2 3 Cube(1), Cube(1), Ball(1), Cube(1), // 0 Cube(1), Cube(1), Ball(1), Cube(1), // 1 Ball(1), Ball(1), Ball(2), Ball(1), // 2 }); var game = new Game(board); // IAction[] actions = game.Swap(new Point(2, 2), new Point(3, 2)); // Console.Out.WriteLine(game.Dump()); var dAct = (DestroyAction)actions[1]; var bomb = new Point(2, 2); Assert.AreEqual(bomb, dAct.SpawnBonuses[0].Pos); Assert.True(dAct.SpawnBonuses[0].Item.IsBombShape); }