askForUseActiveSkill (#26)
* askForUseActiveSkill (not tested) * askForDiscard * askForChoosePlayers (not tested) * add comment, update readme
This commit is contained in:
parent
162b3af505
commit
7b12d82683
26
README.md
26
README.md
|
@ -10,28 +10,10 @@ ___
|
|||
|
||||
## 如何构建
|
||||
|
||||
以Debian11为例,首先克隆仓库:
|
||||
FreeKill使用Qt6.3,支持的运行平台有Windows、Linux、Android。
|
||||
|
||||
```shell
|
||||
$ git clone https://github.com/Notify-ctrl/FreeKill
|
||||
```
|
||||
|
||||
然后安装编译软件所必需的软件包:
|
||||
|
||||
```shell
|
||||
$ sudo apt install qtbase5-dev qtdeclarative5-dev qtmultimedia5-dev qml-module-qtquick2 qml-module-qtquick-controls2 qml-module-qtquick-window2 qml-module-qtquick-layouts qml-module-qtgraphicaleffects cmake swig lua5.4 sqlite3
|
||||
```
|
||||
|
||||
然后编译运行即可。
|
||||
|
||||
```shell
|
||||
$ mkdir build && cd build
|
||||
$ cmake .. && make
|
||||
$ cp src/FreeKill ..
|
||||
$ cd ..
|
||||
$ ./FreeKill
|
||||
```
|
||||
|
||||
对于Windows用户,建议安装Qt Creator和Qt 5.15.2。必要时自行配置CMake。
|
||||
欲编译FreeKill,首先得从Qt官网的安装工具安装Qt Creator和Qt 6.3.2。安装时需要勾选CMake,应该默认就是选上的状态。
|
||||
|
||||
然后下载swig,并为其配置环境变量,即可构建FreeKill。
|
||||
|
||||
对于Linux用户而言,还需要自己从包管理器安装lua5.4和sqlite。
|
||||
|
|
|
@ -5,3 +5,5 @@
|
|||
___
|
||||
|
||||
FreeKill 使用 sqlite3 数据库。
|
||||
|
||||
关于数据库的组织,详见server/init.sql。单纯存个用户名和密码而已
|
||||
|
|
|
@ -226,6 +226,17 @@ fk.client_callback["AddSkill"] = function(jsonData)
|
|||
end
|
||||
end
|
||||
|
||||
fk.client_callback["AskForUseActiveSkill"] = function(jsonData)
|
||||
-- jsonData: [ string skill_name, string prompt, bool cancelable. json extra_data ]
|
||||
local data = json.decode(jsonData)
|
||||
local skill = Fk.skills[data[1]]
|
||||
local extra_data = json.decode(data[4])
|
||||
for k, v in pairs(extra_data) do
|
||||
skill[k] = v
|
||||
end
|
||||
ClientInstance:notifyUI("AskForUseActiveSkill", jsonData)
|
||||
end
|
||||
|
||||
-- Create ClientInstance (used by Lua)
|
||||
ClientInstance = Client:new()
|
||||
dofile "lua/client/client_util.lua"
|
||||
|
|
|
@ -255,4 +255,5 @@ Fk:loadTranslationTable{
|
|||
["$Hand"] = "手牌区",
|
||||
["$Equip"] = "装备区",
|
||||
["$Judge"] = "判定区",
|
||||
["#AskForUseActiveSkill"] = "请使用技能 %1",
|
||||
}
|
||||
|
|
|
@ -30,6 +30,7 @@ function Engine:initialize()
|
|||
self.translations = {} -- srcText --> translated
|
||||
|
||||
self:loadPackages()
|
||||
self:addSkills(AuxSkills)
|
||||
end
|
||||
|
||||
---@param pack Package
|
||||
|
|
1227
lua/server/room.lua
1227
lua/server/room.lua
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,38 @@
|
|||
local discardSkill = fk.CreateActiveSkill{
|
||||
name = "discard_skill",
|
||||
card_filter = function(self, to_select, selected)
|
||||
if #selected >= self.num then
|
||||
return false
|
||||
end
|
||||
|
||||
return true
|
||||
end,
|
||||
feasible = function(self, _, selected)
|
||||
return #selected >= self.min_num
|
||||
end,
|
||||
}
|
||||
|
||||
local choosePlayersSkill = fk.CreateActiveSkill{
|
||||
name = "choose_players_skill",
|
||||
card_filter = function()
|
||||
return false
|
||||
end,
|
||||
target_filter = function(self, to_select, selected)
|
||||
if #selected < self.num then
|
||||
return table.contains(self.player_ids, to_select)
|
||||
end
|
||||
end,
|
||||
feasible = function(self, selected)
|
||||
return #selected >= self.min_num
|
||||
end,
|
||||
}
|
||||
|
||||
Fk:loadTranslationTable{
|
||||
["discard_skill"] = "弃牌",
|
||||
["choose_players_skill"] = "选择角色",
|
||||
}
|
||||
|
||||
AuxSkills = {
|
||||
discardSkill,
|
||||
choosePlayersSkill,
|
||||
}
|
|
@ -1,6 +1,7 @@
|
|||
local extension = Package:new("standard")
|
||||
extension.metadata = require "packages.standard.metadata"
|
||||
dofile "packages/standard/game_rule.lua"
|
||||
dofile "packages/standard/aux_skills.lua"
|
||||
|
||||
Fk:loadTranslationTable{
|
||||
["standard"] = "标准包",
|
||||
|
|
|
@ -48,7 +48,7 @@ callbacks["EnterRoom"] = function(jsonData) {
|
|||
// jsonData: int capacity, int timeout
|
||||
let data = JSON.parse(jsonData);
|
||||
config.roomCapacity = data[0];
|
||||
config.roomTimeout = data[1];
|
||||
config.roomTimeout = data[1] - 1;
|
||||
mainStack.push(room);
|
||||
mainWindow.busy = false;
|
||||
}
|
||||
|
|
|
@ -69,10 +69,10 @@ Item {
|
|||
okCancel.visible = false;
|
||||
endPhaseButton.visible = false;
|
||||
|
||||
dashboard.disableAllCards();
|
||||
dashboard.disableSkills();
|
||||
if (dashboard.pending_skill !== "")
|
||||
dashboard.stopPending();
|
||||
dashboard.disableAllCards();
|
||||
dashboard.disableSkills();
|
||||
selected_targets = [];
|
||||
|
||||
if (popupBox.item != null) {
|
||||
|
@ -277,7 +277,7 @@ Item {
|
|||
anchors.right: parent.right
|
||||
anchors.rightMargin: 30
|
||||
visible: false;
|
||||
onClicked: Logic.doCancelButton();
|
||||
onClicked: Logic.replyToServer("");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -190,6 +190,10 @@ RowLayout {
|
|||
pending_skill = skill_name;
|
||||
pendings = [];
|
||||
handcardAreaItem.unselectAll();
|
||||
for (let i = 0; i < skillButtons.count; i++) {
|
||||
let item = skillButtons.itemAt(i);
|
||||
item.enabled = item.pressed;
|
||||
}
|
||||
|
||||
// TODO: expand pile
|
||||
|
||||
|
|
|
@ -78,15 +78,16 @@ function doOkButton() {
|
|||
|
||||
function doCancelButton() {
|
||||
if (roomScene.state == "playing") {
|
||||
dashboard.stopPending();
|
||||
dashboard.deactivateSkillButton();
|
||||
dashboard.unSelectAll();
|
||||
dashboard.stopPending();
|
||||
dashboard.enableCards();
|
||||
dashboard.enableSkills();
|
||||
return;
|
||||
} else if (roomScene.state == "responding") {
|
||||
dashboard.stopPending();
|
||||
dashboard.deactivateSkillButton();
|
||||
dashboard.unSelectAll();
|
||||
dashboard.stopPending();
|
||||
replyToServer("");
|
||||
return;
|
||||
}
|
||||
|
@ -572,3 +573,20 @@ callbacks["AddSkill"] = function(jsonData) {
|
|||
dashboard.addSkill(skill_name);
|
||||
}
|
||||
}
|
||||
|
||||
callbacks["AskForUseActiveSkill"] = function(jsonData) {
|
||||
// jsonData: string skill_name, string prompt
|
||||
let data = JSON.parse(jsonData);
|
||||
let skill_name = data[0];
|
||||
let prompt = data[1];
|
||||
let cancelable = data[2];
|
||||
if (prompt === "") {
|
||||
roomScene.promptText = Backend.translate("#AskForUseActiveSkill")
|
||||
.arg(Backend.translate(skill_name));
|
||||
}
|
||||
// TODO: process prompt
|
||||
|
||||
roomScene.state = "responding";
|
||||
dashboard.startPending(skill_name);
|
||||
cancelButton.enabled = cancelable;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue