Fix more bug (#81)

修更多的bug,哪来那么多bug啊
This commit is contained in:
notify 2023-03-18 23:37:21 +08:00 committed by GitHub
parent 5228991930
commit fcddd36a6d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 30 additions and 17 deletions

View File

@ -306,7 +306,7 @@ function Player:getMaxCards()
for _, skill in ipairs(status_skills) do
local c = skill:getCorrect(self)
baseValue = baseValue + c
baseValue = baseValue + (c or 0)
end
return math.max(baseValue, 0)

View File

@ -194,6 +194,10 @@ GameEvent.functions[GameEvent.ChangeMaxHp] = function(self)
player.maxHp = math.max(player.maxHp + num, 0)
self:broadcastProperty(player, "maxHp")
if player.maxHp == 0 then
self:killPlayer({ who = player.id })
end
local diff = player.hp - player.maxHp
if diff > 0 then
if not self:changeHp(player, -diff) then
@ -201,10 +205,6 @@ GameEvent.functions[GameEvent.ChangeMaxHp] = function(self)
end
end
if player.maxHp == 0 then
self:killPlayer({ who = player.id })
end
self.logic:trigger(fk.MaxHpChanged, player, { num = num })
return true
end

View File

@ -1808,7 +1808,7 @@ function Room:handleAddLoseSkills(player, skill_names, source_skill, sendlog, no
s.name
})
if sendlog then
if sendlog and s.visible then
self:sendLog{
type = "#LoseSkill",
from = player.id,
@ -1833,7 +1833,7 @@ function Room:handleAddLoseSkills(player, skill_names, source_skill, sendlog, no
s.name
})
if sendlog then
if sendlog and s.visible then
self:sendLog{
type = "#AcquireSkill",
from = player.id,

View File

@ -460,13 +460,11 @@ function ServerPlayer:addToPile(pile_name, card, visible, skillName)
end
function ServerPlayer:bury()
-- self:clearFlags()
-- self:clearHistory()
self:setCardUseHistory("")
self:setSkillUseHistory("")
self:throwAllCards()
-- self:throwAllMarks()
-- self:clearPiles()
-- self.room:clearPlayerCardLimitation(self, false)
self:throwAllMarks()
self:clearPiles()
end
function ServerPlayer:throwAllCards(flag)
@ -485,6 +483,18 @@ function ServerPlayer:throwAllCards(flag)
end
end
function ServerPlayer:throwAllMarks()
for name, _ in pairs(self.mark) do
self.room:setPlayerMark(self, name, 0)
end
end
function ServerPlayer:clearPiles()
for _, ids in pairs(self.special_cards) do
self.room:throwCard(ids, "", self)
end
end
function ServerPlayer:addVirtualEquip(card)
Player.addVirtualEquip(self, card)
self.room:doBroadcastNotify("AddVirtualEquip", json.encode{

View File

@ -149,6 +149,7 @@ Item {
TapHandler {
acceptedButtons: Qt.LeftButton | Qt.RightButton | Qt.NoButton
gesturePolicy: TapHandler.WithinBounds
onTapped: (p, btn) => {
if (btn === Qt.LeftButton || btn === Qt.NoButton) {

View File

@ -15,6 +15,7 @@ import "../skin-bank.js" as SkinBank
CardItem {
property string kingdom
property int hp
property int maxHp
name: ""
// description: Sanguosha.getGeneralDescription(name)
suit: ""
@ -36,15 +37,15 @@ CardItem {
y: 4
spacing: 1
Repeater {
model: hp > 5 ? 1 : hp
model: (hp > 5 || hp !== maxHp) ? 1 : hp
Image {
source: SkinBank.GENERALCARD_DIR + kingdom + "-magatama"
}
}
Text {
visible: hp > 5
text: "x" + hp
visible: hp > 5 || hp !== maxHp
text: hp === maxHp ? ("x" + hp) : (" " + hp + "/" + maxHp)
color: "white"
font.pixelSize: 14
style: Text.Outline
@ -84,5 +85,6 @@ CardItem {
let data = JSON.parse(Backend.callLuaFunction("GetGeneralData", [name]));
kingdom = data.kingdom;
hp = data.hp;
maxHp = data.maxHp;
}
}

View File

@ -87,7 +87,7 @@ Flickable {
}
}
for (let i = 0; i < not_active_skills.count; i++) {
let item = not_active_skills.at(i);
let item = not_active_skills.get(i);
if (item.orig_skill == skill_name) {
not_active_skills.remove(i);
}