Skip to content

Commit f692214

Browse files
committed
Add cell teleport and server cell switch
1 parent 074b10b commit f692214

File tree

16 files changed

+235
-188
lines changed

16 files changed

+235
-188
lines changed

api/lib/src/event/event.mapper.dart

Lines changed: 160 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/lib/src/event/hybrid.dart

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,14 @@ sealed class HybridWorldEvent extends WorldEvent
55
with HybridWorldEventMappable
66
implements ClientWorldEvent, ServerWorldEvent {}
77

8+
@MappableClass()
9+
final class CellSwitched extends HybridWorldEvent with CellSwitchedMappable {
10+
final VectorDefinition? cell;
11+
final bool selected, teleport;
12+
13+
CellSwitched(this.cell, {this.selected = true, this.teleport = false});
14+
}
15+
816
@MappableClass()
917
final class BackgroundChanged extends HybridWorldEvent
1018
with BackgroundChangedMappable {

api/lib/src/event/process/server.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -478,5 +478,7 @@ ServerProcessed processServerEvent(
478478
}
479479
}
480480
return ServerProcessed(state.copyWith(info: info));
481+
case CellSwitched():
482+
return ServerProcessed(null);
481483
}
482484
}

api/lib/src/event/server.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ final class WorldInitialized extends ServerWorldEvent
3434
clearUserInterface: true,
3535
info: state.info.copyWith(
3636
teams: mode?.item.teams ?? {},
37-
script: mode?.location,
37+
gameMode: mode?.location,
3838
),
3939
table: mode?.item.tables[state.tableName] ?? GameTable(),
4040
teamMembers: const {},

api/lib/src/models/table.mapper.dart

Lines changed: 0 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/lib/bloc/world/bloc.dart

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,15 @@ class WorldBloc extends Bloc<PlayableWorldEvent, ClientWorldState> {
8787
})
8888
..serverEvents.listen(_processEvent);
8989

90+
on<CellSwitched>((event, emit) {
91+
emit(
92+
state.copyWith(
93+
selectedCell: event.selected ? event.cell : state.selectedCell,
94+
selectedDeck: null,
95+
showHand: true,
96+
),
97+
);
98+
});
9099
on<ServerWorldEvent>((event, emit) async {
91100
try {
92101
final signature = state.assetManager.createSignature();
@@ -121,17 +130,6 @@ class WorldBloc extends Bloc<PlayableWorldEvent, ClientWorldState> {
121130
),
122131
);
123132
});
124-
on<CellSwitched>((event, emit) {
125-
emit(
126-
state.copyWith(
127-
selectedCell: event.toggle && state.selectedCell == event.cell
128-
? null
129-
: event.cell,
130-
selectedDeck: null,
131-
showHand: true,
132-
),
133-
);
134-
});
135133
on<SwitchCellOnMoveChanged>((event, emit) {
136134
emit(state.copyWith(switchCellOnMove: event.value));
137135
});

app/lib/bloc/world/local.dart

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,6 @@ final class HandChanged extends LocalWorldEvent with HandChangedMappable {
1515
HandChanged.toggle({this.deck}) : show = null;
1616
}
1717

18-
@MappableClass()
19-
final class CellSwitched extends LocalWorldEvent with CellSwitchedMappable {
20-
final VectorDefinition? cell;
21-
final bool toggle;
22-
23-
CellSwitched(this.cell, {this.toggle = false});
24-
}
25-
2618
@MappableClass()
2719
final class ColorSchemeChanged extends LocalWorldEvent
2820
with ColorSchemeChangedMappable {

0 commit comments

Comments
 (0)