Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update ChapterE.lua #41

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 28 additions & 30 deletions ChapterE.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,57 +7,55 @@
技能名:恩怨
相关武将:一将成名·法正
描述:你每次获得一名其他角色两张或更多的牌时,可以令其摸一张牌;每当你受到1点伤害后,你可以令伤害来源选择一项:交给你一张手牌,或失去1点体力。
引用:LuaEnyuan
状态:1217验证通过
引用:LuaEnyuan, findPlayerByName
状态:0504验证通过
]]--

function findPlayerByName(room, name)
for _, p in sgs.qlist(room:getAllPlayers()) do
if p:objectName() == name then
return p
end
end
end

LuaEnyuan = sgs.CreateTriggerSkill{
name = "LuaEnyuan" ,
events = {sgs.CardsMoveOneTime, sgs.Damaged} ,
on_trigger = function(self, event, player, data)
local room = player:getRoom()
if event == sgs.CardsMoveOneTime then
local move = data:toMoveOneTime()
if move.to and (move.to:objectName() == player:objectName()) and move.from and move.from:isAlive()
and (move.from:objectName() ~= move.to:objectName())
and (move.card_ids:length() >= 2)
and (move.reason.m_reason ~= sgs.CardMoveReason_S_REASON_PREVIEWGIVE) then
local _movefrom
for _, p in sgs.qlist(room:getAlivePlayers()) do
if move.from:objectName() == p:objectName() then
_movefrom = p
break
end
end --我去MoveOneTime的from居然是player不是splayer,还得枚举所有splayer获取下……
if move.to:objectName() == player:objectName() and move.from and move.from:isAlive()
and move.from:objectName() ~= move.to:objectName()
and move.card_ids:length() >= 2
and move.reason.m_reason ~= sgs.CardMoveReason_S_REASON_PREVIEWGIVE
and (move.to_place == sgs.Player_PlaceHand or move.to_place == sgs.Player_PlaceEquip) then
local _movefrom = findPlayerByName(room, move.from:objectName())
_movefrom:setFlags("LuaEnyuanDrawTarget")
local invoke = room:askForSkillInvoke(player, self:objectName(), data)
_movefrom:setFlags("-LuaEnyuanDrawTarget")
if invoke then
room:drawCards(_movefrom, 1)
room:drawCards(_movefrom, 1, self:objectName())
end
end
elseif event == sgs.Damaged then
local damage = data:toDamage()
local source = damage.from
if (not source) or (source:objectName() == player:objectName()) then return false end
if (not source or source:objectName() == player:objectName()) then return false end
local x = damage.damage
for i = 0, x - 1, 1 do
if source:isAlive() and player:isAlive() then
if room:askForSkillInvoke(player, self:objectName(), data) then
local card
if not source:isKongcheng() then
card = room:askForExchange(source, self:objectName(), 1, false, "LuaEnyuanGive", true)
end
if card then
local reason = sgs.CardMoveReason(sgs.CardMoveReason_S_REASON_GIVE, source:objectName(),
player:objectName(), self:objectName(), nil)
reason.m_playerId = player:objectName()
room:moveCardTo(card, source, player, sgs.Player_PlaceHand, reason)
else
room:loseHp(source)
end
if source:isAlive() and player:isAlive() and room:askForSkillInvoke(player, self:objectName(), data) then
local card
if not source:isKongcheng() then
card = room:askForExchange(source, self:objectName(), 1, 1, false, "LuaEnyuanGive::"..player:objectName(), true)
end
if card then
local reason = sgs.CardMoveReason(sgs.CardMoveReason_S_REASON_GIVE, source:objectName(),player:objectName(), self:objectName(), nil)
reason.m_playerId = player:objectName()
room:moveCardTo(card, source, player, sgs.Player_PlaceHand, reason)
else
break
room:loseHp(source)
end
else
break
Expand Down