//returns a list of pieces on the current opening public static Pieces GetPieces(int pageNumber) { var pieces = new Pieces(); try { //gets the xelements representing the two pages of the opening (e.g. 1r, 2v) XElement root = SurfaceWindow1.xOldFr.Root; string verso = "#" + (pageNumber-2).ToString() + "v"; string recto = "#" + (pageNumber-1).ToString() + "r"; IEnumerable<XElement> pages = from el in root.Descendants("pb") where ((string)el.Attribute("facs") == verso || el.Attribute("facs").Value == recto) select el; //adds the pieces on each page to the pieceList foreach (XElement page in pages) { //var foo = page.Attribute("facs"); IEnumerable<XElement> pieceElements = from el in page.Elements("p") select el; //.Attribute("id").Value; foreach (XElement p in pieceElements) { var piece = new Piece(p); pieces.Add(piece.ID,piece); } } } catch (Exception e) { MessageBox.Show(e.Message); } return pieces; }
public void swapPieceTo(Pieces piece) { BoardGame boardGame = BoardGame.getInstance(); Coor coor = base.getCurrentCoor(); boardGame.gameBoard.Children.Remove(this.rect); Piece newPiece = null; switch (piece) { case Pieces.bishop: newPiece = new Bishop(this._side); break; case Pieces.knight: newPiece = new Knight(this._side); break; case Pieces.queen: newPiece = new Queen(this._side); break; case Pieces.rook: newPiece = new Rook(this._side); break; default: throw new Exception("Pawn can only be a bishop, knight, queen or rook."); } boardGame.board[coor.y, coor.x] = newPiece; boardGame.gameBoard.Children.Add(newPiece.rect); newPiece.setCoorOnCanvas(coor); }
private Pieces GetOppositeSidePiece(Pieces piece) { Pieces oppositePiece = Pieces.NONE; switch (piece) { case Pieces.WKING: oppositePiece = Pieces.BKING; break; case Pieces.WQUEEN: oppositePiece = Pieces.BQUEEN; break; case Pieces.WROOK: oppositePiece = Pieces.BROOK; break; case Pieces.WBISHOP: oppositePiece = Pieces.BBISHOP; break; case Pieces.WKNIGHT: oppositePiece = Pieces.BKNIGHT; break; case Pieces.WPAWN: oppositePiece = Pieces.BPAWN; break; case Pieces.BKING: oppositePiece = Pieces.WKING; break; case Pieces.BQUEEN: oppositePiece = Pieces.WQUEEN; break; case Pieces.BROOK: oppositePiece = Pieces.WROOK; break; case Pieces.BBISHOP: oppositePiece = Pieces.WBISHOP; break; case Pieces.BKNIGHT: oppositePiece = Pieces.WKNIGHT; break; case Pieces.BPAWN: oppositePiece = Pieces.WPAWN; break; default: break; } return(oppositePiece); }
private void UndoMovesFromHistory() { if (Status == GoGameStatus.BlackWonDueToResignation || Status == GoGameStatus.WhiteWonDueToResignation) { History.RemoveAt(0); } else { Debug.Assert(History.Count < 2, "Can't undo more moves than have been made."); int count = 2; if (History.Count % 2 == 1) { count = 1; } // Pop off the top move. for (int i = 0; i < count; i++) { var his = History[0]; var pos = his.Move.Position; if (his.Move.MoveType == MoveType.Normal) { if (Pieces.ContainsKey(pos)) { var piece = Pieces[pos]; piece.IsNewPiece = false; piece.Color = null; piece.RaiseMultiplePropertiesChanged(); } var player = _players.First(p => p.Color == his.Move.Color); // Restore any captured pieces. foreach (var cap in his.Result.CapturedStones.Split(' ')) { if (cap != String.Empty && Pieces.ContainsKey(cap)) { player.Prisoners--; var piece = Pieces[cap]; piece.IsNewPiece = false; piece.Color = his.Move.Color == GoColor.Black ? GoColor.White : GoColor.Black; piece.RaiseMultiplePropertiesChanged(); } } } History.RemoveAt(0); } var latestPiece = GetLatestNormalMovePieceFromHistory(); if (latestPiece != null) { latestPiece.IsNewPiece = true; latestPiece.RaiseMultiplePropertiesChanged(); } } }
/// <summary> /// Moves the piece to the desired destination /// </summary> /// <param name="origin"></param> /// <param name="destination"></param> public void MakeMove(Position origin, Position destination) { Piece capturedPiece = ExecuteMovement(origin, destination); if (IsInCheck(CurrentPlayer)) { UndoMovement(origin, destination, capturedPiece); throw new BoardException("You can't put yourself in Check!"); } Piece p = Board.GetPiece(destination); // SPECIAL PLAY PROMOTION if (p is Pawn) { if ((p.Color == Color.White && destination.Line == 0) || (p.Color == Color.Black && destination.Line == 7)) { p = Board.RemovePiece(destination); Pieces.Remove(p); Piece queen = new Queen(Board, p.Color); Board.PlacePiece(queen, destination); Pieces.Add(queen); } } if (IsInCheck(Opponent(CurrentPlayer))) { Check = true; } else { Check = false; } if (TestCheckmate(Opponent(CurrentPlayer))) { Finished = true; } else { Turn++; changePlayer(); } //Turn++; //changePlayer(); // SPECIAL PLAY EN PASSANT if (p is Pawn && (destination.Line == origin.Line - 2 || destination.Line == origin.Line + 2)) { VulnerableEnPassant = p; } else { VulnerableEnPassant = null; } }
void Start() { int i = Random.Range(0, Pieces.Count); ControlledPiece = Instantiate(Pieces[i], Spawner.transform.position, Spawner.transform.rotation); tempPieces = ControlledPiece.GetComponent <Pieces>(); ScoreText.text = "Score: " + Score; }
public static Pieces PieceFromString(string piece) { Pieces aPiece = Pieces.NONE; aPiece = PieceFromChar(Convert.ToChar(piece)); return(aPiece); }
/// <summary> /// Initializes a new instance of the <see cref="TicTacToeGame"/> class. /// </summary> /// <param name="player1Piece">Player one's piece.</param> /// <param name="player2Piece">Player two's piece.</param> /// <param name="language">The language.</param> public TicTacToeGame(Pieces player1Piece, Pieces player2Piece, ILanguage language) { this.language = language; this.player1Piece = player1Piece; this.player2Piece = player2Piece; this.GameBoard = new Board(language); this.moves = new Stack <TicTacToeMove>(); }
private void TryMove(int x1, int y1, int x2, int y2) { startDrag = new Vector2(x1, y1); endDrag = new Vector2(x2, y2); selectPiece = pieces[x1, y1]; MovePiece(selectPiece, x2, y2); }
public static void BeatedEffect(this Pieces piece) { // Debug.Log("Beated!!"); Animator anim = piece.gameObject.GetComponent <Animator>(); anim.SetInteger("Animation", (int)Animation.BeatedPiece); }
private void InitializePiece() { board = transform.parent.parent.parent.GetComponent <Board>(); match = transform.parent.parent.parent.parent.GetComponent <Match>(); unitAttiributes = gameObject.GetComponent <Pieces>(); adjacentBlocksOfTarget.Clear(); adjacentBlocksOfThisUnit.Clear(); }
void Start() { SetState(State.Idle); currentPieces = Pieces.Cross; ai = FindObjectOfType <AIController>(); scoreManager = FindObjectOfType <ScoreManager>(); resPan = FindObjectOfType <ResultPanel>(); }
private static void DrawFile(this Pieces @this, byte file, byte rank) { var piece = @this[file, rank]; WriteValue(piece == null ? ' '.Repeat(5) : $" {piece} "); }
/// <summary> /// Adds highlight /// </summary> /// <param name="points"></param> private void AddHighlight(List <Point> points) { foreach (var point in points) { //add highlights to the beginning of the list so they do not overlap with pieces Pieces.Insert(0, new CellData(point, Colors.GreenYellow, null, 0.6)); } }
public static void NotCreateEffect(this Pieces piece) { //Debug.Log("Beated!!"); Animator anim = piece.gameObject.GetComponent <Animator>(); anim.SetBool("isIdle", true); }
public static void MoveFinishEffect(this Pieces piece) { //Debug.Log("MoveFinish!!"); Animator anim = piece.gameObject.GetComponent <Animator>(); anim.SetInteger("Animation", (int)Animation.MoveFinish); }
// This virtualMoveTo method is for calculating dangerous move or regret move back, there is no eaten piece storing inside so that it is called traceless public static void tracelessMoveTo(int[] oriLocation, int[] destLocation) { // Move the chosen piece to the destination and reset the original position to null Pieces temp = Board.pieces[oriLocation[0], oriLocation[1]]; Board.pieces[oriLocation[0], oriLocation[1]] = null; Board.pieces[destLocation[0], destLocation[1]] = temp; }
private void Set(int x, int y, Pieces val) { if (x < 0 || x > 7 || y < 0 || y > 7) { throw new System.IndexOutOfRangeException(); } board[8 * y + x] = val; }
public override void OnCreatedRoom() { base.OnCreatedRoom(); Debug.Log("Created room"); Pieces p = gameObject.GetComponent <Pieces>(); p.connected = true; }
private void init() { // Default row and col are zero; these are convenience properties for the parent controls, // so they are just referenced using setters and getters mRow = 0; mCol = 0; // clear the click listener on open; set up a link to our onClick listener //this.clickListener = null; //super.setOnClickListener(this); // Set up color brush objects for painting parts of pieces. mLightGreenBrush = new SolidColorBrush(); mEdgeGreenBrush = new SolidColorBrush(); mDarkGreenBrush = new SolidColorBrush(); mBlackBrush = new SolidColorBrush(); mBrownBrush = new SolidColorBrush(); mGoldBrush = new SolidColorBrush(); mSilverBrush = new SolidColorBrush(); mRedBrush = new SolidColorBrush(); mLightBlueBrush = new SolidColorBrush(); mBlueBrush = new SolidColorBrush(); mPurpleBrush = new SolidColorBrush(); mYellowBrush = new SolidColorBrush(); mEdgeGreenBrush.Color = Color.FromArgb(255, 164, 255, 164); mDarkGreenBrush.Color = Color.FromArgb(255, 0, 193, 0); mLightGreenBrush.Color = Color.FromArgb(255, 200, 255, 200); mBlackBrush.Color = Color.FromArgb(255, 0, 0, 0); mBrownBrush.Color = Color.FromArgb(255, 184, 134, 1); mGoldBrush.Color = Color.FromArgb(255, 255, 234, 118); mSilverBrush.Color = Color.FromArgb(255, 189, 189, 189); mLightBlueBrush.Color = Color.FromArgb(255, 153, 217, 234); mRedBrush = Brushes.Red; mBlueBrush = Brushes.Blue; mYellowBrush = Brushes.Yellow; mPurpleBrush = Brushes.Purple; // Prepare the person house paints color array. this.personHouseBrushes = new SolidColorBrush[Pieces.numberOfPeople()]; for (int i = 0; i < Pieces.numberOfPeople(); i++) { if (i == 0) { this.personHouseBrushes[i] = this.mRedBrush; } if (i == 1) { this.personHouseBrushes[i] = this.mYellowBrush; } if (i == 2) { this.personHouseBrushes[i] = this.mBlueBrush; } if (i == 3) { this.personHouseBrushes[i] = this.mPurpleBrush; } if (i == 4) { this.personHouseBrushes[i] = this.mGoldBrush; // right now we only have 4 pairs of houses/people. If we get more maybe we will add more colors! } if (i == 5) { this.personHouseBrushes[i] = this.mSilverBrush; } } // Invalidate the control so it redraws this.InvalidateVisual(); }
public bool isForceMove(Pieces[,] board, int x, int y) { if (isRed || isKing) { //top left if (x >= 2 && y <= 5) { Pieces p = board [x - 1, y + 1]; if (p != null && p.isRed != isRed) { if (board [x - 2, y + 2] == null) { return(true); } } } //top right if (x <= 5 && y <= 5) { Pieces p = board [x + 1, y + 1]; if (p != null && p.isRed != isRed) { if (board [x + 2, y + 2] == null) { return(true); } } } } if (!isRed || isKing) { //bot left if (x >= 2 && y >= 2) { Pieces p = board [x - 1, y - 1]; if (p != null && p.isRed != isRed) { if (board [x - 2, y - 2] == null) { return(true); } } } //bot right if (x <= 5 && y >= 2) { Pieces p = board [x + 1, y - 1]; if (p != null && p.isRed != isRed) { if (board [x + 2, y - 2] == null) { return(true); } } } } return(false); }
/// <summary> /// Obtiene el texto del tablero /// </summary> public string GetText() { string board = " 0 1 2 3 4 5 6 7" + Environment.NewLine + " A B C D E F G H" + Environment.NewLine; // Obtiene el texto for (int row = 0; row < 8; row++) { // Añade el carácter con la fila board += $"{8 - row} "; for (int column = 0; column < 8; column++) { PieceBaseModel piece = Pieces.GetPiece(new CellModel(row, column)); if (piece == null) { board += "."; } else { switch (piece.Type) { case PieceBaseModel.PieceType.Pawn: board += piece.Color == PieceBaseModel.PieceColor.White ? "P" : "p"; break; case PieceBaseModel.PieceType.Bishop: board += piece.Color == PieceBaseModel.PieceColor.White ? "B" : "b"; break; case PieceBaseModel.PieceType.Knight: board += piece.Color == PieceBaseModel.PieceColor.White ? "N" : "n"; break; case PieceBaseModel.PieceType.Rook: board += piece.Color == PieceBaseModel.PieceColor.White ? "R" : "r"; break; case PieceBaseModel.PieceType.King: board += piece.Color == PieceBaseModel.PieceColor.White ? "K" : "k"; break; case PieceBaseModel.PieceType.Queen: board += piece.Color == PieceBaseModel.PieceColor.White ? "Q" : "q"; break; } } board += " "; } // Añade el número de fila y un salto de línea board += $" {8 - row} {row}" + Environment.NewLine; } // Añade el número de columna board += " A B C D E F G H" + Environment.NewLine + " 0 1 2 3 4 5 6 7"; // Devuelve el texto return(board); }
private void Grow(int increment) { int newSize = Size + increment; Pieces[] newArray = new Pieces[newSize]; if (Size > 0) Array.Copy(_array, newArray, Size); _array = newArray; Size = newSize; }
public static Model getModel(Pieces piece) { if (models == null) { initializeModels(); } return(models[piece]); }
public static Model getModel(Pieces piece) { if (models == null) { initializeModels(); } return models[piece]; }
public void SetPiece(RankEnum rank, FileEnum file, Pieces piece) { DataRow row = GetBoardDataRow(rank, file); if (row != null) { row[Board.Piece] = piece.ToString("d"); } }
public bool Validmove(Pieces[,] board, int x1, int y1, int x2, int y2) { // if on top on another piece if (board[x2, y2] != null) { return(false); } int deltaMove = Mathf.Abs(x1 - x2); int deltaMoveY = y1 - y2; if (isWhite || isKing) { if (deltaMove == 1) { if (deltaMoveY == -1) { return(true); } } else if (deltaMove == 2) { if (deltaMoveY == -2) { Pieces p = board[(x1 + x2) / 2, (y1 + y2) / 2]; if (p != null && p.isWhite != isWhite) { return(true); } } } } if (!isWhite || isKing) { if (deltaMove == 1) { if (deltaMoveY == 1) { return(true); } } else if (deltaMove == 2) { if (deltaMoveY == 2) { Pieces p = board[(x1 + x2) / 2, (y1 + y2) / 2]; if (p != null && p.isWhite != isWhite) { return(true); } } } } return(false); }
/// <summary> /// Gets the piece representing the opponent. /// </summary> /// <param name="yourPiece">The piece representing the player.</param> /// <returns>Returns the <see cref="Pieces"/> representing the opponent.</returns> public static Pieces GetOpponentPiece(Pieces yourPiece) { return(yourPiece switch { Pieces.X => Pieces.O, Pieces.O => Pieces.X, Pieces.Empty => throw new NotImplementedException(), _ => throw new NotImplementedException() });
public void EnableAiControlledTeam(Teams team) { //Start the Ai controlled team IEnumerator event Debug.Log(team.team.teamName + " Team Up!"); playerTeamEnabled = false; aiTeamEnabled = true; selectedPiece = currentTeamsTurn.pieces[selePieceIndex]; currentTeamsTurn.teamMoveCount = selectedPiece.piece.defaultMoveRange; }
/// <summary> /// Removes piece on the specified position (if possible). /// </summary> /// <param name="position">The piece position.</param> public void RemovePiece(Position position) { var existingPiece = Pieces.FirstOrDefault(p => p.Position == position); if (existingPiece != null) { Pieces.Remove(existingPiece); } }
public override bool IsMoveAllowed() { if (!IsNotOccupied() && Pieces.FirstOrDefault() is BarricadePiece) { return(false); } return(true); }
/// <summary> /// Removes a piece with a given Id. /// </summary> /// <param name="id">The id of the piece to be removed.</param> public void RemovePieceById(int id) { Piece holder = Pieces.Single(z => id == z.Id); holder.Square.RemovePiece(); // New array is all of the previous pieces - the piece being removed. Pieces = Pieces.Where(x => x.Id != id).ToArray(); }
// Code for saving a piece private void NewPieceSelected() { RemoveShowMoves(); movingPiece = AllPieces[FindPosInArr(new int[2] { cellPosNew.x, cellPosNew.y })]; cellPosLast = cellPosNew; movingPiece.Move(); }
/// <summary> /// Kill : kill a piece when another "eat" it /// </summary> /// <param name="pPiece">piece to kill</param> /// <returns>boolean that confirm that the piece is dead</returns> public bool Kill(Piece pPiece) { pPiece.State = State.DEAD; if (Pieces.Remove(pPiece)) { return(true); } return(false); }
public PiecePosition(Players player, Pieces piece, ChessboardCell cell) { Debug.Assert(cell.Row >= Chessboard.ROW_MIN && cell.Row <= Chessboard.ROW_MAX); Debug.Assert(cell.Column >= Chessboard.COLUMN_MIN && cell.Column <= Chessboard.COLUMN_MAX); m_player = player; m_piece = piece; m_cell = cell; }
private void Grow(int increment) { int newSize = _size + increment; Pieces[] newArray = new Pieces[newSize]; if (_size > 0) Array.Copy(_array, newArray, _size); _array = newArray; Fill(_size, increment); _size = newSize; }
// TODO - add parameters public MoveDesc(Pieces piece, ChessboardCell from, ChessboardCell to, Pieces promote_to, bool is_capture, bool is_check, bool is_checkmate) { Debug.Assert(piece != Pieces.NoPiece); Debug.Assert(!from.IsSame(to)); Debug.Assert(!(is_checkmate && !is_check)); m_piece = piece; m_from = from; m_to = to; m_promote_to = promote_to; m_is_capture = is_capture; m_is_check = is_check; m_is_checkmate = is_checkmate; }
// TODO - temporary method, refactor public static string GetPieceString(Pieces piece, string language = null) { Debug.Assert(piece != Pieces.NoPiece); switch (piece) { case Pieces.Knight: return "N"; case Pieces.Bishop: return "B"; case Pieces.Rook: return "R"; case Pieces.Queen: return "Q"; case Pieces.King: return "K"; } return string.Empty; }
private Pieces _pieces; //music objects on the current opening #endregion Fields #region Constructors public StudyTab(SideBar mySideBar, SurfaceWindow1 surfaceWindow, Pieces pieces) : base(mySideBar) { this.mySideBar = mySideBar; // Opening page. studyPrompt = new TextBlock(); studyTabHeader = new TextBlock(); _pieces = pieces; headerImage.Source = new BitmapImage(new Uri(@"..\..\icons\music.png", UriKind.Relative)); studyTabHeader.HorizontalAlignment = HorizontalAlignment.Center; studyTabHeader.VerticalAlignment = VerticalAlignment.Center; studyTabHeader.FontSize = 21; headerGrid.Children.Add(studyTabHeader); studyPrompt.FontSize = 30; studyPrompt.Text = "Please select a piece of music."; Canvas.SetLeft(studyPrompt, 32); Canvas.SetTop(studyPrompt, 45); studyPrompt.Visibility = System.Windows.Visibility.Visible; canvas.Children.Add(studyPrompt); TranslationBox = new Canvas(); int offsetY = 200; int offsetX = 100; foreach (Piece p in pieces.Values) { Button button = new Button(); //button.Click += delegate(object sender, RoutedEventArgs e) { DisplayMusicItem(sender, e, p); }; button.Click += new RoutedEventHandler(DisplayMusicItem); button.Name = '_' + p.ID; button.Height = ButtonHeight; button.Width = ButtonWidth; button.Content = p.Title; button.FontSize = ButtonFontSize; Canvas.SetLeft(button, offsetX); Canvas.SetTop(button, offsetY); offsetY += 100; canvas.Children.Add(button); } }
public DataTable GetAUniqueThang(Pieces p, String did = null) { DataTable dt = new DataTable(); try { switch (p) { default: break; case Pieces.AppContext: AppContext app = new AppContext(); dt = app.GetAll(); break; } } catch (Exception caught) { DBMain.AltLog(LogLevels.Warning, 70192, "Get Unique '" + caught.Message + "' "); } return dt; }
public Point? PlacerPiece(int x, int y, Pieces piece) { if (x < 0 || x > 7 || y < 0 || y > 7) { MessageBox.Show("Erreur, les positions x et y doivent être comprises entre 0 et 7"); return null; } else { Point p = new Point(x, y); return p; } }
/// <summary> /// Make a move on the board /// </summary> /// <param name="position">the board position to take</param> /// <param name="piece"></param> public void MakeMove(int position, Pieces piece) { if (!IsValidSquare(position)) throw new InvalidMoveException(); int pieceNumber = GetPieceNumber(piece); Point point = GetPoint(position); board[point.X, point.Y] = pieceNumber; }
// gets the internal representation of the // piece protected int GetPieceNumber(Pieces p) { if (p == Pieces.O) return 2; else return 1; }
public static byte SetColor(Pieces piece) { return (byte)piece; }
public DataTableReader GetADataTableReader(Pieces p, String did = null) { return new DataTableReader(GetACollection(p, did)); }
public MoveDesc GetLegalMove(ChessboardCell from, ChessboardCell to, Pieces promote_to) { return m_analyzer.GetLegalMove(from, to, promote_to); }
public string getImageResorcePath(Pieces pieceType) { string ResorcePath = "ChessTest.Resources.Images."; if (_side == Side.white) ResorcePath += "white_" + pieceType.ToString() + ".png"; else ResorcePath += "black_" + pieceType.ToString() + ".png"; return ResorcePath; }
public void ClientPlacePiece(int pieceIndex, int highestIndex, Pieces piece, int orientation, int posX, int posY, byte[] grid) { IClient client = ClientManager[ClientCallback]; if (client != null) HostClientPlacePiece.Do(x => x(client, pieceIndex, highestIndex, piece, orientation, posX, posY, grid)); else Log.Default.WriteLine(LogLevels.Warning, "ClientPlacePiece from unknown client"); }
public void ClientPlacePiece(int pieceIndex, int highestIndex, Pieces piece, int orientation, int posX, int posY, byte[] grid) { IClient client = ClientManager[ClientCallback]; if (client != null && HostClientPlacePiece != null) HostClientPlacePiece(client, pieceIndex, highestIndex, piece, orientation, posX, posY, grid); }
public PieceBtnProperties(Piece piece, Pieces pieceType) { this.piece = piece; this.pieceType = pieceType; }
public PlayerPiece GetPiece( Pieces piece ) { return GetPiece ( (int)piece ) ; }
//TODO inside public bool CheckSides(Pieces currElement, List<Pieces> existingPieces, PlayerArea Area) { //TODO //2. ReWrite for current instance bool result = true; // each existing piece if (currElement.hSpeed < 0) //check Left { //adjust speed and stay in play area for (int speed = -this.hSpeed; speed >= 0; speed--) { if (this.posCol -speed >2) { this.hSpeed = -speed; break; } } foreach (Pieces piece in existingPieces) { if (piece.posRow == currElement.posRow) { if (piece.posCol + piece.stringLength > currElement.posCol + currElement.hSpeed) { result = false; } } } } else //Check Right { for (int speed = this.hSpeed; speed >= 0; speed--) { if ( this.posCol+this.stringLength+speed < Area.Width-2) { this.hSpeed = speed; break; } } foreach (Pieces piece in existingPieces) { if (piece.posRow == currElement.posRow) { if (piece.posCol < currElement.posCol + currElement.stringLength + currElement.hSpeed) { result = false; } } } } return result; }
private void PlacePieceAction(IClient client, int pieceIndex, int highestIndex, Pieces piece, int orientation, int posX, int posY, byte[] grid) { Log.Default.WriteLine(LogLevels.Debug, "Game {0}: PlacePieceAction[{1}]{2}:{3} {4} {5} at {6},{7} {8}", Name, client.Name, pieceIndex, highestIndex, piece, orientation, posX, posY, grid == null ? -1 : grid.Count(x => x > 0)); //if (index != player.PieceIndex) // Log.Default.WriteLine(LogLevels.Error, "!!!! piece index different for player {0} local {1} remote {2}", player.Name, player.PieceIndex, index); bool sendNextPieces = false; // Set grid client.Grid = grid; // Get next piece client.PieceIndex = pieceIndex; List<Pieces> nextPiecesToSend = new List<Pieces>(); Log.Default.WriteLine(LogLevels.Debug, "{0} {1} indexes: {2} {3}", client.Id, client.Name, highestIndex, pieceIndex); if (highestIndex < pieceIndex) Log.Default.WriteLine(LogLevels.Error, "PROBLEM WITH INDEXES!!!!!"); if (highestIndex < pieceIndex + PiecesSendOnPlacePiece) // send many pieces when needed { for (int i = 0; i < 2 * PiecesSendOnPlacePiece; i++) nextPiecesToSend.Add(_pieceProvider[highestIndex + i]); sendNextPieces = true; } else if (highestIndex < pieceIndex + 2 * PiecesSendOnPlacePiece) // send next pieces only if needed { for (int i = 0; i < PiecesSendOnPlacePiece; i++) nextPiecesToSend.Add(_pieceProvider[highestIndex + i]); sendNextPieces = true; } // Send grid to other playing players and spectators foreach (IClient target in Clients.Where(x => x != client)) target.OnGridModified(client.Id, grid); if (sendNextPieces) { Log.Default.WriteLine(LogLevels.Debug, "Send next piece {0} {1} {2}", highestIndex, pieceIndex, nextPiecesToSend.Any() ? nextPiecesToSend.Select(x => x.ToString()).Aggregate((n, i) => n + "," + i) : String.Empty); // Send next pieces client.OnPiecePlaced(highestIndex, nextPiecesToSend); } }
public void ClientPlacePiece(int pieceIndex, int highestIndex, Pieces piece, int orientation, int posX, int posY, byte[] grid) { SetCallbackAndAddress(); Host.ClientPlacePiece(pieceIndex, highestIndex, piece, orientation, posX, posX, grid); }
public Piece(Pieces _curPiece) { curPiece = _curPiece; }
public ImageBrush getImageBrush(Pieces pieceType) { /*images were imbeded, this gets em*/ System.Reflection.Assembly myAssembly = System.Reflection.Assembly.GetExecutingAssembly(); Stream stream = myAssembly.GetManifestResourceStream(getImageResorcePath(pieceType)); BitmapFrame bmp = BitmapFrame.Create(stream); Image image = new Image(); image.Source = bmp; return new ImageBrush(image.Source); }
protected void PlayMove(ChessboardCell from, ChessboardCell to, Pieces promote_to) { Factory.Instance.CreateCommand(Commands.PlayMove, m_engine.GetLegalMove(from, to, promote_to)).Execute(m_engine); }
// can use IList interface on this public DataTable GetACollection(Pieces p, String did = null) { DataTable dt = new DataTable(); try { switch (p) { default: break; case Pieces.HVParams: HVParams hv = new HVParams(); dt = hv.Get(did); break; case Pieces.HVResults: HVPlateauResults hvr = new HVPlateauResults(); dt = hvr.AllHVPlateauResults(did); break; case Pieces.Measurements: Measurements ms = new Measurements(); dt = ms.AllMeasurements(did); break; case Pieces.CountingAnalyzers: CountingAnalysisParameters cap = new CountingAnalysisParameters(); dt = cap.AnalyzerParamsForDetector(did); break; case Pieces.AnalysisMethodSpecifiers: using(AnalysisMethodSpecifiers am = new AnalysisMethodSpecifiers()) { dt = am.MethodsForDetector(did); } break; case Pieces.Detectors: Detectors clsD = new Detectors(); dt = clsD.getDetectors(true); break; case Pieces.LMParams: LMNetCommParams blue = new LMNetCommParams(); dt = blue.Get(did); break; case Pieces.LMMultParams: LMMultiplicityParams purple = new LMMultiplicityParams(); dt = purple.Get(did); break; case Pieces.DetectorTypes: Descriptors clsDT = new Descriptors("detector_types"); dt = clsDT.getDescs(); break; case Pieces.Materials: Descriptors clsMtl = new Descriptors("material_types"); dt = clsMtl.getDescs(); break; case Pieces.TestParams: TestParams tp = new TestParams(); dt = tp.Get(); break; case Pieces.NormParams: NormParams np = new NormParams(); dt = np.Get(did); break; case Pieces.AASSetupParams: AASSetupParams aass = new AASSetupParams(); dt = aass.Get(did); break; case Pieces.BackgroundParams: BackgroundParams clsB = new BackgroundParams(); TruncatedBackgroundParams clsTB = new TruncatedBackgroundParams(); dt = clsB.Get(did); DataTable dt2 = clsTB.Get(did); dt.Merge(dt2); break; // next: caution, should use select/join case Pieces.Facilities: Descriptors clsF = new Descriptors("facility_names"); dt = clsF.getDescs(); break; case Pieces.MBAs: Descriptors MBA = new Descriptors(p.ToString()); dt = MBA.getDescs(); break; case Pieces.Items: Items clsI = new Items(); dt = clsI.getItems(); break; case Pieces.CollarItems: CollarItems clsCI = new CollarItems(); dt = clsCI.getItems(); break; case Pieces.Isotopics: Isotopics clsIs = new Isotopics(); dt = clsIs.getIsotopics(); break; case Pieces.Strata: Strata s = new Strata(); dt = s.Get(); break; case Pieces.StrataWithAssoc: Strata ss = new Strata(); dt = ss.GetAssociations(did); break; case Pieces.AcquireParams: AcquireParams aq = new AcquireParams(); dt = aq.Get(did); break; case Pieces.IOCodes: Descriptors ioc = new Descriptors("io_code"); dt = ioc.getDescs(); break; case Pieces.InvChangeCodes: Descriptors icc = new Descriptors("inventory_change_code"); dt = icc.getDescs(); break; case Pieces.UnattendedParams: UnattendParams u = new UnattendParams(); dt = u.Get(did); break; case Pieces.CmPuRatioParams: cm_pu_ratio_rec cpu = new cm_pu_ratio_rec(); dt = cpu.Get(); break; case Pieces.Results: Results rr = new Results(); dt = rr.AllResults(did); break; } } catch (Exception caught) { DBMain.AltLog(LogLevels.Warning, 70191, "Get Collection '" + caught.Message + "' "); } return dt; }
public bool PlacePiece(IClient client, int pieceIndex, int highestIndex, Pieces piece, int orientation, int posX, int posY, byte[] grid) { if (client == null) throw new ArgumentNullException("client"); if (State != GameStates.GameStarted) { Log.Default.WriteLine(LogLevels.Warning, "Cannot place piece, game {0} is not started", Name); return false; } if (client.Game != this) { Log.Default.WriteLine(LogLevels.Error, "Cannot place piece, client {0} is not in this game {1} but in game {2}", client.Name, Name, client.Game == null ? "???" : client.Game.Name); return false; } if (client.State != ClientStates.Playing) { Log.Default.WriteLine(LogLevels.Warning, "Cannot place piece, client {0} is not playing", client.Name); return false; } // _actionQueue.Enqueue(() => PlacePieceAction(client, pieceIndex, highestIndex, piece, orientation, posX, posY, grid)); return true; }
// Use this for initialization public void Init( Pieces type, GameObject display ) { pieceType = type ; this.display = display ; }