-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add countdown and word entry details card
- Loading branch information
1 parent
e58425e
commit c203d07
Showing
30 changed files
with
630 additions
and
232 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
export 'dictionaries.dart'; | ||
export 'dictionary_files.dart'; | ||
export 'fonts.dart'; | ||
export 'images.dart'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import 'package:shiritori/backend/backend.dart'; | ||
|
||
const _basePath = 'assets/dicts'; | ||
|
||
final dictionaryFiles = <Language, String>{ | ||
Language.japanese: '$_basePath/dict_ja.json', | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
export 'models/models.dart'; | ||
export 'repositories/repositories.dart'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import 'package:flutter/widgets.dart'; | ||
import 'package:meta/meta.dart'; | ||
import 'package:provider/provider.dart'; | ||
import 'package:shiritori/backend/backend.dart'; | ||
|
||
class Game { | ||
const Game({ | ||
@required this.settings, | ||
@required this.guessesByPlayerIndex, | ||
this.winningPlayerIndex, | ||
}) : assert(settings != null), | ||
assert(guessesByPlayerIndex != null); | ||
|
||
factory Game.startNew(GameSettings settings) { | ||
return Game( | ||
settings: settings, | ||
guessesByPlayerIndex: {0: {}, 1: {}}, | ||
winningPlayerIndex: null, | ||
); | ||
} | ||
|
||
static Game of(BuildContext context) { | ||
return Provider.of<Game>(context, listen: false); | ||
} | ||
|
||
final GameSettings settings; | ||
final Map<int, Set<String>> guessesByPlayerIndex; | ||
final int winningPlayerIndex; | ||
|
||
Set<String> get allGuesses { | ||
return guessesByPlayerIndex.entries.expand((entry) => entry.value).toSet(); | ||
} | ||
|
||
bool hasBeenGuessed(String guess) { | ||
return allGuesses.contains(guess); | ||
} | ||
|
||
bool isValidGuess(String guess) { | ||
return hasBeenGuessed(guess); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import 'package:flutter/widgets.dart'; | ||
import 'package:meta/meta.dart'; | ||
import 'package:shiritori/backend/backend.dart'; | ||
|
||
@immutable | ||
abstract class GameSettings { | ||
const GameSettings({ | ||
@required this.dictionary, | ||
@required this.answeringDuration, | ||
@required this.enemyType, | ||
}); | ||
|
||
final Dictionary dictionary; | ||
final Duration answeringDuration; | ||
final GameEnemyType enemyType; | ||
} | ||
|
||
@immutable | ||
class SingleplayerGameSettings implements GameSettings { | ||
const SingleplayerGameSettings({ | ||
@required this.dictionary, | ||
@required this.answeringDuration, | ||
}); | ||
|
||
@override | ||
final Dictionary dictionary; | ||
|
||
@override | ||
final Duration answeringDuration; | ||
|
||
@override | ||
final GameEnemyType enemyType = GameEnemyType.singleplayer; | ||
} | ||
|
||
@immutable | ||
class MultiplayerGameSettings implements GameSettings { | ||
const MultiplayerGameSettings({ | ||
@required this.dictionary, | ||
@required this.answeringDuration, | ||
}); | ||
|
||
@override | ||
final Dictionary dictionary; | ||
|
||
@override | ||
final Duration answeringDuration; | ||
|
||
@override | ||
final GameEnemyType enemyType = GameEnemyType.multiplayer; | ||
} | ||
|
||
enum GameEnemyType { | ||
singleplayer, | ||
multiplayer, | ||
} | ||
|
||
extension GameEnemyTypeX on GameEnemyType { | ||
bool get isSingleplayer => this == GameEnemyType.singleplayer; | ||
bool get isMultiplayer => this == GameEnemyType.multiplayer; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export 'dictionaries.dart'; | ||
export 'game.dart'; | ||
export 'game_settings.dart'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.