static AbilityToPiece() { PieceFactory pieceFactory = new PieceFactory(); Array pieceTypes = Enum.GetValues(typeof(PieceType)); foreach (PieceType pieceType in pieceTypes) { IPieceData pieceData = pieceFactory.CreateIPieceData(pieceType); AddOtherMoveAbilities(pieceData); AddPreMoveAbilities(pieceData); AddPostMoveAbilities(pieceData); AddDropAbilities(pieceData); } }
public void TestFixPiece_Wrong_X_Pos() { Board board = new Board(10, 20); Piece piece = PieceFactory.GetPiecebyId(1); board.FixPiece(piece, -3, -1); for (int i = 0; i < board.Height; ++i) { for (int j = 0; j < board.Width; ++j) { Assert.AreEqual(0, board[i, j]); } } }
public PawnReplacementFrm(Board chessboard, PieceColor aColor) { // // Required for Windows Form Designer support // InitializeComponent(); pType = PieceType.QUEEN; pColor = aColor; pFactory = new PieceFactory(); pictureBoxPiece.Paint += new PaintEventHandler(PiecePaint); }
private static Dictionary <Square, Piece> GetStartMap() { var map = new Dictionary <Square, Piece>(64); map[new Square(0, 7)] = PieceFactory.BlackRook(); map[new Square(1, 7)] = PieceFactory.BlackKnight(); map[new Square(2, 7)] = PieceFactory.BlackBishop(); map[new Square(3, 7)] = PieceFactory.BlackQueen(); map[new Square(4, 7)] = PieceFactory.BlackKing(); map[new Square(5, 7)] = PieceFactory.BlackBishop(); map[new Square(6, 7)] = PieceFactory.BlackKnight(); map[new Square(7, 7)] = PieceFactory.BlackRook(); map[new Square(0, 6)] = PieceFactory.BlackPawn(); map[new Square(1, 6)] = PieceFactory.BlackPawn(); map[new Square(2, 6)] = PieceFactory.BlackPawn(); map[new Square(3, 6)] = PieceFactory.BlackPawn(); map[new Square(4, 6)] = PieceFactory.BlackPawn(); map[new Square(5, 6)] = PieceFactory.BlackPawn(); map[new Square(6, 6)] = PieceFactory.BlackPawn(); map[new Square(7, 6)] = PieceFactory.BlackPawn(); for (int y = 2; y < 6; y++) { for (int x = 0; x < 8; x++) { map.Add(new Square(x, 7 - y), Piece.NonePiece); } } map[new Square(0, 1)] = PieceFactory.WhitePawn(); map[new Square(1, 1)] = PieceFactory.WhitePawn(); map[new Square(2, 1)] = PieceFactory.WhitePawn(); map[new Square(3, 1)] = PieceFactory.WhitePawn(); map[new Square(4, 1)] = PieceFactory.WhitePawn(); map[new Square(5, 1)] = PieceFactory.WhitePawn(); map[new Square(6, 1)] = PieceFactory.WhitePawn(); map[new Square(7, 1)] = PieceFactory.WhitePawn(); map[new Square(0, 0)] = PieceFactory.WhiteRook(); map[new Square(1, 0)] = PieceFactory.WhiteKnight(); map[new Square(2, 0)] = PieceFactory.WhiteBishop(); map[new Square(3, 0)] = PieceFactory.WhiteQueen(); map[new Square(4, 0)] = PieceFactory.WhiteKing(); map[new Square(5, 0)] = PieceFactory.WhiteBishop(); map[new Square(6, 0)] = PieceFactory.WhiteKnight(); map[new Square(7, 0)] = PieceFactory.WhiteRook(); return(map); }
public void NewGame() { ListCellManager.listCell = new List <CellManager>(); ListPieceManager.listPiece = new List <PieceManager>(); PieceFactory factory = ScriptableObject.CreateInstance <PieceFactory> (); BoardTableEditor editor = new BoardTableEditor(7, 7, factory); editor.SetPointerInLine(0); editor.PushPiece(3, "Archer", (int)Player.colors.Blue); editor.PushPiece(1, "Boss", (int)Player.colors.Blue); editor.PushPiece(3, "Archer", (int)Player.colors.Blue); editor.SetPointerInLine(1); editor.PushPiece(7, "Warrior", (int)Player.colors.Blue); editor.SetPointerInLine(5); editor.PushPiece(7, "Warrior", (int)Player.colors.Red); editor.SetPointerInLine(6); editor.PushPiece(3, "Archer", (int)Player.colors.Red); editor.PushPiece(1, "Boss", (int)Player.colors.Red); editor.PushPiece(3, "Archer", (int)Player.colors.Red); /* * BoardTableEditor editor = new BoardTableEditor (2, 2, factory); * editor.SetPointerInLine (0); * editor.PushPiece (1, "Archer", (int)Player.colors.Blue); * editor.PushPiece (1, "Boss", (int)Player.colors.Blue); * editor.SetPointerInLine (1); * editor.PushPiece (1, "Archer", (int)Player.colors.Red); * editor.PushPiece (1, "Boss", (int)Player.colors.Red); * */ turnManager = new TurnManager(); game = new Game(editor.GetBoard(), turnManager); MakeListsManager.MakeLists(game); turnManager.SetGame(game); turnManager.AddStep(new NewTurn()); turnManager.AddStep(new PlayerPlay()); turnManager.AddStep(new UpdateScene()); turnManager.AddStep(new UpdateGame()); turnManager.AddStep(new Winner()); turnManager.AddStep(new Menu()); }
public void TestMovePieceSimple() { var states = new State(); states = PieceMove.MovePiece(states, 7, 7, 4, 7);//user Debug.WriteLine(states.ToString()); //states = PieceMove.MovePiece(states, 1, 2, 1, 9);//com states = (AlphaBetaSearch.DoSearch(states, 1)); Debug.WriteLine(states.ToString()); states = PieceMove.MovePiece(states, 0, 9, 1, 9);//user Debug.WriteLine(states.ToString()); Assert.AreEqual(30, states.GetPieceList().Count); var piece = PieceFactory.GetPiece(23, 1, 9); Assert.AreEqual(typeof(Rook), piece.GetType()); }
private static Dictionary <Square, Piece> GetTestMap() { var map = new Dictionary <Square, Piece>(64); for (int y = 0; y < 8; y++) { for (int x = 0; x < 8; x++) { map.Add(new Square(x, 7 - y), Piece.NonePiece); } } map[new Square(0, 0)] = PieceFactory.WhiteKing(); map[new Square(1, 2)] = PieceFactory.BlackRook(); return(map); }
public void combine(PieceController owner, PieceController loser) { owner.move(loser.model.position); Player owningPlayer = playerForNumber(owner.model.playerNum); Player losingPlayer = playerForNumber(loser.model.playerNum); Debug.Log(owningPlayer); owningPlayer.pieces.Remove(owner.model); losingPlayer.pieces.Remove(loser.model); Piece newPiece = PieceFactory.combine(owner.model, loser.model); PieceController piece = Instantiate(piecePrefab, Vector3.zero, Quaternion.identity) as PieceController; piece.transform.parent = transform; piece.model = newPiece; piece.board = this; getTile(piece.model.position).myPiece = piece; owningPlayer.pieces.Add(newPiece); Destroy(owner.gameObject); Destroy(loser.gameObject); }
public void TestFixPiece_Init_Pos_Fix() { Board board = new Board(10, 20); Piece piece = PieceFactory.GetPiecebyId(1); board.FixPiece(piece, 3, -1); for (int i = 3; i < 3 + piece.Width; ++i) { Assert.AreEqual(2, board[0, i]); } for (int i = 0; i < board.Height; ++i) { for (int j = 0; j < board.Width; ++j) { if (i == 0 && j >= 3 && j < 3 + piece.Width) { continue; } Assert.AreEqual(0, board[i, j]); } } }
public Move MakeMove(Board board, Piece piece, Square destination) { var currentPosition = piece.CurrentPosition; var move = new Move(); move.From = new Square(piece.CurrentPosition.Rank, piece.CurrentPosition.Column); move.To = new Square(destination.Rank, destination.Column); move.CapturedPiece = destination.Piece; if (destination.IsOccupied) { RemovePiece(destination.Piece); } destination.Place(piece.CurrentPosition.Pick()); if (IsPromotionalMove(piece, destination)) { move.PromotedToPiece = PieceFactory.CreatePiece(Turn, Players[Turn].GetPromotedToPiece()); RemovePiece(piece); destination.Place(move.PromotedToPiece); } return(move); }
private Piece copyPiece(Piece p) { if (p is WholePiece) { // Debug.Log("Copying whole piece at ("+p.position.x+","+p.position.y+")"); return(PieceFactory.createWholePiece(p)); } else if (p is CompoundPiece) { // Debug.Log("Copying compound piece at ("+p.position.x+","+p.position.y+")"); return(PieceFactory.createCompoundPiece(p.color, p)); } else if (p is BasicPiece) { // Debug.Log("Copying basic piece at ("+p.position.x+","+p.position.y+")"); return(PieceFactory.createBasicPiece(p)); } else { Debug.Log("Model.State.copyPiece shouldn't have gotten here"); return(null); } }
//选择改变颜色的片 public void selectPiece(Vector3 pos) { Ray ray = Camera.main.ScreenPointToRay(pos); RaycastHit hit; if (Physics.Raycast(ray, out hit) && hit.collider.gameObject.tag == "Piece" && is_slt_color) { PieceFactory pf = Singleton <PieceFactory> .Instance; used_step += pf.SetPieceColor(hit.collider.gameObject, slt_color); if (pf.isOneColor()) { if (used_step > max_step) { maintext.text = "Pass But Overstep"; } else { maintext.text = "Perfect!"; } } } }
private static PieceBase _GetChessPieceFromUser() { while (1 == 1) { Console.WriteLine("The available chess pieces are Rook, Queen, Bishop, and King.\n"); Console.WriteLine("Please enter the name of the chess piece."); string chessPieceInput = Console.ReadLine(); PieceBase chessPiece = PieceFactory.CreateChessPiece(chessPieceInput); if (chessPiece == null) { Console.WriteLine(); Console.WriteLine("Chess piece '" + chessPieceInput + "' is invalid. Please Try Again!"); Console.WriteLine(); } else { return(chessPiece); } } }
public void Throws_Exception_When_Piece_Does_Not_Exist() { var pieceFactory = new PieceFactory(BOARD_SIZE); Assert.Throws <ArgumentException>(() => pieceFactory.Create(0)); }
public void TestGetCount() { PieceFactory.Initialize(); Assert.AreEqual(7, PieceFactory.Count); }
public BoardInitializer(Board aBoard, ArrayList aBlockList, ArrayList aWhitePieceList, ArrayList aBlackPieceList, BlockFactory aBlockFactory, PieceFactory aPieceFactory, BlockPositioner aBlockPositioner) { board = aBoard; bList = aBlockList; WhitePieceList = aWhitePieceList; BlackPieceList = aBlackPieceList; bFactory = aBlockFactory; pFactory = aPieceFactory; bPositioner = aBlockPositioner; }
public void TestGetEmptyPiece() { var piece = PieceFactory.GetPiece(0, 0, 9); Assert.AreEqual(typeof(Empty), piece.GetType()); }
public void TestGetRookPiece() { var piece = PieceFactory.GetPiece(23, 1, 9); Assert.AreEqual(typeof(Rook), piece.GetType()); }
public CaptureMove(Piece moved, Position origin, Position destination, Piece captured) : base(moved, origin, destination) { this.Captured = PieceFactory.CopyPiece(captured); }
public ChessLayout() { pieceFactory = new PieceFactory(); }
private void Awake() { IPiece = PieceFactory.createInstance(type); allowedMovesDeltas = IPiece.GetAllowedMoves(); //FindObjectOfType<GameManager>().AddPiece(this); }