-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBattleFiled.lua
2549 lines (2533 loc) · 94.6 KB
/
BattleFiled.lua
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
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
require "import"
import "android.app.*"
import "android.os.*"
import "android.widget.*"
import "android.view.*"
import "BattleSprite"
import "getskill"
import "GetItem"
import "android.text.Html"
import "gundong"
import "commonHelper"
local text
local sp
local role,att
local act
local speed = 2000
local ky = import "keyao"
local pettt = import "petdata"
local Color = {hui="#C6C6C6",black="#000000",white="#FFFFFF",green="#008000",blue="#0000FF",red="#FF0000",orange="#FFA500",cyan="#00FFFF",gold="#FFD700"}
function Color:Get(str,lv)
if lv >= 13 then
str={"<font color=",self.gold,">",str,"</font>"}
elseif lv >= 10 then
str={"<font color=",self.orange,">",str,"</font>"}
elseif lv >= 7 then
str={"<font color=",self.red,">",str,"</font>"}
elseif lv >= 4 then
str={"<font color=",self.blue,">",str,"</font>"}
else
str={"<font color=",self.green,">",str,"</font>"}
end
return table.concat(str)
end
local zdinfo = {}
function zdinfo:getWindow(f,save,m)
function fly(di,num)
if di == nil then
跳转地图("映日村",true,1)
else
跳转地图(di,true,1)
end
end
if self.fp ~= nil then
self.fp.dismiss()
end
local ft
if f == "win" then
ft = "战斗胜利"
elseif f == "lose" and save == nil then
ft = "战斗失败"
SaveTable.map = nil
loadsavewrite(0)
end
local str = table.concat({"杀敌数:",Color:Get(math.ceil(self["杀敌数"]),7),"<br>获得修为:",Color:Get(math.ceil(self["修为"]),1),"<br>获得灵石:",Color:Get(math.ceil(self.money),1)})
local t = {"<br>获得物品:"}
local Item = import "item"
for k,v in pairs(self.drop) do
table.insert(t,table.concat({Color:Get(k,Item:GetLevel(k)),"*",v,"<br>     "}))
end
if #t > 1 then
t=table.concat(t)
str=table.concat({str,t})
end
t = {"<br>获得宠兽:"}
for k,v in pairs(self.pet) do
table.insert(t,table.concat({v,"<br>     "}))
end
if #t > 1 then
t=table.concat(t)
str=Html.fromHtml(table.concat({str,t}))
else
str=Html.fromHtml(str)
end
self.fp=poppb(savelay.zdif)
zdsha.onClick=function
local m = {
LinearLayout;
orientation="vertical";
layout_width="fill";
layout_height="fill";
{
FrameLayout;
layout_width="match_parent";
backgroundColor="#000000";
layout_height="4%h";
{
TextView;
textSize="15sp";
text="伤害";
textColor="#FFFFFF";
layout_gravity="center";
};
};
{
TextView;
id="伤害";
};
};
local num = 0
for k,v in pairs(zdinfo.danmage) do
num = num + v
end
local str = ""
for k,v in pairs(zdinfo.danmage) do
str=str..Color:Get(k,1).."造成伤害:"..Color:Get(math.ceil(v),7).."/(".."伤害占比:"..math.floor(v/num*10000)/100 .."%)<br>"
end
self.dp=AlertDialog.Builder(activity)
.setView(loadlayout(m)).show()
伤害.Text=Html.fromHtml(str)
end
zdqra.onClick=function
SaveTable["重塑"]=os.time()
self.fp.dismiss()
if self.result == nil then
SaveTable["重塑"]=nil
loadsavewrite(0)
fly(SaveTable.map,1)
elseif self.result[f] ~= nil then
if self.result[f].type == "story" then
fly(SaveTable.map,1)
文字动画(self.result[f].value,1)
elseif self.result[f].type == "map" then
fly(self.result[f].value,1)
elseif self.result[f].type == "set_time" then
SaveTable["刷新"][self.result[f].value.key] = {key=self.result[f].value.text,number={0,self.result[f].value.number}}
if SaveTable.finish_story == nil then
SaveTable.finish_story = {}
end
if self.result[f].value.key == "???" and SaveTable.finish_story["古战场一层"] == nil and SaveTable.owner.level <= 20 then
文字动画("古战场一层",1)
end
loadsavewrite(0)
fly(SaveTable.map,1)
end
elseif f == "lose" and save == nil then
提示("战斗失败,已被系统强制传送至安全地点")
fly(SaveTable.map,1)
elseif f == "lose" and save ~= nil then
activity.setContentView(MapUI()["死亡界面"])
else
fly(SaveTable.map,1)
end
if f == "win" then
if save == nil then
loadsavewrite(0)
SaveTable["重塑"]=nil
end
end
m.dismiss()
end
zdxxa.Text=str
end
function Color:Set(str,lv)
if lv >= 13 then
str={"<font color=",self.gold,">",str,"</font>"}
elseif lv >= 10 then
str={"<font color=",self.orange,">",str,"</font>"}
elseif lv >= 7 then
str={"<font color=",self.red,">",str,"</font>"}
elseif lv >= 4 then
str={"<font color=",self.blue,">",str,"</font>"}
else
str={"<font color=",self.green,">",str,"</font>"}
end
return Html.fromHtml(table.concat(str))
end
local exp = import "skillexp"
local 境界 = import "tupo"
local ptjj = import "pettupo"
local Item = import "item"
local battle = import "battle"
function openbattlemap()
local buju = {
LinearLayout;
backgroundColor="#000000";
layout_height="fill";
layout_width="fill";
orientation="horizontal";
{
CardView;
layout_margin="2%w";
layout_height="fill";
layout_width="fill";
radius="10dp";
{
ListView;
layout_width="fill";
layout_height="fill";
id="战斗地图";
};
};
};
local bt = popno(buju)
local mps = {
LinearLayout;
backgroundColor="#000000";
layout_height="fill";
layout_width="fill";
{
CardView;
cardBackgroundColor="#FFF7F7F7";
layout_gravity="center";
layout_height="45dp";
elevation="0dp";
layout_margin="2%w";
layout_width="fill";
radius="5dp";
{
LinearLayout;
id="";
layout_width="fill";
layout_height="fill";
layout_margin="0dp";
gravity="center";
{
TextView;
text="name";
textSize=getsize(14);
textColor="#333333";
id="地图名";
};
};
};
};
SaveTable.zt = 1
local data={}
local zdtb = {"寂静森林","战斗1","战斗2","战斗3","战斗4","战斗5","战斗6","战斗7","战斗8","战斗9","战斗10","战斗11","战斗12","战斗13","战斗14","战斗15","战斗16","战斗17","战斗18","战斗19","战斗20","战斗21"}
local zdjj = {"[炼气一层]","[炼气初期]","[炼气中期]","[炼气后期]","[筑基初期]","[筑基中期]","[筑基后期]","[筑基大圆满]","[金丹初期]","[金丹中期]","[金丹后期]","[金丹大圆满]","[元婴初期]","[元婴中期]","[元婴后期]","[元婴大圆满]","[化神初期]","[化神中期]","[化神后期]","[化神大圆满]","[合体初期]","[合体中期]"}
local adp=LuaAdapter(activity,data,mps)
if SaveTable.sys == nil then
SaveTable.sys = {level=1,shop=1,battle=1}
end
for k,v in pairs(zdtb) do
if k <= SaveTable.sys.battle + 1 then
data[#data+1]={地图名=v..zdjj[k]}
end
end
战斗地图.Adapter=adp
战斗地图.onItemClick=function(l,v,p,i)
SaveTable.zt = nil
bt.dismiss()
BattleStart(zdtb[i])
end
end
function BattleStart(key,phtb,cao,rt,save)
local drop_tb = GetDrop()
local shipei = SaveTable.shipei
local battleui=savelay.bt[1]
local btui = popno(battleui)
插.removeAllViews()
speed = 2000
if SaveTable.speed == 1 then
speed = 1000
elseif SaveTable.speed == 2 then
speed = 666
end
local function petAddSkillExp(key,num,p,id)
local x = 1
local self = SaveTable.pet[id].skill
repeat
if key == self[x].key then
self[x].exp = self[x].exp + num
if tonumber(exp[p][self[x].level]) then
while self[x].exp >= exp[p][self[x].level] do
self[x].exp = self[x].exp - exp[p][self[x].level]
self[x].level = self[x].level + 1
end
end
break
else
x = x + 1
end
until x > #self
end
if save == nil then
SaveTable["重塑"]=os.time()
loadsavewrite(0)
end
if SaveTable["击杀"] == nil then
SaveTable["击杀"] = {}
end
zdinfo["修为"]=0
zdinfo["杀敌数"]=0
zdinfo.money=0
zdinfo.drop={}
zdinfo.pet={}
zdinfo.result=rt
zdinfo.danmage={}
if rt ~= nil and rt.set == true then
if zdinfo.result["win"] ~= nil and zdinfo.result["win"].type == "set_time" then
if SaveTable["刷新"] == nil then
SaveTable["刷新"] = {}
end
SaveTable["刷新"][zdinfo.result["win"].value.key] = {key=zdinfo.result["win"].value.text,number={0,zdinfo.result["win"].value.number}}
loadsavewrite(0)
end
end
local zid
local SpriteTable
if phtb ~= nil then
SpriteTable = phtb
else
SpriteTable = GetSpriteTable(key)
end
for k,v in pairs(SpriteTable) do
if v.team == 1 then
zdinfo.danmage[v.key] = 0
end
end
function 更改挂机()
if SaveTable.zid ~= nil then
zid={
CardView;
onClick=function 更改挂机() end;
layout_height="5%h";
layout_width="20%w";
backgroundColor="#000000";
radius="1%h";
{
CardView;
layout_height="match_parent";
radius="0.8%h";
layout_margin="0.4%w";
layout_width="match_parent";
{
LinearLayout;
layout_gravity="center";
orientation="horizontal";
layout_height="wrap_content";
layout_width="wrap_content";
{
TextView;
textColor="#000000";
text="手动";
textSize=getsize(16);
};
};
};
};
SaveTable.zid = nil
提示("已更改为手动攻击")
else
zid={
CardView;
onClick=function 更改挂机() end;
layout_height="5%h";
layout_width="20%w";
backgroundColor="#000000";
radius="1%h";
{
CardView;
layout_height="match_parent";
radius="0.8%h";
layout_margin="0.4%w";
layout_width="match_parent";
{
CardView;
backgroundColor="#000000";
layout_height="match_parent";
radius="0.65%h";
layout_margin="0.4%w";
layout_width="match_parent";
{
TextView;
layout_gravity="center";
textColor="#FFFFFF";
text="自动";
textSize=getsize(16);
};
};
};
};
SaveTable.zid = 1
提示("已更改为自动操作")
end
自动.removeViews(0,1)
自动.addView(loadlayout(zid))
end
function 加速()
if SaveTable.speed == 2 then
zid={
CardView;
onClick=function 加速() end;
layout_height="5%h";
layout_width="20%w";
backgroundColor="#000000";
radius="1%h";
{
CardView;
layout_height="match_parent";
radius="0.8%h";
layout_margin="0.4%w";
layout_width="match_parent";
{
LinearLayout;
layout_gravity="center";
orientation="horizontal";
layout_height="wrap_content";
layout_width="wrap_content";
{
TextView;
textColor="#000000";
text="加速";
textSize=getsize(16);
};
};
};
};
SaveTable.speed = nil
if 战斗计时 ~= nil then
战斗计时.Period=2000
end
提示("战斗加速已关闭")
elseif SaveTable.speed == nil then
zid={
CardView;
onClick=function 加速() end;
layout_height="5%h";
layout_width="20%w";
backgroundColor="#000000";
radius="1%h";
{
CardView;
layout_height="match_parent";
radius="0.8%h";
layout_margin="0.4%w";
layout_width="match_parent";
{
CardView;
backgroundColor="#000000";
layout_height="match_parent";
radius="0.65%h";
layout_margin="0.4%w";
layout_width="match_parent";
{
TextView;
layout_gravity="center";
textColor="#FFFFFF";
text="加速";
textSize=getsize(16);
};
};
};
};
SaveTable.speed = 1
if 战斗计时 ~= nil then
战斗计时.Period=1000
end
提示("战斗加速已开启!")
elseif SaveTable.speed == 1 then
zid={
CardView;
onClick=function 加速() end;
layout_height="5%h";
layout_width="20%w";
backgroundColor="#000000";
radius="1%h";
{
CardView;
layout_height="match_parent";
radius="0.8%h";
layout_margin="0.4%w";
layout_width="match_parent";
{
CardView;
backgroundColor="#000000";
layout_height="match_parent";
radius="0.65%h";
layout_margin="0.4%w";
layout_width="match_parent";
{
TextView;
layout_gravity="center";
textColor="#FF0000";
text="加速";
textSize=getsize(16);
};
};
};
};
SaveTable.speed = 2
if 战斗计时 ~= nil then
战斗计时.Period=666
end
提示("已开启超级加速!")
end
战斗加速.removeViews(0,1)
战斗加速.addView(loadlayout(zid))
end
if true then
local czt = {
LinearLayout;
orientation="vertical";
layout_width="fill";
layout_height="fill";
{
LinearLayout;
id="行动";
layout_width="22%w";
layout_height="6%h";
};
{
LinearLayout;
id="自动";
layout_width="22%w";
layout_height="6%h";
};
{
LinearLayout;
id="战斗加速";
layout_width="22%w";
layout_height="6%h";
};
{
LinearLayout;
id="逃跑";
layout_width="22%w";
layout_height="6%h";
};
}
插.addView(loadlayout(czt))
if SaveTable.zid == nil then
zid={
CardView;
onClick=function 更改挂机() end;
layout_height="5%h";
layout_width="20%w";
backgroundColor="#000000";
radius="1%h";
{
CardView;
layout_height="match_parent";
radius="0.8%h";
layout_margin="0.4%w";
layout_width="match_parent";
{
LinearLayout;
layout_gravity="center";
orientation="horizontal";
layout_height="wrap_content";
layout_width="wrap_content";
{
TextView;
textColor="#000000";
text="手动";
textSize=getsize(16);
};
};
};
};
else
zid={
CardView;
onClick=function 更改挂机() end;
layout_height="5%h";
layout_width="20%w";
backgroundColor="#000000";
radius="1%h";
{
CardView;
layout_height="match_parent";
radius="0.8%h";
layout_margin="0.4%w";
layout_width="match_parent";
{
CardView;
backgroundColor="#000000";
layout_height="match_parent";
radius="0.65%h";
layout_margin="0.4%w";
layout_width="match_parent";
{
TextView;
layout_gravity="center";
textColor="#FFFFFF";
text="自动";
textSize=getsize(16);
};
};
};
};
end
自动.addView(loadlayout(zid))
if SaveTable.speed == nil then
zid={
CardView;
onClick=function 加速() end;
layout_height="5%h";
layout_width="20%w";
backgroundColor="#000000";
radius="1%h";
{
CardView;
layout_height="match_parent";
radius="0.8%h";
layout_margin="0.4%w";
layout_width="match_parent";
{
LinearLayout;
layout_gravity="center";
orientation="horizontal";
layout_height="wrap_content";
layout_width="wrap_content";
{
TextView;
textColor="#000000";
text="加速";
textSize=getsize(16);
};
};
};
};
elseif SaveTable.speed == 1 then
zid={
CardView;
onClick=function 加速() end;
layout_height="5%h";
layout_width="20%w";
backgroundColor="#000000";
radius="1%h";
{
CardView;
layout_height="match_parent";
radius="0.8%h";
layout_margin="0.4%w";
layout_width="match_parent";
{
CardView;
backgroundColor="#000000";
layout_height="match_parent";
radius="0.65%h";
layout_margin="0.4%w";
layout_width="match_parent";
{
TextView;
layout_gravity="center";
textColor="#FFFFFF";
text="加速";
textSize=getsize(16);
};
};
};
};
elseif SaveTable.speed == 2 then
zid={
CardView;
onClick=function 加速() end;
layout_height="5%h";
layout_width="20%w";
backgroundColor="#000000";
radius="1%h";
{
CardView;
layout_height="match_parent";
radius="0.8%h";
layout_margin="0.4%w";
layout_width="match_parent";
{
CardView;
backgroundColor="#000000";
layout_height="match_parent";
radius="0.65%h";
layout_margin="0.4%w";
layout_width="match_parent";
{
TextView;
layout_gravity="center";
textColor="#FF0000";
text="加速";
textSize=getsize(16);
};
};
};
};
end
战斗加速.addView(loadlayout(zid))
end
function 停止挂机()
AlertDialog.Builder(this)
.setTitle("确认")
.setMessage("确定要停止挂机吗?")
.setPositiveButton("取消",nil)
.setNegativeButton("确认",function
if cao == nil then
SaveTable.gj = nil
MD提示("已停止自动挂机,本场战斗结束后将自动退出")
else
MD提示("无法操作")
end
end)
.show();
end
返回 = "弹窗战斗"
function GetSp(tab)
sp = 0
for k,v in pairs(tab) do
if type(v) == "table" then
if v.Hp > 0 then
local ss = 1
if v["爆发行动"] ~= nil then
ss = ss + v["爆发行动"][1]/100
end
if v["累进行动"] ~= nil then
ss = ss + v["累进行动"][1]/100
end
sp = sp + v.sp * ss
end
end
end
return sp
end
function SpriteTable:GetEnemyTable(team)
local EnemyTable = {}
for i=1,#self do
if team ~= self[i].team then
table.insert(EnemyTable,self[i])
end
end
return EnemyTable
end
local taby = SpriteTable:GetEnemyTable(2)
local tabd = SpriteTable:GetEnemyTable(1)
local data=savelay.bt[2]
local data1=savelay.bt[4]
local data5=savelay.bt[6]
local adp=savelay.bt[3]
adp.clear()
local adp1=savelay.bt[5]
adp1.clear()
local adp5=savelay.bt[7]
adp5.clear()
for i=1,#SpriteTable do
SpriteTable[i].sp = SpriteTable[i].sp + SpriteTable[i].hard
SpriteTable[i].id = i
if SpriteTable[i].team == 1 then
if SpriteTable[i].ph ~= nil then
table.insert(data,{名称境界=table.concat({SpriteTable[i].name,"\n",ptjj[SpriteTable[i].level]["境界"]}),
血量显示=table.concat({math.ceil(SpriteTable[i].Hp),"/",math.ceil(SpriteTable[i].Attribute["气血上限"])}),法力显示=table.concat({math.ceil(SpriteTable[i].Mp),"/",math.ceil(SpriteTable[i].Attribute["法力上限"])}),id=i})
local xt = math.ceil((SpriteTable[i].Hp/SpriteTable[i].Attribute["气血上限"])*shipei)
local lt = math.ceil((SpriteTable[i].Mp/SpriteTable[i].Attribute["法力上限"])*shipei)
local ostr=""
local pstr=""
for i=1,xt do
ostr=table.concat({ostr," "})
end
data[#data].血条=ostr
for i=1,lt do
pstr=table.concat({pstr," "})
end
data[#data].蓝条=pstr
else
if SpriteTable[i].level ~= nil then
table.insert(data,{名称境界=SpriteTable[i].key.."\n"..境界[SpriteTable[i].level]["境界"],
血量显示=table.concat({math.ceil(SpriteTable[i].Hp),"/",math.ceil(SpriteTable[i].Attribute["气血上限"])}),法力显示=table.concat({math.ceil(SpriteTable[i].Mp),"/",math.ceil(SpriteTable[i].Attribute["法力上限"])}),id=i})
local xt = math.ceil((SpriteTable[i].Hp/SpriteTable[i].Attribute["气血上限"])*shipei)
local lt = math.ceil((SpriteTable[i].Mp/SpriteTable[i].Attribute["法力上限"])*shipei)
local ostr=""
local pstr=""
for i=1,xt do
ostr=table.concat({ostr," "})
end
data[#data].血条=ostr
for i=1,lt do
pstr=table.concat({pstr," "})
end
data[#data].蓝条=pstr
end
end
elseif SpriteTable[i].ph ~= nil then
table.insert(data1,{名称境界=table.concat({SpriteTable[i].name,"\n",ptjj[SpriteTable[i].level]["境界"]}),
血量显示=table.concat({math.ceil(SpriteTable[i].Hp),"/",math.ceil(SpriteTable[i].Attribute["气血上限"])}),法力显示=table.concat({math.ceil(SpriteTable[i].Mp),"/",math.ceil(SpriteTable[i].Attribute["法力上限"])}),id=i})
local xt = math.ceil((SpriteTable[i].Hp/SpriteTable[i].Attribute["气血上限"])*shipei)
local lt = math.ceil((SpriteTable[i].Mp/SpriteTable[i].Attribute["法力上限"])*shipei)
local ostr=""
local pstr=""
for i=1,xt do
ostr=table.concat({ostr," "})
end
data1[#data1].血条=ostr
for i=1,lt do
pstr=table.concat({pstr," "})
end
data1[#data1].蓝条=pstr
else
table.insert(data1,{名称境界=SpriteTable[i].key.."\n"..境界[SpriteTable[i].level]["境界"],
血量显示=table.concat({math.ceil(SpriteTable[i].Hp),"/",math.ceil(SpriteTable[i].Attribute["气血上限"])}),法力显示=table.concat({math.ceil(SpriteTable[i].Mp),"/",math.ceil(SpriteTable[i].Attribute["法力上限"])}),id=i})
local xt = math.ceil((SpriteTable[i].Hp/SpriteTable[i].Attribute["气血上限"])*shipei)
local lt = math.ceil((SpriteTable[i].Mp/SpriteTable[i].Attribute["法力上限"])*shipei)
local ostr=""
local pstr=""
for i=1,xt do
ostr=table.concat({ostr," "})
end
data1[#data1].血条=ostr
for i=1,lt do
pstr=table.concat({pstr," "})
end
data1[#data1].蓝条=pstr
end
end
战斗信息.Adapter = nil
战斗信息.Adapter=adp5
敌方面板.Adapter = nil
敌方面板.Adapter=adp1
己方面板.Adapter = nil
己方面板.Adapter=adp
function 战斗开始()
jincheng()
end
function 战斗重复()
if SaveTable.gj ~= nil then
loadsavewrite(0)
adp5.clear()
local tab = GetSpriteTable(key)
sp=GetSp(tab)
for k,v in pairs(tab) do
SpriteTable[k] = v
end
local num = #data
for i=1,num do
table.remove(data)
end
local num1 = #data1
for i=1,num1 do
table.remove(data1)
end
for i=1,#SpriteTable do
SpriteTable[i].id = i
SpriteTable[i].sp = SpriteTable[i].sp + SpriteTable[i].hard
if SpriteTable[i].team == 1 then
if SpriteTable[i].ph ~= nil then
table.insert(data,{名称境界=table.concat({SpriteTable[i].name,"\n",ptjj[SpriteTable[i].level]["境界"]}),
血量显示=table.concat({math.ceil(SpriteTable[i].Hp),"/",math.ceil(SpriteTable[i].Attribute["气血上限"])}),法力显示=table.concat({math.ceil(SpriteTable[i].Mp),"/",math.ceil(SpriteTable[i].Attribute["法力上限"])}),id=i})
local xt = math.ceil((SpriteTable[i].Hp/SpriteTable[i].Attribute["气血上限"])*shipei)
local lt = math.ceil((SpriteTable[i].Mp/SpriteTable[i].Attribute["法力上限"])*shipei)
local ostr=""
local pstr=""
for i=1,xt do
ostr=table.concat({ostr," "})
end
data[#data].血条=ostr
for i=1,lt do
pstr=table.concat({pstr," "})
end
data[#data].蓝条=pstr
else
if SpriteTable[i].level ~= nil then
table.insert(data,{名称境界=SpriteTable[i].key.."\n"..境界[SpriteTable[i].level]["境界"],
血量显示=table.concat({math.ceil(SpriteTable[i].Hp),"/",math.ceil(SpriteTable[i].Attribute["气血上限"])}),法力显示=table.concat({math.ceil(SpriteTable[i].Mp),"/",math.ceil(SpriteTable[i].Attribute["法力上限"])}),id=i})
local xt = math.ceil((SpriteTable[i].Hp/SpriteTable[i].Attribute["气血上限"])*shipei)
local lt = math.ceil((SpriteTable[i].Mp/SpriteTable[i].Attribute["法力上限"])*shipei)
local ostr=""
local pstr=""
for i=1,xt do
ostr=table.concat({ostr," "})
end
data[#data].血条=ostr
for i=1,lt do
pstr=table.concat({pstr," "})
end
data[#data].蓝条=pstr
end
end
else
table.insert(data1,{名称境界=SpriteTable[i].key.."\n"..境界[SpriteTable[i].level]["境界"],
血量显示=table.concat({math.ceil(SpriteTable[i].Hp),"/",math.ceil(SpriteTable[i].Attribute["气血上限"])}),法力显示=table.concat({math.ceil(SpriteTable[i].Mp),"/",math.ceil(SpriteTable[i].Attribute["法力上限"])}),id=i})
local xt = math.ceil((SpriteTable[i].Hp/SpriteTable[i].Attribute["气血上限"])*shipei)
local lt = math.ceil((SpriteTable[i].Mp/SpriteTable[i].Attribute["法力上限"])*shipei)
local ostr=""
local pstr=""
for i=1,xt do
ostr=table.concat({ostr," "})
end
data1[#data1].血条=ostr
for i=1,lt do
pstr=table.concat({pstr," "})
end
data1[#data1].蓝条=pstr
end
end
adp1.notifyDataSetChanged()
adp.notifyDataSetChanged()
SpriteTable:SetUI(nil,"战斗开始!")
if 战斗计时 == nil then
战斗计时=Ticker()
战斗计时.Period=speed
战斗计时.onTick=function()
战斗开始()
end
end
战斗计时.start()
else
zdinfo:getWindow("win",save,btui)
end
end
function SetNowSp(sp,num)
local ss = 1
if sp["爆发行动"] ~= nil then
ss = ss + sp["爆发行动"][1]/100
sp["爆发行动"][1] = sp["爆发行动"][1] - sp["爆发行动"][2]
if sp["爆发行动"][1] <= 0 then
sp["爆发行动"] = nil
end
end
if sp["累进行动"] ~= nil then
ss = ss + sp["累进行动"][1]/100
sp["累进行动"][1] = sp["累进行动"][1] + sp["累进行动"][2]
if sp["累进行动"][1] > sp["累进行动"][3] then
sp["累进行动"][1] = sp["累进行动"][3]
end
end
return probability(sp.sp*ss/num)
end
function SkillColor(str,lv)
if lv >= 13 then
str={"<font color=",Color.gold,">",str,"</font>"}
elseif lv >= 10 then
str={"<font color=",Color.orange,">",str,"</font>"}
elseif lv >= 7 then
str={"<font color=",Color.red,">",str,"</font>"}
elseif lv >= 4 then
str={"<font color=",Color.blue,">",str,"</font>"}
else
str={"<font color=",Color.green,">",str,"</font>"}
end
return table.concat(str)
end
function GetColor(str,co)
str={"<font color=",co,">",tostring(str),"</font>"}
return table.concat(str)
end
function SpriteTable:GetCurrent()
if act == nil then
local num = GetSp(self)
local zd
for i=1,#self do
if self[i] then
if SetNowSp(self[i],num) then
self:Attack(self[i])
break
else
num = num - self[i].sp
end
end
end
else
local idx
for k,v in pairs(self) do
if type(v) == "table" then
if act == v.id then
idx = k
break
end
end
end
self:Attack(self[idx])
act = nil
end
end
function jincheng()
if 战斗计时 ~= nil then
SpriteTable:GetCurrent()
end
end
function SpriteTable:RollSkillTable(current)
local skillbox = {}
for k,v in pairs(current.skill) do
if v.eq == 1 then
table.insert(skillbox,v)
end
end
return skillbox
end
function SpriteTable:Attack(current)
if current.buff ~= nil then
if current.buff["回复"] ~= nil then
local hfx = math.ceil(current.buff["回复"].number.Hp[1] * current.Attribute["气血上限"]/100)
local hff = math.ceil(current.buff["回复"].number.Mp[1] * current.Attribute["法力上限"]/100)
if hfx > current.buff["回复"].number.Hp[2] then
hfx = current.buff["回复"].number.Hp[2]
end
if hff > current.buff["回复"].number.Mp[2] then
hff = current.buff["回复"].number.Mp[2]
end
if hfx + current.Hp > current.Attribute["气血上限"] then
hfx = current.Attribute["气血上限"] - current.Hp
end
if hff + current.Mp > current.Attribute["法力上限"] then
hff = current.Attribute["法力上限"] - current.Mp
end
if hfx ~= 0 or hff ~= 0 then
current.Hp = current.Hp + hfx
current.Mp = current.Mp + hff