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
a125fbe9
Commit
a125fbe9
authored
Jun 12, 2018
by
nanahira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cleanup
parent
028bee34
Changes
6
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
107 additions
and
391 deletions
+107
-391
config_build/config.json
config_build/config.json
+0
-79
config_tourney/config.json
config_tourney/config.json
+0
-79
data/default_config.json
data/default_config.json
+0
-79
data/i18n.json
data/i18n.json
+0
-8
ygopro-server.coffee
ygopro-server.coffee
+73
-5
ygopro-server.js
ygopro-server.js
+34
-141
No files found.
config_build/config.json
View file @
a125fbe9
...
@@ -66,10 +66,6 @@
...
@@ -66,10 +66,6 @@
"enabled"
:
false
,
"enabled"
:
false
,
"get"
:
false
"get"
:
false
},
},
"music"
:
{
"enabled"
:
false
,
"dbpath"
:
"expansions/222DIY.cdb"
},
"random_duel"
:
{
"random_duel"
:
{
"enabled"
:
true
,
"enabled"
:
true
,
"no_rematch_check"
:
false
,
"no_rematch_check"
:
false
,
...
@@ -256,81 +252,6 @@
...
@@ -256,81 +252,6 @@
}
}
]
]
},
},
"command"
:
{
"enabled"
:
false
,
"identity"
:
{
"username1"
:
"password1"
,
"username1"
:
"password2"
},
"command_list"
:
{
"ygopro"
:
{
"command"
:
"git"
,
"args"
:
[
"pull"
,
"origin"
,
"master"
],
"path"
:
"./ygopro/"
},
"make"
:
{
"command"
:
"make"
,
"args"
:
[
"config=release"
],
"path"
:
"./ygopro/build/"
},
"srvpro"
:
{
"command"
:
"git"
,
"args"
:
[
"pull"
,
"origin"
,
"master"
],
"path"
:
"."
},
"windbot"
:
{
"command"
:
"git"
,
"args"
:
[
"pull"
,
"origin"
,
"master"
],
"path"
:
"./windbot/"
},
"buildbot"
:
{
"command"
:
"xbuild"
,
"args"
:
[
"/property:Configuration=Release"
],
"path"
:
"./windbot/"
},
"restartbot"
:
{
"command"
:
"pm2"
,
"args"
:
[
"restart"
,
"windbot-server"
],
"path"
:
"."
},
"restart"
:
{
"command"
:
"pm2"
,
"args"
:
[
"restart"
,
"ygopro-server"
],
"path"
:
"."
},
"script"
:
{
"command"
:
"git"
,
"args"
:
[
"pull"
,
"origin"
,
"master"
],
"path"
:
"./ygopro/script/"
}
}
},
"http"
:
{
"http"
:
{
"port"
:
7211
,
"port"
:
7211
,
"password"
:
"Nanahira"
,
"password"
:
"Nanahira"
,
...
...
config_tourney/config.json
View file @
a125fbe9
...
@@ -66,10 +66,6 @@
...
@@ -66,10 +66,6 @@
"enabled"
:
false
,
"enabled"
:
false
,
"get"
:
false
"get"
:
false
},
},
"music"
:
{
"enabled"
:
false
,
"dbpath"
:
"expansions/222DIY.cdb"
},
"random_duel"
:
{
"random_duel"
:
{
"enabled"
:
false
,
"enabled"
:
false
,
"no_rematch_check"
:
false
,
"no_rematch_check"
:
false
,
...
@@ -256,81 +252,6 @@
...
@@ -256,81 +252,6 @@
}
}
]
]
},
},
"command"
:
{
"enabled"
:
false
,
"identity"
:
{
"username1"
:
"password1"
,
"username1"
:
"password2"
},
"command_list"
:
{
"ygopro"
:
{
"command"
:
"git"
,
"args"
:
[
"pull"
,
"origin"
,
"master"
],
"path"
:
"./ygopro/"
},
"make"
:
{
"command"
:
"make"
,
"args"
:
[
"config=release"
],
"path"
:
"./ygopro/build/"
},
"srvpro"
:
{
"command"
:
"git"
,
"args"
:
[
"pull"
,
"origin"
,
"master"
],
"path"
:
"."
},
"windbot"
:
{
"command"
:
"git"
,
"args"
:
[
"pull"
,
"origin"
,
"master"
],
"path"
:
"./windbot/"
},
"buildbot"
:
{
"command"
:
"xbuild"
,
"args"
:
[
"/property:Configuration=Release"
],
"path"
:
"./windbot/"
},
"restartbot"
:
{
"command"
:
"pm2"
,
"args"
:
[
"restart"
,
"windbot-server"
],
"path"
:
"."
},
"restart"
:
{
"command"
:
"pm2"
,
"args"
:
[
"restart"
,
"ygopro-server"
],
"path"
:
"."
},
"script"
:
{
"command"
:
"git"
,
"args"
:
[
"pull"
,
"origin"
,
"master"
],
"path"
:
"./ygopro/script/"
}
}
},
"http"
:
{
"http"
:
{
"port"
:
1263
,
"port"
:
1263
,
"password"
:
"Nanahira"
,
"password"
:
"Nanahira"
,
...
...
data/default_config.json
View file @
a125fbe9
...
@@ -66,10 +66,6 @@
...
@@ -66,10 +66,6 @@
"enabled"
:
true
,
"enabled"
:
true
,
"get"
:
false
"get"
:
false
},
},
"music"
:
{
"enabled"
:
false
,
"dbpath"
:
"expansions/222DIY.cdb"
},
"random_duel"
:
{
"random_duel"
:
{
"enabled"
:
false
,
"enabled"
:
false
,
"no_rematch_check"
:
false
,
"no_rematch_check"
:
false
,
...
@@ -244,81 +240,6 @@
...
@@ -244,81 +240,6 @@
}
}
]
]
},
},
"command"
:
{
"enabled"
:
false
,
"identity"
:
{
"username1"
:
"password1"
,
"username1"
:
"password2"
},
"command_list"
:
{
"ygopro"
:
{
"command"
:
"git"
,
"args"
:
[
"pull"
,
"origin"
,
"master"
],
"path"
:
"./ygopro/"
},
"make"
:
{
"command"
:
"make"
,
"args"
:
[
"config=release"
],
"path"
:
"./ygopro/build/"
},
"srvpro"
:
{
"command"
:
"git"
,
"args"
:
[
"pull"
,
"origin"
,
"master"
],
"path"
:
"."
},
"windbot"
:
{
"command"
:
"git"
,
"args"
:
[
"pull"
,
"origin"
,
"master"
],
"path"
:
"./windbot/"
},
"buildbot"
:
{
"command"
:
"xbuild"
,
"args"
:
[
"/property:Configuration=Release"
],
"path"
:
"./windbot/"
},
"restartbot"
:
{
"command"
:
"pm2"
,
"args"
:
[
"restart"
,
"windbot-server"
],
"path"
:
"."
},
"restart"
:
{
"command"
:
"pm2"
,
"args"
:
[
"restart"
,
"ygopro-server"
],
"path"
:
"."
},
"script"
:
{
"command"
:
"git"
,
"args"
:
[
"pull"
,
"origin"
,
"master"
],
"path"
:
"./ygopro/script/"
}
}
},
"http"
:
{
"http"
:
{
"port"
:
7922
,
"port"
:
7922
,
"password"
:
"123456"
,
"password"
:
"123456"
,
...
...
data/i18n.json
View file @
a125fbe9
...
@@ -89,10 +89,6 @@
...
@@ -89,10 +89,6 @@
"surrender_confirm"
:
"Are you sure? Enter /surrender again to confirm."
,
"surrender_confirm"
:
"Are you sure? Enter /surrender again to confirm."
,
"surrender_canceled"
:
"Surrender canceled."
,
"surrender_canceled"
:
"Surrender canceled."
,
"surrender_denied"
:
"Please don't surrender in the first 2 turns."
,
"surrender_denied"
:
"Please don't surrender in the first 2 turns."
,
"play_music"
:
"Playing music: "
,
"stop_music"
:
"Music set back to default."
,
"music_not_found_1"
:
"Music "
,
"music_not_found_2"
:
" not found."
,
"unwelcome_warn_part1"
:
"If you keep doing "
,
"unwelcome_warn_part1"
:
"If you keep doing "
,
"unwelcome_warn_part2"
:
", your opponent may leave you."
,
"unwelcome_warn_part2"
:
", your opponent may leave you."
,
"unwelcome_tip_part1"
:
"Your oppenent did "
,
"unwelcome_tip_part1"
:
"Your oppenent did "
,
...
@@ -360,10 +356,6 @@
...
@@ -360,10 +356,6 @@
"surrender_confirm"
:
"确实要投降吗?再次输入 /投降 以确认。"
,
"surrender_confirm"
:
"确实要投降吗?再次输入 /投降 以确认。"
,
"surrender_canceled"
:
"已取消投降,加油!"
,
"surrender_canceled"
:
"已取消投降,加油!"
,
"surrender_denied"
:
"为保证双方玩家的游戏体验,随机对战中3回合后才能投降。"
,
"surrender_denied"
:
"为保证双方玩家的游戏体验,随机对战中3回合后才能投降。"
,
"play_music"
:
"正在播放:"
,
"stop_music"
:
"已切换为默认音乐。"
,
"music_not_found_1"
:
"无法找到音乐:"
,
"music_not_found_2"
:
"。"
,
"unwelcome_warn_part1"
:
"如果您经常"
,
"unwelcome_warn_part1"
:
"如果您经常"
,
"unwelcome_warn_part2"
:
",您的对手可能会离你而去。"
,
"unwelcome_warn_part2"
:
",您的对手可能会离你而去。"
,
"unwelcome_tip_part1"
:
"因为您的对手有"
,
"unwelcome_tip_part1"
:
"因为您的对手有"
,
...
...
ygopro-server.coffee
View file @
a125fbe9
...
@@ -58,10 +58,17 @@ try
...
@@ -58,10 +58,17 @@ try
oldtips
.
tips
=
oldconfig
.
tips
oldtips
.
tips
=
oldconfig
.
tips
fs
.
writeFileSync
(
oldtips
.
file
,
JSON
.
stringify
(
oldtips
,
null
,
2
))
fs
.
writeFileSync
(
oldtips
.
file
,
JSON
.
stringify
(
oldtips
,
null
,
2
))
delete
oldconfig
.
tips
delete
oldconfig
.
tips
if
oldconfig
.
words
oldtips
=
{}
oldtips
.
file
=
'./config/words.json'
oldtips
.
words
=
oldconfig
.
words
fs
.
writeFileSync
(
oldtips
.
file
,
JSON
.
stringify
(
oldtips
,
null
,
2
))
delete
oldconfig
.
words
if
oldconfig
.
dialogues
if
oldconfig
.
dialogues
olddialogues
=
{}
olddialogues
=
{}
olddialogues
.
file
=
'./config/dialogues.json'
olddialogues
.
file
=
'./config/dialogues.json'
olddialogues
.
dialogues
=
oldconfig
.
dialogues
olddialogues
.
dialogues
=
oldconfig
.
dialogues
olddialogues
.
dialogues_custom
=
{}
fs
.
writeFileSync
(
olddialogues
.
file
,
JSON
.
stringify
(
olddialogues
,
null
,
2
))
fs
.
writeFileSync
(
olddialogues
.
file
,
JSON
.
stringify
(
olddialogues
,
null
,
2
))
delete
oldconfig
.
dialogues
delete
oldconfig
.
dialogues
if
oldconfig
.
modules
if
oldconfig
.
modules
...
@@ -136,8 +143,16 @@ try
...
@@ -136,8 +143,16 @@ try
catch
catch
tips
=
default_data
.
tips
tips
=
default_data
.
tips
setting_save
(
tips
)
setting_save
(
tips
)
try
words
=
loadJSON
(
'./config/words.json'
)
catch
words
=
default_data
.
words
setting_save
(
words
)
try
try
dialogues
=
loadJSON
(
'./config/dialogues.json'
)
dialogues
=
loadJSON
(
'./config/dialogues.json'
)
if
!
dialogues
.
dialogues_custom
dialogues
.
dialogues_custom
=
{}
setting_save
(
dialogues
);
catch
catch
dialogues
=
default_data
.
dialogues
dialogues
=
default_data
.
dialogues
setting_save
(
dialogues
)
setting_save
(
dialogues
)
...
@@ -442,6 +457,8 @@ class Room
...
@@ -442,6 +457,8 @@ class Room
else
if
name
[
0
...
3
]
==
'AI#'
else
if
name
[
0
...
3
]
==
'AI#'
@
hostinfo
.
rule
=
2
@
hostinfo
.
rule
=
2
@
hostinfo
.
lflist
=
-
1
@
hostinfo
.
lflist
=
-
1
@
hostinfo
.
time_limit
=
0
@
hostinfo
.
no_check_deck
=
true
else
if
(
param
=
name
.
match
/^(\d)(\d)(T|F)(T|F)(T|F)(\d+),(\d+),(\d+)/i
)
else
if
(
param
=
name
.
match
/^(\d)(\d)(T|F)(T|F)(T|F)(\d+),(\d+),(\d+)/i
)
@
hostinfo
.
rule
=
parseInt
(
param
[
1
])
@
hostinfo
.
rule
=
parseInt
(
param
[
1
])
...
@@ -1266,6 +1283,9 @@ ygopro.stoc_follow 'JOIN_GAME', false, (buffer, info, client, server)->
...
@@ -1266,6 +1283,9 @@ ygopro.stoc_follow 'JOIN_GAME', false, (buffer, info, client, server)->
#欢迎信息
#欢迎信息
room
=
ROOM_all
[
client
.
rid
]
room
=
ROOM_all
[
client
.
rid
]
return
unless
room
return
unless
room
if
settings
.
modules
.
words
.
enabled
and
words
.
words
[
client
.
name
]
for
line
in
_
.
lines
words
.
words
[
client
.
name
][
Math
.
floor
(
Math
.
random
()
*
words
.
words
[
client
.
name
].
length
)]
ygopro
.
stoc_send_chat
(
client
,
line
,
ygopro
.
constants
.
COLORS
.
PINK
)
if
settings
.
modules
.
welcome
if
settings
.
modules
.
welcome
ygopro
.
stoc_send_chat
(
client
,
settings
.
modules
.
welcome
,
ygopro
.
constants
.
COLORS
.
GREEN
)
ygopro
.
stoc_send_chat
(
client
,
settings
.
modules
.
welcome
,
ygopro
.
constants
.
COLORS
.
GREEN
)
if
room
.
welcome
if
room
.
welcome
...
@@ -1333,6 +1353,24 @@ ygopro.stoc_follow 'JOIN_GAME', false, (buffer, info, client, server)->
...
@@ -1333,6 +1353,24 @@ ygopro.stoc_follow 'JOIN_GAME', false, (buffer, info, client, server)->
return
return
# 登场台词
# 登场台词
load_words
=
()
->
request
url
:
settings
.
modules
.
words
.
get
json
:
true
,
(
error
,
response
,
body
)
->
if
_
.
isString
body
log
.
warn
"words bad json"
,
body
else
if
error
or
!
body
log
.
warn
'words error'
,
error
,
response
else
setting_change
(
words
,
"words"
,
body
)
log
.
info
"words loaded"
,
_
.
size
words
.
words
return
return
if
settings
.
modules
.
words
.
get
load_words
()
load_dialogues
=
()
->
load_dialogues
=
()
->
request
request
url
:
settings
.
modules
.
dialogues
.
get
url
:
settings
.
modules
.
dialogues
.
get
...
@@ -1348,9 +1386,27 @@ load_dialogues = () ->
...
@@ -1348,9 +1386,27 @@ load_dialogues = () ->
return
return
return
return
load_dialogues_custom
=
()
->
request
url
:
settings
.
modules
.
dialogues
.
get_custom
json
:
true
,
(
error
,
response
,
body
)
->
if
_
.
isString
body
log
.
warn
"custom dialogues bad json"
,
body
else
if
error
or
!
body
log
.
warn
'custom dialogues error'
,
error
,
response
else
setting_change
(
dialogues
,
"dialogues_custom"
,
body
)
log
.
info
"custom dialogues loaded"
,
_
.
size
dialogues
.
dialogues_custom
return
return
if
settings
.
modules
.
dialogues
.
get
if
settings
.
modules
.
dialogues
.
get
load_dialogues
()
load_dialogues
()
if
settings
.
modules
.
dialogues
.
get_custom
load_dialogues_custom
()
ygopro
.
stoc_follow
'GAME_MSG'
,
true
,
(
buffer
,
info
,
client
,
server
)
->
ygopro
.
stoc_follow
'GAME_MSG'
,
true
,
(
buffer
,
info
,
client
,
server
)
->
room
=
ROOM_all
[
client
.
rid
]
room
=
ROOM_all
[
client
.
rid
]
return
unless
room
return
unless
room
...
@@ -1525,9 +1581,13 @@ ygopro.stoc_follow 'GAME_MSG', true, (buffer, info, client, server)->
...
@@ -1525,9 +1581,13 @@ ygopro.stoc_follow 'GAME_MSG', true, (buffer, info, client, server)->
if
ygopro
.
constants
.
MSG
[
msg
]
==
'SUMMONING'
or
ygopro
.
constants
.
MSG
[
msg
]
==
'SPSUMMONING'
or
ygopro
.
constants
.
MSG
[
msg
]
==
'CHAINING'
if
ygopro
.
constants
.
MSG
[
msg
]
==
'SUMMONING'
or
ygopro
.
constants
.
MSG
[
msg
]
==
'SPSUMMONING'
or
ygopro
.
constants
.
MSG
[
msg
]
==
'CHAINING'
card
=
buffer
.
readUInt32LE
(
1
)
card
=
buffer
.
readUInt32LE
(
1
)
trigger_location
=
buffer
.
readUInt8
(
6
)
trigger_location
=
buffer
.
readUInt8
(
6
)
if
dialogues
.
dialogues
[
card
]
and
(
ygopro
.
constants
.
MSG
[
msg
]
!=
'CHAINING'
or
(
trigger_location
&
0x8
)
and
!
(
trigger_location
&
0x200
))
if
ygopro
.
constants
.
MSG
[
msg
]
!=
'CHAINING'
or
(
trigger_location
&
0x8
)
and
!
(
trigger_location
&
0x200
)
for
line
in
_
.
lines
dialogues
.
dialogues
[
card
][
Math
.
floor
(
Math
.
random
()
*
dialogues
.
dialogues
[
card
].
length
)]
if
dialogues
.
dialogues
[
card
]
ygopro
.
stoc_send_chat
(
client
,
line
,
ygopro
.
constants
.
COLORS
.
PINK
)
for
line
in
_
.
lines
dialogues
.
dialogues
[
card
][
Math
.
floor
(
Math
.
random
()
*
dialogues
.
dialogues
[
card
].
length
)]
ygopro
.
stoc_send_chat
(
client
,
line
,
ygopro
.
constants
.
COLORS
.
PINK
)
else
if
dialogues
.
dialogues_custom
[
card
]
for
line
in
_
.
lines
dialogues
.
dialogues_custom
[
card
][
Math
.
floor
(
Math
.
random
()
*
dialogues
.
dialogues_custom
[
card
].
length
)]
ygopro
.
stoc_send_chat
(
client
,
line
,
ygopro
.
constants
.
COLORS
.
PINK
)
return
false
return
false
#房间管理
#房间管理
...
@@ -1670,6 +1730,7 @@ load_tips = ()->
...
@@ -1670,6 +1730,7 @@ load_tips = ()->
if
settings
.
modules
.
tips
.
get
if
settings
.
modules
.
tips
.
get
load_tips
()
load_tips
()
if
settings
.
modules
.
tips
.
enabled
setInterval
()
->
setInterval
()
->
for
room
in
ROOM_all
when
room
and
room
.
established
for
room
in
ROOM_all
when
room
and
room
.
established
ygopro
.
stoc_send_random_tip_to_room
(
room
)
if
!
room
.
started
or
room
.
changing_side
ygopro
.
stoc_send_random_tip_to_room
(
room
)
if
!
room
.
started
or
room
.
changing_side
...
@@ -1941,7 +2002,7 @@ ygopro.ctos_follow 'UPDATE_DECK', true, (buffer, info, client, server)->
...
@@ -1941,7 +2002,7 @@ ygopro.ctos_follow 'UPDATE_DECK', true, (buffer, info, client, server)->
if
client
.
pos
==
0
if
client
.
pos
==
0
room
.
waiting_for_player
=
room
.
waiting_for_player2
room
.
waiting_for_player
=
room
.
waiting_for_player2
room
.
last_active_time
=
moment
()
room
.
last_active_time
=
moment
()
else
if
!
room
.
started
and
room
.
hostinfo
.
mode
==
1
and
settings
.
modules
.
tournament_mode
.
enabled
and
settings
.
modules
.
tournament_mode
.
deck_check
and
fs
.
readdirSync
(
settings
.
modules
.
tournament_mode
.
deck_path
).
length
else
if
!
room
.
started
and
settings
.
modules
.
tournament_mode
.
enabled
and
settings
.
modules
.
tournament_mode
.
deck_check
and
fs
.
readdirSync
(
settings
.
modules
.
tournament_mode
.
deck_path
).
length
struct
=
ygopro
.
structs
[
"deck"
]
struct
=
ygopro
.
structs
[
"deck"
]
struct
.
_setBuff
(
buffer
)
struct
.
_setBuff
(
buffer
)
struct
.
set
(
"mainc"
,
1
)
struct
.
set
(
"mainc"
,
1
)
...
@@ -2329,8 +2390,15 @@ if settings.modules.http
...
@@ -2329,8 +2390,15 @@ if settings.modules.http
else
if
u
.
query
.
loaddialogues
else
if
u
.
query
.
loaddialogues
load_dialogues
()
load_dialogues
()
if
settings
.
modules
.
dialogues
.
get_custom
load_dialogues_custom
()
response
.
writeHead
(
200
)
response
.
end
(
addCallback
(
u
.
query
.
callback
,
"['loading dialogues', '"
+
settings
.
modules
.
dialogues
.
get
+
(
if
settings
.
modules
.
dialogues
.
get_custom
then
" and "
+
settings
.
modules
.
dialogues
.
get_custom
else
""
)
+
"']"
))
else
if
u
.
query
.
loadwords
load_words
()
response
.
writeHead
(
200
)
response
.
writeHead
(
200
)
response
.
end
(
addCallback
(
u
.
query
.
callback
,
"['loading
dialogues', '"
+
settings
.
modules
.
dialogue
s
.
get
+
"']"
))
response
.
end
(
addCallback
(
u
.
query
.
callback
,
"['loading
words', '"
+
settings
.
modules
.
word
s
.
get
+
"']"
))
else
if
u
.
query
.
ban
else
if
u
.
query
.
ban
ban_user
(
u
.
query
.
ban
)
ban_user
(
u
.
query
.
ban
)
...
...
ygopro-server.js
View file @
a125fbe9
This diff is collapsed.
Click to expand it.
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