Skip to content

Commit

Permalink
fix bug: if character last in list, conditions does not expire on nex…
Browse files Browse the repository at this point in the history
…t round pressed
  • Loading branch information
Tarmslitaren committed Jan 7, 2023
1 parent 5477ed9 commit da85d38
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ class NextRoundCommand extends Command {
GameMethods.shuffleDecksIfNeeded();
GameMethods.updateElements();
GameMethods.setRoundState(RoundState.chooseInitiative);
GameMethods.sortCharactersFirst();
if(_gameState.currentList.last.turnState != TurnsState.done) {
GameMethods.setTurnDone(_gameState.currentList.length - 1);
}
if(_gameState.currentList.last.turnState != TurnsState.done) {
GameMethods.setTurnDone(_gameState.currentList.length - 1);
}
GameMethods.clearTurnState(false);
GameMethods.sortCharactersFirst();

_gameState.toastMessage.value = "";
for(var rule in _gameState.scenarioSpecialRules) {
Expand Down
45 changes: 45 additions & 0 deletions tatus
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
diff --git a/frosthaven_assistant/lib/Resource/commands/next_round_command.dart b/frosthaven_assistant/lib/Resource/commands/next_round_command.dart
index 5a52bd7..40deba5 100644
--- a/frosthaven_assistant/lib/Resource/commands/next_round_command.dart
+++ b/frosthaven_assistant/lib/Resource/commands/next_round_command.dart
@@ -23,7 +23,6 @@ class NextRoundCommand extends Command {
GameMethods.shuffleDecksIfNeeded();
GameMethods.updateElements();
GameMethods.setRoundState(RoundState.chooseInitiative);
- GameMethods.sortCharactersFirst();
if(_gameState.currentList.last.turnState != TurnsState.done) {
GameMethods.setTurnDone(_gameState.currentList.length - 1);
}
@@ -31,6 +30,7 @@ class NextRoundCommand extends Command {
GameMethods.setTurnDone(_gameState.currentList.length - 1);
}
GameMethods.clearTurnState(false);
+ GameMethods.sortCharactersFirst();

_gameState.toastMessage.value = "";
for(var rule in _gameState.scenarioSpecialRules) {
diff --git a/frosthaven_assistant/lib/Resource/game_methods.dart b/frosthaven_assistant/lib/Resource/game_methods.dart
index 70a3991..a95541c 100644
--- a/frosthaven_assistant/lib/Resource/game_methods.dart
+++ b/frosthaven_assistant/lib/Resource/game_methods.dart
@@ -555,7 +555,7 @@ class GameMethods {
}
}

- static void setTurnDone(int index) {
+ static void setTurnDone(int index) { 
for (int i = 0; i < index; i++) {
if(_gameState.currentList[i].turnState != TurnsState.done) {
_gameState.currentList[i].turnState = TurnsState.done;
diff --git a/frosthaven_assistant/lib/main_state.dart b/frosthaven_assistant/lib/main_state.dart
index af5b7a9..c48e2a7 100644
--- a/frosthaven_assistant/lib/main_state.dart
+++ b/frosthaven_assistant/lib/main_state.dart
@@ -36,6 +36,7 @@ class MainState extends State<MyHomePage>
switch (state) {
case AppLifecycleState.resumed:
print("app in resumed");
+ rebuildAllChildren(context); //might be a bit performance heavy
//TODO: reconnect to last known if disconnected, and get latest state if still connected.

break;

0 comments on commit da85d38

Please sign in to comment.