Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
S
srvpro
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nanahira
srvpro
Commits
606510e6
Commit
606510e6
authored
Mar 04, 2018
by
mercury233
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix load json file
parent
d1e13f84
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
53 additions
and
41 deletions
+53
-41
package.json
package.json
+1
-0
ygopro-deck-stats.js
ygopro-deck-stats.js
+3
-2
ygopro-pre.js
ygopro-pre.js
+3
-2
ygopro-server.coffee
ygopro-server.coffee
+13
-11
ygopro-server.js
ygopro-server.js
+14
-12
ygopro-tournament.js
ygopro-tournament.js
+2
-1
ygopro-update.js
ygopro-update.js
+3
-2
ygopro.coffee
ygopro.coffee
+6
-5
ygopro.js
ygopro.js
+8
-6
No files found.
package.json
View file @
606510e6
...
...
@@ -13,6 +13,7 @@
"dependencies"
:
{
"
bunyan
"
:
"
latest
"
,
"
deepmerge
"
:
"
latest
"
,
"
load-json-file
"
:
"
latest
"
,
"
moment
"
:
"
latest
"
,
"
request
"
:
"
latest
"
,
"
underscore
"
:
"
latest
"
,
...
...
ygopro-deck-stats.js
View file @
606510e6
...
...
@@ -8,8 +8,9 @@
*/
var
sqlite3
=
require
(
'
sqlite3
'
).
verbose
();
var
fs
=
require
(
'
fs
'
);
var
config
=
require
(
'
./config/deckstats.json
'
);
//{ "deckpath": "../decks", "dbfile": "cards.cdb" }
var
constants
=
require
(
'
./data/constants.json
'
);
var
loadJSON
=
require
(
'
load-json-file
'
).
sync
;
var
config
=
loadJSON
(
'
./config/deckstats.json
'
);
//{ "deckpath": "../decks", "dbfile": "cards.cdb" }
var
constants
=
loadJSON
(
'
./data/constants.json
'
);
var
ALL_MAIN_CARDS
=
{};
var
ALL_SIDE_CARDS
=
{};
...
...
ygopro-pre.js
View file @
606510e6
...
...
@@ -15,10 +15,11 @@ var spawn = require('child_process').spawn;
var
url
=
require
(
'
url
'
);
var
moment
=
require
(
'
moment
'
);
moment
.
locale
(
'
zh-cn
'
);
var
loadJSON
=
require
(
'
load-json-file
'
).
sync
;
var
constants
=
require
(
'
./data/constants.json
'
);
var
constants
=
loadJSON
(
'
./data/constants.json
'
);
var
settings
=
require
(
'
./config/config.json
'
);
var
settings
=
loadJSON
(
'
./config/config.json
'
);
config
=
settings
.
modules
.
pre_util
;
//全卡HTML列表
...
...
ygopro-server.coffee
View file @
606510e6
...
...
@@ -42,6 +42,8 @@ moment.locale('zh-cn', {
merge
=
require
'deepmerge'
loadJSON
=
require
(
'load-json-file'
).
sync
#heapdump = require 'heapdump'
# 配置
...
...
@@ -49,7 +51,7 @@ merge = require 'deepmerge'
if
not
fs
.
existsSync
(
'./config'
)
fs
.
mkdirSync
(
'./config'
)
try
oldconfig
=
require
(
'./config.user.json'
)
oldconfig
=
loadJSON
(
'./config.user.json'
)
if
oldconfig
.
tips
oldtips
=
{}
oldtips
.
file
=
'./config/tips.json'
...
...
@@ -90,7 +92,7 @@ try
log
.
info
'imported old config from config.user.json'
fs
.
renameSync
(
'./config.user.json'
,
'./config.user.bak'
)
catch
e
log
.
info
e
unless
e
.
code
==
'
MODULE_NOT_FOUND
'
log
.
info
e
unless
e
.
code
==
'
ENOENT
'
setting_save
=
(
settings
)
->
fs
.
writeFileSync
(
settings
.
file
,
JSON
.
stringify
(
settings
,
null
,
2
))
...
...
@@ -113,37 +115,37 @@ setting_change = (settings, path, val) ->
return
# 读取配置
default_config
=
require
(
'./data/default_config.json'
)
default_config
=
loadJSON
(
'./data/default_config.json'
)
try
config
=
require
(
'./config/config.json'
)
config
=
loadJSON
(
'./config/config.json'
)
catch
config
=
{}
settings
=
global
.
settings
=
merge
(
default_config
,
config
,
{
arrayMerge
:
(
destination
,
source
)
->
source
})
# 读取数据
default_data
=
require
(
'./data/default_data.json'
)
default_data
=
loadJSON
(
'./data/default_data.json'
)
try
tips
=
require
(
'./config/tips.json'
)
tips
=
loadJSON
(
'./config/tips.json'
)
catch
tips
=
default_data
.
tips
setting_save
(
tips
)
try
dialogues
=
require
(
'./config/dialogues.json'
)
dialogues
=
loadJSON
(
'./config/dialogues.json'
)
catch
dialogues
=
default_data
.
dialogues
setting_save
(
dialogues
)
try
badwords
=
require
(
'./config/badwords.json'
)
badwords
=
loadJSON
(
'./config/badwords.json'
)
catch
badwords
=
default_data
.
badwords
setting_save
(
badwords
)
try
duel_log
=
require
(
'./config/duel_log.json'
)
duel_log
=
loadJSON
(
'./config/duel_log.json'
)
catch
duel_log
=
default_data
.
duel_log
setting_save
(
duel_log
)
try
chat_color
=
require
(
'./config/chat_color.json'
)
chat_color
=
loadJSON
(
'./config/chat_color.json'
)
catch
chat_color
=
default_data
.
chat_color
setting_save
(
chat_color
)
...
...
@@ -170,7 +172,7 @@ if settings.modules.cloud_replay.enabled
return
if
settings
.
modules
.
windbot
.
enabled
windbots
=
require
(
settings
.
modules
.
windbot
.
botlist
).
windbots
windbots
=
loadJSON
(
settings
.
modules
.
windbot
.
botlist
).
windbots
# 组件
ygopro
=
require
'./ygopro.js'
...
...
ygopro-server.js
View file @
606510e6
// Generated by CoffeeScript 1.12.7
(
function
()
{
var
Cloud_replay_ids
,
ROOM_all
,
ROOM_bad_ip
,
ROOM_ban_player
,
ROOM_connected_ip
,
ROOM_find_by_name
,
ROOM_find_by_port
,
ROOM_find_by_title
,
ROOM_find_or_create_ai
,
ROOM_find_or_create_by_name
,
ROOM_find_or_create_random
,
ROOM_players_banned
,
ROOM_players_oppentlist
,
ROOM_unwelcome
,
ROOM_validate
,
Room
,
_
,
addCallback
,
badwords
,
ban_user
,
bunyan
,
chat_color
,
config
,
cppversion
,
crypto
,
date
,
default_config
,
default_data
,
dialogues
,
duel_log
,
e
,
exec
,
execFile
,
fs
,
geoip
,
get_memory_usage
,
http
,
http_server
,
https
,
https_server
,
lflists
,
list
,
load_dialogues
,
load_tips
,
log
,
memory_usage
,
merge
,
moment
,
net
,
oldbadwords
,
oldconfig
,
olddialogues
,
oldduellog
,
oldtips
,
options
,
os
,
path
,
pgClient
,
pg_client
,
pg_query
,
redis
,
redisdb
,
report_to_big_brother
,
request
,
requestListener
,
roomlist
,
setting_change
,
setting_save
,
settings
,
spawn
,
spawnSync
,
tips
,
url
,
users_cache
,
wait_room_start
,
wait_room_start_arena
,
windbot_bin
,
windbot_parameters
,
windbot_process
,
windbots
,
ygopro
,
zlib
;
var
Cloud_replay_ids
,
ROOM_all
,
ROOM_bad_ip
,
ROOM_ban_player
,
ROOM_connected_ip
,
ROOM_find_by_name
,
ROOM_find_by_port
,
ROOM_find_by_title
,
ROOM_find_or_create_ai
,
ROOM_find_or_create_by_name
,
ROOM_find_or_create_random
,
ROOM_players_banned
,
ROOM_players_oppentlist
,
ROOM_unwelcome
,
ROOM_validate
,
Room
,
_
,
addCallback
,
badwords
,
ban_user
,
bunyan
,
chat_color
,
config
,
cppversion
,
crypto
,
date
,
default_config
,
default_data
,
dialogues
,
duel_log
,
e
,
exec
,
execFile
,
fs
,
geoip
,
get_memory_usage
,
http
,
http_server
,
https
,
https_server
,
lflists
,
list
,
load
JSON
,
load
_dialogues
,
load_tips
,
log
,
memory_usage
,
merge
,
moment
,
net
,
oldbadwords
,
oldconfig
,
olddialogues
,
oldduellog
,
oldtips
,
options
,
os
,
path
,
pgClient
,
pg_client
,
pg_query
,
redis
,
redisdb
,
report_to_big_brother
,
request
,
requestListener
,
roomlist
,
setting_change
,
setting_save
,
settings
,
spawn
,
spawnSync
,
tips
,
url
,
users_cache
,
wait_room_start
,
wait_room_start_arena
,
windbot_bin
,
windbot_parameters
,
windbot_process
,
windbots
,
ygopro
,
zlib
;
net
=
require
(
'
net
'
);
...
...
@@ -60,12 +60,14 @@
merge
=
require
(
'
deepmerge
'
);
loadJSON
=
require
(
'
load-json-file
'
).
sync
;
if
(
!
fs
.
existsSync
(
'
./config
'
))
{
fs
.
mkdirSync
(
'
./config
'
);
}
try
{
oldconfig
=
require
(
'
./config.user.json
'
);
oldconfig
=
loadJSON
(
'
./config.user.json
'
);
if
(
oldconfig
.
tips
)
{
oldtips
=
{};
oldtips
.
file
=
'
./config/tips.json
'
;
...
...
@@ -115,7 +117,7 @@
fs
.
renameSync
(
'
./config.user.json
'
,
'
./config.user.bak
'
);
}
catch
(
error1
)
{
e
=
error1
;
if
(
e
.
code
!==
'
MODULE_NOT_FOUND
'
)
{
if
(
e
.
code
!==
'
ENOENT
'
)
{
log
.
info
(
e
);
}
}
...
...
@@ -144,10 +146,10 @@
setting_save
(
settings
);
};
default_config
=
require
(
'
./data/default_config.json
'
);
default_config
=
loadJSON
(
'
./data/default_config.json
'
);
try
{
config
=
require
(
'
./config/config.json
'
);
config
=
loadJSON
(
'
./config/config.json
'
);
}
catch
(
error1
)
{
config
=
{};
}
...
...
@@ -158,38 +160,38 @@
}
});
default_data
=
require
(
'
./data/default_data.json
'
);
default_data
=
loadJSON
(
'
./data/default_data.json
'
);
try
{
tips
=
require
(
'
./config/tips.json
'
);
tips
=
loadJSON
(
'
./config/tips.json
'
);
}
catch
(
error1
)
{
tips
=
default_data
.
tips
;
setting_save
(
tips
);
}
try
{
dialogues
=
require
(
'
./config/dialogues.json
'
);
dialogues
=
loadJSON
(
'
./config/dialogues.json
'
);
}
catch
(
error1
)
{
dialogues
=
default_data
.
dialogues
;
setting_save
(
dialogues
);
}
try
{
badwords
=
require
(
'
./config/badwords.json
'
);
badwords
=
loadJSON
(
'
./config/badwords.json
'
);
}
catch
(
error1
)
{
badwords
=
default_data
.
badwords
;
setting_save
(
badwords
);
}
try
{
duel_log
=
require
(
'
./config/duel_log.json
'
);
duel_log
=
loadJSON
(
'
./config/duel_log.json
'
);
}
catch
(
error1
)
{
duel_log
=
default_data
.
duel_log
;
setting_save
(
duel_log
);
}
try
{
chat_color
=
require
(
'
./config/chat_color.json
'
);
chat_color
=
loadJSON
(
'
./config/chat_color.json
'
);
}
catch
(
error1
)
{
chat_color
=
default_data
.
chat_color
;
setting_save
(
chat_color
);
...
...
@@ -234,7 +236,7 @@
}
if
(
settings
.
modules
.
windbot
.
enabled
)
{
windbots
=
require
(
settings
.
modules
.
windbot
.
botlist
).
windbots
;
windbots
=
loadJSON
(
settings
.
modules
.
windbot
.
botlist
).
windbots
;
}
ygopro
=
require
(
'
./ygopro.js
'
);
...
...
ygopro-tournament.js
View file @
606510e6
...
...
@@ -14,8 +14,9 @@ var formidable = require('formidable');
var
_
=
require
(
'
underscore
'
);
_
.
str
=
require
(
'
underscore.string
'
);
_
.
mixin
(
_
.
str
.
exports
());
var
loadJSON
=
require
(
'
load-json-file
'
).
sync
;
var
settings
=
require
(
'
./config/config.json
'
);
var
settings
=
loadJSON
(
'
./config/config.json
'
);
config
=
settings
.
modules
.
tournament_mode
;
//http长连接
...
...
ygopro-update.js
View file @
606510e6
...
...
@@ -16,10 +16,11 @@ var spawnSync = require('child_process').spawnSync;
var
url
=
require
(
'
url
'
);
var
moment
=
require
(
'
moment
'
);
moment
.
locale
(
'
zh-cn
'
);
var
loadJSON
=
require
(
'
load-json-file
'
).
sync
;
var
constants
=
require
(
'
./data/constants.json
'
);
var
constants
=
loadJSON
(
'
./data/constants.json
'
);
var
settings
=
require
(
'
./config/config.json
'
);
var
settings
=
loadJSON
(
'
./config/config.json
'
);
config
=
settings
.
modules
.
update_util
;
//全卡名称列表
...
...
ygopro.coffee
View file @
606510e6
...
...
@@ -3,14 +3,15 @@ _.str = require 'underscore.string'
_
.
mixin
(
_
.
str
.
exports
())
Struct
=
require
(
'./struct.js'
).
Struct
loadJSON
=
require
(
'load-json-file'
).
sync
i18ns
=
require
'./data/i18n.json'
i18ns
=
loadJSON
'./data/i18n.json'
#常量/类型声明
structs_declaration
=
require
'./data/structs.json'
#结构体声明
typedefs
=
require
'./data/typedefs.json'
#类型声明
@
proto_structs
=
require
'./data/proto_structs.json'
#消息与结构体的对应,未完成,对着duelclient.cpp加
@
constants
=
require
'./data/constants.json'
#network.h里定义的常量
structs_declaration
=
loadJSON
'./data/structs.json'
#结构体声明
typedefs
=
loadJSON
'./data/typedefs.json'
#类型声明
@
proto_structs
=
loadJSON
'./data/proto_structs.json'
#消息与结构体的对应,未完成,对着duelclient.cpp加
@
constants
=
loadJSON
'./data/constants.json'
#network.h里定义的常量
#结构体定义
@
structs
=
{}
...
...
ygopro.js
View file @
606510e6
// Generated by CoffeeScript 1.12.7
(
function
()
{
var
Struct
,
_
,
declaration
,
field
,
i
,
i18ns
,
len
,
name
,
result
,
structs_declaration
,
type
,
typedefs
;
var
Struct
,
_
,
declaration
,
field
,
i
,
i18ns
,
len
,
loadJSON
,
name
,
result
,
structs_declaration
,
type
,
typedefs
;
_
=
require
(
'
underscore
'
);
...
...
@@ -10,15 +10,17 @@
Struct
=
require
(
'
./struct.js
'
).
Struct
;
i18ns
=
require
(
'
./data/i18n.json
'
)
;
loadJSON
=
require
(
'
load-json-file
'
).
sync
;
structs_declaration
=
require
(
'
./data/structs
.json
'
);
i18ns
=
loadJSON
(
'
./data/i18n
.json
'
);
typedefs
=
require
(
'
./data/typedef
s.json
'
);
structs_declaration
=
loadJSON
(
'
./data/struct
s.json
'
);
t
his
.
proto_structs
=
require
(
'
./data/proto_struct
s.json
'
);
t
ypedefs
=
loadJSON
(
'
./data/typedef
s.json
'
);
this
.
constants
=
require
(
'
./data/constants.json
'
);
this
.
proto_structs
=
loadJSON
(
'
./data/proto_structs.json
'
);
this
.
constants
=
loadJSON
(
'
./data/constants.json
'
);
this
.
structs
=
{};
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment