Fixbug2 (#107)
修了窃听移走装备不失去装备技能 询问无懈时减少CPU使用 将skill.interaction的数据传到服务器 自动清除诸如-round结尾的标记 增加了和 轮次流程 相关的游戏流程与时机
This commit is contained in:
parent
8aa8775fd6
commit
a51806f902
|
@ -74,7 +74,7 @@ Arch Linux:
|
||||||
如果你使用 Nix/NixOs 的话,可以在clone repo后直接使用 nix flake 构建:
|
如果你使用 Nix/NixOs 的话,可以在clone repo后直接使用 nix flake 构建:
|
||||||
|
|
||||||
.. code:: sh
|
.. code:: sh
|
||||||
|
|
||||||
$ git clone https://github.com/Notify-ctrl/FreeKill
|
$ git clone https://github.com/Notify-ctrl/FreeKill
|
||||||
$ nix build '.?submodules=1'
|
$ nix build '.?submodules=1'
|
||||||
|
|
||||||
|
|
|
@ -207,6 +207,14 @@ function string:split(delimiter)
|
||||||
return result
|
return result
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function string:startsWith(start)
|
||||||
|
return self:sub(1, #start) == start
|
||||||
|
end
|
||||||
|
|
||||||
|
function string:endsWith(e)
|
||||||
|
return e == "" or self:sub(-#e) == e
|
||||||
|
end
|
||||||
|
|
||||||
---@class Sql
|
---@class Sql
|
||||||
Sql = {
|
Sql = {
|
||||||
---@param filename string
|
---@param filename string
|
||||||
|
|
|
@ -33,8 +33,8 @@ fk.AskForRetrial = 25
|
||||||
fk.FinishRetrial = 26
|
fk.FinishRetrial = 26
|
||||||
fk.FinishJudge = 27
|
fk.FinishJudge = 27
|
||||||
|
|
||||||
fk.Empty28 = 28
|
fk.RoundStart = 28
|
||||||
fk.Empty29 = 29
|
fk.RoundEnd = 29
|
||||||
|
|
||||||
fk.TurnedOver = 30
|
fk.TurnedOver = 30
|
||||||
fk.ChainStateChanged = 31
|
fk.ChainStateChanged = 31
|
||||||
|
|
|
@ -5,6 +5,23 @@ GameEvent.functions[GameEvent.DrawInitial] = function(self)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
GameEvent.functions[GameEvent.Round] = function(self)
|
||||||
|
local room = self.room
|
||||||
|
local logic = room.logic
|
||||||
|
local p
|
||||||
|
|
||||||
|
logic:trigger(fk.RoundStart, room.current)
|
||||||
|
|
||||||
|
repeat
|
||||||
|
p = room.current
|
||||||
|
GameEvent(GameEvent.Turn):exec()
|
||||||
|
if room.game_finished then break end
|
||||||
|
room.current = room.current:getNextAlive()
|
||||||
|
until p.seat > p:getNextAlive().seat
|
||||||
|
|
||||||
|
logic:trigger(fk.RoundEnd, p)
|
||||||
|
end
|
||||||
|
|
||||||
GameEvent.functions[GameEvent.Turn] = function(self)
|
GameEvent.functions[GameEvent.Turn] = function(self)
|
||||||
local room = self.room
|
local room = self.room
|
||||||
room.logic:trigger(fk.TurnStart, room.current)
|
room.logic:trigger(fk.TurnStart, room.current)
|
||||||
|
|
|
@ -27,10 +27,11 @@ GameEvent.Judge = 14
|
||||||
dofile "lua/server/events/judge.lua"
|
dofile "lua/server/events/judge.lua"
|
||||||
|
|
||||||
GameEvent.DrawInitial = 15
|
GameEvent.DrawInitial = 15
|
||||||
GameEvent.Turn = 16
|
GameEvent.Round = 16
|
||||||
|
GameEvent.Turn = 17
|
||||||
dofile "lua/server/events/gameflow.lua"
|
dofile "lua/server/events/gameflow.lua"
|
||||||
|
|
||||||
GameEvent.Pindian = 17
|
GameEvent.Pindian = 18
|
||||||
dofile "lua/server/events/pindian.lua"
|
dofile "lua/server/events/pindian.lua"
|
||||||
|
|
||||||
-- TODO: fix this
|
-- TODO: fix this
|
||||||
|
|
|
@ -105,7 +105,14 @@ GameEvent.functions[GameEvent.MoveCards] = function(self)
|
||||||
currentCard.equip_skill
|
currentCard.equip_skill
|
||||||
then
|
then
|
||||||
currentCard:onInstall(self, self:getPlayerById(data.to))
|
currentCard:onInstall(self, self:getPlayerById(data.to))
|
||||||
elseif realFromArea == Player.Equip and currentCard.type == Card.TypeEquip and data.from ~= nil and currentCard.equip_skill then
|
end
|
||||||
|
|
||||||
|
if
|
||||||
|
realFromArea == Player.Equip and
|
||||||
|
currentCard.type == Card.TypeEquip and
|
||||||
|
data.from ~= nil and
|
||||||
|
currentCard.equip_skill
|
||||||
|
then
|
||||||
currentCard:onUninstall(self, self:getPlayerById(data.from))
|
currentCard:onUninstall(self, self:getPlayerById(data.from))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -166,9 +166,8 @@ function GameLogic:action()
|
||||||
execGameEvent(GameEvent.DrawInitial)
|
execGameEvent(GameEvent.DrawInitial)
|
||||||
|
|
||||||
while true do
|
while true do
|
||||||
execGameEvent(GameEvent.Turn)
|
execGameEvent(GameEvent.Round)
|
||||||
if room.game_finished then break end
|
if room.game_finished then break end
|
||||||
room.current = room.current:getNextAlive()
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -509,6 +509,8 @@ function Room:doRaceRequest(command, players, jsonData)
|
||||||
if #players == #canceled_players then
|
if #players == #canceled_players then
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
fk.QThread_msleep(10)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -1212,6 +1214,7 @@ function Room:handleUseCardReply(player, data)
|
||||||
local card_data = json.decode(card)
|
local card_data = json.decode(card)
|
||||||
local skill = Fk.skills[card_data.skill]
|
local skill = Fk.skills[card_data.skill]
|
||||||
local selected_cards = card_data.subcards
|
local selected_cards = card_data.subcards
|
||||||
|
if skill.interaction then skill.interaction.data = data.interaction_data end
|
||||||
if skill:isInstanceOf(ActiveSkill) then
|
if skill:isInstanceOf(ActiveSkill) then
|
||||||
self:useSkill(player, skill, function()
|
self:useSkill(player, skill, function()
|
||||||
self:doIndicate(player.id, targets)
|
self:doIndicate(player.id, targets)
|
||||||
|
|
|
@ -41,6 +41,7 @@ GameRule = fk.CreateTriggerSkill{
|
||||||
refresh_events = {
|
refresh_events = {
|
||||||
fk.GameStart, fk.DrawInitialCards, fk.TurnStart,
|
fk.GameStart, fk.DrawInitialCards, fk.TurnStart,
|
||||||
fk.EventPhaseProceeding, fk.EventPhaseEnd, fk.EventPhaseChanging,
|
fk.EventPhaseProceeding, fk.EventPhaseEnd, fk.EventPhaseChanging,
|
||||||
|
fk.RoundStart,
|
||||||
fk.AskForPeaches, fk.AskForPeachesDone,
|
fk.AskForPeaches, fk.AskForPeachesDone,
|
||||||
fk.GameOverJudge, fk.BuryVictim,
|
fk.GameOverJudge, fk.BuryVictim,
|
||||||
},
|
},
|
||||||
|
@ -51,17 +52,18 @@ GameRule = fk.CreateTriggerSkill{
|
||||||
end,
|
end,
|
||||||
|
|
||||||
on_refresh = function(self, event, target, player, data)
|
on_refresh = function(self, event, target, player, data)
|
||||||
if RoomInstance.tag["SkipGameRule"] then
|
local room = player.room
|
||||||
RoomInstance.tag["SkipGameRule"] = false
|
if room:getTag("SkipGameRule") then
|
||||||
|
room:setTag("SkipGameRule", false)
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
if event == fk.GameStart then
|
if event == fk.GameStart then
|
||||||
RoomInstance.tag["FirstRound"] = true
|
room:setTag("FirstRound", true)
|
||||||
|
room:setTag("RoundCount", 0)
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
local room = player.room
|
|
||||||
switch(event, {
|
switch(event, {
|
||||||
[fk.DrawInitialCards] = function()
|
[fk.DrawInitialCards] = function()
|
||||||
if data.num > 0 then
|
if data.num > 0 then
|
||||||
|
@ -89,25 +91,27 @@ GameRule = fk.CreateTriggerSkill{
|
||||||
room.logic:trigger(fk.AfterDrawInitialCards, player, data)
|
room.logic:trigger(fk.AfterDrawInitialCards, player, data)
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
[fk.TurnStart] = function()
|
[fk.RoundStart] = function()
|
||||||
player = room.current
|
if room:getTag("FirstRound") then
|
||||||
if room.tag["FirstRound"] == true then
|
room:setTag("FirstRound", false)
|
||||||
room.tag["FirstRound"] = false
|
|
||||||
player:setFlag("Global_FirstRound")
|
|
||||||
end
|
end
|
||||||
|
|
||||||
if player.seat == 1 then
|
room:setTag("RoundCount", room:getTag("RoundCount") + 1)
|
||||||
for _, p in ipairs(room.players) do
|
|
||||||
p:setCardUseHistory("", 0, Player.HistoryRound)
|
for _, p in ipairs(room.players) do
|
||||||
p:setSkillUseHistory("", 0, Player.HistoryRound)
|
p:setCardUseHistory("", 0, Player.HistoryRound)
|
||||||
|
p:setSkillUseHistory("", 0, Player.HistoryRound)
|
||||||
|
for name, _ in pairs(p.mark) do
|
||||||
|
if name:endsWith("-round") then
|
||||||
|
room:setPlayerMark(p, name, 0)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
room:sendLog{ type = "$AppendSeparator" }
|
room:sendLog{ type = "$AppendSeparator" }
|
||||||
|
end,
|
||||||
player:addMark("Global_TurnCount")
|
[fk.TurnStart] = function()
|
||||||
if not player.faceup then
|
if not player.faceup then
|
||||||
player:setFlag("-Global_FirstRound")
|
|
||||||
player:turnOver()
|
player:turnOver()
|
||||||
elseif not player.dead then
|
elseif not player.dead then
|
||||||
player:play()
|
player:play()
|
||||||
|
@ -185,6 +189,11 @@ GameRule = fk.CreateTriggerSkill{
|
||||||
for _, p in ipairs(room.players) do
|
for _, p in ipairs(room.players) do
|
||||||
p:setCardUseHistory("", 0, Player.HistoryPhase)
|
p:setCardUseHistory("", 0, Player.HistoryPhase)
|
||||||
p:setSkillUseHistory("", 0, Player.HistoryPhase)
|
p:setSkillUseHistory("", 0, Player.HistoryPhase)
|
||||||
|
for name, _ in pairs(p.mark) do
|
||||||
|
if name:endsWith("-phase") then
|
||||||
|
room:setPlayerMark(p, name, 0)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
|
@ -194,6 +203,11 @@ GameRule = fk.CreateTriggerSkill{
|
||||||
for _, p in ipairs(room.players) do
|
for _, p in ipairs(room.players) do
|
||||||
p:setCardUseHistory("", 0, Player.HistoryTurn)
|
p:setCardUseHistory("", 0, Player.HistoryTurn)
|
||||||
p:setSkillUseHistory("", 0, Player.HistoryTurn)
|
p:setSkillUseHistory("", 0, Player.HistoryTurn)
|
||||||
|
for name, _ in pairs(p.mark) do
|
||||||
|
if name:endsWith("-turn") then
|
||||||
|
room:setPlayerMark(p, name, 0)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
|
|
|
@ -91,10 +91,37 @@ local test_active = fk.CreateActiveSkill{
|
||||||
-- p(cards)
|
-- p(cards)
|
||||||
end,
|
end,
|
||||||
}
|
}
|
||||||
|
local test_vs = fk.CreateViewAsSkill{
|
||||||
|
name = "test_vs",
|
||||||
|
card_filter = function(self, to_select, selected)
|
||||||
|
return #selected == 0
|
||||||
|
end,
|
||||||
|
interaction = UI.ComboBox {
|
||||||
|
choices = {
|
||||||
|
"ex_nihilo",
|
||||||
|
"duel",
|
||||||
|
"snatch",
|
||||||
|
"dismantlement",
|
||||||
|
"savage_assault",
|
||||||
|
"archery_attack",
|
||||||
|
}
|
||||||
|
},
|
||||||
|
view_as = function(self, cards)
|
||||||
|
if #cards ~= 1 then
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
if not self.interaction.data then return end
|
||||||
|
local c = Fk:cloneCard(self.interaction.data)
|
||||||
|
c.skillName = self.name
|
||||||
|
c:addSubcard(cards[1])
|
||||||
|
return c
|
||||||
|
end,
|
||||||
|
}
|
||||||
local test2 = General(extension, "mouxusheng", "wu", 4, 4, General.Female)
|
local test2 = General(extension, "mouxusheng", "wu", 4, 4, General.Female)
|
||||||
test2:addSkill("rende")
|
test2:addSkill("rende")
|
||||||
test2:addSkill(cheat)
|
test2:addSkill(cheat)
|
||||||
test2:addSkill(test_active)
|
test2:addSkill(test_active)
|
||||||
|
test2:addSkill(test_vs)
|
||||||
|
|
||||||
Fk:loadTranslationTable{
|
Fk:loadTranslationTable{
|
||||||
["test"] = "测试",
|
["test"] = "测试",
|
||||||
|
|
|
@ -27,6 +27,7 @@ Item {
|
||||||
property alias dynamicCardArea: dynamicCardArea
|
property alias dynamicCardArea: dynamicCardArea
|
||||||
property alias tableCards: tablePile.cards
|
property alias tableCards: tablePile.cards
|
||||||
property alias dashboard: dashboard
|
property alias dashboard: dashboard
|
||||||
|
property alias skillInteraction: skillInteraction
|
||||||
|
|
||||||
property var selected_targets: []
|
property var selected_targets: []
|
||||||
property string responding_card
|
property string responding_card
|
||||||
|
|
|
@ -70,6 +70,7 @@ function doOkButton() {
|
||||||
card: dashboard.getSelectedCard(),
|
card: dashboard.getSelectedCard(),
|
||||||
targets: selected_targets,
|
targets: selected_targets,
|
||||||
special_skill: roomScene.getCurrentCardUseMethod(),
|
special_skill: roomScene.getCurrentCardUseMethod(),
|
||||||
|
interaction_data: roomScene.skillInteraction.item ? roomScene.skillInteraction.item.answer : undefined,
|
||||||
}
|
}
|
||||||
));
|
));
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Reference in New Issue