Piece class

Generic class for the pieces all the types of pieces implement this class.

We use this to be able to treat all the types as the same one with a common interface. It haves the following methods and fields:

  • Userdata: Instance of the singleton to render custom skins.
  • _img: String to save the img name.
  • _value: Value of the Piece.
  • isWhite: Boolean, it sets the color of the piece.
  • isEmpty: Boolean method, it returns if a Piece is Empty or not(we use a Empty piece for all the empty squares).
  • possibleMovements: Returns all the possible movements for the current board for a given piece.
Implementers

Constructors

Piece({required bool isWhite})

Properties

hashCode int
The hash code for this object.
read-onlyinherited
isWhite bool
read / write
runtimeType Type
A representation of the runtime type of the object.
read-onlyinherited
userData UserData
final

Methods

color() bool
getImg() String
getValue() int
isEmpty() bool
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
possibleMovements(int x, int y, List<List<Piece>> board, bool reversedBoard, List<List<int>> lastMovement) List<List<int>>
toString() String
A string representation of this object.
inherited

Operators

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