card_mark (#124)
试着增加了card_mark,如果顺利希望后续能在前端对@和@@整特效 例如@@开头的就是那种只有特定文字写在卡牌下方的标记牌 有个展望是和playermark类似,后续根据进入弃牌堆/进入其他区域/进入其他玩家手里决定是否删除对应mark。 同时本版本存在standard_card对AOE的一些修改,不过N神你之前要的那个恕我菜菜,合不起来···
This commit is contained in:
parent
7309dbfb6f
commit
d763929544
|
@ -557,6 +557,17 @@ fk.client_callback["SetPlayerMark"] = function(jsonData)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
fk.client_callback["SetCardMark"] = function(jsonData)
|
||||||
|
-- jsonData: [ int id, string mark, int value ]
|
||||||
|
local data = json.decode(jsonData)
|
||||||
|
local card, mark, value = data[1], data[2], data[3]
|
||||||
|
ClientInstance:getCardById(card):setMark(mark, value)
|
||||||
|
|
||||||
|
if string.sub(mark, 1, 1) == "@" then
|
||||||
|
ClientInstance:notifyUI("SetCardMark", jsonData)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
fk.client_callback["Chat"] = function(jsonData)
|
fk.client_callback["Chat"] = function(jsonData)
|
||||||
-- jsonData: { int type, int sender, string msg }
|
-- jsonData: { int type, int sender, string msg }
|
||||||
local data = json.decode(jsonData)
|
local data = json.decode(jsonData)
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
---@field public type CardType @ 卡牌的种类(基本牌、锦囊牌、装备牌)
|
---@field public type CardType @ 卡牌的种类(基本牌、锦囊牌、装备牌)
|
||||||
---@field public sub_type CardSubtype @ 卡牌的子种类(例如延时锦囊牌、武器、防具等)
|
---@field public sub_type CardSubtype @ 卡牌的子种类(例如延时锦囊牌、武器、防具等)
|
||||||
---@field public area CardArea @ 卡牌所在区域(例如手牌区,判定区,装备区,牌堆,弃牌堆···)
|
---@field public area CardArea @ 卡牌所在区域(例如手牌区,判定区,装备区,牌堆,弃牌堆···)
|
||||||
|
---@field public mark table<string, integer> @ 当前拥有的所有标记,用烂了
|
||||||
---@field public subcards integer[]
|
---@field public subcards integer[]
|
||||||
---@field public skillName string @ for virtual cards
|
---@field public skillName string @ for virtual cards
|
||||||
---@field public skillNames string[]
|
---@field public skillNames string[]
|
||||||
|
@ -93,6 +94,7 @@ function Card:initialize(name, suit, number, color)
|
||||||
self.skillName = nil -- ""
|
self.skillName = nil -- ""
|
||||||
self._skillName = ""
|
self._skillName = ""
|
||||||
self.skillNames = {}
|
self.skillNames = {}
|
||||||
|
self.mark = {}
|
||||||
|
|
||||||
local mt = table.simpleClone(getmetatable(self))
|
local mt = table.simpleClone(getmetatable(self))
|
||||||
local newidx = mt.__newindex or rawset
|
local newidx = mt.__newindex or rawset
|
||||||
|
@ -281,6 +283,55 @@ local function getNumberStr(num)
|
||||||
return tostring(num)
|
return tostring(num)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- 为卡牌赋予Mark。
|
||||||
|
---@param mark string @ 标记
|
||||||
|
---@param count integer @ 为标记赋予的数量
|
||||||
|
-- mark name and UI:
|
||||||
|
-- 'xxx': invisible mark
|
||||||
|
-- '@mark': mark with extra data (maybe string or number)
|
||||||
|
-- '@@mark': mark without data
|
||||||
|
function Card:addMark(mark, count)
|
||||||
|
count = count or 1
|
||||||
|
local num = self.mark[mark]
|
||||||
|
num = num or 0
|
||||||
|
self:setMark(mark, math.max(num + count, 0))
|
||||||
|
end
|
||||||
|
|
||||||
|
--- 为卡牌移除Mark。
|
||||||
|
---@param mark string @ 标记
|
||||||
|
---@param count integer @ 为标记删除的数量
|
||||||
|
function Card:removeMark(mark, count)
|
||||||
|
count = count or 1
|
||||||
|
local num = self.mark[mark]
|
||||||
|
num = num or 0
|
||||||
|
self:setMark(mark, math.max(num - count, 0))
|
||||||
|
end
|
||||||
|
|
||||||
|
--- 为卡牌设置Mark至指定数量。
|
||||||
|
---@param mark string @ 标记
|
||||||
|
---@param count integer @ 为标记删除的数量
|
||||||
|
function Card:setMark(mark, count)
|
||||||
|
if self.mark[mark] ~= count then
|
||||||
|
self.mark[mark] = count
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
--- 获取卡牌对应Mark的数量。
|
||||||
|
---@param mark string @ 标记
|
||||||
|
---@param count integer @ 为标记删除的数量
|
||||||
|
function Card:getMark(mark)
|
||||||
|
return (self.mark[mark] or 0)
|
||||||
|
end
|
||||||
|
|
||||||
|
--- 获取卡牌有哪些Mark。
|
||||||
|
function Card:getMarkNames()
|
||||||
|
local ret = {}
|
||||||
|
for k, _ in pairs(self.mark) do
|
||||||
|
table.insert(ret, k)
|
||||||
|
end
|
||||||
|
return ret
|
||||||
|
end
|
||||||
|
|
||||||
-- for sendLog
|
-- for sendLog
|
||||||
--- 获取卡牌的文字信息并准备作为log发送。
|
--- 获取卡牌的文字信息并准备作为log发送。
|
||||||
function Card:toLogString()
|
function Card:toLogString()
|
||||||
|
|
|
@ -358,6 +358,44 @@ function Room:removePlayerMark(player, mark, count)
|
||||||
self:setPlayerMark(player, mark, math.max(num - count, 0))
|
self:setPlayerMark(player, mark, math.max(num - count, 0))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- 将一张卡牌的某种标记数量相应的值。
|
||||||
|
---
|
||||||
|
--- 在设置之后,会通知所有客户端也更新一下标记的值。之后的两个相同
|
||||||
|
---@param card Card @ 要被更新标记的那张牌
|
||||||
|
---@param mark string @ 标记的名称
|
||||||
|
---@param value integer @ 要设为的值,其实也可以设为字符串
|
||||||
|
function Room:setCardMark(card, mark, value)
|
||||||
|
card:setMark(mark, value)
|
||||||
|
self:doBroadcastNotify("SetCardMark", json.encode{
|
||||||
|
card.id,
|
||||||
|
mark,
|
||||||
|
value
|
||||||
|
})
|
||||||
|
end
|
||||||
|
|
||||||
|
--- 将一张卡牌的mark标记增加count个。
|
||||||
|
---@param card Card @ 要被增加标记的那张牌
|
||||||
|
---@param mark string @ 标记名称
|
||||||
|
---@param count integer | nil @ 要增加的数量,默认为1
|
||||||
|
function Room:addCardMark(card, mark, count)
|
||||||
|
count = count or 1
|
||||||
|
local num = card:getMark(mark)
|
||||||
|
num = num or 0
|
||||||
|
self:setCardMark(card, mark, math.max(num + count, 0))
|
||||||
|
end
|
||||||
|
|
||||||
|
--- 将一名玩家的mark标记减少count个。
|
||||||
|
---@param card Card @ 要被减少标记的那张牌
|
||||||
|
---@param mark string @ 标记名称
|
||||||
|
---@param count integer | nil @ 要减少的数量,默认为1
|
||||||
|
function Room:removeCardMark(card, mark, count)
|
||||||
|
count = count or 1
|
||||||
|
local num = card:getMark(mark)
|
||||||
|
num = num or 0
|
||||||
|
self:setCardMark(card, mark, math.max(num - count, 0))
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
--- 将房间中某个tag设为特定值。
|
--- 将房间中某个tag设为特定值。
|
||||||
---
|
---
|
||||||
--- 当在编程中想在服务端搞点全局变量的时候哦,不要自己设置全局变量或者上值,而是应该使用room的tag。
|
--- 当在编程中想在服务端搞点全局变量的时候哦,不要自己设置全局变量或者上值,而是应该使用room的tag。
|
||||||
|
@ -919,7 +957,6 @@ function Room:askForDiscard(player, minNum, maxNum, includeEquip, skillName, can
|
||||||
pattern = pattern,
|
pattern = pattern,
|
||||||
}
|
}
|
||||||
local prompt = prompt or ("#AskForDiscard:::" .. maxNum .. ":" .. minNum)
|
local prompt = prompt or ("#AskForDiscard:::" .. maxNum .. ":" .. minNum)
|
||||||
|
|
||||||
local _, ret = self:askForUseActiveSkill(player, "discard_skill", prompt, cancelable, data)
|
local _, ret = self:askForUseActiveSkill(player, "discard_skill", prompt, cancelable, data)
|
||||||
|
|
||||||
if ret then
|
if ret then
|
||||||
|
|
|
@ -3,6 +3,28 @@
|
||||||
local extension = Package:new("standard_cards", Package.CardPack)
|
local extension = Package:new("standard_cards", Package.CardPack)
|
||||||
extension.metadata = require "packages.standard_cards.metadata"
|
extension.metadata = require "packages.standard_cards.metadata"
|
||||||
|
|
||||||
|
local global_on_use = function(self, room, cardUseEvent)
|
||||||
|
if not cardUseEvent.tos or #TargetGroup:getRealTargets(cardUseEvent.tos) == 0 then
|
||||||
|
cardUseEvent.tos = {}
|
||||||
|
for _, player in ipairs(room:getAlivePlayers()) do
|
||||||
|
if not room:getPlayerById(cardUseEvent.from):isProhibited(player, cardUseEvent.card) then
|
||||||
|
TargetGroup:pushTargets(cardUseEvent.tos, player.id)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local aoe_on_use = function(self, room, cardUseEvent)
|
||||||
|
if not cardUseEvent.tos or #TargetGroup:getRealTargets(cardUseEvent.tos) == 0 then
|
||||||
|
cardUseEvent.tos = {}
|
||||||
|
for _, player in ipairs(room:getOtherPlayers(room:getPlayerById(cardUseEvent.from))) do
|
||||||
|
if not room:getPlayerById(cardUseEvent.from):isProhibited(player, cardUseEvent.card) then
|
||||||
|
TargetGroup:pushTargets(cardUseEvent.tos, player.id)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
local slashSkill = fk.CreateActiveSkill{
|
local slashSkill = fk.CreateActiveSkill{
|
||||||
name = "slash_skill",
|
name = "slash_skill",
|
||||||
max_phase_use_time = 1,
|
max_phase_use_time = 1,
|
||||||
|
@ -419,14 +441,7 @@ extension:addCards({
|
||||||
|
|
||||||
local savageAssaultSkill = fk.CreateActiveSkill{
|
local savageAssaultSkill = fk.CreateActiveSkill{
|
||||||
name = "savage_assault_skill",
|
name = "savage_assault_skill",
|
||||||
on_use = function(self, room, cardUseEvent)
|
on_use = aoe_on_use,
|
||||||
if not cardUseEvent.tos or #TargetGroup:getRealTargets(cardUseEvent.tos) == 0 then
|
|
||||||
cardUseEvent.tos = {}
|
|
||||||
for _, player in ipairs(room:getOtherPlayers(room:getPlayerById(cardUseEvent.from))) do
|
|
||||||
TargetGroup:pushTargets(cardUseEvent.tos, player.id)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end,
|
|
||||||
on_effect = function(self, room, effect)
|
on_effect = function(self, room, effect)
|
||||||
local cardResponded = nil
|
local cardResponded = nil
|
||||||
if not (effect.disresponsive or table.contains(effect.disresponsiveList or {}, effect.to)) then
|
if not (effect.disresponsive or table.contains(effect.disresponsiveList or {}, effect.to)) then
|
||||||
|
@ -467,14 +482,7 @@ extension:addCards({
|
||||||
|
|
||||||
local archeryAttackSkill = fk.CreateActiveSkill{
|
local archeryAttackSkill = fk.CreateActiveSkill{
|
||||||
name = "archery_attack_skill",
|
name = "archery_attack_skill",
|
||||||
on_use = function(self, room, cardUseEvent)
|
on_use = aoe_on_use,
|
||||||
if not cardUseEvent.tos or #TargetGroup:getRealTargets(cardUseEvent.tos) == 0 then
|
|
||||||
cardUseEvent.tos = {}
|
|
||||||
for _, player in ipairs(room:getOtherPlayers(room:getPlayerById(cardUseEvent.from))) do
|
|
||||||
TargetGroup:pushTargets(cardUseEvent.tos, player.id)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end,
|
|
||||||
on_effect = function(self, room, effect)
|
on_effect = function(self, room, effect)
|
||||||
local cardResponded = nil
|
local cardResponded = nil
|
||||||
if not (effect.disresponsive or table.contains(effect.disresponsiveList or {}, effect.to)) then
|
if not (effect.disresponsive or table.contains(effect.disresponsiveList or {}, effect.to)) then
|
||||||
|
@ -513,14 +521,7 @@ extension:addCards({
|
||||||
|
|
||||||
local godSalvationSkill = fk.CreateActiveSkill{
|
local godSalvationSkill = fk.CreateActiveSkill{
|
||||||
name = "god_salvation_skill",
|
name = "god_salvation_skill",
|
||||||
on_use = function(self, room, cardUseEvent)
|
on_use = global_on_use,
|
||||||
if not cardUseEvent.tos or #TargetGroup:getRealTargets(cardUseEvent.tos) == 0 then
|
|
||||||
cardUseEvent.tos = {}
|
|
||||||
for _, player in ipairs(room:getAlivePlayers()) do
|
|
||||||
TargetGroup:pushTargets(cardUseEvent.tos, player.id)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end,
|
|
||||||
about_to_effect = function(self, room, effect)
|
about_to_effect = function(self, room, effect)
|
||||||
if not room:getPlayerById(effect.to):isWounded() then
|
if not room:getPlayerById(effect.to):isWounded() then
|
||||||
return true
|
return true
|
||||||
|
@ -547,14 +548,7 @@ extension:addCards({
|
||||||
|
|
||||||
local amazingGraceSkill = fk.CreateActiveSkill{
|
local amazingGraceSkill = fk.CreateActiveSkill{
|
||||||
name = "amazing_grace_skill",
|
name = "amazing_grace_skill",
|
||||||
on_use = function(self, room, cardUseEvent)
|
on_use = global_on_use,
|
||||||
if not cardUseEvent.tos or #TargetGroup:getRealTargets(cardUseEvent.tos) == 0 then
|
|
||||||
cardUseEvent.tos = {}
|
|
||||||
for _, player in ipairs(room:getAlivePlayers()) do
|
|
||||||
TargetGroup:pushTargets(cardUseEvent.tos, player.id)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end,
|
|
||||||
on_effect = function(self, room, effect)
|
on_effect = function(self, room, effect)
|
||||||
local to = room:getPlayerById(effect.to)
|
local to = room:getPlayerById(effect.to)
|
||||||
if not (effect.extra_data and effect.extra_data.AGFilled) then
|
if not (effect.extra_data and effect.extra_data.AGFilled) then
|
||||||
|
|
Loading…
Reference in New Issue