Paracel/QSanguosha-Para — pull request #12 by sxyizhiren (2014-06-07 22:03:06+00:00)
Title: add a global map to save player parameter

add a global map configuration to save player parameter. it is in order
to resolve a problem that: can not share Mark between "on_trigger" skill
and "residue_func" skill in lua code. below is my example:

--[[
一个无法实现的技能：
回合开始钱选择是否发动，若发动，则无限出杀，
我在on_trigger中设置的setMark在residue_func中无法getMark到，所以我实现的这个技能没法工作。
调试c++代码后发现on_trigger和residue_func中的该player虽然都表示同一个玩家，但是其this指针是不一样的，也就是存在两个player实例。所以mark无法共享 。
于是我只能增加一个全局变量来解决这个问题。
你看下是否有这个情况，有这个情况的话可以考虑合并之。
]]
module("extensions.testskill", package.seeall)
extension = sgs.Package("testskill")

test_player=sgs.General(extension, "test_player", "qun", "30")

luatestskill_modifykill = sgs.CreateTargetModSkill
{--
name = "#luatestskill_modifykill",
pattern = "Slash",
residue_func = function(self,player)
local skillstate = "luatestskill_state"
if player:hasSkill(self:objectName()) and (1==player:getMark(skillstate)) then
return 900
else
return 0
end
end
}

luatestskill = sgs.CreateTriggerSkill
{--
name = "luatestskill",
events = {sgs.AfterDrawNCards },

on_trigger = function(self, event, player, data)
local skillstate = "luatestskill_state"
if (room:askForSkillInvoke(player, "luatestskill")) then
player:setMark(skillstate, 1)
else
player:setMark(skillstate, 0)
end

end
}

test_player:addSkill(luatestskill)
test_player:addSkill(luatestskill_modifykill)

sgs.LoadTranslationTable{
["testskill"] = "测试技能",
}