PieceType class

Specifies a piece type, with all of its moves and attributes.

Constructors

PieceType({String? betza, required List<MoveDefinition> moves, bool royal = false, PiecePromoOptions promoOptions = PiecePromoOptions.promoPiece, bool enPassantable = false, bool noSanSymbol = false, int value = Bishop.defaultPieceValue, List<RegionEffect> regionEffects = const [], List<Action> actions = const [], PieceOptimisationData? optimisationData})
const
PieceType.alfil()
Jumps two squares diagonally in any direction.
factory
PieceType.amazon()
Moves and captures like a queen or a knight.
factory
PieceType.archbishop()
Moves and captures like a bishop or a knight.
factory
PieceType.berolinaPawn()
An 'inverted' pawn that moves diagonally and captures fowards.
factory
PieceType.bishop()
factory
PieceType.biskni()
Moves like a bishop, captures like a knight.
factory
PieceType.bisroo()
Moves like a bishop, captures like a rook.
factory
PieceType.blocker({bool immortal = true})
A piece that does nothing but blocks. Can optionally be immortal.
factory
PieceType.camel()
Jumps 3 squares in one direction, 1 in the other. Like a long knight.
factory
PieceType.chancellor()
Moves and captures like a rook or a knight.
factory
PieceType.commoner()
A non-royal king.
factory
PieceType.dabbaba()
Jumps two squares orthogonally in any direction.
factory
PieceType.duck()
Can move to any empty square on the board.
factory
PieceType.empty()
factory
PieceType.ferz()
Moves one square diagonally in any direction.
factory
PieceType.fromBetza(String betza, {bool royal = false, PiecePromoOptions promoOptions = PiecePromoOptions.promoPiece, bool enPassantable = false, bool noSanSymbol = false, int value = Bishop.defaultPieceValue, List<RegionEffect> regionEffects = const [], List<Action> actions = const []})
Generate a piece type with all of its moves from Betza notation.
factory
PieceType.fromJson(Map<String, dynamic> json, {List<BishopTypeAdapter> adapters = const []})
factory
PieceType.giraffe()
Jumps 4 squares in one direction, 1 in the other.
factory
PieceType.grasshopper()
Moves and captures like a queen, but must jump over exactly one piece, and land on the square directly after it.
factory
PieceType.king()
factory
PieceType.knibis()
Moves like a knight, captures like a bishop.
factory
PieceType.knight()
factory
PieceType.kniroo()
Moves like a knight, captures like a rook.
factory
PieceType.longMovePawn(int moveLength)
factory
PieceType.nightrider()
A piece that can make any number of consecutive knight moves in the same direction.
factory
PieceType.pawn()
factory
PieceType.queen()
factory
PieceType.roobis()
Moves like a rook, captures like a bishop.
factory
PieceType.rook()
factory
PieceType.rookni()
Moves like a rook, captures like a knight.
factory
PieceType.simplePawn()
A pawn with no double move and no en passant.
factory
PieceType.staticKing()
A king that cannot move.
factory
PieceType.wazir()
Moves one square orthogonally in any direction.
factory
PieceType.zebra()
Jumps 3 squares in one direction, 2 in the other.
factory

Properties

actions List<Action>
final
betza String?
A Betza notation string that defines the piece. See: https://www.gnu.org/software/xboard/Betza.html
final
changePieceRegionEffects List<RegionEffect>
Region effects that change the piece type.
no setter
enPassantable bool
Whether this piece can set the en passant flag.
final
hashCode int
The hash code for this object.
no setterinherited
moves List<MoveDefinition>
All of the different move groups this piece can make.
final
noSanSymbol bool
If true, the piece symbol will be omitted in SAN representations of moves. For example, pawn moves should be like 'b4', rather than 'Pb4'.
final
optimisationData PieceOptimisationData?
Contains precomputed flags that help move generation run faster. You don't need to set this yourself, it is generated during normalise().
final
promoOptions PiecePromoOptions
Defines the promotion behaviour of this piece type.
final
regionEffects List<RegionEffect>
Regions in which the behaviour of the piece is altered.
final
restrictMovementRegionEffects List<RegionEffect>
Region effects that restrict movement.
no setter
royal bool
Royal pieces can be checkmated, and can castle.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
value int
The value of the piece, in centipawns (a pawn is 100). Can be overridden in a Variant.
final
winRegionEffects List<RegionEffect>
Region effects that win the game.
no setter

Methods

copyWith({String? betza, List<MoveDefinition>? moves, bool? royal, PiecePromoOptions? promoOptions, bool? enPassantable, bool? noSanSymbol, int? value, List<RegionEffect>? regionEffects, List<Action>? actions, PieceOptimisationData? optimisationData}) PieceType
Returns a copy of this piece type with some properties changed.
normalise(BoardSize size) PieceType
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
promotable() PieceType
Returns a copy of the piece type with PiecePromoOptions.promotable.
toJson({bool verbose = false, List<BishopTypeAdapter> adapters = const []}) Map<String, dynamic>
toString() String
A string representation of this object.
inherited
withAction(Action action, {bool first = false}) PieceType
Returns a copy of the piece type with action added. If first is true, it will be added to the start of the list.
withImmortality() PieceType
Returns a copy of the piece type with immortality.
withNoPromotion() PieceType
Returns a copy of the piece type with PiecePromoOptions.none.
withRegionEffect(RegionEffect effect) PieceType
Returns a copy of the piece type with effect added.
withRoyal() PieceType
Returns a royal version of the piece type.
withValue(int value) PieceType
Returns a copy of the piece type with value.

Operators

operator ==(Object other) bool
The equality operator.
inherited