1. 修复传入数组的extraPile无法收回
2. 被弃置牌的log添加操作者
3. beforeMaxHpChanged的num可以被修改
4. 额外回合增加skillName
5. 修复亮将技能和禁止亮将
6. 水一些注释和格式

---------

Signed-off-by: Mechanel <nyutanislavsky@qq.com>
This commit is contained in:
Nyutanislavsky 2024-02-04 15:30:27 +08:00 committed by GitHub
parent 58e76c1b9c
commit f72aaa23cf
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
13 changed files with 123 additions and 76 deletions

View File

@ -19,6 +19,7 @@ RowLayout {
property alias skillButtons: skillPanel.skill_buttons
property var expanded_piles: ({}) // name -> int[]
property var extra_cards: []
property var disabledSkillNames: []
@ -86,6 +87,7 @@ RowLayout {
footnote = "$Equip";
} else if (pile === "_extra") {
ids = extra_ids;
extra_cards = ids;
footnote = extra_footnote;
} else {
ids = lcall("GetPile", self.playerid, pile);
@ -122,7 +124,13 @@ RowLayout {
})
handcardAreaItem.updateCardPosition();
} else {
const ids = lcall("GetPile", self.playerid, pile);
let ids = [];
if (pile === "_extra") {
ids = extra_cards;
extra_cards = [];
} else {
ids = lcall("GetPile", self.playerid, pile);
}
ids.forEach(id => {
const card = handcardAreaItem.remove([id])[0];
card.origX = parentPos.x;

View File

@ -469,6 +469,7 @@ local function separateMoves(moves)
moveReason = move.moveReason,
specialName = move.specialName,
fromSpecialName = info.fromSpecialName,
proposer = move.proposer,
})
end
end
@ -480,9 +481,9 @@ local function mergeMoves(moves)
local ret = {}
local temp = {}
for _, move in ipairs(moves) do
local info = string.format("%q,%q,%q,%q,%s,%s",
local info = string.format("%q,%q,%q,%q,%s,%s,%q",
move.from, move.to, move.fromArea, move.toArea,
move.specialName, move.fromSpecialName)
move.specialName, move.fromSpecialName, move.proposer)
if temp[info] == nil then
temp[info] = {
ids = {},
@ -493,6 +494,7 @@ local function mergeMoves(moves)
moveReason = move.moveReason,
specialName = move.specialName,
fromSpecialName = move.fromSpecialName,
proposer = move.proposer,
}
end
table.insert(temp[info].ids, move.ids[1])
@ -504,7 +506,7 @@ local function mergeMoves(moves)
end
local function sendMoveCardLog(move)
local client = ClientInstance
local client = ClientInstance ---@class Client
if #move.ids == 0 then return end
local hidden = table.contains(move.ids, -1)
local msgtype
@ -607,12 +609,22 @@ local function sendMoveCardLog(move)
})
elseif move.toArea == Card.DiscardPile then
if move.moveReason == fk.ReasonDiscard then
client:appendLog{
type = "$DiscardCards",
from = move.from,
card = move.ids,
arg = #move.ids,
}
if move.proposer and move.proposer ~= move.from then
client:appendLog{
type = "$DiscardOther",
from = move.from,
to = {move.proposer},
card = move.ids,
arg = #move.ids,
}
else
client:appendLog{
type = "$DiscardCards",
from = move.from,
card = move.ids,
arg = #move.ids,
}
end
elseif move.moveReason == fk.ReasonPutIntoDiscardPile then
client:appendLog{
type = "$PutToDiscard",

View File

@ -344,6 +344,7 @@ Fk:loadTranslationTable({
["$LightningMove"] = "%card transfered from %from to %to",
["$PasteCard"] = "%from used %card to %to",
["$DiscardCards"] = "%from discarded %arg card(s) %card",
["$DiscardOther"] = "%to discarded %arg card(s) %card from %from",
["$InstallEquip"] = "%from equipped %card",
["$UninstallEquip"] = "%from uninstalled %card",

View File

@ -330,7 +330,7 @@ Fk:loadTranslationTable{
["fire_damage"] = "火属性",
["thunder_damage"] = "雷属性",
["ice_damage"] = "冰属性",
["hp_lost"] = "体力流失",
["hp_lost"] = "失去体力",
["lose_hp"] = "失去体力",
["phase_start"] = "准备阶段",
@ -412,6 +412,7 @@ Fk:loadTranslationTable{
["$PutCard"] = "%from 的 %arg 张牌被置于牌堆",
["$PutKnownCard"] = "%from 的牌 %card 被置于牌堆",
["$DiscardCards"] = "%from 弃置了 %arg 张牌 %card",
["$DiscardOther"] = "%to 弃置了 %from 的 %arg 张牌 %card",
["$PutToDiscard"] = "%arg 张牌 %card 被置入弃牌堆",
["#ShowCard"] = "%from 展示了牌 %card",

View File

@ -94,7 +94,8 @@ function General:addRelatedSkill(skill)
end
--- 获取武将所有技能。
---@param include_lord bool
---@param include_lord? boolean
---@return string[]
function General:getSkillNameList(include_lord)
local ret = {}
local other_skills = table.map(self.other_skills, Util.Name2SkillMapper)

View File

@ -45,8 +45,8 @@ end
---@param to_select integer @ id of the target
---@param selected integer[] @ ids of selected targets
---@param selected_cards integer[] @ ids of selected cards
---@param extra_data any @ extra_data
---@param card Card @ helper
---@param extra_data? any @ extra_data
function ActiveSkill:targetFilter(to_select, selected, selected_cards, card, extra_data)
return false
end

View File

@ -74,14 +74,14 @@ GameEvent.functions[GameEvent.ChangeHp] = function(self)
room:sendLog{
type = "#LoseHP",
from = player.id,
arg = 0 - num,
arg = 0 - data.num,
}
room:sendLogEvent("LoseHP", {})
elseif reason == "recover" then
room:sendLog{
type = "#HealHP",
from = player.id,
arg = num,
arg = data.num,
}
end
@ -290,12 +290,19 @@ end
GameEvent.functions[GameEvent.ChangeMaxHp] = function(self)
local player, num = table.unpack(self.data)
local room = self.room
if room.logic:trigger(fk.BeforeMaxHpChanged, player, { num = num }) or num == 0 then
---@type MaxHpChangedData
local data = {
num = num,
}
if room.logic:trigger(fk.BeforeMaxHpChanged, player, data) or data.num == 0 then
return false
end
player.maxHp = math.max(player.maxHp + num, 0)
room:broadcastProperty(player, "maxHp")
num = data.num
room:setPlayerProperty(player, "maxHp", math.max(player.maxHp + num, 0))
room:sendLogEvent("ChangeMaxHp", {
player = player.id,
num = num,

View File

@ -872,11 +872,11 @@ function Room:notifyMoveCards(players, card_moves, forceVisible)
if not (move.moveVisible or forceVisible or containArea(move.toArea, move.to and p.isBuddy and p:isBuddy(move.to))) then
for _, info in ipairs(move.moveInfo) do
if not containArea(info.fromArea, move.from == p.id) then
info.cardId = -1
info.cardId = -1
end
end
end
end
end
p:doNotify("MoveCards", json.encode(arg))
end
end
@ -1195,7 +1195,7 @@ function Room:askForDiscard(player, minNum, maxNum, includeEquip, skillName, can
toDiscard = ret.cards
else
if cancelable then return {} end
toDiscard = table.random(canDiscards, minNum)
toDiscard = table.random(canDiscards, minNum) ---@type integer[]
end
if not skipDiscard then
@ -1272,7 +1272,7 @@ function Room:askForCard(player, minNum, maxNum, includeEquip, skillName, cancel
pattern = pattern,
expand_pile = expand_pile,
}
local prompt = prompt or ("#AskForCard:::" .. maxNum .. ":" .. minNum)
prompt = prompt or ("#AskForCard:::" .. maxNum .. ":" .. minNum)
local _, ret = self:askForUseActiveSkill(player, "choose_cards_skill", prompt, cancelable, data, no_indicate)
if ret then
chosenCards = ret.cards
@ -2633,7 +2633,7 @@ function Room:doCardUseEffect(cardUseEvent)
return
end
---@type CardEffectEvent
---@class CardEffectEvent
local cardEffectEvent = {
from = cardUseEvent.from,
tos = cardUseEvent.tos,
@ -2916,7 +2916,8 @@ end
---@param cid integer|Card @ 要拿到的卡牌
---@param unhide? boolean @ 是否明着拿
---@param reason? CardMoveReason @ 卡牌移动的原因
function Room:obtainCard(player, cid, unhide, reason)
---@param proposer? integer @ 移动操作者的id
function Room:obtainCard(player, cid, unhide, reason, proposer)
if type(cid) ~= "number" then
assert(cid and cid:isInstanceOf(Card))
cid = cid:isVirtual() and cid.subcards or {cid.id}
@ -2935,7 +2936,7 @@ function Room:obtainCard(player, cid, unhide, reason)
to = player,
toArea = Card.PlayerHand,
moveReason = reason or fk.ReasonJustMove,
proposer = player,
proposer = proposer or player,
moveVisible = unhide or false,
})
end
@ -2987,7 +2988,6 @@ function Room:moveCardTo(card, to_place, target, reason, skill_name, special_nam
reason = reason or fk.ReasonJustMove
skill_name = skill_name or ""
special_name = special_name or ""
proposer = proposer or nil
local ids = Card:getIdList(card)
local to
@ -3587,6 +3587,10 @@ function Room:printCard(name, suit, number)
return cd
end
--- 刷新使命技状态
---@param player ServerPlayer
---@param skillName Suit
---@param failed? boolean
function Room:updateQuestSkillState(player, skillName, failed)
assert(Fk.skills[skillName].frequency == Skill.Quest)
@ -3600,6 +3604,9 @@ function Room:updateQuestSkillState(player, skillName, failed)
})
end
--- 废除区域
---@param player ServerPlayer
---@param playerSlots string | string[]
function Room:abortPlayerArea(player, playerSlots)
assert(type(playerSlots) == "string" or type(playerSlots) == "table")
@ -3652,6 +3659,9 @@ function Room:abortPlayerArea(player, playerSlots)
self.logic:trigger(fk.AreaAborted, player, { slots = slotsSealed })
end
--- 恢复区域
---@param player ServerPlayer
---@param playerSlots string | string[]
function Room:resumePlayerArea(player, playerSlots)
assert(type(playerSlots) == "string" or type(playerSlots) == "table")
@ -3675,6 +3685,9 @@ function Room:resumePlayerArea(player, playerSlots)
end
end
--- 设置休整
---@param player ServerPlayer
---@param roundNum integer
function Room:setPlayerRest(player, roundNum)
player.rest = roundNum
self:broadcastProperty(player, "rest")

View File

@ -630,15 +630,18 @@ function ServerPlayer:endPlayPhase()
-- TODO: send log
end
--- 获得一个额外回合
---@param delay? boolean
function ServerPlayer:gainAnExtraTurn(delay)
---@param skillName? string
function ServerPlayer:gainAnExtraTurn(delay, skillName)
local room = self.room
delay = (delay == nil) and true or delay
skillName = (skillName == nil) and room.logic:getCurrentSkillName() or skillName
if delay then
local logic = room.logic
local turn = logic:getCurrentEvent():findParent(GameEvent.Turn, true)
if turn then
turn:prependExitFunc(function() self:gainAnExtraTurn(false) end)
turn:prependExitFunc(function() self:gainAnExtraTurn(false, skillName) end)
return
end
end
@ -653,7 +656,6 @@ function ServerPlayer:gainAnExtraTurn(delay)
self.tag["_extra_turn_count"] = self.tag["_extra_turn_count"] or {}
local ex_tag = self.tag["_extra_turn_count"]
local skillName = room.logic:getCurrentSkillName()
table.insert(ex_tag, skillName)
GameEvent(GameEvent.Turn, self):exec()
@ -833,7 +835,7 @@ end
-- Hegemony func
---@param skill Skill
---@param skill Skill | string
function ServerPlayer:addFakeSkill(skill)
assert(type(skill) == "string" or skill:isInstanceOf(Skill))
if type(skill) == "string" then
@ -854,7 +856,7 @@ function ServerPlayer:addFakeSkill(skill)
self:doNotify("AddSkill", json.encode{ self.id, skill.name, true })
end
---@param skill Skill
---@param skill Skill | string
function ServerPlayer:loseFakeSkill(skill)
assert(type(skill) == "string" or skill:isInstanceOf(Skill))
if type(skill) == "string" then
@ -873,6 +875,7 @@ function ServerPlayer:loseFakeSkill(skill)
self:doNotify("LoseSkill", json.encode{ self.id, skill.name, true })
end
---@param skill Skill | string
function ServerPlayer:isFakeSkill(skill)
if type(skill) == "string" then skill = Fk.skills[skill] end
assert(skill:isInstanceOf(Skill))
@ -1049,18 +1052,8 @@ function ServerPlayer:hideGeneral(isDeputy)
end
local general = Fk.generals[generalName]
local skills = general.skills
local place = isDeputy and "m" or "d"
for _, s in ipairs(skills) do
room:handleAddLoseSkills(self, "-" .. s.name, nil, false, true)
if s.relate_to_place ~= place then
if s.frequency == Skill.Compulsory then
self:addFakeSkill("reveal_skill")
end
self:addFakeSkill(s)
end
end
for _, sname in ipairs(general.other_skills) do
for _, sname in ipairs(general:getSkillNameList()) do
room:handleAddLoseSkills(self, "-" .. sname, nil, false, true)
local s = Fk.skills[sname]
if s.relate_to_place ~= place then

View File

@ -50,6 +50,10 @@
---@field public num integer @ 失去体力的数值
---@field public skillName string @ 导致这次失去的技能名
--- 描述跟体力上限变化有关的数据
---@class MaxHpChangedData
---@field public num integer @ 体力上限变化量,可能是正数或者负数
---@alias DamageType integer
fk.NormalDamage = 1

View File

@ -197,18 +197,14 @@ local revealProhibited = fk.CreateInvaliditySkill {
end
if #generals == 0 then return false end
if type(from._fake_skills) == "table" and not table.contains(from._fake_skills, skill) then return false end
local sname = skill.name
for _, g in ipairs(generals) do
if g == "m" then
if from.general ~= "anjiang" then return false end
else
if from.deputyGeneral ~= "anjiang" then return false end
end
local generalName = g == "m" and from:getMark("__heg_general") or from:getMark("__heg_deputy")
local general = Fk.generals[generalName]
if table.contains(general:getSkillNameList(true), sname) then
return true
if (g == "m" and from.general == "anjiang") or (g == "d" and from.deputyGeneral == "anjiang") then
local generalName = g == "m" and from:getMark("__heg_general") or from:getMark("__heg_deputy")
local general = Fk.generals[generalName]
if table.contains(general:getSkillNameList(true), sname) then
return true
end
end
end
return false
@ -254,6 +250,30 @@ local revealSkill = fk.CreateActiveSkill{
elseif choice == "revealMain" then player:revealGeneral(false)
elseif choice == "revealDeputy" then player:revealGeneral(true) end
end,
can_use = function(self, player)
local choiceList = {}
if (player.general == "anjiang" and not player:prohibitReveal()) then
local general = Fk.generals[player:getMark("__heg_general")]
for _, sname in ipairs(general:getSkillNameList(true)) do
local s = Fk.skills[sname]
if s.frequency == Skill.Compulsory and s.relate_to_place ~= "m" then
table.insert(choiceList, "revealMain")
break
end
end
end
if (player.deputyGeneral == "anjiang" and not player:prohibitReveal(true)) then
local general = Fk.generals[player:getMark("__heg_deputy")]
for _, sname in ipairs(general:getSkillNameList(true)) do
local s = Fk.skills[sname]
if s.frequency == Skill.Compulsory and s.relate_to_place ~= "d" then
table.insert(choiceList, "revealDeputy")
break
end
end
end
return #choiceList > 0
end
}
AuxSkills = {

View File

@ -1048,7 +1048,7 @@ local spearSkill = fk.CreateViewAsSkill{
pattern = "slash",
card_filter = function(self, to_select, selected)
if #selected == 2 then return false end
return Fk:currentRoom():getCardArea(to_select) ~= Player.Equip
return table.contains(Self:getHandlyIds(true), to_select)
end,
view_as = function(self, cards)
if #cards ~= 2 then

View File

@ -208,19 +208,10 @@ local test_vs = fk.CreateViewAsSkill{
}
local test_trig = fk.CreateTriggerSkill{
name = "test_trig",
events = {fk.EventPhaseEnd},
can_trigger = function(self, event, target, player, data)
return target == player and player:hasSkill(self.name) and player.phase == Player.Discard
end,
on_cost = function(self, event, target, player, data)
local cards = player.room:askForDiscard(player, 1, 1, false, self.name, true, nil, "#test_trig-ask", true)
if #cards > 0 then
self.cost_data = cards
return true
end
end,
events = {fk.BeforeHpChanged},
on_cost = Util.TrueFunc,
on_use = function(self, event, target, player, data)
player.room:throwCard(self.cost_data, self.name, player, player)
data.num = data.num - 1
end,
}
local damage_maker = fk.CreateActiveSkill{
@ -245,7 +236,7 @@ local damage_maker = fk.CreateActiveSkill{
} end,
on_use = function(self, room, effect)
local from = room:getPlayerById(effect.from)
local victim = #effect.tos > 0 and room:getPlayerById(effect.tos[1])
local victim = room:getPlayerById(effect.tos[1])
local target = #effect.tos > 1 and room:getPlayerById(effect.tos[2])
local choice = self.interaction.data
local number
@ -254,7 +245,7 @@ local damage_maker = fk.CreateActiveSkill{
for i = 1, 99 do
table.insert(choices, tostring(i))
end
number = tonumber(room:askForChoice(from, choices, self.name, nil))
number = tonumber(room:askForChoice(from, choices, self.name, nil)) ---@type integer
end
if target then from = target end
if choice == "heal_hp" then
@ -316,9 +307,6 @@ local change_hero = fk.CreateActiveSkill{
local choice = self.interaction.data
local generals = room:getNGenerals(8)
local general = room:askForGeneral(from, generals, 1)
if general == nil then
general = table.random(generals)
end
table.removeOne(generals, general)
room:changeHero(target, general, false, choice == "deputyGeneral", true)
room:returnToGeneralPile(generals)
@ -330,7 +318,7 @@ local test_zhenggong = fk.CreateTriggerSkill{
frequency = Skill.Compulsory,
anim_type = "negative",
can_trigger = function(self, event, target, player, data)
return player:hasSkill(self.name) and player.room:getTag("RoundCount") == 1
return player:hasSkill(self) and player.room:getTag("RoundCount") == 1
end,
on_use = function(self, event, target, player, data)
player:gainAnExtraTurn()
@ -359,8 +347,8 @@ test2.hidden = true
test2:addSkill("rende")
test2:addSkill(cheat)
test2:addSkill(control)
--test2:addSkill(test_vs)
--test2:addSkill(test_trig)
-- test2:addSkill(test_vs)
-- test2:addSkill(test_trig)
test2:addSkill(damage_maker)
test2:addSkill(test_zhenggong)
test2:addSkill(change_hero)
@ -390,7 +378,6 @@ Fk:loadTranslationTable{
["$cheat"] = "喝啊!",
-- ["@@test_cheat-phase"] = "苦肉",
-- ["@@test_cheat-inhand"] = "连营",
--["#test_trig-ask"] = "你可弃置一张手牌",
["control"] = "控制",
[":control"] = "出牌阶段,你可以控制/解除控制若干名其他角色。",
["$control"] = "战将临阵,斩关刈城!",
@ -416,8 +403,8 @@ Fk:loadTranslationTable{
["~mouxusheng"] = "来世,愿再为我江东之臣……",
["heal_hp"] = "回复体力",
["lose_max_hp"] = "体力上限",
["heal_max_hp"] = "加体力上限",
["lose_max_hp"] = "体力上限",
["heal_max_hp"] = "加体力上限",
["revive"] = "复活",
}