1. 修复亮将和暗将的性别判断。
2. 下N家和上N家函数。
3. 君主和双势力的脚手架。

---------

Signed-off-by: Mechanel <nyutanislavsky@qq.com>
This commit is contained in:
Nyutanislavsky 2023-09-30 11:51:17 +08:00 committed by GitHub
parent b6d0f17127
commit d816ae4955
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 43 additions and 16 deletions

View File

@ -362,7 +362,7 @@ Item {
} }
Button { Button {
text: qsTr("Search") text: Backend.translate("Search")
enabled: word.text !== "" enabled: word.text !== ""
onClicked: { onClicked: {
listView.currentIndex = 0; listView.currentIndex = 0;

View File

@ -60,7 +60,7 @@ Item {
} }
Button { Button {
text: qsTr("Quit") text: Backend.translate("Quit")
anchors.bottom: parent.bottom anchors.bottom: parent.bottom
onClicked: { onClicked: {
mainStack.pop(); mainStack.pop();

View File

@ -25,6 +25,7 @@ Fk:loadTranslationTable{
["Disable message audio"] = "禁用聊天语音", ["Disable message audio"] = "禁用聊天语音",
["Hide unselectable cards"] = "下移不可选卡牌", ["Hide unselectable cards"] = "下移不可选卡牌",
["Ban General Settings"] = "禁将", ["Ban General Settings"] = "禁将",
["Search"] = "搜索",
["Back"] = "返回", ["Back"] = "返回",
["Refresh Room List"] = "刷新房间列表", ["Refresh Room List"] = "刷新房间列表",

View File

@ -562,8 +562,9 @@ end
--- 获取下家。 --- 获取下家。
---@param ignoreRemoved bool @ 忽略被移除 ---@param ignoreRemoved bool @ 忽略被移除
---@param num interger|nil @ 第几个默认1
---@return ServerPlayer ---@return ServerPlayer
function Player:getNextAlive(ignoreRemoved) function Player:getNextAlive(ignoreRemoved, num)
if #Fk:currentRoom().alive_players == 0 then if #Fk:currentRoom().alive_players == 0 then
return self return self
end end
@ -572,13 +573,27 @@ function Player:getNextAlive(ignoreRemoved)
return self return self
end end
local ret = self.next local ret = self
num = num or 1
for _ = 1, num do
ret = ret.next
while ret.dead or (doNotIgnore and ret:isRemoved()) do while ret.dead or (doNotIgnore and ret:isRemoved()) do
ret = ret.next ret = ret.next
end end
end
return ret return ret
end end
--- 获取上家。
---@param ignoreRemoved bool @ 忽略被移除
---@param num interger|nil @ 第几个默认1
---@return ServerPlayer
function Player:getLastAlive(ignoreRemoved, num)
num = num or 1
local index = ignoreRemoved and #Fk:currentRoom().alive_players or #table.filter(Fk:currentRoom().alive_players, function(p) return not p:isRemoved() end) - num
return self:getNextAlive(ignoreRemoved, index)
end
--- 增加玩家使用特定牌的历史次数。 --- 增加玩家使用特定牌的历史次数。
---@param cardName string @ 牌名 ---@param cardName string @ 牌名
---@param num integer|nil @ 次数 ---@param num integer|nil @ 次数

View File

@ -605,14 +605,15 @@ end
---@param isDeputy bool @ 是否变的是副将 ---@param isDeputy bool @ 是否变的是副将
---@param sendLog bool @ 是否发Log ---@param sendLog bool @ 是否发Log
---@param maxHpChange bool @ 是否改变体力上限,默认改变 ---@param maxHpChange bool @ 是否改变体力上限,默认改变
function Room:changeHero(player, new_general, full, isDeputy, sendLog, maxHpChange) function Room:changeHero(player, new_general, full, isDeputy, sendLog, maxHpChange, kingdomChange)
local new = Fk.generals[new_general] or Fk.generals["sunce"] or Fk.generals["blank_shibing"] local new = Fk.generals[new_general] or Fk.generals["sunce"] or Fk.generals["blank_shibing"]
local kingdom = isDeputy and player.kingdom or new.kingdom kingdomChange = (kingdomChange == nil) and true or kingdomChange
if not isDeputy and (new.kingdom == "god" or new.subkingdom) then local kingdom = (isDeputy or not kingdomChange) and player.kingdom or new.kingdom
if not isDeputy and kingdomChange and (new.kingdom == "god" or new.subkingdom) then
local allKingdoms = {} local allKingdoms = {}
if new.kingdom == "god" then if new.kingdom == "god" then
allKingdoms = {"wei", "shu", "wu", "qun", "jin"} allKingdoms = table.filter({"wei", "shu", "wu", "qun", "jin"}, function(k) return table.contains(Fk.kingdoms, k) end)
elseif new.subkingdom then elseif new.subkingdom then
allKingdoms = { new.kingdom, new.subkingdom } allKingdoms = { new.kingdom, new.subkingdom }
end end
@ -2757,6 +2758,7 @@ function Room:drawCards(player, num, skillName, fromPlace)
num = drawData.num num = drawData.num
fromPlace = drawData.fromPlace fromPlace = drawData.fromPlace
player = drawData.who
local topCards = self:getNCards(num, fromPlace) local topCards = self:getNCards(num, fromPlace)
self:moveCards({ self:moveCards({

View File

@ -891,14 +891,14 @@ function ServerPlayer:revealGeneral(isDeputy, no_trigger)
end end
local oldKingdom = self.kingdom local oldKingdom = self.kingdom
room:changeHero(self, generalName, false, isDeputy, false, false) room:changeHero(self, generalName, false, isDeputy, false, false, false)
if oldKingdom ~= "wild" then if oldKingdom ~= "wild" then
local kingdom = general.kingdom local kingdom = (self:getMark("__heg_wild") == 1 and not isDeputy) and "wild" or self:getMark("__heg_kingdom")
self.kingdom = kingdom self.kingdom = kingdom
if oldKingdom == "unknown" and #table.filter(room:getOtherPlayers(self, false, true), if oldKingdom == "unknown" and kingdom ~= "wild" and #table.filter(room:getOtherPlayers(self, false, true),
function(p) function(p)
return p.kingdom == kingdom return p.kingdom == kingdom
end) >= #room.players // 2 then end) >= #room.players // 2 and table.every(room.alive_players, function(p) return p.kingdom ~= kingdom or not string.find(p.general, "lord") end) then
self.kingdom = "wild" self.kingdom = "wild"
end end
room:broadcastProperty(self, "kingdom") room:broadcastProperty(self, "kingdom")
@ -906,8 +906,8 @@ function ServerPlayer:revealGeneral(isDeputy, no_trigger)
room:setPlayerProperty(self, "kingdom", "wild") room:setPlayerProperty(self, "kingdom", "wild")
end end
if self.gender == General.Agender then if self.gender == General.Agender or self.gender ~= Fk.generals[self.general].gender then
self.gender = general.gender room:setPlayerProperty(self, "gender", general.gender)
end end
room:sendLog{ room:sendLog{
@ -982,8 +982,17 @@ function ServerPlayer:hideGeneral(isDeputy)
end end
end end
room.logic:trigger(fk.GeneralHidden, room, generalName) self.gender = General.Agender
if Fk.generals[self.general].gender ~= General.Agender then
self.gender = Fk.generals[self.general].gender
elseif self.deputyGeneral and Fk.generals[self.deputyGeneral].gender ~= General.Agender then
self.gender = Fk.generals[self.deputyGeneral].gender
end
room:broadcastProperty(self, "gender")
room.logic:trigger(fk.GeneralHidden, self, generalName)
end end
-- 神貂蝉 -- 神貂蝉
---@param p ServerPlayer ---@param p ServerPlayer