2024-06-16 12:18:59 +02:00
|
|
|
import 'dart:math';
|
2024-06-16 23:56:48 +02:00
|
|
|
|
|
|
|
import '../../enums/StoneColor.dart';
|
2024-06-16 12:18:59 +02:00
|
|
|
|
|
|
|
/// Class to represent a stone on the board.
|
|
|
|
class Stone {
|
|
|
|
/// Color of the stone
|
2024-06-16 23:56:48 +02:00
|
|
|
late StoneColors stoneColor;
|
2024-06-16 12:18:59 +02:00
|
|
|
|
|
|
|
Stone() {
|
|
|
|
setRandomColor();
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Getter for the color.
|
|
|
|
/// \return color
|
2024-06-16 23:56:48 +02:00
|
|
|
StoneColors getStoneColor() => stoneColor;
|
2024-06-16 12:18:59 +02:00
|
|
|
|
|
|
|
/// Setter for the color
|
|
|
|
/// \param color
|
2024-06-16 23:56:48 +02:00
|
|
|
void setColor(StoneColors stoneColor) {
|
|
|
|
this.stoneColor = stoneColor;
|
2024-06-16 12:18:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/// method that sets a random color
|
|
|
|
void setRandomColor() {
|
2024-06-16 23:56:48 +02:00
|
|
|
stoneColor =
|
2024-06-17 10:48:31 +02:00
|
|
|
StoneColors.values[Random().nextInt(StoneColors.values.length - 1)];
|
2024-06-16 12:18:59 +02:00
|
|
|
}
|
|
|
|
}
|