2022-03-27 14:49:41 +08:00
|
|
|
local Room = class("Room")
|
2022-03-25 12:28:07 +08:00
|
|
|
|
2022-03-27 14:49:41 +08:00
|
|
|
function Room:initialize(_room)
|
|
|
|
self.room = _room
|
|
|
|
self.players = {}
|
|
|
|
self.gameFinished = false
|
|
|
|
end
|
|
|
|
|
|
|
|
-- When this function returns, the Room(C++) thread stopped.
|
|
|
|
function Room:run()
|
|
|
|
print 'Room is running!'
|
|
|
|
-- First, create players(Lua) from ServerPlayer(C++)
|
|
|
|
for _, p in freekill.qlist(self.room:getPlayers()) do
|
|
|
|
local player = ServerPlayer:new(p)
|
|
|
|
print(player:getId())
|
|
|
|
table.insert(self.players, p)
|
|
|
|
end
|
|
|
|
-- Second, assign role and adjust seats
|
|
|
|
-- Then let's choose general and start the game!
|
|
|
|
end
|
2022-03-25 12:28:07 +08:00
|
|
|
|
2022-03-27 14:49:41 +08:00
|
|
|
function Room:startGame()
|
|
|
|
while true do
|
|
|
|
if self.gameFinished then break end
|
|
|
|
end
|
2022-03-25 12:28:07 +08:00
|
|
|
end
|
|
|
|
|
2022-03-27 14:49:41 +08:00
|
|
|
function Room:gameOver()
|
|
|
|
self.gameFinished = true
|
|
|
|
-- dosomething
|
|
|
|
self.room:gameOver()
|
2022-03-25 12:28:07 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
return Room
|