修复了qml的一些问题;增加利好私服的服主配置项。

---------

Co-authored-by: YoumuKon <38815081+YoumuKon@users.noreply.github.com>
This commit is contained in:
notify 2023-08-03 15:24:17 +08:00 committed by GitHub
parent c86d6a7249
commit 7fb5f7bb14
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
25 changed files with 130 additions and 45 deletions

View File

@ -2,6 +2,12 @@
___
## v0.3.0
修复了测试版的诸多bug更换了一些素材。
___
## v0.2.11
新测试版

View File

@ -2,7 +2,7 @@
cmake_minimum_required(VERSION 3.16)
project(FreeKill VERSION 0.2.11)
project(FreeKill VERSION 0.3.0)
add_definitions(-DFK_VERSION=\"${CMAKE_PROJECT_VERSION}\")
find_package(Qt6 REQUIRED COMPONENTS

View File

@ -38,6 +38,8 @@ QtObject {
property string aeskey
// Client data
property string serverMotd: ""
property var serverHiddenPacks: []
property int roomCapacity: 0
property int roomTimeout: 0
property bool enableFreeAssign: false

View File

@ -14,7 +14,7 @@ Item {
anchors.rightMargin: 8
spacing: 16
Text {
text: "禁将方案"
text: Backend.translate("Ban List")
}
ComboBox {
id: banCombo
@ -30,18 +30,18 @@ Item {
}
Button {
text: "新建"
text: Backend.translate("New")
onClicked: {
const i = config.disableGeneralSchemes.length;
banComboList.append({
name: "方案" + (i + 1),
name: Backend.translate("List") + (i + 1),
});
config.disableGeneralSchemes.push([]);
}
}
Button {
text: "清空"
text: Backend.translate("Clear")
onClicked: {
config.disabledGenerals = [];
}
@ -52,42 +52,41 @@ Item {
Layout.fillWidth: true
Layout.margins: 8
wrapMode: Text.WrapAnywhere
text: "导出键会将这个方案的内容复制到剪贴板中;" +
"导入键会自动读取剪贴板,若可以导入则导入,不能导入则报错。"
text: Backend.translate("Help_Ban_List")
}
RowLayout {
Button {
text: "导出"
text: Backend.translate("Export")
onClicked: {
Backend.copyToClipboard(JSON.stringify(config.disabledGenerals));
toast.show("该禁将方案已经复制到剪贴板。");
toast.show(Backend.translate("Export Success"));
}
}
Button {
text: "导入"
text: Backend.translate("Import")
onClicked: {
const str = Backend.readClipboard();
let data;
try {
data = JSON.parse(str);
} catch (e) {
toast.show("导入失败不是合法的JSON字符串。");
toast.show(Backend.translate("Not Legal"));
return;
}
if (!data instanceof Array) {
toast.show("导入失败:数据格式不对。");
toast.show(Backend.translate("Not JSON"));
return;
}
let d = [];
for (let e of data) {
if (!(typeof e === "string" && Backend.translate(e) !== e)) {
toast.show("导入失败:含有未知的武将。");
return;
if (typeof e === "string" && Backend.translate(e) !== e) {
d.push(e);
}
}
config.disabledGenerals = data;
toast.show("导入禁将方案成功。");
config.disabledGenerals = d;
toast.show(Backend.translate("Import Success"));
}
}
}
@ -118,7 +117,7 @@ Item {
Component.onCompleted: {
for (let i = 0; i < config.disableGeneralSchemes.length; i++) {
banComboList.append({
name: "方案" + (i + 1),
name: Backend.translate("List") + (i + 1),
});
}
banCombo.currentIndex = config.disableSchemeIdx;

View File

@ -22,6 +22,9 @@ Item {
TabButton {
text: Backend.translate("Package Settings")
}
TabButton {
text: Backend.translate("Ban General Settings")
}
}
SwipeView {
@ -37,5 +40,6 @@ Item {
anchors.fill: parent
}
}
BanGeneralSetting {}
}
}

View File

@ -24,9 +24,6 @@ Item {
TabButton {
text: Backend.translate("Audio Settings")
}
TabButton {
text: Backend.translate("Ban General Settings")
}
}
SwipeView {
@ -39,6 +36,5 @@ Item {
UserInfo {}
BGSetting {}
AudioSetting {}
BanGeneralSetting {}
}
}

View File

@ -48,6 +48,8 @@ Item {
}
TapHandler {
gesturePolicy: TapHandler.WithinBounds
onTapped: {
lobby_dialog.sourceComponent = Qt.createComponent("EditProfile.qml");
lobby_drawer.open();

View File

@ -179,13 +179,30 @@ Flickable {
disabledGenerals = Array.from(new Set(disabledGenerals));
}
let disabledPack = config.disabledPack.slice();
config.serverHiddenPacks.forEach(p => {
if (!disabledPack.includes(p)) {
disabledPack.push(p);
}
});
const generalPacks = JSON.parse(Backend.callLuaFunction("GetAllGeneralPack", []));
for (let pk of generalPacks) {
if (disabledPack.includes(pk)) continue;
let generals = JSON.parse(Backend.callLuaFunction("GetGenerals", [pk]));
let t = generals.filter(g => !disabledGenerals.includes(g));
if (t.length === 0) {
disabledPack.push(pk);
disabledGenerals = disabledGenerals.filter(g1 => !generals.includes(g1));
}
}
ClientInstance.notifyServer(
"CreateRoom",
JSON.stringify([roomName.text, playerNum.value, config.preferredTimeout, {
enableFreeAssign: freeAssignCheck.checked,
enableDeputy: deputyCheck.checked,
gameMode: config.preferedMode,
disabledPack: config.disabledPack,
disabledPack: disabledPack,
generalNum: config.preferredGeneralNum,
luckTime: config.preferredLuckTime,
password: roomPassword.text,

View File

@ -22,7 +22,7 @@ Flickable {
anchors.topMargin: 8
Switch {
text: "禁用Lua拓展 (重启后生效)"
text: Backend.translate("Disable Extension")
}
RowLayout {
@ -132,19 +132,25 @@ Flickable {
Component.onCompleted: {
const g = JSON.parse(Backend.callLuaFunction("GetAllGeneralPack", []));
for (let orig of g) {
if (config.serverHiddenPacks.includes(orig)) {
continue;
}
gpacklist.append({
name: Backend.translate(orig),
orig_name: orig,
pkg_enabled: config.disabledPack.indexOf(orig) === -1,
pkg_enabled: !config.disabledPack.includes(orig),
});
}
const c = JSON.parse(Backend.callLuaFunction("GetAllCardPack", []));
for (let orig of c) {
if (config.serverHiddenPacks.includes(orig)) {
continue;
}
cpacklist.append({
name: Backend.translate(orig),
orig_name: orig,
pkg_enabled: config.disabledPack.indexOf(orig) === -1,
pkg_enabled: !config.disabledPack.includes(orig),
});
}
}

View File

@ -98,6 +98,13 @@ callbacks["BackToStart"] = (jsonData) => {
}
}
callbacks["SetServerSettings"] = (j) => {
const data = JSON.parse(j);
const [ motd, hiddenPacks ] = data;
config.serverMotd = motd;
config.serverHiddenPacks = hiddenPacks;
};
callbacks["EnterLobby"] = (jsonData) => {
// depth == 1 means the lobby page is not present in mainStack
// createClientPages();

View File

@ -302,7 +302,11 @@ Item {
function loadPackages() {
if (loaded) return;
const packs = JSON.parse(Backend.callLuaFunction("GetAllCardPack", []));
packs.forEach((name) => packages.append({ name: name }));
packs.forEach(name => {
if (!config.serverHiddenPacks.includes(name)) {
packages.append({ name: name });
}
});
loaded = true;
}
}

View File

@ -359,7 +359,11 @@ Item {
function loadPackages() {
if (loaded) return;
const packs = JSON.parse(Backend.callLuaFunction("GetAllGeneralPack", []));
packs.forEach((name) => packages.append({ name: name }));
packs.forEach(name => {
if (!config.serverHiddenPacks.includes(name)) {
packages.append({ name: name });
}
});
generalDetail.updateGeneral();
loaded = true;
}

View File

@ -41,7 +41,7 @@ Item {
width: parent.width
wrapMode: TextEdit.WordWrap
textFormat: Text.MarkdownText
text: Backend.translate('Bulletin Info')
text: config.serverMotd + "\n___\n" + Backend.translate('Bulletin Info')
}
}
}

View File

@ -223,9 +223,9 @@ Item {
x: 8; y: 8
Component.onCompleted: {
const data = JSON.parse(Backend.callLuaFunction("GetRoomConfig", []));
text = "手气卡次数:" + data.luckTime + "<br />出手时间:" + config.roomTimeout
+ "<br />选将框数:" + data.generalNum + (data.enableFreeAssign ? "<br /><font color=\"red\">可自由点将</font>" : "")
+ (data.enableDeputy ? "<br /><font color=\"red\">启用副将机制</font>" : "")
text = Backend.translate("LuckCardNum") + data.luckTime + "<br />" + Backend.translate("ResponseTime") + config.roomTimeout
+ "<br />" + Backend.translate("GeneralBoxNum") + data.generalNum + (data.enableFreeAssign ? "<br />" + Backend.translate("IncludeFreeAssign") : "")
+ (data.enableDeputy ? "<br />" + Backend.translate("IncludeDeputy") : "")
}
}
}
@ -478,13 +478,13 @@ Item {
}
Switch {
text: "匀速"
text: Backend.translate("Speed Resume")
checked: false
onCheckedChanged: Backend.controlReplayer("uniform");
}
Button {
text: "减速"
text: Backend.translate("Speed Down")
onClicked: Backend.controlReplayer("slowdown");
}
@ -495,13 +495,13 @@ Item {
}
Button {
text: "加速"
text: Backend.translate("Speed Up")
onClicked: Backend.controlReplayer("speedup");
}
Button {
property bool running: true
text: running ? "暂停" : "继续"
text: Backend.translate(running ? "Pause" : "Resume")
onClicked: {
running = !running;
Backend.controlReplayer("toggle");

View File

@ -3,8 +3,8 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.notify.FreeKill"
android:installLocation="preferExternal"
android:versionCode="211"
android:versionName="0.2.11">
android:versionCode="300"
android:versionName="0.3.0">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />

View File

@ -3,5 +3,7 @@
"description": "FreeKill Server",
"iconUrl": "https://img1.imgtp.com/2023/07/01/DGUdj8eu.png",
"capacity": 100,
"tempBanTime": 20
"tempBanTime": 20,
"motd": "Welcome!",
"hiddenPacks": []
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.4 KiB

After

Width:  |  Height:  |  Size: 9.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 55 KiB

After

Width:  |  Height:  |  Size: 71 KiB

View File

@ -29,6 +29,7 @@ Fk:loadTranslationTable{
["Refresh Room List"] = "刷新房间列表",
["Disable Extension"] = "禁用Lua拓展 (重启后生效)",
["Create Room"] = "创建房间",
["Room Name"] = "房间名字",
["$RoomName"] = "%1的房间",
@ -65,6 +66,19 @@ Fk:loadTranslationTable{
["Win=%1 Run=%2 Total=%3"] = "胜率%1% 逃率%2% 总场次%3",
["Win=%1\nRun=%2\nTotal=%3"] = "胜率: %1%\n逃率: %2%\n总场次: %3",
["Ban List"] = "禁将方案",
["List"] = "方案",
["New"] = "新建",
["Clear"] = "清空",
["Help_Ban_List"] = "导出键会将这个方案的内容复制到剪贴板中;" ..
"导入键会自动读取剪贴板,若可以导入则导入,不能导入则报错。",
["Export"] = "导出",
["Export Success"] = "禁将方案已经复制到剪贴板。",
["Import"] = "导入",
["Not Legal"] = "导入失败不是合法的JSON字符串。",
["Not JSON"] = "导入失败:数据格式不对。",
["Import Success"] = "从剪贴板导入禁将方案成功。",
["$OnlineInfo"] = "大厅人数:%1总在线人数%2",
["Generals Overview"] = "武将一览",
@ -164,6 +178,11 @@ FreeKill使用的是libgit2的C API与此同时使用Git完成拓展包的下
["Death audio"] = "阵亡",
["$WelcomeToLobby"] = "欢迎进入新月杀游戏大厅!",
["LuckCardNum"] = "手气卡次数:",
["ResponseTime"] = "出手时间:",
["GeneralBoxNum"] = "选将框数:",
["IncludeFreeAssign"] = "<font color=\"red\">可自由点将</font>",
["IncludeDeputy"] = "<font color=\"red\">启用副将机制</font>",
-- Room
["$EnterRoom"] = "成功加入房间。",
@ -256,12 +275,18 @@ FreeKill使用的是libgit2的C API与此同时使用Git完成拓展包的下
["Back To Lobby"] = "返回大厅",
["Save Replay"] = "保存录像",
["Speed Resume"] = "匀速",
["Speed Up"] = "加速",
["Speed Down"] = "减速",
["Pause"] = "暂停",
["Resume"] = "继续",
["Bulletin Info"] = [==[
## v0.2.10
## v0.3.0
0.3.0bug
西0.2.9
]==],
}
@ -300,6 +325,7 @@ Fk:loadTranslationTable{
["pile_draw"] = "牌堆",
["pile_discard"] = "弃牌堆",
["processing_area"] = "处理区",
["Pile"] = "牌堆",
["Top"] = "牌堆顶",
["Bottom"] = "牌堆底",
["Shuffle"] = "洗牌",

View File

@ -59,7 +59,7 @@ function UsableSkill:withinDistanceLimit(player, isattack, card, to)
end
local temp_suf = table.simpleClone(MarkEnum.TempMarkSuffix)
table.insert(temp_suf, "-tmp")
return isattack and player:inMyAttackRange(to, self:getDistanceLimit(player, card, to)) or player:distanceTo(to) <= self:getDistanceLimit(player, card, to) or
return isattack and player:inMyAttackRange(to) or player:distanceTo(to) <= self:getDistanceLimit(player, card, to) or
(player:getMark(MarkEnum.BypassDistancesLimit) ~= 0 or
table.find(temp_suf, function(s)
return player:getMark(MarkEnum.BypassDistancesLimit .. s) ~= 0

View File

@ -121,10 +121,13 @@ local function _waitForReply(player, timeout)
end
local rest = timeout * 1000 - (os.getms() - start) / 1000
if timeout and rest <= 0 then
player._timewaste_count = player._timewaste_count + 1
if timeout >= 15 then
player._timewaste_count = player._timewaste_count + 1
end
player.serverplayer:setThinking(false)
if player._timewaste_count >= 3 then
player._timewaste_count = 0
player.serverplayer:emitKick()
end

View File

@ -213,7 +213,7 @@ local snatchSkill = fk.CreateActiveSkill{
mod_target_filter = function(self, to_select, selected, user, card, distance_limited)
local player = Fk:currentRoom():getPlayerById(to_select)
local from = Fk:currentRoom():getPlayerById(user)
return from ~= player and not (player:isAllNude() or (distance_limited and not self:withinDistanceLimit(from, true, card, player)))
return from ~= player and not (player:isAllNude() or (distance_limited and not self:withinDistanceLimit(from, false, card, player)))
end,
target_filter = function(self, to_select, selected, _, card)
if #selected == 0 then

View File

@ -508,6 +508,11 @@ void Server::handleNameAndPassword(ClientSocket *client, const QString &name,
arr << player->getAvatar();
player->doNotify("Setup", JsonArray2Bytes(arr));
player->doNotify("SetServerSettings", JsonArray2Bytes({
getConfig("motd"),
getConfig("hiddenPacks"),
}));
lobby()->addPlayer(player);
} else {
qInfo() << client->peerAddress() << "lost connection:" << error_msg;
@ -613,6 +618,8 @@ void Server::readConfig() {
SET_DEFAULT_CONFIG("iconUrl", "https://img1.imgtp.com/2023/07/01/DGUdj8eu.png");
SET_DEFAULT_CONFIG("capacity", 100);
SET_DEFAULT_CONFIG("tempBanTime", 20);
SET_DEFAULT_CONFIG("motd", "Welcome!");
SET_DEFAULT_CONFIG("hiddenPacks", QJsonArray());
}
QJsonValue Server::getConfig(const QString &key) { return config.value(key); }