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
1
Issues
1
List
Boards
Labels
Service Desk
Milestones
Merge Requests
3
Merge Requests
3
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
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
MyCard
srvpro
Commits
54b96fe5
Commit
54b96fe5
authored
9 years ago
by
mercury233
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update & fix
parent
c6b37a09
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
50 additions
and
31 deletions
+50
-31
config.json
config.json
+2
-0
room.coffee
room.coffee
+5
-5
room.js
room.js
+10
-8
roomlist.js
roomlist.js
+2
-2
ygopro-deck-stats.js
ygopro-deck-stats.js
+6
-4
ygopro-pre.js
ygopro-pre.js
+13
-1
ygopro-server.coffee
ygopro-server.coffee
+4
-3
ygopro-server.js
ygopro-server.js
+8
-8
No files found.
config.json
View file @
54b96fe5
...
...
@@ -8,6 +8,7 @@
"tips"
:
"http://mycard.moe/ygopro/tips.json"
,
"dialogues"
:
"http://mycard.moe/ygopro/dialogues.json"
,
"redis_port"
:
6379
,
"enable_websocket_roomlist"
:
true
,
"enable_random_duel"
:
false
,
"mycard_auth"
:
"https://ygobbs.com"
,
"post_start_watching"
:
true
,
...
...
@@ -17,6 +18,7 @@
"port"
:
7922
,
"password"
:
"123456"
,
"ssl"
:
{
"enabled"
:
true
,
"port"
:
7923
,
"cert"
:
"ssl/ygopro-server.crt"
,
"key"
:
"ssl/ygopro-server.key"
...
...
This diff is collapsed.
Click to expand it.
room.coffee
View file @
54b96fe5
...
...
@@ -4,7 +4,7 @@ _.mixin(_.str.exports());
spawn
=
require
(
'child_process'
).
spawn
spawnSync
=
require
(
'child_process'
).
spawnSync
ygopro
=
require
'./ygopro.js'
roomlist
=
require
'./roomlist'
roomlist
=
require
'./roomlist'
if
settings
.
modules
.
enable_websocket_roomlist
bunyan
=
require
'bunyan'
moment
=
require
'moment'
#redis = require 'redis'
...
...
@@ -309,7 +309,7 @@ class Room
@
process
.
stdout
.
setEncoding
(
'utf8'
)
@
process
.
stdout
.
once
'data'
,
(
data
)
=>
@
established
=
true
roomlist
.
create
(
this
)
if
!
@
private
roomlist
.
create
(
this
)
if
!
@
private
and
settings
.
modules
.
enable_websocket_roomlist
@
port
=
parseInt
data
_
.
each
@
players
,
(
player
)
=>
player
.
server
.
connect
@
port
,
'127.0.0.1'
,
=>
...
...
@@ -352,7 +352,7 @@ class Room
index
=
_
.
indexOf
(
Room
.
all
,
this
)
#Room.all[index] = null unless index == -1
Room
.
all
.
splice
(
index
,
1
)
unless
index
==
-
1
roomlist
.
delete
@
name
if
!
@
private
and
!
@
started
and
@
established
roomlist
.
delete
@
name
if
!
@
private
and
!
@
started
and
@
established
and
settings
.
modules
.
enable_websocket_roomlist
return
get_playing_player
:
->
...
...
@@ -383,7 +383,7 @@ class Room
Room
.
players_oppentlist
[
client
.
remoteAddress
]
=
null
if
@
established
roomlist
.
update
(
this
)
if
!
@
private
and
!
@
started
roomlist
.
update
(
this
)
if
!
@
private
and
!
@
started
and
settings
.
modules
.
enable_websocket_roomlist
client
.
server
.
connect
@
port
,
'127.0.0.1'
,
->
client
.
server
.
write
buffer
for
buffer
in
client
.
pre_establish_buffers
client
.
established
=
true
...
...
@@ -405,7 +405,7 @@ class Room
Room
.
ban_player
(
client
.
name
,
client
.
ip
,
"强退"
)
if
@
players
.
length
ygopro
.
stoc_send_chat_to_room
this
,
"
#{
client
.
name
}
#{
'离开了游戏'
}#{
if
error
then
":
#{
error
}
"
else
''
}
"
roomlist
.
update
(
this
)
if
!
@
private
and
!
@
started
roomlist
.
update
(
this
)
if
!
@
private
and
!
@
started
and
settings
.
modules
.
enable_websocket_roomlist
#client.room = null
else
@
process
.
kill
()
...
...
This diff is collapsed.
Click to expand it.
room.js
View file @
54b96fe5
// Generated by CoffeeScript 1.
9.3
// Generated by CoffeeScript 1.
10.0
(
function
()
{
var
Room
,
_
,
bunyan
,
get_memory_usage
,
log
,
moment
,
roomlist
,
settings
,
spawn
,
spawnSync
,
ygopro
;
...
...
@@ -14,7 +14,9 @@
ygopro
=
require
(
'
./ygopro.js
'
);
roomlist
=
require
(
'
./roomlist
'
);
if
(
settings
.
modules
.
enable_websocket_roomlist
)
{
roomlist
=
require
(
'
./roomlist
'
);
}
bunyan
=
require
(
'
bunyan
'
);
...
...
@@ -187,7 +189,7 @@
};
function
Room
(
name
,
hostinfo
)
{
var
draw_count
,
lflist
,
param
,
rule
,
start_hand
,
start_lp
,
time_limit
;
var
draw_count
,
error1
,
lflist
,
param
,
rule
,
start_hand
,
start_lp
,
time_limit
;
this
.
hostinfo
=
hostinfo
;
this
.
name
=
name
;
this
.
alive
=
true
;
...
...
@@ -394,7 +396,7 @@
this
.
process
.
stdout
.
once
(
'
data
'
,
(
function
(
_this
)
{
return
function
(
data
)
{
_this
.
established
=
true
;
if
(
!
_this
[
"
private
"
])
{
if
(
!
_this
[
"
private
"
]
&&
settings
.
modules
.
enable_websocket_roomlist
)
{
roomlist
.
create
(
_this
);
}
_this
.
port
=
parseInt
(
data
);
...
...
@@ -412,7 +414,7 @@
});
};
})(
this
));
}
catch
(
_error
)
{
}
catch
(
error1
)
{
this
.
error
=
"
建立房间失败,请重试
"
;
}
}
...
...
@@ -453,7 +455,7 @@
if
(
index
!==
-
1
)
{
Room
.
all
.
splice
(
index
,
1
);
}
if
(
!
this
[
"
private
"
]
&&
!
this
.
started
&&
this
.
established
)
{
if
(
!
this
[
"
private
"
]
&&
!
this
.
started
&&
this
.
established
&&
settings
.
modules
.
enable_websocket_roomlist
)
{
roomlist
[
"
delete
"
](
this
.
name
);
}
};
...
...
@@ -498,7 +500,7 @@
}
}
if
(
this
.
established
)
{
if
(
!
this
[
"
private
"
]
&&
!
this
.
started
)
{
if
(
!
this
[
"
private
"
]
&&
!
this
.
started
&&
settings
.
modules
.
enable_websocket_roomlist
)
{
roomlist
.
update
(
this
);
}
client
.
server
.
connect
(
this
.
port
,
'
127.0.0.1
'
,
function
()
{
...
...
@@ -532,7 +534,7 @@
}
if
(
this
.
players
.
length
)
{
ygopro
.
stoc_send_chat_to_room
(
this
,
client
.
name
+
"
"
+
'
离开了游戏
'
+
(
error
?
"
:
"
+
error
:
''
));
if
(
!
this
[
"
private
"
]
&&
!
this
.
started
)
{
if
(
!
this
[
"
private
"
]
&&
!
this
.
started
&&
settings
.
modules
.
enable_websocket_roomlist
)
{
roomlist
.
update
(
this
);
}
}
else
{
...
...
This diff is collapsed.
Click to expand it.
roomlist.js
View file @
54b96fe5
// Generated by CoffeeScript 1.
9.3
// Generated by CoffeeScript 1.
10.0
(
function
()
{
var
WebSocketServer
,
_delete
,
broadcast
,
create
,
init
,
room_data
,
server
,
update
;
...
...
@@ -82,7 +82,7 @@
connection
=
ref
[
i
];
try
{
results
.
push
(
connection
.
send
(
message
));
}
catch
(
_error
)
{}
}
catch
(
undefined
)
{}
}
return
results
;
};
...
...
This diff is collapsed.
Click to expand it.
ygopro-deck-stats.js
View file @
54b96fe5
...
...
@@ -10,7 +10,7 @@ var sqlite3 = require('sqlite3').verbose();
var
fs
=
require
(
'
fs
'
);
var
constants
=
require
(
'
./constants.json
'
);
var
DECKPATH
=
"
S:
\\
deck
\\
replays
"
var
DECKPATH
=
"
C:
\\
deck
\\
deck
"
var
DBFILE
=
"
F:
\\
Works
\\
deck
\\
cards.cdb
"
var
ALL_MAIN_CARDS
=
{};
...
...
@@ -47,12 +47,12 @@ function add_to_all_list(LIST,id,use) {
function
read_deck_file
(
filename
)
{
console
.
log
(
"
reading
"
+
filename
);
var
deck_text
=
fs
.
readFileSync
(
DECKPATH
+
"
\\
"
+
filename
,{
encoding
:
"
ASCII
"
})
var
deck_array
=
deck_text
.
split
(
"
\
r\
n
"
);
var
deck_array
=
deck_text
.
split
(
"
\n
"
);
var
deck_main
=
{};
var
deck_side
=
{};
var
current_deck
=
deck_main
;
for
(
var
i
in
deck_array
)
{
if
(
deck_array
[
i
]
==
"
!side
"
)
if
(
deck_array
[
i
]
.
indexOf
(
"
!side
"
)
>=
0
)
current_deck
=
deck_side
;
var
card
=
parseInt
(
deck_array
[
i
]);
if
(
!
isNaN
(
card
))
{
...
...
@@ -150,7 +150,9 @@ function read_decks() {
}
}
output_csv
(
ALL_MAIN_CARDS
,
"
main.csv
"
);
//output_csv(ALL_SIDE_CARDS,"side.csv");
if
(
ALL_SIDE_CARDS
.
length
)
{
output_csv
(
ALL_SIDE_CARDS
,
"
side.csv
"
);
}
}
function
output_csv
(
list
,
filename
)
{
...
...
This diff is collapsed.
Click to expand it.
ygopro-pre.js
View file @
54b96fe5
...
...
@@ -225,6 +225,18 @@ var pushDatas = function() {
}
catch
(
error
)
{
sendResponse
(
"
git error:
"
+
error
.
stdout
);
}
var
proc2
=
spawn
(
"
git
"
,
[
"
push
"
,
"
gitcafe
"
,
"
master:gitcafe-pages
"
],
{
cwd
:
config
.
git_html_path
,
env
:
process
.
env
});
proc2
.
stdout
.
setEncoding
(
'
utf8
'
);
proc2
.
stdout
.
on
(
'
data
'
,
function
(
data
)
{
sendResponse
(
"
git push:
"
+
data
);
});
proc2
.
stderr
.
setEncoding
(
'
utf8
'
);
proc2
.
stderr
.
on
(
'
data
'
,
function
(
data
)
{
sendResponse
(
"
git push error:
"
+
data
);
});
proc2
.
on
(
'
close
'
,
function
(
code
)
{
sendResponse
(
"
gitcafe上传完成。
"
);
});
var
proc
=
spawn
(
"
git
"
,
[
"
push
"
],
{
cwd
:
config
.
git_html_path
,
env
:
process
.
env
});
proc
.
stdout
.
setEncoding
(
'
utf8
'
);
proc
.
stdout
.
on
(
'
data
'
,
function
(
data
)
{
...
...
@@ -235,7 +247,7 @@ var pushDatas = function() {
sendResponse
(
"
git push:
"
+
data
);
});
proc
.
on
(
'
close
'
,
function
(
code
)
{
sendResponse
(
"
命令执行
完成。
"
);
sendResponse
(
"
github上传
完成。
"
);
});
}
...
...
This diff is collapsed.
Click to expand it.
ygopro-server.coffee
View file @
54b96fe5
...
...
@@ -34,7 +34,7 @@ settings.version = parseInt(fs.readFileSync('ygopro/gframe/game.cpp', 'utf8').ma
#组件
ygopro
=
require
'./ygopro.js'
Room
=
require
'./room.js'
roomlist
=
require
'./roomlist.js'
roomlist
=
require
'./roomlist.js'
if
settings
.
modules
.
enable_websocket_roomlist
users_cache
=
{}
...
...
@@ -643,6 +643,7 @@ ygopro.stoc_follow 'GAME_MSG', false, (buffer, info, client, server)->
if
dialogues
[
card
]
for
line
in
_
.
lines
dialogues
[
card
][
Math
.
floor
(
Math
.
random
()
*
dialogues
[
card
].
length
)]
ygopro
.
stoc_send_chat
client
,
line
,
15
return
#房间管理
ygopro
.
ctos_follow
'HS_KICK'
,
true
,
(
buffer
,
info
,
client
,
server
)
->
...
...
@@ -730,7 +731,7 @@ ygopro.stoc_follow 'DUEL_START', false, (buffer, info, client, server)->
return
unless
client
.
room
unless
client
.
room
.
started
#first start
client
.
room
.
started
=
true
roomlist
.
delete
client
.
room
.
name
unless
client
.
room
.
private
roomlist
.
delete
client
.
room
.
name
if
settings
.
modules
.
enable_websocket_roomlist
and
not
client
.
room
.
private
#client.room.duels = []
client
.
room
.
dueling_players
=
[]
for
player
in
client
.
room
.
players
when
player
.
pos
!=
7
...
...
@@ -897,7 +898,7 @@ if settings.modules.http
http_server
=
http
.
createServer
(
requestListener
)
http_server
.
listen
settings
.
modules
.
http
.
port
if
settings
.
modules
.
http
.
ssl
if
settings
.
modules
.
http
.
ssl
.
enabled
https
=
require
'https'
options
=
cert
:
fs
.
readFileSync
(
settings
.
modules
.
http
.
ssl
.
cert
)
...
...
This diff is collapsed.
Click to expand it.
ygopro-server.js
View file @
54b96fe5
// Generated by CoffeeScript 1.
9.3
// Generated by CoffeeScript 1.
10.0
(
function
()
{
var
Graveyard
,
Room
,
_
,
bunyan
,
crypto
,
debug
,
dialogues
,
execFile
,
fs
,
http
,
http_server
,
https
,
https_server
,
log
,
moment
,
net
,
options
,
os
,
path
,
pg
,
request
,
requestListener
,
roomlist
,
settings
,
tips
,
tribute
,
url
,
users_cache
,
wait_room_start
,
ygopro
;
...
...
@@ -44,7 +44,9 @@
Room
=
require
(
'
./room.js
'
);
roomlist
=
require
(
'
./roomlist.js
'
);
if
(
settings
.
modules
.
enable_websocket_roomlist
)
{
roomlist
=
require
(
'
./roomlist.js
'
);
}
users_cache
=
{};
...
...
@@ -629,7 +631,7 @@
}
ygopro
.
stoc_follow
(
'
GAME_MSG
'
,
false
,
function
(
buffer
,
info
,
client
,
server
)
{
var
card
,
k
,
len
,
line
,
msg
,
playertype
,
pos
,
ref
,
ref1
,
ref2
,
results
,
val
;
var
card
,
k
,
len
,
line
,
msg
,
playertype
,
pos
,
ref
,
ref1
,
ref2
,
val
;
msg
=
buffer
.
readInt8
(
0
);
if
(
msg
>=
10
&&
msg
<
30
)
{
client
.
room
.
waiting_for_player
=
client
;
...
...
@@ -692,12 +694,10 @@
card
=
buffer
.
readUInt32LE
(
1
);
if
(
dialogues
[
card
])
{
ref2
=
_
.
lines
(
dialogues
[
card
][
Math
.
floor
(
Math
.
random
()
*
dialogues
[
card
].
length
)]);
results
=
[];
for
(
k
=
0
,
len
=
ref2
.
length
;
k
<
len
;
k
++
)
{
line
=
ref2
[
k
];
results
.
push
(
ygopro
.
stoc_send_chat
(
client
,
line
,
15
)
);
ygopro
.
stoc_send_chat
(
client
,
line
,
15
);
}
return
results
;
}
}
}
...
...
@@ -838,7 +838,7 @@
}
if
(
!
client
.
room
.
started
)
{
client
.
room
.
started
=
true
;
if
(
!
client
.
room
[
"
private
"
])
{
if
(
settings
.
modules
.
enable_websocket_roomlist
&&
!
client
.
room
[
"
private
"
])
{
roomlist
[
"
delete
"
](
client
.
room
.
name
);
}
client
.
room
.
dueling_players
=
[];
...
...
@@ -1082,7 +1082,7 @@
};
http_server
=
http
.
createServer
(
requestListener
);
http_server
.
listen
(
settings
.
modules
.
http
.
port
);
if
(
settings
.
modules
.
http
.
ssl
)
{
if
(
settings
.
modules
.
http
.
ssl
.
enabled
)
{
https
=
require
(
'
https
'
);
options
=
{
cert
:
fs
.
readFileSync
(
settings
.
modules
.
http
.
ssl
.
cert
),
...
...
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