【太阳神三国杀】武将技能设定与代码

DIY了一些三国杀武将,并实现在太阳神三国杀中。

1号武将

男性 3体力 神

深谋

锁定技 你的非延时锦囊不能被“无懈可击”响应。

1
2
3
4
5
6
7
8
9
10
shenmou = sgs.CreateTriggerSkill{
name = "shenmou",
events = {sgs.TrickCardCanceling},
can_trigger = function(self, target) return target end,
frequency = sgs.Skill_Compulsory,
on_trigger = function(self, event, player, data)
local effect = data:toCardEffect()
return effect.from and effect.from:hasSkill(self:objectName()) and effect.from:isAlive()
end
}

远虑

当有角色的锦囊指定了至少两个目标时,你可以弃一些牌并指定等量目标角色,使此锦囊对这些角色无效。

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
yuanlvCard = sgs.CreateSkillCard{
name = "yuanlv",
handling_method = sgs.Card_MethodDiscard,
filter = function(self,targets,to_select)
local tos = sgs.Self:property("yuanlvUse"):toString():split("+")
local old_nullified = sgs.Self:property("yuanlvOldNullify"):toString():split("+")
return table.contains(tos,to_select:objectName()) and #targets < self:getSubcards():length()
and (not table.contains(old_nullified,to_select:objectName()))
end,
feasible = function(self,targets)
return #targets == self:getSubcards():length()
end,
on_use = function(self,room,source,targets)
local nullified_list = {}
for _, target in ipairs(targets) do
table.insert(nullified_list,target:objectName())
end
room:setPlayerProperty(source,"yuanlvNullify",sgs.QVariant(table.concat(nullified_list,"+")))
end
}


yuanlvVS = sgs.CreateViewAsSkill{
name = "yuanlv",
n = 999,
response_pattern = "@@yuanlv",
view_filter = function(self,selected,to_select)
local tos = sgs.Self:property("yuanlvUse"):toString():split("+")
return #selected < #tos
end,
view_as = function(self,cards)
if #cards == 0 then return nil end
local vs_card = yuanlvCard:clone()
for _, card in ipairs(cards) do
vs_card:addSubcard(card)
end
return vs_card
end
}


yuanlv = sgs.CreateTriggerSkill{
name = "yuanlv",
view_as_skill = yuanlvVS,
events = {sgs.TargetSpecified},

on_trigger = function(self,event,player,data)
local room = player:getRoom()
player = room:findPlayerBySkillName(self:objectName())
local use = data:toCardUse()
player:setTag("yuanlv",data) --给AI使用
if use.to:length() < 2 or not use.card:isNDTrick() then return false end
local to_table = {}
for _, to in sgs.qlist(use.to) do
table.insert(to_table,to:objectName())
end
local nullified_list = use.nullified_list --获取原来的免疫列表
room:setPlayerProperty(player,"yuanlvOldNullify",sgs.QVariant(table.concat(nullified_list,"+")))
room:setPlayerProperty(player,"yuanlvUse",sgs.QVariant(table.concat(to_table,"+"))) --可施加免疫角色列表
if room:askForUseCard(player,"@@yuanlv","@yuanlv",-1,sgs.Card_MethodDiscard) then
local yuanlv_nullified = player:property("yuanlvNullify"):toString():split("+")
for _, target in ipairs(yuanlv_nullified) do
table.insert(nullified_list,target) --把远虑指定的免疫列表加到原来的列表里面
end
use.nullified_list = nullified_list
data:setValue(use) --更新值
end

end,
can_trigger = function(self, target)
return target and target:isAlive()
end
}

天佑

你的每张点数为素数的牌因弃置而置入弃牌堆时,你可以摸一张牌。

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
function isPrime(card)
n = card:getNumber()
return n==2 or n==3 or n==5 or n==7 or n==11 or n==13
end

tianyou = sgs.CreateTriggerSkill{
name = "tianyou",
events = {sgs.CardsMoveOneTime},
frequency = sgs.Skill_Frequent,
on_trigger = function(self, event, player, data)
local room=player:getRoom()
local move = data:toMoveOneTime()
local source = move.from
if not move.from or source:objectName() ~= player:objectName() then return end
local reason = move.reason.m_reason
if move.to_place == sgs.Player_DiscardPile then
if bit32.band(reason, sgs.CardMoveReason_S_MASK_BASIC_REASON) == sgs.CardMoveReason_S_REASON_DISCARD then
local count = 0
for i=0, (move.card_ids:length()-1), 1 do
local card_id = move.card_ids:at(i)
local card = sgs.Sanguosha:getCard(card_id)
if (move.from_places:at(i) == sgs.Player_PlaceHand
or move.from_places:at(i) == sgs.Player_PlaceEquip) and isPrime(card) then
count = count + 1
end
end
if count > 0 and player:askForSkillInvoke(self:objectName()) then
player:drawCards(count)
end
end
end
return false
end
}

2号武将

? 3体力 神

攻受

锁定技 其他角色回合开始时,你的性别变成与之相反。你的回合开始时,需选择性别。

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
gongshou = sgs.CreateTriggerSkill{
name = "gongshou",
frequency = sgs.Skill_Compulsory,
events = {sgs.TurnStart},
on_trigger = function(self, event, player, data)
room = player:getRoom()
local yly = room:findPlayerBySkillName(self:objectName())
if yly and yly:isAlive() then
room:sendCompulsoryTriggerLog(yly, self:objectName())
msg = sgs.LogMessage()
msg.from=yly
if player:objectName() == yly:objectName() then
local result = room:askForChoice(player, self:objectName(), "nan+nv")
if result == "nan" then
msg.type = "#tomale"
player:setGender(sgs.General_Male)
else
player:setGender(sgs.General_Female)
msg.type = "#tofemale"
end
else
if player:isMale() then
yly:setGender(sgs.General_Female)
msg.type = "#tofemale"
elseif player:isFemale() then
yly:setGender(sgs.General_Male)
msg.type = "#tomale"
else
yly:setGender(sgs.General_Neuter)
msg.type = "#toneuter"
end
end
room:sendLog(msg)
end
return false
end,
can_trigger = function(self, target)
return target and target:isAlive()
end
}

[":gongshou:"] = "请选择性别:",
["gongshou:nan"] = "男性",
["gongshou:nv"] = "女性",
["#tomale"] = "%from 的性别变成男性。",
["#tofemale"] = "%from 的性别变成女性。",
["#toneuter"] = "%from 的性别未知。",

调情

锁定技 你的杀攻击范围始终加一;你的杀指定异性角色为目标时,可以令其选择一项:弃一张手牌或让你摸一张牌。

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
tiaoqing = sgs.CreateTriggerSkill{--调情
name = "tiaoqing",
events = {sgs.TargetConfirmed},
on_trigger = function(self,event,player,data)
local use = data:toCardUse()
local card = use.card
local room = player:getRoom()
if card:isKindOf("Slash") and use.from:objectName()==player:objectName() then
for _,p in sgs.qlist(use.to) do
if p:getGender() ~= use.from:getGender() and player:askForSkillInvoke(self:objectName()) then
if not p:isKongcheng() then
if not room:askForCard(p, ".|.|.|hand", "@tiaoqing-discard:"..use.from:objectName(),data) then
use.from:drawCards(1)
end
else
use.from:drawCards(1)
end
end
end
end
return false
end,
}

TiaoqingTargetMod = sgs.CreateTargetModSkill{
name = "#tiaoqing-target",
pattern = "Slash",
distance_limit_func = function(self, player)
if player:hasSkill(self:objectName()) then
return 1
else
return 0
end
end
}

extension:insertRelatedSkills("tiaoqing","#tiaoqing-target")

["@tiaoqing-discard"]="%src 发动了技能【调情】,你须弃置一张手牌,或令 %src 摸一张牌",

解衣

出牌阶段,你可以弃掉一张装备牌,然后摸一张牌。你以此法弃掉防具时回复一点体力。

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
jieyi = sgs.CreateViewAsSkill{  --解衣
name = "jieyi",
n = 1,
view_filter = function(self, selected, to_select)
return to_select:getTypeId() == 3 --是装备
end,
view_as = function(self, cards)
if #cards == 1 then
local vs_card=jieyiCard:clone()
vs_card:addSubcard(cards[1])
return vs_card
end
return false
end
}

jieyiCard = sgs.CreateSkillCard{
name = "jieyi",
target_fixed = true,
will_throw = true,
on_use = function(self, room, source, targets)
room:drawCards(source,1)
local card=sgs.Sanguosha:getCard(self:getSubcards():first())
if source:isWounded() and card:isKindOf("Armor") then
local theRecover = sgs.RecoverStruct()
theRecover.recover = 1
theRecover.who = source
room:recover(source, theRecover)
end
end
}

3号武将

女性 3体力 神

阴谋

每当你将造成伤害或受到伤害时,你可以弃一张牌并选择一名角色,使其成为此伤害的来源。

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
yinmouCard = sgs.CreateSkillCard{
name = "yinmouCard" ,
filter = function(self, selected, to_select)
return #selected == 0
end ,
on_effect = function(self, effect)
local room = effect.to:getRoom()
effect.to:addMark("yinmouFrom")
local damage = effect.from:getTag("yinmouDamage"):toDamage()
damage.from = effect.to
room:damage(damage)
effect.to:removeMark("yinmouFrom")
end
}

yinmouVS = sgs.CreateViewAsSkill{
name = "yinmou" ,
n = 1 ,
view_filter = function(self, selected, to_select)
return not sgs.Self:isJilei(to_select)
end ,
view_as = function(self, cards)
if #cards ~= 1 then return nil end
local ymCard = yinmouCard:clone()
ymCard:addSubcard(cards[1])
ymCard:setSkillName(self:objectName())
return ymCard
end ,
enabled_at_play = function()
return false
end,
enabled_at_response = function(self, player, pattern)
return pattern == "@@yinmou"
end
}

yinmou = sgs.CreateTriggerSkill{
name = "yinmou",
events = {sgs.DamageCaused,sgs.DamageInflicted},
view_as_skill = yinmouVS,
priority={11,11},
on_trigger = function(self, event, player, data)
if player:getCardCount(true)>0 then
local damage = data:toDamage()
if not damage.from or damage.from:getMark("yinmouFrom") ==0 then
player:setTag("yinmouDamage", data)
return player:getRoom():askForUseCard(player, "@@yinmou", "@yinmou-card", -1, sgs.Card_MethodDiscard)
end
end
return false
end
}

阳谋

每当你对距离为1以内的角色造成伤害后,你可以摸一张牌,或者弃一张牌并回复1点体力。

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
yangmou = sgs.CreateTriggerSkill{
name = "yangmou",
frequency = sgs.Skill_Frequent,
events = {sgs.Damage, sgs.PreDamageDone},
on_trigger = function(self, event, player, data)
local damage = data:toDamage()
local room = player:getRoom()
if (event == sgs.PreDamageDone) and damage.from and damage.from:hasSkill(self:objectName()) and damage.from:isAlive() then
local zzh=damage.from
zzh:setTag("can_yangmou", sgs.QVariant((zzh:distanceTo(damage.to) <= 1)))
elseif (event == sgs.Damage) and player:hasSkill(self:objectName()) and player:hasSkill(self:objectName()) and player:isAlive() then
local invoke = player:getTag("can_yangmou"):toBool()
player:setTag("can_yangmou", sgs.QVariant(false))
if invoke and player:askForSkillInvoke(self:objectName()) then
local choices = {}
table.insert(choices, "draw")
if player:isWounded() and player:getCardCount(true)>0 then
table.insert(choices, "recover")
end
local choice = room:askForChoice(player, self:objectName(), table.concat(choices, "+"))
if choice=="recover" then
room:askForDiscard(player, self:objectName(), 1, 1, false, true)
local recover = sgs.RecoverStruct()
recover.who = player
room:recover(player, recover)
elseif choice=="draw" then
player:drawCards(1)
end
end

end
return false
end,
can_trigger = function(self, target)
return target
end
}

["yangmou:draw"]="摸一张牌",
["yangmou:recover"]="弃牌回血",

对诗

当有角色的牌被弃置时,你可以弃一张点数相同的牌,然后与其各摸一张牌。

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
duishi = sgs.CreateTriggerSkill{
name = "duishi",
events = {sgs.CardsMoveOneTime},
on_trigger = function(self, event, player, data)
local room = player:getRoom()
local move = data:toMoveOneTime()
if not move.from then return false end
if player:getHp() > 0 and move.from:isAlive() and (move.from_places:contains(sgs.Player_PlaceHand) or move.from_places:contains(sgs.Player_PlaceEquip))
and move.reason.m_reason == sgs.CardMoveReason_S_REASON_DISMANTLE then
for _, card_id in sgs.qlist(move.card_ids) do
local n=sgs.Sanguosha:getCard(card_id):getNumber()
local flag=false
for _, card in sgs.qlist(player:getHandcards()) do
if card:getNumber()==n then
flag=true
break
end
end
if not flag then
for _, card in sgs.qlist(player:getEquips()) do
if card:getNumber()==n then
flag=true
break
end
end
end
if flag and player:askForSkillInvoke(self:objectName(), data) then
card = room:askForCard(player, string.format(".|.|%d", n), "@duishi-discard:" .. move.from:objectName())
if card and card:getNumber()==n then
speakSkill(room,self:objectName(),math.random(1,2),100)
player:drawCards(1)
local from = room:findPlayer(move.from:getGeneralName())
from:drawCards(1) --必须要这么纠结才能摸到牌。。。
end
end
end

end
return false
end
}

["@duishi-discard"]="请弃置相同点数的牌,然后你与 %src 各摸一张牌",

4号武将

男性 4体力 神

求异

阶段技 你可以弃一张【杀】并指定一名其他角色,该角色需弃置一张【闪】或受到你的一点伤害。

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
qiuyiCard = sgs.CreateSkillCard{
name = "qiuyi",
handling_method = sgs.Card_MethodDiscard,
target_fixed = false,
will_throw = true,
filter = function(self, targets, to_select)
return #targets == 0 and to_select:objectName() ~= sgs.Self:objectName()
end,
feasible = function(self, targets)
return #targets == 1
end,
on_use = function(self, room, source, targets)
card=room:askForCard(targets[1], "jink", "@qiuyi-jink:"..source:objectName(),sgs.QVariant(),sgs.Card_MethodDiscard)
if not card then
room:damage(sgs.DamageStruct(self:objectName(), source,targets[1]))
end
end
}

qiuyi = sgs.CreateViewAsSkill{
name = "qiuyi",
n = 1,
view_filter = function(self, selected, to_select)
return to_select:isKindOf("Slash")
end,
view_as = function(self, cards)
if #cards == 1 then
local vs_card=qiuyiCard:clone()
vs_card:addSubcard(cards[1])
return vs_card
end
return false
end,
enabled_at_play = function(self, player)
return not player:hasUsed("#qiuyi") and player:getHandcardNum() > 0
end
}

["@qiuyi-jink"] = "弃置一张【闪】,否则受到 %src 对你造成的一点伤害。",

自摸

一名角色的准备阶段时,若其判定区有牌,你可以观看牌堆顶的一张牌,然后你可以获得之。
PS: 双击框内显示的牌获得之;点确定则不获得。

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
zimo = sgs.CreateTriggerSkill{
name = "zimo",
events = {sgs.EventPhaseEnd},
on_trigger = function(self, event, player, data)
local room=player:getRoom()
local source = room:findPlayerBySkillName(self:objectName())
if not source or player:getJudgingArea():length()==0 then return false end
if player:getPhase()==sgs.Player_Start and source:askForSkillInvoke(self:objectName()) then
local cards = room:getNCards(1)
room:fillAG(cards, source)
local card_id = room:askForAG(source, cards, true, "zimo")
room:clearAG(source)
if card_id >= 0 then
local cd = sgs.Sanguosha:getCard(card_id)
local reason = sgs.CardMoveReason(sgs.CardMoveReason_S_REASON_EXCHANGE_FROM_PILE, source:objectName(), self:objectName(), "")
room:obtainCard(source, cd, reason, false)
else
room:returnToTopDrawPile(cards)
end
end
return false
end,
can_trigger = function(self, target)
return target and target:isAlive()
end
}

5号武将

男性 4体力 神

整装

回合结束时,你可以弃一张非基本牌并指定一名角色,该角色开始一个额外的、由你指定的阶段。

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
function sendMsg(room,message,from,to,arg)
local msg = sgs.LogMessage()
msg.type = message
if from then msg.from = from end
if to then msg.to:append(to) end
if arg then msg.arg = arg end
room:sendLog(msg)
end

zhengzhuangCard = sgs.CreateSkillCard{
name = "zhengzhuang",
target_fixed = false,
will_throw = true,
handling_method = sgs.Card_MethodDiscard,
filter = function(self, targets, to_select)
return #targets == 0
end,
on_use = function(self, room, player, targets)
target = targets[1]
--local phase = {sgs.Player_Start,sgs.Player_Judge,sgs.Player_Draw,sgs.Player_Play,sgs.Player_Discard,sgs.Player_Finish}
choice = room:askForChoice(player, "zhengzhuang", "1+2+3+4+5+6")
sendMsg(room, "#zhengzhuang", player, target, "zhengzhuang:"..choice)
choice = tonumber(choice)
player = target
player:setPhase(choice)
room:broadcastProperty(player, "phase")
local thread = room:getThread()
if not thread:trigger(sgs.EventPhaseStart, room, player) then
thread:trigger(sgs.EventPhaseProceeding, room, player)
end
thread:trigger(sgs.EventPhaseEnd, room, player)
room:broadcastProperty(player, "phase")
end
}

zhengzhuangVS = sgs.CreateViewAsSkill{
name = "zhengzhuang",
n = 1,
view_filter = function(self, selected, to_select)
return (not to_select:isKindOf("BasicCard")) and (not sgs.Self:isJilei(to_select))
end,
view_as = function(self, cards)
if #cards == 1 then
local card = zhengzhuangCard:clone()
card:addSubcard(cards[1])
return card
end
end,
enabled_at_play = function(self, player)
return false
end,
enabled_at_response = function(self, player, pattern)
return pattern == "@@zhengzhuang"
end
}

zhengzhuang = sgs.CreateTriggerSkill{
name = "zhengzhuang",
events = {sgs.EventPhaseChanging},
view_as_skill = zhengzhuangVS,
on_trigger = function(self, event, player, data)
local room=player:getRoom()
local change = data:toPhaseChange()
if change.to == sgs.Player_NotActive and player:canDiscard(player, "h") then
local flag
if player:getEquips():length() > 0 then
room:askForUseCard(player, "@@zhengzhuang", "@zhengzhuang")
return false
end

for _, card in sgs.qlist(player:getHandcards()) do
if card:isKindOf("TrickCard") or card:isKindOf("EquipCard") then
room:askForUseCard(player, "@@zhengzhuang", "@zhengzhuang")
return false
end
end
end
return false
end
}

["#zhengzhuang"]="%from 令 %to 开始了一个额外的 %arg。",
["zhengzhuang:1"]="准备阶段",
["zhengzhuang:2"]="判定阶段",
["zhengzhuang:3"]="摸牌阶段",
["zhengzhuang:4"]="出牌阶段",
["zhengzhuang:5"]="弃牌阶段",
["zhengzhuang:6"]="结束阶段",

逗乐

当有【乐不思蜀】即将进入弃牌堆时,若此时为一名角色的出牌阶段或弃牌阶段,你可以获得之。

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
doule = sgs.CreateTriggerSkill{
name = "doule" ,
events = {sgs.BeforeCardsMove} ,
frequency = sgs.Skill_Frequent,
on_trigger = function(self, event, player, data)
local room = player:getRoom()
local move = data:toMoveOneTime()
local cur = room:getCurrent()
if player:isAlive() and move and move.to_place == sgs.Player_DiscardPile
and cur and (cur:getPhase()==sgs.Player_Play or cur:getPhase()==sgs.Player_Discard) then
local i=0
local card_ids = sgs.IntList()
for _, card_id in sgs.qlist(move.card_ids) do
local card=sgs.Sanguosha:getCard(card_id)
if card:isKindOf("Indulgence") and player:askForSkillInvoke(self:objectName(),data) then
move.from_places:removeAt(i)
card_ids:append(card_id)
else
i=i+1
end
end
for _, id in sgs.qlist(card_ids) do
if move.card_ids:contains(id) then
move.card_ids:removeOne(id)
end
data:setValue(move)
room:moveCardTo(sgs.Sanguosha:getCard(id), player, sgs.Player_PlaceHand, move.reason, true)
if not player:isAlive() then break end
end
end
return false
end
}

6号武将

男性 4体力 神

单身

你可以将两张手牌当一张基本牌使用或打出。

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
function Set(list)
local set = {}
for _, l in ipairs(list) do set[l] = true end
return set
end

function isStandard()
return (Set(sgs.Sanguosha:getBanPackages()))["maneuvering"]
end

danshenCard = sgs.CreateSkillCard{
name = "danshenCard",
will_throw = false,
target_fixed = true,
mute = true,
on_use = function(self, room, source, targets)
local choice={}
local patterns = {"slash","jink", "peach"}
if not isStandard() then
table.insert(patterns, "analeptic")
end
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 cd=="slash" and not isStandard() then
table.insert(choice, "normal_slash")
table.insert(choice, "thunder_slash")
table.insert(choice, "fire_slash")
else
table.insert(choice, cd)
end
end
end
end
if #choice>0 then
pattern=room:askForChoice(source, "@danshen-choose", table.concat(choice, "+"))
end
if pattern~="cancel" then
if pattern=="normal_slash" then _pattern="slash"
else _pattern=pattern end
room:setPlayerProperty(source,"danshenPattern",sgs.QVariant(_pattern))
room:askForUseCard(source, "@@danshen", "@danshen:::"..pattern)
end
end
}

danshenResponse = sgs.CreateSkillCard{
name = "danshenResponse",
will_throw = true,
handling_method = sgs.Card_MethodNone,
filter = function(self, targets, to_select, player)
if sgs.Sanguosha:getCurrentCardUseReason() == sgs.CardUseStruct_CARD_USE_REASON_RESPONSE_USE and sgs.Sanguosha:getCurrentCardUsePattern() ~= "@@danshen" then
local card = nil
if self:getUserString() ~= "" then
card = sgs.Sanguosha:cloneCard(self:getUserString():split("+")[1])
card:setSkillName("danshen")
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)
elseif sgs.Sanguosha:getCurrentCardUseReason() == sgs.CardUseStruct_CARD_USE_REASON_RESPONSE then
return false
end
local pattern = player:property("danshenPattern"):toString()
if pattern == "normal_slash" then pattern = "slash" end
local card = sgs.Sanguosha:cloneCard(pattern, sgs.Card_SuitToBeDecided, -1)
card:setSkillName("danshen")
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)
end,
target_fixed = function(self)
if sgs.Sanguosha:getCurrentCardUseReason() == sgs.CardUseStruct_CARD_USE_REASON_RESPONSE_USE and sgs.Sanguosha:getCurrentCardUsePattern() ~= "@@danshen" then
local card = nil
if self:getUserString() ~= "" then
card = sgs.Sanguosha:cloneCard(self:getUserString():split("+")[1])
end
return card and card:targetFixed()
elseif sgs.Sanguosha:getCurrentCardUseReason() == sgs.CardUseStruct_CARD_USE_REASON_RESPONSE then
return true
end
local pattern = player:property("danshenPattern"):toString()
if pattern == "normal_slash" then pattern = "slash" end
local card = sgs.Sanguosha:cloneCard(pattern, sgs.Card_SuitToBeDecided, -1)
return card and card:targetFixed()
end,
feasible = function(self, targets)
if sgs.Sanguosha:getCurrentCardUseReason() == sgs.CardUseStruct_CARD_USE_REASON_RESPONSE_USE and sgs.Sanguosha:getCurrentCardUsePattern() ~= "@@danshen" then
local card = nil
if self:getUserString() ~= "" then
card = sgs.Sanguosha:cloneCard(self:getUserString():split("+")[1])
card:setSkillName("danshen")
end
local qtargets = sgs.PlayerList()
for _, p in ipairs(targets) do
qtargets:append(p)
end
return card and card:targetsFeasible(qtargets, sgs.Self)
elseif sgs.Sanguosha:getCurrentCardUseReason() == sgs.CardUseStruct_CARD_USE_REASON_RESPONSE then
return true
end
local pattern = player:property("danshenPattern"):toString()
if pattern == "normal_slash" then pattern = "slash" end
local card = sgs.Sanguosha:cloneCard(pattern, sgs.Card_SuitToBeDecided, -1)
card:setSkillName("danshen")
local qtargets = sgs.PlayerList()
for _, p in ipairs(targets) do
qtargets:append(p)
end
return card and card:targetsFeasible(qtargets, sgs.Self)
end,
on_validate = function(self, card_use)
local player=card_use.from
local room = player:getRoom()
local pattern=self:getUserString()
if pattern == "slash" and not isStandard() then
pattern= "normal_slash+thunder_slash+fire_slash"
end
pattern = room:askForChoice(player, "@danshen-choose", pattern)
if pattern=="normal_slash" then pattern="slash" end
if pattern=="cancel" then return nil end
room:setPlayerProperty(player,"danshenPattern",sgs.QVariant(pattern))
local use_card = sgs.Sanguosha:cloneCard(pattern, sgs.Card_NoSuit, 0)
use_card:setSkillName("danshen")
use_card:addSubcards(self:getSubcards())
use_card:deleteLater()
room:setEmotion(player, "weapon/spear")
return use_card
end,
on_validate_in_response = function(self, player)
local room = player:getRoom()
--room:broadcastSkillInvoke("danshen")
local pattern=self:getUserString()
if pattern== "peach+analeptic" and isStandard() then
pattern="peach"
elseif pattern == "slash" and not isStandard() then
pattern= "normal_slash+thunder_slash+fire_slash"
end
pattern = room:askForChoice(player, "@danshen-choose", pattern)
if pattern=="normal_slash" then pattern="slash" end
if pattern=="cancel" then return nil end
room:setPlayerProperty(player,"danshenPattern",sgs.QVariant(pattern))
local use_card = sgs.Sanguosha:cloneCard(pattern, sgs.Card_NoSuit, 0)
use_card:setSkillName("danshen")
use_card:addSubcards(self:getSubcards())
use_card:deleteLater()
room:setEmotion(player, "weapon/spear")
return use_card
end
}
danshen = sgs.CreateViewAsSkill{
name = "danshen" ,
n = 2,
view_filter = function(self, selected, to_select)
local reason=sgs.Sanguosha:getCurrentCardUseReason()
return not to_select:isEquipped() and (reason == sgs.CardUseStruct_CARD_USE_REASON_RESPONSE or reason == sgs.CardUseStruct_CARD_USE_REASON_RESPONSE_USE)
end ,
view_as = function(self, cards)
local reason=sgs.Sanguosha:getCurrentCardUseReason()
if reason == sgs.CardUseStruct_CARD_USE_REASON_RESPONSE or reason == sgs.CardUseStruct_CARD_USE_REASON_RESPONSE_USE then
if sgs.Sanguosha:getCurrentCardUsePattern() == "@@danshen" then
local pattern = sgs.Self:property("danshenPattern"):toString()
local c = sgs.Sanguosha:cloneCard(pattern, sgs.Card_SuitToBeDecided, 0)
if c and #cards == 2 then
c:setSkillName(self:objectName())
c:addSubcard(cards[1])
c:addSubcard(cards[2])
return c
else
return nil
end
elseif #cards==2 then
local card = danshenResponse:clone()
card:setUserString(sgs.Sanguosha:getCurrentCardUsePattern())
card:addSubcard(cards[1])
card:addSubcard(cards[2])
return card
end
elseif #cards == 0 then
return danshenCard:clone()
end
end ,
enabled_at_play = function(self, player)
if player:getHandcardNum() < 2 then return false end
local patterns = {"slash","jink", "peach"}
if not isStandard() then
table.insert(patterns, "analeptic")
end
for _, cd in ipairs(patterns) do
local card = sgs.Sanguosha:cloneCard(cd, sgs.Card_NoSuit, 0)
if card then
card:deleteLater()
if card:isAvailable(player) then
return true
end
end
end
return false
end ,
enabled_at_response = function(self, player, pattern)
if pattern=="@@danshen" then return player:getHandcardNum() >= 2 end
return (player:getHandcardNum() >= 2)
and (string.find(pattern, "slash") or string.find(pattern, "analeptic") or string.find(pattern, "jink") or string.find(pattern, "peach"))
end
}

表白

当其他角色受到伤害后,若伤害来源不为你,你可以交给其一张牌并弃掉所有其他角色的“爱”标记,然后你其各获得一个“爱”标记。

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
biaobai = sgs.CreateTriggerSkill{
name = "biaobai",
events = {sgs.Damaged},
on_trigger = function(self, event, player, data)
local room = player:getRoom()
local damage = data:toDamage()
local mark="@aiMark"
local syly = room:findPlayerBySkillName(self:objectName())
if not syly then return end
if damage.from and damage.from:hasSkill(self:objectName()) then return false end
if syly:getCardCount(true)>0 and syly:askForSkillInvoke(self:objectName()) then
card = room:askForExchange(syly, self:objectName(), 1, 1, true, "biaobaiGive::"..player:objectName(),true)
if card and card:subcardsLength()>0 then
local reason = sgs.CardMoveReason(sgs.CardMoveReason_S_REASON_GIVE, syly:objectName(),
player:objectName(), self:objectName(), nil)
reason.m_playerId = player:objectName()
room:moveCardTo(card, syly, player, sgs.Player_PlaceHand, reason)
for _, p in sgs.qlist(room:getOtherPlayers(syly)) do
p:loseAllMarks(mark)
end
syly:gainMark(mark)
player:gainMark(mark)
end
end
return false
end,
can_trigger = function(self, target)
return target and target:isAlive() and not target:hasSkill(self:objectName())
end
}

["biaobaiGive"]="请交给 %dest 1 张牌",

脱单

觉醒技 当伤害结算完毕时,若你的“爱”标记不少于3个,你增加一点体力上限并回复一点体力,失去技能“单身”、“表白”并获得技能“相爱”。

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
tuodan = sgs.CreateTriggerSkill{
name = "tuodan",
events = {sgs.DamageComplete},
frequency = sgs.Skill_Wake,
on_trigger = function(self, event, player, data)
local room = player:getRoom()
local mark="@aiMark"
local syly = room:findPlayerBySkillName(self:objectName())
if not syly then return end
if syly:getMark(mark)>=3 and syly:getMark("tuodanWake")==0 then
room:doSuperLightbox(syly:getGeneralName(),self:objectName())
room:setPlayerMark(syly,"tuodanWake", 1)
local n=syly:getGeneralMaxHp()
syly:loseSkill("danshen")
syly:loseSkill("biaobai")
syly:acquireSkill("xiangai")
local isSecondaryHero = not (sgs.Sanguosha:getGeneral(syly:getGeneralName()):hasSkill(self:objectName()))
room:changeHero(syly, "spyly", false, true,isSecondaryHero, false)
syly:setMaxHp(n)
room:changeMaxHpForAwakenSkill(syly,1)
room:recover(syly, sgs.RecoverStruct(syly))
for _, p in sgs.qlist(room:getOtherPlayers(syly)) do
if p:getMark(mark)>0 then
sgs.updateIntention(syly, p, -150)
break
end
end
end
return false
end,
can_trigger = function(self, target)
return target
end
}

相爱

每当有“爱”标记的角色即将受到伤害时,另一名有“爱”标记的角色可以失去一点体力,然后防止此伤害。

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
xiangai = sgs.CreateTriggerSkill{
name = "xiangai",
frequency = sgs.Skill_NotFrequent,
events = {sgs.DamageInflicted},
priority={0},
on_trigger = function(self, event, player, data)
local room = player:getRoom()
local another
for _, p in sgs.qlist(room:getOtherPlayers(player)) do
if p:getMark("@aiMark")>0 then
another=p
break
end
end
local damage=data:toDamage()
local nature="normal"
if damage.nature ~= sgs.DamageStruct_Normal then nature="unnormal" end
local datatable = {"help",player:objectName(),tostring(damage.damage),nature}
if another and damage and damage.damage>0
and room:askForSkillInvoke(another,self:objectName(),sgs.QVariant(table.concat(datatable,":"))) then
room:loseHp(another,1)
local log2 = sgs.LogMessage()
log2.type = "#xiangai:log"
log2.from = player
room:sendLog(log2)
return true
end
return false
end,
can_trigger = function(self, target)
return target and target:isAlive() and target:getMark("@aiMark")>0
end
}

["xiangai:help"] = "你可以失去一点体力,然后防止 %src 受到此伤害。",
["#xiangai:log"] = "%from 受到的伤害被防止。",

相关AI:

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
local getCmpHp = function(p,self)
local hp = p:getHp()
if p:isLord() and self:isWeak(p) then hp = hp - 4
elseif self:isWeak(p) then hp = hp-2 end
if p:hasSkill("qingnang") then hp = hp - 5 end
if p:hasSkill("buqu") or p:hasSkill("nosbuqu") then hp = hp + 4 end
if p:hasSkills("nosrende|rende|kuanggu|kofkuanggu|zaiqi") and p:getHp() >= 2 then hp = hp + 1 end
if p:hasSkills("yinghun|nosmiji|miji|ganlu|shangshi|nosshangshi") and not self:isWeak(p) then hp = hp+2 end
if p:hasSkill("hunzi") and p:getHp()==2 then hp = hp +5 end
if p:hasSkill("longhun") and p:getHandcardNum()>2 and p:getHp()>1 then hp=hp+6 end
return hp
end

sgs.ai_skill_invoke["xiangai"] = function(self,data)
local promptlist = data:toString():split(":")
local to = findPlayerByObjectName(self.room, promptlist[2])
--local room = to:getRoom()
local damage = tonumber(promptlist[3])
local nature = promptlist[4]
local n=0
if not to:isWounded() and nature=="nature" and damage==1 then return false end
if nature~="nature" and to:isChained() then
for _, aplayer in sgs.qlist(self.room:getAllPlayers()) do
if aplayer:isChained() then
if self:isFriend(aplayer) then
n=n+1
else
n=n-1
end
end
end
damage=damage*n
elseif not self:isFriend(to) then
return false
end
if damage<=0 then return false end
myhp=getCmpHp(self.player,self)+2*(damage-1)
hishp=getCmpHp(to,self)

return myhp>hishp
end

7号武将

3体力 女性 神

专权

出牌阶段,你可以将一些牌置于武将牌上,称为“權”。锁定技 你的回合内,其他角色不能使用或打出与“權”同名的手牌。
(为了不与钟会的技能冲突,将“权”写成繁体字以示区分)

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
zhuanquanMod = sgs.CreateTriggerSkill{
name = "#zhuanquanMod",
events = {sgs.EventPhaseChanging,sgs.EventLoseSkill},
frequency = sgs.Skill_Compulsory,
on_trigger = function(self, event, player, data)
local room = player:getRoom()
if event == sgs.EventPhaseChanging then
local change = data:toPhaseChange()
if change.to == sgs.Player_Start and player:getPile("quanMod"):length()>0 then
room:sendCompulsoryTriggerLog(player, "zhuanquan")
local zhuan = player:getPile("quanMod")
for _,id in sgs.qlist(zhuan) do
local cd = sgs.Sanguosha:getCard(id)
local name = cardName(cd)
if not player:hasFlag("zhuanquan:"..name) then
for _, p in sgs.qlist(room:getOtherPlayers(player)) do
room:setPlayerCardLimitation(p, "use,response", name.."|.|.|hand", false)
end
room:setPlayerFlag(player,"zhuanquan:"..name)
end
end
elseif change.to == sgs.Player_NotActive then
local flags = player:getFlags()
local flagtable = flags:split("|")
for _, flag in ipairs(flagtable) do
local t = flag:split(":")
if t[1] == "zhuanquan" then
for _, p in sgs.qlist(room:getOtherPlayers(player)) do
room:removePlayerCardLimitation(p, "use,response", t[2].."|.|.|hand$0")
end
end
end
end
elseif data:toString() == "zhuanquan" then
local flags = player:getFlags()
local flagtable = flags:split("|")
for _, flag in ipairs(flagtable) do
local t = flag:split(":")
if t[1] == "zhuanquan" then
for _, p in sgs.qlist(room:getOtherPlayers(player)) do
room:removePlayerCardLimitation(p, "use,response", t[2].."|.|.|hand$0")
end
end
end
end
return false
end
}
zhuanquanCard = sgs.CreateSkillCard{
name = "zhuanquan" ,
will_throw = false ,
target_fixed = true ,
on_use = function(self, room, source, targets)
source:addToPile("quanMod", self, true)
local zhuan = source:getPile("quanMod")
for _,id in sgs.qlist(zhuan) do
local cd = sgs.Sanguosha:getCard(id)
local name = cardName(cd)
if not source:hasFlag("zhuanquan:"..name) then
for _, p in sgs.qlist(room:getOtherPlayers(source)) do
room:setPlayerCardLimitation(p, "use,response", name.."|.|.|hand", false)
end
room:setPlayerFlag(source,"zhuanquan:"..name)
end
end
room:sendCompulsoryTriggerLog(source, "zhuanquan")
end
}

zhuanquan = sgs.CreateViewAsSkill{
name = "zhuanquan",
n = 999,
view_filter = function(self, selected, to_select)
return true
end,
view_as = function(self, cards)
if #cards > 0 then
local zhuanquan_card = zhuanquanCard:clone()
for _,card in pairs(cards) do
zhuanquan_card:addSubcard(card)
end
return zhuanquan_card
end
end
}

谋利

锁定技 弃牌阶段结束时,若你武将牌上有“權”,你须进行一次判定,然后弃掉所有与判定牌同类型的“權”并摸X张牌(X为弃置的“權”的数量且至多为2)。

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
mouli = sgs.CreateTriggerSkill{
name = "mouli",
events = {sgs.EventPhaseChanging},
frequency = sgs.Skill_Compulsory,
on_trigger = function(self, event, player, data)
local room = player:getRoom()
if event == sgs.EventPhaseChanging then
local change = data:toPhaseChange()
if change.to == sgs.Player_NotActive and player:getPile("quanMod"):length()>0 then
room:sendCompulsoryTriggerLog(player, self:objectName())
local judge = sgs.JudgeStruct()
judge.pattern = "."
judge.good=true
judge.reason=self:objectName()
judge.who=player
room:judge(judge)
local zhuan = player:getPile("quanMod")
local n = 0
local dummy = sgs.Sanguosha:cloneCard("slash", sgs.Card_NoSuit, 0)
for _,id in sgs.qlist(zhuan) do
cd = sgs.Sanguosha:getCard(id)
if cd:getTypeId() == judge.card:getTypeId() then
dummy:addSubcard(cd)
n=n+1
end
end
local reason = sgs.CardMoveReason(sgs.CardMoveReason_S_REASON_THROW, player:objectName(), self:objectName(),"")
if n>0 then
room:throwCard(dummy, reason, nil)
if n>2 then n=2 end
player:drawCards(n)
end
dummy:deleteLater()
end
end
return false
end
}

8号武将

4体力 男性 神

剑道

锁定技 你每使用或打出一张基本牌或锦囊牌时,获得一个“易”标记;你与其他角色计算相互的距离-X(X为“易”的数量的一半,向下取整)。

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
jiandao = sgs.CreateTriggerSkill{
name = "jiandao",
frequency = sgs.Skill_Compulsory,
events = {sgs.CardResponded,sgs.CardUsed},
on_trigger = function(self, event, player, data)
local room = player:getRoom()
local mark = "@yiMark"
local flag = "lianjiFlag"
local card
if event==sgs.CardResponded then
card = data:toCardResponse().m_card
elseif event==sgs.CardUsed then
card = data:toCardUse().card
end
if card then
if player:hasFlag(flag) then
player:setFlags("-"..flag)
elseif (card:isKindOf("BasicCard") or card:isKindOf("TrickCard")) then
player:gainMark(mark)
end
end
return false
end
}
jiandaoDist = sgs.CreateDistanceSkill{
name = "#jiandaoDist" ,
correct_func = function(self, from, to)
return -math.floor((from:getMark("@yiMark")+to:getMark("@yiMark"))/2)
end
}

extension:insertRelatedSkills("jiandao","#jiandaoDist")

["@yiMark"]="易",

连击

锁定技 你每次使用【杀】或除【无懈可击】之外的非延时锦囊结算完后,若你的“易”标记不少于你的体力上限,你弃掉所有标记,然后此牌进行一次额外的合法结算。

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
function canUse(use)
local card = use.card
for _, p in sgs.qlist(use.to) do
if not p:isAlive() or (use.card:isKindOf("Collateral") and not p:getWeapon())
or ((use.card:isKindOf("Snatch") or use.card:isKindOf("Dismantlement")) and p:getCardCount(true,true)==0)
or (use.card:isKindOf("FireAttack") and p:getCardCount(false)==0) then
use.to:removeOne(p)
end
end
return not use.to:isEmpty()
end

luaLianji = sgs.CreateTriggerSkill{
name = "luaLianji",
frequency = sgs.Skill_Compulsory,
events = {sgs.CardFinished,sgs.SlashEffected},
on_trigger = function(self, event, player, data)
local room = player:getRoom()
local mark = "@yiMark"
local flag = "lianjiFlag"
if event == sgs.CardFinished then
local use = data:toCardUse()
local card = use.card
if player:getMark(mark)>=player:getMaxHp() and (card:isKindOf("Slash") or (card:isNDTrick() and not card:isKindOf("Nullification"))) then
room:getThread():delay()
room:sendCompulsoryTriggerLog(player, self:objectName())
player:loseAllMarks(mark)
player:setFlags(flag)
if canUse(use) then
if use.card:isKindOf("Slash") then
player:setFlags("lianjiSlash")
end
room:useCard(use)
end
end
else
local effect = data:toSlashEffect()
if effect.from:hasFlag("lianjiSlash") then
effect.drank=0
data:setValue(effect)
effect.from:setFlags("-lianjiSlash")
end
end
return false
end,
can_trigger = function(self, target)
return target and target:isAlive()
end
}

α突袭

觉醒技 准备阶段开始时,若你计算与所有其他角色距离为1,你失去1点体力上限,然后摸X张牌并弃掉所有“易”标记(X为“易”的数量且至多为2)。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
alphatuxi = sgs.CreateTriggerSkill{
name = "alphatuxi",
frequency = sgs.Skill_Wake,
events = {sgs.EventPhaseStart},
on_trigger = function(self, event, player, data)
local room = player:getRoom()
if player:getPhase()==sgs.Player_Start and player:getMark("yiWake")==0 and isAllAdjacent(player)
and room:changeMaxHpForAwakenSkill(player) then
room:doSuperLightbox(player:objectName(),self:objectName())
if player:getMark("@yiMark")>0 then
room:getThread():delay()
player:drawCards(math.min(player:getMark("@yiMark"), 2))
player:loseAllMarks("@yiMark")
end
room:setPlayerMark(player,"yiWake", 1)
end
return false
end
}