From 7ef427d7eff16cd28c4ecd8649aedb558986a592 Mon Sep 17 00:00:00 2001
From: YoumuKon <38815081+YoumuKon@users.noreply.github.com>
Date: Wed, 14 Jun 2023 13:40:50 +0800
Subject: [PATCH] =?UTF-8?q?=E6=AD=BB=E4=BA=A1=E9=9F=B3=E6=95=88=E6=9F=A5?=
=?UTF-8?q?=E8=AF=A2=E4=BF=AE=E5=A4=8D+=E5=90=84=E7=A7=8D=E5=8A=9F?=
=?UTF-8?q?=E8=83=BD+i18n=20(#191)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
- 迁移了死亡音效判定防止bug
- 牌种类/部分常见用语i18n
- 在线人数<10时会播放之前的登录/退出/重连信息
- askfordiscard禁止编辑已传入的maxNum/minNum
- getSuitString可以返回符号
- 添加getSuitCompletedString,可显示完整的**花色+点数**的完整点数
---
.gitignore | 3 +++
Fk/Pages/GeneralsOverview.qml | 5 +++++
Fk/Pages/Init.qml | 2 +-
lang/zh_CN.ts | 2 +-
lua/client/i18n/zh_CN.lua | 15 ++++++++++++++-
lua/core/card.lua | 26 ++++++++++++++++++--------
lua/server/mark_enum.lua | 5 ++++-
lua/server/room.lua | 9 ++++++---
packages/standard/aux_skills.lua | 3 +--
packages/standard_cards/i18n/zh_CN.lua | 19 +++++++++++++++++++
src/server/server.cpp | 15 +++++++++------
11 files changed, 81 insertions(+), 23 deletions(-)
diff --git a/.gitignore b/.gitignore
index 4e7279dd..addb66a9 100644
--- a/.gitignore
+++ b/.gitignore
@@ -40,8 +40,11 @@ freekill-wrap.cxx
/Qt5Compat/
/QtQml/
/QtMultimedia/
+/multimedia/
+/qmltooling/
/sqldrivers/
/styles/
/tls/
/translations/
/*.dll
+/*.bat
diff --git a/Fk/Pages/GeneralsOverview.qml b/Fk/Pages/GeneralsOverview.qml
index 018cb3eb..da3a11e9 100644
--- a/Fk/Pages/GeneralsOverview.qml
+++ b/Fk/Pages/GeneralsOverview.qml
@@ -163,6 +163,10 @@ Item {
if (i > 0) break;
}
}
+ }
+
+ function findDeathAudio(general) {
+ const extension = JSON.parse(Backend.callLuaFunction("GetGeneralData", [general])).extension;
const fname = AppPath + "/packages/" + extension + "/audio/death/" + general + ".mp3";
if (Backend.exists(fname)) {
audioDeath.visible = true;
@@ -188,6 +192,7 @@ Item {
addSkillAudio(t.name);
});
+ findDeathAudio(general);
addSkillAudio(general + "_win_audio");
}
diff --git a/Fk/Pages/Init.qml b/Fk/Pages/Init.qml
index dbefa7eb..839c105f 100644
--- a/Fk/Pages/Init.qml
+++ b/Fk/Pages/Init.qml
@@ -185,7 +185,7 @@ Item {
// Temp
Button {
- text: qsTr("Mod Making")
+ text: qsTr("Making Mod")
anchors.right: parent.right
anchors.bottom: parent.bottom
visible: Debugging
diff --git a/lang/zh_CN.ts b/lang/zh_CN.ts
index 1f401669..15aebdeb 100644
--- a/lang/zh_CN.ts
+++ b/lang/zh_CN.ts
@@ -136,7 +136,7 @@
管理拓展包
-
+
制作Mod
diff --git a/lua/client/i18n/zh_CN.lua b/lua/client/i18n/zh_CN.lua
index c860192e..9d2f311d 100644
--- a/lua/client/i18n/zh_CN.lua
+++ b/lua/client/i18n/zh_CN.lua
@@ -158,7 +158,6 @@ FreeKill使用的是libgit2的C API,与此同时使用Git完成拓展包的下
["AskForGeneral"] = "选择武将",
["AskForGuanxing"] = "观星",
["AskForExchange"] = "换牌",
- ["Pile"] = "牌堆",
["AskForChoice"] = "选择",
["AskForKingdom"] = "选择势力",
["AskForPindian"] = "拼点",
@@ -265,6 +264,7 @@ Fk:loadTranslationTable{
["fire_damage"] = "火属性",
["thunder_damage"] = "雷属性",
["ice_damage"] = "冰属性",
+ ["hp_lost"] = "体力流失",
["phase_start"] = "准备阶段",
["phase_judge"] = "判定阶段",
@@ -276,8 +276,21 @@ Fk:loadTranslationTable{
["chained"] = "横置",
["not-chained"] = "重置",
+ ["pile_draw"] = "牌堆",
+ ["pile_discard"] = "弃牌堆",
+ ["processing_area"] = "处理区",
["Top"] = "牌堆顶",
["Bottom"] = "牌堆底",
+ ["Shuffle"] = "洗牌",
+
+ ["general_card"] = "武将牌",
+ ["General"] = "武将",
+ ["Hp"] = "体力",
+ ["Damage"] = "伤害",
+ ["Lost"] = "失去",
+ ["Distance"] = "距离",
+ ["Judge"] = "判定",
+ ["Retrial"] = "改判",
}
-- related to sendLog
diff --git a/lua/core/card.lua b/lua/core/card.lua
index cb7a211a..59964402 100644
--- a/lua/core/card.lua
+++ b/lua/core/card.lua
@@ -225,21 +225,24 @@ function Card:matchPattern(pattern)
return Exppattern:Parse(pattern):match(self)
end
---- 获取卡牌花色并返回花色文字描述(如 黑桃、红桃、梅花、方块)。
+--- 获取卡牌花色并返回花色文字描述(如 黑桃、红桃、梅花、方块)或者符号(如♠♥♣♦,带颜色)。
+---@param symbol boolean @ 是否以符号形式显示
---@return string @ 描述花色的字符串
-function Card:getSuitString()
+function Card:getSuitString(symbol)
local suit = self.suit
+ local ret
if suit == Card.Spade then
- return "spade"
+ ret = "spade"
elseif suit == Card.Heart then
- return "heart"
+ ret = "heart"
elseif suit == Card.Club then
- return "club"
+ ret = "club"
elseif suit == Card.Diamond then
- return "diamond"
+ ret = "diamond"
else
- return "nosuit"
+ ret = "nosuit"
end
+ return symbol and "log_" .. ret or ret
end
--- 获取卡牌颜色并返回点数颜色描述(例如黑色/红色/无色)。
@@ -254,7 +257,7 @@ function Card:getColorString()
return "nocolor"
end
---- 获取卡牌类型并返回点数类型描述(例如基本牌/锦囊牌/装备牌)。
+--- 获取卡牌类型并返回类型描述(例如基本牌/锦囊牌/装备牌)。
function Card:getTypeString()
local t = self.type
if t == Card.TypeBasic then
@@ -281,6 +284,13 @@ local function getNumberStr(num)
return tostring(num)
end
+--- 获取卡牌的完整点数(花色+点数),如(黑桃A/♠A)。
+---@param symbol boolean @ 是否以符号形式显示花色
+---@return string @ 完整点数(字符串)
+function Card:getSuitCompletedString(symbol)
+ return self:getSuitString(symbol) .. getNumberStr(self.number)
+end
+
--- 判断卡牌是否为普通锦囊牌
---@return boolean
function Card:isCommonTrick()
diff --git a/lua/server/mark_enum.lua b/lua/server/mark_enum.lua
index 4118b69b..864e0dcf 100644
--- a/lua/server/mark_enum.lua
+++ b/lua/server/mark_enum.lua
@@ -19,5 +19,8 @@ MarkEnum.MinusMaxCards = "MinusMaxCards"
---@field AddMaxCards string @ 于本回合内减少标记值数量的手牌上限
MarkEnum.MinusMaxCardsInTurn = "MinusMaxCards-turn"
----@field uncompulsoryInvalidity string @ 非锁定技失效,可带清除标记后缀
+---@field UncompulsoryInvalidity string @ 非锁定技失效,可带清除标记后缀
MarkEnum.UncompulsoryInvalidity = "uncompulsoryInvalidity"
+
+---@field TempMarkSuffix string[] @ 各种清除标记后缀
+MarkEnum.TempMarkSuffix = { "-phase", "-turn", "-round" }
diff --git a/lua/server/room.lua b/lua/server/room.lua
index 1a12ff55..1dfbc511 100644
--- a/lua/server/room.lua
+++ b/lua/server/room.lua
@@ -978,10 +978,10 @@ function Room:askForDiscard(player, minNum, maxNum, includeEquip, skillName, can
end
)
- maxNum = math.min(#canDiscards, maxNum)
- minNum = math.min(#canDiscards, minNum)
+ -- maxNum = math.min(#canDiscards, maxNum)
+ -- minNum = math.min(#canDiscards, minNum)
- if minNum < 1 and not cancelable then
+ if minNum < #canDiscards and not cancelable then
return {}
end
@@ -2128,6 +2128,7 @@ function Room:handleCardEffect(event, cardEffectEvent)
loopTimes = cardEffectEvent.fixedResponseTimes
end
end
+ Fk.currentResponsePattern = "jink"
for i = 1, loopTimes do
local to = self:getPlayerById(cardEffectEvent.to)
@@ -2163,6 +2164,7 @@ function Room:handleCardEffect(event, cardEffectEvent)
not table.contains(cardEffectEvent.prohibitedCardNames or Util.DummyTable, "nullification")
then
local players = {}
+ Fk.currentResponsePattern = "nullification"
for _, p in ipairs(self.alive_players) do
local cards = p:getCardIds(Player.Hand)
for _, cid in ipairs(cards) do
@@ -2208,6 +2210,7 @@ function Room:handleCardEffect(event, cardEffectEvent)
self:useCard(use)
end
end
+ Fk.currentResponsePattern = nil
elseif event == fk.CardEffecting then
if cardEffectEvent.card.skill then
execGameEvent(GameEvent.SkillEffect, function ()
diff --git a/packages/standard/aux_skills.lua b/packages/standard/aux_skills.lua
index 6a5ef452..587a3041 100644
--- a/packages/standard/aux_skills.lua
+++ b/packages/standard/aux_skills.lua
@@ -110,13 +110,12 @@ local uncompulsoryInvalidity = fk.CreateInvaliditySkill {
name = "uncompulsory_invalidity",
global = true,
invalidity_func = function(self, from, skill)
- local suffix = { "-phase", "-turn", "-round" }
return
(skill.frequency ~= Skill.Compulsory and skill.frequency ~= Skill.Wake) and
not (skill:isEquipmentSkill() or skill.name:endsWith("&")) and
(
from:getMark(MarkEnum.UncompulsoryInvalidity) ~= 0 or
- table.find(suffix, function(s)
+ table.find(MarkEnum.TempMarkSuffix, function(s)
return from:getMark(MarkEnum.UncompulsoryInvalidity .. s) ~= 0
end)
)
diff --git a/packages/standard_cards/i18n/zh_CN.lua b/packages/standard_cards/i18n/zh_CN.lua
index 93f58b21..04f8aa2e 100644
--- a/packages/standard_cards/i18n/zh_CN.lua
+++ b/packages/standard_cards/i18n/zh_CN.lua
@@ -14,18 +14,37 @@ Fk:loadTranslationTable{
["heart"] = "红桃",
["club"] = "梅花",
["diamond"] = "方块",
+ ["suit"] = "花色",
+ ["color"] = "颜色",
+ ["figure"] = "点数",
["basic_char"] = "基",
["trick_char"] = "锦",
["equip_char"] = "装",
+ ["basic"] = "基本牌",
+ ["trick"] = "锦囊牌",
+ ["equip"] = "装备牌",
["weapon"] = "武器牌",
["armor"] = "防具牌",
["defensive_horse"] = "防御坐骑牌",
["offensive_horse"] = "进攻坐骑牌",
+ ["equip_horse"] = "坐骑牌",
["treasure"] = "宝物牌",
["delayed_trick"] = "延时类锦囊牌",
+ ["type_weapon"] = "武器",
+ ["type_armor"] = "防具",
+ ["type_defensive_horse"] = "防御坐骑",
+ ["type_offensive_horse"] = "进攻坐骑",
+ ["type_horse"] = "坐骑",
+
+ ["method_use"] = "使用",
+ ["method_response_play"] = "打出",
+ ["method_response"] = "响应",
+ ["method_draw"] = "摸",
+ ["method_discard"] = "弃置",
+
["slash"] = "杀",
[":slash"] = "基本牌
时机:出牌阶段
目标:攻击范围内的一名其他角色
效果:对目标角色造成1点伤害。",
["#slash-jink"] = "%src 对你使用了杀,请使用 %arg 张闪",
diff --git a/src/server/server.cpp b/src/server/server.cpp
index 6ec80522..4c7f45f1 100644
--- a/src/server/server.cpp
+++ b/src/server/server.cpp
@@ -388,8 +388,9 @@ void Server::handleNameAndPassword(ClientSocket *client, const QString &name,
player->setSocket(client);
player->alive = true;
client->disconnect(this);
- // broadcast("ServerMessage",
- // tr("%1 backed").arg(player->getScreenName()));
+ if (players.count() <= 10) {
+ broadcast("ServerMessage", tr("%1 backed").arg(player->getScreenName()));
+ }
if (room && !room->isLobby()) {
room->pushRequest(QString("%1,reconnect").arg(id));
@@ -428,8 +429,9 @@ void Server::handleNameAndPassword(ClientSocket *client, const QString &name,
player->setScreenName(name);
player->setAvatar(obj["avatar"].toString());
player->setId(obj["id"].toString().toInt());
- // broadcast("ServerMessage", tr("%1 logged
- // in").arg(player->getScreenName()));
+ if (players.count() <= 10) {
+ broadcast("ServerMessage", tr("%1 logged in").arg(player->getScreenName()));
+ }
players.insert(player->getId(), player);
// tell the lobby player's basic property
@@ -481,8 +483,9 @@ void Server::onRoomAbandoned() {
void Server::onUserDisconnected() {
ServerPlayer *player = qobject_cast(sender());
qInfo() << "Player" << player->getId() << "disconnected";
- // broadcast("ServerMessage", tr("%1 logged
- // out").arg(player->getScreenName()));
+ if (players.count() <= 10) {
+ broadcast("ServerMessage", tr("%1 logged out").arg(player->getScreenName()));
+ }
Room *room = player->getRoom();
if (room->isStarted()) {
if (room->getObservers().contains(player)) {