-
Notifications
You must be signed in to change notification settings - Fork 0
/
lanwar.player.js
187 lines (181 loc) · 5.92 KB
/
lanwar.player.js
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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
function selectplayer(id,who) {
if (formation[who].player.idplayer == id) {
notice("same player");
}
else {
formation[who].player = getobjbyid("player","idplayer",id);
notice("player "+formation[who].player.player_name+"selected");
for (var i in pool[who]) {
pool[who][i].status = "waiting refresh";
}
$(lanwarevent).trigger("refreshformation",who);
}
}
function custogglebell (who,bell) {
var playerobj = customplayer[who];
playerobj.bell[bell] = !playerobj.bell[bell];
if (!playerobj.bell[bell]) {
if (playerobj.round <= 1) {
notice("last belligerent can not be removed.");
playerobj.bell[bell] = true;
return false;
}
var classoff = false;
for (var i in rule.bell[bell].class_id) {
var classid = rule.bell[bell].class_id[i];
if (playerobj.class_id == classid) {
classoff = true;
break;
}
}
if (classoff) {
cuschangclass(who,rule.bell.common.class_id[0]);
}
playerobj.round--;
$("#"+who+"cus"+bell).removeClass(bell);
$("#"+who+"cus"+bell).addClass("bellinactive");
for (var i in rule.bell[bell]) {
if ($("#"+who+"class"+rule.bell[bell][i]).hasClass(bell)) {
$("#"+who+"class"+rule.bell[bell][i]).removeClass(bell);
$("#"+who+"class"+rule.bell[bell][i]).addClass("bellinactive");
}
}
}
else {
playerobj.round++;
$("#"+who+"cus"+bell).removeClass("bellinactive");
$("#"+who+"cus"+bell).addClass(bell);
for (var i in rule.bell[bell]) {
if ($("#"+who+"class"+rule.bell[bell][i]).hasClass("bellinactive")) {
$("#"+who+"class"+rule.bell[bell][i]).removeClass("bellinactive");
$("#"+who+"class"+rule.bell[bell][i]).addClass(bell);
}
}
}
$("#"+who+"cusname").removeClass("s e d b se sd sb ed eb db sed seb sdb edb sedb");
var newcolor = "";
if (playerobj.bell.shrine) {
newcolor += 's';
}
if (playerobj.bell.empire) {
newcolor += 'e';
}
if (playerobj.bell.demon) {
newcolor += 'd';
}
if (playerobj.bell.barbarian) {
newcolor += 'b';
}
$("#"+who+"cusname").addClass(newcolor);
return true;
}
function cuschangclass (who,classid) {
selectclass (who,classid);
}
function selectlv (who, lv) {
var playerobj = customplayer[who];
if (playerobj.lv == lv) {
notice("same level");
}
else {
playerobj.lv = lv;
$("#"+who+"cuslv").empty().append("Lv."+lv);
notice("change level to " + lv);
}
}
function selectclass (who, classid) {
var playerobj = customplayer[who];
if (playerobj.class_id == classid) {
notice("same class");
}
else {
playerobj.class_id = classid;
for (var i in classobj) {
if (classobj[i].id == classid) {
playerobj.class_name = classobj[i].name;
break;
}
}
for (var i in rule.bell) {
if (i == "common") {
continue;
}
for (var j in rule.bell[i]) {
if (classid == rule.bell[i][j]) {
if (!playerobj.bell[i]) {
custogglebell(who,i);
}
break;
}
}
}
$("#"+who+"cusclass").empty().append(playerobj.class_name);
notice("change class to " + playerobj.class_name);
}
}
function insertplayer(instype,playerobj) {
var newhtm = "";
if (instype == "sel") {
newhtm = '<div class="playerselectbtn ';
if (playerobj.bell.shrine) {
newhtm += 's';
}
if (playerobj.bell.empire) {
newhtm += 'e';
}
if (playerobj.bell.demon) {
newhtm += 'd';
}
if (playerobj.bell.barbarian) {
newhtm += 'b';
}
newhtm += '" id="p' + playerobj.idplayer + '">' + playerobj.player_name + '</div>';
}
else if (instype == "det") {
newhtm = '<div class="playerdetail" id="p' + playerobj.idplayer +'d"><span class="bell ';
if (playerobj.bell.shrine) {
newhtm += 'shrine';
}
else {
newhtm += 'bellinactive';
}
newhtm += '">光辉</span><span class="bell ';
if (playerobj.bell.empire) {
newhtm += 'empire';
}
else {
newhtm += 'bellinactive';
}
newhtm += '">帝国</span><span class="bell ';
if (playerobj.bell.demon) {
newhtm += 'demon';
}
else {
newhtm += 'bellinactive';
}
newhtm += '">魔族</span><span class="bell ';
if (playerobj.bell.barbarian) {
newhtm += 'barbarian';
}
else {
newhtm += 'bellinactive';
}
newhtm += '">蛮族</span>';
newhtm += '<span class="lv">Lv.' + playerobj.level + '</span><span class="leaderclass">' + playerobj.class_name + '</span><span class="expname">EXP</span>';
newhtm += '<span class="exp">' ;
var expbar = Math.round(playerobj.exp / playerobj.maxexp * 100);
if (expbar < 1) {
newhtm += '<div class="expback ui-widget-content" style="width: 100%"></div>';
}
else if (expbar >= 1 && expbar < 100) {
var emptybar = 100 - expbar;
newhtm += '<div class="expgraph ui-widget-header" style="width: ' + expbar +'%"></div><div class="expback ui-widget-content" style="width: ' + emptybar + '%"></div>';
}
else {
newhtm += '<div class="expgraph ui-widget-header" style="width: 100%"> </div>'
}
newhtm += playerobj.exp + '/' + playerobj.maxexp + '</span>'
newhtm += '</div>';
}
return newhtm;
}