fix observe
This commit is contained in:
parent
297d466b05
commit
0626f2441f
|
@ -99,6 +99,7 @@ Item {
|
||||||
|
|
||||||
Button {
|
Button {
|
||||||
id: surrenderButton
|
id: surrenderButton
|
||||||
|
enabled: !config.observing
|
||||||
text: Backend.translate("Surrender")
|
text: Backend.translate("Surrender")
|
||||||
onClicked: {
|
onClicked: {
|
||||||
if (isStarted && !getPhoto(Self.id).dead) {
|
if (isStarted && !getPhoto(Self.id).dead) {
|
||||||
|
|
|
@ -13,7 +13,7 @@ local function tellRoomToObserver(self, player)
|
||||||
player:doNotify("StartGame", "")
|
player:doNotify("StartGame", "")
|
||||||
|
|
||||||
-- send player data
|
-- send player data
|
||||||
for _, p in ipairs(self:getOtherPlayers(observee, true, true)) do
|
for _, p in ipairs(self:getOtherPlayers(observee, false, true)) do
|
||||||
player:doNotify("AddPlayer", json.encode{
|
player:doNotify("AddPlayer", json.encode{
|
||||||
p.id,
|
p.id,
|
||||||
p._splayer:getScreenName(),
|
p._splayer:getScreenName(),
|
||||||
|
@ -85,7 +85,9 @@ end
|
||||||
|
|
||||||
request_handlers["prelight"] = function(room, id, reqlist)
|
request_handlers["prelight"] = function(room, id, reqlist)
|
||||||
local p = room:getPlayerById(id)
|
local p = room:getPlayerById(id)
|
||||||
p:prelightSkill(reqlist[3], reqlist[4] == "true")
|
if p then
|
||||||
|
p:prelightSkill(reqlist[3], reqlist[4] == "true")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
request_handlers["luckcard"] = function(room, id, reqlist)
|
request_handlers["luckcard"] = function(room, id, reqlist)
|
||||||
|
@ -136,12 +138,13 @@ request_handlers["changeself"] = function(room, id, reqlist)
|
||||||
end
|
end
|
||||||
|
|
||||||
request_handlers["surrender"] = function(room, id, reqlist)
|
request_handlers["surrender"] = function(room, id, reqlist)
|
||||||
|
local player = room:getPlayerById(id)
|
||||||
|
if not player then return end
|
||||||
local logic = room.logic
|
local logic = room.logic
|
||||||
local curEvent = logic:getCurrentEvent()
|
local curEvent = logic:getCurrentEvent()
|
||||||
if curEvent then
|
if curEvent then
|
||||||
curEvent:addExitFunc(
|
curEvent:addExitFunc(
|
||||||
function()
|
function()
|
||||||
local player = room:getPlayerById(id)
|
|
||||||
player.surrendered = true
|
player.surrendered = true
|
||||||
room:broadcastProperty(player, "surrendered")
|
room:broadcastProperty(player, "surrendered")
|
||||||
room:gameOver(Fk.game_modes[room.settings.gameMode]:getWinner(player))
|
room:gameOver(Fk.game_modes[room.settings.gameMode]:getWinner(player))
|
||||||
|
|
Loading…
Reference in New Issue