本文整理汇总了C#中Game.SetPieceLocation方法的典型用法代码示例。如果您正苦于以下问题:C# Game.SetPieceLocation方法的具体用法?C# Game.SetPieceLocation怎么用?C# Game.SetPieceLocation使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Game
的用法示例。
在下文中一共展示了Game.SetPieceLocation方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ExecuteMoves_Capture_MovesPieceAwayFromStart
public void ExecuteMoves_Capture_MovesPieceAwayFromStart()
{
Game game = new Game();
game.SetPieceLocation(Coord.Create(0, 0), BoardSpaceState.FriendlyPieceShort);
game.SetPieceLocation(Coord.Create(0, 1), BoardSpaceState.OpponentPieceShort);
game.AddActiveMove(Coord.Create(0, 0));
game.AddActiveMove(Coord.Create(0, 2));
GameController.ExecuteMoves(game);
Assert.AreEqual(game.GetPieceAt(Coord.Create(0, 0)), BoardSpaceState.None);
}
示例2: AddPiece
public void AddPiece()
{
Coord coord = new Coord() { Row = 1, Col = 0 };
var piece = BoardSpaceState.FriendlyPieceShort;
Game game = new Game();
game.SetPieceLocation(coord, piece);
Assert.AreEqual(piece, game.GetPieceAt(coord));
}
示例3: ExecuteMoves
public static void ExecuteMoves(Game game, bool flipPieceState = false)
{
if (game.ActiveMoves.Count() == 0)
{
return;
}
Func<BoardSpaceState, BoardSpaceState> getPieceForPlayer = boardSpaceState => flipPieceState ? boardSpaceState.TogglePlayer() : boardSpaceState;
if (!(game.ActiveMoves.Count() == 2 && GameUtils.AreNeighbors(game.ActiveMoves.First(), game.ActiveMoves.Last())))
{
// TODO the recepient can't capture anything - perhaps a board flipping issue?
var opponentsLoc =
game.ActiveMoves
.Pairwise()
.Select((moves) => GameUtils.SpaceBetween(moves.Item1, moves.Item2))
.Where(loc => GameUtils.IsOpponent(getPieceForPlayer(game.GetPieceAt(loc))));
// TODO this doesn't actually fire
Debug.Assert(opponentsLoc.Count() > 0, "If we're doing a jump, we should find some pieces to capture.");
foreach (var opponentLoc in opponentsLoc)
{
game.CapturePiece(game.GetPieceAt(opponentLoc));
game.SetPieceLocation(opponentLoc, BoardSpaceState.None);
}
}
GameUtils.MovePiece(game, game.ActiveMoves.First(), game.ActiveMoves.Last());
game.ClearActiveMoves();
game.Winner = GameValidator.GameWinner(game);
game.WaitingOn = game.WaitingOn.Toggle();
}
示例4: ExecuteMoves_Capture_RemovesCapturedPiece
public void ExecuteMoves_Capture_RemovesCapturedPiece()
{
Game game = new Game();
game.SetPieceLocation(Coord.Create(0, 0), BoardSpaceState.FriendlyPieceShort);
game.SetPieceLocation(Coord.Create(0, 1), BoardSpaceState.OpponentPieceShort);
game.AddActiveMove(Coord.Create(0, 0));
game.AddActiveMove(Coord.Create(0, 2));
GameController.ExecuteMoves(game);
Assert.AreEqual(BoardSpaceState.None, game.GetPieceAt(Coord.Create(0, 1)));
Assert.AreEqual(1, game.GetCapturedCount(BoardSpaceState.OpponentPieceShort));
}
示例5: Winner_DisablesMoving
public void Winner_DisablesMoving()
{
Game game = new Game();
game.SetPieceLocation(Coord.Create(Game.BOARD_ROW_MAX, Game.ENDZONE_COL_1), BoardSpaceState.OpponentPieceShort);
game.SetPieceLocation(Coord.Create(Game.BOARD_ROW_MAX, Game.ENDZONE_COL_2), BoardSpaceState.OpponentPieceTall);
game.SetPieceLocation(Coord.Create(4, 5), BoardSpaceState.OpponentPieceTall);
game.AddActiveMove(Coord.Create(4, 5));
Assert.IsFalse(GameValidator.IsValidMove(game, Coord.Create(4, 6)));
}
示例6: Victory_OutOfPieces
public void Victory_OutOfPieces()
{
Game game = new Game() { WaitingOn = AbsolutePlayer.Recepient };
game.SetPieceLocation(Coord.Create(4, 5), BoardSpaceState.OpponentPieceTall);
game.SetPieceLocation(Coord.Create(9, 2), BoardSpaceState.OpponentPieceShort);
Assert.AreEqual(RelativePlayer.Opponent, GameValidator.GameWinner(game));
}
示例7: Victory_Opponent
public void Victory_Opponent()
{
Game game = new Game();
game.SetPieceLocation(Coord.Create(10, 0), BoardSpaceState.FriendlyPieceShort); // for game.RowMax
game.SetPieceLocation(Coord.Create(Game.BOARD_ROW_MAX, Game.ENDZONE_COL_1), BoardSpaceState.OpponentPieceShort);
game.SetPieceLocation(Coord.Create(Game.BOARD_ROW_MAX, Game.ENDZONE_COL_2), BoardSpaceState.OpponentPieceShort);
Assert.AreEqual(RelativePlayer.Opponent, GameValidator.GameWinner(game));
}
示例8: Victory_Friendly
public void Victory_Friendly()
{
Game game = new Game();
game.SetPieceLocation(Coord.Create(0, Game.ENDZONE_COL_1), BoardSpaceState.FriendlyPieceShort);
game.SetPieceLocation(Coord.Create(0, Game.ENDZONE_COL_2), BoardSpaceState.FriendlyPieceShort);
Assert.AreEqual(RelativePlayer.Friendly, GameValidator.GameWinner(game));
}
示例9: ExecuteMoves_HandleSingleMove
public void ExecuteMoves_HandleSingleMove()
{
Game game = new Game();
game.SetPieceLocation(Coord.Create(0, 10), BoardSpaceState.FriendlyPieceShort);
game.AddActiveMove(Coord.Create(0, 10));
game.AddActiveMove(Coord.Create(0, 11));
GameController.ExecuteMoves(game);
Assert.AreEqual(BoardSpaceState.None, game.GetPieceAt(Coord.Create(0, 10)));
Assert.AreEqual(BoardSpaceState.FriendlyPieceShort, game.GetPieceAt(Coord.Create(0, 11)));
}
示例10: IsJumpable_LandingSpotBlocked
public void IsJumpable_LandingSpotBlocked()
{
Game game = new Game();
game.SetPieceLocation(Coord.Create(10, 10), BoardSpaceState.OpponentPieceShort);
game.SetPieceLocation(Coord.Create(10, 11), BoardSpaceState.OpponentPieceShort);
Assert.IsFalse(GameUtils.IsJumpableFrom(game, Coord.Create(10, 9), Coord.Create(10, 10)));
}
示例11: IsJumpable_Diagonal_Not
public void IsJumpable_Diagonal_Not()
{
Game game = new Game();
game.SetPieceLocation(Coord.Create(10, 10), BoardSpaceState.OpponentPieceShort);
game.SetPieceLocation(Coord.Create(9, 9), BoardSpaceState.OpponentPieceShort);
Assert.IsFalse(GameUtils.IsJumpableFrom(game, Coord.Create(11, 11), Coord.Create(10, 10)));
}
示例12: IsJumpable
public void IsJumpable()
{
Game game = new Game();
game.SetPieceLocation(Coord.Create(10, 10), BoardSpaceState.OpponentPieceShort);
Assert.IsTrue(GameUtils.IsJumpableFrom(game, Coord.Create(10, 9), Coord.Create(10, 10)));
}
示例13: IsCompleteCapture_True
public void IsCompleteCapture_True()
{
Game game = new Game();
game.AddActiveMove(Coord.Create(0, 2));
game.SetPieceLocation(Coord.Create(0, 3), BoardSpaceState.OpponentPieceShort);
game.AddActiveMove(Coord.Create(0, 4));
game.SetPieceLocation(Coord.Create(0, 5), BoardSpaceState.OpponentPieceShort);
game.AddActiveMove(Coord.Create(0, 6));
Assert.IsTrue(GameValidator.IsCompleteMove(game));
}
示例14: GameValidator_GameWinner_RowMax
public void GameValidator_GameWinner_RowMax()
{
Game game = new Game();
game.SetPieceLocation(Coord.Create(4, Game.ENDZONE_COL_1), BoardSpaceState.FriendlyPieceShort);
game.SetPieceLocation(Coord.Create(4, Game.ENDZONE_COL_2), BoardSpaceState.FriendlyPieceShort);
game.SetPieceLocation(Coord.Create(6, 5), BoardSpaceState.OpponentPieceShort);
game.SetPieceLocation(Coord.Create(7, 5), BoardSpaceState.OpponentPieceShort);
Assert.AreEqual(RelativePlayer.None, GameValidator.GameWinner(game));
}
示例15: ExecuteMoves_SetWinner_Friendly
public void ExecuteMoves_SetWinner_Friendly()
{
Game game = new Game();
// is this the right row?
game.SetPieceLocation(Coord.Create(0, Game.ENDZONE_COL_1), BoardSpaceState.FriendlyPieceShort);
game.SetPieceLocation(Coord.Create(1, Game.ENDZONE_COL_2), BoardSpaceState.FriendlyPieceShort);
game.AddActiveMove(Coord.Create(1, Game.ENDZONE_COL_2));
game.AddActiveMove(Coord.Create(0, Game.ENDZONE_COL_2));
GameController.ExecuteMoves(game);
Assert.AreEqual(RelativePlayer.Friendly, game.Winner);
}