Skip to content

Commit

Permalink
Add first rendering of board in deck
Browse files Browse the repository at this point in the history
  • Loading branch information
CodeDoctorDE committed Sep 18, 2024
1 parent deb34d5 commit f51b522
Show file tree
Hide file tree
Showing 21 changed files with 768 additions and 121 deletions.
427 changes: 427 additions & 0 deletions BRANDING_LICENSE

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,5 +67,5 @@ To get started, visit [the contributing guide](CONTRIBUTING.md).
## License

The code is open source and licensed under the [AGPL-3.0](./LICENSE) license.
All images in `app/images/`, the core pack in `app/packs` and all images in `docs/` are licensed under the [CC-BY-4.0](./BRANDING_LICENSE) license.
All images in `app/images/`, the core pack in `app/packs` and all images in `docs/` are licensed under the [CC-BY-SA-4.0](./BRANDING_LICENSE) license.
The files in `api` are licensed under the [Apache-2.0](./api/LICENSE) license instead of the AGPL-3.0 license to allow the use of the API without the need to open source the code (for example for extensions or other external services).
10 changes: 9 additions & 1 deletion api/lib/src/models/data.dart
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ class QuokkaData extends ArchiveData<QuokkaData> {
...archive.files.map((e) => e.name),
...state.added.keys,
}
.where((e) => e.startsWith(path))
.where((e) => e.startsWith(path) && e != path)
.where((e) => !state.removed.contains(e))
.map((e) => e.substring(path.length))
.map((e) {
Expand Down Expand Up @@ -161,6 +161,14 @@ class QuokkaData extends ArchiveData<QuokkaData> {
}
}

PackItem<BoardDefinition>? getBoardItem(String id, [String namespace = '']) =>
PackItem.wrap(
pack: this,
namespace: namespace,
id: id,
item: getBoard(id),
);

Iterable<String> getBackgrounds() =>
getAssets('$kPackBackgroundsPath/', true);

Expand Down
2 changes: 2 additions & 0 deletions api/lib/src/models/definition.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,13 @@ class BoardDefinition with BoardDefinitionMappable, VisualDefinition {
final VectorDefinition? size;
@override
final String texture;
final VectorDefinition tiles;

BoardDefinition({
this.offset = VectorDefinition.zero,
this.size,
required this.texture,
this.tiles = VectorDefinition.one,
});
}

Expand Down
29 changes: 24 additions & 5 deletions api/lib/src/models/definition.mapper.dart
Original file line number Diff line number Diff line change
Expand Up @@ -468,19 +468,24 @@ class BoardDefinitionMapper extends ClassMapperBase<BoardDefinition> {
static String _$texture(BoardDefinition v) => v.texture;
static const Field<BoardDefinition, String> _f$texture =
Field('texture', _$texture);
static VectorDefinition _$tiles(BoardDefinition v) => v.tiles;
static const Field<BoardDefinition, VectorDefinition> _f$tiles =
Field('tiles', _$tiles, opt: true, def: VectorDefinition.one);

@override
final MappableFields<BoardDefinition> fields = const {
#offset: _f$offset,
#size: _f$size,
#texture: _f$texture,
#tiles: _f$tiles,
};

static BoardDefinition _instantiate(DecodingData data) {
return BoardDefinition(
offset: data.dec(_f$offset),
size: data.dec(_f$size),
texture: data.dec(_f$texture));
texture: data.dec(_f$texture),
tiles: data.dec(_f$tiles));
}

@override
Expand Down Expand Up @@ -538,7 +543,12 @@ abstract class BoardDefinitionCopyWith<$R, $In extends BoardDefinition, $Out>
implements ClassCopyWith<$R, $In, $Out> {
VectorDefinitionCopyWith<$R, VectorDefinition, VectorDefinition> get offset;
VectorDefinitionCopyWith<$R, VectorDefinition, VectorDefinition>? get size;
$R call({VectorDefinition? offset, VectorDefinition? size, String? texture});
VectorDefinitionCopyWith<$R, VectorDefinition, VectorDefinition> get tiles;
$R call(
{VectorDefinition? offset,
VectorDefinition? size,
String? texture,
VectorDefinition? tiles});
BoardDefinitionCopyWith<$R2, $In, $Out2> $chain<$R2, $Out2>(
Then<$Out2, $R2> t);
}
Expand All @@ -558,17 +568,26 @@ class _BoardDefinitionCopyWithImpl<$R, $Out>
VectorDefinitionCopyWith<$R, VectorDefinition, VectorDefinition>? get size =>
$value.size?.copyWith.$chain((v) => call(size: v));
@override
$R call({VectorDefinition? offset, Object? size = $none, String? texture}) =>
VectorDefinitionCopyWith<$R, VectorDefinition, VectorDefinition> get tiles =>
$value.tiles.copyWith.$chain((v) => call(tiles: v));
@override
$R call(
{VectorDefinition? offset,
Object? size = $none,
String? texture,
VectorDefinition? tiles}) =>
$apply(FieldCopyWithData({
if (offset != null) #offset: offset,
if (size != $none) #size: size,
if (texture != null) #texture: texture
if (texture != null) #texture: texture,
if (tiles != null) #tiles: tiles
}));
@override
BoardDefinition $make(CopyWithData data) => BoardDefinition(
offset: data.get(#offset, or: $value.offset),
size: data.get(#size, or: $value.size),
texture: data.get(#texture, or: $value.texture));
texture: data.get(#texture, or: $value.texture),
tiles: data.get(#tiles, or: $value.tiles));

@override
BoardDefinitionCopyWith<$R2, BoardDefinition, $Out2> $chain<$R2, $Out2>(
Expand Down
10 changes: 5 additions & 5 deletions api/lib/src/models/table.dart
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class GameSeat with GameSeatMappable {
@MappableClass()
class TableCell with TableCellMappable {
final List<GameObject> objects;
final List<GameBoard> boards;
final List<BoardTile> boards;
final String? team;
final int reveal;
final int? teamReveal;
Expand Down Expand Up @@ -104,13 +104,13 @@ class GameObject with GameObjectMappable {
}

@MappableClass()
class GameBoard with GameBoardMappable {
class BoardTile with BoardTileMappable {
final ItemLocation asset;
final VectorDefinition offset;
final VectorDefinition tile;

GameBoard({
BoardTile({
required this.asset,
required this.offset,
required this.tile,
});
}

Expand Down
122 changes: 60 additions & 62 deletions api/lib/src/models/table.mapper.dart
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ class TableCellMapper extends ClassMapperBase<TableCell> {
if (_instance == null) {
MapperContainer.globals.use(_instance = TableCellMapper._());
GameObjectMapper.ensureInitialized();
GameBoardMapper.ensureInitialized();
BoardTileMapper.ensureInitialized();
}
return _instance!;
}
Expand All @@ -152,8 +152,8 @@ class TableCellMapper extends ClassMapperBase<TableCell> {
static List<GameObject> _$objects(TableCell v) => v.objects;
static const Field<TableCell, List<GameObject>> _f$objects =
Field('objects', _$objects, opt: true, def: const []);
static List<GameBoard> _$boards(TableCell v) => v.boards;
static const Field<TableCell, List<GameBoard>> _f$boards =
static List<BoardTile> _$boards(TableCell v) => v.boards;
static const Field<TableCell, List<BoardTile>> _f$boards =
Field('boards', _$boards, opt: true, def: const []);
static String? _$team(TableCell v) => v.team;
static const Field<TableCell, String> _f$team =
Expand Down Expand Up @@ -235,11 +235,11 @@ abstract class TableCellCopyWith<$R, $In extends TableCell, $Out>
implements ClassCopyWith<$R, $In, $Out> {
ListCopyWith<$R, GameObject, GameObjectCopyWith<$R, GameObject, GameObject>>
get objects;
ListCopyWith<$R, GameBoard, GameBoardCopyWith<$R, GameBoard, GameBoard>>
ListCopyWith<$R, BoardTile, BoardTileCopyWith<$R, BoardTile, BoardTile>>
get boards;
$R call(
{List<GameObject>? objects,
List<GameBoard>? boards,
List<BoardTile>? boards,
String? team,
int? reveal,
int? teamReveal});
Expand All @@ -259,13 +259,13 @@ class _TableCellCopyWithImpl<$R, $Out>
get objects => ListCopyWith($value.objects,
(v, t) => v.copyWith.$chain(t), (v) => call(objects: v));
@override
ListCopyWith<$R, GameBoard, GameBoardCopyWith<$R, GameBoard, GameBoard>>
ListCopyWith<$R, BoardTile, BoardTileCopyWith<$R, BoardTile, BoardTile>>
get boards => ListCopyWith($value.boards, (v, t) => v.copyWith.$chain(t),
(v) => call(boards: v));
@override
$R call(
{List<GameObject>? objects,
List<GameBoard>? boards,
List<BoardTile>? boards,
Object? team = $none,
int? reveal,
Object? teamReveal = $none}) =>
Expand Down Expand Up @@ -522,124 +522,122 @@ class _ItemLocationCopyWithImpl<$R, $Out>
_ItemLocationCopyWithImpl($value, $cast, t);
}

class GameBoardMapper extends ClassMapperBase<GameBoard> {
GameBoardMapper._();
class BoardTileMapper extends ClassMapperBase<BoardTile> {
BoardTileMapper._();

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

@override
final String id = 'GameBoard';
final String id = 'BoardTile';

static ItemLocation _$asset(GameBoard v) => v.asset;
static const Field<GameBoard, ItemLocation> _f$asset =
static ItemLocation _$asset(BoardTile v) => v.asset;
static const Field<BoardTile, ItemLocation> _f$asset =
Field('asset', _$asset);
static VectorDefinition _$offset(GameBoard v) => v.offset;
static const Field<GameBoard, VectorDefinition> _f$offset =
Field('offset', _$offset);
static VectorDefinition _$tile(BoardTile v) => v.tile;
static const Field<BoardTile, VectorDefinition> _f$tile =
Field('tile', _$tile);

@override
final MappableFields<GameBoard> fields = const {
final MappableFields<BoardTile> fields = const {
#asset: _f$asset,
#offset: _f$offset,
#tile: _f$tile,
};

static GameBoard _instantiate(DecodingData data) {
return GameBoard(asset: data.dec(_f$asset), offset: data.dec(_f$offset));
static BoardTile _instantiate(DecodingData data) {
return BoardTile(asset: data.dec(_f$asset), tile: data.dec(_f$tile));
}

@override
final Function instantiate = _instantiate;

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

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

mixin GameBoardMappable {
mixin BoardTileMappable {
String toJson() {
return GameBoardMapper.ensureInitialized()
.encodeJson<GameBoard>(this as GameBoard);
return BoardTileMapper.ensureInitialized()
.encodeJson<BoardTile>(this as BoardTile);
}

Map<String, dynamic> toMap() {
return GameBoardMapper.ensureInitialized()
.encodeMap<GameBoard>(this as GameBoard);
return BoardTileMapper.ensureInitialized()
.encodeMap<BoardTile>(this as BoardTile);
}

GameBoardCopyWith<GameBoard, GameBoard, GameBoard> get copyWith =>
_GameBoardCopyWithImpl(this as GameBoard, $identity, $identity);
BoardTileCopyWith<BoardTile, BoardTile, BoardTile> get copyWith =>
_BoardTileCopyWithImpl(this as BoardTile, $identity, $identity);
@override
String toString() {
return GameBoardMapper.ensureInitialized()
.stringifyValue(this as GameBoard);
return BoardTileMapper.ensureInitialized()
.stringifyValue(this as BoardTile);
}

@override
bool operator ==(Object other) {
return GameBoardMapper.ensureInitialized()
.equalsValue(this as GameBoard, other);
return BoardTileMapper.ensureInitialized()
.equalsValue(this as BoardTile, other);
}

@override
int get hashCode {
return GameBoardMapper.ensureInitialized().hashValue(this as GameBoard);
return BoardTileMapper.ensureInitialized().hashValue(this as BoardTile);
}
}

extension GameBoardValueCopy<$R, $Out> on ObjectCopyWith<$R, GameBoard, $Out> {
GameBoardCopyWith<$R, GameBoard, $Out> get $asGameBoard =>
$base.as((v, t, t2) => _GameBoardCopyWithImpl(v, t, t2));
extension BoardTileValueCopy<$R, $Out> on ObjectCopyWith<$R, BoardTile, $Out> {
BoardTileCopyWith<$R, BoardTile, $Out> get $asBoardTile =>
$base.as((v, t, t2) => _BoardTileCopyWithImpl(v, t, t2));
}

abstract class GameBoardCopyWith<$R, $In extends GameBoard, $Out>
abstract class BoardTileCopyWith<$R, $In extends BoardTile, $Out>
implements ClassCopyWith<$R, $In, $Out> {
ItemLocationCopyWith<$R, ItemLocation, ItemLocation> get asset;
VectorDefinitionCopyWith<$R, VectorDefinition, VectorDefinition> get offset;
$R call({ItemLocation? asset, VectorDefinition? offset});
GameBoardCopyWith<$R2, $In, $Out2> $chain<$R2, $Out2>(Then<$Out2, $R2> t);
VectorDefinitionCopyWith<$R, VectorDefinition, VectorDefinition> get tile;
$R call({ItemLocation? asset, VectorDefinition? tile});
BoardTileCopyWith<$R2, $In, $Out2> $chain<$R2, $Out2>(Then<$Out2, $R2> t);
}

class _GameBoardCopyWithImpl<$R, $Out>
extends ClassCopyWithBase<$R, GameBoard, $Out>
implements GameBoardCopyWith<$R, GameBoard, $Out> {
_GameBoardCopyWithImpl(super.value, super.then, super.then2);
class _BoardTileCopyWithImpl<$R, $Out>
extends ClassCopyWithBase<$R, BoardTile, $Out>
implements BoardTileCopyWith<$R, BoardTile, $Out> {
_BoardTileCopyWithImpl(super.value, super.then, super.then2);

@override
late final ClassMapperBase<GameBoard> $mapper =
GameBoardMapper.ensureInitialized();
late final ClassMapperBase<BoardTile> $mapper =
BoardTileMapper.ensureInitialized();
@override
ItemLocationCopyWith<$R, ItemLocation, ItemLocation> get asset =>
$value.asset.copyWith.$chain((v) => call(asset: v));
@override
VectorDefinitionCopyWith<$R, VectorDefinition, VectorDefinition> get offset =>
$value.offset.copyWith.$chain((v) => call(offset: v));
VectorDefinitionCopyWith<$R, VectorDefinition, VectorDefinition> get tile =>
$value.tile.copyWith.$chain((v) => call(tile: v));
@override
$R call({ItemLocation? asset, VectorDefinition? offset}) =>
$apply(FieldCopyWithData({
if (asset != null) #asset: asset,
if (offset != null) #offset: offset
}));
$R call({ItemLocation? asset, VectorDefinition? tile}) =>
$apply(FieldCopyWithData(
{if (asset != null) #asset: asset, if (tile != null) #tile: tile}));
@override
GameBoard $make(CopyWithData data) => GameBoard(
BoardTile $make(CopyWithData data) => BoardTile(
asset: data.get(#asset, or: $value.asset),
offset: data.get(#offset, or: $value.offset));
tile: data.get(#tile, or: $value.tile));

@override
GameBoardCopyWith<$R2, GameBoard, $Out2> $chain<$R2, $Out2>(
BoardTileCopyWith<$R2, BoardTile, $Out2> $chain<$R2, $Out2>(
Then<$Out2, $R2> t) =>
_GameBoardCopyWithImpl($value, $cast, t);
_BoardTileCopyWithImpl($value, $cast, t);
}

class GlobalVectorDefinitionMapper
Expand Down
Loading

0 comments on commit f51b522

Please sign in to comment.