Wake limit (#101)
显示限定技标记的UI。 原理上也能显示觉醒技,我也做了显示觉醒技,但没测试。 转换技、使命技也是这样显示的,但先不提就是了,先合一发
This commit is contained in:
parent
09dd59bebf
commit
4833d202b1
Binary file not shown.
After Width: | Height: | Size: 6.6 KiB |
Binary file not shown.
After Width: | Height: | Size: 4.1 KiB |
Binary file not shown.
After Width: | Height: | Size: 4.1 KiB |
|
@ -491,6 +491,16 @@ fk.client_callback["LoseSkill"] = function(jsonData)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- 说是限定技,其实也适用于觉醒技、转换技、使命技
|
||||||
|
---@param skill Skill
|
||||||
|
---@param times integer
|
||||||
|
local function updateLimitSkill(pid, skill, times)
|
||||||
|
if not skill.visible then return end
|
||||||
|
if skill.frequency == Skill.Limited or skill.frequency == Skill.Wake then
|
||||||
|
ClientInstance:notifyUI("UpdateLimitSkill", json.encode{ pid, skill.name, times })
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
fk.client_callback["AddSkill"] = function(jsonData)
|
fk.client_callback["AddSkill"] = function(jsonData)
|
||||||
-- jsonData: [ int player_id, string skill_name ]
|
-- jsonData: [ int player_id, string skill_name ]
|
||||||
local data = json.decode(jsonData)
|
local data = json.decode(jsonData)
|
||||||
|
@ -501,6 +511,8 @@ fk.client_callback["AddSkill"] = function(jsonData)
|
||||||
if skill.visible then
|
if skill.visible then
|
||||||
ClientInstance:notifyUI("AddSkill", jsonData)
|
ClientInstance:notifyUI("AddSkill", jsonData)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
updateLimitSkill(id, skill, target:usedSkillTimes(skill_name, Player.HistoryGame))
|
||||||
end
|
end
|
||||||
|
|
||||||
fk.client_callback["AskForUseActiveSkill"] = function(jsonData)
|
fk.client_callback["AskForUseActiveSkill"] = function(jsonData)
|
||||||
|
@ -574,12 +586,20 @@ end
|
||||||
|
|
||||||
fk.client_callback["AddSkillUseHistory"] = function(jsonData)
|
fk.client_callback["AddSkillUseHistory"] = function(jsonData)
|
||||||
local data = json.decode(jsonData)
|
local data = json.decode(jsonData)
|
||||||
Self:addSkillUseHistory(data[1], data[2])
|
local playerid, skill_name, time = data[1], data[2], data[3]
|
||||||
|
local player = ClientInstance:getPlayerById(playerid)
|
||||||
|
player:addSkillUseHistory(skill_name, time)
|
||||||
|
if not Fk.skills[skill_name] then return end
|
||||||
|
updateLimitSkill(playerid, Fk.skills[skill_name], player:usedSkillTimes(skill_name, Player.HistoryGame))
|
||||||
end
|
end
|
||||||
|
|
||||||
fk.client_callback["SetSkillUseHistory"] = function(jsonData)
|
fk.client_callback["SetSkillUseHistory"] = function(jsonData)
|
||||||
local data = json.decode(jsonData)
|
local data = json.decode(jsonData)
|
||||||
Self:setSkillUseHistory(data[1], data[2], data[3])
|
local id, skill_name, time, scope = data[1], data[2], data[3], data[4]
|
||||||
|
local player = ClientInstance:getPlayerById(id)
|
||||||
|
player:setSkillUseHistory(skill_name, time, scope)
|
||||||
|
if not Fk.skills[skill_name] then return end
|
||||||
|
updateLimitSkill(id, Fk.skills[skill_name], player:usedSkillTimes(skill_name, Player.HistoryGame))
|
||||||
end
|
end
|
||||||
|
|
||||||
fk.client_callback["AddVirtualEquip"] = function(jsonData)
|
fk.client_callback["AddVirtualEquip"] = function(jsonData)
|
||||||
|
|
|
@ -231,11 +231,18 @@ function GetSkillData(skill_name)
|
||||||
if skill:isInstanceOf(ActiveSkill) or skill:isInstanceOf(ViewAsSkill) then
|
if skill:isInstanceOf(ActiveSkill) or skill:isInstanceOf(ViewAsSkill) then
|
||||||
freq = "active"
|
freq = "active"
|
||||||
end
|
end
|
||||||
|
local frequency
|
||||||
|
if skill.frequency == Skill.Limited then
|
||||||
|
frequency = "limit"
|
||||||
|
elseif skill.frequency == Skill.Wake then
|
||||||
|
frequency = "wake"
|
||||||
|
end
|
||||||
return json.encode{
|
return json.encode{
|
||||||
skill = Fk:translate(skill_name),
|
skill = Fk:translate(skill_name),
|
||||||
orig_skill = skill_name,
|
orig_skill = skill_name,
|
||||||
extension = skill.package.extensionName,
|
extension = skill.package.extensionName,
|
||||||
freq = freq
|
freq = freq,
|
||||||
|
frequency = frequency,
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -10,8 +10,8 @@
|
||||||
---@field public interaction any
|
---@field public interaction any
|
||||||
local ActiveSkill = UsableSkill:subclass("ActiveSkill")
|
local ActiveSkill = UsableSkill:subclass("ActiveSkill")
|
||||||
|
|
||||||
function ActiveSkill:initialize(name)
|
function ActiveSkill:initialize(name, frequency)
|
||||||
UsableSkill.initialize(self, name, Skill.NotFrequent)
|
UsableSkill.initialize(self, name, frequency)
|
||||||
self.min_target_num = 0
|
self.min_target_num = 0
|
||||||
self.max_target_num = 999
|
self.max_target_num = 999
|
||||||
self.min_card_num = 0
|
self.min_card_num = 0
|
||||||
|
|
|
@ -153,7 +153,7 @@ end
|
||||||
---@return ActiveSkill
|
---@return ActiveSkill
|
||||||
function fk.CreateActiveSkill(spec)
|
function fk.CreateActiveSkill(spec)
|
||||||
assert(type(spec.name) == "string")
|
assert(type(spec.name) == "string")
|
||||||
local skill = ActiveSkill:new(spec.name)
|
local skill = ActiveSkill:new(spec.name, spec.frequency or Skill.NotFrequent)
|
||||||
readUsableSpecToSkill(skill, spec)
|
readUsableSpecToSkill(skill, spec)
|
||||||
|
|
||||||
if spec.can_use then skill.canUse = spec.can_use end
|
if spec.can_use then skill.canUse = spec.can_use end
|
||||||
|
|
|
@ -540,12 +540,12 @@ end
|
||||||
|
|
||||||
function ServerPlayer:addSkillUseHistory(cardName, num)
|
function ServerPlayer:addSkillUseHistory(cardName, num)
|
||||||
Player.addSkillUseHistory(self, cardName, num)
|
Player.addSkillUseHistory(self, cardName, num)
|
||||||
self:doNotify("AddSkillUseHistory", json.encode{cardName, num})
|
self.room:doBroadcastNotify("AddSkillUseHistory", json.encode{self.id, cardName, num})
|
||||||
end
|
end
|
||||||
|
|
||||||
function ServerPlayer:setSkillUseHistory(cardName, num, scope)
|
function ServerPlayer:setSkillUseHistory(cardName, num, scope)
|
||||||
Player.setSkillUseHistory(self, cardName, num, scope)
|
Player.setSkillUseHistory(self, cardName, num, scope)
|
||||||
self:doNotify("SetSkillUseHistory", json.encode{cardName, num, scope})
|
self.room:doBroadcastNotify("SetSkillUseHistory", json.encode{self.id, cardName, num, scope})
|
||||||
end
|
end
|
||||||
|
|
||||||
---@param chained boolean
|
---@param chained boolean
|
||||||
|
|
|
@ -336,6 +336,14 @@ Item {
|
||||||
anchors.rightMargin: -4
|
anchors.rightMargin: -4
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LimitSkillArea {
|
||||||
|
id: limitSkills
|
||||||
|
anchors.top: role.bottom
|
||||||
|
anchors.left: role.left
|
||||||
|
anchors.topMargin: 2
|
||||||
|
anchors.leftMargin: -2
|
||||||
|
}
|
||||||
|
|
||||||
GlowText {
|
GlowText {
|
||||||
id: playerName
|
id: playerName
|
||||||
anchors.horizontalCenter: parent.horizontalCenter
|
anchors.horizontalCenter: parent.horizontalCenter
|
||||||
|
@ -526,4 +534,8 @@ Item {
|
||||||
chat.visible = true;
|
chat.visible = true;
|
||||||
chatAnim.restart();
|
chatAnim.restart();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function updateLimitSkill(skill, time) {
|
||||||
|
limitSkills.update(skill, time);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,31 @@
|
||||||
|
import QtQuick
|
||||||
|
import QtQuick.Layouts
|
||||||
|
|
||||||
|
ColumnLayout {
|
||||||
|
id: root
|
||||||
|
|
||||||
|
Repeater {
|
||||||
|
id: rep
|
||||||
|
model: ListModel {
|
||||||
|
id: skills
|
||||||
|
}
|
||||||
|
LimitSkillItem {
|
||||||
|
skillname: skillname_
|
||||||
|
usedtimes: times
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function update(skill, times) {
|
||||||
|
for (let i = 0; i < rep.count; i++) {
|
||||||
|
let data = skills.get(i);
|
||||||
|
if (data.skillname_ === skill) {
|
||||||
|
data.times = times;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
skills.append({
|
||||||
|
skillname_: skill,
|
||||||
|
times: times,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,62 @@
|
||||||
|
import QtQuick
|
||||||
|
import "../../skin-bank.js" as SkinBank
|
||||||
|
|
||||||
|
Item {
|
||||||
|
id: root
|
||||||
|
height: 20
|
||||||
|
property string skillname: "zhiheng"
|
||||||
|
property string skilltype: "limit" // limit, wake, ...
|
||||||
|
property int usedtimes: -1 // -1 will not be shown
|
||||||
|
// visible: false
|
||||||
|
|
||||||
|
Image {
|
||||||
|
id: bg
|
||||||
|
source: SkinBank.LIMIT_SKILL_DIR + skilltype
|
||||||
|
height: 47 * 0.6
|
||||||
|
width: 87 * 0.6
|
||||||
|
}
|
||||||
|
|
||||||
|
Text {
|
||||||
|
anchors.centerIn: bg
|
||||||
|
color: "#F0E5DA"
|
||||||
|
font.pixelSize: 20
|
||||||
|
font.family: fontLi2.name
|
||||||
|
style: Text.Outline
|
||||||
|
styleColor: "#3D2D1C"
|
||||||
|
text: Backend.translate(skillname);
|
||||||
|
}
|
||||||
|
|
||||||
|
Text {
|
||||||
|
id: x
|
||||||
|
opacity: skilltype === "limit" ? 1 : 0
|
||||||
|
text: "X"
|
||||||
|
font.family: fontLibian.name
|
||||||
|
font.pixelSize: 28
|
||||||
|
color: "red"
|
||||||
|
x: 26
|
||||||
|
}
|
||||||
|
|
||||||
|
onSkillnameChanged: {
|
||||||
|
let data = Backend.callLuaFunction("GetSkillData", [skillname]);
|
||||||
|
data = JSON.parse(data);
|
||||||
|
if (data.frequency) {
|
||||||
|
skilltype = data.frequency;
|
||||||
|
visible = true;
|
||||||
|
} else {
|
||||||
|
visible = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
onUsedtimesChanged: {
|
||||||
|
x.visible = false;
|
||||||
|
if (skilltype === "wake") {
|
||||||
|
visible = (usedtimes < 1);
|
||||||
|
} else if (skilltype === "limit") {
|
||||||
|
visible = true;
|
||||||
|
if (usedtimes >= 1) {
|
||||||
|
x.visible = true;
|
||||||
|
bg.source = SkinBank.LIMIT_SKILL_DIR + "limit-used";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -996,3 +996,15 @@ callbacks["CustomDialog"] = (j) => {
|
||||||
roomScene.popupBox.item.loadData(dat);
|
roomScene.popupBox.item.loadData(dat);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
callbacks["UpdateLimitSkill"] = (j) => {
|
||||||
|
let data = JSON.parse(j);
|
||||||
|
let id = data[0];
|
||||||
|
let skill = data[1];
|
||||||
|
let time = data[2];
|
||||||
|
|
||||||
|
let photo = getPhotoOrSelf(id);
|
||||||
|
if (photo) {
|
||||||
|
photo.updateLimitSkill(skill, time);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -8,6 +8,7 @@ var STATUS_DIR = AppPath + "/image/photo/status/";
|
||||||
var ROLE_DIR = AppPath + "/image/photo/role/";
|
var ROLE_DIR = AppPath + "/image/photo/role/";
|
||||||
var DEATH_DIR = AppPath + "/image/photo/death/";
|
var DEATH_DIR = AppPath + "/image/photo/death/";
|
||||||
var MAGATAMA_DIR = AppPath + "/image/photo/magatama/";
|
var MAGATAMA_DIR = AppPath + "/image/photo/magatama/";
|
||||||
|
var LIMIT_SKILL_DIR = AppPath + "/image/photo/skill/";
|
||||||
var CARD_DIR = AppPath + "/image/card/";
|
var CARD_DIR = AppPath + "/image/card/";
|
||||||
var CARD_SUIT_DIR = AppPath + "/image/card/suit/";
|
var CARD_SUIT_DIR = AppPath + "/image/card/suit/";
|
||||||
var DELAYED_TRICK_DIR = AppPath + "/image/card/delayedTrick/";
|
var DELAYED_TRICK_DIR = AppPath + "/image/card/delayedTrick/";
|
||||||
|
|
Loading…
Reference in New Issue