Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ChangeLog: v0.5.4 #441

Merged
merged 6 commits into from
Jan 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .luarc.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"workspace.ignoreDir": [
"/lua",
"/test",
"/packages/*",
"!/packages/freekill-core",
"!/packages/utility",
Expand Down
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
# ChangeLog

## v0.5.3
## v0.5.3 & v0.5.4

- 修复服务端若干的bug
- 服务端新增若干命令:stat, lsroom, killroom, msgroom
- 服务端新增限制单设备注册数量的配置key: maxPlayersPerDevice
- 可以查看和复制房间中的禁将
- 新增命令行参数--testskills 可用于运行技能测试例

___

Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

cmake_minimum_required(VERSION 3.22)

project(FreeKill VERSION 0.5.3)
project(FreeKill VERSION 0.5.4)
add_definitions(-DFK_VERSION=\"${CMAKE_PROJECT_VERSION}\")

find_package(Qt6 REQUIRED COMPONENTS
Expand Down
1 change: 0 additions & 1 deletion Fk/Pages/GeneralDetailPage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import Fk.RoomElement

Item {
id: root
anchors.centerIn: parent

property string general: "caocao"
property bool isFavor: {
Expand Down
41 changes: 33 additions & 8 deletions Fk/Pages/GeneralPoolOverview.qml
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,6 @@ Item {
detailed: true
}

Rectangle {
anchors.fill: parent
color: "black"
opacity: 0.6
visible: !root.allGenerals.includes(modelData)
}

TapHandler {
acceptedButtons: Qt.LeftButton | Qt.NoButton
gesturePolicy: TapHandler.WithinBounds
Expand Down Expand Up @@ -60,7 +53,36 @@ Item {
anchors.top: favorBar.bottom
cellWidth: 68; cellHeight: 68
model: config.favoriteGenerals
delegate: avatarCard
delegate: Item {
width: 64; height: 64
Avatar {
general: modelData
detailed: true
}

Rectangle {
anchors.fill: parent
color: "black"
opacity: 0.6
visible: !root.allGenerals.includes(modelData)
}

Image {
width: 24; height: 23
source: SkinBank.MISC_DIR + "favorite"
x: -8; y: 48
}

TapHandler {
acceptedButtons: Qt.LeftButton | Qt.NoButton
gesturePolicy: TapHandler.WithinBounds

onTapped: () => {
popLoader.item.general = modelData;
pop.open();
}
}
}
}
}

Expand Down Expand Up @@ -127,6 +149,7 @@ Item {
anchors.top: topBar.bottom
anchors.left: favorite.right
visible: showByPkg.checked
interactive: showByPkg.checked
model: ListModel {
id: pkgModel
}
Expand Down Expand Up @@ -163,6 +186,7 @@ Item {
anchors.top: topBar.bottom
anchors.left: favorite.right
visible: !showByPkg.checked
interactive: !showByPkg.checked
cellWidth: 68; cellHeight: 68
model: root.allGenerals
delegate: avatarCard
Expand Down Expand Up @@ -193,6 +217,7 @@ Item {
id: popLoader
width: parent.width / mainWindow.scale
height: parent.height / mainWindow.scale
anchors.centerIn: parent
scale: mainWindow.scale
source: AppPath + "/Fk/Pages/GeneralDetailPage.qml"
}
Expand Down
1 change: 1 addition & 0 deletions Fk/Pages/GeneralsOverview.qml
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,7 @@ Item {
id: generalDetailLoader
width: parent.width / mainWindow.scale
height: parent.height / mainWindow.scale
anchors.centerIn: parent
scale: mainWindow.scale
source: AppPath + "/Fk/Pages/GeneralDetailPage.qml"
}
Expand Down
4 changes: 2 additions & 2 deletions android/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.notify.FreeKill"
android:installLocation="preferExternal"
android:versionCode="503"
android:versionName="0.5.3">
android:versionCode="504"
android:versionName="0.5.4">
<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" />
Expand Down
2 changes: 1 addition & 1 deletion lua/lsp/client.lua
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ end
---@param avatar string
---@return fk.Player
function FClient:addPlayer(id, name, avatar)
self.players[id] = CreateFakePlayer(id, name, avatar)
self.players[id] = FkTest.createFakePlayer(id, name, avatar)
return self.players[id]
end

Expand Down
60 changes: 30 additions & 30 deletions packages/standard/test/test_standard.lua
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
TestStandard = { setup = InitRoom, tearDown = ClearRoom }
TestStandard = { setup = FkTest.initRoom, tearDown = FkTest.clearRoom }

function TestStandard:testJianxiong()
local room = LRoom
local room = FkTest.room
local me, comp2 = room.players[1], room.players[2] ---@type ServerPlayer, ServerPlayer
RunInRoom(function() room:handleAddLoseSkills(me, "jianxiong") end)
FkTest.runInRoom(function() room:handleAddLoseSkills(me, "jianxiong") end)

local slash = Fk:getCardById(1)
SetNextReplies(me, { "__cancel", "1" })
RunInRoom(function()
FkTest.setNextReplies(me, { "__cancel", "1" })
FkTest.runInRoom(function()
room:useCard{
from = comp2.id,
tos = { { me.id } },
Expand All @@ -19,14 +19,14 @@ function TestStandard:testJianxiong()
end

function TestStandard:testFanKui()
local room = LRoom
local room = FkTest.room
local me, comp2 = room.players[1], room.players[2] ---@type ServerPlayer, ServerPlayer
RunInRoom(function() room:handleAddLoseSkills(me, "fankui") end)
FkTest.runInRoom(function() room:handleAddLoseSkills(me, "fankui") end)

-- 空牌的情况
local slash = Fk:getCardById(1)
SetNextReplies(me, { "__cancel" })
RunInRoom(function()
FkTest.setNextReplies(me, { "__cancel" })
FkTest.runInRoom(function()
room:useCard{
from = comp2.id,
tos = { { me.id } },
Expand All @@ -36,8 +36,8 @@ function TestStandard:testFanKui()
lu.assertEquals(#me:getCardIds("h"), 0)

-- 有牌的情况
SetNextReplies(me, { "__cancel", "1", "3" })
RunInRoom(function()
FkTest.setNextReplies(me, { "__cancel", "1", "3" })
FkTest.runInRoom(function()
room:obtainCard(comp2, { 3 })
room:useCard{
from = comp2.id,
Expand All @@ -49,18 +49,18 @@ function TestStandard:testFanKui()
end

function TestStandard:testGangLie()
local room = LRoom ---@type Room
local room = FkTest.room ---@type Room
local me, comp2 = room.players[1], room.players[2] ---@type ServerPlayer, ServerPlayer
RunInRoom(function()
FkTest.runInRoom(function()
room:handleAddLoseSkills(me, "ganglie")
end)

-- 第一段:测试我发动刚烈,AI点取消
local slash = Fk:getCardById(1)
SetNextReplies(me, { "__cancel", "1" })
SetNextReplies(comp2, { "__cancel" })
FkTest.setNextReplies(me, { "__cancel", "1" })
FkTest.setNextReplies(comp2, { "__cancel" })
local origin_hp = comp2.hp
RunInRoom(function()
FkTest.runInRoom(function()
room:obtainCard(comp2, { 3, 4 })

room:moveCardTo(2, Card.DrawPile) -- 控顶
Expand All @@ -75,12 +75,12 @@ function TestStandard:testGangLie()

-- 第二段:测试我发动刚烈,AI丢二
origin_hp = comp2.hp
SetNextReplies(me, { "__cancel", "1" })
SetNextReplies(comp2, { json.encode {
FkTest.setNextReplies(me, { "__cancel", "1" })
FkTest.setNextReplies(comp2, { json.encode {
card = { skill = "discard_skill", subcards = { 3, 4 } },
targets = {}
} })
RunInRoom(function()
FkTest.runInRoom(function()
room:moveCardTo(2, Card.DrawPile) -- 再控顶
room:useCard{
from = comp2.id,
Expand All @@ -93,9 +93,9 @@ function TestStandard:testGangLie()

-- 第三段:测试我发动刚烈,判定判红桃
origin_hp = comp2.hp
SetNextReplies(me, { "__cancel", "1" })
SetNextReplies(comp2, { "__cancel" })
RunInRoom(function()
FkTest.setNextReplies(me, { "__cancel", "1" })
FkTest.setNextReplies(comp2, { "__cancel" })
FkTest.runInRoom(function()
room:obtainCard(comp2, { 3, 4 })

room:moveCardTo(24, Card.DrawPile) -- 控顶
Expand All @@ -110,20 +110,20 @@ function TestStandard:testGangLie()
end

function TestStandard:testLuoYi()
local room = LRoom ---@type Room
local room = FkTest.room ---@type Room
local me, comp2 = room.players[1], room.players[2] ---@type ServerPlayer, ServerPlayer
RunInRoom(function()
FkTest.runInRoom(function()
room:handleAddLoseSkills(me, "luoyi")
end)
local slash = Fk:getCardById(1)
SetNextReplies(me, { "1", json.encode {
FkTest.setNextReplies(me, { "1", json.encode {
card = 1,
targets = { comp2.id }
} })
SetNextReplies(comp2, { "__cancel" })
FkTest.setNextReplies(comp2, { "__cancel" })

local origin_hp = comp2.hp
RunInRoom(function()
FkTest.runInRoom(function()
room:obtainCard(me, 1)
GameEvent.Turn:create(me):exec()
end)
Expand All @@ -133,7 +133,7 @@ function TestStandard:testLuoYi()

-- 测标记持续时间
origin_hp = comp2.hp
RunInRoom(function()
FkTest.runInRoom(function()
room:useCard{
from = me.id,
tos = { { comp2.id } },
Expand All @@ -144,12 +144,12 @@ function TestStandard:testLuoYi()
end

function TestStandard:testMashu()
local room = LRoom ---@type Room
local room = FkTest.room ---@type Room
local me = room.players[1] ---@type ServerPlayer

local origin = table.map(room:getOtherPlayers(me), function(other) return me:distanceTo(other) end)

RunInRoom(function()
FkTest.runInRoom(function()
room:handleAddLoseSkills(me, "mashu")
end)

Expand Down
27 changes: 27 additions & 0 deletions src/freekill.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#include "client/client.h"
#include "core/util.h"
#include "core/c-wrapper.h"
using namespace fkShell;

#include "core/packman.h"
Expand Down Expand Up @@ -188,6 +189,28 @@ static void cleanUpGlobalStates() {
if (Pacman) Pacman->deleteLater();
}

static int runSkillTest() {
Pacman = new PackMan;
auto L = new Lua;
L->eval("__os = os; __io = io; __package = package"); // 保存一下
bool using_core = false;
if (QFile::exists("packages/freekill-core") &&
!GetDisabledPacks().contains("freekill-core")) {
using_core = true;
QDir::setCurrent("packages/freekill-core");
}
int ret = 1;
if (!L->dofile("lua/freekill.lua")) goto RET;
if (using_core) QDir::setCurrent("../..");
if (!L->dofile("test/lua/cpp_run_skill.lua")) goto RET;
ret = L->eval("return lu.LuaUnit.run()").toInt();

RET:
delete L;
delete Pacman;
return ret;
}

// FreeKill 的程序主入口。整个程序就是从这里开始执行的。
int freekill_main(int argc, char *argv[]) {
// 初始化一下各种杂项信息
Expand Down Expand Up @@ -220,9 +243,11 @@ int freekill_main(int argc, char *argv[]) {
// 分析命令行,如果有 -s 或者 --server 就在命令行直接开服务器
QCommandLineParser parser;
parser.setApplicationDescription("FreeKill server");
parser.setSingleDashWordOptionMode(QCommandLineParser::ParseAsLongOptions);
parser.addVersionOption();
parser.addOption({{"s", "server"}, "start server at <port>", "port"});
parser.addOption({{"h", "help"}, "display help information"});
parser.addOption({"testskills", "run test case of skills"});
QStringList cliOptions;
for (int i = 0; i < argc; i++)
cliOptions << argv[i];
Expand All @@ -234,6 +259,8 @@ int freekill_main(int argc, char *argv[]) {
} else if (parser.isSet("help")) {
parser.showHelp();
return 0;
} else if (parser.isSet("testskills")) {
return runSkillTest();
}

bool startServer = parser.isSet("server");
Expand Down
Loading
Loading