-
Notifications
You must be signed in to change notification settings - Fork 59
/
ChapterH.lua
1517 lines (1495 loc) · 49.6 KB
/
ChapterH.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
--[[
代码速查手册(H区)
技能索引:
汉统、好施、鹤翼、横江、弘援、弘援、红颜、后援、胡笳、虎威、虎啸、护驾、护援、化身、怀异、缓释、缓释、皇恩、黄天、挥泪、魂姿、火计、祸首、祸水、恢拓
]]--
--[[
技能名:汉统
相关武将:贴纸·刘协
描述:弃牌阶段,你可以将你弃置的手牌置于武将牌上,称为“诏”。你可以将一张“诏”置入弃牌堆,然后你拥有并发动以下技能之一:“护驾”、“激将”、“救援”、“血裔”,直到当前回合结束。
引用:LuaXHantong、LuaXHantongDetach
状态:1217验证通过
]]--
function hasShuGenerals(player)
for _,p in sgs.qlist(player:getAliveSiblings()) do
if p:getKingdom() == "shu" then
return true
end
end
return false
end
LuaXHantongRemove = function(player)
local room = player:getRoom()
local card_ids = player:getPile("pile")
room:fillAG(card_ids,player)
local card_id = room:askForAG(player, card_ids, false, "LuaXHantong")
room:clearAG(player)
if card_id == -1 then return false end
card_ids:removeOne(card_id)
local reason = sgs.CardMoveReason(sgs.CardMoveReason_S_REASON_REMOVE_FROM_PILE, "", "LuaXHantong", "")
local card = sgs.Sanguosha:getCard(card_id)
room:throwCard(card, reason, nil)
player:setTag("LuaXHantong",sgs.QVariant(true))
return true
end
LuaXHantongCard = sgs.CreateSkillCard{
name = "LuaXHantongCard",
target_fixed = true,
on_validate = function(self,card_use)
local source = card_use.from
local room = source:getRoom()
card_use.m_isOwnerUse = false;
if not LuaXHantongRemove(source) then return false end
room:acquireSkill(source, "jijiang");
if not room:askForUseCard(source, "@jijiang", "@hantong-jijiang")then
room:setPlayerFlag(source, "Global_JijiangFailed");
return nil
end
return self
end,
on_use = function(self, room, source, targets)
end,
}
LuaXHantongVS = sgs.CreateViewAsSkill{
name = "LuaXHantong",
n = 0,
view_as = function(self, cards)
return LuaXHantongCard:clone()
end,
enabled_at_play = function(self, player)
if not player:getPile("pile"):isEmpty() then
if not player:hasFlag("Global_JijiangFailed") then
return sgs.Slash_IsAvailable(player) and not player:hasSkill("jijiang")
end
end
return false
end,
enabled_at_response = function(self,player,pattern)
return player:getPile("pile"):length()>0 and hasShuGenerals(player) and pattern == "slash" and
sgs.Sanguosha:getCurrentCardUseReason() == sgs.CardUseStruct_CARD_USE_REASON_RESPONSE_USE and
not player:hasFlag("Global_JijiangFailed") and not player:hasSkill("jijiang")
end
}
LuaXHantong = sgs.CreateTriggerSkill{
name = "LuaXHantong",
events = {sgs.BeforeCardsMove,sgs.CardAsked, sgs.EventPhaseStart, sgs.TargetConfirmed},
view_as_skill = LuaXHantongVS,
on_trigger = function(self, event, player, data)
local room = player:getRoom()
if event == sgs.BeforeCardsMove then
if player:getPhase() ~= sgs.Player_Discard then return false end
local move = data:toMoveOneTime()
if move.from:objectName() ~= player:objectName() then return false end
if move.to_place == sgs.Player_DiscardPile and bit32.band(move.reason.m_reason,sgs.CardMoveReason_S_MASK_BASIC_REASON) == sgs.CardMoveReason_S_REASON_DISCARD then
if player:askForSkillInvoke(self:objectName()) then
local ids = move.card_ids
local dummy = {}
local i = 0
for _,card in sgs.qlist(ids) do
local id = sgs.Sanguosha:getCard(card)
table.insert(dummy, id)
end
local count = #dummy
if count > 0 then
for _,c in pairs(dummy) do
local cid = c:getEffectiveId()
player:addToPile("pile", cid)
ids:removeOne(cid)
end
end
data:setValue(move)
end
end
return false
end
local hantongs = player:getPile("pile")
if hantongs:length() > 0 then
if event == sgs.CardAsked then
local pattern = data:toStringList()[1]
if pattern == "slash" and (not player:hasFlag("Global_JijiangFailed")) and not player:hasSkill("jijiang")then
if (room:askForSkillInvoke(player,self:objectName())) then
if not LuaXHantongRemove(player) then return false end
room:acquireSkill(player, "jijiang")
end
elseif pattern == "jink" and not player:hasSkill("hujia") then
if (room:askForSkillInvoke(player,self:objectName()))then
if not LuaXHantongRemove(player) then return false end
room:acquireSkill(player, "hujia")
end
end
elseif event == sgs.TargetConfirmed then
local use = data:toCardUse()
if (not use.card:isKindOf("Peach"))or(not use.from)or(use.from:getKingdom() ~= "wu")or(player:objectName() == use.from:objectName())or(not player:hasFlag("Global_Dying"))or(player:hasSkill("jiuyuan")) then return false end
if room:askForSkillInvoke(player,self:objectName()) then
if not LuaXHantongRemove(player) then return false end
room:acquireSkill(player, "jiuyuan")
end
elseif event == sgs.EventPhaseStart then
if player:getPhase() == sgs.Player_Discard then
if player:getPhase() ~= sgs.Player_Discard or player:hasSkill("xueyi") then return false end
if room:askForSkillInvoke(player,self:objectName()) then
if not LuaXHantongRemove(player) then return false end
room:acquireSkill(player, "xueyi")
end
end
end
end
end,
priority = 3,
}
LuaXHantongDetach = sgs.CreateTriggerSkill{
name = "#LuaXHantongDetach",
events = {sgs.EventPhaseChanging},
on_trigger = function(self, event, player, data)
local change = data:toPhaseChange()
local room = player:getRoom()
if change.to ~= sgs.Player_NotActive then return false end
for _,p in sgs.qlist(room:getAllPlayers())do
if p:getTag("LuaXHantong"):toBool() then
room:handleAcquireDetachSkills(p, "-hujia|-jijiang|-jiuyuan|-xueyi")
p:removeTag("LuaXHantong")
end
end
return false
end,
can_trigger = function(self, target)
return target
end,
}
--[[
技能名:好施
相关武将:林·鲁肃
描述:摸牌阶段,你可以额外摸两张牌,若此时你的手牌多于五张,则将一半(向下取整)的手牌交给全场手牌数最少的一名其他角色。
引用:LuaHaoshiGive、LuaHaoshi、LuaHaoshiVS
状态:1217验证通过
]]--
LuaHaoshiCard = sgs.CreateSkillCard{
name = "LuaHaoshiCard",
target_fixed = false,
will_throw = false,
handling_method = sgs.Card_MethodNone ,
filter = function(self, targets, to_select)
if (#targets ~= 0) or to_select:objectName() == sgs.Self:objectName() then return false end
return to_select:getHandcardNum() == sgs.Self:getMark("LuaHaoshi")
end,
on_use = function(self, room, source, targets)
room:moveCardTo(self, targets[1], sgs.Player_PlaceHand, false)
end
}
LuaHaoshiVS = sgs.CreateViewAsSkill{
name = "LuaHaoshi",
n = 999,
view_filter = function(self, selected, to_select)
if to_select:isEquipped() then return false end
local length = math.floor(sgs.Self:getHandcardNum() / 2)
return #selected < length
end,
view_as = function(self, cards)
if #cards ~= math.floor(sgs.Self:getHandcardNum() / 2) then return nil end
local card = LuaHaoshiCard:clone()
for _, c in ipairs(cards) do
card:addSubcard(c)
end
return card
end,
enabled_at_play = function(self, player)
return false
end,
enabled_at_response = function(self, player, pattern)
return pattern == "@@LuaHaoshi"
end
}
LuaHaoshiGive = sgs.CreateTriggerSkill{
name = "#LuaHaoshiGive",
frequency = sgs.Skill_NotFrequent,
events = {sgs.AfterDrawNCards},
on_trigger = function(self, event, player, data)
local room = player:getRoom()
if player:hasFlag("LuaHaoshi") then
player:setFlags("-LuaHaoshi")
if player:getHandcardNum() <= 5 then return false end
local other_players = room:getOtherPlayers(player)
local least = 1000
for _, _player in sgs.qlist(other_players) do
least = math.min(_player:getHandcardNum(), least)
end
room:setPlayerMark(player, "LuaHaoshi", least)
local used = room:askForUseCard(player, "@@LuaHaoshi", "@haoshi", -1, sgs.Card_MethodNone)
if not used then
local beggar
for _, _player in sgs.qlist(other_players) do
if _player:getHandcardNum() == least then
beggar = _player
break
end
end
local n = math.floor(player:getHandcardNum() / 2)
local to_give = player:handCards():mid(0, n)
local haoshi_card = LuaHaoshiCard:clone()
for _, card_id in sgs.qlist(to_give) do
haoshi_card:addSubcard(card_id)
end
local targets = {beggar}
haoshi_card:on_use(room, player, targets)
end
end
end
}
LuaHaoshi = sgs.CreateTriggerSkill{
name = "LuaHaoshi",
frequency = sgs.Skill_NotFrequent,
events = {sgs.DrawNCards},
view_as_skill = LuaHaoshiVS,
on_trigger = function(self, event, player, data)
local room = player:getRoom()
if room:askForSkillInvoke(player, "LuaHaoshi") then
room:setPlayerFlag(player, "LuaHaoshi")
local count = data:toInt() + 2
data:setValue(count)
end
end
}
--[[
技能名:鹤翼
相关武将:阵·曹洪
描述:回合结束时,你可以选择包括你在内的至少两名连续的角色,这些角色(除你外)拥有“飞影”,直到你的下个回合结束时。
引用:LuaHeyi
状态:1217验证通过
]]--
LuaHeyiCard = sgs.CreateSkillCard{
name = "LuaHeyiCard",
target_fixed = false,
will_throw = true,
filter = function(self, targets, to_select)
return #targets < 2
end,
feasible = function(self, targets)
return #targets == 2
end,
on_use = function(self, room, source, targets)
local data = sgs.QVariant()
data:setValue(source)
room:setTag("LuaHeyiSource",data)
local players = room:getAllPlayers()
local index1,index2 = players:indexOf(targets[1]), players:indexOf(targets[2])
local index_self = players:indexOf(source)
local cont_targets = sgs.SPlayerList()
if index1 == index_self or index2 == index_self then
while true do
cont_targets:append(players:at(index1));
if index1 == index2 then break end
index1 = index1 + 1
if index1 >= players:length() then
index1 = index1 - players:length()
end
end
else
if index1 > index2 then
local temp = index1
index1 = index2
index2 = temp
temp = nil
end
if (index_self > index1 and index_self < index2)then
for i = index1,index2,1 do
cont_targets:append(players:at(i))
end
else
while true do
cont_targets:append(players:at(index2))
if index1 == index2 then break end
index2 = index2 + 1
if index2 >= players:length() then
index2 = index2 - players:length()
end
end
end
end
cont_targets:removeOne(source)
local list = {}
for _,p in sgs.qlist(cont_targets)do
if not p:isAlive() then continue end
table.insert(list,p:objectName())
source:setTag("LuaHeyi",sgs.QVariant(table.concat(list,"+")))
room:acquireSkill(p, "feiying")
end
end,
}
LuaHeyiVS = sgs.CreateZeroCardViewAsSkill{
name = "LuaHeyi",
response_pattern = "@@LuaHeyi",
view_as = function(self, cards)
return LuaHeyiCard:clone()
end,
}
LuaHeyi = sgs.CreateTriggerSkill{
name = "LuaHeyi",
events = {sgs.EventPhaseChanging,sgs.Death},
view_as_skill = LuaHeyiVS,
on_trigger = function(self, triggerEvent, player, data)
local room = player:getRoom()
if triggerEvent == sgs.Death then
local death = data:toDeath()
if death.who:objectName() ~= player:objectName() then
return false
end
elseif triggerEvent == sgs.EventPhaseChanging then
local change = data:toPhaseChange()
if change.to ~= sgs.Player_NotActive then
return false
end
end
if room:getTag("LuaHeyiSource"):toPlayer() and room:getTag("LuaHeyiSource"):toPlayer():objectName() == player:objectName()then
room:removeTag("LuaHeyiSource")
local list = player:getTag(self:objectName()):toString():split("+");
player:removeTag(self:objectName())
for _,p in sgs.qlist(room:getOtherPlayers(player))do
if table.contains(list,p:objectName()) then
room:detachSkillFromPlayer(p, "feiying", false, true)
end
end
end
if player and player:isAlive() and player:hasSkill(self:objectName()) and triggerEvent == sgs.EventPhaseChanging then
room:askForUseCard(player, "@@LuaHeyi", "@LuaHeyi")
end
return false
end,
can_trigger = function(self, target)
return target
end,
priority = 2
}
--[[
技能名:横江
相关武将:势·臧霸
描述:每当你受到1点伤害后,你可以令当前回合角色本回合手牌上限-1,然后其回合结束时,若你于此回合发动过“横江”,且其未于弃牌阶段内弃置牌,你摸一张牌。
引用:LuaHengjiang,LuaHengjiangDraw,LuaHengjiangMaxcards
状态:1217验证通过
DB:效果(处理方法)和源码一致,但我始终觉得有问题。描述写错了么,还是我脑子还没转过来·····
]]--
LuaHengjiang = sgs.CreateMasochismSkill{
name = "LuaHengjiang",
on_damaged = function(self,player,damage)
local room = player:getRoom()
for i = 1, damage.damage, 1 do
local current = room:getCurrent()
if not current or current:isDead() or current:getPhase() == sgs.Player_NotActive then
break
end
local value = sgs.QVariant()
value:setValue(current)
if room:askForSkillInvoke(player,self:objectName(),value) then
room:addPlayerMark(current,"@hengjiang")
end
end
end
}
LuaHengjiangDraw = sgs.CreateTriggerSkill{
name = "#LuaHengjiangDraw",
events = {sgs.TurnStart,sgs.CardsMoveOneTime,sgs.EventPhaseChanging},
on_trigger = function(self, event, player, data)
local room = player:getRoom()
if event == sgs.TurnStart then
room:setPlayerMark(player,"@hengjiang",0)
elseif event == sgs.CardsMoveOneTime then
local move = data:toMoveOneTime()
if move.from and player:objectName() == move.from:objectName() and player:getPhase() == sgs.Player_Discard and bit32.band(move.reason.m_reason,sgs.CardMoveReason_S_MASK_BASIC_REASON) == sgs.CardMoveReason_S_REASON_DISCARD then
player:setFlags("LuaHengjiangDiscarded")
end
elseif event == sgs.EventPhaseChanging then
local change = data:toPhaseChange()
if change.to ~= sgs.Player_NotActive then return false end
local zangba = room:findPlayerBySkillName("LuaHengjiang")
if not zangba then return false end
if player:getMark("@hengjiang") > 0 then
local invoke = false
if not player:hasFlag("LuaHengjiangDiscarded") then
invoke = true
end
player:setFlags("-LuaHengjiangDiscarded")
room:setPlayerMark(player,"@hengjiang",0)
if invoke then
zangba:drawCards(1)
end
end
end
end,
can_trigger = function(self, target)
return target ~= nil
end
}
LuaHengjiangMaxCards = sgs.CreateMaxCardsSkill{
name = "#LuaHengjiangMaxCards",
extra_func = function(self, target)
return -target:getMark("@hengjiang")
end
}
--[[
技能名:弘援
相关武将:新3V3·诸葛瑾
描述:摸牌阶段,你可以少摸一张牌,令其他己方角色各摸一张牌。
引用:LuaXHongyuan、LuaXHongyuanAct
状态:1217验证通过
]]--
Lua3V3_isFriend = function(player,other)
local tb = { ["lord"] = "warm", ["loyalist"] = "warm", ["renegade"] = "cold", ["rebel"] = "cold" }
return tb[player:getRole()] == tb[other:getRole()]
end
LuaXHongyuan = sgs.CreateTriggerSkill{
name = "LuaXHongyuan",
frequency = sgs.Skill_NotFrequent,
events = { sgs.DrawNCards },
on_trigger = function(self, event, player, data)
local room = player:getRoom()
if room:askForSkillInvoke(player, self:objectName()) then
player:setFlags(self:objectName())
local count = data:toInt() - 1
data:setValue(count)
end
end
}
LuaXHongyuanAct = sgs.CreateTriggerSkill {
name = "#LuaXHongyuanAct",
frequency = sgs.Skill_Frequent,
events = { sgs.AfterDrawNCards },
on_trigger = function(self, event, player, data)
local room = player:getRoom()
if player:getPhase() == sgs.Player_Draw then
if player:hasFlag("LuaXHongyuan") then
player:setFlags("-LuaXHongyuan")
for _, other in sgs.qlist(room:getOtherPlayers(player)) do
if Lua3V3_isFriend(player, other) then
other:drawCards(1)
end
end
end
end
return false
end
}
--[[
技能名:弘援
相关武将:新3V3·诸葛瑾(身份局)
描述:摸牌阶段,你可以少摸一张牌,令一至两名其他角色各摸一张牌。
引用:LuaHongyuan、LuaHongyuanAct
状态:1217验证通过
]]--
LuaHongyuanCard = sgs.CreateSkillCard{
name = "LuaHongyuanCard",
target_fixed = false,
will_throw = true,
filter = function(self, targets, to_select, Self)
if to_select:objectName() ~= Self:objectName() then
return #targets < 2
end
return false
end,
on_effect = function(self, effect)
effect.to:setFlags("LuaHongyuan_Target")
end
}
LuaHongyuanVS = sgs.CreateViewAsSkill{
name = "LuaHongyuan",
n = 0,
view_as = function(self, cards)
return LuaHongyuanCard:clone()
end,
enabled_at_play = function(self, player)
return false
end,
enabled_at_response = function(self, player, pattern)
return pattern == "@@LuaHongyuan"
end
}
LuaHongyuan = sgs.CreateTriggerSkill{
name = "LuaHongyuan",
frequency = sgs.Skill_NotFrequent,
events = {sgs.DrawNCards},
view_as_skill = LuaHongyuanVS,
on_trigger = function(self, event, player, data)
local room = player:getRoom()
if room:askForUseCard(player, "@@LuaHongyuan", "@hongyuan") then
local count = data:toInt() - 1
data:setValue(count)
player:setFlags("LuaHongyuan")
end
return false
end
}
LuaHongyuanAct = sgs.CreateTriggerSkill{
name = "#LuaHongyuanAct",
frequency = sgs.Skill_Frequent,
events = {sgs.AfterDrawNCards},
on_trigger = function(self, event, player, data)
local room = player:getRoom()
if player:getPhase() == sgs.Player_Draw and player:hasFlag("LuaHongyuan") then
player:setFlags("-LuaHongyuan")
local targets = sgs.SPlayerList()
for _,p in sgs.qlist(room:getAlivePlayers())do
if p:hasFlag("LuaHongyuan_Target") then
p:setFlags("-LuaHongyuan_Target")
targets:append(p)
end
end
room:drawCards(targets,1,"LuaHongyuan")
end
return false
end
}
--[[
技能名:红颜(锁定技)
相关武将:风·小乔、SP·王战小乔
描述:你的黑桃牌均视为红桃牌。
引用:LuaHongyan
状态:1217验证通过
]]--
LuaHongyan = sgs.CreateFilterSkill{
name = "LuaHongyan",
view_filter = function(self, to_select)
return to_select:getSuit() == sgs.Card_Spade
end,
view_as = function(self, card)
local id = card:getEffectiveId()
local new_card = sgs.Sanguosha:getWrappedCard(id)
new_card:setSkillName(self:objectName())
new_card:setSuit(sgs.Card_Heart)
new_card:setModified(true)
return new_card
end
}
--[[
技能名:后援
相关武将:智·蒋琬
描述:出牌阶段,你可以弃置两张手牌,指定一名其他角色摸两张牌,每阶段限一次
引用:LuaHouyuan
状态:1217验证通过
]]--
LuaHouyuanCard = sgs.CreateSkillCard{
name = "LuaHouyuanCard" ,
on_effect = function(self, effect)
effect.to:drawCards(2)
end ,
}
LuaHouyuan = sgs.CreateViewAsSkill{
name = "LuaHouyuan" ,
n = 2,
view_filter = function(self, selected, to_select)
return (not to_select:isEquipped()) and (#selected < 2)
end ,
view_as = function(self, cards)
if #cards ~= 2 then return nil end
local card = LuaHouyuanCard:clone()
for _, c in ipairs(cards) do
card:addSubcard(c)
end
return card
end ,
enabled_at_play = function(self, player)
return not player:hasUsed("#LuaHouyuanCard")
end
}
--[[
技能名:胡笳
相关武将:倚天·蔡昭姬
描述:回合结束阶段开始时,你可以进行判定:若为红色,立即获得此牌,如此往复,直到出现黑色为止,连续发动3次后武将翻面
引用:LuaCaizhaojiHujia
状态:1217验证通过
]]--
LuaCaizhaojiHujia = sgs.CreateTriggerSkill{
name = "LuaCaizhaojiHujia" ,
events = {sgs.EventPhaseStart, sgs.FinishJudge} ,
on_trigger = function(self, event, player, data)
if (event == sgs.EventPhaseStart) and (player:getPhase() == sgs.Player_Finish) then
local times = 0
local room = player:getRoom()
while player:askForSkillInvoke(self:objectName()) do
player:setFlags("LuaCaizhaojiHujia")
times = times + 1
if times == 3 then player:turnOver() end
local judge = sgs.JudgeStruct()
judge.pattern = ".|red"
judge.good = true
judge.reason = self:objectName()
judge.who = player
room:judge(judge)
if judge:isBad() then break end
end
player:setFlags("-LuaCaizhaojiHujia")
elseif event == sgs.FinishJudge then
if player:hasFlag("LuaCaizhaojiHujia") then
local judge = data:toJudge()
if judge.card:isRed() then
player:obtainCard(judge.card)
end
end
end
return false
end
}
--[[
技能名:虎威
相关武将:1v1·关羽1v1
描述:你登场时,你可以视为使用一张【水淹七军】。
状态:1217验证通过
]]--
LuaHuwei = sgs.CreateTriggerSkill{
name = "LuaHuwei",
events = {sgs.Debut},
on_trigger = function(self, event, player, data)
local drowning = sgs.Sanguosha:cloneCard("drowning")
local opponent = player:getNext()
if not opponent:isAlive() then return false end
drowning:setSkillName("_LuaHuwei")
if not (drowning:isAvailable(player) and player:isProhibited(opponent, drowning)) then
drowning:deleteLater()
return false
end
if room:askForSkillInvoke(player, objectName()) then
room:useCard(CardUseStruct(drowning,player,opponent),false)
end
return false
end,
}
--[[
技能名:虎啸
相关武将:SP·关银屏
描述:每当你于出牌阶段使用【杀】被【闪】抵消后,本阶段你可以额外使用一张【杀】。
引用:LuaHuxiaoCount、LuaHuxiao、LuaHuxiaoClear
状态:0405验证通过
]]--
LuaHuxiao = sgs.CreateTargetModSkill{
name = "LuaHuxiao",
residue_func = function(self, from)
if from:hasSkill(self:objectName()) then
return from:getMark(self:objectName())
else
return 0
end
end
}
LuaHuxiaoCount = sgs.CreateTriggerSkill{
name = "#LuaHuxiao-count" ,
events = {sgs.SlashMissed,sgs.EventPhaseChanging},
on_trigger = function(self, event, player, data)
local room = player:getRoom()
if event == sgs.SlashMissed then
if player:getPhase() == sgs.Player_Play then
room:addPlayerMark(player, "LuaHuxiao")
end
elseif event == sgs.EventPhaseChanging then
local change = data:toPhaseChange()
if change.from == sgs.Player_Play then
if player:getMark("LuaHuxiao") > 0 then
room:setPlayerMark(player, "LuaHuxiao", 0)
end
end
end
end
}
LuaHuxiaoClear = sgs.CreateTriggerSkill{
name = "LuaHuxiao-clear" ,
events = {sgs.EventLoseSkill} ,
on_trigger = function(self, event, player, data)
if data:toString() == "LuaHuxiao" then
player:getRoom():setPlayerMark(player, "LuaHuxiao", 0)
end
end,
can_trigger = function(self, target)
return target
end
}
--[[
技能名:护驾(主公技)
相关武将:标准·曹操、铜雀台·曹操
描述:当你需要使用或打出一张【闪】时,你可以令其他魏势力角色打出一张【闪】(视为由你使用或打出)。
引用:LuaHujia
状态:1217验证通过
]]--
LuaHujia = sgs.CreateTriggerSkill{
name = "LuaHujia$",
frequency = sgs.NotFrequent,
events = {sgs.CardAsked},
on_trigger = function(self, event, player, data)
local room = player:getRoom()
local pattern = data:toStringList()[1]
local prompt = data:toStringList()[2]
if (pattern ~= "jink") or string.find(prompt, "@hujia-jink") then return false end
local lieges = room:getLieges("wei", player)
if lieges:isEmpty() then return false end
if not room:askForSkillInvoke(player, self:objectName(), data) then return false end
local tohelp = sgs.QVariant()
tohelp:setValue(player)
for _, p in sgs.qlist(lieges) do
local prompt = string.format("@hujia-jink:%s", player:objectName())
local jink = room:askForCard(p, "jink", prompt, tohelp, sgs.Card_MethodResponse, player, false,"", true)
if jink then
room:provide(jink)
return true
end
end
return false
end,
can_trigger = function(self, player)
if player then
return player:hasLordSkill(self:objectName())
end
return false
end
}
--[[
技能名:护援
相关武将:阵·曹洪
描述:结束阶段开始时,你可以将一张装备牌置于一名角色装备区内,然后你弃置该角色距离1的一名角色区域内的一张牌。
状态:1217验证通过
注备:Xusine1131(数字君):我真应该扇自己两巴掌……
]]--
LuaHuyuanCard = sgs.CreateSkillCard{
name = "LuaHuyuanCard",
will_throw = false,
handling_method = sgs.Card_MethodNone,
filter = function(self, targets, to_select)
if not #targets == 0 then return false end
local card = sgs.Sanguosha:getCard(self:getEffectiveId())
local equip = card:getRealCard():toEquipCard()
local index = equip:location()
return to_select:getEquip(index) == nil
end,
on_effect = function(self, effect)
local caohong = effect.from
local room = caohong:getRoom()
room:moveCardTo(self, caohong, effect.to, sgs.Player_PlaceEquip,sgs.CardMoveReason(sgs.CardMoveReason_S_REASON_PUT, caohong:objectName(), "LuaYuanhu", ""))
local card = sgs.Sanguosha:getCard(self:getEffectiveId())
local targets = sgs.SPlayerList()
for _,p in sgs.qlist(room:getAllPlayers()) do
if effect.to:distanceTo(p) == 1 and caohong:canDiscard(p, "he") then
targets:append(p)
end
end
if not targets:isEmpty() then
local to_dismantle = room:askForPlayerChosen(caohong, targets, "LuaHuyuan", "@huyuan-discard:" .. effect.to:objectName())
local card_id = room:askForCardChosen(caohong, to_dismantle, "he", "LuaHuyuan", false,sgs.Card_MethodDiscard)
room:throwCard(sgs.Sanguosha:getCard(card_id), to_dismantle, caohong)
end
end
}
LuaHuyuanVS = sgs.CreateOneCardViewAsSkill{
name = "LuaHuyuan",
filter_pattern = "EquipCard",
response_pattern = "@@LuaHuyuan",
view_as = function(self, card)
local first = LuaHuyuanCard:clone()
first:addSubcard(card:getId())
first:setSkillName(self:objectName())
return first
end,
}
LuaHuyuan = sgs.CreatePhaseChangeSkill{
name = "LuaHuyuan",
view_as_skill = LuaHuyuanVS,
on_phasechange = function(self,target)
local room = target:getRoom()
if target:getPhase() == sgs.Player_Finish and not target:isNude() then
room:askForUseCard(target, "@@LuaHuyuan", "@huyuan-equip", -1, sgs.Card_MethodNone)
end
end
}
--[[
技能名:化身
相关武将:山·左慈
描述:所有人都展示武将牌后,你随机获得两张未加入游戏的武将牌,称为“化身牌”,选一张置于你面前并声明该武将的一项技能,你获得该技能且同时将性别和势力属性变成与该武将相同直到“化身牌”被替换。在你的每个回合开始时和结束后,你可以替换“化身牌”,然后(无论是否替换)你为当前的“化身牌”声明一项技能(你不可以声明限定技、觉醒技或主公技)。
引用:LuaHuashen LuaHuashenDetach
状态:1217验证通过(源码功能完全实现)
备注:Xusine(所谓的数字君1131561728):这个技能使用了JsonForLua的库,请将json.lua放在游戏目录或者放在lua\lib
]]--
local json = require ("json")
function isNormalGameMode (mode_name)
return mode_name:endsWith("p") or mode_name:endsWith("pd") or mode_name:endsWith("pz")
end
function GetAvailableGenerals(zuoci) ----完全按照源码写的,累死了……
local all = sgs.Sanguosha:getLimitedGeneralNames()
local room = zuoci:getRoom()
if (isNormalGameMode(room:getMode()) or room:getMode():find("_mini_")or room:getMode() == "custom_scenario") then
table.removeTable(all,sgs.GetConfig("Banlist/Roles",""):split(","))
elseif (room:getMode() == "04_1v3") then
table.removeTable(all,sgs.GetConfig("Banlist/HulaoPass",""):split(","))
elseif (room:getMode() == "06_XMode") then
table.removeTable(all,sgs.GetConfig("Banlist/XMode",""):split(","))
for _,p in sgs.qlist(room:getAlivePlayers())do
table.removeTable(all,(p:getTag("XModeBackup"):toStringList()) or {})
end
elseif (room:getMode() == "02_1v1") then
table.removeTable(all,sgs.GetConfig("Banlist/1v1",""):split(","))
for _,p in sgs.qlist(room:getAlivePlayers())do
table.removeTable(all,(p:getTag("1v1Arrange"):toStringList()) or {})
end
end
local Huashens = {}
local Hs_String = zuoci:getTag("LuaHuashens"):toString()
if Hs_String and Hs_String ~= "" then
Huashens = Hs_String:split("+")
end
table.removeTable(all,Huashens)
for _,player in sgs.qlist(room:getAlivePlayers())do
local name = player:getGeneralName()
if sgs.Sanguosha:isGeneralHidden(name) then
local fname = sgs.Sanguosha:findConvertFrom(name);
if fname ~= "" then name = fname end
end
table.removeOne(all,name)
if player:getGeneral2() == nil then continue end
name = player:getGeneral2Name();
if sgs.Sanguosha:isGeneralHidden(name) then
local fname = sgs.Sanguosha:findConvertFrom(name);
if fname ~= "" then name = fname end
end
table.removeOne(all,name)
end
local banned = {"zuoci", "guzhielai", "dengshizai", "caochong", "jiangboyue", "bgm_xiahoudun"}
table.removeTable(all,banned)
return all
end
function AcquireGenerals(zuoci, n)
local room = zuoci:getRoom();
local Huashens = {}
local Hs_String = zuoci:getTag("LuaHuashens"):toString()
if Hs_String and Hs_String ~= "" then
Huashens = Hs_String:split("+")
end
local list = GetAvailableGenerals(zuoci)
if #list == 0 then return end
n = math.min(n, #list)
local acquired = {}
repeat
local rand = math.random(1,#list)
if not table.contains(acquired,list[rand]) then
table.insert(acquired,(list[rand]))
end
until #acquired == n
for _,name in pairs(acquired)do
table.insert(Huashens,name)
localgeneral = sgs.Sanguosha:getGeneral(name)
if general then
for _,skill in sgs.list(general:getTriggerSkills()) do
if skill:isVisible() then
room:getThread():addTriggerSkill(skill)
end
end
end
end
zuoci:setTag("LuaHuashens", sgs.QVariant(table.concat(Huashens, "+")))
local hidden = {}
for i = 1,n,1 do
table.insert(hidden,"unknown")
end
for _,p in sgs.qlist(room:getAllPlayers())do
local splist = sgs.SPlayerList()
splist:append(p)
if p:objectName() == zuoci:objectName() then
room:doAnimate(4, zuoci:objectName(), table.concat(acquired,":"), splist)
else
room:doAnimate(4, zuoci:objectName(),table.concat(hidden,":"),splist);
end
end
local log = sgs.LogMessage()
log.type = "#GetHuashen"
log.from = zuoci
log.arg = n
log.arg2 = #Huashens
room:sendLog(log)
--Json大法好 ^_^
local jsonLog ={
"#GetHuashenDetail",
zuoci:objectName(),
"",
"",
table.concat(acquired,"\\, \\"),
"",
}
room:doNotify(zuoci,sgs.CommandType.S_COMMAND_LOG_SKILL,json.encode(jsonLog));
room:setPlayerMark(zuoci, "@huashen", #Huashens)
end
function SelectSkill(zuoci)
local room = zuoci:getRoom();
local ac_dt_list = {}
local huashen_skill = zuoci:getTag("LuaHuashenSkill"):toString();
if huashen_skill ~= "" then
table.insert(ac_dt_list,"-"..huashen_skill)
end
local Huashens = {}
local Hs_String = zuoci:getTag("LuaHuashens"):toString()
if Hs_String and Hs_String ~= "" then
Huashens = Hs_String:split("+")
end
if #Huashens == 0 then return end
local huashen_generals = {}
for _,huashen in pairs(Huashens)do
table.insert(huashen_generals,huashen)
end
local skill_names = {}
local skill_name
local general
local ai = zuoci:getAI();
if (ai) then
local hash = {}
for _,general_name in pairs (huashen_generals) do
local general = sgs.Sanguosha:getGeneral(general_name)
for _,skill in (general:getVisibleSkillList())do
if skill:isLordSkill() or skill:getFrequency() == sgs.Skill_Limited or skill:getFrequency() == sgs.Skill_Wake then
continue
end
if not table.contains(skill_names,skill:objectName()) then
hash[skill:objectName()] = general;
table.insert(skill_names,skill:objectName())
end
end
end
if #skill_names == 0 then return end
skill_name = ai:askForChoice("huashen",table.concat(skill_names,"+"), sgs.QVariant());
general = hash[skill_name]
else
local general_name = room:askForGeneral(zuoci, table.concat(huashen_generals,"+"))
general = sgs.Sanguosha:getGeneral(general_name)
assert(general)
for _,skill in sgs.qlist(general:getVisibleSkillList())do
if skill:isLordSkill() or skill:getFrequency() == sgs.Skill_Limited or skill:getFrequency() == sgs.Skill_Wake then
continue
end
if not table.contains(skill_names,skill:objectName()) then
table.insert(skill_names,skill:objectName())
end
end
if #skill_names > 0 then
skill_name = room:askForChoice(zuoci, "huashen",table.concat(skill_names,"+"))
end
end
local kingdom = general:getKingdom()
if zuoci:getKingdom() ~= kingdom then
if kingdom == "god" then
kingdom = room:askForKingdom(zuoci);
local log = sgs.LogMessage()
log.type = "#ChooseKingdom";
log.from = zuoci;
log.arg = kingdom;
room:sendLog(log);
end
room:setPlayerProperty(zuoci, "kingdom", sgs.QVariant(kingdom))
end
if zuoci:getGender() ~= general:getGender() then
zuoci:setGender(general:getGender())
end
----Json大法又释放了一次英姿!
local jsonValue = {