修流离锁定技
修斧子弃自己
修顺手空城卡死
修旁观者id是自己的
修旁观者再开新局就闪退(或许吧)
修拼点报nil
修询问无懈时旁观者被卡在外面
修Room的请求队列不清理干净
This commit is contained in:
notify 2023-04-12 22:28:19 +08:00 committed by GitHub
parent 28436eb9d4
commit a735013411
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 67 additions and 27 deletions

View File

@ -236,7 +236,6 @@ end
---@return ProhibitSkill
function fk.CreateProhibitSkill(spec)
assert(type(spec.name) == "string")
assert(type(spec.is_prohibited) == "function")
local skill = ProhibitSkill:new(spec.name)
readStatusSpecToSkill(skill, spec)

View File

@ -509,6 +509,7 @@ function Room:doRaceRequest(command, players, jsonData)
return nil
end
coroutine.yield("__handleRequest", remainTime - elapsed)
fk.QThread_msleep(10)
end
end
@ -520,13 +521,11 @@ function Room:requestLoop(rest_time)
local observee = self.players[1]
player:doNotify("Setup", json.encode{
observee.id,
player:getScreenName(),
player:getAvatar(),
observee.serverplayer:getScreenName(),
observee.serverplayer:getAvatar(),
})
player:doNotify("EnterRoom", json.encode{
#self.players, self.timeout,
-- FIXME: use real room settings here
{ enableFreeAssign = false }
#self.players, self.timeout, self.settings
})
-- send player data

View File

@ -142,6 +142,7 @@ function ServerPlayer:marshal(player)
room:notifyProperty(player, self, "maxHp")
room:notifyProperty(player, self, "hp")
room:notifyProperty(player, self, "gender")
room:notifyProperty(player, self, "kingdom")
if self.kingdom ~= Fk.generals[self.general].kingdom then
self.kingdom = Fk.generals[self.general].kingdom

View File

@ -21,7 +21,7 @@ local discardSkill = fk.CreateActiveSkill{
checkpoint = checkpoint and (Fk:currentRoom():getCardArea(to_select) ~= Player.Equip)
end
if self.pattern ~= "" then
if self.pattern and self.pattern ~= "" then
checkpoint = checkpoint and (Exppattern:Parse(self.pattern):match(card))
end
return checkpoint
@ -33,7 +33,23 @@ local discardSkill = fk.CreateActiveSkill{
local chooseCardsSkill = fk.CreateActiveSkill{
name = "choose_cards_skill",
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,
max_card_num = function(self) return self.num end,
}

View File

@ -682,7 +682,8 @@ local liuli = fk.CreateTriggerSkill{
on_cost = function(self, event, target, player, data)
local room = player.room
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
self.cost_data = {plist[1], cid}
return true

View File

@ -206,11 +206,12 @@ local snatchSkill = fk.CreateActiveSkill{
end,
target_num = 1,
on_effect = function(self, room, effect)
local to = effect.to
local to = room:getPlayerById(effect.to)
local from = effect.from
if to:isAllNude() then return end
local cid = room:askForCardChosen(
room:getPlayerById(from),
room:getPlayerById(to),
to,
"hej",
self.name
)
@ -335,15 +336,17 @@ local collateralSkill = fk.CreateActiveSkill{
cardUseEvent.tos = { { cardUseEvent.tos[1][1], cardUseEvent.tos[2][1] } }
end,
on_effect = function(self, room, effect)
local use = room:askForUseCard(
room:getPlayerById(effect.to),
"slash", nil, nil, nil, { must_targets = effect.subTargets }
)
local to = room:getPlayerById(effect.to)
if not to:getEquipment(Card.SubtypeWeapon) then return end
local use = room:askForUseCard(to, "slash", nil, nil, nil,
{ must_targets = effect.subTargets })
if use then
room:useCard(use)
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
}
@ -973,6 +976,14 @@ extension:addCards({
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{
name = "#axe_skill",
attached_equip = "axe",
@ -989,6 +1000,7 @@ local axeSkill = fk.CreateTriggerSkill{
end,
on_use = function() return true end,
}
axeSkill:addRelatedSkill(axeProhibit)
Fk:addSkill(axeSkill)
local axe = fk.CreateWeapon{
name = "axe",

View File

@ -57,7 +57,6 @@ Item {
Text {
text: Backend.translate("Observe")
visible: false // FIXME
font.pixelSize: 24
TapHandler {
onTapped: {

View File

@ -102,7 +102,8 @@ void Room::addPlayer(ServerPlayer *player) {
if (runned_players.contains(player->getId())) {
player->doNotify("ErrorMsg", "Running away is shameful.");
}
// FIXME: add to lobby again
// 此时player仍在lobby中别管就行了
// emit playerRemoved(player);
return;
}
@ -166,8 +167,6 @@ void Room::addRobot(ServerPlayer *player) {
void Room::removePlayer(ServerPlayer *player) {
// 如果是旁观者的话,就清旁观者
// FIXME: 游戏结束后旁观者若退出房间则不会调用此处遂导致bug(大厅加人)
// FIXME: 考虑一下把gameOver处的observers.clear()去掉
if (observers.contains(player)) {
removeObserver(player);
return;
@ -247,15 +246,17 @@ void Room::addObserver(ServerPlayer *player) {
// 向observers中追加player并从大厅移除player然后将player的room设为this
observers.append(player);
server->lobby()->removePlayer(player);
player->setRoom(this);
emit playerAdded(player);
pushRequest(QString("%1,observe").arg(player->getId()));
}
void Room::removeObserver(ServerPlayer *player) {
// FIXME: 判断一下有没有
if (observers.contains(player)) {
observers.removeOne(player);
server->lobby()->addPlayer(player);
}
emit playerRemoved(player);
if (player->getState() == Player::Online) {
QJsonArray arr;
arr << player->getId();
@ -263,8 +264,6 @@ void Room::removeObserver(ServerPlayer *player) {
arr << player->getAvatar();
player->doNotify("Setup", JsonArray2Bytes(arr));
}
// FIXME: 游戏结束后就别加request了Lua已经没了
// FIXME: 但是按理说这东西在Lua没了之后/Lua创建时应该自动清空才对啊
pushRequest(QString("%1,leave").arg(player->getId()));
}
@ -307,12 +306,15 @@ void Room::gameOver() {
p->deleteLater();
}
}
observers.clear();
// 旁观者不能在这清除因为removePlayer逻辑不一样
// observers.clear();
players.clear();
clearRequest();
owner = nullptr;
}
QString Room::fetchRequest() {
if (!gameStarted) return "";
request_queue_mutex.lock();
QString ret = "";
if (!request_queue.isEmpty()) {
@ -323,15 +325,25 @@ QString Room::fetchRequest() {
}
void Room::pushRequest(const QString &req) {
if (!gameStarted) return;
request_queue_mutex.lock();
request_queue.enqueue(req);
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(); }
void Room::run() {
gameStarted = true;
clearRequest();
// 此处调用了Lua Room:run()函数
roomStart();
}

View File

@ -61,6 +61,7 @@ class Room : public QThread {
QString fetchRequest();
void pushRequest(const QString &req);
void clearRequest();
bool hasRequest() const;
signals: