1
0
Fork 0
mirror of https://github.com/Nioux/AideDeJeu.git synced 2025-10-30 06:56:10 +00:00
This commit is contained in:
Yan Maniez 2020-05-16 13:12:24 +02:00
parent 49a46595d7
commit 8987e446a8
8 changed files with 132 additions and 6 deletions

View file

@ -19,6 +19,8 @@ class PlayerCharacterBloc
yield* _mapRaceEventToState(event);
} else if (event is SubRaceEvent) {
yield* _mapSubRaceEventToState(event);
} else if (event is OriginEvent) {
yield* _mapOriginEventToState(event);
} else if (event is BackgroundEvent) {
yield* _mapBackgroundEventToState(event);
} else if (event is SubBackgroundEvent) {
@ -33,11 +35,14 @@ class PlayerCharacterBloc
var subRaces = await _db.loadSubRaces(event.item);
yield state.copyWithClean(race: event.item, subRaces: subRaces);
}
Stream<PlayerCharacterState> _mapSubRaceEventToState(
SubRaceEvent event) async* {
yield state.copyWith(subRace: event.item);
}
Stream<PlayerCharacterState> _mapOriginEventToState(
OriginEvent event) async* {
yield state.copyWith(origin: event.item);
}
Stream<PlayerCharacterState> _mapBackgroundEventToState(
BackgroundEvent event) async* {
var subBackgrounds = await _db.loadSubBackgrounds(event.item);
@ -50,7 +55,8 @@ class PlayerCharacterBloc
Stream<PlayerCharacterState> _mapLoadEventToState(
LoadEvent event) async* {
var races = await _db.loadRaces();
var origins = await _db.loadOrigins();
var backgrounds = await _db.loadBackgrounds();
yield state.copyWith(races: races, backgrounds: backgrounds); // state;
yield state.copyWith(races: races, origins: origins, backgrounds: backgrounds); // state;
}
}