public PieceType(PieceTypeIdentifier identifier, string name) { Identifier = identifier; Name = name; _Attack = 1; _Support = 1; _Defence = 3; _Movement = 2; _PassThrough = false; }
public PiecePlacement(PieceTypeIdentifier type, Position position) { Type = type; Position = position; }
public PiecePromotion(Position location, PieceTypeIdentifier promotion) { Position = location; Type = promotion; }
public void PromotePiece(Position position, PieceTypeIdentifier type) { position.CheckValidity(); if (CurrentTurnActions >= GameConstants.ActionsPerTurn) throw new GameException("You may not perform any more actions this turn"); Hex hex = GetHex(position); Piece piece = hex.Piece; if (piece == null) throw new GameException("There is no piece to promote, the specified hex is empty"); if (piece.Type.Identifier != PieceTypeIdentifier.Pawn) throw new GameException("Only pawns may be promoted"); if (!piece.CanMove) throw new GameException("This piece has already been moved this turn and can hence not be promoted"); if(type == PieceTypeIdentifier.Pawn) throw new GameException("Invalid promotion identifier"); bool isClear = true; foreach (Hex neighbour in hex.Neighbours) { Piece neighbourPiece = neighbour.Piece; if (neighbourPiece != null && !object.ReferenceEquals(neighbourPiece.Owner, CurrentTurnPlayer)) { isClear = false; break; } } if (!isClear) throw new GameException("You cannot promote a piece that is in direct proximity of an opponent's piece"); Piece newPiece = new Piece(GameConstants.Pieces[type], CurrentTurnPlayer); hex.Piece = newPiece; newPiece.Hex = hex; newPiece.CanMove = false; piece.Hex = null; CurrentTurnActions++; }