Modify process & UI component (#98)
耦老周泰 点牌堆弹出牌 --------- Co-authored-by: Ho-spair <linyuy@163.com>
This commit is contained in:
parent
64f095d98f
commit
2e37b46234
|
@ -11,12 +11,17 @@ GameEvent.functions[GameEvent.Dying] = function(self)
|
|||
self.logic:trigger(fk.EnterDying, dyingPlayer, dyingStruct)
|
||||
|
||||
if dyingPlayer.hp < 1 then
|
||||
self.logic:trigger(fk.Dying, dyingPlayer, dyingStruct)
|
||||
self.logic:trigger(fk.AskForPeaches, dyingPlayer, dyingStruct)
|
||||
-- self.logic:trigger(fk.Dying, dyingPlayer, dyingStruct)
|
||||
local savers = self:getAlivePlayers()
|
||||
for _, p in ipairs(savers) do
|
||||
if dyingPlayer.hp > 0 or dyingPlayer.dead or self.logic:trigger(fk.AskForPeaches, p, dyingStruct) then
|
||||
break
|
||||
end
|
||||
end
|
||||
self.logic:trigger(fk.AskForPeachesDone, dyingPlayer, dyingStruct)
|
||||
end
|
||||
|
||||
if not dyingPlayer.dead then
|
||||
if not dyingPlayer.dead and dyingPlayer.dying then
|
||||
dyingPlayer.dying = false
|
||||
self:broadcastProperty(dyingPlayer, "dying")
|
||||
end
|
||||
|
|
|
@ -74,7 +74,7 @@ GameEvent.functions[GameEvent.ChangeHp] = function(self)
|
|||
self.logic:trigger(fk.HpChanged, player, data)
|
||||
|
||||
if player.hp < 1 then
|
||||
if num < 0 then
|
||||
if num < 0 and not data.preventDying then
|
||||
---@type DyingStruct
|
||||
local dyingStruct = {
|
||||
who = player.id,
|
||||
|
@ -84,6 +84,7 @@ GameEvent.functions[GameEvent.ChangeHp] = function(self)
|
|||
end
|
||||
elseif player.dying then
|
||||
player.dying = false
|
||||
self:broadcastProperty(player, "dying")
|
||||
end
|
||||
|
||||
return true
|
||||
|
|
|
@ -268,6 +268,7 @@ function GameLogic:trigger(event, target, data)
|
|||
local skill_name = room:askForChoice(player, skill_names, "trigger", "#choose-trigger")
|
||||
local skill = triggerables[table.indexOf(skill_names, skill_name)]
|
||||
broken = skill:trigger(event, target, player, data)
|
||||
broken = broken or (event == fk.AskForPeaches and room:getPlayerById(data.who).hp > 0)
|
||||
if broken then break end
|
||||
table.removeOne(skill_names, skill_name)
|
||||
table.removeOne(triggerables, skill)
|
||||
|
|
|
@ -928,8 +928,9 @@ end
|
|||
---@param cancelable boolean @ 能不能点取消
|
||||
---@param pattern string @ 选牌规则
|
||||
---@param prompt string @ 提示信息
|
||||
---@param expand_pile string @ 可选私人牌堆名称
|
||||
---@return integer[] @ 选择的牌的id列表,可能是空的
|
||||
function Room:askForCard(player, minNum, maxNum, includeEquip, skillName, cancelable, pattern, prompt)
|
||||
function Room:askForCard(player, minNum, maxNum, includeEquip, skillName, cancelable, pattern, prompt, expand_pile)
|
||||
if minNum < 1 then
|
||||
return nil
|
||||
end
|
||||
|
@ -943,6 +944,7 @@ function Room:askForCard(player, minNum, maxNum, includeEquip, skillName, cancel
|
|||
include_equip = includeEquip,
|
||||
reason = skillName,
|
||||
pattern = pattern,
|
||||
expand_pile = expand_pile,
|
||||
}
|
||||
local prompt = prompt or ("#AskForCard:::" .. maxNum .. ":" .. minNum)
|
||||
local _, ret = self:askForUseActiveSkill(player, "choose_cards_skill", prompt, cancelable, data)
|
||||
|
|
|
@ -37,6 +37,7 @@
|
|||
---@field public reason string @ 体力变化原因
|
||||
---@field public skillName string @ 引起体力变化的技能名
|
||||
---@field public damageEvent DamageStruct|nil @ 引起这次体力变化的伤害数据
|
||||
---@field public preventDying boolean|null @ 是否阻止本次体力变更流程引发濒死流程
|
||||
|
||||
--- 描述跟失去体力有关的数据
|
||||
---@class HpLostData
|
||||
|
@ -71,6 +72,7 @@ fk.FireDamage = 3
|
|||
---@class DyingStruct
|
||||
---@field public who integer
|
||||
---@field public damage DamageStruct
|
||||
---@field public ignoreDeath boolean|null
|
||||
|
||||
---@class DeathStruct
|
||||
---@field public who integer
|
||||
|
|
|
@ -21,6 +21,7 @@ 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,
|
||||
min_card_num = function(self) return self.min_num end,
|
||||
max_card_num = function(self) return self.num end,
|
||||
|
|
|
@ -198,28 +198,25 @@ GameRule = fk.CreateTriggerSkill{
|
|||
end
|
||||
end,
|
||||
[fk.AskForPeaches] = function()
|
||||
local savers = room:getAlivePlayers()
|
||||
for _, p in ipairs(savers) do
|
||||
if player.hp > 0 or player.dead then break end
|
||||
while player.hp < 1 do
|
||||
local pattern = "peach"
|
||||
if p == player then
|
||||
pattern = pattern .. ",analeptic"
|
||||
end
|
||||
|
||||
local peach_use = room:askForUseCard(p, "peach", pattern)
|
||||
if not peach_use then break end
|
||||
peach_use.tos = { {player.id} }
|
||||
if peach_use.card.trueName == "analeptic" then
|
||||
peach_use.extra_data = peach_use.extra_data or {}
|
||||
peach_use.extra_data.analepticRecover = true
|
||||
end
|
||||
room:useCard(peach_use)
|
||||
local dyingPlayer = room:getPlayerById(data.who)
|
||||
while dyingPlayer.hp < 1 do
|
||||
local pattern = "peach"
|
||||
if player == dyingPlayer then
|
||||
pattern = pattern .. ",analeptic"
|
||||
end
|
||||
|
||||
local peach_use = room:askForUseCard(player, "peach", pattern)
|
||||
if not peach_use then break end
|
||||
peach_use.tos = { {dyingPlayer.id} }
|
||||
if peach_use.card.trueName == "analeptic" then
|
||||
peach_use.extra_data = peach_use.extra_data or {}
|
||||
peach_use.extra_data.analepticRecover = true
|
||||
end
|
||||
room:useCard(peach_use)
|
||||
end
|
||||
end,
|
||||
[fk.AskForPeachesDone] = function()
|
||||
if player.hp < 1 then
|
||||
if player.hp < 1 and not data.ignoreDeath then
|
||||
---@type DeathStruct
|
||||
local deathData = {
|
||||
who = player.id,
|
||||
|
|
|
@ -262,8 +262,8 @@ RowLayout {
|
|||
[pending_skill, cid, pendings, targets]
|
||||
))) {
|
||||
enabled_cards.push(cid);
|
||||
if (!expanded_piles[pile_name]) {
|
||||
expandPile(pile_name);
|
||||
if (!expanded_piles[pile]) {
|
||||
expandPile(pile);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
import QtQuick
|
||||
import QtQuick.Layouts
|
||||
import QtQuick.Controls
|
||||
import Qt5Compat.GraphicalEffects
|
||||
|
||||
Item {
|
||||
id: root
|
||||
|
@ -6,9 +9,81 @@ Item {
|
|||
property var extra_data: ({})
|
||||
signal finish()
|
||||
|
||||
// TODO: complete this ......
|
||||
Text {
|
||||
Rectangle {
|
||||
anchors.fill: parent
|
||||
text: JSON.stringify(extra_data)
|
||||
color: "black"
|
||||
|
||||
GlowText {
|
||||
id: pileName
|
||||
text: Backend.translate(extra_data.name)
|
||||
width: parent.width
|
||||
anchors.topMargin: 10
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
font.family: fontLibian.name
|
||||
color: "#E4D5A0"
|
||||
font.pixelSize: 30
|
||||
font.weight: Font.Medium
|
||||
glow.color: "black"
|
||||
glow.spread: 0.3
|
||||
glow.radius: 5
|
||||
}
|
||||
|
||||
LinearGradient {
|
||||
anchors.fill: pileName
|
||||
source: pileName
|
||||
gradient: Gradient {
|
||||
GradientStop {
|
||||
position: 0
|
||||
color: "#FEF7C2"
|
||||
}
|
||||
|
||||
GradientStop {
|
||||
position: 0.5
|
||||
color: "#D2AD4A"
|
||||
}
|
||||
|
||||
GradientStop {
|
||||
position: 1
|
||||
color: "#BE9878"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Flickable {
|
||||
id: flickableContainer
|
||||
ScrollBar.vertical: ScrollBar {}
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
anchors.top: parent.top
|
||||
anchors.topMargin: 40
|
||||
flickableDirection: Flickable.VerticalFlick
|
||||
width: parent.width - 20
|
||||
height: parent.height - 40
|
||||
contentWidth: cardsList.width
|
||||
contentHeight: cardsList.height
|
||||
clip: true
|
||||
|
||||
ColumnLayout {
|
||||
id: cardsList
|
||||
|
||||
GridLayout {
|
||||
columns: 4
|
||||
|
||||
Repeater {
|
||||
model: extra_data.ids
|
||||
|
||||
CardItem {
|
||||
id: cardItem
|
||||
width: (flickableContainer.width - 15) / 4
|
||||
height: cardItem.width * 1.4
|
||||
autoBack: false
|
||||
Component.onCompleted: {
|
||||
let data = JSON.parse(Backend.callLuaFunction("GetCardData", [modelData]));
|
||||
setData(data);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue