Compare commits
3 Commits
43f9620a80
...
982132c621
Author | SHA1 | Date | |
---|---|---|---|
982132c621 | |||
aad9b09935 | |||
ac77b6cb8f |
23
lua/autorun/server/sv_config.lua
Normal file
23
lua/autorun/server/sv_config.lua
Normal file
@ -0,0 +1,23 @@
|
||||
utils = include("sv_utils.lua")
|
||||
config = include("../sh_config.lua")
|
||||
|
||||
local dirs = utils.split(config.config_path, "/")
|
||||
table.remove(dirs)
|
||||
local tmp = "";
|
||||
for i, dir in ipairs(dirs) do
|
||||
tmp = tmp .. dir
|
||||
if not file.Exists(tmp, "DATA")
|
||||
then
|
||||
print(tmp)
|
||||
file.CreateDir(tmp)
|
||||
end
|
||||
tmp = tmp .. "/"
|
||||
end
|
||||
|
||||
if not file.Exists(config.config_path, "DATA")
|
||||
then
|
||||
print(config.config_path)
|
||||
local default_config = {}
|
||||
default_config.diseases = {}
|
||||
file.Write(config.config_path, util.TableToJSON(default_config, true))
|
||||
end
|
20
lua/autorun/server/sv_disease.lua
Normal file
20
lua/autorun/server/sv_disease.lua
Normal file
@ -0,0 +1,20 @@
|
||||
Disease = {}
|
||||
|
||||
--- Disease class
|
||||
---@param side name string? the name of the disease (string)
|
||||
---@param side symbtoms_by_stages list? a list of list of symbtom, a list of symbtoms by stage (Symbtom)
|
||||
---@param side contaminations_methods list? a list of contamination method (string)
|
||||
---@param side transmissions_zone_by_stage list? a list of transmissions zone (int), one number by stage
|
||||
---@param side stages_durations list? a list of stage duration (int), one number by stage
|
||||
function Disease:new(name, symbtoms_by_stages, contaminations_methods, transmissions_zone_by_stages, stages_durations)
|
||||
local instance = {}
|
||||
setmetatable(instance, {__index = Disease})
|
||||
instance.name = name
|
||||
instance.symbtoms_by_stages = symbtoms_by_stages
|
||||
instance.contaminations_methods = contaminations_methods
|
||||
instance.transmissions_zone_by_stages = transmissions_zone_by_stages
|
||||
instance.stages_durations = stages_durations
|
||||
return instance
|
||||
end
|
||||
|
||||
return Disease
|
11
lua/autorun/server/sv_utils.lua
Normal file
11
lua/autorun/server/sv_utils.lua
Normal file
@ -0,0 +1,11 @@
|
||||
utils = {}
|
||||
|
||||
function utils.split (str, sep)
|
||||
local new_table = {}
|
||||
for v in string.gmatch(str, "([^"..sep.."]+)") do
|
||||
table.insert(new_table, v)
|
||||
end
|
||||
return new_table
|
||||
end
|
||||
|
||||
return utils
|
6
lua/autorun/sh_config.lua
Normal file
6
lua/autorun/sh_config.lua
Normal file
@ -0,0 +1,6 @@
|
||||
config = {}
|
||||
|
||||
-- the config file path location
|
||||
config.config_path = "disease/config.json"
|
||||
|
||||
return config
|
Loading…
Reference in New Issue
Block a user