Fixbug (#51)
* add translation for askforguanxing * fix bug: observer will kill room that not take action * fix bug: observe and reconnect * fix bug: notifyCardMove * fix bug: hegmony nullification * fix bug: never show test generals in normal askforgeneral * if game doesn't start, marshal() will only send simple information
This commit is contained in:
parent
3fe92b4344
commit
b2dfd69a16
|
@ -444,6 +444,7 @@ Fk:loadTranslationTable{
|
||||||
|
|
||||||
[" thinking..."] = " 思考中...",
|
[" thinking..."] = " 思考中...",
|
||||||
["AskForGeneral"] = "选择武将",
|
["AskForGeneral"] = "选择武将",
|
||||||
|
["AskForGuanxiong"] = "观星",
|
||||||
["AskForChoice"] = "选择",
|
["AskForChoice"] = "选择",
|
||||||
["PlayCard"] = "出牌",
|
["PlayCard"] = "出牌",
|
||||||
|
|
||||||
|
|
|
@ -185,6 +185,9 @@ function Engine:getGeneralsRandomly(num, generalPool, except, filter)
|
||||||
|
|
||||||
generalPool = generalPool or self.generals
|
generalPool = generalPool or self.generals
|
||||||
except = except or {}
|
except = except or {}
|
||||||
|
for _, g in ipairs(self.packages["test_p_0"].generals) do
|
||||||
|
table.insert(except, g.name)
|
||||||
|
end
|
||||||
|
|
||||||
local availableGenerals = {}
|
local availableGenerals = {}
|
||||||
for _, general in pairs(generalPool) do
|
for _, general in pairs(generalPool) do
|
||||||
|
|
|
@ -66,6 +66,15 @@ function table.clone(self)
|
||||||
return ret
|
return ret
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- similar to table.clone but not recursively
|
||||||
|
function table.simpleClone(self)
|
||||||
|
local ret = {}
|
||||||
|
for k, v in pairs(self) do
|
||||||
|
ret[k] = v
|
||||||
|
end
|
||||||
|
return ret
|
||||||
|
end
|
||||||
|
|
||||||
-- if table does not contain the element, we insert it
|
-- if table does not contain the element, we insert it
|
||||||
function table:insertIfNeed(element)
|
function table:insertIfNeed(element)
|
||||||
if not table.contains(self, element) then
|
if not table.contains(self, element) then
|
||||||
|
|
|
@ -34,6 +34,7 @@ function GameLogic:run()
|
||||||
|
|
||||||
self:chooseGenerals()
|
self:chooseGenerals()
|
||||||
self:prepareForStart()
|
self:prepareForStart()
|
||||||
|
self.room.game_started = true
|
||||||
self:action()
|
self:action()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
---@field alive_players ServerPlayer[]
|
---@field alive_players ServerPlayer[]
|
||||||
---@field observers fk.ServerPlayer[]
|
---@field observers fk.ServerPlayer[]
|
||||||
---@field current ServerPlayer
|
---@field current ServerPlayer
|
||||||
|
---@field game_started boolean
|
||||||
---@field game_finished boolean
|
---@field game_finished boolean
|
||||||
---@field timeout integer
|
---@field timeout integer
|
||||||
---@field tag table<string, any>
|
---@field tag table<string, any>
|
||||||
|
@ -80,6 +81,7 @@ function Room:initialize(_room)
|
||||||
self.alive_players = {}
|
self.alive_players = {}
|
||||||
self.observers = {}
|
self.observers = {}
|
||||||
self.current = nil
|
self.current = nil
|
||||||
|
self.game_started = false
|
||||||
self.game_finished = false
|
self.game_finished = false
|
||||||
self.timeout = _room:getTimeout()
|
self.timeout = _room:getTimeout()
|
||||||
self.tag = {}
|
self.tag = {}
|
||||||
|
@ -173,6 +175,9 @@ end
|
||||||
---@param sortBySeat boolean
|
---@param sortBySeat boolean
|
||||||
---@return ServerPlayer[]
|
---@return ServerPlayer[]
|
||||||
function Room:getAllPlayers(sortBySeat)
|
function Room:getAllPlayers(sortBySeat)
|
||||||
|
if not self.game_started then
|
||||||
|
return { table.unpack(self.players) }
|
||||||
|
end
|
||||||
if sortBySeat == nil or sortBySeat then
|
if sortBySeat == nil or sortBySeat then
|
||||||
local current = self.current
|
local current = self.current
|
||||||
local temp = current.next
|
local temp = current.next
|
||||||
|
@ -505,19 +510,28 @@ function Room:notifyMoveCards(players, card_moves, forceVisible)
|
||||||
for _, move in ipairs(arg) do
|
for _, move in ipairs(arg) do
|
||||||
-- local to = self:getPlayerById(move.to)
|
-- local to = self:getPlayerById(move.to)
|
||||||
|
|
||||||
|
local function infosContainArea(info, area)
|
||||||
|
for _, i in ipairs(info) do
|
||||||
|
if i.fromArea == area then
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
-- forceVisible make the move visible
|
-- forceVisible make the move visible
|
||||||
-- FIXME: move.moveInfo is an array, fix this
|
-- FIXME: move.moveInfo is an array, fix this
|
||||||
move.moveVisible = (forceVisible)
|
move.moveVisible = (forceVisible)
|
||||||
-- if move is relevant to player, it should be open
|
-- if move is relevant to player, it should be open
|
||||||
or ((move.from == p.id) or (move.to == p.id and move.toArea ~= Card.PlayerSpecial))
|
or ((move.from == p.id) or (move.to == p.id and move.toArea ~= Card.PlayerSpecial))
|
||||||
-- cards move from/to equip/judge/discard/processing should be open
|
-- cards move from/to equip/judge/discard/processing should be open
|
||||||
or move.moveInfo.fromArea == Card.PlayerEquip
|
or infosContainArea(move.moveInfo, Card.PlayerEquip)
|
||||||
or move.toArea == Card.PlayerEquip
|
or move.toArea == Card.PlayerEquip
|
||||||
or move.moveInfo.fromArea == Card.PlayerJudge
|
or infosContainArea(move.moveInfo, Card.PlayerJudge)
|
||||||
or move.toArea == Card.PlayerJudge
|
or move.toArea == Card.PlayerJudge
|
||||||
or move.moveInfo.fromArea == Card.DiscardPile
|
or infosContainArea(move.moveInfo, Card.DiscardPile)
|
||||||
or move.toArea == Card.DiscardPile
|
or move.toArea == Card.DiscardPile
|
||||||
or move.moveInfo.fromArea == Card.Processing
|
or infosContainArea(move.moveInfo, Card.Processing)
|
||||||
or move.toArea == Card.Processing
|
or move.toArea == Card.Processing
|
||||||
-- TODO: PlayerSpecial
|
-- TODO: PlayerSpecial
|
||||||
|
|
||||||
|
@ -1413,7 +1427,7 @@ function Room:useCard(cardUseEvent)
|
||||||
|
|
||||||
collaboratorsIndex[toId] = collaboratorsIndex[toId] + 1
|
collaboratorsIndex[toId] = collaboratorsIndex[toId] + 1
|
||||||
|
|
||||||
self:doCardEffect(cardEffectEvent)
|
self:doCardEffect(table.simpleClone(cardEffectEvent))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -2276,6 +2290,7 @@ function Room:shuffleDrawPile()
|
||||||
end
|
end
|
||||||
|
|
||||||
function Room:gameOver(winner)
|
function Room:gameOver(winner)
|
||||||
|
self.game_started = false
|
||||||
self.game_finished = true
|
self.game_finished = true
|
||||||
|
|
||||||
for _, p in ipairs(self.players) do
|
for _, p in ipairs(self.players) do
|
||||||
|
|
|
@ -93,6 +93,17 @@ end
|
||||||
---@param player ServerPlayer
|
---@param player ServerPlayer
|
||||||
function ServerPlayer:marshal(player)
|
function ServerPlayer:marshal(player)
|
||||||
local room = self.room
|
local room = self.room
|
||||||
|
if not room.game_started then
|
||||||
|
-- If game does not starts, that mean we are entering room that
|
||||||
|
-- all players are choosing their generals.
|
||||||
|
-- Note that when we are in this function, the main thread must be
|
||||||
|
-- calling delay() or waiting for reply.
|
||||||
|
if self.role_shown then
|
||||||
|
room:notifyProperty(player, self, "role")
|
||||||
|
end
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
room:notifyProperty(player, self, "maxHp")
|
room:notifyProperty(player, self, "maxHp")
|
||||||
room:notifyProperty(player, self, "hp")
|
room:notifyProperty(player, self, "hp")
|
||||||
room:notifyProperty(player, self, "gender")
|
room:notifyProperty(player, self, "gender")
|
||||||
|
@ -165,7 +176,7 @@ function ServerPlayer:marshal(player)
|
||||||
end
|
end
|
||||||
|
|
||||||
for k, v in pairs(self.cardUsedHistory) do
|
for k, v in pairs(self.cardUsedHistory) do
|
||||||
player:doNotify("AddCardUseHistory", json.encode{k, v})
|
player:doNotify("AddCardUseHistory", json.encode{k, v[1]})
|
||||||
end
|
end
|
||||||
|
|
||||||
if self.role_shown then
|
if self.role_shown then
|
||||||
|
|
|
@ -154,12 +154,13 @@ function getAreaItem(area, id) {
|
||||||
|
|
||||||
if (area === Card.PlayerHand) {
|
if (area === Card.PlayerHand) {
|
||||||
return photo.handcardArea;
|
return photo.handcardArea;
|
||||||
} else if (area === Card.PlayerEquip)
|
} else if (area === Card.PlayerEquip) {
|
||||||
return photo.equipArea;
|
return photo.equipArea;
|
||||||
else if (area === Card.PlayerJudge)
|
} else if (area === Card.PlayerJudge) {
|
||||||
return photo.delayedTrickArea;
|
return photo.delayedTrickArea;
|
||||||
else if (area === Card.PlayerSpecial)
|
} else if (area === Card.PlayerSpecial) {
|
||||||
return photo.specialArea;
|
return photo.specialArea;
|
||||||
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue