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
c1bdbbf5
Commit
c1bdbbf5
authored
Nov 16, 2017
by
nanahira
Committed by
GitHub
Nov 16, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2 from moecube/master
mg
parents
d62cd152
0d5b65e0
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
188 additions
and
46 deletions
+188
-46
i18n.json
i18n.json
+5
-2
ygopro-server.coffee
ygopro-server.coffee
+72
-16
ygopro-server.js
ygopro-server.js
+111
-28
No files found.
i18n.json
View file @
c1bdbbf5
...
...
@@ -146,12 +146,14 @@
"exp_value_part1"
:
",你有"
,
"exp_value_part2"
:
"点经验"
,
"exp_value_part3"
:
",你的战斗力是"
,
"exp_value_part4"
:
"。
正式上线前这些积分可能被重置
"
,
"exp_value_part4"
:
"。
竞技场部分积分按赛季重置。
"
,
"lp_low_opponent"
:
"你的生命已经如风中残烛了!"
,
"lp_low_self"
:
"背水一战!"
,
"kicked_by_player"
:
"被请出了房间"
,
"kicked_by_system"
:
"被系统请出了房间"
,
"kick_count_down"
:
"秒后房主若不开始游戏将被请出房间"
,
"kick_count_down_arena_part1"
:
"秒后"
,
"kick_count_down_arena_part2"
:
"若不准备或开始游戏将视为投降"
,
"chat_order_main"
:
"Mycard YGOPro Server 指令帮助"
,
"chat_order_help"
:
"/help 显示这个帮助信息"
,
"chat_order_roomname"
:
"/roomname 显示当前房间的名字"
,
...
...
@@ -179,7 +181,8 @@
"unwelcome_warn_part1"
:
"如果您经常"
,
"unwelcome_warn_part2"
:
",您的对手可能会离你而去。"
,
"unwelcome_tip_part1"
:
"因为您的对手有"
,
"unwelcome_tip_part2"
:
"行为,现在您可以直接离开游戏或投降,不视为强退。"
"unwelcome_tip_part2"
:
"行为,现在您可以直接离开游戏或投降,不视为强退。"
,
"athletic_arena_tip"
:
"在竞技匹配中,比赛开始前退出游戏也会视为投降。"
},
"ko-kr"
:
{
"random_duel_enter_room_waiting"
:
"땅콩: 게임을 진행하게 준비 또는 시작을 하십시오."
,
...
...
ygopro-server.coffee
View file @
c1bdbbf5
...
...
@@ -448,13 +448,15 @@ class Room
delete
:
->
return
if
@
deleted
#log.info 'room-delete', this.name, ROOM_all.length
if
@
started
and
settings
.
modules
.
arena_mode
.
enabled
and
@
arena
#log.info @scores
score_array
=
[]
for
name
,
score
of
@
scores
score_array
.
push
{
name
:
name
,
score
:
score
}
score_array
=
[]
for
name
,
score
of
@
scores
score_array
.
push
{
name
:
name
,
score
:
score
}
if
score_array
.
length
>
0
and
settings
.
modules
.
arena_mode
.
enabled
and
@
arena
#log.info 'SCORE', score_array, @start_time
if
score_array
.
length
==
2
end_time
=
moment
().
format
()
if
!
@
start_time
@
start_time
=
end_time
request
.
post
{
url
:
settings
.
modules
.
arena_mode
.
post_score
,
form
:
{
accesskey
:
settings
.
modules
.
arena_mode
.
accesskey
,
usernameA
:
score_array
[
0
].
name
,
...
...
@@ -462,7 +464,7 @@ class Room
userscoreA
:
score_array
[
0
].
score
,
userscoreB
:
score_array
[
1
].
score
,
start
:
@
start_time
,
end
:
moment
().
format
()
,
end
:
end_time
,
arena
:
@
arena
}},
(
error
,
response
,
body
)
=>
if
error
...
...
@@ -575,9 +577,13 @@ class Room
@
watchers
.
splice
(
index
,
1
)
unless
index
==
-
1
#client.room = null
else
#log.info(client.name, @started, @disconnector, @random_type, @players.length)
if
@
arena
==
"athletic"
and
!
@
started
and
@
players
.
length
==
2
for
player
in
@
players
when
player
.
pos
!=
7
@
scores
[
player
.
name
]
=
0
@
scores
[
client
.
name
]
=
-
9
index
=
_
.
indexOf
(
@
players
,
client
)
@
players
.
splice
(
index
,
1
)
unless
index
==
-
1
#log.info(@started,@disconnector,@random_type)
if
@
started
and
@
disconnector
!=
'server'
and
(
client
.
pos
<
4
or
client
.
is_host
)
@
finished
=
true
@
scores
[
client
.
name
]
=
-
9
...
...
@@ -991,6 +997,9 @@ ygopro.ctos_follow 'JOIN_GAME', false, (buffer, info, client, server)->
room
=
ROOM_find_or_create_by_name
(
'M#'
+
info
.
pass
.
slice
(
8
))
room
.
private
=
true
room
.
arena
=
settings
.
modules
.
arena_mode
.
mode
if
room
.
arena
==
"athletic"
room
.
max_player
=
2
room
.
welcome
=
"${athletic_arena_tip}"
when
5
title
=
info
.
pass
.
slice
(
8
).
replace
(
String
.
fromCharCode
(
0xFEFF
),
' '
)
room
=
ROOM_find_by_title
(
title
)
...
...
@@ -1304,6 +1313,10 @@ ygopro.ctos_follow 'HS_KICK', true, (buffer, info, client, server)->
return
unless
room
for
player
in
room
.
players
if
player
and
player
.
pos
==
info
.
pos
and
player
!=
client
if
room
.
arena
==
"athletic"
ygopro
.
stoc_send_chat_to_room
(
room
,
"
#{
client
.
name
}
${kicked_by_system}"
,
ygopro
.
constants
.
COLORS
.
RED
)
client
.
destroy
()
return
true
client
.
kick_count
=
if
client
.
kick_count
then
client
.
kick_count
+
1
else
1
if
client
.
kick_count
>=
5
and
room
.
random_type
ygopro
.
stoc_send_chat_to_room
(
room
,
"
#{
client
.
name
}
${kicked_by_system}"
,
ygopro
.
constants
.
COLORS
.
RED
)
...
...
@@ -1327,15 +1340,44 @@ ygopro.stoc_follow 'HS_PLAYER_CHANGE', false, (buffer, info, client, server)->
pos
=
info
.
status
>>
4
is_ready
=
(
info
.
status
&
0xf
)
==
9
if
pos
<
room
.
max_player
room
.
ready_player_count_without_host
=
0
for
player
in
room
.
players
if
player
.
pos
==
pos
player
.
is_ready
=
is_ready
unless
player
.
is_host
room
.
ready_player_count_without_host
+=
player
.
is_ready
if
room
.
ready_player_count_without_host
>=
room
.
max_player
-
1
#log.info "all ready"
setTimeout
(()
->
wait_room_start
(
ROOM_all
[
client
.
rid
],
20
);
return
),
1000
if
room
.
arena
room
.
ready_player_count
=
0
for
player
in
room
.
players
if
player
.
pos
==
pos
player
.
is_ready
=
is_ready
p1
=
room
.
players
[
0
]
p2
=
room
.
players
[
1
]
if
!
p1
or
!
p2
if
room
.
waiting_for_player_interval
clearInterval
room
.
waiting_for_player_interval
room
.
waiting_for_player_interval
=
null
return
room
.
waiting_for_player2
=
room
.
waiting_for_player
room
.
waiting_for_player
=
null
if
p1
.
is_ready
and
p2
.
is_ready
room
.
waiting_for_player
=
if
p1
.
is_host
then
p1
else
p2
if
!
p1
.
is_ready
and
p2
.
is_ready
room
.
waiting_for_player
=
p1
if
!
p2
.
is_ready
and
p1
.
is_ready
room
.
waiting_for_player
=
p2
if
room
.
waiting_for_player
!=
room
.
waiting_for_player2
room
.
waiting_for_player2
=
room
.
waiting_for_player
room
.
waiting_for_player_time
=
20
room
.
waiting_for_player_interval
=
setInterval
(()
->
wait_room_start_arena
(
ROOM_all
[
client
.
rid
]);
return
),
1000
else
if
!
room
.
waiting_for_player
and
room
.
waiting_for_player_interval
clearInterval
room
.
waiting_for_player_interval
room
.
waiting_for_player_interval
=
null
room
.
waiting_for_player_time
=
20
else
room
.
ready_player_count_without_host
=
0
for
player
in
room
.
players
if
player
.
pos
==
pos
player
.
is_ready
=
is_ready
unless
player
.
is_host
room
.
ready_player_count_without_host
+=
player
.
is_ready
if
room
.
ready_player_count_without_host
>=
room
.
max_player
-
1
#log.info "all ready"
setTimeout
(()
->
wait_room_start
(
ROOM_all
[
client
.
rid
],
20
);
return
),
1000
return
wait_room_start
=
(
room
,
time
)
->
...
...
@@ -1353,6 +1395,20 @@ wait_room_start = (room, time)->
player
.
destroy
()
return
wait_room_start_arena
=
(
room
)
->
unless
!
room
or
room
.
started
or
!
room
.
waiting_for_player
room
.
waiting_for_player_time
=
room
.
waiting_for_player_time
-
1
if
room
.
waiting_for_player_time
>
0
unless
room
.
waiting_for_player_time
%
5
ygopro
.
stoc_send_chat_to_room
(
room
,
"
#{
if
room
.
waiting_for_player_time
<=
9
then
' '
else
''
}#{
room
.
waiting_for_player_time
}
${kick_count_down_arena_part1}
#{
room
.
waiting_for_player
.
name
}
${kick_count_down_arena_part2}"
,
if
room
.
waiting_for_player_time
<=
9
then
ygopro
.
constants
.
COLORS
.
RED
else
ygopro
.
constants
.
COLORS
.
LIGHTBLUE
)
else
ygopro
.
stoc_send_chat_to_room
(
room
,
"
#{
room
.
waiting_for_player
.
name
}
${kicked_by_system}"
,
ygopro
.
constants
.
COLORS
.
RED
)
room
.
waiting_for_player
.
destroy
()
if
room
.
waiting_for_player_interval
clearInterval
room
.
waiting_for_player_interval
room
.
waiting_for_player_interval
=
null
return
#tip
ygopro
.
stoc_send_random_tip
=
(
client
)
->
if
settings
.
modules
.
tips
.
enabled
&&
settings
.
tips
.
length
...
...
ygopro-server.js
View file @
c1bdbbf5
// Generated by CoffeeScript 1.12.2
(
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
,
ban_user
,
bunyan
,
cppversion
,
crypto
,
date
,
defaultconfig
,
execFile
,
fs
,
geoip
,
get_memory_usage
,
http
,
http_server
,
https
,
https_server
,
list
,
load_dialogues
,
load_tips
,
log
,
moment
,
nconf
,
net
,
options
,
os
,
path
,
pgClient
,
pg_client
,
pg_query
,
redis
,
redisdb
,
report_to_big_brother
,
request
,
requestListener
,
roomlist
,
settings
,
spawn
,
spawnSync
,
url
,
users_cache
,
wait_room_start
,
windbot_bin
,
windbot_parameters
,
windbot_process
,
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
,
ban_user
,
bunyan
,
cppversion
,
crypto
,
date
,
defaultconfig
,
execFile
,
fs
,
geoip
,
get_memory_usage
,
http
,
http_server
,
https
,
https_server
,
list
,
load_dialogues
,
load_tips
,
log
,
moment
,
nconf
,
net
,
options
,
os
,
path
,
pgClient
,
pg_client
,
pg_query
,
redis
,
redisdb
,
report_to_big_brother
,
request
,
requestListener
,
roomlist
,
settings
,
spawn
,
spawnSync
,
url
,
users_cache
,
wait_room_start
,
w
ait_room_start_arena
,
w
indbot_bin
,
windbot_parameters
,
windbot_process
,
ygopro
,
zlib
;
net
=
require
(
'
net
'
);
...
...
@@ -605,21 +605,25 @@
}
Room
.
prototype
[
"
delete
"
]
=
function
()
{
var
index
,
log_rep_id
,
name
,
player_ips
,
player_names
,
recorder_buffer
,
ref
,
replay_id
,
score
,
score_array
;
var
end_time
,
index
,
log_rep_id
,
name
,
player_ips
,
player_names
,
recorder_buffer
,
ref
,
replay_id
,
score
,
score_array
;
if
(
this
.
deleted
)
{
return
;
}
if
(
this
.
started
&&
settings
.
modules
.
arena_mode
.
enabled
&&
this
.
arena
)
{
score_array
=
[]
;
ref
=
this
.
scores
;
for
(
name
in
ref
)
{
score
=
ref
[
name
];
score_array
.
push
({
name
:
name
,
score
:
score
});
}
score_array
=
[];
ref
=
this
.
scores
;
for
(
name
in
ref
)
{
score
=
ref
[
name
];
score_array
.
push
({
name
:
name
,
score
:
score
});
}
if
(
score_array
.
length
>
0
&&
settings
.
modules
.
arena_mode
.
enabled
&&
this
.
arena
)
{
if
(
score_array
.
length
===
2
)
{
end_time
=
moment
().
format
();
if
(
!
this
.
start_time
)
{
this
.
start_time
=
end_time
;
}
request
.
post
({
url
:
settings
.
modules
.
arena_mode
.
post_score
,
form
:
{
...
...
@@ -629,7 +633,7 @@
userscoreA
:
score_array
[
0
].
score
,
userscoreB
:
score_array
[
1
].
score
,
start
:
this
.
start_time
,
end
:
moment
().
format
()
,
end
:
end_time
,
arena
:
this
.
arena
}
},
(
function
(
_this
)
{
...
...
@@ -763,7 +767,7 @@
};
Room
.
prototype
.
disconnect
=
function
(
client
,
error
)
{
var
index
;
var
index
,
j
,
len
,
player
,
ref
;
if
(
client
.
is_post_watcher
)
{
ygopro
.
stoc_send_chat_to_room
(
this
,
(
client
.
name
+
"
${quit_watch}
"
)
+
(
error
?
"
:
"
+
error
:
''
));
index
=
_
.
indexOf
(
this
.
watchers
,
client
);
...
...
@@ -771,6 +775,16 @@
this
.
watchers
.
splice
(
index
,
1
);
}
}
else
{
if
(
this
.
arena
===
"
athletic
"
&&
!
this
.
started
&&
this
.
players
.
length
===
2
)
{
ref
=
this
.
players
;
for
(
j
=
0
,
len
=
ref
.
length
;
j
<
len
;
j
++
)
{
player
=
ref
[
j
];
if
(
player
.
pos
!==
7
)
{
this
.
scores
[
player
.
name
]
=
0
;
}
}
this
.
scores
[
client
.
name
]
=
-
9
;
}
index
=
_
.
indexOf
(
this
.
players
,
client
);
if
(
index
!==
-
1
)
{
this
.
players
.
splice
(
index
,
1
);
...
...
@@ -1213,6 +1227,10 @@
room
=
ROOM_find_or_create_by_name
(
'
M#
'
+
info
.
pass
.
slice
(
8
));
room
[
"
private
"
]
=
true
;
room
.
arena
=
settings
.
modules
.
arena_mode
.
mode
;
if
(
room
.
arena
===
"
athletic
"
)
{
room
.
max_player
=
2
;
room
.
welcome
=
"
${athletic_arena_tip}
"
;
}
break
;
case
5
:
title
=
info
.
pass
.
slice
(
8
).
replace
(
String
.
fromCharCode
(
0xFEFF
),
'
'
);
...
...
@@ -1559,6 +1577,11 @@
for
(
j
=
0
,
len
=
ref
.
length
;
j
<
len
;
j
++
)
{
player
=
ref
[
j
];
if
(
player
&&
player
.
pos
===
info
.
pos
&&
player
!==
client
)
{
if
(
room
.
arena
===
"
athletic
"
)
{
ygopro
.
stoc_send_chat_to_room
(
room
,
client
.
name
+
"
${kicked_by_system}
"
,
ygopro
.
constants
.
COLORS
.
RED
);
client
.
destroy
();
return
true
;
}
client
.
kick_count
=
client
.
kick_count
?
client
.
kick_count
+
1
:
1
;
if
(
client
.
kick_count
>=
5
&&
room
.
random_type
)
{
ygopro
.
stoc_send_chat_to_room
(
room
,
client
.
name
+
"
${kicked_by_system}
"
,
ygopro
.
constants
.
COLORS
.
RED
);
...
...
@@ -1581,7 +1604,7 @@
});
ygopro
.
stoc_follow
(
'
HS_PLAYER_CHANGE
'
,
false
,
function
(
buffer
,
info
,
client
,
server
)
{
var
is_ready
,
j
,
len
,
player
,
pos
,
ref
,
room
;
var
is_ready
,
j
,
k
,
len
,
len1
,
p1
,
p2
,
player
,
pos
,
ref
,
ref1
,
room
;
room
=
ROOM_all
[
client
.
rid
];
if
(
!
(
room
&&
room
.
max_player
&&
client
.
is_host
))
{
return
;
...
...
@@ -1589,21 +1612,63 @@
pos
=
info
.
status
>>
4
;
is_ready
=
(
info
.
status
&
0xf
)
===
9
;
if
(
pos
<
room
.
max_player
)
{
room
.
ready_player_count_without_host
=
0
;
ref
=
room
.
players
;
for
(
j
=
0
,
len
=
ref
.
length
;
j
<
len
;
j
++
)
{
player
=
ref
[
j
];
if
(
player
.
pos
===
pos
)
{
player
.
is_ready
=
is_ready
;
if
(
room
.
arena
)
{
room
.
ready_player_count
=
0
;
ref
=
room
.
players
;
for
(
j
=
0
,
len
=
ref
.
length
;
j
<
len
;
j
++
)
{
player
=
ref
[
j
];
if
(
player
.
pos
===
pos
)
{
player
.
is_ready
=
is_ready
;
}
}
if
(
!
player
.
is_host
)
{
room
.
ready_player_count_without_host
+=
player
.
is_ready
;
p1
=
room
.
players
[
0
];
p2
=
room
.
players
[
1
];
if
(
!
p1
||
!
p2
)
{
if
(
room
.
waiting_for_player_interval
)
{
clearInterval
(
room
.
waiting_for_player_interval
);
room
.
waiting_for_player_interval
=
null
;
}
return
;
}
room
.
waiting_for_player2
=
room
.
waiting_for_player
;
room
.
waiting_for_player
=
null
;
if
(
p1
.
is_ready
&&
p2
.
is_ready
)
{
room
.
waiting_for_player
=
p1
.
is_host
?
p1
:
p2
;
}
if
(
!
p1
.
is_ready
&&
p2
.
is_ready
)
{
room
.
waiting_for_player
=
p1
;
}
if
(
!
p2
.
is_ready
&&
p1
.
is_ready
)
{
room
.
waiting_for_player
=
p2
;
}
if
(
room
.
waiting_for_player
!==
room
.
waiting_for_player2
)
{
room
.
waiting_for_player2
=
room
.
waiting_for_player
;
room
.
waiting_for_player_time
=
20
;
room
.
waiting_for_player_interval
=
setInterval
((
function
()
{
wait_room_start_arena
(
ROOM_all
[
client
.
rid
]);
}),
1000
);
}
else
if
(
!
room
.
waiting_for_player
&&
room
.
waiting_for_player_interval
)
{
clearInterval
(
room
.
waiting_for_player_interval
);
room
.
waiting_for_player_interval
=
null
;
room
.
waiting_for_player_time
=
20
;
}
}
else
{
room
.
ready_player_count_without_host
=
0
;
ref1
=
room
.
players
;
for
(
k
=
0
,
len1
=
ref1
.
length
;
k
<
len1
;
k
++
)
{
player
=
ref1
[
k
];
if
(
player
.
pos
===
pos
)
{
player
.
is_ready
=
is_ready
;
}
if
(
!
player
.
is_host
)
{
room
.
ready_player_count_without_host
+=
player
.
is_ready
;
}
}
if
(
room
.
ready_player_count_without_host
>=
room
.
max_player
-
1
)
{
setTimeout
((
function
()
{
wait_room_start
(
ROOM_all
[
client
.
rid
],
20
);
}),
1000
);
}
}
if
(
room
.
ready_player_count_without_host
>=
room
.
max_player
-
1
)
{
setTimeout
((
function
()
{
wait_room_start
(
ROOM_all
[
client
.
rid
],
20
);
}),
1000
);
}
}
});
...
...
@@ -1633,6 +1698,24 @@
}
};
wait_room_start_arena
=
function
(
room
)
{
if
(
!
(
!
room
||
room
.
started
||
!
room
.
waiting_for_player
))
{
room
.
waiting_for_player_time
=
room
.
waiting_for_player_time
-
1
;
if
(
room
.
waiting_for_player_time
>
0
)
{
if
(
!
(
room
.
waiting_for_player_time
%
5
))
{
ygopro
.
stoc_send_chat_to_room
(
room
,
""
+
(
room
.
waiting_for_player_time
<=
9
?
'
'
:
''
)
+
room
.
waiting_for_player_time
+
"
${kick_count_down_arena_part1}
"
+
room
.
waiting_for_player
.
name
+
"
${kick_count_down_arena_part2}
"
,
room
.
waiting_for_player_time
<=
9
?
ygopro
.
constants
.
COLORS
.
RED
:
ygopro
.
constants
.
COLORS
.
LIGHTBLUE
);
}
}
else
{
ygopro
.
stoc_send_chat_to_room
(
room
,
room
.
waiting_for_player
.
name
+
"
${kicked_by_system}
"
,
ygopro
.
constants
.
COLORS
.
RED
);
room
.
waiting_for_player
.
destroy
();
if
(
room
.
waiting_for_player_interval
)
{
clearInterval
(
room
.
waiting_for_player_interval
);
room
.
waiting_for_player_interval
=
null
;
}
}
}
};
ygopro
.
stoc_send_random_tip
=
function
(
client
)
{
if
(
settings
.
modules
.
tips
.
enabled
&&
settings
.
tips
.
length
)
{
ygopro
.
stoc_send_chat
(
client
,
"
Tip:
"
+
settings
.
tips
[
Math
.
floor
(
Math
.
random
()
*
settings
.
tips
.
length
)]);
...
...
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