2023-04-09 05:35:35 +00:00
|
|
|
|
-- SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
|
|
2023-04-12 12:51:09 +00:00
|
|
|
|
-- 用于初始化FreeKill的最基本脚本
|
|
|
|
|
-- 向Lua虚拟机中加载库、游戏中的类,以及加载Mod等等。
|
2022-01-24 02:23:08 +00:00
|
|
|
|
|
2023-04-12 12:51:09 +00:00
|
|
|
|
-- 加载第三方库
|
2022-03-25 04:28:07 +00:00
|
|
|
|
package.path = package.path .. ";./lua/lib/?.lua"
|
2022-03-28 14:24:30 +00:00
|
|
|
|
.. ";./lua/?.lua"
|
2022-01-24 02:23:08 +00:00
|
|
|
|
|
2023-04-12 12:51:09 +00:00
|
|
|
|
-- middleclass: 轻量级的面向对象库
|
2022-03-25 04:28:07 +00:00
|
|
|
|
class = require "middleclass"
|
2023-04-12 12:51:09 +00:00
|
|
|
|
|
|
|
|
|
-- json: 提供json处理支持,能解析JSON和生成JSON
|
2022-03-25 04:28:07 +00:00
|
|
|
|
json = require "json"
|
2022-03-30 08:33:56 +00:00
|
|
|
|
|
2023-04-12 12:51:09 +00:00
|
|
|
|
-- 初始化随机数种子
|
|
|
|
|
math.randomseed(os.time())
|
|
|
|
|
|
|
|
|
|
-- 加载实用类,让Lua编写起来更轻松。
|
2023-04-13 12:17:39 +00:00
|
|
|
|
local Utils = require "core.util"
|
2023-11-07 04:57:00 +00:00
|
|
|
|
-- TargetGroup, AimGroup, Util = table.unpack(Utils)
|
|
|
|
|
TargetGroup, AimGroup, Util = Utils[1], Utils[2], Utils[3]
|
2022-04-01 12:51:01 +00:00
|
|
|
|
dofile "lua/core/debug.lua"
|
2022-03-31 05:29:23 +00:00
|
|
|
|
|
2023-04-12 12:51:09 +00:00
|
|
|
|
-- 加载游戏核心类
|
2022-03-30 06:14:40 +00:00
|
|
|
|
Engine = require "core.engine"
|
|
|
|
|
Package = require "core.package"
|
|
|
|
|
General = require "core.general"
|
|
|
|
|
Card = require "core.card"
|
2023-01-16 11:13:07 +00:00
|
|
|
|
Exppattern = require "core.exppattern"
|
2022-03-30 06:14:40 +00:00
|
|
|
|
Skill = require "core.skill"
|
2023-01-29 10:11:41 +00:00
|
|
|
|
UsableSkill = require "core.skill_type.usable_skill"
|
|
|
|
|
StatusSkill = require "core.skill_type.status_skill"
|
2022-03-30 06:14:40 +00:00
|
|
|
|
Player = require "core.player"
|
2023-03-13 16:12:02 +00:00
|
|
|
|
GameMode = require "core.game_mode"
|
2024-02-17 01:46:48 +00:00
|
|
|
|
AbstractRoom = require "core.abstract_room"
|
2023-04-04 16:49:54 +00:00
|
|
|
|
UI = require "ui-util"
|
2022-03-25 04:28:07 +00:00
|
|
|
|
|
2023-04-12 12:51:09 +00:00
|
|
|
|
-- 读取配置文件。
|
|
|
|
|
-- 因为io马上就要被禁用了,所以赶紧先在这里读取配置文件。
|
2023-02-27 02:23:48 +00:00
|
|
|
|
local function loadConf()
|
|
|
|
|
local cfg = io.open("freekill.client.config.json")
|
|
|
|
|
local ret
|
|
|
|
|
if cfg == nil then
|
|
|
|
|
ret = {
|
|
|
|
|
language = "zh_CN",
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
ret = json.decode(cfg:read("a"))
|
|
|
|
|
cfg:close()
|
|
|
|
|
end
|
|
|
|
|
return ret
|
|
|
|
|
end
|
|
|
|
|
Config = loadConf()
|
|
|
|
|
|
2023-04-12 12:51:09 +00:00
|
|
|
|
-- 禁用各种危险的函数,尽可能让Lua执行安全的代码。
|
2023-03-14 12:50:36 +00:00
|
|
|
|
local _os = {
|
|
|
|
|
time = os.time,
|
|
|
|
|
date = os.date,
|
|
|
|
|
clock = os.clock,
|
|
|
|
|
difftime = os.difftime,
|
|
|
|
|
getms = os.getms,
|
|
|
|
|
}
|
|
|
|
|
os = _os
|
2023-02-27 02:23:48 +00:00
|
|
|
|
io = nil
|
2023-03-14 12:50:36 +00:00
|
|
|
|
package = nil
|
|
|
|
|
load = nil
|
|
|
|
|
loadfile = nil
|
2023-04-30 10:51:05 +00:00
|
|
|
|
local _dofile = dofile
|
|
|
|
|
dofile = function(f)
|
|
|
|
|
local errmsg = "Refusing dofile that not in game directory"
|
|
|
|
|
assert(not f:startsWith("/"), errmsg)
|
|
|
|
|
assert(not f:startsWith(".."), errmsg)
|
|
|
|
|
assert(not f:find(":"), errmsg)
|
|
|
|
|
return _dofile(f)
|
|
|
|
|
end
|
2023-02-27 02:23:48 +00:00
|
|
|
|
|
2023-04-12 12:51:09 +00:00
|
|
|
|
-- 初始化Engine类并置于Fk全局变量中,这里会加载拓展包
|
2022-03-31 05:29:23 +00:00
|
|
|
|
dofile "lua/fk_ex.lua"
|
2022-03-28 14:24:30 +00:00
|
|
|
|
Fk = Engine:new()
|