-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathmisc.dart
141 lines (121 loc) · 2.71 KB
/
misc.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
part of md5;
abstract class IPlr{
String idName;
String toString(){
return idName;
}
}
class NPlr extends IPlr{
NPlr(IPlr p) {
idName = p.idName;
}
}
/// hp update
class HPlr extends IPlr{
String pcss;
int oldHp;
int newHp;
HPlr(Plr p, this.oldHp) {
idName = p.idName;
newHp = p.hp;
}
}
/// max hp update
class MPlr extends IPlr{
int newHp;
int maxHp;
MPlr(Plr p) {
idName = p.idName;
newHp = p.hp;
maxHp = p.maxhp;
}
}
class DPlr extends IPlr{
DPlr(Plr p) {
idName = p.idName;
}
}
class HDamage {
int damage;
HDamage(this.damage);
String toString(){
return damage.toString();
}
}
class HRecover {
int recover;
HRecover(this.recover);
String toString(){
return recover.toString();
}
}
class RunUpdate {
static RunUpdate newline = new RunUpdate('\n', null);
int score;
int delay0;
int delay1;
String message;
/// caster mostly the skill caster
/// except during dodge and defend, target is the one that use defend or dodge
IPlr caster;
IPlr target;
List<IPlr> targets2;
Object param;
RunUpdate(this.message, this.caster,
[this.target, this.param, this.targets2, this.score = 0, this.delay0 = 1000, this.delay1 = 100]) {
if (caster is Plr) {
caster = new NPlr(caster);
}
if (target is Plr) {
target = new NPlr(target);
}
if (param is Plr) {
param = new NPlr(param as Plr);
}
if (targets2 != null) {
for (int i = 0; i < targets2.length; ++i) {
if (targets2[i] is Plr) {
targets2[i] = new NPlr(targets2[i]);
}
}
}
}
String toString() {
String msg = message;
if (caster != null) {
msg = msg.replaceAll('[0]', caster.toString());
}
if (target != null) {
msg = msg.replaceAll('[1]', target.toString());
}
if (param != null) {
msg = msg.replaceAll('[2]', param.toString());
}
return msg;
}
}
class RunUpdateCancel extends RunUpdate {
RunUpdateCancel(String message, IPlr caster,
[IPlr target, Object param, List<IPlr> targets2, int score = 0, int delay0 = 1000, int delay1 = 500]) :
super(message, caster, target, param, targets2, score, delay0, delay1);
}
class RunUpdateWin extends RunUpdate {
Grp get winner => param as Grp;
RunUpdateWin(IPlr caster, Grp w):super(l('[2]获得胜利', 'win'), caster, null, w, null, 0, 3000);
}
class RunUpdates {
static DummyRunUpdates dummy = new DummyRunUpdates();
List<RunUpdate> updates = [];
void add(RunUpdate update) {
updates.add(update);
}
String toString() {
return '$updates';
}
List<Function> onUpdateEnd = [];
}
class DummyRunUpdates extends RunUpdates {
void add(RunUpdate update) {
// do nothing;
}
}