luaqicecard = sgs.CreateSkillCard
{
name = "luaqicecard",
target_fixed = true,
will_throw = false,
on_use = function(self,room,source,targets)
local choice = room:askForChoice(source,self:objectName(),"snatch+dismantlement+collateral+ex_nihilo+duel+fire_attack+amazing_grace+savage_assault+archery_attack+god_salvation+iron_chain")
room:setPlayerFlag(source,"luaqice"..choice)
if room:askForUseCard(source,"@@luaqice","@luaqice") then
--room:loseHp(source)
room:setPlayerFlag(source,"luaqicecardused")
end
room:setPlayerFlag(source,"-luaqice"..choice)
end
}
function trickjudging(player)
local choice = nil
local from = {"snatch","dismantlement","collateral","ex_nihilo","duel","fire_attack","amazing_grace","savage_assault","archery_attack","god_salvation","iron_chain"}
for _,i in pairs(from) do
if player:hasFlag("luaqice"..i) then
choice = i
break
end
end
return choice
end
luaqicevs = sgs.CreateViewAsSkill
{
name = "luaqice",
n = 0,
view_as = function(self,cards)
local player = sgs.Self
local choice = trickjudging(player)
local card
if not choice then
card = luaqicecard:clone()
else
card = sgs.Sanguosha:cloneCard(choice,sgs.Card_NoSuit,0)
card:setSkillName(self:objectName())
end
return card
end,
enabled_at_play = function()
return not sgs.Self:hasFlag("luaqicecardused")
end,
enabled_at_response = function(pattern)
return pattern == "@@luaqice"
end
}
luaqice = sgs.CreateTriggerSkill
{
name = "luaqice",
events = {sgs.EventPhaseChanging,sgs.CardUsed},
view_as_skill = luaqicevs,
on_trigger = function(self,event,player,data)
local room = player:getRoom()
if event == sgs.EventPhaseChanging then
local change = data:toPhaseChange()
if change.from == sgs.Player_Play then
if player:hasFlag("luaqicecardused") then
room:setPlayerFlag(player,"-luaqicecardused")
end
end
end
if event == sgs.CardUsed then
if player:hasFlag("luaqiceusing") then return false end
local use = data:toCardUse()
if use.card:getSkillName() == self:objectName() then
room:setPlayerFlag(player,"luaqiceusing")
for _,id in sgs.qlist(player:handCards()) do
use.card:addSubcard(id)
end
room:useCard(use)
room:setPlayerFlag(player,"-luaqiceusing")
return true
end
end
end
}