123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- import '../models/player.dart';
- import 'driver_online.dart';
- import 'driver_robot.dart';
- import 'driver_user.dart';
- abstract class PlayerDriver {
-
- final Player player;
- bool canBacktrace = true;
-
- static const rstGiveUp = 'giveup';
-
- static const rstRqstDraw = 'rqstrdraw';
-
- static const rstRqstRetract = 'rqstretract';
-
- static const rstDraw = 'draw';
-
- static const rstRetract = 'retract';
- static const rstActions = [
- rstGiveUp,
- rstRqstDraw,
- rstRqstRetract,
- rstDraw,
- rstRetract
- ];
- static bool isAction(String move) {
- return rstActions.contains(move) || move.contains(rstRqstDraw);
- }
- PlayerDriver(this.player);
- static PlayerDriver createDriver(
- Player manager, [
- DriverType type = DriverType.user,
- ]) {
- switch (type) {
- case DriverType.robot:
- return DriverRobot(manager);
- case DriverType.online:
- return DriverOnline(manager);
- default:
- return DriverUser(manager);
- }
- }
-
- Future<bool> tryDraw();
-
- Future<bool> tryRetract();
-
- Future<String?> move();
-
- Future<String> ponder();
-
- void completeMove(String move);
- @override
- String toString() => "$runtimeType ${player.team}";
- }
- class DriverType {
- final String type;
- static const user = DriverType('user');
- static const robot = DriverType('robot');
- static const online = DriverType('online');
- const DriverType(this.type);
- }
|