mirror of
https://github.com/Qsgs-Fans/FreeKill.git
synced 2024-11-15 19:22:25 +08:00
JS修改+距离计算修改 (#179)
- 替换大多数let为const - 将一些双等号替换为三等号 - 距离计算追加“玩家自己与距离为0”设定,副作用是不显示自身距离
This commit is contained in:
parent
713bbca17a
commit
a6ad71c19f
80
Fk/Logic.js
80
Fk/Logic.js
|
@ -17,7 +17,7 @@ function createClientPages() {
|
|||
var callbacks = {};
|
||||
let sheduled_download = "";
|
||||
|
||||
callbacks["NetworkDelayTest"] = function(jsonData) {
|
||||
callbacks["NetworkDelayTest"] = (jsonData) => {
|
||||
// jsonData: RSA pub key
|
||||
let cipherText;
|
||||
let aeskey;
|
||||
|
@ -37,10 +37,10 @@ callbacks["NetworkDelayTest"] = function(jsonData) {
|
|||
Backend.replyDelayTest(config.screenName, cipherText);
|
||||
}
|
||||
|
||||
callbacks["ErrorMsg"] = function(jsonData) {
|
||||
callbacks["ErrorMsg"] = (jsonData) => {
|
||||
let log;
|
||||
try {
|
||||
let a = JSON.parse(jsonData);
|
||||
const a = JSON.parse(jsonData);
|
||||
log = qsTr(a[0]).arg(a[1]);
|
||||
} catch (e) {
|
||||
log = qsTr(jsonData);
|
||||
|
@ -58,22 +58,22 @@ callbacks["ErrorMsg"] = function(jsonData) {
|
|||
|
||||
callbacks["UpdatePackage"] = (jsonData) => sheduled_download = jsonData;
|
||||
|
||||
callbacks["UpdateBusyText"] = function(jsonData) {
|
||||
callbacks["UpdateBusyText"] = (jsonData) => {
|
||||
mainWindow.busyText = jsonData;
|
||||
}
|
||||
|
||||
callbacks["DownloadComplete"] = function() {
|
||||
callbacks["DownloadComplete"] = () => {
|
||||
mainWindow.busy = false;
|
||||
mainStack.currentItem.downloadComplete(); // should be pacman page
|
||||
}
|
||||
|
||||
callbacks["BackToStart"] = function(jsonData) {
|
||||
callbacks["BackToStart"] = (jsonData) => {
|
||||
while (mainStack.depth > 1) {
|
||||
mainStack.pop();
|
||||
}
|
||||
}
|
||||
|
||||
callbacks["EnterLobby"] = function(jsonData) {
|
||||
callbacks["EnterLobby"] = (jsonData) => {
|
||||
// depth == 1 means the lobby page is not present in mainStack
|
||||
createClientPages();
|
||||
if (mainStack.depth === 1) {
|
||||
|
@ -92,50 +92,54 @@ callbacks["EnterLobby"] = function(jsonData) {
|
|||
mainWindow.busy = false;
|
||||
}
|
||||
|
||||
callbacks["EnterRoom"] = function(jsonData) {
|
||||
callbacks["EnterRoom"] = (jsonData) => {
|
||||
// jsonData: int capacity, int timeout
|
||||
let data = JSON.parse(jsonData);
|
||||
const data = JSON.parse(jsonData);
|
||||
config.roomCapacity = data[0];
|
||||
config.roomTimeout = data[1] - 1;
|
||||
let roomSettings = data[2];
|
||||
const roomSettings = data[2];
|
||||
config.enableFreeAssign = roomSettings.enableFreeAssign;
|
||||
mainStack.push(room);
|
||||
mainWindow.busy = false;
|
||||
}
|
||||
|
||||
callbacks["UpdateRoomList"] = function(jsonData) {
|
||||
let current = mainStack.currentItem; // should be lobby
|
||||
current.roomModel.clear();
|
||||
JSON.parse(jsonData).forEach(function(room) {
|
||||
current.roomModel.append({
|
||||
roomId: room[0],
|
||||
roomName: room[1],
|
||||
gameMode: room[2],
|
||||
playerNum: room[3],
|
||||
capacity: room[4],
|
||||
hasPassword: room[5] ? true : false,
|
||||
callbacks["UpdateRoomList"] = (jsonData) => {
|
||||
const current = mainStack.currentItem; // should be lobby
|
||||
if (mainStack.currentItem === lobby) {
|
||||
current.roomModel.clear();
|
||||
JSON.parse(jsonData).forEach(function (room) {
|
||||
current.roomModel.append({
|
||||
roomId: room[0],
|
||||
roomName: room[1],
|
||||
gameMode: room[2],
|
||||
playerNum: room[3],
|
||||
capacity: room[4],
|
||||
hasPassword: room[5] ? true : false,
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
callbacks["UpdatePlayerNum"] = (j) => {
|
||||
let current = mainStack.currentItem; // should be lobby
|
||||
let data = JSON.parse(j);
|
||||
let l = data[0];
|
||||
let s = data[1];
|
||||
current.lobbyPlayerNum = l;
|
||||
current.serverPlayerNum = s;
|
||||
const current = mainStack.currentItem; // should be lobby
|
||||
if (mainStack.currentItem === lobby) {
|
||||
const data = JSON.parse(j);
|
||||
const l = data[0];
|
||||
const s = data[1];
|
||||
current.lobbyPlayerNum = l;
|
||||
current.serverPlayerNum = s;
|
||||
}
|
||||
}
|
||||
|
||||
callbacks["Chat"] = function(jsonData) {
|
||||
callbacks["Chat"] = (jsonData) => {
|
||||
// jsonData: { string userName, string general, string time, string msg }
|
||||
let current = mainStack.currentItem; // lobby or room
|
||||
let data = JSON.parse(jsonData);
|
||||
let pid = data.sender;
|
||||
let userName = data.userName;
|
||||
let general = Backend.translate(data.general);
|
||||
let time = data.time;
|
||||
let msg = data.msg;
|
||||
const current = mainStack.currentItem; // lobby or room
|
||||
const data = JSON.parse(jsonData);
|
||||
const pid = data.sender;
|
||||
const userName = data.userName;
|
||||
const general = Backend.translate(data.general);
|
||||
const time = data.time;
|
||||
const msg = data.msg;
|
||||
|
||||
if (general === "")
|
||||
current.addToChat(pid, data, `[${time}] ${userName}: ${msg}`);
|
||||
|
@ -143,8 +147,8 @@ callbacks["Chat"] = function(jsonData) {
|
|||
current.addToChat(pid, data, `[${time}] ${userName}(${general}): ${msg}`);
|
||||
}
|
||||
|
||||
callbacks["ServerMessage"] = function(jsonData) {
|
||||
let current = mainStack.currentItem; // lobby or room
|
||||
callbacks["ServerMessage"] = (jsonData) => {
|
||||
const current = mainStack.currentItem; // lobby or room
|
||||
current.sendDanmaku('<font color="gold"><b>[Server] </b></font>' + jsonData);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
callbacks["UpdateAvatar"] = function(jsonData) {
|
||||
callbacks["UpdateAvatar"] = (jsonData) => {
|
||||
mainWindow.busy = false;
|
||||
Self.avatar = jsonData;
|
||||
toast.show("Update avatar done.");
|
||||
}
|
||||
|
||||
callbacks["UpdatePassword"] = function(jsonData) {
|
||||
callbacks["UpdatePassword"] = (jsonData) => {
|
||||
mainWindow.busy = false;
|
||||
if (jsonData === "1")
|
||||
toast.show("Update password done.");
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -397,7 +397,8 @@ end
|
|||
--- 通过 二者位次+距离技能之和 与 两者间固定距离 进行对比,更大的为实际距离。
|
||||
---@param other Player @ 其他玩家
|
||||
function Player:distanceTo(other)
|
||||
assert(other:isInstanceOf(Player))
|
||||
-- assert(other:isInstanceOf(Player))
|
||||
if other == self then return 0 end
|
||||
local right = 0
|
||||
local temp = self
|
||||
while temp ~= other do
|
||||
|
|
Loading…
Reference in New Issue
Block a user