-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
start understanding riverpod: emergency commit, more a backup than a …
…version (docker desktop crashes)
- Loading branch information
Showing
38 changed files
with
4,955 additions
and
293 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 |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* AUTOMATICALLY GENERATED CODE DO NOT MODIFY */ | ||
/* To generate run: "serverpod generate" */ | ||
|
||
// ignore_for_file: library_private_types_in_public_api | ||
// ignore_for_file: public_member_api_docs | ||
// ignore_for_file: implementation_imports | ||
// ignore_for_file: use_super_parameters | ||
// ignore_for_file: type_literal_in_constant_pattern | ||
|
||
// ignore_for_file: no_leading_underscores_for_library_prefixes | ||
import 'package:serverpod_client/serverpod_client.dart' as _i1; | ||
|
||
enum TroopType with _i1.SerializableEntity { | ||
commander; | ||
|
||
static TroopType? fromJson(String name) { | ||
switch (name) { | ||
case 'commander': | ||
return commander; | ||
default: | ||
return null; | ||
} | ||
} | ||
|
||
@override | ||
String toJson() => name; | ||
@override | ||
String toString() => toJson(); | ||
} |
23 changes: 23 additions & 0 deletions
23
bluevsred_flutter/lib/player/active_game_player_troops.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,23 @@ | ||
import 'package:bluevsred_shared/bluesvsred_shared.dart'; | ||
import 'package:riverpod_annotation/riverpod_annotation.dart'; | ||
|
||
part 'active_game_player_troops.g.dart'; | ||
|
||
@riverpod | ||
class ActiveGamePlayerTroops extends _$ActiveGamePlayerTroops { | ||
// ActiveGamePlayerTroops._(); | ||
@override | ||
Future<Set<Troop>> build({required Set<Troop> troops}) async { | ||
return troops; | ||
} | ||
|
||
void addTroops({required List<Troop> newTroops}) { | ||
this. | ||
state | ||
if (state.value != null) { | ||
state.value!.addAll(newTroops); | ||
} else { | ||
state.value => newTroops; | ||
} | ||
} | ||
} |
177 changes: 177 additions & 0 deletions
177
bluevsred_flutter/lib/player/active_game_player_troops.g.dart
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,21 @@ | ||
import 'package:bluevsred_client/bluevsred_client.dart'; | ||
import 'package:bluevsred_flutter/player/active_game_player_troops.dart'; | ||
import 'package:bluevsred_shared/bluesvsred_shared.dart'; | ||
import 'package:flutter_riverpod/flutter_riverpod.dart'; | ||
|
||
import 'active_game_player.dart'; | ||
|
||
Future<void> createGamePlayer( | ||
{required String gamePlayerName, | ||
required ProviderContainer container}) async { | ||
final gamePlayerProvider = activeGamePlayerProvider(gamePlayerName); | ||
// container.listen(gamePlayerProvider, (previous, next) {}); | ||
final troopsProvider = activeGamePlayerTroopsProvider(troops: const {}); | ||
// container.listen(troopsProvider, (previous, next) {}); | ||
|
||
container.read(troopsProvider).value!.addTroops(newTroops: [ | ||
Troop( | ||
troopDb: TroopDb(troopType: TroopType.commander, actionPoints: 10), | ||
gamePlayer: container.read(gamePlayerProvider).value!), | ||
]); | ||
} |
Oops, something went wrong.