Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
M
mycard
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
xiaoye
mycard
Commits
ff51a04b
Commit
ff51a04b
authored
Dec 18, 2012
by
神楽坂玲奈
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
0.8.4
parent
03bca965
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
412 additions
and
107 deletions
+412
-107
Rakefile
Rakefile
+1
-1
lib/cacheable.rb
lib/cacheable.rb
+4
-1
lib/scene_lobby.rb
lib/scene_lobby.rb
+2
-2
lib/update.rb
lib/update.rb
+1
-1
lib/window_filter.rb
lib/window_filter.rb
+1
-0
lib/ygocore/event.rb
lib/ygocore/event.rb
+28
-28
lib/ygocore/game.rb
lib/ygocore/game.rb
+319
-33
lib/ygocore/room.rb
lib/ygocore/room.rb
+56
-41
No files found.
Rakefile
View file @
ff51a04b
...
...
@@ -20,7 +20,7 @@ end
spec
=
Gem
::
Specification
.
new
do
|
s
|
s
.
name
=
'mycard'
s
.
version
=
'0.8.
2
'
s
.
version
=
'0.8.
4
'
s
.
extra_rdoc_files
=
[
'README.txt'
,
'LICENSE.txt'
]
s
.
summary
=
'a card game'
s
.
description
=
s
.
summary
...
...
lib/cacheable.rb
View file @
ff51a04b
...
...
@@ -8,5 +8,8 @@ module Cacheable
else
@@all
[
self
][
id
]
=
super
(
id
,
*
args
)
end
end
end
def
find
(
id
)
@@all
[
self
][
id
]
end
end
\ No newline at end of file
lib/scene_lobby.rb
View file @
ff51a04b
...
...
@@ -66,8 +66,8 @@ class Scene_Lobby < Scene
when
Game_Event
::
AllUsers
@userlist
.
items
=
$game
.
users
when
Game_Event
::
AllRooms
,
Game_Event
::
AllServers
@roomlist
.
items
=
$game
.
rooms
.
find_all
{
|
room
|
$game
.
filter
[
:servers
].
collect
{
|
server
|
server
.
id
}.
include?
(
room
.
server_id
)
and
@roomlist
.
items
=
p
$game
.
rooms
.
find_all
{
|
room
|
$game
.
filter
[
:servers
].
include?
(
room
.
server
)
and
$game
.
filter
[
:waiting_only
]
?
(
room
.
status
==
:
wait
)
:
true
and
$game
.
filter
[
:normal_only
]
?
(
!
room
.
tag?
&&
(
room
.
ot
==
0
)
&&
(
room
.
lp
=
8000
))
:
true
}
...
...
lib/update.rb
View file @
ff51a04b
...
...
@@ -2,7 +2,7 @@ require 'open-uri'
require
"fileutils"
require_relative
'card'
module
Update
Version
=
'0.8.
2
'
Version
=
'0.8.
4
'
URL
=
"http://my-card.in/mycard/update.json?version=
#{
Version
}
"
class
<<
self
attr_reader
:thumbnails
,
:images
,
:status
...
...
lib/window_filter.rb
View file @
ff51a04b
...
...
@@ -11,6 +11,7 @@ class Window_Filter < Window
@servers
=
$game
.
servers
.
each_with_index
.
collect
do
|
server
,
index
|
result
=
Widget_Checkbox
.
new
(
self
,
4
+
@x
,
@y
+
WLH
+
WLH
*
index
,
@width
-
8
,
24
,
true
,
server
.
name
){
|
checked
|
checked
?
$game
.
filter
[:
servers
].
push
(
server
)
:
$game
.
filter
[
:servers
].
delete
(
server
)
;
Game_Event
.
push
(
Game_Event
::
AllRooms
.
new
(
$game
.
rooms
))}
result
.
background
=
@background
.
copy_rect
(
4
,
WLH
+
WLH
*
index
,
@width
-
8
,
24
)
result
.
checked
=
$game
.
filter
[
:servers
].
include?
server
result
.
refresh
result
end
...
...
lib/ygocore/event.rb
View file @
ff51a04b
...
...
@@ -7,22 +7,22 @@ class Game_Event
else
Error
.
new
(
'登录'
,
'用户名或密码错误'
)
end
when
:rooms
AllRooms
.
new
data
.
collect
{
|
room
|
parse_room
(
room
)}
when
:rooms_update
RoomsUpdate
.
new
data
.
collect
{
|
room
|
parse_room
(
room
)}
when
:servers
servers
=
data
.
collect
{
|
server
|
parse_server
(
server
)}
$game
.
filter
[
:servers
].
concat
(
servers
-
$game
.
servers
)
AllServers
.
new
servers
#
when :rooms
#
AllRooms.new data.collect{|room|parse_room(room)}
#
when :rooms_update
#
RoomsUpdate.new data.collect{|room|parse_room(room)}
#
when :servers
#
servers = data.collect{|server|parse_server(server)}
#
$game.filter[:servers].concat (servers - $game.servers)
#
AllServers.new servers
#when :newuser
#NewUser.new parse_user data
#when :missinguser
#MissingUser.new parse_user data
when
:newroom
NewRoom
.
new
parse_room
data
when
:missingroom
MissingRoom
.
new
parse_room
data
#
when :newroom
#
NewRoom.new parse_room data
#
when :missingroom
#
MissingRoom.new parse_room data
when
:chat
case
data
[
:channel
]
when
:lobby
...
...
@@ -33,25 +33,25 @@ class Game_Event
end
end
def
self
.
parse_room
(
room
)
result
=
Room
.
new
(
room
[
:id
],
room
[
:name
])
result
.
p
layer1
=
room
[
:player1
]
&&
parse_user
(
room
[
:player1
])
result
.
p
layer2
=
room
[
:player2
]
&&
parse_user
(
room
[
:player2
])
result
.
private
=
room
[
:private
]
result
.
pvp
=
room
[
:pvp
]
result
.
match
=
room
[
:match
]
result
.
tag
=
room
[
:tag
]
result
.
ot
=
room
[
:ot
]
result
.
status
=
room
[
:status
]
result
.
lp
=
room
[
:lp
]
result
.
_deleted
=
room
[
:_deleted
]
result
.
server_id
=
room
[
:server_id
]
result
.
server
_ip
=
room
[
:server_ip
]
result
.
server_port
=
room
[
:server_port
]
result
.
server_auth
=
room
[
:server_auth
]
result
=
Room
.
new
(
room
[
'id'
],
room
[
'name'
])
result
.
p
rivate
=
room
[
'private'
]
result
.
p
vp
=
room
[
'pvp'
]
result
.
match
=
room
[
'mode'
]
==
1
result
.
tag
=
room
[
'mode'
]
==
2
result
.
ot
=
room
[
'rule'
]
||
0
result
.
status
=
room
[
'status'
].
to_sym
result
.
lp
=
room
[
'start_lp'
]
||
8000
result
.
player1
=
room
[
'users'
][
0
]
&&
parse_user
(
room
[
'users'
][
0
])
result
.
player2
=
room
[
'users'
][
1
]
&&
parse_user
(
room
[
'users'
][
1
])
result
.
server
=
Server
.
find
room
[
'server_id'
]
result
.
_deleted
=
room
[
'_deleted'
]
result
end
def
self
.
parse_user
(
user
)
User
.
new
(
user
[
:id
],
user
[
:name
],
user
[
:certified
])
User
.
new
(
user
[
'id'
]
||
user
[
:id
],
user
[
'name'
]
||
user
[
:name
],
user
[
'certified'
]
||
user
[
:certified
])
end
def
self
.
parse_server
(
server
)
Server
.
new
(
server
[
:id
],
server
[
:name
],
server
[
:ip
],
server
[
:port
],
server
[
:auth
])
...
...
lib/ygocore/game.rb
View file @
ff51a04b
#encoding: UTF-8
load
'lib/ygocore/window_login.rb'
require
'eventmachine'
require
'em-http'
require
'websocket'
require
'open-uri'
require
'yaml'
class
Ygocore
<
Game
...
...
@@ -24,8 +26,8 @@ class Ygocore < Game
end
def
login
(
username
,
password
)
@username
=
username
@password
=
password
@username
=
username
@password
=
password
#@nickname_conflict = []
#@@im = Jabber::Client.new(Jabber::JID::new(@username, 'my-card.in', 'mycard'))
#@@im_room = Jabber::MUC::MUCClient.new(@@im)
...
...
@@ -77,7 +79,30 @@ class Ygocore < Game
def
connect
@recv
=
Thread
.
new
do
EventMachine
::
run
{
EventMachine
::
connect
"mycard-server.my-card.in"
,
9997
,
Client
http
=
EM
::
HttpRequest
.
new
(
"http://my-card.in/servers.json"
).
get
http
.
callback
{
begin
self
.
servers
.
replace
JSON
.
parse
(
http
.
response
).
collect
{
|
data
|
Server
.
new
(
data
[
'id'
],
data
[
'name'
],
data
[
'ip'
],
data
[
'port'
],
data
[
'auth'
])}
self
.
filter
[
:servers
]
=
self
.
servers
.
clone
rescue
Game_Event
.
push
Game_Event
::
Error
.
new
(
'ygocore'
,
'读取服务器列表失败'
,
true
)
end
EventMachine
::
connect
"mycard-server.my-card.in"
,
9997
,
Client
ws
=
WebSocket
::
EventMachine
::
Client
.
connect
(
:host
=>
"mycard-server.my-card.in"
,
:port
=>
9998
);
ws
.
onmessage
do
|
msg
,
type
|
$log
.
info
(
'收到websocket消息'
){
msg
.
force_encoding
(
"UTF-8"
)}
Game_Event
.
push
Game_Event
::
RoomsUpdate
.
new
JSON
.
parse
(
msg
).
collect
{
|
room
|
Game_Event
.
parse_room
(
room
)
}
end
ws
.
onclose
do
$log
.
info
(
'websocket连接断开'
)
Game_Event
.
push
Game_Event
::
Error
.
new
(
'ygocore'
,
'网络连接中断.1'
,
true
)
end
}
http
.
errback
{
Game_Event
.
push
Game_Event
::
Error
.
new
(
'ygocore'
,
'读取服务器列表失败'
,
true
)
}
}
end
end
...
...
@@ -130,17 +155,16 @@ class Ygocore < Game
end
def
host
(
room_name
,
room_config
)
room
=
Room
.
new
(
0
,
room_name
)
room
.
pvp
=
room_config
[
:pvp
]
room
.
match
=
room_config
[
:match
]
room
.
tag
=
room_config
[
:tag
]
room
=
Room
.
new
(
0
,
room_name
)
room
.
pvp
=
room_config
[
:pvp
]
room
.
match
=
room_config
[
:match
]
room
.
tag
=
room_config
[
:tag
]
room
.
password
=
room_config
[
:password
]
room
.
ot
=
room_config
[
:ot
]
room
.
lp
=
room_config
[
:lp
]
server
=
@filter
[
:servers
].
sample
||
Server
.
new
(
nil
,
""
,
$game
.
server
,
$game
.
port
,
true
)
room
.
server_ip
=
server
.
ip
room
.
server_port
=
server
.
port
room
.
server_auth
=
server
.
auth
room
.
ot
=
room_config
[
:ot
]
room
.
lp
=
room_config
[
:lp
]
room
.
host_server
if
$game
.
rooms
.
any?
{
|
game_room
|
game_room
.
name
==
room_name
}
Widget_Msgbox
.
new
(
"建立房间"
,
"房间名已存在"
,
:ok
=>
"确定"
)
else
...
...
@@ -157,7 +181,7 @@ class Ygocore < Game
end
def
refresh
send
(
:refresh
)
#
send(:refresh)
end
def
send
(
header
,
data
=
nil
)
...
...
@@ -204,14 +228,14 @@ class Ygocore < Game
Dir
.
chdir
(
File
.
dirname
(
path
))
do
case
option
when
Room
room
=
option
room
=
option
room_name
=
if
room
.
ot
!=
0
or
room
.
lp
!=
8000
mode
=
case
when
room
.
match?
then
1
;
when
room
.
tag?
then
2
else
0
end
mode
=
case
when
room
.
match?
then
1
;
when
room
.
tag?
then
2
else
0
end
room_name
=
"
#{
room
.
ot
}#{
mode
}
FFF
#{
room
.
lp
}
,5,1,
#{
room
.
name
}
"
elsif
room
.
tag?
"T#"
+
room
.
name
...
...
@@ -232,19 +256,19 @@ class Ygocore < Game
IO
.
readlines
(
'system.conf'
).
each
do
|
line
|
line
.
force_encoding
"UTF-8"
next
if
line
[
0
,
1
]
==
'#'
field
,
contents
=
line
.
chomp
.
split
(
' = '
,
2
)
field
,
contents
=
line
.
chomp
.
split
(
' = '
,
2
)
system_conf
[
field
]
=
contents
end
rescue
system_conf
[
'antialias'
]
=
2
system_conf
[
'textfont'
]
=
'c:/windows/fonts/simsun.ttc 14'
system_conf
[
'numfont'
]
=
'c:/windows/fonts/arialbd.ttf'
system_conf
[
'textfont'
]
=
'c:/windows/fonts/simsun.ttc 14'
system_conf
[
'numfont'
]
=
'c:/windows/fonts/arialbd.ttf'
end
system_conf
[
'nickname'
]
=
$game
.
user
.
name
system_conf
[
'nickname'
]
+=
'$'
+
$game
.
password
if
$game
.
password
and
!
$game
.
password
.
empty?
and
room
.
server
_
auth
p
room
system_conf
[
'lastip'
]
=
room
.
server_
ip
system_conf
[
'lastport'
]
=
room
.
server
_
port
.
to_s
system_conf
[
'nickname'
]
+=
'$'
+
$game
.
password
if
$game
.
password
and
!
$game
.
password
.
empty?
and
room
.
server
.
auth
$log
.
info
room
system_conf
[
'lastip'
]
=
room
.
server
.
ip
system_conf
[
'lastport'
]
=
room
.
server
.
port
.
to_s
system_conf
[
'roompass'
]
=
room_name
open
(
'system.conf'
,
'w'
)
{
|
file
|
file
.
write
system_conf
.
collect
{
|
key
,
value
|
"
#{
key
}
=
#{
value
}
"
}.
join
(
"
\n
"
)
}
args
=
'-j'
...
...
@@ -258,13 +282,13 @@ class Ygocore < Game
IO
.
readlines
(
'system.conf'
).
each
do
|
line
|
line
.
force_encoding
"UTF-8"
next
if
line
[
0
,
1
]
==
'#'
field
,
contents
=
line
.
chomp
.
split
(
' = '
,
2
)
field
,
contents
=
line
.
chomp
.
split
(
' = '
,
2
)
system_conf
[
field
]
=
contents
end
rescue
system_conf
[
'antialias'
]
=
2
system_conf
[
'textfont'
]
=
'c:/windows/fonts/simsun.ttc 14'
system_conf
[
'numfont'
]
=
'c:/windows/fonts/arialbd.ttf'
system_conf
[
'textfont'
]
=
'c:/windows/fonts/simsun.ttc 14'
system_conf
[
'numfont'
]
=
'c:/windows/fonts/arialbd.ttf'
end
system_conf
[
'lastdeck'
]
=
option
open
(
'system.conf'
,
'w'
)
{
|
file
|
file
.
write
system_conf
.
collect
{
|
key
,
value
|
"
#{
key
}
=
#{
value
}
"
}.
join
(
"
\n
"
)
}
...
...
@@ -287,7 +311,7 @@ class Ygocore < Game
def
self
.
get_announcements
#公告
$config
[
'ygocore'
]
||=
{}
$config
[
'ygocore'
]
||=
{}
$config
[
'ygocore'
][
'announcements'
]
||=
[
Announcement
.
new
(
"开放注册"
,
nil
,
nil
)]
#Thread.new do
# begin
...
...
@@ -325,4 +349,266 @@ class Ygocore < Game
end
end
get_announcements
end
\ No newline at end of file
end
# websocket, due to the author hasn't release separate gem yet
#https://github.com/imanel/websocket-ruby/issues/12
module
WebSocket
module
EventMachine
class
Base
<
::
EventMachine
::
Connection
###########
### API ###
###########
def
onopen
(
&
blk
)
;
@onopen
=
blk
;
end
# Called when connection is opened
def
onclose
(
&
blk
)
;
@onclose
=
blk
;
end
# Called when connection is closed
def
onerror
(
&
blk
)
;
@onerror
=
blk
;
end
# Called when error occurs
def
onmessage
(
&
blk
)
;
@onmessage
=
blk
;
end
# Called when message is received from server
def
onping
(
&
blk
)
;
@onping
=
blk
;
end
# Called when ping message is received from server
def
onpong
(
&
blk
)
;
@onpong
=
blk
;
end
# Called when pond message is received from server
# Send data to client
# @param data [String] Data to send
# @param args [Hash] Arguments for send
# @option args [String] :type Type of frame to send - available types are "text", "binary", "ping", "pong" and "close"
# @return [Boolean] true if data was send, otherwise call on_error if needed
def
send
(
data
,
args
=
{})
type
=
args
[
:type
]
||
:text
unless
type
==
:plain
frame
=
outgoing_frame
.
new
(
:version
=>
@handshake
.
version
,
:data
=>
data
,
:type
=>
type
)
if
!
frame
.
supported?
trigger_onerror
(
"Frame type '
#{
type
}
' is not supported in protocol version
#{
@handshake
.
version
}
"
)
return
false
elsif
!
frame
.
require_sending?
return
false
end
data
=
frame
.
to_s
end
# debug "Sending raw: ", data
send_data
(
data
)
true
end
# Close connection
# @return [Boolean] true if connection is closed immediately, false if waiting for server to close connection
def
close
if
@state
==
:open
@state
=
:closing
return
false
if
send
(
''
,
:type
=>
:close
)
else
send
(
''
,
:type
=>
:close
)
if
@state
==
:closing
@state
=
:closed
end
close_connection_after_writing
true
end
# Send ping message to client
# @return [Boolean] false if protocol version is not supporting ping requests
def
ping
(
data
=
''
)
send
(
data
,
:type
=>
:ping
)
end
# Send pong message to client
# @return [Boolean] false if protocol version is not supporting pong requests
def
pong
(
data
=
''
)
send
(
data
,
:type
=>
:pong
)
end
############################
### EventMachine methods ###
############################
def
receive_data
(
data
)
# debug "Received raw: ", data
case
@state
when
:connecting
then
handle_connecting
(
data
)
when
:open
then
handle_open
(
data
)
when
:closing
then
handle_closing
(
data
)
end
end
def
unbind
unless
@state
==
:closed
@state
=
:closed
close
trigger_onclose
(
''
)
end
end
#######################
### Private methods ###
#######################
private
[
'onopen'
].
each
do
|
m
|
define_method
"trigger_
#{
m
}
"
do
callback
=
instance_variable_get
(
"@
#{
m
}
"
)
callback
.
call
if
callback
end
end
[
'onerror'
,
'onping'
,
'onpong'
,
'onclose'
].
each
do
|
m
|
define_method
"trigger_
#{
m
}
"
do
|
data
|
callback
=
instance_variable_get
(
"@
#{
m
}
"
)
callback
.
call
(
data
)
if
callback
end
end
def
trigger_onmessage
(
data
,
type
)
@onmessage
.
call
(
data
,
type
)
if
@onmessage
end
def
handle_connecting
(
data
)
@handshake
<<
data
return
unless
@handshake
.
finished?
if
@handshake
.
valid?
send
(
@handshake
.
to_s
,
:type
=>
:plain
)
if
@handshake
.
should_respond?
@frame
=
incoming_frame
.
new
(
:version
=>
@handshake
.
version
)
@state
=
:open
trigger_onopen
handle_open
(
@handshake
.
leftovers
)
if
@handshake
.
leftovers
else
trigger_onerror
(
@handshake
.
error
)
close
end
end
def
handle_open
(
data
)
@frame
<<
data
while
frame
=
@frame
.
next
case
frame
.
type
when
:close
@state
=
:closing
close
trigger_onclose
(
frame
.
to_s
)
when
:ping
pong
(
frame
.
to_s
)
trigger_onping
(
frame
.
to_s
)
when
:pong
trigger_onpong
(
frame
.
to_s
)
when
:text
trigger_onmessage
(
frame
.
to_s
,
:text
)
when
:binary
trigger_onmessage
(
frame
.
to_s
,
:binary
)
end
end
unbind
if
@frame
.
error?
end
def
handle_closing
(
data
)
@state
=
:closed
close
trigger_onclose
end
def
debug
(
description
,
data
)
puts
(
description
+
data
.
bytes
.
to_a
.
collect
{
|
b
|
'\x'
+
b
.
to_s
(
16
).
rjust
(
2
,
'0'
)
}.
join
)
unless
@state
==
:connecting
end
end
end
end
# Example WebSocket Client (using EventMachine)
# @example
# ws = WebSocket::EventMachine::Client.connect(:host => "0.0.0.0", :port => 8080)
# ws.onmessage { |msg| ws.send "Pong: #{msg}" }
# ws.send "data"
module
WebSocket
module
EventMachine
class
Client
<
Base
# Connect to websocket server
# @param args [Hash] The request arguments
# @option args [String] :host The host IP/DNS name
# @option args [Integer] :port The port to connect too(default = 80)
# @option args [Integer] :version Version of protocol to use(default = 13)
def
self
.
connect
(
args
=
{})
host
=
nil
port
=
nil
if
args
[
:uri
]
uri
=
URI
.
parse
(
args
[
:uri
])
host
=
uri
.
host
port
=
uri
.
port
end
host
=
args
[
:host
]
if
args
[
:host
]
port
=
args
[
:port
]
if
args
[
:port
]
port
||=
80
::
EventMachine
.
connect
host
,
port
,
self
,
args
end
# Initialize connection
# @param args [Hash] Arguments for connection
# @option args [String] :host The host IP/DNS name
# @option args [Integer] :port The port to connect too(default = 80)
# @option args [Integer] :version Version of protocol to use(default = 13)
def
initialize
(
args
)
@args
=
args
end
############################
### EventMachine methods ###
############################
# Called after initialize of connection, but before connecting to server
def
post_init
@state
=
:connecting
@handshake
=
WebSocket
::
Handshake
::
Client
.
new
(
@args
)
end
# Called by EventMachine after connecting.
# Sends handshake to server
def
connection_completed
send
(
@handshake
.
to_s
,
:type
=>
:plain
)
end
private
def
incoming_frame
WebSocket
::
Frame
::
Incoming
::
Client
end
def
outgoing_frame
WebSocket
::
Frame
::
Outgoing
::
Client
end
end
end
end
lib/ygocore/room.rb
View file @
ff51a04b
class
Room
attr_accessor
:pvp
attr_accessor
:match
attr_accessor
:tag
attr_accessor
:ot
attr_accessor
:lp
attr_accessor
:status
attr_accessor
:server_id
,
:server_ip
,
:server_port
,
:server_auth
alias
pvp?
pvp
alias
match?
match
alias
tag?
tag
def
lp
@lp
||=
8000
end
def
ot
@ot
||=
0
end
def
full?
$game
.
is_a?
(
Ygocore
)
?
(
@status
==
:
start
)
:
player2
#不规范修正iduel房间识别问题
end
def
extra
result
=
{}
if
pvp?
result
[
"[竞技场]"
]
=
[
255
,
0
,
0
]
end
if
tag?
result
[
"[TAG双打]"
]
=
[
128
,
0
,
255
]
elsif
match?
result
[
"[三回决斗]"
]
=
[
0xff
,
0x72
,
0
]
end
if
ot
==
1
result
[
"[TCG]"
]
=
[
255
,
0
,
0
]
elsif
ot
==
2
result
[
"[O/T混]"
]
=
[
255
,
0
,
0
]
end
if
lp
!=
8000
result
[
"[LP:
#{
lp
}
]"
]
=
[
255
,
0
,
0
]
end
result
end
end
class
Room
attr_accessor
:pvp
attr_accessor
:match
attr_accessor
:tag
attr_accessor
:ot
attr_accessor
:lp
attr_accessor
:status
attr_accessor
:server
alias
pvp?
pvp
alias
match?
match
alias
tag?
tag
def
lp
@lp
||=
8000
end
def
ot
@ot
||=
0
end
def
full?
$game
.
is_a?
(
Ygocore
)
?
(
@status
==
:
start
)
:
player2
#不规范修正iduel房间识别问题
end
def
extra
result
=
{}
if
pvp?
result
[
"[竞技场]"
]
=
[
255
,
0
,
0
]
end
if
tag?
result
[
"[TAG双打]"
]
=
[
128
,
0
,
255
]
elsif
match?
result
[
"[三回决斗]"
]
=
[
0xff
,
0x72
,
0
]
end
if
ot
==
1
result
[
"[TCG]"
]
=
[
255
,
0
,
0
]
elsif
ot
==
2
result
[
"[O/T混]"
]
=
[
255
,
0
,
0
]
end
if
lp
!=
8000
result
[
"[LP:
#{
lp
}
]"
]
=
[
255
,
0
,
0
]
end
result
end
def
host_server
servers
=
$game
.
servers
servers
.
select!
{
|
server
|
server
.
auth
}
if
@pvp
s
=
servers
&
$game
.
filter
[
:servers
]
servers
=
s
if
!
s
.
empty?
server
=
servers
.
min_by
{
|
server
|
$game
.
rooms
.
select
{
|
room
|
room
.
server
==
server
}.
size
}
p
server
server
||=
Server
.
new
(
nil
,
""
,
$game
.
server
,
$game
.
port
,
true
)
self
.
server
=
server
server
end
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