Fixbug (#115)
修流离锁定技 修斧子弃自己 修顺手空城卡死 修旁观者id是自己的 修旁观者再开新局就闪退(或许吧) 修拼点报nil 修询问无懈时旁观者被卡在外面 修Room的请求队列不清理干净
This commit is contained in:
parent
28436eb9d4
commit
a735013411
|
@ -236,7 +236,6 @@ end
|
||||||
---@return ProhibitSkill
|
---@return ProhibitSkill
|
||||||
function fk.CreateProhibitSkill(spec)
|
function fk.CreateProhibitSkill(spec)
|
||||||
assert(type(spec.name) == "string")
|
assert(type(spec.name) == "string")
|
||||||
assert(type(spec.is_prohibited) == "function")
|
|
||||||
|
|
||||||
local skill = ProhibitSkill:new(spec.name)
|
local skill = ProhibitSkill:new(spec.name)
|
||||||
readStatusSpecToSkill(skill, spec)
|
readStatusSpecToSkill(skill, spec)
|
||||||
|
|
|
@ -509,6 +509,7 @@ function Room:doRaceRequest(command, players, jsonData)
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
coroutine.yield("__handleRequest", remainTime - elapsed)
|
||||||
fk.QThread_msleep(10)
|
fk.QThread_msleep(10)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -520,13 +521,11 @@ function Room:requestLoop(rest_time)
|
||||||
local observee = self.players[1]
|
local observee = self.players[1]
|
||||||
player:doNotify("Setup", json.encode{
|
player:doNotify("Setup", json.encode{
|
||||||
observee.id,
|
observee.id,
|
||||||
player:getScreenName(),
|
observee.serverplayer:getScreenName(),
|
||||||
player:getAvatar(),
|
observee.serverplayer:getAvatar(),
|
||||||
})
|
})
|
||||||
player:doNotify("EnterRoom", json.encode{
|
player:doNotify("EnterRoom", json.encode{
|
||||||
#self.players, self.timeout,
|
#self.players, self.timeout, self.settings
|
||||||
-- FIXME: use real room settings here
|
|
||||||
{ enableFreeAssign = false }
|
|
||||||
})
|
})
|
||||||
|
|
||||||
-- send player data
|
-- send player data
|
||||||
|
|
|
@ -142,6 +142,7 @@ function ServerPlayer:marshal(player)
|
||||||
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")
|
||||||
|
room:notifyProperty(player, self, "kingdom")
|
||||||
|
|
||||||
if self.kingdom ~= Fk.generals[self.general].kingdom then
|
if self.kingdom ~= Fk.generals[self.general].kingdom then
|
||||||
self.kingdom = Fk.generals[self.general].kingdom
|
self.kingdom = Fk.generals[self.general].kingdom
|
||||||
|
|
|
@ -21,7 +21,7 @@ local discardSkill = fk.CreateActiveSkill{
|
||||||
checkpoint = checkpoint and (Fk:currentRoom():getCardArea(to_select) ~= Player.Equip)
|
checkpoint = checkpoint and (Fk:currentRoom():getCardArea(to_select) ~= Player.Equip)
|
||||||
end
|
end
|
||||||
|
|
||||||
if self.pattern ~= "" then
|
if self.pattern and self.pattern ~= "" then
|
||||||
checkpoint = checkpoint and (Exppattern:Parse(self.pattern):match(card))
|
checkpoint = checkpoint and (Exppattern:Parse(self.pattern):match(card))
|
||||||
end
|
end
|
||||||
return checkpoint
|
return checkpoint
|
||||||
|
@ -33,7 +33,23 @@ local discardSkill = fk.CreateActiveSkill{
|
||||||
local chooseCardsSkill = fk.CreateActiveSkill{
|
local chooseCardsSkill = fk.CreateActiveSkill{
|
||||||
name = "choose_cards_skill",
|
name = "choose_cards_skill",
|
||||||
expand_pile = function(self) return self.expand_pile end,
|
expand_pile = function(self) return self.expand_pile end,
|
||||||
card_filter = discardSkill.cardFilter,
|
card_filter = function(self, to_select, selected)
|
||||||
|
if #selected >= self.num then
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
local checkpoint = true
|
||||||
|
local card = Fk:getCardById(to_select)
|
||||||
|
|
||||||
|
if not self.include_equip then
|
||||||
|
checkpoint = checkpoint and (Fk:currentRoom():getCardArea(to_select) ~= Player.Equip)
|
||||||
|
end
|
||||||
|
|
||||||
|
if self.pattern and self.pattern ~= "" then
|
||||||
|
checkpoint = checkpoint and (Exppattern:Parse(self.pattern):match(card))
|
||||||
|
end
|
||||||
|
return checkpoint
|
||||||
|
end,
|
||||||
min_card_num = function(self) return self.min_num end,
|
min_card_num = function(self) return self.min_num end,
|
||||||
max_card_num = function(self) return self.num end,
|
max_card_num = function(self) return self.num end,
|
||||||
}
|
}
|
||||||
|
|
|
@ -682,7 +682,8 @@ local liuli = fk.CreateTriggerSkill{
|
||||||
on_cost = function(self, event, target, player, data)
|
on_cost = function(self, event, target, player, data)
|
||||||
local room = player.room
|
local room = player.room
|
||||||
local prompt = "#liuli-target"
|
local prompt = "#liuli-target"
|
||||||
local plist, cid = room:askForChooseCardAndPlayers(player, self.target_list, 1, 1, nil, prompt, self.name)
|
local plist, cid = room:askForChooseCardAndPlayers(player,
|
||||||
|
self.target_list, 1, 1, nil, prompt, self.name, true)
|
||||||
if #plist > 0 then
|
if #plist > 0 then
|
||||||
self.cost_data = {plist[1], cid}
|
self.cost_data = {plist[1], cid}
|
||||||
return true
|
return true
|
||||||
|
|
|
@ -206,11 +206,12 @@ local snatchSkill = fk.CreateActiveSkill{
|
||||||
end,
|
end,
|
||||||
target_num = 1,
|
target_num = 1,
|
||||||
on_effect = function(self, room, effect)
|
on_effect = function(self, room, effect)
|
||||||
local to = effect.to
|
local to = room:getPlayerById(effect.to)
|
||||||
local from = effect.from
|
local from = effect.from
|
||||||
|
if to:isAllNude() then return end
|
||||||
local cid = room:askForCardChosen(
|
local cid = room:askForCardChosen(
|
||||||
room:getPlayerById(from),
|
room:getPlayerById(from),
|
||||||
room:getPlayerById(to),
|
to,
|
||||||
"hej",
|
"hej",
|
||||||
self.name
|
self.name
|
||||||
)
|
)
|
||||||
|
@ -335,15 +336,17 @@ local collateralSkill = fk.CreateActiveSkill{
|
||||||
cardUseEvent.tos = { { cardUseEvent.tos[1][1], cardUseEvent.tos[2][1] } }
|
cardUseEvent.tos = { { cardUseEvent.tos[1][1], cardUseEvent.tos[2][1] } }
|
||||||
end,
|
end,
|
||||||
on_effect = function(self, room, effect)
|
on_effect = function(self, room, effect)
|
||||||
local use = room:askForUseCard(
|
local to = room:getPlayerById(effect.to)
|
||||||
room:getPlayerById(effect.to),
|
if not to:getEquipment(Card.SubtypeWeapon) then return end
|
||||||
"slash", nil, nil, nil, { must_targets = effect.subTargets }
|
local use = room:askForUseCard(to, "slash", nil, nil, nil,
|
||||||
)
|
{ must_targets = effect.subTargets })
|
||||||
|
|
||||||
if use then
|
if use then
|
||||||
room:useCard(use)
|
room:useCard(use)
|
||||||
else
|
else
|
||||||
room:obtainCard(effect.from, room:getPlayerById(effect.to):getEquipment(Card.SubtypeWeapon), true, fk.ReasonGive)
|
room:obtainCard(effect.from,
|
||||||
|
room:getPlayerById(effect.to):getEquipment(Card.SubtypeWeapon),
|
||||||
|
true, fk.ReasonGive)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
|
@ -973,6 +976,14 @@ extension:addCards({
|
||||||
spear,
|
spear,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
local axeProhibit = fk.CreateProhibitSkill{
|
||||||
|
name = "#axe_prohibit",
|
||||||
|
prohibit_discard = function(self, player, card)
|
||||||
|
return player:hasSkill(self.name) and card.name == "axe" and
|
||||||
|
Fk.currentResponseReason == "#axe_skill" and
|
||||||
|
Fk:currentRoom():getCardArea(card.id) == Player.Equip
|
||||||
|
end,
|
||||||
|
}
|
||||||
local axeSkill = fk.CreateTriggerSkill{
|
local axeSkill = fk.CreateTriggerSkill{
|
||||||
name = "#axe_skill",
|
name = "#axe_skill",
|
||||||
attached_equip = "axe",
|
attached_equip = "axe",
|
||||||
|
@ -989,6 +1000,7 @@ local axeSkill = fk.CreateTriggerSkill{
|
||||||
end,
|
end,
|
||||||
on_use = function() return true end,
|
on_use = function() return true end,
|
||||||
}
|
}
|
||||||
|
axeSkill:addRelatedSkill(axeProhibit)
|
||||||
Fk:addSkill(axeSkill)
|
Fk:addSkill(axeSkill)
|
||||||
local axe = fk.CreateWeapon{
|
local axe = fk.CreateWeapon{
|
||||||
name = "axe",
|
name = "axe",
|
||||||
|
|
|
@ -57,7 +57,6 @@ Item {
|
||||||
|
|
||||||
Text {
|
Text {
|
||||||
text: Backend.translate("Observe")
|
text: Backend.translate("Observe")
|
||||||
visible: false // FIXME
|
|
||||||
font.pixelSize: 24
|
font.pixelSize: 24
|
||||||
TapHandler {
|
TapHandler {
|
||||||
onTapped: {
|
onTapped: {
|
||||||
|
|
|
@ -102,7 +102,8 @@ void Room::addPlayer(ServerPlayer *player) {
|
||||||
if (runned_players.contains(player->getId())) {
|
if (runned_players.contains(player->getId())) {
|
||||||
player->doNotify("ErrorMsg", "Running away is shameful.");
|
player->doNotify("ErrorMsg", "Running away is shameful.");
|
||||||
}
|
}
|
||||||
// FIXME: add to lobby again
|
// 此时player仍在lobby中,别管就行了
|
||||||
|
// emit playerRemoved(player);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -166,8 +167,6 @@ void Room::addRobot(ServerPlayer *player) {
|
||||||
|
|
||||||
void Room::removePlayer(ServerPlayer *player) {
|
void Room::removePlayer(ServerPlayer *player) {
|
||||||
// 如果是旁观者的话,就清旁观者
|
// 如果是旁观者的话,就清旁观者
|
||||||
// FIXME: 游戏结束后,旁观者若退出房间,则不会调用此处,遂导致bug(大厅加人)
|
|
||||||
// FIXME: 考虑一下把gameOver处的observers.clear()去掉
|
|
||||||
if (observers.contains(player)) {
|
if (observers.contains(player)) {
|
||||||
removeObserver(player);
|
removeObserver(player);
|
||||||
return;
|
return;
|
||||||
|
@ -247,15 +246,17 @@ void Room::addObserver(ServerPlayer *player) {
|
||||||
|
|
||||||
// 向observers中追加player,并从大厅移除player,然后将player的room设为this
|
// 向observers中追加player,并从大厅移除player,然后将player的room设为this
|
||||||
observers.append(player);
|
observers.append(player);
|
||||||
server->lobby()->removePlayer(player);
|
|
||||||
player->setRoom(this);
|
player->setRoom(this);
|
||||||
|
emit playerAdded(player);
|
||||||
pushRequest(QString("%1,observe").arg(player->getId()));
|
pushRequest(QString("%1,observe").arg(player->getId()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Room::removeObserver(ServerPlayer *player) {
|
void Room::removeObserver(ServerPlayer *player) {
|
||||||
// FIXME: 判断一下有没有
|
if (observers.contains(player)) {
|
||||||
observers.removeOne(player);
|
observers.removeOne(player);
|
||||||
server->lobby()->addPlayer(player);
|
}
|
||||||
|
emit playerRemoved(player);
|
||||||
|
|
||||||
if (player->getState() == Player::Online) {
|
if (player->getState() == Player::Online) {
|
||||||
QJsonArray arr;
|
QJsonArray arr;
|
||||||
arr << player->getId();
|
arr << player->getId();
|
||||||
|
@ -263,8 +264,6 @@ void Room::removeObserver(ServerPlayer *player) {
|
||||||
arr << player->getAvatar();
|
arr << player->getAvatar();
|
||||||
player->doNotify("Setup", JsonArray2Bytes(arr));
|
player->doNotify("Setup", JsonArray2Bytes(arr));
|
||||||
}
|
}
|
||||||
// FIXME: 游戏结束后就别加request了,Lua已经没了
|
|
||||||
// FIXME: 但是按理说这东西在Lua没了之后/Lua创建时应该自动清空才对啊
|
|
||||||
pushRequest(QString("%1,leave").arg(player->getId()));
|
pushRequest(QString("%1,leave").arg(player->getId()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -307,12 +306,15 @@ void Room::gameOver() {
|
||||||
p->deleteLater();
|
p->deleteLater();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
observers.clear();
|
// 旁观者不能在这清除,因为removePlayer逻辑不一样
|
||||||
|
// observers.clear();
|
||||||
players.clear();
|
players.clear();
|
||||||
|
clearRequest();
|
||||||
owner = nullptr;
|
owner = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString Room::fetchRequest() {
|
QString Room::fetchRequest() {
|
||||||
|
if (!gameStarted) return "";
|
||||||
request_queue_mutex.lock();
|
request_queue_mutex.lock();
|
||||||
QString ret = "";
|
QString ret = "";
|
||||||
if (!request_queue.isEmpty()) {
|
if (!request_queue.isEmpty()) {
|
||||||
|
@ -323,15 +325,25 @@ QString Room::fetchRequest() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Room::pushRequest(const QString &req) {
|
void Room::pushRequest(const QString &req) {
|
||||||
|
if (!gameStarted) return;
|
||||||
request_queue_mutex.lock();
|
request_queue_mutex.lock();
|
||||||
request_queue.enqueue(req);
|
request_queue.enqueue(req);
|
||||||
request_queue_mutex.unlock();
|
request_queue_mutex.unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Room::clearRequest() {
|
||||||
|
request_queue_mutex.lock();
|
||||||
|
request_queue.clear();
|
||||||
|
request_queue_mutex.unlock();
|
||||||
|
}
|
||||||
|
|
||||||
bool Room::hasRequest() const { return !request_queue.isEmpty(); }
|
bool Room::hasRequest() const { return !request_queue.isEmpty(); }
|
||||||
|
|
||||||
void Room::run() {
|
void Room::run() {
|
||||||
gameStarted = true;
|
gameStarted = true;
|
||||||
|
|
||||||
|
clearRequest();
|
||||||
|
|
||||||
// 此处调用了Lua Room:run()函数
|
// 此处调用了Lua Room:run()函数
|
||||||
roomStart();
|
roomStart();
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,6 +61,7 @@ class Room : public QThread {
|
||||||
|
|
||||||
QString fetchRequest();
|
QString fetchRequest();
|
||||||
void pushRequest(const QString &req);
|
void pushRequest(const QString &req);
|
||||||
|
void clearRequest();
|
||||||
bool hasRequest() const;
|
bool hasRequest() const;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
|
Loading…
Reference in New Issue