1
0
Fork 0
mirror of https://github.com/Nioux/AideDeJeu.git synced 2025-10-30 23:16:09 +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;
}
}

View file

@ -20,6 +20,10 @@ class SubRaceEvent extends SetItemEvent<SubRaceItem> {
SubRaceEvent(SubRaceItem item) : super(item);
}
class OriginEvent extends SetItemEvent<OriginItem> {
OriginEvent(OriginItem item) : super(item);
}
class BackgroundEvent extends SetItemEvent<BackgroundItem> {
BackgroundEvent(BackgroundItem item) : super(item);
}

View file

@ -8,6 +8,9 @@ class PlayerCharacterState extends Equatable {
final List<RaceItem> races;
final List<SubRaceItem> subRaces;
final OriginItem origin;
final List<OriginItem> origins;
final BackgroundItem background;
final SubBackgroundItem subBackground;
final List<BackgroundItem> backgrounds;
@ -18,6 +21,8 @@ class PlayerCharacterState extends Equatable {
this.races,
this.subRace,
this.subRaces,
this.origin,
this.origins,
this.background,
this.backgrounds,
this.subBackground,
@ -29,6 +34,8 @@ class PlayerCharacterState extends Equatable {
List<RaceItem> races,
SubRaceItem subRace,
List<SubRaceItem> subRaces,
OriginItem origin,
List<OriginItem> origins,
BackgroundItem background,
List<BackgroundItem> backgrounds,
SubBackgroundItem subBackground,
@ -39,6 +46,8 @@ class PlayerCharacterState extends Equatable {
races: races ?? this.races,
subRace: subRace ?? this.subRace,
subRaces: subRaces ?? this.subRaces,
origin: origin ?? this.origin,
origins: origins ?? this.origins,
background: background ?? this.background,
backgrounds: backgrounds ?? this.backgrounds,
subBackground: subBackground ?? this.subBackground,
@ -51,6 +60,8 @@ class PlayerCharacterState extends Equatable {
List<RaceItem> races,
SubRaceItem subRace,
List<SubRaceItem> subRaces,
OriginItem origin,
List<OriginItem> origins,
BackgroundItem background,
List<BackgroundItem> backgrounds,
SubBackgroundItem subBackground,
@ -61,6 +72,8 @@ class PlayerCharacterState extends Equatable {
races: races ?? this.races,
subRace: race != null ? null : subRace ?? this.subRace,
subRaces: race != null ? subRaces : subRaces ?? this.subRaces,
origin: origin ?? this.origin,
origins: origins ?? this.origins,
background: background ?? this.background,
backgrounds: backgrounds ?? this.backgrounds,
subBackground: background != null ? null : subBackground ?? this.subBackground,
@ -74,6 +87,8 @@ class PlayerCharacterState extends Equatable {
subRace,
races,
subRaces,
origin,
origins,
background,
subBackground,
backgrounds,