Fixbug2 (#107)
修了窃听移走装备不失去装备技能 询问无懈时减少CPU使用 将skill.interaction的数据传到服务器 自动清除诸如-round结尾的标记 增加了和 轮次流程 相关的游戏流程与时机
This commit is contained in:
parent
8aa8775fd6
commit
a51806f902
|
@ -207,6 +207,14 @@ function string:split(delimiter)
|
|||
return result
|
||||
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
|
||||
Sql = {
|
||||
---@param filename string
|
||||
|
|
|
@ -33,8 +33,8 @@ fk.AskForRetrial = 25
|
|||
fk.FinishRetrial = 26
|
||||
fk.FinishJudge = 27
|
||||
|
||||
fk.Empty28 = 28
|
||||
fk.Empty29 = 29
|
||||
fk.RoundStart = 28
|
||||
fk.RoundEnd = 29
|
||||
|
||||
fk.TurnedOver = 30
|
||||
fk.ChainStateChanged = 31
|
||||
|
|
|
@ -5,6 +5,23 @@ GameEvent.functions[GameEvent.DrawInitial] = function(self)
|
|||
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)
|
||||
local room = self.room
|
||||
room.logic:trigger(fk.TurnStart, room.current)
|
||||
|
|
|
@ -27,10 +27,11 @@ GameEvent.Judge = 14
|
|||
dofile "lua/server/events/judge.lua"
|
||||
|
||||
GameEvent.DrawInitial = 15
|
||||
GameEvent.Turn = 16
|
||||
GameEvent.Round = 16
|
||||
GameEvent.Turn = 17
|
||||
dofile "lua/server/events/gameflow.lua"
|
||||
|
||||
GameEvent.Pindian = 17
|
||||
GameEvent.Pindian = 18
|
||||
dofile "lua/server/events/pindian.lua"
|
||||
|
||||
-- TODO: fix this
|
||||
|
|
|
@ -105,7 +105,14 @@ GameEvent.functions[GameEvent.MoveCards] = function(self)
|
|||
currentCard.equip_skill
|
||||
then
|
||||
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))
|
||||
end
|
||||
end
|
||||
|
|
|
@ -166,9 +166,8 @@ function GameLogic:action()
|
|||
execGameEvent(GameEvent.DrawInitial)
|
||||
|
||||
while true do
|
||||
execGameEvent(GameEvent.Turn)
|
||||
execGameEvent(GameEvent.Round)
|
||||
if room.game_finished then break end
|
||||
room.current = room.current:getNextAlive()
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -509,6 +509,8 @@ function Room:doRaceRequest(command, players, jsonData)
|
|||
if #players == #canceled_players then
|
||||
return nil
|
||||
end
|
||||
|
||||
fk.QThread_msleep(10)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -1212,6 +1214,7 @@ function Room:handleUseCardReply(player, data)
|
|||
local card_data = json.decode(card)
|
||||
local skill = Fk.skills[card_data.skill]
|
||||
local selected_cards = card_data.subcards
|
||||
if skill.interaction then skill.interaction.data = data.interaction_data end
|
||||
if skill:isInstanceOf(ActiveSkill) then
|
||||
self:useSkill(player, skill, function()
|
||||
self:doIndicate(player.id, targets)
|
||||
|
|
|
@ -41,6 +41,7 @@ GameRule = fk.CreateTriggerSkill{
|
|||
refresh_events = {
|
||||
fk.GameStart, fk.DrawInitialCards, fk.TurnStart,
|
||||
fk.EventPhaseProceeding, fk.EventPhaseEnd, fk.EventPhaseChanging,
|
||||
fk.RoundStart,
|
||||
fk.AskForPeaches, fk.AskForPeachesDone,
|
||||
fk.GameOverJudge, fk.BuryVictim,
|
||||
},
|
||||
|
@ -51,17 +52,18 @@ GameRule = fk.CreateTriggerSkill{
|
|||
end,
|
||||
|
||||
on_refresh = function(self, event, target, player, data)
|
||||
if RoomInstance.tag["SkipGameRule"] then
|
||||
RoomInstance.tag["SkipGameRule"] = false
|
||||
local room = player.room
|
||||
if room:getTag("SkipGameRule") then
|
||||
room:setTag("SkipGameRule", false)
|
||||
return false
|
||||
end
|
||||
|
||||
if event == fk.GameStart then
|
||||
RoomInstance.tag["FirstRound"] = true
|
||||
room:setTag("FirstRound", true)
|
||||
room:setTag("RoundCount", 0)
|
||||
return false
|
||||
end
|
||||
|
||||
local room = player.room
|
||||
switch(event, {
|
||||
[fk.DrawInitialCards] = function()
|
||||
if data.num > 0 then
|
||||
|
@ -89,25 +91,27 @@ GameRule = fk.CreateTriggerSkill{
|
|||
room.logic:trigger(fk.AfterDrawInitialCards, player, data)
|
||||
end
|
||||
end,
|
||||
[fk.TurnStart] = function()
|
||||
player = room.current
|
||||
if room.tag["FirstRound"] == true then
|
||||
room.tag["FirstRound"] = false
|
||||
player:setFlag("Global_FirstRound")
|
||||
[fk.RoundStart] = function()
|
||||
if room:getTag("FirstRound") then
|
||||
room:setTag("FirstRound", false)
|
||||
end
|
||||
|
||||
if player.seat == 1 then
|
||||
for _, p in ipairs(room.players) do
|
||||
p:setCardUseHistory("", 0, Player.HistoryRound)
|
||||
p:setSkillUseHistory("", 0, Player.HistoryRound)
|
||||
room:setTag("RoundCount", room:getTag("RoundCount") + 1)
|
||||
|
||||
for _, p in ipairs(room.players) do
|
||||
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
|
||||
|
||||
room:sendLog{ type = "$AppendSeparator" }
|
||||
|
||||
player:addMark("Global_TurnCount")
|
||||
end,
|
||||
[fk.TurnStart] = function()
|
||||
if not player.faceup then
|
||||
player:setFlag("-Global_FirstRound")
|
||||
player:turnOver()
|
||||
elseif not player.dead then
|
||||
player:play()
|
||||
|
@ -185,6 +189,11 @@ GameRule = fk.CreateTriggerSkill{
|
|||
for _, p in ipairs(room.players) do
|
||||
p:setCardUseHistory("", 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,
|
||||
|
@ -194,6 +203,11 @@ GameRule = fk.CreateTriggerSkill{
|
|||
for _, p in ipairs(room.players) do
|
||||
p:setCardUseHistory("", 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,
|
||||
|
|
|
@ -91,10 +91,37 @@ local test_active = fk.CreateActiveSkill{
|
|||
-- p(cards)
|
||||
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)
|
||||
test2:addSkill("rende")
|
||||
test2:addSkill(cheat)
|
||||
test2:addSkill(test_active)
|
||||
test2:addSkill(test_vs)
|
||||
|
||||
Fk:loadTranslationTable{
|
||||
["test"] = "测试",
|
||||
|
|
|
@ -27,6 +27,7 @@ Item {
|
|||
property alias dynamicCardArea: dynamicCardArea
|
||||
property alias tableCards: tablePile.cards
|
||||
property alias dashboard: dashboard
|
||||
property alias skillInteraction: skillInteraction
|
||||
|
||||
property var selected_targets: []
|
||||
property string responding_card
|
||||
|
|
|
@ -70,6 +70,7 @@ function doOkButton() {
|
|||
card: dashboard.getSelectedCard(),
|
||||
targets: selected_targets,
|
||||
special_skill: roomScene.getCurrentCardUseMethod(),
|
||||
interaction_data: roomScene.skillInteraction.item ? roomScene.skillInteraction.item.answer : undefined,
|
||||
}
|
||||
));
|
||||
return;
|
||||
|
|
Loading…
Reference in New Issue