UserContext.dart 407 B

12345678910111213141516171819202122232425262728
  1. import 'package:gobang/state/State.dart';
  2. class UserContext {
  3. late State _state;
  4. UserContext(){
  5. _state = StartState(this);
  6. }
  7. play() {
  8. _state.play();
  9. }
  10. // 悔棋只能悔棋三次
  11. bool regretChess() {
  12. return _state.regretChess();
  13. }
  14. // 认输10步之内不能认输
  15. bool surrender() {
  16. return _state.surrender();
  17. }
  18. setState(State state){
  19. _state = state;
  20. }
  21. }