修了很多bug 但我自己都不确定是不是修了
This commit is contained in:
notify 2023-03-07 10:21:56 +08:00 committed by GitHub
parent 0ad2f35783
commit 861d87849a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 73 additions and 53 deletions

View File

@ -83,7 +83,11 @@ function Client:moveCards(moves)
end
if move.to and move.toArea then
self:getPlayerById(move.to):addCards(move.toArea, move.ids, move.specialName)
local ids = move.ids
if (move.to ~= Self.id and move.toArea == Card.PlayerHand) or table.contains(ids, -1) then
ids = table.map(ids, function() return -1 end)
end
self:getPlayerById(move.to):addCards(move.toArea, ids, move.specialName)
elseif move.toArea == Card.DiscardPile then
table.insert(self.discard_pile, move.ids[1])
end
@ -176,6 +180,7 @@ end
fk.client_callback["EnterRoom"] = function(jsonData)
Self = ClientPlayer:new(fk.Self)
ClientInstance = Client:new() -- clear old client data
ClientInstance.players = {Self}
ClientInstance.alive_players = {Self}
ClientInstance.discard_pile = {}
@ -275,6 +280,9 @@ fk.client_callback["AskForCardChosen"] = function(jsonData)
local judge = target.player_cards[Player.Judge]
if not string.find(flag, "h") then
hand = {}
elseif target.id ~= Self.id then
-- FIXME: can not see other's handcard
hand = table.map(hand, function() return -1 end)
end
if not string.find(flag, "e") then
equip = {}

View File

@ -371,4 +371,9 @@ function GetVirtualEquip(player, cid)
}
end
function GetExpandPileOfSkill(skillName)
local skill = Fk.skills[skillName]
return skill and (skill.expand_pile or "") or ""
end
dofile "lua/client/i18n/init.lua"

View File

@ -73,12 +73,17 @@ local function matchCard(matcher, card)
matcher.place,
placetable[Fk:currentRoom():getCardArea(card.id)]
) then
if ClientInstance then
return Self:getPileNameOfId(card.id) and true or false
else
for _, p in ipairs(RoomInstance.alive_players) do
local pile = p:getPileNameOfId(card.id)
if pile then return true end
local piles = table.filter(matcher.place, function(e)
return not table.contains(placetable, e)
end)
for _, pi in ipairs(piles) do
if ClientInstance then
if Self:getPileNameOfId(card.id) == pi then return true end
else
for _, p in ipairs(RoomInstance.alive_players) do
local pile = p:getPileNameOfId(card.id)
if pile == pi then return true end
end
end
end
return false
@ -181,7 +186,7 @@ local function parseMatcher(str)
end
ret.suit = not table.contains(t[3], ".") and t[3] or nil
ret.place = not table.contains(t[4], ".") and t[4] or { "hand", "equip" }
ret.place = not table.contains(t[4], ".") and t[4] or nil
ret.generalName = not table.contains(t[5], ".") and t[5] or nil
ret.cardType = not table.contains(t[6], ".") and t[6] or nil

View File

@ -62,7 +62,7 @@ function Player:initialize()
self.gender = General.Male
self.seat = 0
self.next = nil
self.phase = Player.PhaseNone
self.phase = Player.NotActive
self.faceup = true
self.chained = false
self.dying = false

View File

@ -1,5 +1,6 @@
---@class UsableSkill : Skill
---@field max_use_time integer[]
---@field expand_pile string
local UsableSkill = Skill:subclass("UsableSkill")
function UsableSkill:initialize(name, frequency)

View File

@ -138,8 +138,8 @@ end
---@param n integer
---@return T|T[]
function table.random(tab, n)
n = n or 1
local n0 = n
n = n or 1
if #tab == 0 then return nil end
local tmp = {table.unpack(tab)}
local ret = {}
@ -148,7 +148,7 @@ function table.random(tab, n)
table.insert(ret, table.remove(tmp, i))
n = n - 1
end
return n0 == 1 and ret[1] or ret
return n0 == nil and ret[1] or ret
end
---@param delimiter string

View File

@ -45,6 +45,7 @@ local function readUsableSpecToSkill(skill, spec)
spec.max_game_use_time or 9999,
}
skill.distance_limit = spec.distance_limit or skill.distance_limit
skill.expand_pile = spec.expand_pile
end
local function readStatusSpecToSkill(skill, spec)

View File

@ -1489,7 +1489,7 @@ function Room:doCardEffect(cardEffectEvent)
if event == fk.PreCardEffect then
if cardEffectEvent.card.skill:aboutToEffect(self, cardEffectEvent) then return end
if cardEffectEvent.card.name == "slash" and
if cardEffectEvent.card.trueName == "slash" and
not (
cardEffectEvent.disresponsive or
cardEffectEvent.unoffsetable or

View File

@ -168,7 +168,7 @@ local luoyi = fk.CreateTriggerSkill{
end
local c = data.card
return c and c.name == "slash" or c.name == "duel"
return c and c.trueName == "slash" or c.name == "duel"
end,
on_refresh = function(self, event, target, player, data)
local room = player.room
@ -344,7 +344,7 @@ local paoxiaoAudio = fk.CreateTriggerSkill{
refresh_events = {fk.CardUsing},
can_refresh = function(self, event, target, player, data)
return target == player and player:hasSkill(self.name) and
data.card.name == "slash" and
data.card.trueName == "slash" and
player:usedCardTimes("slash") > 1
end,
on_refresh = function(self, event, target, player, data)
@ -359,7 +359,7 @@ local paoxiaoAudio = fk.CreateTriggerSkill{
local paoxiao = fk.CreateTargetModSkill{
name = "paoxiao",
residue_func = function(self, player, skill, scope)
if player:hasSkill(self.name) and skill.name == "slash_skill"
if player:hasSkill(self.name) and skill.trueName == "slash_skill"
and scope == Player.HistoryPhase then
return 999
end
@ -411,7 +411,7 @@ local kongcheng = fk.CreateProhibitSkill{
name = "kongcheng",
is_prohibited = function(self, from, to, card)
if to:hasSkill(self.name) and to:isKongcheng() then
return card.name == "slash" or card.name == "duel"
return card.trueName == "slash" or card.name == "duel"
end
end,
}
@ -426,7 +426,7 @@ local longdan = fk.CreateViewAsSkill{
card_filter = function(self, to_select, selected)
if #selected == 1 then return false end
local c = Fk:getCardById(to_select)
return c.name == "slash" or c.name == "jink"
return c.trueName == "slash" or c.name == "jink"
end,
view_as = function(self, cards)
if #cards ~= 1 then
@ -434,7 +434,7 @@ local longdan = fk.CreateViewAsSkill{
end
local _c = Fk:getCardById(cards[1])
local c
if _c.name == "slash" then
if _c.trueName == "slash" then
c = Fk:cloneCard("jink")
elseif _c.name == "jink" then
c = Fk:cloneCard("slash")
@ -460,7 +460,7 @@ local tieqi = fk.CreateTriggerSkill{
events = {fk.TargetSpecified},
can_trigger = function(self, event, target, player, data)
return target == player and player:hasSkill(self.name) and
data.card.name == "slash"
data.card.trueName == "slash"
end,
on_use = function(self, event, target, player, data)
local room = player.room
@ -563,7 +563,7 @@ local keji = fk.CreateTriggerSkill{
return false
end
if event == fk.CardResponding then
return data.card.name == "slash"
return data.card.trueName == "slash"
elseif event == fk.EventPhaseStart then
return player.phase == player.NotActive
end
@ -658,7 +658,7 @@ local liuli = fk.CreateTriggerSkill{
events = {fk.TargetConfirming},
can_trigger = function(self, event, target, player, data)
local ret = target == player and player:hasSkill(self.name) and
data.card.name == "slash"
data.card.trueName == "slash"
if ret then
self.target_list = {}
local room = player.room
@ -865,7 +865,7 @@ local wushuang = fk.CreateTriggerSkill{
end,
on_use = function(self, event, target, player, data)
data.fixedResponseTimes = data.fixedResponseTimes or {}
if data.card.name == "slash" then
if data.card.trueName == "slash" then
data.fixedResponseTimes["jink"] = 2
else
data.fixedResponseTimes["slash"] = 2

View File

@ -675,7 +675,7 @@ local crossbowAudio = fk.CreateTriggerSkill{
refresh_events = {fk.CardUsing},
can_refresh = function(self, event, target, player, data)
return target == player and player:hasSkill(self.name) and
data.card.name == "slash" and
data.card.trueName == "slash" and
player:usedCardTimes("slash") > 1
end,
on_refresh = function(self, event, target, player, data)
@ -688,7 +688,7 @@ local crossbowSkill = fk.CreateTargetModSkill{
name = "#crossbow_skill",
attached_equip = "crossbow",
residue_func = function(self, player, skill, scope)
if player:hasSkill(self.name) and skill.name == "slash_skill"
if player:hasSkill(self.name) and skill.trueName == "slash_skill"
and scope == Player.HistoryPhase then
return 999
end
@ -727,7 +727,7 @@ local iceSwordSkill = fk.CreateTriggerSkill{
events = {fk.DamageCaused},
can_trigger = function(self, event, target, player, data)
return target == player and player:hasSkill(self.name) and
data.card and data.card.name == "slash" and not data.to:isNude()
data.card and data.card.trueName == "slash" and not data.to:isNude()
end,
on_use = function(self, event, target, player, data)
local room = player.room
@ -760,7 +760,7 @@ local doubleSwordsSkill = fk.CreateTriggerSkill{
events = {fk.TargetSpecified},
can_trigger = function(self, event, target, player, data)
return target == player and player:hasSkill(self.name) and
data.card and data.card.name == "slash" and
data.card and data.card.trueName == "slash" and
(player.room:getPlayerById(data.to).gender ~= player.gender)
end,
on_use = function(self, event, target, player, data)
@ -792,7 +792,7 @@ local bladeSkill = fk.CreateTriggerSkill{
can_trigger = function(self, event, target, player, data)
if not player:hasSkill(self.name) then return end
local use = data ---@type CardUseStruct
if use.card.name == "jink" and use.toCard and use.toCard.name == "slash" then
if use.card.name == "jink" and use.toCard and use.toCard.trueName == "slash" then
local effect = use.responseToEvent
return effect.from == player.id
end
@ -860,7 +860,7 @@ local axeSkill = fk.CreateTriggerSkill{
can_trigger = function(self, event, target, player, data)
if not player:hasSkill(self.name) then return end
local effect = data ---@type CardEffectEvent
return effect.card.name == "slash" and effect.from == player.id
return effect.card.trueName == "slash" and effect.from == player.id
end,
on_cost = function(self, event, target, player, data)
local room = player.room
@ -887,7 +887,7 @@ local halberdAudio = fk.CreateTriggerSkill{
refresh_events = {fk.CardUsing},
can_refresh = function(self, event, target, player, data)
return target == player and player:hasSkill(self.name) and
data.card.name == "slash" and #TargetGroup:getRealTargets(data.tos) > 1
data.card.trueName == "slash" and #TargetGroup:getRealTargets(data.tos) > 1
end,
on_refresh = function(self, event, target, player, data)
local room = player.room
@ -899,7 +899,7 @@ local halberdSkill = fk.CreateTargetModSkill{
name = "#halberd_skill",
attached_equip = "halberd",
extra_target_func = function(self, player, skill, card)
if player:hasSkill(self.name) and skill.name == "slash_skill"
if player:hasSkill(self.name) and skill.trueName == "slash_skill"
and #player:getCardIds(Player.Hand) == 1
and player:getCardIds(Player.Hand)[1] == card.id then
return 2
@ -926,7 +926,7 @@ local kylinBowSkill = fk.CreateTriggerSkill{
events = {fk.DamageCaused},
can_trigger = function(self, event, target, player, data)
local ret = target == player and player:hasSkill(self.name) and
data.card and data.card.name == "slash"
data.card and data.card.trueName == "slash"
if ret then
---@type ServerPlayer
local to = data.to
@ -1023,7 +1023,7 @@ local niohShieldSkill = fk.CreateTriggerSkill{
can_trigger = function(self, event, target, player, data)
local effect = data ---@type CardEffectEvent
return player.id == effect.to and player:hasSkill(self.name) and
effect.card.name == "slash" and effect.card.color == Card.Black
effect.card.trueName == "slash" and effect.card.color == Card.Black
end,
on_use = function() return true end,
}

View File

@ -160,10 +160,13 @@ RowLayout {
}
});
// Must manually analyze pattern here
let pile_list = cname.split("|")[4];
let pile_data = JSON.parse(Backend.callLuaFunction("GetAllPiles", [selfPhoto.playerid]));
if (!(pile_data instanceof Array)) {
for (let pile_name in pile_data) {
pile_data[pile_name].forEach(cid => {
if (pile_list && pile_list !== "." && !(pile_data instanceof Array)) {
pile_list = pile_list.split(",");
for (let pile_name of pile_list) {
pile_data[pile_name] && pile_data[pile_name].forEach(cid => {
if (JSON.parse(Backend.callLuaFunction(
"CardFitPattern",
[cid, cname]
@ -180,7 +183,7 @@ RowLayout {
handcardAreaItem.enableCards(ids);
return;
}
// TODO: expand pile
let ids = [], cards = handcardAreaItem.cards;
for (let i = 0; i < cards.length; i++) {
if (JSON.parse(Backend.callLuaFunction("CanUseCard", [cards[i].cid, Self.id])))
@ -251,22 +254,19 @@ RowLayout {
}
})
let pile_data = JSON.parse(Backend.callLuaFunction("GetAllPiles", [selfPhoto.playerid]));
if (!(pile_data instanceof Array)) {
for (let pile_name in pile_data) {
pile_data[pile_name].forEach(cid => {
if (JSON.parse(Backend.callLuaFunction(
"ActiveCardFilter",
[pending_skill, cid, pendings, targets]
))) {
enabled_cards.push(cid);
if (!expanded_piles[pile_name]) {
expandPile(pile_name);
}
}
});
let pile = Backend.callLuaFunction("GetExpandPileOfSkill", [pending_skill]);
let pile_ids = JSON.parse(Backend.callLuaFunction("GetPile", [selfPhoto.playerid, pile]));
pile_ids.forEach(cid => {
if (JSON.parse(Backend.callLuaFunction(
"ActiveCardFilter",
[pending_skill, cid, pendings, targets]
))) {
enabled_cards.push(cid);
if (!expanded_piles[pile_name]) {
expandPile(pile_name);
}
}
}
});
handcardAreaItem.enableCards(enabled_cards);

View File

@ -195,8 +195,8 @@ int PackMan::clone(const QString &u) {
int error = git_clone(&repo, url.toUtf8(), fileName.toUtf8(), &opt);
if (error < 0) {
GIT_FAIL;
QDir(fileName).removeRecursively();
QDir(".").rmdir(fileName);
// QDir(fileName).removeRecursively();
// QDir(".").rmdir(fileName);
} else {
if (Backend == nullptr)
printf("\n");