diff --git a/lib/util.dart b/lib/util.dart index edaf5e1..aefa59d 100644 --- a/lib/util.dart +++ b/lib/util.dart @@ -25,6 +25,18 @@ class Util { emptyBoardClassic, ]; + static TTCState nextTurn(TTCState currentPlayer, + {TTCState defaultState = TTCState.x}) { + switch (currentPlayer) { + case TTCState.x: + return TTCState.o; + case TTCState.o: + return TTCState.x; + default: + return defaultState; + } + } + static String stateText(TTCState state) => state.name.toUpperCase(); static String cellAddress(int index) => "${index % 3}, ${(index / 3).floor()}";