public static void TestInequality_DifferentPieceAndPlayer() { Piece piece1 = new King(Player.White); Piece piece2 = new Queen(Player.Black); Assert.AreNotEqual(piece1, piece2, "piece1 and piece2 are equal"); Assert.False(piece1.Equals(piece2), "piece1.Equals(piece2) should be false"); Assert.False(piece2.Equals(piece1), "piece2.Equals(piece1) should be false"); Assert.False(piece1 == piece2, "piece1 == piece2 should be false"); Assert.False(piece2 == piece1, "piece2 == piece1 should be false"); Assert.True(piece1 != piece2, "piece1 != piece2 should be True"); Assert.True(piece2 != piece1, "piece2 != piece1 should be True"); Assert.AreNotEqual(piece1.GetHashCode(), piece2.GetHashCode(), "Hash codes are equal"); }
public void TestKingEquality() { King king1 = new King(true); King king2 = new King(true); Assert.True(king1.Equals(king2)); Assert.True(king2.Equals(king1)); Assert.True(king1 == king2); Assert.True(king2 == king1); Assert.False(king1 != king2); Assert.False(king2 != king1); //I don't feel like checking more, I am preety sure that it works }
public static void TestEquality() { Piece piece1 = new King(Player.White); Piece piece2 = new King(Player.White); Assert.AreEqual(piece1, piece2, "piece1 and piece2 are not equal"); Assert.True(piece1.Equals(piece2), "piece1.Equals(piece2) should be True"); Assert.True(piece2.Equals(piece1), "piece2.Equals(piece1) should be True"); Assert.True(piece1 == piece2, "piece1 == piece2 should be True"); Assert.True(piece2 == piece1, "piece2 == piece1 should be True"); Assert.False(piece1 != piece2, "piece1 != piece2 should be false"); Assert.False(piece2 != piece1, "piece2 != piece1 should be false"); Assert.AreEqual(piece1.GetHashCode(), piece2.GetHashCode(), "Hash codes are different"); }
public static void TestInequality_DifferentPlayer() { var piece1 = new King(Player.White); var piece2 = new King(Player.Black); Assert.AreNotEqual(piece1, piece2); Assert.False(piece1.Equals(piece2)); Assert.False(piece2.Equals(piece1)); Assert.False(piece1 == piece2); Assert.False(piece2 == piece1); Assert.True(piece1 != piece2); Assert.True(piece2 != piece1); Assert.AreNotEqual(piece1.GetHashCode(), piece2.GetHashCode()); }
public static void TestEquality() { var piece1 = new King(Player.White); var piece2 = new King(Player.White); Assert.AreEqual(piece1, piece2); Assert.True(piece1.Equals(piece2)); Assert.True(piece2.Equals(piece1)); Assert.True(piece1 == piece2); Assert.True(piece2 == piece1); Assert.False(piece1 != piece2); Assert.False(piece2 != piece1); Assert.AreEqual(piece1.GetHashCode(), piece2.GetHashCode()); }
public static void GetReport(Player p1, Player p2) { Player.CheckHeroes6(p1); Player.CheckHeroes6(p2); King king1 = new King("Name", 1, 1, 1); King king2 = new King("Name", 1, 1, 1); Console.WriteLine($"Команда {p1.NameTeam}: "); foreach (var item in p1.heroes) { Console.WriteLine(item.Name); if (item is King) { king1 = item as King; } } Console.WriteLine($"Команда {p2.NameTeam}: "); foreach (var item in p2.heroes) { Console.WriteLine(item.Name); if (item is King) { king2 = item as King; } } if (king1.Equals(king2)) { Console.WriteLine("Война нам здесь не поможет,мы потеряем лишь много героев." + "Так что теперь у нас конфеты,дружба,жвачка!"); } foreach (Hero item in p1.heroes) { item.ShoutForTheKing(); } foreach (Hero item in p2.heroes) { item.ShoutForTheKing(); } }
/// <summary> /// Vraca polje sa kog napada kralj, ako napada /// </summary> private static Field KingAttacking(Board board, Field f, bool opponentPieceWhite) { Type king = new King(true).GetType(); for (int dx = -1; dx <= 1; dx++) { for (int dy = -1; dy <= 1; dy++) { if (!(dx == 0 && dy == 0)) { if (WithinBoundaries(f.X + dx, f.Y + dy) && board.Fields[f.X + dx][f.Y + dy].Piece != null && board.Fields[f.X + dx][f.Y + dy].Piece.White == opponentPieceWhite) { if (king.Equals(board.Fields[f.X + dx][f.Y + dy].Piece.GetType())) { return(board.Fields[f.X + dx][f.Y + dy]); } } } } } return(null); }