Skip to content

Commit 0c619e8

Browse files
committed
Refactor: Separated core files into subfolders
Separated core files into subfolders to improve organization and maintainability. Created an index file for easy importing of core components. Updated imports to reflect the new file structure.
1 parent f73a6f8 commit 0c619e8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+186
-179
lines changed

escape_wild/lib/core.dart

Lines changed: 0 additions & 43 deletions
This file was deleted.

escape_wild/lib/core/action.dart renamed to escape_wild/lib/core/action/action.dart

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
1-
import 'package:escape_wild/core.dart';
1+
import 'package:escape_wild/core/index.dart';
22

33
/// Full name: User Action.
44
///
55
/// It's to disambiguate with `Action` in flutter.
6-
class UAction with Moddable {
7-
final UAction? parent;
6+
class UserAction with Moddable {
7+
final UserAction? parent;
88
@override
99
final String name;
10-
final List<UAction> subActions = [];
10+
final List<UserAction> subActions = [];
1111

12-
UAction(this.name, {this.parent}) {
12+
UserAction(this.name, {this.parent}) {
1313
parent?.subActions.add(this);
1414
}
1515

1616
/// The sub-action should be in `parent-name.sub-name`.
17-
UAction sub(String name) => UAction("${this.name}.$name", parent: this);
17+
UserAction sub(String name) => UserAction("${this.name}.$name", parent: this);
1818

19-
factory UAction.named(String name) => UAction(name);
19+
factory UserAction.named(String name) => UserAction(name);
2020

2121
String l10nName() {
2222
final parent = this.parent;
@@ -28,9 +28,9 @@ class UAction with Moddable {
2828
}
2929
}
3030

31-
bool belongsToOrSelf(UAction ancestorOrSelf) => this == ancestorOrSelf || belongsTo(ancestorOrSelf);
31+
bool belongsToOrSelf(UserAction ancestorOrSelf) => this == ancestorOrSelf || belongsTo(ancestorOrSelf);
3232

33-
bool belongsTo(UAction ancestor) {
33+
bool belongsTo(UserAction ancestor) {
3434
var cur = parent;
3535
while (cur != null) {
3636
if (cur == ancestor) return true;
@@ -43,30 +43,30 @@ class UAction with Moddable {
4343
String toString() => name;
4444

4545
// Move
46-
static final UAction move = UAction("move"),
46+
static final UserAction move = UserAction("move"),
4747
moveLeft = move.sub("left"),
4848
moveRight = move.sub("right"),
4949
moveUp = move.sub("up"),
5050
moveDown = move.sub("down"),
5151
moveForward = move.sub("forward"),
5252
moveBackward = move.sub("backward");
53-
static final UAction explore = UAction("explore");
54-
static final UAction gather = UAction("gather"),
53+
static final UserAction explore = UserAction("explore");
54+
static final UserAction gather = UserAction("gather"),
5555
gatherGetWater = gather.sub("get-water"),
5656
gatherGetWood = gather.sub("get-wood"),
5757
gatherGetFood = gather.sub("get-food");
5858

59-
static final UAction shelter = UAction("shelter"),
59+
static final UserAction shelter = UserAction("shelter"),
6060
shelterSleepTillTomorrow = shelter.sub("sleep-till-tomorrow"),
6161
shelterReinforce = shelter.sub("reinforce"),
6262
shelterRest = shelter.sub("rest");
63-
static final UAction hunt = UAction("hunt"), hunTrap = hunt.sub("trap"), hunGun = hunt.sub("gun");
64-
static final UAction fish = UAction("fish");
63+
static final UserAction hunt = UserAction("hunt"), hunTrap = hunt.sub("trap"), hunGun = hunt.sub("gun");
64+
static final UserAction fish = UserAction("fish");
6565

6666
// Win or lose the game.
67-
static final UAction escapeWild = UAction("escape-wild"), stopHeartbeat = UAction("stop-heartbeat");
67+
static final UserAction escapeWild = UserAction("escape-wild"), stopHeartbeat = UserAction("stop-heartbeat");
6868

69-
static final List<UAction> defaultActions = [
69+
static final List<UserAction> defaultActions = [
7070
move,
7171
explore,
7272
shelter,
@@ -75,15 +75,15 @@ class UAction with Moddable {
7575
@override
7676
bool operator ==(Object other) {
7777
if (identical(this, other)) return true;
78-
if (other is! UAction || other.runtimeType != runtimeType) return false;
78+
if (other is! UserAction || other.runtimeType != runtimeType) return false;
7979
return name == other.name;
8080
}
8181

8282
@override
8383
int get hashCode => name.hashCode;
8484
}
8585

86-
extension UActionX on UAction {
86+
extension UActionX on UserAction {
8787
bool get isTopLevel => parent == null;
8888

8989
bool get isLeaf => subActions.isEmpty;

escape_wild/lib/core/attribute/attribute.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import 'dart:math';
2-
import 'package:escape_wild/core.dart';
2+
import 'package:escape_wild/core/index.dart';
33

44
import 'package:flutter/cupertino.dart';
55
import 'package:json_annotation/json_annotation.dart';

escape_wild/lib/core/backpack/backpack.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import 'package:collection/collection.dart';
2-
import 'package:escape_wild/core.dart';
2+
import 'package:escape_wild/core/index.dart';
33
import 'package:jconverter/jconverter.dart';
44
import 'package:json_annotation/json_annotation.dart';
55
import 'package:noitcelloc/noitcelloc.dart';

escape_wild/lib/core/campfire/campfire.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import 'dart:math';
22
import 'package:json_annotation/json_annotation.dart';
33

4-
import 'package:escape_wild/core.dart';
4+
import 'package:escape_wild/core/index.dart';
55
import 'package:flutter/widgets.dart';
66

77
part 'campfire.g.dart';

escape_wild/lib/core/content.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import 'package:escape_wild/core.dart';
1+
import 'package:escape_wild/core/index.dart';
22

33
class Contents {
44
Contents._();

escape_wild/lib/core/cook/container.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import 'package:escape_wild/core.dart';
1+
import 'package:escape_wild/core/index.dart';
22
import 'package:jconverter/jconverter.dart';
33

44
/// [ContainerCookRecipe] will transform a certain [Item] that meets [inputTags] into [result] by a certain ratio.

escape_wild/lib/core/cook/continuous.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import 'dart:math';
22

3-
import 'package:escape_wild/core.dart';
3+
import 'package:escape_wild/core/index.dart';
44
import 'package:jconverter/jconverter.dart';
55
import 'package:json_annotation/json_annotation.dart';
66

escape_wild/lib/core/cook/instant.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import 'package:escape_wild/core.dart';
1+
import 'package:escape_wild/core/index.dart';
22
import 'package:jconverter/jconverter.dart';
33
import 'package:json_annotation/json_annotation.dart';
44

escape_wild/lib/core/cook/protocol.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import 'package:escape_wild/core.dart';
1+
import 'package:escape_wild/core/index.dart';
22
import 'package:json_annotation/json_annotation.dart';
33

44
abstract class CookRecipeProtocol with Moddable {

0 commit comments

Comments
 (0)