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
2edd956c
Commit
2edd956c
authored
Sep 07, 2015
by
mercury233
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add room name code
parent
bba69ea7
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
132 additions
and
9 deletions
+132
-9
config.sample.json
config.sample.json
+1
-1
room.coffee
room.coffee
+49
-2
room.js
room.js
+78
-2
ygopro-server.coffee
ygopro-server.coffee
+2
-2
ygopro-server.js
ygopro-server.js
+2
-2
No files found.
config.sample.json
View file @
2edd956c
...
...
@@ -8,7 +8,7 @@
"tips"
:
"http://mercury233.me/ygosrv233/tips.json"
,
"dialogues"
:
"http://mercury233.me/ygosrv233/dialogues.json"
,
"post_start_watching"
:
true
,
"
skip_empty_side"
:
true
,
"
TCG_banlist_id"
:
7
,
"http"
:
{
"port"
:
7922
,
"password"
:
"123456"
,
...
...
room.coffee
View file @
2edd956c
...
...
@@ -96,8 +96,55 @@ class Room
@
hostinfo
.
start_lp
=
parseInt
(
param
[
6
])
@
hostinfo
.
start_hand
=
parseInt
(
param
[
7
])
@
hostinfo
.
draw_count
=
parseInt
(
param
[
8
])
param
=
[
0
,
@
hostinfo
.
lflist
,
@
hostinfo
.
rule
,
@
hostinfo
.
mode
,
(
if
@
hostinfo
.
enable_priority
then
'T'
else
'F'
),
(
if
@
hostinfo
.
no_check_deck
then
'T'
else
'F'
),
(
if
@
hostinfo
.
no_shuffle_deck
then
'T'
else
'F'
),
@
hostinfo
.
start_lp
,
@
hostinfo
.
start_hand
,
@
hostinfo
.
draw_count
]
else
if
(
param
=
name
.
match
/(.+)#/
)
rule
=
param
[
1
]
log
.
info
rule
if
(
rule
.
match
/(^|,|,)(M|MATCH)(,|,|$)/i
)
@
hostinfo
.
mode
=
1
if
(
rule
.
match
/(^|,|,)(T|TAG)(,|,|$)/i
)
@
hostinfo
.
mode
=
2
@
hostinfo
.
start_lp
=
16000
if
(
rule
.
match
/(^|,|,)(TCGONLY|TO)(,|,|$)/i
)
@
hostinfo
.
rule
=
1
@
hostinfo
.
lflist
=
settings
.
modules
.
TCG_banlist_id
if
(
rule
.
match
/(^|,|,)(OT|TCG)(,|,|$)/i
)
@
hostinfo
.
rule
=
2
if
(
param
=
rule
.
match
/(^|,|,)LP(\d+)(,|,|$)/i
)
start_lp
=
parseInt
(
param
[
2
])
if
(
start_lp
<=
0
)
then
start_lp
=
1
if
(
start_lp
>=
99999
)
then
start_lp
=
99999
@
hostinfo
.
start_lp
=
start_lp
if
(
param
=
rule
.
match
/(^|,|,)TIME(\d+)(,|,|$)/i
)
time_limit
=
parseInt
(
param
[
2
])
if
(
time_limit
<=
0
)
then
time_limit
=
180
if
(
time_limit
>=
1
and
time_limit
<=
60
)
then
time_limit
=
time_limit
*
60
if
(
time_limit
>=
999
)
then
time_limit
=
999
@
hostinfo
.
time_limit
=
time_limit
if
(
param
=
rule
.
match
/(^|,|,)START(\d+)(,|,|$)/i
)
start_hand
=
parseInt
(
param
[
2
])
if
(
start_hand
<=
0
)
then
start_hand
=
1
if
(
start_hand
>=
40
)
then
start_hand
=
40
@
hostinfo
.
start_hand
=
start_hand
if
(
param
=
rule
.
match
/(^|,|,)DRAW(\d+)(,|,|$)/i
)
draw_count
=
parseInt
(
param
[
2
])
if
(
draw_count
>=
35
)
then
draw_count
=
35
@
hostinfo
.
draw_count
=
draw_count
if
(
param
=
rule
.
match
/(^|,|,)LFLIST(\d+)(,|,|$)/i
)
lflist
=
parseInt
(
param
[
2
])
-
1
@
hostinfo
.
lflist
=
lflist
if
(
param
=
rule
.
match
/(^|,|,)NOLFLIST(,|,|$)/i
)
@
hostinfo
.
lflist
=
-
1
if
(
param
=
rule
.
match
/(^|,|,)NOUNIQUE(,|,|$)/i
)
@
hostinfo
.
rule
=
3
if
(
param
=
rule
.
match
/(^|,|,)NOCHECK(,|,|$)/i
)
@
hostinfo
.
no_check_deck
=
"T"
if
(
param
=
rule
.
match
/(^|,|,)NOSHUFFLE(,|,|$)/i
)
@
hostinfo
.
no_shuffle_deck
=
"T"
if
(
param
=
rule
.
match
/(^|,|,)IGPRIORITY(,|,|$)/i
)
@
hostinfo
.
enable_priority
=
"T"
param
=
[
0
,
@
hostinfo
.
lflist
,
@
hostinfo
.
rule
,
@
hostinfo
.
mode
,
(
if
@
hostinfo
.
enable_priority
then
'T'
else
'F'
),
(
if
@
hostinfo
.
no_check_deck
then
'T'
else
'F'
),
(
if
@
hostinfo
.
no_shuffle_deck
then
'T'
else
'F'
),
@
hostinfo
.
start_lp
,
@
hostinfo
.
start_hand
,
@
hostinfo
.
draw_count
,
@
hostinfo
.
time_limit
]
@
process
=
spawn
'./ygopro'
,
param
,
cwd
:
'ygocore'
@
process
.
on
'exit'
,
(
code
)
=>
...
...
room.js
View file @
2edd956c
...
...
@@ -79,7 +79,7 @@
};
function
Room
(
name
)
{
var
param
;
var
draw_count
,
lflist
,
param
,
rule
,
start_hand
,
start_lp
,
time_limit
;
this
.
name
=
name
;
this
.
alive
=
true
;
this
.
players
=
[];
...
...
@@ -114,8 +114,84 @@
this
.
hostinfo
.
start_lp
=
parseInt
(
param
[
6
]);
this
.
hostinfo
.
start_hand
=
parseInt
(
param
[
7
]);
this
.
hostinfo
.
draw_count
=
parseInt
(
param
[
8
]);
}
else
if
((
param
=
name
.
match
(
/
(
.+
)
#/
)))
{
rule
=
param
[
1
];
log
.
info
(
rule
);
if
(
rule
.
match
(
/
(
^|,|,
)(
M|MATCH
)(
,|,|$
)
/i
))
{
this
.
hostinfo
.
mode
=
1
;
}
if
(
rule
.
match
(
/
(
^|,|,
)(
T|TAG
)(
,|,|$
)
/i
))
{
this
.
hostinfo
.
mode
=
2
;
this
.
hostinfo
.
start_lp
=
16000
;
}
if
(
rule
.
match
(
/
(
^|,|,
)(
TCGONLY|TO
)(
,|,|$
)
/i
))
{
this
.
hostinfo
.
rule
=
1
;
this
.
hostinfo
.
lflist
=
settings
.
modules
.
TCG_banlist_id
;
}
if
(
rule
.
match
(
/
(
^|,|,
)(
OT|TCG
)(
,|,|$
)
/i
))
{
this
.
hostinfo
.
rule
=
2
;
}
if
((
param
=
rule
.
match
(
/
(
^|,|,
)
LP
(\d
+
)(
,|,|$
)
/i
)))
{
start_lp
=
parseInt
(
param
[
2
]);
if
(
start_lp
<=
0
)
{
start_lp
=
1
;
}
if
(
start_lp
>=
99999
)
{
start_lp
=
99999
;
}
this
.
hostinfo
.
start_lp
=
start_lp
;
}
if
((
param
=
rule
.
match
(
/
(
^|,|,
)
TIME
(\d
+
)(
,|,|$
)
/i
)))
{
time_limit
=
parseInt
(
param
[
2
]);
if
(
time_limit
<=
0
)
{
time_limit
=
180
;
}
if
(
time_limit
>=
1
&&
time_limit
<=
60
)
{
time_limit
=
time_limit
*
60
;
}
if
(
time_limit
>=
999
)
{
time_limit
=
999
;
}
this
.
hostinfo
.
time_limit
=
time_limit
;
}
if
((
param
=
rule
.
match
(
/
(
^|,|,
)
START
(\d
+
)(
,|,|$
)
/i
)))
{
start_hand
=
parseInt
(
param
[
2
]);
if
(
start_hand
<=
0
)
{
start_hand
=
1
;
}
if
(
start_hand
>=
40
)
{
start_hand
=
40
;
}
this
.
hostinfo
.
start_hand
=
start_hand
;
}
if
((
param
=
rule
.
match
(
/
(
^|,|,
)
DRAW
(\d
+
)(
,|,|$
)
/i
)))
{
draw_count
=
parseInt
(
param
[
2
]);
if
(
draw_count
>=
35
)
{
draw_count
=
35
;
}
this
.
hostinfo
.
draw_count
=
draw_count
;
}
if
((
param
=
rule
.
match
(
/
(
^|,|,
)
LFLIST
(\d
+
)(
,|,|$
)
/i
)))
{
lflist
=
parseInt
(
param
[
2
])
-
1
;
this
.
hostinfo
.
lflist
=
lflist
;
}
if
((
param
=
rule
.
match
(
/
(
^|,|,
)
NOLFLIST
(
,|,|$
)
/i
)))
{
this
.
hostinfo
.
lflist
=
-
1
;
}
if
((
param
=
rule
.
match
(
/
(
^|,|,
)
NOUNIQUE
(
,|,|$
)
/i
)))
{
this
.
hostinfo
.
rule
=
3
;
}
if
((
param
=
rule
.
match
(
/
(
^|,|,
)
NOCHECK
(
,|,|$
)
/i
)))
{
this
.
hostinfo
.
no_check_deck
=
"
T
"
;
}
if
((
param
=
rule
.
match
(
/
(
^|,|,
)
NOSHUFFLE
(
,|,|$
)
/i
)))
{
this
.
hostinfo
.
no_shuffle_deck
=
"
T
"
;
}
if
((
param
=
rule
.
match
(
/
(
^|,|,
)
IGPRIORITY
(
,|,|$
)
/i
)))
{
this
.
hostinfo
.
enable_priority
=
"
T
"
;
}
}
param
=
[
0
,
this
.
hostinfo
.
lflist
,
this
.
hostinfo
.
rule
,
this
.
hostinfo
.
mode
,
(
this
.
hostinfo
.
enable_priority
?
'
T
'
:
'
F
'
),
(
this
.
hostinfo
.
no_check_deck
?
'
T
'
:
'
F
'
),
(
this
.
hostinfo
.
no_shuffle_deck
?
'
T
'
:
'
F
'
),
this
.
hostinfo
.
start_lp
,
this
.
hostinfo
.
start_hand
,
this
.
hostinfo
.
draw_count
];
param
=
[
0
,
this
.
hostinfo
.
lflist
,
this
.
hostinfo
.
rule
,
this
.
hostinfo
.
mode
,
(
this
.
hostinfo
.
enable_priority
?
'
T
'
:
'
F
'
),
(
this
.
hostinfo
.
no_check_deck
?
'
T
'
:
'
F
'
),
(
this
.
hostinfo
.
no_shuffle_deck
?
'
T
'
:
'
F
'
),
this
.
hostinfo
.
start_lp
,
this
.
hostinfo
.
start_hand
,
this
.
hostinfo
.
draw_count
,
this
.
hostinfo
.
time_limit
];
this
.
process
=
spawn
(
'
./ygopro
'
,
param
,
{
cwd
:
'
ygocore
'
});
...
...
ygopro-server.coffee
View file @
2edd956c
...
...
@@ -507,12 +507,12 @@ if settings.modules.http
else
if
u
.
query
.
pass
==
settings
.
modules
.
http
.
password
&&
u
.
query
.
stop
settings
.
modules
.
stop
=
u
.
query
.
stop
response
.
writeHead
(
200
)
response
.
end
(
"stop "
+
u
.
query
.
s
hout
+
" ok"
)
response
.
end
(
"stop "
+
u
.
query
.
s
top
+
" ok"
)
else
if
u
.
query
.
pass
==
settings
.
modules
.
http
.
password
&&
u
.
query
.
welcome
settings
.
modules
.
welcome
=
u
.
query
.
welcome
response
.
writeHead
(
200
)
response
.
end
(
"welcome "
+
u
.
query
.
s
hout
+
" ok"
)
response
.
end
(
"welcome "
+
u
.
query
.
s
top
+
" ok"
)
else
response
.
writeHead
(
404
);
...
...
ygopro-server.js
View file @
2edd956c
...
...
@@ -632,11 +632,11 @@
}
else
if
(
u
.
query
.
pass
===
settings
.
modules
.
http
.
password
&&
u
.
query
.
stop
)
{
settings
.
modules
.
stop
=
u
.
query
.
stop
;
response
.
writeHead
(
200
);
response
.
end
(
"
stop
"
+
u
.
query
.
s
hout
+
"
ok
"
);
response
.
end
(
"
stop
"
+
u
.
query
.
s
top
+
"
ok
"
);
}
else
if
(
u
.
query
.
pass
===
settings
.
modules
.
http
.
password
&&
u
.
query
.
welcome
)
{
settings
.
modules
.
welcome
=
u
.
query
.
welcome
;
response
.
writeHead
(
200
);
response
.
end
(
"
welcome
"
+
u
.
query
.
s
hout
+
"
ok
"
);
response
.
end
(
"
welcome
"
+
u
.
query
.
s
top
+
"
ok
"
);
}
else
{
response
.
writeHead
(
404
);
response
.
end
();
...
...
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