Skip to content

Commit

Permalink
wip: tech level
Browse files Browse the repository at this point in the history
chore: LICENSE MIT -> GNU AFFERO GENERAL PUBLIC
  • Loading branch information
Arenukvern committed Sep 1, 2024
1 parent a39aca4 commit 58ac80f
Show file tree
Hide file tree
Showing 7 changed files with 701 additions and 57 deletions.
682 changes: 661 additions & 21 deletions LICENSE

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -641,7 +641,7 @@ class GameSaver {
void onTick() {
final now = DateTime.now();
if (now.difference(_lastSaveDate).inSeconds > 3) {
debugPrint('game_saver onTick');
debugPrint('game_saver saving');
_lastSaveDate = now;
onSave();
}
Expand Down
28 changes: 10 additions & 18 deletions lib/subgames/quick_game/dialogs/core/dialog_controller.dart
Original file line number Diff line number Diff line change
@@ -1,19 +1,11 @@
import 'package:flutter/material.dart';
import 'package:word_by_word_game/pack_core/global_states/global_states.dart';
import 'package:word_by_word_game/common_imports.dart';

final class DialogController {
DialogController({
required this.showLevelLostDialog,
required this.showLevelWinDialog,
required this.showLevelWordSuggestionDialog,
required this.closeDialog,
required this.closeDialogAndResume,
required this.showTechnologiesTree,
});
final ValueChanged<EndLevelEvent> showLevelLostDialog;
final ValueChanged<EndLevelEvent> showLevelWinDialog;
final VoidCallback closeDialog;
final VoidCallback closeDialogAndResume;
final VoidCallback showLevelWordSuggestionDialog;
final VoidCallback showTechnologiesTree;
}
typedef DialogController = ({
ValueChanged<EndLevelEvent> showLevelLostDialog,
ValueChanged<EndLevelEvent> showLevelWinDialog,
VoidCallback closeDialog,
VoidCallback closeDialogAndResume,
VoidCallback showLevelWordSuggestionDialog,
VoidCallback showTechnologiesTree,
ValueChanged<TechnologyLevelIndex> showTechLevelAchieveDialog,
});
8 changes: 7 additions & 1 deletion lib/subgames/quick_game/dialogs/core/dialog_stack.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import 'package:word_by_word_game/pack_core/ads/ads.dart';
import 'package:word_by_word_game/pack_core/global_states/global_states.dart';
import 'package:word_by_word_game/subgames/quick_game/dialogs/dialogs.dart';
import 'package:word_by_word_game/subgames/quick_game/dialogs/level_word_suggestion.dart';
import 'package:word_by_word_game/subgames/quick_game/dialogs/technologies/tech_level_achieved_dialog.dart';
import 'package:word_by_word_game/subgames/quick_game/dialogs/technologies/tech_level_dialog.dart';
import 'package:word_by_word_game/subgames/quick_game/dialogs/tutorial_dialogs/tutorial_dialogs.dart';

part 'dialog_stack_notifier.dart';
Expand All @@ -20,6 +22,7 @@ enum GameDialogType {
tutorialBool,
tutorialOk,
technologiesTree,
techLevelAchieved,
}

class DialogStack extends HookWidget {
Expand All @@ -40,7 +43,10 @@ class DialogStack extends HookWidget {
isVisible: state.dialogType != GameDialogType.none,
child: switch (state.dialogType) {
GameDialogType.none => const SizedBox(),
GameDialogType.technologiesTree => TechnologiesTreeDialog(
GameDialogType.technologiesTree => TechLevelsDialog(
onClose: dialogController.closeDialogAndResume,
),
GameDialogType.techLevelAchieved => TechLevelAchievedDialog(
onClose: dialogController.closeDialogAndResume,
),
GameDialogType.levelLost => LevelLostDialog(
Expand Down
11 changes: 9 additions & 2 deletions lib/subgames/quick_game/dialogs/core/dialog_stack_notifier.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,14 @@ class DialogStackNotifier extends ChangeNotifier {
}
static DialogController getDialogController(final BuildContext context) =>
context.read<DialogStackNotifier>().dialogController;
late final dialogController = DialogController(
late final DialogController dialogController = (
showLevelLostDialog: _showLevelLostDialog,
closeDialog: _closeDialog,
showLevelWinDialog: _showLevelWinDialog,
showLevelWordSuggestionDialog: _showLevelWordSuggestionDialog,
showTechnologiesTree: _showTechnologiesTree,
closeDialogAndResume: onResume,
showTechLevelAchieveDialog: _showTechLevelAchieveDialog,
);
late final _tutorialSubscriber = _TutorialSubscriber(
diDto: dto,
Expand All @@ -37,7 +38,8 @@ class DialogStackNotifier extends ChangeNotifier {
GameDialogType.technologiesTree ||
GameDialogType.levelWordSuggestion ||
GameDialogType.tutorialBool ||
GameDialogType.tutorialOk =>
GameDialogType.tutorialOk ||
GameDialogType.techLevelAchieved =>
false,
};

Expand Down Expand Up @@ -102,6 +104,11 @@ class DialogStackNotifier extends ChangeNotifier {
_pause();
}

void _showTechLevelAchieveDialog(final TechnologyLevelIndex levelIndex) {
dialogType = GameDialogType.techLevelAchieved;
_pause();
}

void _pause() => dto.globalGameBloc.dto.mechanics.worldTime.pause();
void _resume() => dto.globalGameBloc.dto.mechanics.worldTime.resume();

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import 'package:flutter/material.dart';

class TechLevelAchievedDialog extends StatelessWidget {
const TechLevelAchievedDialog({
required this.onClose,
super.key,
});

final VoidCallback onClose;

@override
Widget build(final BuildContext context) => const Placeholder();
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,10 @@ import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter_animate/flutter_animate.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_hooks/flutter_hooks.dart';
import 'package:wbw_core/wbw_core.dart';
import 'package:wbw_design_core/wbw_design_core.dart';
import 'package:wbw_dictionaries/wbw_dictionaries.dart';
import 'package:word_by_word_game/pack_core/global_states/global_states.dart';
import 'package:word_by_word_game/subgames/quick_game/dialogs/technologies/tech_level_dialog.dart';

typedef TechnologyWordInfoTuple = ({
TechnologyModel technology,
Expand All @@ -27,18 +25,6 @@ typedef TechnologyWordInfoTuple = ({
UsefulWordModel? languageWord
});

class TechnologiesTreeDialog extends HookWidget {
const TechnologiesTreeDialog({
required this.onClose,
super.key,
});
final VoidCallback onClose;

@override
Widget build(final BuildContext context) =>
TechLevelsDialog(onClose: onClose);
}

class _TechnologyTile extends StatelessWidget {
const _TechnologyTile({
required this.value,
Expand Down

0 comments on commit 58ac80f

Please sign in to comment.