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;
0 commit comments