Skip to content

Commit 1f3a4fd

Browse files
committed
Restructure code
1 parent bbc005f commit 1f3a4fd

20 files changed

+1041
-254
lines changed

.gitignore

-2
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,3 @@
33
*.iws
44
.idea/
55
.vscode/
6-
7-
*.mapper.dart

app/analysis_options.yaml

+3
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ analyzer:
1212
exclude:
1313
- "**/*.g.dart"
1414
- "**/*.freezed.dart"
15+
- "build/**/*.dart"
16+
- "lib/src/rust/*.dart"
17+
- "lib/src/rust/**/*.dart"
1518
errors:
1619
invalid_annotation_target: ignore
1720
linter:

app/lib/game/board/game.dart

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import 'package:flame/game.dart';
2+
3+
class BoardGame extends FlameGame {}

app/lib/game/board/grid.dart

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import 'package:flame/components.dart';
2+
3+
class BoardGrid extends Component {}

app/lib/game/board.dart renamed to app/lib/game/world/game.dart

+10-6
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ import 'package:flame/game.dart';
88
import 'package:flame_tiled/flame_tiled.dart';
99
import 'package:flutter/services.dart';
1010
import 'package:flutter/widgets.dart';
11-
import 'package:qeck/game/inventory.dart';
12-
import 'package:qeck/game/player.dart';
13-
import 'package:qeck/game/wall.dart';
11+
import 'package:qeck/game/world/inventory.dart';
12+
import 'package:qeck/game/world/player.dart';
13+
import 'package:qeck/game/world/wall.dart';
1414
import 'package:qeck/services/network.dart';
1515

1616
class SpacedSpriteSheet {
@@ -34,7 +34,7 @@ class SpacedSpriteSheet {
3434
}
3535
}
3636

37-
class BoardGame extends FlameGame with KeyboardEvents, HasCollisionDetection {
37+
class GameWorld extends FlameGame with KeyboardEvents, HasCollisionDetection {
3838
final NetworkingService networkingService;
3939
final BoardPlayer _player = BoardPlayer(true);
4040
final Map<int, BoardPlayer> _players = <int, BoardPlayer>{};
@@ -43,7 +43,7 @@ class BoardGame extends FlameGame with KeyboardEvents, HasCollisionDetection {
4343
Vector2 get tileSize => _tileSize;
4444
final VoidCallback onEscape;
4545

46-
BoardGame({
46+
GameWorld({
4747
required this.networkingService,
4848
required this.onEscape,
4949
});
@@ -52,7 +52,11 @@ class BoardGame extends FlameGame with KeyboardEvents, HasCollisionDetection {
5252

5353
@override
5454
Future<void> onLoad() async {
55-
final component = await TiledComponent.load('map.tmx', _tileSize);
55+
final component = await TiledComponent.load(
56+
'map.tmx',
57+
_tileSize,
58+
useAtlas: false,
59+
);
5660

5761
final objects = component.tileMap.getLayer<ObjectGroup>('Objects')?.objects;
5862
final spawn = objects?.firstWhere(

app/lib/game/inventory.dart renamed to app/lib/game/world/inventory.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import 'dart:ui';
44
import 'package:flame/components.dart';
55
import 'package:flame/events.dart';
66
import 'package:flame/flame.dart';
7-
import 'package:qeck/game/board.dart';
7+
import 'package:qeck/game/world/game.dart';
88

99
class HudSpriteSheet {
1010
final SpacedSpriteSheet _spriteSheet;

app/lib/game/player.dart renamed to app/lib/game/world/player.dart

+3-3
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ import 'package:flame/effects.dart';
88
import 'package:flame/extensions.dart';
99
import 'package:flame/flame.dart';
1010
import 'package:flame/text.dart';
11-
import 'package:qeck/game/board.dart';
12-
import 'package:qeck/game/wall.dart';
11+
import 'package:qeck/game/world/game.dart';
12+
import 'package:qeck/game/world/wall.dart';
1313
import 'package:qeck/models/message.dart';
1414
import 'package:qeck/models/state.dart';
1515

@@ -50,7 +50,7 @@ extension RendererExtension on PlayerState {
5050

5151
class BoardPlayer
5252
extends SpriteAnimationGroupComponent<(PlayerState, PlayerDirection)>
53-
with HasGameRef<BoardGame>, CollisionCallbacks {
53+
with HasGameRef<GameWorld>, CollisionCallbacks {
5454
final bool isSelf;
5555
NetworkingUser _user;
5656

File renamed without changes.

app/lib/main.dart

+4-4
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ String? dataPath;
2828

2929
Future<void> main(List<String> args) async {
3030
WidgetsFlutterBinding.ensureInitialized();
31-
3231
usePathUrlStrategy();
32+
3333
final argParser = ArgParser();
3434
argParser.addOption('path', abbr: 'p');
3535
final result = argParser.parse(args);
@@ -44,7 +44,7 @@ Future<void> main(List<String> args) async {
4444
value: settingsCubit,
4545
child: RepositoryProvider(
4646
create: (context) => NetworkingService(settingsCubit),
47-
child: FlowApp(),
47+
child: QeckApp(),
4848
),
4949
),
5050
);
@@ -74,8 +74,8 @@ List<Locale> getLocales() =>
7474
.where((l) => !kUnsupportedLanguages.contains(l.toString()))
7575
.toList();
7676

77-
class FlowApp extends StatelessWidget {
78-
FlowApp({super.key});
77+
class QeckApp extends StatelessWidget {
78+
QeckApp({super.key});
7979

8080
@override
8181
Widget build(BuildContext context) {

app/lib/models/table.dart

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
import 'package:dart_mappable/dart_mappable.dart';
2+
3+
part 'table.mapper.dart';
4+
5+
@MappableClass()
6+
class GridLocation with GridLocationMappable {
7+
final int x, y;
8+
9+
GridLocation(this.x, this.y);
10+
}
11+
12+
@MappableClass()
13+
class GameTable with GameTableMappable {
14+
final Map<GridLocation, TableCell> cells;
15+
final Map<GridLocation, GameBoard> boards;
16+
17+
GameTable({
18+
this.cells = const {},
19+
this.boards = const {},
20+
});
21+
}
22+
23+
@MappableClass()
24+
class TableCell with TableCellMappable {
25+
final List<GameObject> objects;
26+
27+
TableCell(this.objects);
28+
}
29+
30+
@MappableClass()
31+
class GameBoard with GameBoardMappable {
32+
final AssetLocation asset;
33+
34+
GameBoard(this.asset);
35+
}
36+
37+
@MappableClass()
38+
class GameObject with GameObjectMappable {
39+
final AssetLocation asset;
40+
final String? variation;
41+
42+
GameObject({
43+
required this.asset,
44+
this.variation,
45+
});
46+
}
47+
48+
@MappableClass()
49+
class AssetLocation with AssetLocationMappable {
50+
final String namespace, id;
51+
52+
AssetLocation(this.namespace, this.id);
53+
}

0 commit comments

Comments
 (0)