Skip to content

Commit

Permalink
Add first board events and rendering
Browse files Browse the repository at this point in the history
  • Loading branch information
CodeDoctorDE committed Sep 18, 2024
1 parent f51b522 commit 71104d2
Show file tree
Hide file tree
Showing 10 changed files with 453 additions and 41 deletions.
16 changes: 16 additions & 0 deletions api/lib/src/event/client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,19 @@ final class MessageRequest extends ClientWorldEvent

MessageRequest(this.message);
}

@MappableClass()
final class BoardsSpawnRequest extends ClientWorldEvent
with BoardsSpawnRequestMappable {
final String table;
final List<
({
VectorDefinition cell,
ItemLocation asset,
})> assets;

BoardsSpawnRequest(this.table, this.assets);
BoardsSpawnRequest.single(GlobalVectorDefinition cell, ItemLocation asset)
: table = cell.table,
assets = [(cell: cell.position, asset: asset)];
}
333 changes: 333 additions & 0 deletions api/lib/src/event/event.mapper.dart
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ class ServerWorldEventMapper extends SubClassMapperBase<ServerWorldEvent> {
ObjectsChangedMapper.ensureInitialized();
CellShuffledMapper.ensureInitialized();
MessageSentMapper.ensureInitialized();
BoardTilesSpawnedMapper.ensureInitialized();
HybridWorldEventMapper.ensureInitialized();
}
return _instance!;
Expand Down Expand Up @@ -982,6 +983,141 @@ class _MessageSentCopyWithImpl<$R, $Out>
_MessageSentCopyWithImpl($value, $cast, t);
}

class BoardTilesSpawnedMapper extends SubClassMapperBase<BoardTilesSpawned> {
BoardTilesSpawnedMapper._();

static BoardTilesSpawnedMapper? _instance;
static BoardTilesSpawnedMapper ensureInitialized() {
if (_instance == null) {
MapperContainer.globals.use(_instance = BoardTilesSpawnedMapper._());
ServerWorldEventMapper.ensureInitialized().addSubMapper(_instance!);
VectorDefinitionMapper.ensureInitialized();
BoardTileMapper.ensureInitialized();
}
return _instance!;
}

@override
final String id = 'BoardTilesSpawned';

static String _$table(BoardTilesSpawned v) => v.table;
static const Field<BoardTilesSpawned, String> _f$table =
Field('table', _$table);
static Map<VectorDefinition, List<BoardTile>> _$tiles(BoardTilesSpawned v) =>
v.tiles;
static const Field<BoardTilesSpawned, Map<VectorDefinition, List<BoardTile>>>
_f$tiles = Field('tiles', _$tiles);

@override
final MappableFields<BoardTilesSpawned> fields = const {
#table: _f$table,
#tiles: _f$tiles,
};

@override
final String discriminatorKey = 'type';
@override
final dynamic discriminatorValue = 'BoardTilesSpawned';
@override
late final ClassMapperBase superMapper =
ServerWorldEventMapper.ensureInitialized();

static BoardTilesSpawned _instantiate(DecodingData data) {
return BoardTilesSpawned(data.dec(_f$table), data.dec(_f$tiles));
}

@override
final Function instantiate = _instantiate;

static BoardTilesSpawned fromMap(Map<String, dynamic> map) {
return ensureInitialized().decodeMap<BoardTilesSpawned>(map);
}

static BoardTilesSpawned fromJson(String json) {
return ensureInitialized().decodeJson<BoardTilesSpawned>(json);
}
}

mixin BoardTilesSpawnedMappable {
String toJson() {
return BoardTilesSpawnedMapper.ensureInitialized()
.encodeJson<BoardTilesSpawned>(this as BoardTilesSpawned);
}

Map<String, dynamic> toMap() {
return BoardTilesSpawnedMapper.ensureInitialized()
.encodeMap<BoardTilesSpawned>(this as BoardTilesSpawned);
}

BoardTilesSpawnedCopyWith<BoardTilesSpawned, BoardTilesSpawned,
BoardTilesSpawned>
get copyWith => _BoardTilesSpawnedCopyWithImpl(
this as BoardTilesSpawned, $identity, $identity);
@override
String toString() {
return BoardTilesSpawnedMapper.ensureInitialized()
.stringifyValue(this as BoardTilesSpawned);
}

@override
bool operator ==(Object other) {
return BoardTilesSpawnedMapper.ensureInitialized()
.equalsValue(this as BoardTilesSpawned, other);
}

@override
int get hashCode {
return BoardTilesSpawnedMapper.ensureInitialized()
.hashValue(this as BoardTilesSpawned);
}
}

extension BoardTilesSpawnedValueCopy<$R, $Out>
on ObjectCopyWith<$R, BoardTilesSpawned, $Out> {
BoardTilesSpawnedCopyWith<$R, BoardTilesSpawned, $Out>
get $asBoardTilesSpawned =>
$base.as((v, t, t2) => _BoardTilesSpawnedCopyWithImpl(v, t, t2));
}

abstract class BoardTilesSpawnedCopyWith<$R, $In extends BoardTilesSpawned,
$Out> implements ServerWorldEventCopyWith<$R, $In, $Out> {
MapCopyWith<$R, VectorDefinition, List<BoardTile>,
ObjectCopyWith<$R, List<BoardTile>, List<BoardTile>>> get tiles;
@override
$R call({String? table, Map<VectorDefinition, List<BoardTile>>? tiles});
BoardTilesSpawnedCopyWith<$R2, $In, $Out2> $chain<$R2, $Out2>(
Then<$Out2, $R2> t);
}

class _BoardTilesSpawnedCopyWithImpl<$R, $Out>
extends ClassCopyWithBase<$R, BoardTilesSpawned, $Out>
implements BoardTilesSpawnedCopyWith<$R, BoardTilesSpawned, $Out> {
_BoardTilesSpawnedCopyWithImpl(super.value, super.then, super.then2);

@override
late final ClassMapperBase<BoardTilesSpawned> $mapper =
BoardTilesSpawnedMapper.ensureInitialized();
@override
MapCopyWith<$R, VectorDefinition, List<BoardTile>,
ObjectCopyWith<$R, List<BoardTile>, List<BoardTile>>>
get tiles => MapCopyWith($value.tiles,
(v, t) => ObjectCopyWith(v, $identity, t), (v) => call(tiles: v));
@override
$R call({String? table, Map<VectorDefinition, List<BoardTile>>? tiles}) =>
$apply(FieldCopyWithData({
if (table != null) #table: table,
if (tiles != null) #tiles: tiles
}));
@override
BoardTilesSpawned $make(CopyWithData data) => BoardTilesSpawned(
data.get(#table, or: $value.table), data.get(#tiles, or: $value.tiles));

@override
BoardTilesSpawnedCopyWith<$R2, BoardTilesSpawned, $Out2> $chain<$R2, $Out2>(
Then<$Out2, $R2> t) =>
_BoardTilesSpawnedCopyWithImpl($value, $cast, t);
}

class ClientWorldEventMapper extends SubClassMapperBase<ClientWorldEvent> {
ClientWorldEventMapper._();

Expand All @@ -996,6 +1132,7 @@ class ClientWorldEventMapper extends SubClassMapperBase<ClientWorldEvent> {
ShuffleCellRequestMapper.ensureInitialized();
PacksChangeRequestMapper.ensureInitialized();
MessageRequestMapper.ensureInitialized();
BoardsSpawnRequestMapper.ensureInitialized();
HybridWorldEventMapper.ensureInitialized();
}
return _instance!;
Expand Down Expand Up @@ -1772,6 +1909,154 @@ class _MessageRequestCopyWithImpl<$R, $Out>
_MessageRequestCopyWithImpl($value, $cast, t);
}

class BoardsSpawnRequestMapper extends SubClassMapperBase<BoardsSpawnRequest> {
BoardsSpawnRequestMapper._();

static BoardsSpawnRequestMapper? _instance;
static BoardsSpawnRequestMapper ensureInitialized() {
if (_instance == null) {
MapperContainer.globals.use(_instance = BoardsSpawnRequestMapper._());
ClientWorldEventMapper.ensureInitialized().addSubMapper(_instance!);
_t$_R0Mapper.ensureInitialized();
ItemLocationMapper.ensureInitialized();
VectorDefinitionMapper.ensureInitialized();
}
return _instance!;
}

@override
final String id = 'BoardsSpawnRequest';

static String _$table(BoardsSpawnRequest v) => v.table;
static const Field<BoardsSpawnRequest, String> _f$table =
Field('table', _$table);
static List<_t$_R0<ItemLocation, VectorDefinition>> _$assets(
BoardsSpawnRequest v) =>
v.assets;
static const Field<BoardsSpawnRequest,
List<_t$_R0<ItemLocation, VectorDefinition>>> _f$assets =
Field('assets', _$assets);

@override
final MappableFields<BoardsSpawnRequest> fields = const {
#table: _f$table,
#assets: _f$assets,
};

@override
final String discriminatorKey = 'type';
@override
final dynamic discriminatorValue = 'BoardsSpawnRequest';
@override
late final ClassMapperBase superMapper =
ClientWorldEventMapper.ensureInitialized();

static BoardsSpawnRequest _instantiate(DecodingData data) {
return BoardsSpawnRequest(data.dec(_f$table), data.dec(_f$assets));
}

@override
final Function instantiate = _instantiate;

static BoardsSpawnRequest fromMap(Map<String, dynamic> map) {
return ensureInitialized().decodeMap<BoardsSpawnRequest>(map);
}

static BoardsSpawnRequest fromJson(String json) {
return ensureInitialized().decodeJson<BoardsSpawnRequest>(json);
}
}

mixin BoardsSpawnRequestMappable {
String toJson() {
return BoardsSpawnRequestMapper.ensureInitialized()
.encodeJson<BoardsSpawnRequest>(this as BoardsSpawnRequest);
}

Map<String, dynamic> toMap() {
return BoardsSpawnRequestMapper.ensureInitialized()
.encodeMap<BoardsSpawnRequest>(this as BoardsSpawnRequest);
}

BoardsSpawnRequestCopyWith<BoardsSpawnRequest, BoardsSpawnRequest,
BoardsSpawnRequest>
get copyWith => _BoardsSpawnRequestCopyWithImpl(
this as BoardsSpawnRequest, $identity, $identity);
@override
String toString() {
return BoardsSpawnRequestMapper.ensureInitialized()
.stringifyValue(this as BoardsSpawnRequest);
}

@override
bool operator ==(Object other) {
return BoardsSpawnRequestMapper.ensureInitialized()
.equalsValue(this as BoardsSpawnRequest, other);
}

@override
int get hashCode {
return BoardsSpawnRequestMapper.ensureInitialized()
.hashValue(this as BoardsSpawnRequest);
}
}

extension BoardsSpawnRequestValueCopy<$R, $Out>
on ObjectCopyWith<$R, BoardsSpawnRequest, $Out> {
BoardsSpawnRequestCopyWith<$R, BoardsSpawnRequest, $Out>
get $asBoardsSpawnRequest =>
$base.as((v, t, t2) => _BoardsSpawnRequestCopyWithImpl(v, t, t2));
}

abstract class BoardsSpawnRequestCopyWith<$R, $In extends BoardsSpawnRequest,
$Out> implements ClientWorldEventCopyWith<$R, $In, $Out> {
ListCopyWith<
$R,
_t$_R0<ItemLocation, VectorDefinition>,
ObjectCopyWith<$R, _t$_R0<ItemLocation, VectorDefinition>,
_t$_R0<ItemLocation, VectorDefinition>>> get assets;
@override
$R call(
{String? table, List<_t$_R0<ItemLocation, VectorDefinition>>? assets});
BoardsSpawnRequestCopyWith<$R2, $In, $Out2> $chain<$R2, $Out2>(
Then<$Out2, $R2> t);
}

class _BoardsSpawnRequestCopyWithImpl<$R, $Out>
extends ClassCopyWithBase<$R, BoardsSpawnRequest, $Out>
implements BoardsSpawnRequestCopyWith<$R, BoardsSpawnRequest, $Out> {
_BoardsSpawnRequestCopyWithImpl(super.value, super.then, super.then2);

@override
late final ClassMapperBase<BoardsSpawnRequest> $mapper =
BoardsSpawnRequestMapper.ensureInitialized();
@override
ListCopyWith<
$R,
_t$_R0<ItemLocation, VectorDefinition>,
ObjectCopyWith<$R, _t$_R0<ItemLocation, VectorDefinition>,
_t$_R0<ItemLocation, VectorDefinition>>> get assets => ListCopyWith(
$value.assets,
(v, t) => ObjectCopyWith(v, $identity, t),
(v) => call(assets: v));
@override
$R call(
{String? table,
List<_t$_R0<ItemLocation, VectorDefinition>>? assets}) =>
$apply(FieldCopyWithData({
if (table != null) #table: table,
if (assets != null) #assets: assets
}));
@override
BoardsSpawnRequest $make(CopyWithData data) => BoardsSpawnRequest(
data.get(#table, or: $value.table), data.get(#assets, or: $value.assets));

@override
BoardsSpawnRequestCopyWith<$R2, BoardsSpawnRequest, $Out2> $chain<$R2, $Out2>(
Then<$Out2, $R2> t) =>
_BoardsSpawnRequestCopyWithImpl($value, $cast, t);
}

class HybridWorldEventMapper extends SubClassMapperBase<HybridWorldEvent> {
HybridWorldEventMapper._();

Expand Down Expand Up @@ -3537,3 +3822,51 @@ abstract class LocalWorldEventCopyWith<$R, $In extends LocalWorldEvent, $Out>
LocalWorldEventCopyWith<$R2, $In, $Out2> $chain<$R2, $Out2>(
Then<$Out2, $R2> t);
}

typedef _t$_R0<A, B> = ({A asset, B cell});

class _t$_R0Mapper extends RecordMapperBase<_t$_R0> {
static _t$_R0Mapper? _instance;
_t$_R0Mapper._();

static _t$_R0Mapper ensureInitialized() {
if (_instance == null) {
MapperContainer.globals.use(_instance = _t$_R0Mapper._());
MapperBase.addType(<A, B>(f) => f<({A asset, B cell})>());
}
return _instance!;
}

static dynamic _$asset(_t$_R0 v) => v.asset;
static dynamic _arg$asset<A, B>(f) => f<A>();
static const Field<_t$_R0, dynamic> _f$asset =
Field('asset', _$asset, arg: _arg$asset);
static dynamic _$cell(_t$_R0 v) => v.cell;
static dynamic _arg$cell<A, B>(f) => f<B>();
static const Field<_t$_R0, dynamic> _f$cell =
Field('cell', _$cell, arg: _arg$cell);

@override
final MappableFields<_t$_R0> fields = const {
#asset: _f$asset,
#cell: _f$cell,
};

@override
Function get typeFactory => <A, B>(f) => f<_t$_R0<A, B>>();

static _t$_R0<A, B> _instantiate<A, B>(DecodingData<_t$_R0> data) {
return (asset: data.dec(_f$asset), cell: data.dec(_f$cell));
}

@override
final Function instantiate = _instantiate;

static _t$_R0<A, B> fromMap<A, B>(Map<String, dynamic> map) {
return ensureInitialized().decodeMap<_t$_R0<A, B>>(map);
}

static _t$_R0<A, B> fromJson<A, B>(String json) {
return ensureInitialized().decodeJson<_t$_R0<A, B>>(json);
}
}
Loading

0 comments on commit 71104d2

Please sign in to comment.