Skip to content
Snippets Groups Projects
Select Git revision
  • 0b591288c15a1a566d5c69c4c794555647ae95fc
  • master default protected
  • 19-improve-app-metadata
  • Release_0.8.1_34 protected
  • Release_0.8.0_33 protected
  • Release_0.7.2_32 protected
  • Release_0.7.1_31 protected
  • Release_0.7.0_30 protected
  • Release_0.6.0_29 protected
  • Release_0.5.0_28 protected
  • Release_0.4.0_27 protected
  • Release_0.3.2_26 protected
  • Release_0.3.1_25 protected
  • Release_0.3.0_24 protected
  • Release_0.2.1_23 protected
  • Release_0.2.0_22 protected
  • Release_0.1.2_21 protected
  • Release_0.1.1_20 protected
  • Release_0.1.0_19 protected
  • Release_0.0.18_18 protected
  • Release_0.0.17_17 protected
  • Release_0.0.16_16 protected
  • Release_0.0.15_15 protected
23 results

Contents.json

Blame
  • game.dart 4.19 KiB
    import 'package:flutter_custom_toolbox/flutter_toolbox.dart';
    
    import 'package:momomotus/config/default_game_settings.dart';
    import 'package:momomotus/data/fetch_data_helper.dart';
    import 'package:momomotus/models/settings/settings_game.dart';
    import 'package:momomotus/models/settings/settings_global.dart';
    
    class Game {
      Game({
        // Settings
        required this.gameSettings,
        required this.globalSettings,
    
        // State
        this.isRunning = false,
        this.isStarted = false,
        this.animationInProgress = false,
    
        // Base data
        required this.word,
        required this.dictionary,
    
        // Game data
        this.currentGuess = '',
        this.foundLetters = '',
        required this.guesses,
        this.foundWord = false,
      });
    
      // Settings
      final GameSettings gameSettings;
      final GlobalSettings globalSettings;
    
      // State
      bool isRunning;
      bool isStarted;
      bool animationInProgress;
    
      // Base data
      final String word;
      final List<String> dictionary;
    
      // Game data
      String currentGuess;
      String foundLetters;
      List<String> guesses;
      bool foundWord;
    
      factory Game.createEmpty() {
        return Game(
          // Settings
          gameSettings: GameSettings.createDefault(),
          globalSettings: GlobalSettings.createDefault(),
          // Base data
          word: '',
          dictionary: [],
          // Game data
          guesses: [],
        );
      }
    
      factory Game.createNew({
        GameSettings? gameSettings,
        GlobalSettings? globalSettings,
      }) {
        final GameSettings newGameSettings = gameSettings ?? GameSettings.createDefault();
        final GlobalSettings newGlobalSettings = globalSettings ?? GlobalSettings.createDefault();
    
        final String pickedWord = FetchDataHelper().getRandomWord(
          lang: newGameSettings.lang,