This repository has been archived by the owner on Jun 6, 2023. It is now read-only.
forked from Mystery333/QSanguoshaAI
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstandard_cards-ai.lua
3394 lines (3011 loc) · 135 KB
/
standard_cards-ai.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
function SmartAI:canAttack(enemy, attacker, nature)
attacker = attacker or self.player
nature = nature or sgs.DamageStruct_Normal
local damage = 1
if nature == sgs.DamageStruct_Fire and not enemy:hasArmorEffect("SilverLion") then
if enemy:hasArmorEffect("Vine") then damage = damage + 1 end
if enemy:getMark("@gale") > 0 then damage = damage + 1 end
end
if #self.enemies == 1 or self:hasSkills("jueqing") then return true end
if self:getDamagedEffects(enemy, attacker) or (self:needToLoseHp(enemy, attacker, false, true) and #self.enemies > 1) or not sgs.isGoodTarget(enemy, self.enemies, self) then return false end
if self:objectiveLevel(enemy) <= 2 or self:cantbeHurt(enemy, self.player, damage) or not self:damageIsEffective(enemy, nature, attacker) then return false end
if nature ~= sgs.DamageStruct_Normal and enemy:isChained() and not self:isGoodChainTarget(enemy, self.player, nature) then return false end
return true
end
function hasExplicitRebel(room)
room = room or global_room
for _, player in sgs.qlist(room:getAllPlayers()) do
if sgs.isRolePredictable() and sgs.evaluatePlayerRole(player) == "rebel" then return true end
if sgs.compareRoleEvaluation(player, "rebel", "loyalist") == "rebel" then return true end
end
return false
end
function sgs.isGoodHp(player)
local goodHp = player:getHp() > 1 or getCardsNum("Peach", player) >= 1 or getCardsNum("Analeptic", player) >= 1
or hasBuquEffect(player)
or (player:hasSkill("niepan") and player:getMark("@nirvana") > 0)
or (player:hasSkill("fuli") and player:getMark("@laoji") > 0)
if goodHp then
return goodHp
else
for _, p in sgs.qlist(global_room:getOtherPlayers(player)) do
if sgs.compareRoleEvaluation(p,"rebel","loyalist")==sgs.compareRoleEvaluation(player,"rebel","loyalist")
and getCardsNum("Peach",p)>0 and not global_room:getCurrent():hasSkill("wansha") then
return true
end
end
return false
end
end
function sgs.isGoodTarget(player, targets, self, isSlash)
local arr = {"jieming", "yiji", "guixin", "fangzhu", "neoganglie", "nosmiji", "xuehen", "xueji"}
local m_skill = false
local attacker = global_room:getCurrent()
if targets and type(targets)=="table" then
if #targets == 1 then return true end
local foundtarget = false
for i = 1, #targets, 1 do
if sgs.isGoodTarget(targets[i]) and not self:cantbeHurt(targets[i]) then
foundtarget = true
break
end
end
if not foundtarget then return true end
end
for _, masochism in ipairs(arr) do
if player:hasSkill(masochism) then
if masochism == "nosmiji" and player:isWounded() then m_skill = false
elseif masochism == "xueji" and player:isWounded() then m_skill = false
elseif attacker and attacker:hasSkill("jueqing") then m_skill = false
elseif masochism == "jieming" and self and self:getJiemingChaofeng(player) > -4 then m_skill = false
elseif masochism == "yiji" and self and not self:findFriendsByType(sgs.Friend_Draw, player) then m_skill = false
else
m_skill = true
break
end
end
end
if not (attacker and attacker:hasSkill("jueqing")) and player:hasSkill("huilei") and not player:isLord() and player:getHp() == 1 then
if attacker and attacker:getHandcardNum() >= 4 then return false end
return sgs.compareRoleEvaluation(player, "rebel", "loyalist") == "rebel"
end
if not (attacker and attacker:hasSkill("jueqing")) and player:hasSkill("wuhun") and not player:isLord()
and ((attacker and attacker:isLord()) or player:getHp() <= 2) then
return false
end
if player:hasLordSkill("shichou") and player:getMark("@hate") == 0 then
for _, p in sgs.qlist(player:getRoom():getOtherPlayers(player)) do
if p:getMark("hate_" .. player:objectName()) > 0 and p:getMark("@hate_to") > 0 then
return false
end
end
end
if isSlash and self and (self:hasCrossbowEffect() or self:getCardsNum("Crossbow") > 0) and self:getCardsNum("Slash") > player:getHp() then
return true
end
if player:hasSkill("hunzi") and player:getMark("hunzi") == 0 and player:isLord() and player:getHp() == 2 and sgs.current_mode_players["loyalist"] > 0 then
return false
end
if m_skill and sgs.isGoodHp(player) then
return false
else
return true
end
end
function sgs.getDefenseSlash(player, self)
if not player then return 0 end
local attacker = self and self.player or global_room:getCurrent()
local defense = getCardsNum("Jink", player, attacker)
local knownJink = getKnownCard(player, attacker, "Jink", true)
if sgs.card_lack[player:objectName()]["Jink"] == 1 and knownJink == 0 then defense = 0 end
defense = defense + knownJink * 1.2
local hasEightDiagram = false
if (player:hasArmorEffect("EightDiagram") or (player:hasSkill("bazhen") and not player:getArmor()))
and not IgnoreArmor(attacker, player) then
hasEightDiagram = true
end
if hasEightDiagram then
defense = defense + 1.3
if player:hasSkill("tiandu") then defense = defense + 0.6 end
if player:hasSkill("gushou") then defense = defense + 0.4 end
if player:hasSkill("leiji") then defense = defense + 0.4 end
if player:hasSkill("noszhenlie") then defense = defense + 0.2 end
if player:hasSkill("hongyan") then defense = defense + 0.2 end
end
if getCardsNum("Jink", player, global_room:getCurrent()) >= 1 then
if player:hasSkill("mingzhe") then defense = defense + 0.2 end
if player:hasSkill("gushou") then defense = defense + 0.2 end
if player:hasSkills("tuntian+zaoxian") then defense = defense + 1.5 end
end
if player:hasSkill("aocai") and player:getPhase() == sgs.Player_NotActive then defense = defense + 0.5 end
if player:hasSkill("wanrong") and not hasManjuanEffect(player) then defense = defense + 0.5 end
local hujiaJink = 0
if player:hasLordSkill("hujia") then
local lieges = global_room:getLieges("wei", player)
for _, liege in sgs.qlist(lieges) do
if sgs.compareRoleEvaluation(liege,"rebel","loyalist") == sgs.compareRoleEvaluation(player,"rebel","loyalist") then
hujiaJink = hujiaJink + getCardsNum("Jink", liege, global_room:getCurrent())
if liege:hasArmorEffect("EightDiagram") then hujiaJink = hujiaJink + 0.8 end
end
end
defense = defense + hujiaJink
end
if player:getMark("@tied") > 0 and not attacker:hasSkill("jueqing") then defense = defense + 1 end
if attacker:canSlashWithoutCrossbow() and attacker:getPhase() == sgs.Player_Play then
local hcard = player:getHandcardNum()
if attacker:hasSkill("liegong") and (hcard >= attacker:getHp() or hcard <= attacker:getAttackRange()) then defense = 0 end
if attacker:hasSkill("kofliegong") and hcard >= attacker:getHp() then defense = 0 end
end
local jiangqin = global_room:findPlayerBySkillName("niaoxiang")
local need_double_jink = attacker:hasSkills("wushuang|drwushuang")
or (attacker:hasSkill("roulin") and player:isFemale())
or (player:hasSkill("roulin") and attacker:isFemale())
or (jiangqin and jiangqin:isAdjacentTo(player) and attacker:isAdjacentTo(player) and self and self:isFriend(jiangqin, attacker))
if need_double_jink and getKnownCard(player, attacker, "Jink", true, "he") < 2
and getCardsNum("Jink", player) < 1.5
and (not player:hasLordSkill("hujia") or hujiaJink < 2) then
defense = 0
end
if attacker:hasSkill("dahe") and player:hasFlag("dahe") and getKnownCard(player, attacker, "Jink", true, "he") == 0 and getKnownNum(player) == player:getHandcardNum()
and not (player:hasLordSkill("hujia") and hujiaJink >= 1) then
defense = 0
end
local jink = sgs.Sanguosha:cloneCard("jink")
if player:isCardLimited(jink, sgs.Card_MethodUse) then defense = 0 end
if player:hasFlag("QianxiTarget") then
local red = player:getMark("@qianxi_red") > 0
local black = player:getMark("@qianxi_black") > 0
if red then
if player:hasSkill("qingguo") or (player:hasSkill("longhun") and player:isWounded()) then
defense = defense - 1
else
defense = 0
end
elseif black then
if player:hasSkill("qingguo") then
defense = defense - 1
end
end
end
defense = defense + math.min(player:getHp() * 0.45, 10)
if attacker and not attacker:hasSkill("jueqing") then
local m = sgs.masochism_skill:split("|")
for _, masochism in ipairs(m) do
if player:hasSkill(masochism) and sgs.isGoodHp(player) then
defense = defense + 1
end
end
if player:hasSkill("jieming") then defense = defense + 4 end
if player:hasSkill("yiji") then defense = defense + 4 end
if player:hasSkill("guixin") then defense = defense + 4 end
if player:hasSkill("yuce") then defense = defense + 2 end
end
if not sgs.isGoodTarget(player) then defense = defense + 10 end
if player:hasSkills("nosrende|rende") and player:getHp() > 2 then defense = defense + 1 end
if player:hasSkill("kuanggu") and player:getHp() > 1 then defense = defense + 0.2 end
if player:hasSkill("zaiqi") and player:getHp() > 1 then defense = defense + 0.35 end
if player:hasSkill("tianming") then defense = defense + 0.1 end
if player:getHp() > getBestHp(player) then defense = defense + 0.8 end
if player:getHp() <= 2 then defense = defense - 0.4 end
local playernum = global_room:alivePlayerCount()
if (player:getSeat() - attacker:getSeat()) % playernum >= playernum - 2 and playernum > 3 and player:getHandcardNum() <= 2 and player:getHp() <= 2 then
defense = defense - 0.4
end
if player:hasSkill("tianxiang") then defense = defense + player:getHandcardNum() * 0.5 end
if player:getHandcardNum() == 0 and hujiaJink == 0 and not player:hasSkill("kongcheng") then
if player:getHp() <= 1 then defense = defense - 2.5 end
if player:getHp() == 2 then defense = defense - 1.5 end
if not hasEightDiagram then defense = defense - 2 end
if attacker:hasWeapon("GudingBlade") and player:getHandcardNum() == 0
and not (player:hasArmorEffect("SilverLion") and not IgnoreArmor(attacker, player)) then
defense = defense - 2
end
end
local has_fire_slash
local cards = sgs.QList2Table(attacker:getHandcards())
for i = 1, #cards, 1 do
if (attacker:hasWeapon("Fan") and cards[i]:objectName() == "slash" and not cards[i]:isKindOf("ThunderSlash")) or cards[i]:isKindOf("FireSlash") then
has_fire_slash = true
break
end
end
if player:hasArmorEffect("Vine") and not IgnoreArmor(attacker, player) and has_fire_slash then
defense = defense - 0.6
end
if isLord(player) then
defense = defense - 0.4
if sgs.isLordInDanger() then defense = defense - 0.7 end
end
if not player:faceUp() then defense = defense - 0.35 end
if player:containsTrick("indulgence") and not player:containsTrick("YanxiaoCard") then defense = defense - 0.15 end
if player:containsTrick("supply_shortage") and not player:containsTrick("YanxiaoCard") then defense = defense - 0.15 end
if (attacker:hasSkill("roulin") and player:isFemale()) or (attacker:isFemale() and player:hasSkill("roulin")) then
defense = defense - 2.4
end
if not hasEightDiagram then
if player:hasSkill("jijiu") then defense = defense - 3 end
if player:hasSkill("dimeng") then defense = defense - 2.5 end
if player:hasSkill("guzheng") and knownJink == 0 then defense = defense - 2.5 end
if player:hasSkill("qiaobian") then defense = defense - 2.4 end
if player:hasSkill("jieyin") then defense = defense - 2.3 end
if player:hasSkills("noslijian|lijian") then defense = defense - 2.2 end
if player:hasSkill("nosmiji") and player:isWounded() then defense = defense - 1.5 end
if player:hasSkill("xiliang") and knownJink == 0 then defense = defense - 2 end
if player:hasSkill("shouye") then defense = defense - 2 end
end
return defense
end
sgs.ai_compare_funcs["defenseSlash"] = function(a, b)
return sgs.getDefenseSlash(a) < sgs.getDefenseSlash(b)
end
function SmartAI:slashProhibit(card, enemy, from)
local mode = self.room:getMode()
if mode:find("_mini_36") then return self.player:hasSkill("keji") end
card = card or sgs.Sanguosha:cloneCard("slash", sgs.Card_NoSuit, 0)
from = from or self.player
if self.room:isProhibited(from, enemy, card) then return true end
local nature = card:isKindOf("FireSlash") and sgs.DamageStruct_Fire
or card:isKindOf("ThunderSlash") and sgs.DamageStruct_Thunder
for _, askill in sgs.qlist(enemy:getVisibleSkillList(true)) do
local filter = sgs.ai_slash_prohibit[askill:objectName()]
if filter and type(filter) == "function" and filter(self, from, enemy, card) then return true end
end
if self:isFriend(enemy, from) then
if card:isKindOf("FireSlash") or from:hasWeapon("Fan") or from:hasSkill("zonghuo") then
if enemy:hasArmorEffect("Vine") and not (enemy:isChained() and self:isGoodChainTarget(enemy, from, nil, nil, card)) then return true end
end
if enemy:isChained() and (card:isKindOf("NatureSlash") or from:hasSkill("zonghuo")) and self:slashIsEffective(card, enemy, from)
and (not self:isGoodChainTarget(enemy, from, nature, nil, card) and not from:hasSkill("jueqing")) then return true end
if getCardsNum("Jink",enemy, from) == 0 and enemy:getHp() < 2 and self:slashIsEffective(card, enemy, from) then return true end
if enemy:isLord() and self:isWeak(enemy) and self:slashIsEffective(card, enemy, from) then return true end
if from:hasWeapon("GudingBlade") and enemy:isKongcheng() then return true end
else
if (card:isKindOf("NatureSlash") or from:hasSkill("zonghuo")) and not from:hasSkill("jueqing") and enemy:isChained()
and not self:isGoodChainTarget(enemy, from, nature, nil, card) and self:slashIsEffective(card, enemy, from) then
return true
end
end
return not self:slashIsEffective(card, enemy, from) -- @todo: param of slashIsEffective
end
function SmartAI:canLiuli(other, another)
if not other:hasSkill("liuli") then return false end
if type(another) == "table" then
if #another == 0 then return false end
for _, target in ipairs(another) do
if target:getHp() < 3 and self:canLiuli(other, target) then return true end
end
return false
end
if not self:needToLoseHp(another, self.player, true) or not self:getDamagedEffects(another, self.player, true) then return false end
local n = other:getHandcardNum()
if n > 0 and (other:distanceTo(another) <= other:getAttackRange()) then return true
elseif other:getWeapon() and other:getOffensiveHorse() and (other:distanceTo(another) <= other:getAttackRange()) then return true
elseif other:getWeapon() or other:getOffensiveHorse() then return other:distanceTo(another) <= 1
else return false end
end
function SmartAI:slashIsEffective(slash, to, from, ignore_armor)
if not slash or not to then self.room:writeToConsole(debug.traceback()) return end
from = from or self.player
if to:hasSkill("zuixiang") and to:isLocked(slash) then return false end
if to:hasSkill("yizhong") and not to:getArmor() then
if slash:isBlack() then
return false
end
end
if to:getMark("@late") > 0 then return false end
local natures = {
Slash = sgs.DamageStruct_Normal,
FireSlash = sgs.DamageStruct_Fire,
ThunderSlash = sgs.DamageStruct_Thunder,
}
local nature = natures[slash:getClassName()]
self.equipsToDec = sgs.getCardNumAtCertainPlace(slash, from, sgs.Player_PlaceEquip)
if from:hasSkill("zonghuo") then nature = sgs.DamageStruct_Fire end
local eff = self:damageIsEffective(to, nature, from)
self.equipsToDec = 0
if not eff then return false end
if not ignore_armor and from:objectName() == self.player:objectName() then
if to:getArmor() and from:hasSkill("moukui") then
if not self:isFriend(to) or self:needToThrowArmor(to) then
if not (self:isEnemy(to) and self:doNotDiscard(to)) then
local id = self:askForCardChosen(to, "he", "moukui")
if id == to:getArmor():getEffectiveId() then ignore_armor = true end
end
end
end
end
if IgnoreArmor(from, to) or ignore_armor then
return true
end
if to:hasArmorEffect("RenwangShield") and slash:isBlack() then return false end
if to:hasArmorEffect("Vine") and not slash:isKindOf("NatureSlash") then
local skill_name = slash:getSkillName() or ""
local can_convert = false
if skill_name == "guhuo" then
can_convert = true
else
local skill = sgs.Sanguosha:getSkill(skill_name)
if not skill or skill:inherits("FilterSkill") then
can_convert = true
end
end
return can_convert and (from:hasWeapon("Fan") or from:hasSkill("zonghuo") or (from:hasSkill("lihuo") and not self:isWeak(from)))
end
if slash:isKindOf("ThunderSlash") then
local f_slash = self:getCard("FireSlash")
if f_slash and self:hasHeavySlashDamage(from, f_slash, to, true) > self:hasHeavySlashDamage(from, slash, to, true)
and (not to:isChained() or self:isGoodChainTarget(to, from, sgs.DamageStruct_Fire, nil, f_slash)) then
return self:slashProhibit(f_slash, to, from)
end
elseif slash:isKindOf("FireSlash") then
local t_slash = self:getCard("ThunderSlash")
if t_slash and self:hasHeavySlashDamage(from, t_slash, to, true) > self:hasHeavySlashDamage(from, slash, to, true)
and (not to:isChained() or self:isGoodChainTarget(to, from, sgs.DamageStruct_Thunder, nil, t_slash)) then
return self:slashProhibit(t_slash, to, from)
end
end
return true
end
function SmartAI:slashIsAvailable(player, slash) -- @todo: param of slashIsAvailable
player = player or self.player
slash = slash or self:getCard("Slash", player)
if not slash or not slash:isKindOf("Slash") then slash = sgs.Sanguosha:cloneCard("slash") end
assert(slash)
return slash:isAvailable(player)
end
function SmartAI:findWeaponToUse(enemy)
local weaponvalue = {}
local hasweapon
for _, c in sgs.qlist(self.player:getHandcards()) do
if c:isKindOf("Weapon") then
local dummy_use = { isDummy == true, to = sgs.SPlayerList() }
self:useEquipCard(c, dummy_use)
if dummy_use.card then
weaponvalue[c] = self:evaluateWeapon(c, self.player, enemy)
hasweapon = true
end
end
end
if not hasweapon then return end
if self.player:getWeapon() then weaponvalue[self.player:getWeapon()] = self:evaluateWeapon(self.player:getWeapon(), self.player, enemy) end
local max_value, max_card = -1000
for c, v in pairs(weaponvalue) do
if v > max_value then max_card = c max_value = v end
end
if self.player:getWeapon() and self.player:getWeapon():getEffectiveId() == max_card:getEffectiveId() then return false end
return max_card
end
function SmartAI:isPriorFriendOfSlash(friend, card, source)
source = source or self.player
local huatuo = self.room:findPlayerBySkillName("jijiu")
if not self:hasHeavySlashDamage(source, card, friend) and card:getSkillName() ~= "lihuo"
and (self:findLeijiTarget(friend, 50, source)
or (friend:isLord() and source:hasSkill("guagu") and friend:getLostHp() >= 1 and getCardsNum("Jink", friend, source) == 0)
or (friend:hasSkill("jieming") and source:hasSkill("nosrende") and (huatuo and self:isFriend(huatuo, source)))
or (friend:hasSkill("hunzi") and friend:getHp() == 2 and self:getDamagedEffects(friend, source)))
or self:hasQiuyuanEffect(source, friend) --or self:hasNosQiuyuanEffect(source, friend)
then
return true
end
if not source:hasSkill("jueqing") and card:isKindOf("NatureSlash") and friend:isChained() and self:isGoodChainTarget(friend, source, nil, nil, card) then return true end
return
end
function SmartAI:useCardSlash(card, use)
if not use.isDummy and not self:slashIsAvailable(self.player, card) then return end
local basicnum = 0
local cards = self.player:getCards("he")
cards = sgs.QList2Table(cards)
for _, acard in ipairs(cards) do
if acard:getTypeId() == sgs.Card_TypeBasic and not acard:isKindOf("Peach") then basicnum = basicnum + 1 end
end
local no_distance = sgs.Sanguosha:correctCardTarget(sgs.TargetModSkill_DistanceLimit, self.player, card) > 50
or self.player:hasFlag("slashNoDistanceLimit")
or card:getSkillName() == "qiaoshui"
self.slash_targets = 1 + sgs.Sanguosha:correctCardTarget(sgs.TargetModSkill_ExtraTarget, self.player, card)
if use.isDummy and use.extra_target then self.slash_targets = self.slash_targets + use.extra_target end
if self.player:hasSkill("duanbing") then self.slash_targets = self.slash_targets + 1 end
local rangefix = 0
if card:isVirtualCard() then
if self.player:getWeapon() and card:getSubcards():contains(self.player:getWeapon():getEffectiveId()) then
if self.player:getWeapon():getClassName() ~= "Weapon" then
rangefix = sgs.weapon_range[self.player:getWeapon():getClassName()] - self.player:getAttackRange(false)
end
end
if self.player:getOffensiveHorse() and card:getSubcards():contains(self.player:getOffensiveHorse():getEffectiveId()) then
rangefix = rangefix + 1
end
end
local function canAppendTarget(target)
if use.to:contains(target) then return false end
local targets = sgs.PlayerList()
for _, to in sgs.qlist(use.to) do
targets:append(to)
end
return card:targetFilter(targets, target, self.player)
end
if not use.isDummy and self.player:hasSkill("qingnang") and self:isWeak() and self:getOverflow() == 0 then return end
for _, friend in ipairs(self.friends_noself) do
local slash_prohibit = false
slash_prohibit = self:slashProhibit(card, friend)
if self:isPriorFriendOfSlash(friend, card) then
if not slash_prohibit then
if (not use.current_targets or not table.contains(use.current_targets, friend:objectName()))
and (self.player:canSlash(friend, card, not no_distance, rangefix)
or (use.isDummy and (self.player:distanceTo(friend, rangefix) <= self.predictedRange)))
and self:slashIsEffective(card, friend) then
use.card = card
if use.to and canAppendTarget(friend) then
use.to:append(friend)
end
if not use.to or self.slash_targets <= use.to:length() then return end
end
end
end
end
local targets = {}
local forbidden = {}
self:sort(self.enemies, "defenseSlash")
for _, enemy in ipairs(self.enemies) do
if not self:slashProhibit(card, enemy) and sgs.isGoodTarget(enemy, self.enemies, self, true) then
if self:hasQiuyuanEffect(self.player, enemy) then table.insert(forbidden, enemy)
elseif not self:getDamagedEffects(enemy, self.player, true) then table.insert(targets, enemy)
else table.insert(forbidden, enemy) end
end
end
if #targets == 0 and #forbidden > 0 then targets = forbidden end
if #targets == 1 and card:getSkillName() == "lihuo" and not targets[1]:hasArmorEffect("Vine") then return end
for _, target in ipairs(targets) do
local canliuli = false
local use_wuqian = self.player:hasSkill("wuqian") and self.player:getMark("@wrath") >= 2
and not target:isLocked(sgs.Sanguosha:cloneCard("jink"))
and (not self.player:hasSkill("wushuang")
or target:getArmor() and target:hasArmorEffect(target:getArmor():objectName()) and not self.player:hasWeapon("QinggangSword"))
and (self:hasHeavySlashDamage(self.player, card, target)
or (getCardsNum("Jink", target, self.player) < 2 and getCardsNum("Jink", target, self.player) >= 1 and target:getHp() <= 2))
for _, friend in ipairs(self.friends_noself) do
if self:canLiuli(target, friend) and self:slashIsEffective(card, friend) and #targets > 1 and friend:getHp() < 3 then canliuli = true end
end
if (not use.current_targets or not table.contains(use.current_targets, target:objectName()))
and (self.player:canSlash(target, card, not no_distance, rangefix)
or (use.isDummy and self.predictedRange and self.player:distanceTo(target, rangefix) <= self.predictedRange))
and self:objectiveLevel(target) > 3
and self:slashIsEffective(card, target, self.player, shoulduse_wuqian)
and not (target:hasSkill("xiangle") and basicnum < 2) and not canliuli
and not (not self:isWeak(target) and #self.enemies > 1 and #self.friends > 1 and self.player:hasSkill("keji")
and self:getOverflow() > 0 and not self:hasCrossbowEffect()) then
if target:getHp() > 1 and target:hasSkill("jianxiong") and self.player:hasWeapon("Spear") and card:getSkillName() == "Spear" then
local ids, isGood = card:getSubcards(), true
for _, id in sgs.qlist(ids) do
local c = sgs.Sanguosha:getCard(id)
if isCard("Peach", c, target) or isCard("Analeptic", c, target) then isGood = false break end
end
if not isGood then continue end
end
-- fill the card use struct
local usecard = card
if not use.to or use.to:isEmpty() then
if self.player:hasWeapon("Spear") and card:getSkillName() == "Spear" then
elseif self.player:hasWeapon("Crossbow") and self:getCardsNum("Slash") > 1 then
elseif not use.isDummy then
local card = self:findWeaponToUse(target)
if card then
use.card = card
return
end
end
if target:isChained() and self:isGoodChainTarget(target, nil, nil, nil, card) and not use.card then
if self:hasCrossbowEffect() and card:isKindOf("NatureSlash") then
local slashes = self:getCards("Slash")
for _, slash in ipairs(slashes) do
if not slash:isKindOf("NatureSlash") and self:slashIsEffective(slash, target)
and not self:slashProhibit(slash, target) then
usecard = slash
break
end
end
elseif not card:isKindOf("NatureSlash") then
local slash = self:getCard("NatureSlash")
if slash and self:slashIsEffective(slash, target) and not self:slashProhibit(slash, target) then usecard = slash end
end
end
local godsalvation = self:getCard("GodSalvation")
if not use.isDummy and godsalvation and godsalvation:getId() ~= card:getId() and self:willUseGodSalvation(godsalvation) and
(not target:isWounded() or not self:hasTrickEffective(godsalvation, target, self.player)) then
use.card = godsalvation
return
end
end
use.card = use.card or usecard
if use.to and not use.to:contains(target) and canAppendTarget(target) then
use.to:append(target)
end
if not use.isDummy then
local analeptic = self:searchForAnaleptic(use, target, use.card)
if analeptic and self:shouldUseAnaleptic(target, use.card) and analeptic:getEffectiveId() ~= card:getEffectiveId() then
use.card = analeptic
if use.to then use.to = sgs.SPlayerList() end
return
end
if self.player:hasSkill("jilve") and self.player:getMark("@bear") > 0 and not self.player:hasFlag("JilveWansha") and target:getHp() == 1 and not self.room:getCurrent():hasSkill("wansha")
and (target:isKongcheng() or getCardsNum("Jink", target, self.player) < 1 or sgs.card_lack[target:objectName()]["Jink"] == 1) then
use.card = sgs.Card_Parse("@JilveCard=.")
sgs.ai_skill_choice.jilve = "wansha"
if use.to then use.to = sgs.SPlayerList() end
return
end
if self.player:hasSkill("duyi") and self.room:getDrawPile():length() > 0 and not self.player:hasUsed("DuyiCard")
and (target:getHp() <= 2 or self:hasHeavySlashDamage(self.player, card, target)) then
sgs.ai_duyi = { id = self.room:getDrawPile():first(), tg = target }
use.card = sgs.Card_Parse("@DuyiCard=.")
if use.to then use.to = sgs.SPlayerList() end
return
end
if use_wuqian then
use.card = sgs.Card_Parse("@WuqianCard=.")
if use.to then use.to = sgs.SPlayerList() use.to:append(target) end
return
end
end
if not use.to or self.slash_targets <= use.to:length() then return end
end
end
for _, friend in ipairs(self.friends_noself) do
local slash_prohibit = self:slashProhibit(card, friend)
if (not use.current_targets or not table.contains(use.current_targets, friend:objectName()))
and not self:hasHeavySlashDamage(self.player, card, friend) and card:getSkillName() ~= "lihuo"
and (not use.to or not use.to:contains(friend))
and ((self.player:hasSkill("pojun") and friend:getHp() > 4 and getCardsNum("Jink", friend, self.player) == 0 and friend:getHandcardNum() < 3)
or (self:getDamagedEffects(friend, self.player) and not (friend:isLord() and #self.enemies < 1))
or (self:needToLoseHp(friend, self.player, true, true) and not (friend:isLord() and #self.enemies < 1))) then
if not slash_prohibit then
if ((self.player:canSlash(friend, card, not no_distance, rangefix))
or (use.isDummy and self.predictedRange and self.player:distanceTo(friend, rangefix) <= self.predictedRange))
and self:slashIsEffective(card, friend) then
use.card = card
if use.to and canAppendTarget(friend) then
use.to:append(friend)
end
if not use.to or self.slash_targets <= use.to:length() then return end
end
end
end
end
end
sgs.ai_skill_use.slash = function(self, prompt)
local parsedPrompt = prompt:split(":")
local callback = sgs.ai_skill_cardask[parsedPrompt[1]] -- for askForUseSlashTo
if self.player:hasFlag("slashTargetFixToOne") and type(callback) == "function" then
local slash
local target
for _, player in sgs.qlist(self.room:getOtherPlayers(self.player)) do
if player:hasFlag("SlashAssignee") then target = player break end
end
local target2 = nil
if #parsedPrompt >= 3 then target2 = findPlayerByObjectName(self.room, parsedPrompt[3]) end
if not target then return "." end
local ret = callback(self, nil, nil, target, target2, prompt)
if ret == nil or ret == "." then return "." end
slash = sgs.Card_Parse(ret)
local no_distance = sgs.Sanguosha:correctCardTarget(sgs.TargetModSkill_DistanceLimit, self.player, slash) > 50 or self.player:hasFlag("slashNoDistanceLimit")
local targets = {}
local use = { to = sgs.SPlayerList() }
if self.player:canSlash(target, slash, not no_distance) then use.to:append(target) else return "." end
if parsedPrompt[1] ~= "@niluan-slash" and target:hasSkill("xiansi") and target:getPile("counter"):length() > 1
and not (self:needKongcheng() and self.player:isLastHandCard(slash, true)) then
return "@XiansiSlashCard=.->" .. target:objectName()
end
self:useCardSlash(slash, use)
for _, p in sgs.qlist(use.to) do table.insert(targets, p:objectName()) end
if table.contains(targets, target:objectName()) then return ret .. "->" .. table.concat(targets, "+") end
return "."
end
local useslash, target
local slashes = self:getCards("Slash")
self:sort(self.enemies, "defenseSlash")
for _, slash in ipairs(slashes) do
local no_distance = sgs.Sanguosha:correctCardTarget(sgs.TargetModSkill_DistanceLimit, self.player, slash) > 50 or self.player:hasFlag("slashNoDistanceLimit")
for _, friend in ipairs(self.friends_noself) do
local slash_prohibit = false
slash_prohibit = self:slashProhibit(card, friend)
if not self:hasHeavySlashDamage(self.player, card, friend)
and self.player:canSlash(friend, slash, not no_distance) and not self:slashProhibit(slash, friend)
and self:slashIsEffective(slash, friend)
and (self:findLeijiTarget(friend, 50, self.player)
or (friend:isLord() and self.player:hasSkill("guagu") and friend:getLostHp() >= 1 and getCardsNum("Jink", friend, self.player) == 0)
or (friend:hasSkill("jieming") and self.player:hasSkill("nosrende") and (huatuo and self:isFriend(huatuo))))
and not (self.player:hasFlag("slashTargetFix") and not friend:hasFlag("SlashAssignee"))
and not (slash:isKindOf("XiansiSlashCard") and friend:getPile("counter"):length() < 2) then
useslash = slash
target = friend
break
end
end
end
if not useslash then
for _, slash in ipairs(slashes) do
local no_distance = sgs.Sanguosha:correctCardTarget(sgs.TargetModSkill_DistanceLimit, self.player, slash) > 50 or self.player:hasFlag("slashNoDistanceLimit")
for _, enemy in ipairs(self.enemies) do
if self.player:canSlash(enemy, slash, not no_distance) and not self:slashProhibit(slash, enemy)
and self:slashIsEffective(slash, enemy) and sgs.isGoodTarget(enemy, self.enemies, self)
and not (self.player:hasFlag("slashTargetFix") and not enemy:hasFlag("SlashAssignee")) then
useslash = slash
target = enemy
break
end
end
end
end
if useslash and target then
local targets = {}
local use = { to = sgs.SPlayerList() }
use.to:append(target)
if target:hasSkill("xiansi") and target:getPile("counter"):length() > 1 and not (self:needKongcheng() and self.player:isLastHandCard(slash, true)) then
return "@XiansiSlashCard=.->" .. target:objectName()
end
self:useCardSlash(useslash, use)
for _, p in sgs.qlist(use.to) do table.insert(targets, p:objectName()) end
if table.contains(targets, target:objectName()) then return useslash:toString() .. "->" .. table.concat(targets, "+") end
end
return "."
end
sgs.ai_skill_playerchosen.slash_extra_targets = function(self, targets)
local slash = sgs.Sanguosha:cloneCard("slash")
targets = sgs.QList2Table(targets)
self:sort(targets, "defenseSlash")
for _, target in ipairs(targets) do
if self:isEnemy(target) and not self:slashProhibit(slash, target) and sgs.isGoodTarget(target, targetlist, self) and self:slashIsEffective(slash, target) then
return target
end
end
return nil
end
sgs.ai_skill_playerchosen.zero_card_as_slash = function(self, targets)
local slash = sgs.Sanguosha:cloneCard("slash")
local targetlist = sgs.QList2Table(targets)
local arrBestHp, canAvoidSlash, forbidden = {}, {}, {}
self:sort(targetlist, "defenseSlash")
for _, target in ipairs(targetlist) do
if self:isEnemy(target) and not self:slashProhibit(slash ,target) and sgs.isGoodTarget(target, targetlist, self) then
if self:slashIsEffective(slash, target) then
if self:getDamagedEffects(target, self.player, true) or self:needLeiji(target, self.player) then
table.insert(forbidden, target)
elseif self:needToLoseHp(target, self.player, true, true) then
table.insert(arrBestHp, target)
else
return target
end
else
table.insert(canAvoidSlash, target)
end
end
end
for i=#targetlist, 1, -1 do
local target = targetlist[i]
if not self:slashProhibit(slash, target) then
if self:slashIsEffective(slash, target) then
if self:isFriend(target) and (self:needToLoseHp(target, self.player, true, true)
or self:getDamagedEffects(target, self.player, true) or self:needLeiji(target, self.player)) then
return target
end
else
table.insert(canAvoidSlash, target)
end
end
end
if #canAvoidSlash > 0 then return canAvoidSlash[1] end
if #arrBestHp > 0 then return arrBestHp[1] end
self:sort(targetlist, "defenseSlash")
targetlist = sgs.reverse(targetlist)
for _, target in ipairs(targetlist) do
if target:objectName() ~= self.player:objectName() and not self:isFriend(target) and not table.contains(forbidden, target) then
return target
end
end
return targetlist[1]
end
sgs.ai_card_intention.Slash = function(self, card, from, tos)
if sgs.ai_liuli_effect then
sgs.ai_liuli_effect = false
if sgs.ai_liuli_user then
sgs.updateIntention(from, sgs.ai_liuli_user, 10)
sgs.ai_liuli_user = nil
end
return
end
if sgs.ai_collateral then sgs.ai_collateral = false return end
if card:hasFlag("nosjiefan-slash") then return end
if card:getSkillName() == "mizhao" then return end
for _, to in ipairs(tos) do
local value = 80
speakTrigger(card, from, to)
if to:hasSkills("yiji|qiuyaun") then value = 0 end
if to:hasSkills("nosleiji|leiji") and (getCardsNum("Jink", to, from) > 0 or to:hasArmorEffect("EightDiagram")) and not self:hasHeavySlashDamage(from, card, to)
and (hasExplicitRebel(self.room) or sgs.explicit_renegade) and not self:canLiegong(to, from) then value = 0 end
if not self:hasHeavySlashDamage(from, card, to) and (self:getDamagedEffects(to, from, true) or self:needToLoseHp(to, from, true, true)) then value = 0 end
if from:hasSkill("pojun") and to:getHp() > (2 + self:hasHeavySlashDamage(from, card, to, true)) then value = 0 end
if self:needLeiji(to, from) then value = from:getState() == "online" and 0 or -10 end
sgs.updateIntention(from, to, value)
end
end
sgs.ai_skill_cardask["slash-jink"] = function(self, data, pattern, target)
local isdummy = type(data) == "number"
local function getJink()
if target and target:hasSkill("dahe") and self.player:hasFlag("dahe") then
for _, card in ipairs(self:getCards("Jink")) do
if card:getSuit() == sgs.Card_Heart then return card:getId() end
end
return "."
end
return self:getCardId("Jink") or not isdummy and "."
end
local slash
if type(data) == "userdata" then
local effect = data:toSlashEffect()
slash = effect.slash
else
slash = sgs.Sanguosha:cloneCard("slash")
end
local cards = sgs.QList2Table(self.player:getHandcards())
if (not target or self:isFriend(target)) and slash:hasFlag("nosjiefan-slash") then return "." end
if sgs.ai_skill_cardask.nullfilter(self, data, pattern, target) then return "." end
if not target then return getJink() end
if not self:hasHeavySlashDamage(target, slash, self.player) and self:getDamagedEffects(self.player, target, slash) then return "." end
if slash:isKindOf("NatureSlash") and self.player:isChained() and self:isGoodChainTarget(self.player, target, nil, nil, slash) then return "." end
if self:isFriend(target) then
if self:findLeijiTarget(self.player, 50, target) then return getJink() end
if target:hasSkill("jieyin") and not self.player:isWounded() and self.player:isMale() and not self.player:hasSkills("leiji|nosleiji") then return "." end
if not target:hasSkill("jueqing") then
if (target:hasSkill("nosrende") or (target:hasSkill("rende") and not target:hasUsed("RendeCard"))) and self.player:hasSkill("jieming") then return "." end
if target:hasSkill("pojun") and not self.player:faceUp() then return "." end
end
else
if self:hasHeavySlashDamage(target, slash) then return getJink() end
local current = self.room:getCurrent()
if current and current:hasSkill("juece") and self.player:getHp() > 0 then
local use = false
for _, card in ipairs(self:getCards("Jink")) do
if not self.player:isLastHandCard(card, true) then
use = true
break
end
end
if not use then return not isdummy and "." end
end
if self.player:getHandcardNum() == 1 and self:needKongcheng() then return getJink() end
if not self:hasLoseHandcardEffective() and not self.player:isKongcheng() then return getJink() end
if target:hasSkill("mengjin") and not (target:hasSkill("nosqianxi") and target:distanceTo(self.player) == 1) then
if self:doNotDiscard(self.player, "he", true) then return getJink() end
if self.player:getCards("he"):length() == 1 and not self.player:getArmor() then return getJink() end
if self.player:hasSkills("jijiu|qingnang") and self.player:getCards("he"):length() > 1 then return "." end
if self:canUseJieyuanDecrease(target) then return "." end
if (self:getCardsNum("Peach") > 0 or (self:getCardsNum("Analeptic") > 0 and self:isWeak()))
and not self.player:hasSkills("tuntian+zaoxian") and not self:willSkipPlayPhase() then
return "."
end
end
if self.player:getHp() > 1 and getKnownCard(target, self.player, "Slash") >= 1 and getKnownCard(target, self.player, "Analeptic") >= 1 and self:getCardsNum("Jink") == 1
and (target:getPhase() < sgs.Player_Play or self:slashIsAvailable(target) and target:canSlash(self.player)) then
return "."
end
if not (target:hasSkill("nosqianxi") and target:distanceTo(self.player) == 1) then
if target:hasWeapon("Axe") then
if target:hasSkills(sgs.lose_equip_skill) and target:getEquips():length() > 1 and target:getCards("he"):length() > 2 then return not isdummy and "." end
if target:getHandcardNum() - target:getHp() > 2 and not self:isWeak() and not self:getOverflow() then return not isdummy and "." end
elseif target:hasWeapon("Blade") then
if slash:isKindOf("NatureSlash") and self.player:hasArmorEffect("Vine")
or self.player:hasArmorEffect("RenwangShield")
or self:hasEightDiagramEffect()
or self:hasHeavySlashDamage(target, slash)
or (self.player:getHp() == 1 and #self.friends_noself == 0) then
elseif (self:getCardsNum("Jink") <= getCardsNum("Slash", target, self.player) or self.player:hasSkill("qingnang")) and self.player:getHp() > 1
or self.player:hasSkill("jijiu") and getKnownCard(self.player, self.player, "red") > 0
or self:canUseJieyuanDecrease(target)
then
return not isdummy and "."
end
end
end
end
return getJink()
end
sgs.dynamic_value.damage_card.Slash = true
sgs.ai_use_value.Slash = 4.5
sgs.ai_keep_value.Slash = 3.6
sgs.ai_use_priority.Slash = 2.6
function SmartAI:canHit(to, from, conservative)
from = from or self.room:getCurrent()
to = to or self.player
local jink = sgs.Sanguosha:cloneCard("jink")
if to:isCardLimited(jink, sgs.Card_MethodUse) then return true end
if self:canLiegong(to, from) then return true end
if not self:isFriend(to, from) then
if from:hasWeapon("Axe") and from:getCards("he"):length() > 2 then return true end
if from:hasWeapon("Blade") and getCardsNum("Jink", to, from) <= getCardsNum("Slash", from, from) then return true end
if from:hasSkill("mengjin") and not (from:hasSkill("nosqianxi") and not from:hasSkill("jueqing") and from:distanceTo(to) == 1)
and not self:hasHeavySlashDamage(from, nil, to) and not self:needLeiji(to, from) then
if self:doNotDiscard(to, "he", true) then
elseif to:getCards("he"):length() == 1 and not to:getArmor() then
elseif self:canUseJieyuanDecrease(from, to) then return false
elseif self:willSkipPlayPhase() then
elseif (getCardsNum("Peach", to, from) > 0 or getCardsNum("Analeptic", to, from) > 0) then return true
elseif not self:isWeak(to) and to:getArmor() and not self:needToThrowArmor() then return true
elseif not self:isWeak(to) and to:getDefensiveHorse() then return true
end
end
end
local hasHeart, hasRed, hasBlack
for _, card in ipairs(self:getCards("Jink"), to) do
if card:getSuit() == sgs.Card_Heart then hasHeart = true end
if card:isRed() then hasRed = true end
if card:isBlack() then hasBlack = true end
end
if to:hasFlag("dahe") and not hasHeart then return true end
if to:getMark("@qianxi_red") > 0 and not hasBlack then return true end
if to:getMark("@qianxi_black") > 0 and not hasRed then return true end
if not conservative and self:hasHeavySlashDamage(from, nil, to) then conservative = true end
if not conservative and from:hasSkill("moukui") then conservative = true end
if not conservative and self:hasEightDiagramEffect(to) and not IgnoreArmor(from, to) then return false end
local need_double_jink = from and (from:hasSkill("wushuang")
or (from:hasSkill("roulin") and to:isFemale()) or (from:isFemale() and to:hasSkill("roulin")))
if to:objectName() == self.player:objectName() then
if getCardsNum("Jink", to, from) == 0 then return true end
if need_double_jink and getCardsNum("Jink", to, from) < 2 then return true end
end
if getCardsNum("Jink", to, from) == 0 then return true end
if need_double_jink and getCardsNum("Jink", to, from) < 2 then return true end
return false
end
function SmartAI:useCardPeach(card, use)
local mustusepeach = false
if not self.player:isWounded() then return end
if self.player:hasSkill("yongsi") and self:getCardsNum("Peach") > self:getOverflow(nil, true) then
use.card = card
return
end
if self.player:hasSkill("longhun") and not self.player:isLord() and
math.min(self.player:getMaxCards(), self.player:getHandcardNum()) + self.player:getCards("e"):length() > 3 then return end
local peaches = 0
local cards = self.player:getHandcards()
local lord= getLord(self.player)
cards = sgs.QList2Table(cards)
for _,card in ipairs(cards) do
if isCard("Peach", card, self.player) then peaches = peaches + 1 end
end
if self.player:isLord() and (self.player:hasSkill("hunzi") and self.player:getMark("hunzi") == 0)
and self.player:getHp() < 4 and self.player:getHp() > peaches then return end
if (self.player:hasSkill("nosrende") or (self.player:hasSkill("rende") and not self.player:hasUsed("RendeCard"))) and self:findFriendsByType(sgs.Friend_Draw) then return end
if self.player:hasArmorEffect("SilverLion") then
for _, card in sgs.qlist(self.player:getHandcards()) do
if card:isKindOf("Armor") and self:evaluateArmor(card) > 0 then
use.card = card
return
end
end
end
local SilverLion, OtherArmor
for _, card in sgs.qlist(self.player:getHandcards()) do
if card:isKindOf("SilverLion") then
SilverLion = card
elseif card:isKindOf("Armor") and not card:isKindOf("SilverLion") and self:evaluateArmor(card) > 0 then
OtherArmor = true
end
end
if SilverLion and OtherArmor then
use.card = SilverLion
return
end