bug fix (#277)
堆一堆 - 更改了许褚台词 - 让lua认为prompt可以是string - 修改魄袭框,添加extra_data和cancelable - 修复GetNcards的洗牌判定逻辑 - 为聊天添加300字符限制
This commit is contained in:
parent
4d7359d834
commit
edf10893e9
|
@ -114,6 +114,7 @@ Rectangle {
|
||||||
color: "white"
|
color: "white"
|
||||||
clip: true
|
clip: true
|
||||||
font.pixelSize: 14
|
font.pixelSize: 14
|
||||||
|
maximumLength: 300
|
||||||
|
|
||||||
onAccepted: {
|
onAccepted: {
|
||||||
if (text != "") {
|
if (text != "") {
|
||||||
|
|
|
@ -1071,13 +1071,15 @@ callbacks["AskForCardsChosen"] = (jsonData) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
callbacks["AskForPoxi"] = (jsonData) => {
|
callbacks["AskForPoxi"] = (jsonData) => {
|
||||||
const { type, data } = JSON.parse(jsonData);
|
const { type, data, extra_data, cancelable } = JSON.parse(jsonData);
|
||||||
|
|
||||||
roomScene.state = "replying";
|
roomScene.state = "replying";
|
||||||
roomScene.popupBox.sourceComponent = Qt.createComponent("../RoomElement/PoxiBox.qml");
|
roomScene.popupBox.sourceComponent = Qt.createComponent("../RoomElement/PoxiBox.qml");
|
||||||
const box = roomScene.popupBox.item;
|
const box = roomScene.popupBox.item;
|
||||||
box.poxi_type = type;
|
box.poxi_type = type;
|
||||||
box.card_data = data;
|
box.card_data = data;
|
||||||
|
box.extra_data = extra_data;
|
||||||
|
box.cancelable = cancelable;
|
||||||
for (let d of data) {
|
for (let d of data) {
|
||||||
const arr = [];
|
const arr = [];
|
||||||
const ids = d[1];
|
const ids = d[1];
|
||||||
|
|
|
@ -11,13 +11,15 @@ GraphicsBox {
|
||||||
|
|
||||||
// TODO: Adjust the UI design in case there are more than 7 cards
|
// TODO: Adjust the UI design in case there are more than 7 cards
|
||||||
width: 70 + 700
|
width: 70 + 700
|
||||||
height: 64 + Math.min(cardView.contentHeight, 400) + 20
|
height: 64 + Math.min(cardView.contentHeight, 400) + 30
|
||||||
|
|
||||||
signal cardSelected(int cid)
|
signal cardSelected(int cid)
|
||||||
signal cardsSelected(var ids)
|
signal cardsSelected(var ids)
|
||||||
property var selected_ids: []
|
property var selected_ids: []
|
||||||
property string poxi_type
|
property string poxi_type
|
||||||
property var card_data
|
property var card_data
|
||||||
|
property bool cancelable: true
|
||||||
|
property var extra_data
|
||||||
|
|
||||||
ListModel {
|
ListModel {
|
||||||
id: cardModel
|
id: cardModel
|
||||||
|
@ -29,14 +31,14 @@ GraphicsBox {
|
||||||
anchors.topMargin: 40
|
anchors.topMargin: 40
|
||||||
anchors.leftMargin: 20
|
anchors.leftMargin: 20
|
||||||
anchors.rightMargin: 20
|
anchors.rightMargin: 20
|
||||||
anchors.bottomMargin: 20
|
anchors.bottomMargin: 30
|
||||||
spacing: 20
|
spacing: 20
|
||||||
model: cardModel
|
model: cardModel
|
||||||
clip: true
|
clip: true
|
||||||
|
|
||||||
delegate: RowLayout {
|
delegate: RowLayout {
|
||||||
spacing: 15
|
spacing: 15
|
||||||
visible: areaCards.count > 0
|
// visible: areaCards.count > 0
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
border.color: "#A6967A"
|
border.color: "#A6967A"
|
||||||
|
@ -72,7 +74,7 @@ GraphicsBox {
|
||||||
selectable: {
|
selectable: {
|
||||||
return root.selected_ids.includes(model.cid) || JSON.parse(Backend.callLuaFunction(
|
return root.selected_ids.includes(model.cid) || JSON.parse(Backend.callLuaFunction(
|
||||||
"PoxiFilter",
|
"PoxiFilter",
|
||||||
[root.poxi_type, model.cid, root.selected_ids, root.card_data]
|
[root.poxi_type, model.cid, root.selected_ids, root.card_data, root.extra_data]
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
onSelectedChanged: {
|
onSelectedChanged: {
|
||||||
|
@ -91,18 +93,36 @@ GraphicsBox {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MetroButton {
|
Row {
|
||||||
|
anchors.margins: 8
|
||||||
anchors.bottom: parent.bottom
|
anchors.bottom: parent.bottom
|
||||||
|
anchors.horizontalCenter: parent.horizontalCenter
|
||||||
|
spacing: 32
|
||||||
|
|
||||||
|
MetroButton {
|
||||||
|
width: 120
|
||||||
|
height: 35
|
||||||
text: Backend.translate("OK")
|
text: Backend.translate("OK")
|
||||||
enabled: {
|
enabled: {
|
||||||
return JSON.parse(Backend.callLuaFunction(
|
return JSON.parse(Backend.callLuaFunction(
|
||||||
"PoxiFeasible",
|
"PoxiFeasible",
|
||||||
[root.poxi_type, root.selected_ids, root.card_data]
|
[root.poxi_type, root.selected_ids, root.card_data, root.extra_data]
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
onClicked: root.cardsSelected(root.selected_ids)
|
onClicked: root.cardsSelected(root.selected_ids)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MetroButton {
|
||||||
|
width: 120
|
||||||
|
height: 35
|
||||||
|
text: Backend.translate("Cancel")
|
||||||
|
enabled: root.cancelable
|
||||||
|
onClicked: root.cardsSelected([])
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
onCardSelected: finished();
|
onCardSelected: finished();
|
||||||
|
|
||||||
function findAreaModel(name) {
|
function findAreaModel(name) {
|
||||||
|
|
|
@ -722,16 +722,16 @@ function PoxiPrompt(poxi_type, data)
|
||||||
return poxi.prompt(data)
|
return poxi.prompt(data)
|
||||||
end
|
end
|
||||||
|
|
||||||
function PoxiFilter(poxi_type, to_select, selected, data)
|
function PoxiFilter(poxi_type, to_select, selected, data, extra_data)
|
||||||
local poxi = Fk.poxi_methods[poxi_type]
|
local poxi = Fk.poxi_methods[poxi_type]
|
||||||
if not poxi then return "false" end
|
if not poxi then return "false" end
|
||||||
return json.encode(poxi.card_filter(to_select, selected, data))
|
return json.encode(poxi.card_filter(to_select, selected, data, extra_data))
|
||||||
end
|
end
|
||||||
|
|
||||||
function PoxiFeasible(poxi_type, selected, data)
|
function PoxiFeasible(poxi_type, selected, data, extra_data)
|
||||||
local poxi = Fk.poxi_methods[poxi_type]
|
local poxi = Fk.poxi_methods[poxi_type]
|
||||||
if not poxi then return "false" end
|
if not poxi then return "false" end
|
||||||
return json.encode(poxi.feasible(selected, data))
|
return json.encode(poxi.feasible(selected, data, extra_data))
|
||||||
end
|
end
|
||||||
|
|
||||||
dofile "lua/client/i18n/init.lua"
|
dofile "lua/client/i18n/init.lua"
|
||||||
|
|
|
@ -126,6 +126,7 @@ end
|
||||||
Util.NameMapper = function(e) return e.name end
|
Util.NameMapper = function(e) return e.name end
|
||||||
Util.Name2GeneralMapper = function(e) return Fk.generals[e] end
|
Util.Name2GeneralMapper = function(e) return Fk.generals[e] end
|
||||||
Util.Name2SkillMapper = function(e) return Fk.skills[e] end
|
Util.Name2SkillMapper = function(e) return Fk.skills[e] end
|
||||||
|
Util.TranslateMapper = function(str) return Fk:translate(str) end
|
||||||
|
|
||||||
-- for card preset
|
-- for card preset
|
||||||
Util.GlobalCanUse = function(self, player, card)
|
Util.GlobalCanUse = function(self, player, card)
|
||||||
|
|
|
@ -179,7 +179,7 @@ end
|
||||||
---@field public on_effect nil|fun(self: ActiveSkill, room: Room, cardEffectEvent: CardEffectEvent): bool
|
---@field public on_effect nil|fun(self: ActiveSkill, room: Room, cardEffectEvent: CardEffectEvent): bool
|
||||||
---@field public on_nullified nil|fun(self: ActiveSkill, room: Room, cardEffectEvent: CardEffectEvent): bool
|
---@field public on_nullified nil|fun(self: ActiveSkill, room: Room, cardEffectEvent: CardEffectEvent): bool
|
||||||
---@field public mod_target_filter nil|fun(self: ActiveSkill, to_select: integer, selected: integer[], user: integer, card: Card, distance_limited: boolean): bool
|
---@field public mod_target_filter nil|fun(self: ActiveSkill, to_select: integer, selected: integer[], user: integer, card: Card, distance_limited: boolean): bool
|
||||||
---@field public prompt nil|fun(self: ActiveSkill, selected: integer[], selected_cards: integer[]): string
|
---@field public prompt nil|string|fun(self: ActiveSkill, selected: integer[], selected_cards: integer[]): string
|
||||||
---@field public interaction any
|
---@field public interaction any
|
||||||
|
|
||||||
---@param spec ActiveSkillSpec
|
---@param spec ActiveSkillSpec
|
||||||
|
@ -228,7 +228,7 @@ end
|
||||||
---@field public enabled_at_play nil|fun(self: ViewAsSkill, player: Player): bool
|
---@field public enabled_at_play nil|fun(self: ViewAsSkill, player: Player): bool
|
||||||
---@field public enabled_at_response nil|fun(self: ViewAsSkill, player: Player, response: boolean): bool
|
---@field public enabled_at_response nil|fun(self: ViewAsSkill, player: Player, response: boolean): bool
|
||||||
---@field public before_use nil|fun(self: ViewAsSkill, player: ServerPlayer, use: CardUseStruct)
|
---@field public before_use nil|fun(self: ViewAsSkill, player: ServerPlayer, use: CardUseStruct)
|
||||||
---@field public prompt nil|fun(self: ActiveSkill, selected: integer[], selected_cards: integer[]): string
|
---@field public prompt nil|string|fun(self: ActiveSkill, selected: integer[], selected_cards: integer[]): string
|
||||||
|
|
||||||
---@param spec ViewAsSkillSpec
|
---@param spec ViewAsSkillSpec
|
||||||
---@return ViewAsSkill
|
---@return ViewAsSkill
|
||||||
|
@ -593,8 +593,8 @@ end
|
||||||
|
|
||||||
---@class PoxiSpec
|
---@class PoxiSpec
|
||||||
---@field name string
|
---@field name string
|
||||||
---@field card_filter fun(to_select: int, selected: int[], data: any): bool
|
---@field card_filter fun(to_select: int, selected: int[], data: any, extra_data: any): bool
|
||||||
---@field feasible fun(selected: int[], data: any): bool
|
---@field feasible fun(selected: int[], data: any, extra_data: any): bool
|
||||||
---@field post_select nil | fun(selected: int[], data: any): int[]
|
---@field post_select nil | fun(selected: int[], data: any, extra_data: any): int[]
|
||||||
---@field default_choice nil | fun(data: any): int[]
|
---@field default_choice nil | fun(data: any, extra_data: any): int[]
|
||||||
---@field prompt nil | string | fun(data: any): string
|
---@field prompt nil | string | fun(data: any, extra_data: any): string
|
||||||
|
|
|
@ -439,16 +439,16 @@ end
|
||||||
function Room:getNCards(num, from)
|
function Room:getNCards(num, from)
|
||||||
from = from or "top"
|
from = from or "top"
|
||||||
assert(from == "top" or from == "bottom")
|
assert(from == "top" or from == "bottom")
|
||||||
|
if #self.draw_pile < num then
|
||||||
local cardIds = {}
|
|
||||||
while num > 0 do
|
|
||||||
if #self.draw_pile < 1 then
|
|
||||||
self:shuffleDrawPile()
|
self:shuffleDrawPile()
|
||||||
if #self.draw_pile < 1 then
|
if #self.draw_pile < num then
|
||||||
self:gameOver("")
|
self:gameOver("")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local cardIds = {}
|
||||||
|
while num > 0 do
|
||||||
|
|
||||||
local index = from == "top" and 1 or #self.draw_pile
|
local index = from == "top" and 1 or #self.draw_pile
|
||||||
table.insert(cardIds, self.draw_pile[index])
|
table.insert(cardIds, self.draw_pile[index])
|
||||||
table.remove(self.draw_pile, index)
|
table.remove(self.draw_pile, index)
|
||||||
|
@ -1565,8 +1565,10 @@ end
|
||||||
---@param player ServerPlayer
|
---@param player ServerPlayer
|
||||||
---@param poxi_type string
|
---@param poxi_type string
|
||||||
---@param data any
|
---@param data any
|
||||||
|
---@param extra_data any
|
||||||
|
---@param cancelable nil|bool
|
||||||
---@return integer[]
|
---@return integer[]
|
||||||
function Room:askForPoxi(player, poxi_type, data)
|
function Room:askForPoxi(player, poxi_type, data, extra_data, cancelable)
|
||||||
local poxi = Fk.poxi_methods[poxi_type]
|
local poxi = Fk.poxi_methods[poxi_type]
|
||||||
if not poxi then return {} end
|
if not poxi then return {} end
|
||||||
|
|
||||||
|
@ -1575,12 +1577,14 @@ function Room:askForPoxi(player, poxi_type, data)
|
||||||
local result = self:doRequest(player, command, json.encode {
|
local result = self:doRequest(player, command, json.encode {
|
||||||
type = poxi_type,
|
type = poxi_type,
|
||||||
data = data,
|
data = data,
|
||||||
|
extra_data = extra_data,
|
||||||
|
cancelable = (cancelable == nil) and true or cancelable
|
||||||
})
|
})
|
||||||
|
|
||||||
if result == "" then
|
if result == "" then
|
||||||
return poxi.default_choice(data)
|
return poxi.default_choice(data, extra_data)
|
||||||
else
|
else
|
||||||
return poxi.post_select(json.decode(result), data)
|
return poxi.post_select(json.decode(result), data, extra_data)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -52,7 +52,7 @@ Fk:loadTranslationTable{
|
||||||
|
|
||||||
["xuchu"] = "许褚",
|
["xuchu"] = "许褚",
|
||||||
["~xuchu"] = "冷,好冷啊……",
|
["~xuchu"] = "冷,好冷啊……",
|
||||||
["$luoyi1"] = "破!",
|
["$luoyi1"] = "脱!",
|
||||||
["$luoyi2"] = "谁来与我大战三百回合?",
|
["$luoyi2"] = "谁来与我大战三百回合?",
|
||||||
["luoyi"] = "裸衣",
|
["luoyi"] = "裸衣",
|
||||||
[":luoyi"] = "摸牌阶段,你可以少摸一张牌,若如此做,本回合你使用【杀】或【决斗】对目标角色造成伤害时,此伤害+1。",
|
[":luoyi"] = "摸牌阶段,你可以少摸一张牌,若如此做,本回合你使用【杀】或【决斗】对目标角色造成伤害时,此伤害+1。",
|
||||||
|
|
|
@ -93,7 +93,7 @@ local control = fk.CreateActiveSkill{
|
||||||
-- p(room:askForPoxi(from, "test", {
|
-- p(room:askForPoxi(from, "test", {
|
||||||
-- { "你自己", from:getCardIds "h" },
|
-- { "你自己", from:getCardIds "h" },
|
||||||
-- { "对方", to:getCardIds "h" },
|
-- { "对方", to:getCardIds "h" },
|
||||||
-- }))
|
-- }, from.hp, false))
|
||||||
-- room:setPlayerMark(from, "@$a", {1,2,3})
|
-- room:setPlayerMark(from, "@$a", {1,2,3})
|
||||||
-- room:setPlayerMark(from, "@$b", {'slash','duel','axe'})
|
-- room:setPlayerMark(from, "@$b", {'slash','duel','axe'})
|
||||||
if to:getMark("mouxushengcontrolled") == 0 then
|
if to:getMark("mouxushengcontrolled") == 0 then
|
||||||
|
@ -133,15 +133,15 @@ local control = fk.CreateActiveSkill{
|
||||||
--[[
|
--[[
|
||||||
Fk:addPoxiMethod{
|
Fk:addPoxiMethod{
|
||||||
name = "test",
|
name = "test",
|
||||||
card_filter = function(to_select, selected, data)
|
card_filter = function(to_select, selected, data, extra_data)
|
||||||
local s = Fk:getCardById(to_select).suit
|
local s = Fk:getCardById(to_select).suit
|
||||||
for _, id in ipairs(selected) do
|
for _, id in ipairs(selected) do
|
||||||
if Fk:getCardById(id).suit == s then return false end
|
if Fk:getCardById(id).suit == s then return false end
|
||||||
end
|
end
|
||||||
return true
|
return true
|
||||||
end,
|
end,
|
||||||
feasible = function(selected, data)
|
feasible = function(selected, data, extra_data)
|
||||||
return #selected == 0 or #selected == 4
|
return #selected == 0 or #selected == 4 or #selected == extra_data
|
||||||
end,
|
end,
|
||||||
prompt = "魄袭:选你们俩手牌总共四个花色,或者不选直接按确定按钮"
|
prompt = "魄袭:选你们俩手牌总共四个花色,或者不选直接按确定按钮"
|
||||||
}
|
}
|
||||||
|
|
|
@ -370,6 +370,8 @@ void Room::chat(ServerPlayer *sender, const QString &jsonData) {
|
||||||
// 屏蔽.号,防止有人在HTML文本发链接,而正常发链接看不出来有啥改动
|
// 屏蔽.号,防止有人在HTML文本发链接,而正常发链接看不出来有啥改动
|
||||||
auto msg = doc["msg"].toString();
|
auto msg = doc["msg"].toString();
|
||||||
msg.replace(".", "․");
|
msg.replace(".", "․");
|
||||||
|
// 300字限制,与客户端相同
|
||||||
|
msg.erase(msg.begin() + 300, msg.end());
|
||||||
doc["msg"] = msg;
|
doc["msg"] = msg;
|
||||||
if (!server->checkBanWord(msg)) {
|
if (!server->checkBanWord(msg)) {
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Reference in New Issue