forked from Mogara/LuaSkillsForQSGS
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathChapterG.lua
1768 lines (1760 loc) · 59.1 KB
/
ChapterG.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
--[[
代码速查手册(G区)
技能索引:
甘露、感染、刚烈、刚烈、刚烈、刚烈、弓骑、弓骑、攻心、共谋、蛊惑、蛊惑、固守、固政、观星、归命、归汉、归心、归心、闺秀、鬼才、鬼道、国色
]]--
--[[
技能名:甘露
相关武将:一将成名·吴国太
描述:出牌阶段限一次,你可以令装备区的装备牌数量差不超过你已损失体力值的两名角色交换他们装备区的装备牌。。
引用:LuaGanlu
状态:1217验证通过
]]--
swapEquip = function(first, second)
local room = first:getRoom()
local equips1, equips2 = sgs.IntList(), sgs.IntList()
for _, equip in sgs.qlist(first:getEquips()) do
equips1:append(equip:getId())
end
for _, equip in sgs.qlist(second:getEquips()) do
equips2:append(equip:getId())
end
local exchangeMove = sgs.CardsMoveList()
local move1 = sgs.CardsMoveStruct(equips1, second, sgs.Player_PlaceEquip,
sgs.CardMoveReason(sgs.CardMoveReason_S_REASON_SWAP, first:objectName(), second:objectName(), "LuaGanlu", ""))
local move2 = sgs.CardsMoveStruct(equips2, first, sgs.Player_PlaceEquip,
sgs.CardMoveReason(sgs.CardMoveReason_S_REASON_SWAP, first:objectName(), second:objectName(), "LuaGanlu", ""))
exchangeMove:append(move2)
exchangeMove:append(move1)
room:moveCards(exchangeMove, false)
end
LuaGanluCard = sgs.CreateSkillCard{
name = "LuaGanluCard" ,
filter = function(self, targets, to_select)
if #targets == 0 then
return true
elseif #targets == 1 then
local n1 = targets[1]:getEquips():length()
local n2 = to_select:getEquips():length()
return math.abs(n1 - n2) <= sgs.Self:getLostHp()
else
return false
end
end ,
feasible = function(self, targets)
return #targets == 2
end,
on_use = function(self, room, source, targets)
swapEquip(targets[1], targets[2])
end
}
LuaGanlu = sgs.CreateViewAsSkill{
name = "LuaGanlu" ,
n = 0 ,
view_as = function()
return LuaGanluCard:clone()
end ,
enabled_at_play = function(self, player)
return not player:hasUsed("#LuaGanluCard")
end
}
--[[
技能名:感染(锁定技)
相关武将:僵尸·僵尸
描述:你的装备牌都视为铁锁连环。
引用:LuaXGanran
状态:0405验证通过
]]--
LuaGanran = sgs.CreateFilterSkill{
name = "LuaGanran",
view_filter = function(self, to_select)
local room = sgs.Sanguosha:currentRoom()
local place = room:getCardPlace(to_select:getEffectiveId())
return place == sgs.Player_PlaceHand and to_select:getTypeId() == sgs.Card_TypeEquip
end,
view_as = function(self, card)
local ironchain = sgs.Sanguosha:cloneCard("iron_chain", card:getSuit(), card:getNumber())
ironchain:setSkillName(self:objectName())
local vs_card = sgs.Sanguosha:getWrappedCard(card:getEffectiveId())
vs_card:takeOver(ironchain)
return vs_card
end,
}
--[[
技能名:刚烈
相关武将:界限突破·夏侯惇
描述:每当你受到1点伤害后,你可以进行判定:若结果为红色,你对伤害来源造成1点伤害;黑色,你弃置伤害来源一张牌。
引用:LuaGanglie
状态:0405验证通过
]]--
LuaGanglie = sgs.CreateTriggerSkill{
name = "LuaGanglie",
events = {sgs.Damaged, sgs.FinishJudge},
can_trigger = function(self, target)
return target
end,
on_trigger = function(self, event, player, data)
local room = player:getRoom()
if event == sgs.Damaged and player:isAlive() and player:hasSkill(self:objectName()) then
local damage = data:toDamage()
local from = damage.from
for i = 0, damage.damage - 1, 1 do
if room:askForSkillInvoke(player, self:objectName(), data) then
local judge = sgs.JudgeStruct()
judge.pattern = "."
judge.play_animation = false
judge.reason = self:objectName()
judge.who = player
room:judge(judge)
if (not from) or from:isDead() then return end
if judge.card:isRed() then
room:damage(sgs.DamageStruct(self:objectName(), player, from))
elseif judge.card:isBlack() then
if player:canDiscard(from, "he") then
local id = room:askForCardChosen(player, from, "he", self:objectName(), false, sgs.Card_MethodDiscard)
room:throwCard(id, from, player)
end
end
end
end
elseif event == sgs.FinishJudge then
local judge = sgs.JudgeStruct()
if judge.reason ~= self:objectName() then return false end
judge.pattern = tostring(judge.card:getSuit())
end
return false
end
}
--[[
技能名:刚烈
相关武将:标准·夏侯惇
描述:每当你受到伤害后,你可以进行判定:若结果不为♥,则伤害来源选择一项:弃置两张手牌,或受到1点伤害。
引用:LuaNosGanglie
状态:0405验证通过
]]--
LuaNosGanglie = sgs.CreateMasochismSkill{
name = "LuaNosGanglie" ,
on_damaged = function(self, player, damage)
local from = damage.from
local room = player:getRoom()
local data = sgs.QVariant()
data:setValue(damage)
if room:askForSkillInvoke(player, self:objectName(), data) then
local judge = sgs.JudgeStruct()
judge.pattern = ".|heart"
judge.good = false
judge.reason = self:objectName()
judge.who = player
room:judge(judge)
if (not from) or from:isDead() then return end
if judge:isGood() then
if from:getHandcardNum() < 2 or not room:askForDiscard(from, self:objectName(), 2, 2, true) then
room:damage(sgs.DamageStruct(self:objectName(), player, from))
end
end
end
end
}
--[[
技能名:刚烈
相关武将:2013-3v3·夏侯惇
描述: 每当你受到伤害后,你可以选择一名对方角色并进行一次判定,若判定结果不为♥,则该角色选择一项:弃置两张手牌,或受到你造成的1点伤害。
引用:LuaVsGanglie
状态:1217验证通过
]]--
LuaVsGanglie = sgs.CreateMasochismSkill{
name = "LuaVsGanglie",
on_damaged = function(self,player)
local room = player:getRoom()
local mode = room:getMode()
local function isFriend (a,b)
return string.sub(a:getRole(),1,1) == string.sub(b:getRole(),1,1)
end
if mode:startsWith("06_") then
local enemies = sgs.SPlayerList()
for _,p in sgs.qlist(room:getAlivePlayers())do
if not isFriend(player,p) then
enemies:append(p)
end
end
local from = room:askForPlayerChosen(player,enemies,self:objectName(),"vsganglie-invoke", true, true)
if from then
local judge = sgs.JudgeStruct()
judge.pattern = ".|heart"
judge.good = false
judge.reason = self:objectName()
judge.who = player
room:judge(judge)
if judge:isGood() then
if from:getHandcardNum() < 2 then
room:damage(sgs.DamageStruct(self:objectName(), player, from))
else
if not room:askForDiscard(from, self:objectName(), 2, 2, true) then
room:damage(sgs.DamageStruct(self:objectName(), player, from))
end
end
end
end
end
return false
end
}
--[[
技能名:刚烈
相关武将:翼·夏侯惇
描述:每当你受到一次伤害后,你可以进行一次判定,若判定结果不为红桃,你选择一项:令伤害来源弃置两张手牌,或受到你对其造成的1点伤害。
引用:LuaXNeoGanglie
状态:1217验证通过
]]--
LuaXNeoGanglie = sgs.CreateTriggerSkill{
name = "LuaXNeoGanglie",
frequency = sgs.Skill_NotFrequent,
events = {sgs.Damaged},
on_trigger = function(self, event, player, data)
local room = player:getRoom()
local damage = data:toDamage()
local from = damage.from
local ai_data = sgs.QVariant()
ai_data:setValue(from)
if from and from:isAlive() then
if room:askForSkillInvoke(player, self:objectName(), ai_data) then
local judge = sgs.JudgeStruct()
judge.pattern = ".|heart"
judge.good = false
judge.reason = self:objectName()
judge.who = player
room:judge(judge)
if judge:isGood() then
local choicelist = "damage"
local flag = false
if from:getHandcardNum() > 1 then
choicelist = "damage+throw"
flag = true
end
local choice
if flag then
choice = room:askForChoice(player, self:objectName(), choicelist)
else
choice = choicelist
end
if choice == "damage" then
local damage = sgs.DamageStruct()
damage.from = player
damage.to = from
room:setEmotion(player, "good")
room:damage(damage)
else
room:askForDiscard(from, self:objectName(), 2, 2)
end
else
room:setEmotion(player, "bad")
end
end
end
end
}
--[[
技能名:弓骑
相关武将:一将成名2012·韩当
描述:出牌阶段限一次,你可以弃置一张牌,令你于此回合内攻击范围无限,若你以此法弃置的牌为装备牌,你可以弃置一名其他角色的一张牌。
引用:LuaGongqi
状态:1217验证通过
]]--
LuaGongqiCard = sgs.CreateSkillCard{
name = "LuaGongqiCard" ,
target_fixed = true ,
on_use = function(self, room, source, targets)
room:setPlayerFlag(source,"InfinityAttackRange")
local cd = sgs.Sanguosha:getCard(self:getSubcards():first())
if cd:isKindOf("EquipCard") then
local _targets = sgs.SPlayerList()
for _, p in sgs.qlist(room:getOtherPlayers(source)) do
if source:canDiscard(p, "he") then _targets:append(p) end
end
if not _targets:isEmpty() then
local to_discard = room:askForPlayerChosen(source, _targets, "LuaGongqi", "@gongqi-discard", true)
if to_discard then
room:throwCard(room:askForCardChosen(source, to_discard, "he", "LuaGongqi", false, sgs.Card_MethodDiscard), to_discard, source)
end
end
end
end
}
LuaGongqi = sgs.CreateViewAsSkill{
name = "LuaGongqi" ,
n = 1 ,
view_filter = function(self, cards, to_select)
return not sgs.Self:isJilei(to_select)
end ,
view_as = function(self, cards)
if #cards ~= 1 then return nil end
local card = LuaGongqiCard:clone()
card:addSubcard(cards[1])
card:setSkillName(self:objectName())
return card
end ,
enabled_at_play = function(self, player)
return not player:hasUsed("#LuaGongqiCard")
end
}
--[[
技能名:弓骑
相关武将:怀旧·韩当
描述:你可以将一张装备牌当【杀】使用或打出。你以此法使用的【杀】无距离限制。
引用:LuaNosGongqi、LuaNosGongqiTargetMod
状态:1217验证通过
]]--
LuaNosGongqi = sgs.CreateViewAsSkill{
name = "LuaNosGongqi" ,
n = 1 ,
view_filter = function(self, selected, to_select)
if to_select:getTypeId() ~= sgs.Card_TypeEquip then return false end
if sgs.Sanguosha:getCurrentCardUseReason() == sgs.CardUseStruct_CARD_USE_REASON_PLAY then
local slash = sgs.Sanguosha:cloneCard("slash", sgs.Card_SuitToBeDecided, -1)
slash:addSubcard(to_select:getEffectiveId())
slash:deleteLater()
return slash:isAvailable(sgs.Self)
end
return true
end ,
view_as = function(self, cards)
if #cards == 1 then
local slash = sgs.Sanguosha:cloneCard("slash", cards[1]:getSuit(), cards[1]:getNumber())
slash:addSubcard(cards[1])
slash:setSkillName(self:objectName())
return slash
end
end ,
enabled_at_play = function(self, player)
return sgs.Slash_IsAvailable(player)
end ,
enabled_at_response = function(self, player, pattern)
return pattern == "slash"
end
}
LuaNosGongqiTargetMod = sgs.CreateTargetModSkill{
name = "#LuaNosGongqi-target" ,
distance_limit_func = function(self, player, card)
if card:getSkillName() == "LuaNosGongqi" then
return 1000
else
return 0
end
end
}
--[[
技能名:攻心
相关武将:神·吕蒙,界·吕蒙
描述:出牌阶段限一次,你可以观看一名其他角色的手牌,然后选择其中一张♥牌并选择一项:弃置之,或将之置于牌堆顶。
引用:LuaGongxin
状态:0405验证通过
]]--
LuaGongxinCard = sgs.CreateSkillCard{
name = "LuaGongxinCard" ,
filter = function(self, targets, to_select)
return #targets == 0 and to_select:objectName() ~= sgs.Self:objectName() --and not to_select:isKongcheng() 如果不想选择没有手牌的角色就加上这一句,源码是没有这句的
end ,
on_effect = function(self, effect)
local room = effect.from:getRoom()
if not effect.to:isKongcheng() then--如果加上了上面的那句,这句和对应的end可以删除
local ids = sgs.IntList()
for _, card in sgs.qlist(effect.to:getHandcards()) do
if card:getSuit() == sgs.Card_Heart then
ids:append(card:getEffectiveId())
end
end
local card_id = room:doGongxin(effect.from, effect.to, ids)
if (card_id == -1) then return end
local result = room:askForChoice(effect.from, "LuaGongxin", "discard+put")
effect.from:removeTag("LuaGongxin")
if result == "discard" then
local reason = sgs.CardMoveReason(sgs.CardMoveReason_S_REASON_DISMANTLE, effect.from:objectName(), nil, "LuaGongxin", nil)
room:throwCard(sgs.Sanguosha:getCard(card_id), reason, effect.to, effect.from)
else
effect.from:setFlags("Global_GongxinOperator")
local reason = sgs.CardMoveReason(sgs.CardMoveReason_S_REASON_PUT, effect.from:objectName(), nil, "LuaGongxin", nil)
room:moveCardTo(sgs.Sanguosha:getCard(card_id), effect.to, nil, sgs.Player_DrawPile, reason, true)
effect.from:setFlags("-Global_GongxinOperator")
end
end
end
}
LuaGongxin = sgs.CreateZeroCardViewAsSkill{
name = "LuaGongxin" ,
view_as = function()
return LuaGongxinCard:clone()
end ,
enabled_at_play = function(self, target)
return not target:hasUsed("#LuaGongxinCard")
end
}
--[[
技能名:共谋
相关武将:倚天·钟士季
描述:回合结束阶段开始时,你可指定一名其他角色:其在摸牌阶段摸牌后,须给你X张手牌(X为你手牌数与对方手牌数的较小值),然后你须选择X张手牌交给对方
引用:LuaXGongmou、LuaXGongmouExchange
状态:1217验证通过
]]--
LuaXGongmou = sgs.CreateTriggerSkill{
name = "LuaXGongmou",
frequency = sgs.Skill_NotFrequent,
events = {sgs.EventPhaseStart},
on_trigger = function(self, event, player, data)
local room = player:getRoom()
local phase = player:getPhase()
if phase == sgs.Player_Finish then
if player:askForSkillInvoke(self:objectName()) then
local players = room:getOtherPlayers(player)
local target = room:askForPlayerChosen(player, players, self:objectName())
target:gainMark("@conspiracy")
end
elseif phase == sgs.Player_Start then
local players = room:getOtherPlayers(player)
for _,p in sgs.qlist(players) do
if p:getMark("@conspiracy") > 0 then
p:loseMark("@conspiracy")
end
end
end
return false
end
}
LuaXGongmouExchange = sgs.CreateTriggerSkill{
name = "#LuaXGongmouExchange",
frequency = sgs.Skill_Frequent,
events = {sgs.EventPhaseStart},
on_trigger = function(self, event, player, data)
if player:getPhase() == sgs.Player_Draw then
player:loseMark("@conspiracy")
local room = player:getRoom()
local source = room:findPlayerBySkillName("LuaXGongmou")
if source then
local thisCount = player:getHandcardNum()
local thatCount = source:getHandcardNum()
local x = math.min(thatCount, thisCount)
if x > 0 then
local to_exchange = nil
if thisCount == x then
to_exchange = player:wholeHandCards()
else
to_exchange = room:askForExchange(player, "LuaXGongmou", x)
end
room:moveCardTo(to_exchange, source, sgs.Player_PlaceHand, false)
to_exchange = room:askForExchange(source, "LuaXGongmou", x)
room:moveCardTo(to_exchange, player, sgs.Player_PlaceHand, false)
end
end
end
return false
end,
can_trigger = function(self, target)
if target then
return target:getMark("@conspiracy") > 0
end
return false
end,
priority = -2
}
--[[
技能名:蛊惑
相关武将:风·于吉
描述:你可以扣置一张手牌当做一张基本牌或非延时锦囊牌使用或打出,其他角色选择是否质疑:若无角色质疑,你展示该牌,取消不合法的目标并按你所述类型结算;若有角色质疑,中止质疑询问并展示该牌:若该牌为真,该角色获得“缠怨”(锁定技。你不能质疑“蛊惑”。若你的体力值为1,你的其他武将技能无效。),取消不合法的目标并按你所述类型结算;若该牌为假,你将其置入弃牌堆。每名角色的回合限一次。
引用:guhuo_new
状态:0405验证通过(需配合本手册的缠怨一起使用)不知是否还有隐藏的问题
]]--
function guhuo(self, yuji)
local room = yuji:getRoom()
local players = room:getOtherPlayers(yuji)
local used_cards = sgs.IntList()
local moves = sgs.CardsMoveList()
for _, card_id in sgs.qlist(self:getSubcards()) do
used_cards:append(card_id)
end
--room:setTag("GuhuoType", self:getUserString())
local questioned = nil
for _, player in sgs.qlist(players) do
if player:hasSkill("LuaChanyuan") then
room:notifySkillInvoked(player, "LuaChanyuan")
room:setEmotion(player, "no-question")
continue
end
local choice = room:askForChoice(player, "LuaGuhuo", "noquestion+question")
if choice == "question" then
room:setEmotion(player, "question")
else
room:setEmotion(player, "no-question")
end
if choice == "question" then
questioned = player
break
end
end
local success = false
if not questioned then
success = true
for _, player in sgs.qlist(players) do
room:setEmotion(player, ".")
end
local reason = sgs.CardMoveReason(sgs.CardMoveReason_S_REASON_USE, yuji:objectName(), "", "LuaGuhuo")
local move = sgs.CardsMoveStruct(used_cards, yuji, nil, sgs.Player_PlaceUnknown, sgs.Player_PlaceTable, reason)
moves:append(move)
room:moveCardsAtomic(moves, true)
else
local card = sgs.Sanguosha:getCard(self:getSubcards():first())
if self:getUserString() and self:getUserString() == "peach+analeptic" then
success = card:objectName() == yuji:getTag("GuhuoSaveSelf"):toString()
elseif self:getUserString() and self:getUserString() == "slash" then
success = string.find(card:objectName(),"slash")
elseif self:getUserString() and self:getUserString() == "normal_slash" then
success = card:objectName() == "slash"
else
success = card:match(self:getUserString())
end
if success then
local reason = sgs.CardMoveReason(sgs.CardMoveReason_S_REASON_USE, yuji:objectName(), "", "LuaGuhuo")
local move = sgs.CardsMoveStruct(used_cards, yuji, nil, sgs.Player_PlaceUnknown, sgs.Player_PlaceTable, reason)
moves:append(move)
room:moveCardsAtomic(moves, true)
else
room:moveCardTo(self, yuji, nil, sgs.Player_DiscardPile, sgs.CardMoveReason(sgs.CardMoveReason_S_REASON_PUT, yuji:objectName(), "", "LuaGuhuo"), true)
end
for _, player in sgs.qlist(players) do
room:setEmotion(player, ".")
if success and questioned:objectName() == player:objectName() then
room:acquireSkill(questioned, "LuaChanyuan")
end
end
end
yuji:removeTag("GuhuoSaveSelf")
yuji:removeTag("GuhuoSlash")
room:setPlayerFlag(yuji, "GuhuoUsed")
return success
end
LuaGuhuoCard = sgs.CreateSkillCard {
name = "LuaGuhuoCard",
will_throw = false,
handling_method = sgs.Card_MethodNone,
filter = function(self, targets, to_select)
local players = sgs.PlayerList()
for i = 1 , #targets do
players:append(targets[i])
end
if sgs.Sanguosha:getCurrentCardUseReason() == sgs.CardUseStruct_CARD_USE_REASON_RESPONSE_USE then
local card = nil
if self:getUserString() and self:getUserString() ~= "" then
card = sgs.Sanguosha:cloneCard(self:getUserString():split("+")[1])
return card and card:targetFilter(players, to_select, sgs.Self) and not sgs.Self:isProhibited(to_select, card, players)
end
elseif sgs.Sanguosha:getCurrentCardUseReason() == sgs.CardUseStruct_CARD_USE_REASON_RESPONSE then
return false
end
local _card = sgs.Self:getTag("LuaGuhuo"):toCard()
if _card == nil then
return false
end
local card = sgs.Sanguosha:cloneCard(_card)
card:setCanRecast(false)
card:deleteLater()
return card and card:targetFilter(players, to_select, sgs.Self) and not sgs.Self:isProhibited(to_select, card, players)
end ,
feasible = function(self, targets)
local players = sgs.PlayerList()
for i = 1 , #targets do
players:append(targets[i])
end
if sgs.Sanguosha:getCurrentCardUseReason() == sgs.CardUseStruct_CARD_USE_REASON_RESPONSE_USE then
local card = nil
if self:getUserString() and self:getUserString() ~= "" then
card = sgs.Sanguosha:cloneCard(self:getUserString():split("+")[1])
return card and card:targetsFeasible(players, sgs.Self)
end
elseif sgs.Sanguosha:getCurrentCardUseReason() == sgs.CardUseStruct_CARD_USE_REASON_RESPONSE then
return true
end
local _card = sgs.Self:getTag("LuaGuhuo"):toCard()
if _card == nil then
return false
end
local card = sgs.Sanguosha:cloneCard(_card)
card:setCanRecast(false)
card:deleteLater()
return card and card:targetsFeasible(players, sgs.Self)
end ,
on_validate = function(self, card_use)
local yuji = card_use.from
local room = yuji:getRoom()
local to_guhuo = self:getUserString()
if to_guhuo == "slash" and sgs.Sanguosha:getCurrentCardUseReason() == sgs.CardUseStruct_CARD_USE_REASON_RESPONSE_USE then
local guhuo_list = {}
table.insert(guhuo_list, "slash")
local sts = sgs.GetConfig("BanPackages", "")
if not string.find(sts, "maneuvering") then
table.insert(guhuo_list, "normal_slash")
table.insert(guhuo_list, "thunder_slash")
table.insert(guhuo_list, "fire_slash")
end
to_guhuo = room:askForChoice(yuji, "guhuo_slash", table.concat(guhuo_list, "+"))
yuji:setTag("GuhuoSlash", sgs.QVariant(to_guhuo))
end
if guhuo(self, yuji) then
local card = sgs.Sanguosha:getCard(self:getSubcards():first())
local user_str = ""
if to_guhuo == "slash" then
if card:isKindOf("Slash") then
user_str = card:objectName()
else
user_str = "slash"
end
elseif to_guhuo == "normal_slash" then
user_str = "slash"
else
user_str = to_guhuo
end
--yuji:setTag("GuhuoSlash", sgs.QVariant(user_str))
local use_card = sgs.Sanguosha:cloneCard(user_str, card:getSuit(), card:getNumber())
use_card:setSkillName("LuaGuhuo")
use_card:addSubcard(self:getSubcards():first())
use_card:deleteLater()
local tos = card_use.to
for _, to in sgs.qlist(tos) do
local skill = room:isProhibited(yuji, to, use_card)
if skill then
card_use.to:removeOne(to)
end
end
return use_card
else
return nil
end
end ,
on_validate_in_response = function(self, yuji)
local room = yuji:getRoom()
local to_guhuo = ""
if self:getUserString() == "peach+analeptic" then
local guhuo_list = {}
table.insert(guhuo_list, "peach")
local sts = sgs.GetConfig("BanPackages", "")
if not string.find(sts, "maneuvering") then
table.insert(guhuo_list, "analeptic")
end
to_guhuo = room:askForChoice(yuji, "guhuo_saveself", table.concat(guhuo_list, "+"))
yuji:setTag("GuhuoSaveSelf", sgs.QVariant(to_guhuo))
elseif self:getUserString() == "slash" then
local guhuo_list = {}
table.insert(guhuo_list, "slash")
local sts = sgs.GetConfig("BanPackages", "")
if not string.find(sts, "maneuvering") then
table.insert(guhuo_list, "normal_slash")
table.insert(guhuo_list, "thunder_slash")
table.insert(guhuo_list, "fire_slash")
end
to_guhuo = room:askForChoice(yuji, "guhuo_slash", table.concat(guhuo_list, "+"))
yuji:setTag("GuhuoSlash", sgs.QVariant(to_guhuo))
else
to_guhuo = self:getUserString()
end
if guhuo(self, yuji) then
local card = sgs.Sanguosha:getCard(self:getSubcards():first())
local user_str = ""
if to_guhuo == "slash" then
if card:isKindOf("Slash") then
user_str = card:objectName()
else
user_str = "slash"
end
elseif to_guhuo == "normal_slash" then
user_str = "slash"
else
user_str = to_guhuo
end
local use_card = sgs.Sanguosha:cloneCard(user_str, card:getSuit(), card:getNumber())
use_card:setSkillName("LuaGuhuo")
use_card:addSubcard(self)
use_card:deleteLater()
return use_card
else
return nil
end
end
}
LuaGuhuo = sgs.CreateOneCardViewAsSkill{
name = "LuaGuhuo",
filter_pattern = ".|.|.|hand",
response_or_use = true,
enabled_at_response = function(self, player, pattern)
local current = false
local players = player:getAliveSiblings()
players:append(player)
for _, p in sgs.qlist(players) do
if p:getPhase() ~= sgs.Player_NotActive then
current = true
break
end
end
if not current then return false end
if player:isKongcheng() or player:hasFlag("GuhuoUsed") or string.sub(pattern, 1, 1) == "." or string.sub(pattern, 1, 1) == "@" then
return false
end
if pattern == "peach" and player:getMark("Global_PreventPeach") > 0 then return false end
if string.find(pattern, "[%u%d]") then return false end--这是个极其肮脏的黑客!! 因此我们需要去阻止基本牌模式
return true
end,
enabled_at_play = function(self, player)
local current = false
local players = player:getAliveSiblings()
players:append(player)
for _, p in sgs.qlist(players) do
if p:getPhase() ~= sgs.Player_NotActive then
current = true
break
end
end
if not current then return false end
return not player:isKongcheng() and not player:hasFlag("GuhuoUsed")
end,
view_as = function(self, cards)
if sgs.Sanguosha:getCurrentCardUseReason() == sgs.CardUseStruct_CARD_USE_REASON_RESPONSE or sgs.Sanguosha:getCurrentCardUseReason() == sgs.CardUseStruct_CARD_USE_REASON_RESPONSE_USE then
local card = LuaGuhuoCard:clone()
card:setUserString(sgs.Sanguosha:getCurrentCardUsePattern())
card:addSubcard(cards)
return card
end
local c = sgs.Self:getTag("LuaGuhuo"):toCard()
if c then
local card = LuaGuhuoCard:clone()
if not string.find(c:objectName(), "slash") then
card:setUserString(c:objectName())
else
card:setUserString(sgs.Self:getTag("GuhuoSlash"):toString())
card:setTargetFixed(c:targetFixed() or sgs.Sanguosha:getCurrentCardUseReason() == sgs.CardUseStruct_CARD_USE_REASON_RESPONSE)
end
card:addSubcard(cards)
return card
else
return nil
end
end,
enabled_at_nullification = function(self, player)
local current = player:getRoom():getCurrent()
if not current or current:isDead() or current:getPhase() == sgs.Player_NotActive then return false end
return not player:isKongcheng() and not player:hasFlag("GuhuoUsed")
end
}
LuaGuhuo:setGuhuoDialog("lr")
LuaGuhuoClear = sgs.CreateTriggerSkill{
name = "#LuaGuhuo-clear" ,
events = {sgs.EventPhaseChanging} ,
can_trigger = function(self, target)
return target
end ,
on_trigger = function(self, event, player, data)
local change = data:toPhaseChange()
local room = player:getRoom()
if change.to == sgs.Player_NotActive then
for _, p in sgs.qlist(room:getAlivePlayers()) do
if p:hasFlag("GuhuoUsed") then
room:setPlayerFlag(p, "-GuhuoUsed")
end
end
end
return false
end
}
--[[
技能名:蛊惑
相关武将:怀旧·于吉
描述:你可以说出一张基本牌或非延时类锦囊牌的名称,并背面朝上使用或打出一张手牌。若无其他角色质疑,则亮出此牌并按你所述之牌结算。若有其他角色质疑则亮出验明:若为真,质疑者各失去1点体力;若为假,质疑者各摸一张牌。除非被质疑的牌为红桃且为真,此牌仍然进行结算,否则无论真假,将此牌置入弃牌堆。
引用:LuaNosguhuo
状态:1217验证通过
]]--
function Set(list)
local set = {}
for _, l in ipairs(list) do set[l] = true end
return set
end
local patterns = {"slash", "jink", "peach", "analeptic", "nullification", "snatch", "dismantlement", "collateral", "ex_nihilo", "duel", "fire_attack", "amazing_grace", "savage_assault", "archery_attack", "god_salvation", "iron_chain"}
if not (Set(sgs.Sanguosha:getBanPackages()))["maneuvering"] then
table.insert(patterns, 2, "thunder_slash")
table.insert(patterns, 2, "fire_slash")
table.insert(patterns, 2, "normal_slash")
end
local slash_patterns = {"slash", "normal_slash", "thunder_slash", "fire_slash"}
function getPos(table, value)
for i, v in ipairs(table) do
if v == value then
return i
end
end
return 0
end
local pos = 0
guhuo_select = sgs.CreateSkillCard {
name = "guhuo_select",
will_throw = false,
handling_method = sgs.Card_MethodNone,
target_fixed = true,
mute = true,
on_use = function(self, room, source, targets)
local type = {}
local basic = {}
local sttrick = {}
local mttrick = {}
for _, cd in ipairs(patterns) do
local card = sgs.Sanguosha:cloneCard(cd, sgs.Card_NoSuit, 0)
if card then
card:deleteLater()
if card:isAvailable(source) then
if card:getTypeId() == sgs.Card_TypeBasic then
table.insert(basic, cd)
elseif card:isKindOf("SingleTargetTrick") then
table.insert(sttrick, cd)
else
table.insert(mttrick, cd)
end
if cd == "slash" then
table.insert(basic, "normal_slash")
end
end
end
end
if #basic ~= 0 then table.insert(type, "basic") end
if #sttrick ~= 0 then table.insert(type, "single_target_trick") end
if #mttrick ~= 0 then table.insert(type, "multiple_target_trick") end
local typechoice = ""
if #type > 0 then
typechoice = room:askForChoice(source, "LuaNosguhuo", table.concat(type, "+"))
end
local choices = {}
if typechoice == "basic" then
choices = table.copyFrom(basic)
elseif typechoice == "single_target_trick" then
choices = table.copyFrom(sttrick)
elseif typechoice == "multiple_target_trick" then
choices = table.copyFrom(mttrick)
end
local pattern = room:askForChoice(source, "guhuo-new", table.concat(choices, "+"))
if pattern then
if string.sub(pattern, -5, -1) == "slash" then
pos = getPos(slash_patterns, pattern)
room:setPlayerMark(source, "GuhuoSlashPos", pos)
end
pos = getPos(patterns, pattern)
room:setPlayerMark(source, "GuhuoPos", pos)
room:askForUseCard(source, "@LuaNosguhuo", "@@LuaNosguhuo")
end
end,
}
function questionOrNot(player)
local room = player:getRoom()
local yuji = room:findPlayerBySkillName("LuaNosguhuo")
local guhuoname = room:getTag("GuhuoType"):toString()
if guhuoname == "peach+analeptic" then guhuoname = "peach" end
if guhuoname == "normal_slash" then guhuoname = "slash" end
local guhuocard = sgs.Sanguosha:cloneCard(guhuoname, sgs.Card_NoSuit, 0)
local guhuotype = guhuocard:getClassName()
if guhuotype and guhuotype == "AmazingGrace" then return "noquestion" end
if guhuotype:match("Slash") then
if yuji:getState() ~= "robot" and math.random(1, 4) == 1 and not sgs.questioner then return "question" end
end
if math.random(1, 6) == 1 and player:getHp() >= 3 and player:getHp() > player:getLostHp() then return "question" end
local players = room:getOtherPlayers(player)
players = sgs.QList2Table(players)
local x = math.random(1, 5)
if sgs.questioner then return "noquestion" end
local questioner = room:getOtherPlayers(player):at(0)
return player:objectName() == questioner:objectName() and x ~= 1 and "question" or "noquestion"
end
function guhuo(self, yuji)
local room = yuji:getRoom()
local players = room:getOtherPlayers(yuji)
local used_cards = sgs.IntList()
local moves = sgs.CardsMoveList()
for _, card_id in sgs.qlist(self:getSubcards()) do
used_cards:append(card_id)
end
local questioned = sgs.SPlayerList()
for _, p in sgs.qlist(players) do
if p:hasSkill("LuaChanyuan") then
local log = sgs.LogMessage()
log.type = "#LuaChanyuan"
log.from = yuji
log.to:append(p)
log.arg = "LuaChanyuan"
room:sendLog(log)
room:notifySkillInvoked(p, "LuaChanyuan")
room:setEmotion(p, "no-question")
else
local choice = "noquestion"
if p:getState() == "online" then
choice = room:askForChoice(p, "guhuo", "noquestion+question")
else
room:getThread():delay(sgs.GetConfig("OriginAIDelay", ""))
choice = questionOrNot(p)
end
if choice == "question" then
sgs.questioner = p
room:setEmotion(p, "question")
questioned:append(p)
else
room:setEmotion(p, "no-question")
end
local log = sgs.LogMessage()
log.type = "#GuhuoQuery"
log.from = p
log.arg = choice
room:sendLog(log)
end
end
room:removeTag("GuhuoType")
local log = sgs.LogMessage()
log.type = "$GuhuoResult"
log.from = yuji
local subcards = self:getSubcards()
log.card_str = tostring(subcards:first())
room:sendLog(log)
local success = false
local canuse = false
if questioned:isEmpty() then
canuse = true
for _, p in sgs.qlist(players) do
room:setEmotion(p, ".")
end
local reason = sgs.CardMoveReason(sgs.CardMoveReason_S_REASON_USE, yuji:objectName(), "", "guhuo")
local move = sgs.CardsMoveStruct()
move.card_ids = used_cards
move.from = yuji
move.to = nil
move.to_place = sgs.Player_PlaceTable
move.reason = reason
moves:append(move)
room:moveCardsAtomic(moves, true)
else
local card = sgs.Sanguosha:getCard(subcards:first())
local user_string = self:getUserString()
if user_string == "peach+analeptic" then
success = card:objectName() == yuji:getTag("GuhuoSaveSelf"):toString()
elseif user_string == "slash" then
success = string.sub(card:objectName(), -5, -1) == "slash"
elseif user_string == "normal_slash" then
success = card:objectName() == "slash"
else
success = card:match(user_string)
end
if success then
for _, p in sgs.qlist(questioned) do
room:loseHp(p)
end
else
for _, p in sgs.qlist(questioned) do
if p:isAlive() then
p:drawCards(1)
end
end
end
if success and card:getSuit() == sgs.Card_Heart then canuse = true end
if canuse then
local reason = sgs.CardMoveReason(sgs.CardMoveReason_S_REASON_USE, yuji:objectName(), "", "guhuo")
local move = sgs.CardsMoveStruct()
move.card_ids = used_cards
move.from = yuji
move.to = nil
move.to_place = sgs.Player_PlaceTable
move.reason = reason
moves:append(move)
room:moveCardsAtomic(moves, true)
else
room:moveCardTo(self, yuji, nil, sgs.Player_DiscardPile, sgs.CardMoveReason(sgs.CardMoveReason_S_REASON_PUT, yuji:objectName(), "", "guhuo"), true)
end
for _, p in sgs.qlist(players) do
room:setEmotion(p, ".")
end
end
yuji:removeTag("GuhuoSaveSelf")
return canuse
end
LuaNosguhuoCard = sgs.CreateSkillCard {
name = "LuaNosguhuo",
will_throw = false,
handling_method = sgs.Card_MethodNone,
player = nil,
on_use = function(self, room, source)
player = source
end,
filter = function(self, targets, to_select, player)
if sgs.Sanguosha:getCurrentCardUseReason() == sgs.CardUseStruct_CARD_USE_REASON_RESPONSE_USE and sgs.Sanguosha:getCurrentCardUsePattern() ~= "@LuaNosguhuo" then
local card = nil
if self:getUserString() ~= "" then
card = sgs.Sanguosha:cloneCard(self:getUserString():split("+")[1])
card:setSkillName("guhuo")
end
if card and card:targetFixed() then
return false
end
local qtargets = sgs.PlayerList()
for _, p in ipairs(targets) do
qtargets:append(p)
end
return card and card:targetFilter(qtargets, to_select, sgs.Self) and not sgs.Self:isProhibited(to_select, card, qtargets)