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
syntax_j
mycard
Commits
17ae1837
Commit
17ae1837
authored
Dec 05, 2012
by
神楽坂玲奈
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
0.8.1
parent
1e26242c
Changes
19
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
19 changed files
with
294 additions
and
185 deletions
+294
-185
lib/config.rb
lib/config.rb
+3
-0
lib/game_event.rb
lib/game_event.rb
+38
-12
lib/iduel/user.rb
lib/iduel/user.rb
+2
-2
lib/main.rb
lib/main.rb
+25
-18
lib/quickstart.rb
lib/quickstart.rb
+5
-3
lib/room.rb
lib/room.rb
+4
-1
lib/update.rb
lib/update.rb
+1
-1
lib/widget_msgbox.rb
lib/widget_msgbox.rb
+1
-1
lib/window.rb
lib/window.rb
+47
-27
lib/window_chat.rb
lib/window_chat.rb
+1
-1
lib/window_config.rb
lib/window_config.rb
+2
-2
lib/window_lobbybuttons.rb
lib/window_lobbybuttons.rb
+3
-3
lib/window_login.rb
lib/window_login.rb
+7
-7
lib/window_roomlist.rb
lib/window_roomlist.rb
+2
-3
lib/ygocore/event.rb
lib/ygocore/event.rb
+15
-20
lib/ygocore/game.rb
lib/ygocore/game.rb
+133
-80
lib/ygocore/room.rb
lib/ygocore/room.rb
+1
-0
lib/ygocore/server.yml
lib/ygocore/server.yml
+2
-2
lib/ygocore/user.rb
lib/ygocore/user.rb
+2
-2
No files found.
lib/config.rb
View file @
17ae1837
...
...
@@ -9,6 +9,9 @@ module Config
config
[
'bgm'
]
=
true
if
config
[
'bgm'
].
nil?
config
[
'screen'
]
||=
{}
config
[
'screen'
][
'width'
],
config
[
'screen'
][
'height'
]
=
Resolution
.
default
unless
Resolution
.
all
.
include?
[
config
[
'screen'
][
'width'
],
config
[
'screen'
][
'height'
]]
config
[
'i18n'
]
||=
{}
config
[
'i18n'
][
'locale'
]
||=
"
#{
Locale
.
current
.
language
}
-
#{
Locale
.
current
.
region
}
"
I18n
.
locale
=
config
[
'i18n'
][
'locale'
]
config
end
def
save
(
config
=
$config
,
file
=
"config.yml"
)
...
...
lib/game_event.rb
View file @
17ae1837
#游戏事件的抽象类
class
Game_Event
@queue
=
[]
def
self
.
push
(
event
)
@queue
<<
event
end
def
self
.
poll
@queue
.
shift
end
def
self
.
parse
(
info
,
*
args
)
#适配器定义
end
...
...
@@ -14,14 +17,16 @@ class Game_Event
class
Login
<
Game_Event
attr_reader
:user
def
initialize
(
user
)
@user
=
user
@user
=
user
$game
.
user
=
@user
end
end
class
AllUsers
<
Game_Event
attr_reader
:users
def
initialize
(
users
)
@users
=
[]
users
.
each
do
|
user
|
...
...
@@ -34,9 +39,10 @@ class Game_Event
$game
.
users
.
replace
@users
end
end
class
NewUser
<
AllUsers
attr_reader
:users
def
initialize
(
user
)
@user
=
user
unless
$game
.
users
.
include?
@user
...
...
@@ -51,6 +57,7 @@ class Game_Event
class
MissingUser
<
AllUsers
attr_reader
:users
def
initialize
(
user
)
@user
=
user
$game
.
users
.
delete
@user
...
...
@@ -59,14 +66,27 @@ class Game_Event
class
AllRooms
<
Game_Event
attr_reader
:rooms
def
initialize
(
rooms
)
@rooms
=
rooms
$game
.
rooms
.
replace
@rooms
$game
.
rooms
.
sort_by!
{
|
room
|
[
room
.
status
==
:start
?
1
:
0
,
room
.
private
?
1
:
0
,
room
.
id
]
}
end
end
class
RoomsUpdate
<
AllRooms
attr_reader
:rooms
def
initialize
(
rooms
)
@rooms
=
rooms
$game
.
rooms
.
replace
$game
.
rooms
|
@rooms
$game
.
rooms
.
delete_if
{
|
room
|
room
.
_deleted
}
$game
.
rooms
.
sort_by!
{
|
room
|
[
room
.
status
==
:start
?
1
:
0
,
room
.
private
?
1
:
0
,
room
.
id
]
}
end
end
class
NewRoom
<
AllRooms
attr_reader
:room
def
initialize
(
room
)
@room
=
room
unless
$game
.
rooms
.
include?
@room
...
...
@@ -80,6 +100,7 @@ class Game_Event
end
class
MissingRoom
<
AllRooms
attr_reader
:room
def
initialize
(
room
)
@room
=
room
$game
.
rooms
.
delete
@room
...
...
@@ -87,9 +108,9 @@ class Game_Event
end
class
Chat
<
Game_Event
attr_reader
:chatmessage
def
initialize
(
chatmessage
)
@chatmessage
=
chatmessage
end
...
...
@@ -97,8 +118,9 @@ class Game_Event
class
Join
<
Game_Event
attr_reader
:room
def
initialize
(
room
)
@room
=
room
@room
=
room
$game
.
room
=
@room
end
end
...
...
@@ -106,8 +128,9 @@ class Game_Event
end
class
Watch
<
Game_Event
attr_reader
:room
def
initialize
(
room
)
@room
=
room
@room
=
room
$game
.
room
=
@room
end
end
...
...
@@ -117,8 +140,9 @@ class Game_Event
end
class
PlayerJoin
<
Game_Event
attr_reader
:user
def
initialize
(
user
)
@user
=
user
@user
=
user
$game
.
room
.
player2
=
@user
end
end
...
...
@@ -130,20 +154,22 @@ class Game_Event
class
Action
<
Game_Event
attr_reader
:action
,
:str
def
initialize
(
action
,
str
=
action
.
escape
)
@action
=
action
@str
=
str
@str
=
str
end
end
class
Error
<
Game_Event
attr_reader
:title
,
:message
,
:fatal
def
initialize
(
title
,
message
,
fatal
=
true
)
@title
=
title
@title
=
title
@message
=
message
@fatal
=
fatal
$log
.
error
(
@fatal
?
"致命错误"
:
"一般错误"
)
{
"
#{
@title
}
:
#{
@message
}
#{
caller
}
"
}
@fatal
=
fatal
$log
.
error
(
@fatal
?
"致命错误"
:
"一般错误"
)
{
"
#{
@title
}
:
#{
@message
}
#{
caller
}
"
}
end
end
class
Unknown
<
Error
...
...
lib/iduel/user.rb
View file @
17ae1837
...
...
@@ -21,12 +21,12 @@ class User
end
def
avatar
(
size
=
:small
)
cache
=
"graphics/avatars/
#{
@id
}
_
#{
size
}
.png"
result
=
Surface
.
load
(
cache
)
rescue
Surface
.
load
(
"graphics/avatars/loading_
#{
size
}
.
gif
"
)
result
=
Surface
.
load
(
cache
)
rescue
Surface
.
load
(
"graphics/avatars/loading_
#{
size
}
.
png
"
)
scene
=
$scene
if
block_given?
yield
result
Thread
.
new
do
open
(
"http://www.duelcn.com/uc_server/avatar.php?uid=
#{
id
-
100000
}
&size=
#{
size
}
"
,
'rb'
)
{
|
io
|
open
(
cache
,
'wb'
)
{
|
c
|
c
.
write
io
.
read
}}
rescue
cache
=
"graphics/avatars/
noavatar_
#{
size
}
.gif
"
open
(
"http://www.duelcn.com/uc_server/avatar.php?uid=
#{
id
-
100000
}
&size=
#{
size
}
"
,
'rb'
)
{
|
io
|
open
(
cache
,
'wb'
)
{
|
c
|
c
.
write
io
.
read
}}
rescue
cache
=
"graphics/avatars/
error_
#{
size
}
.png
"
(
yield
Surface
.
load
(
cache
)
if
scene
==
$scene
)
rescue
nil
end
else
...
...
lib/main.rb
View file @
17ae1837
...
...
@@ -2,6 +2,7 @@
begin
Windows
=
RUBY_PLATFORM
[
"win"
]
||
RUBY_PLATFORM
[
"ming"
]
Dir
.
glob
(
'post_update_*.rb'
).
sort
.
each
{
|
file
|
load
file
}
Thread
.
abort_on_exception
=
true
require_relative
'resolution'
...
...
@@ -9,30 +10,36 @@ begin
require_relative
'config'
require_relative
'association'
#i18n
require
'i18n'
require
'locale'
I18n
.
load_path
+=
Dir
[
'locales/*.yml'
]
I18n
::
Backend
::
Simple
.
include
(
I18n
::
Backend
::
Fallbacks
)
#读取配置文件
$config
=
Config
.
load
Config
.
save
#读取命令行参数
log
=
"log.log"
log
=
"log.log"
log_level
=
"INFO"
profile
=
nil
profile
=
nil
ARGV
.
each
do
|
arg
|
arg
=
arg
.
dup
.
force_encoding
(
"UTF-8"
)
arg
.
force_encoding
(
"GBK"
)
unless
arg
.
valid_encoding?
case
arg
when
/--log=(.*)/
log
.
replace
$1
when
/--log-level=(.*)/
log_level
.
replace
$1
when
/--profile=(.*)/
profile
=
$1
when
/^mycard:.*|\.ydk$|\.yrp$|\.deck$/
require_relative
'quickstart'
$scene
=
false
when
/register_association/
Association
.
register
$scene
=
false
when
/--log=(.*)/
log
.
replace
$1
when
/--log-level=(.*)/
log_level
.
replace
$1
when
/--profile=(.*)/
profile
=
$1
when
/^mycard:.*|\.ydk$|\.yrp$|\.deck$/
require_relative
'quickstart'
$scene
=
false
when
/register_association/
Association
.
register
$scene
=
false
end
end
...
...
@@ -51,7 +58,7 @@ begin
if
log
==
"STDOUT"
#调试用
log
=
STDOUT
end
$log
=
Logger
.
new
(
log
)
$log
=
Logger
.
new
(
log
)
$log
.
level
=
Logger
.
const_get
log_level
#性能分析
...
...
@@ -63,7 +70,7 @@ begin
end
require
'profiler'
RubyVM
::
InstructionSequence
.
compile_option
=
{
:trace_instruction
=>
true
,
:trace_instruction
=>
true
,
:specialized_instruction
=>
false
}
Profiler__
::
start_profile
...
...
@@ -71,13 +78,13 @@ begin
SDL
::
Event
::
APPMOUSEFOCUS
=
1
SDL
::
Event
::
APPINPUTFOCUS
=
2
SDL
::
Event
::
APPACTIVE
=
4
SDL
::
Event
::
APPACTIVE
=
4
SDL
.
putenv
(
"SDL_VIDEO_CENTERED=1"
);
SDL
.
init
(
INIT_VIDEO
)
WM
::
set_caption
(
"MyCard"
,
"MyCard"
)
WM
::
icon
=
Surface
.
load
(
"graphics/system/icon.gif"
)
$screen
=
Screen
.
open
(
$config
[
'screen'
][
'width'
],
$config
[
'screen'
][
'height'
],
0
,
HWSURFACE
|
(
$config
[
'screen'
][
'fullscreen'
]
?
FULLSCREEN
:
0
))
$screen
=
Screen
.
open
(
$config
[
'screen'
][
'width'
],
$config
[
'screen'
][
'height'
],
0
,
HWSURFACE
|
(
$config
[
'screen'
][
'fullscreen'
]
?
FULLSCREEN
:
0
))
TTF
.
init
#声音
...
...
lib/quickstart.rb
View file @
17ae1837
...
...
@@ -49,7 +49,9 @@ case file
require
'uri'
$game
.
user
=
User
.
new
(
$1
.
to_sym
,
$1
)
if
$1
$game
.
password
=
$2
if
$2
$game
.
server
=
$3
$game
.
port
=
$4
.
to_i
Ygocore
.
run_ygocore
Room
.
new
(
0
,
$5
),
true
room
=
Room
.
new
(
0
,
$5
)
room
.
server_ip
=
$3
room
.
server_port
=
$4
.
to_i
room
.
server_auth
=
true
if
$2
Ygocore
.
run_ygocore
room
,
true
end
\ No newline at end of file
lib/room.rb
View file @
17ae1837
...
...
@@ -2,7 +2,7 @@ require_relative 'cacheable'
class
Room
Color
=
[[
0
,
0
,
0
],
[
255
,
0
,
0
],
[
0
,
128
,
0
],
[
0
,
0
,
255
],
[
255
,
165
,
0
]]
extend
Cacheable
attr_accessor
:id
,
:name
,
:player1
,
:player2
,
:private
,
:color
,
:forbid
attr_accessor
:id
,
:name
,
:player1
,
:player2
,
:private
,
:color
,
:forbid
,
:_deleted
attr_accessor
:password
def
initialize
(
id
,
name
=
"等待更新"
,
player1
=
nil
,
player2
=
nil
,
private
=
false
,
color
=
[
0
,
0
,
0
],
session
=
nil
,
forbid
=
nil
)
@id
=
id
...
...
@@ -30,6 +30,9 @@ class Room
def
extra
{}
end
def
status
player2
?
:
start
:
:wait
end
alias
full?
player2
alias
private
?
private
end
\ No newline at end of file
lib/update.rb
View file @
17ae1837
...
...
@@ -2,7 +2,7 @@ require 'open-uri'
require
"fileutils"
require_relative
'card'
module
Update
Version
=
'0.
7.4
'
Version
=
'0.
8.1
'
URL
=
"http://my-card.in/mycard/update.json?version=
#{
Version
}
"
class
<<
self
attr_reader
:thumbnails
,
:images
,
:status
...
...
lib/widget_msgbox.rb
View file @
17ae1837
...
...
@@ -4,7 +4,7 @@ class Widget_Msgbox < Window
class
<<
self
alias
old_new
new
def
new
(
title
,
message
,
buttons
=
{},
&
proc
)
if
instance
=
$scene
.
windows
.
find
{
|
window
|
window
.
class
==
self
and
!
window
.
destroyed?
}
if
instance
=
$scene
.
windows
.
find
{
|
window
|
window
.
class
==
self
and
!
window
.
destroyed?
}
rescue
nil
instance
.
set
(
title
,
message
,
buttons
,
&
proc
)
instance
else
...
...
lib/window.rb
View file @
17ae1837
...
...
@@ -2,91 +2,111 @@ class Window
WLH
=
24
attr_accessor
:x
,
:y
,
:width
,
:height
,
:z
,
:contents
,
:visible
,
:viewport
,
:background
alias
visible?
visible
def
initialize
(
x
,
y
,
width
,
height
,
z
=
200
)
@x
=
x
@y
=
y
@z
=
z
@width
=
width
@height
=
height
@visible
=
true
@x
=
x
@y
=
y
@z
=
z
@width
=
width
@height
=
height
@visible
=
true
#@angle = 0
@viewport
=
[
0
,
0
,
@width
,
@height
]
@viewport
=
[
0
,
0
,
@width
,
@height
]
@destroyed
=
false
amask
=
0xff000000
rmask
=
0x00ff0000
gmask
=
0x0000ff00
bmask
=
0x000000ff
amask
=
0xff000000
rmask
=
0x00ff0000
gmask
=
0x0000ff00
bmask
=
0x000000ff
#@background ||= Surface.new(SWSURFACE, @width, @height, 32, rmask, gmask, bmask, amask)
@contents
||=
Surface
.
new
(
SWSURFACE
,
@width
,
@height
,
32
,
rmask
,
gmask
,
bmask
,
amask
)
@contents
||=
Surface
.
new
(
SWSURFACE
,
@width
,
@height
,
32
,
rmask
,
gmask
,
bmask
,
amask
)
#按Z坐标插入
unless
$scene
.
windows
.
each_with_index
do
|
window
,
index
|
if
window
.
z
>
@z
$scene
.
windows
.
insert
(
index
,
self
)
break
true
end
end
==
true
if
window
.
z
>
@z
$scene
.
windows
.
insert
(
index
,
self
)
break
true
end
end
==
true
$scene
.
windows
<<
self
end
end
def
center_margin
(
text
,
width
,
font
=
@font
)
(
width
-
font
.
text_size
(
text
)[
0
])
/
2
end
def
draw_stroked_text
(
text
,
x
,
y
,
size
=
1
,
font
=
@font
,
color
=
@color
,
color_stroke
=
@color_stroke
)
[[
x
-
size
,
y
-
size
],
[
x
-
size
,
y
],
[
x
-
size
,
y
+
size
],
[
x
,
y
-
size
],
[
x
,
y
+
size
],
[
x
+
size
,
y
-
size
],
[
x
+
size
,
y
],
[
x
+
size
,
y
+
size
],
].
each
{
|
pos
|
font
.
draw_blended_utf8
(
@contents
,
text
,
pos
[
0
],
pos
[
1
],
*
color
)}
def
draw_stroked_text
(
text
,
x
,
y
,
size
=
1
,
font
=
@font
,
color
=
@color
,
color_stroke
=
@color_stroke
)
[[
x
-
size
,
y
-
size
],
[
x
-
size
,
y
],
[
x
-
size
,
y
+
size
],
[
x
,
y
-
size
],
[
x
,
y
+
size
],
[
x
+
size
,
y
-
size
],
[
x
+
size
,
y
],
[
x
+
size
,
y
+
size
],
].
each
{
|
pos
|
font
.
draw_blended_utf8
(
@contents
,
text
,
pos
[
0
],
pos
[
1
],
*
color
)
}
font
.
draw_blended_utf8
(
@contents
,
text
,
x
,
y
,
*
color_stroke
)
end
def
include?
(
x
,
y
)
def
include?
(
x
,
y
)
x
>=
@x
&&
x
<
@x
+
@width
&&
y
>=
@y
&&
y
<
@y
+
@height
end
def
destroy
@destroyed
=
true
@contents
.
destroy
if
@contents
$scene
.
windows
.
delete
self
if
$scene
end
def
destroyed?
@destroyed
end
def
draw
(
screen
)
return
unless
self
.
contents
&&
self
.
visible?
&&
!
self
.
destroyed?
Surface
.
blit
(
self
.
contents
,
*
self
.
viewport
,
screen
,
self
.
x
,
self
.
y
)
end
def
clear
(
x
=
0
,
y
=
0
,
width
=
@width
,
height
=
@height
)
if
@background
Surface
.
blit
(
@background
,
x
,
y
,
width
,
height
,
@contents
,
x
,
y
)
Surface
.
blit
(
@background
,
x
,
y
,
width
,
height
,
@contents
,
x
,
y
)
elsif
$scene
and
$scene
.
background
Surface
.
blit
(
$scene
.
background
,
@x
+
x
,
@y
+
y
,
width
,
height
,
@contents
,
x
,
y
)
Surface
.
blit
(
$scene
.
background
,
@x
+
x
,
@y
+
y
,
width
,
height
,
@contents
,
x
,
y
)
else
@contents
.
fill_rect
(
x
,
y
,
width
,
height
,
0xFF000000
)
@contents
.
fill_rect
(
x
,
y
,
width
,
height
,
0xFF000000
)
end
end
def
update
#子类定义
end
def
refresh
#子类定义
end
def
mousemoved
(
x
,
y
)
def
mousemoved
(
x
,
y
)
#子类定义
end
def
clicked
#子类定义
end
def
mouseleftbuttonup
#子类定义
end
def
lostfocus
(
active_window
=
nil
)
#子类定义
end
def
cursor_up
(
wrap
=
false
)
#子类定义
end
def
cursor_down
(
wrap
=
false
)
#子类定义
end
def
scroll_up
cursor_up
end
def
scroll_down
cursor_down
end
...
...
lib/window_chat.rb
View file @
17ae1837
...
...
@@ -27,7 +27,7 @@ class Window_Chat < Window_Scrollable
if
!
@chat_input
.
value
.
empty?
chatmessage
=
ChatMessage
.
new
(
$game
.
user
,
@chat_input
.
value
,
@channel
)
$game
.
chat
chatmessage
Game_Event
.
push
Game_Event
::
Chat
.
new
(
chatmessage
)
if
$game
.
show_chat_self
Game_Event
.
push
Game_Event
::
Chat
.
new
(
chatmessage
)
#
if $game.show_chat_self
true
end
end
...
...
lib/window_config.rb
View file @
17ae1837
...
...
@@ -42,7 +42,7 @@ class Window_Config < Window
when
:avatar_cache
size
=
0
count
=
0
Dir
.
glob
(
"graphics/avatars/*
_*.png"
)
do
|
file
|
Dir
.
glob
(
"graphics/avatars/*
"
).
reject
{
|
file
|
File
.
basename
(
file
)
=~
/(?:error|loading)_(?:small|middle|large)\.png/
}.
each
do
|
file
|
count
+=
1
size
+=
File
.
size
(
file
)
end
...
...
@@ -105,7 +105,7 @@ class Window_Config < Window
draw_item
(
@index
,
1
)
when
:avatar_cache
#clear(*item_rect(@index))
Dir
.
glob
(
"graphics/avatars/*
_*.png"
)
do
|
file
|
Dir
.
glob
(
"graphics/avatars/*
"
).
reject
{
|
file
|
File
.
basename
(
file
)
=~
/(?:error|loading)_(?:small|middle|large)\.png/
}.
each
do
|
file
|
File
.
delete
file
end
refresh
...
...
lib/window_lobbybuttons.rb
View file @
17ae1837
require_relative
'window_host'
class
Window_LobbyButtons
<
Window_List
def
initialize
(
x
,
y
)
@items
=
[
"常见问题"
,
"卡组编辑"
,
"建立房间"
]
@items
=
[
I18n
.
t
(
'lobby.faq'
),
I18n
.
t
(
'lobby.editdeck'
),
I18n
.
t
(
'lobby.newroom'
)
]
@button
=
Surface
.
load
(
"graphics/lobby/button.png"
)
super
(
x
,
y
,
@items
.
size
*
@button
.
w
/
3
+
@items
.
size
*
4
,
30
)
@font
=
TTF
.
open
(
"fonts/wqy-microhei.ttc"
,
15
)
...
...
@@ -9,9 +9,9 @@ class Window_LobbyButtons < Window_List
end
def
draw_item
(
index
,
status
=
0
)
x
,
y
=
item_rect
(
index
)
x
,
y
,
width
=
item_rect
(
index
)
Surface
.
blit
(
@button
,
status
*
@button
.
w
/
3
,
0
,
@button
.
w
/
3
,
@button
.
h
,
@contents
,
x
,
y
)
draw_stroked_text
(
@items
[
index
],
x
+
8
,
y
+
3
,
2
,
@font
,
[
0xdf
,
0xf1
,
0xff
],
[
0x27
,
0x43
,
0x59
])
draw_stroked_text
(
@items
[
index
],
x
+
center_margin
(
@items
[
index
],
width
,
@font
)
,
y
+
3
,
2
,
@font
,
[
0xdf
,
0xf1
,
0xff
],
[
0x27
,
0x43
,
0x59
])
end
def
item_rect
(
index
)
...
...
lib/window_login.rb
View file @
17ae1837
...
...
@@ -45,23 +45,23 @@ class Window_Login < Window
:replay
=>
[
378
,
200
,
@button
.
w
/
3
,
@button
.
h
]
}
@items_text
=
{
:login
=>
"登录"
,
:register
=>
"注册"
,
:replay
=>
"录像"
:login
=>
I18n
.
t
(
"login.login"
)
,
:register
=>
I18n
.
t
(
"login.register"
)
,
:replay
=>
I18n
.
t
(
"login.replay"
),
}
#self.index = nil
@remember_password
=
Widget_Checkbox
.
new
(
self
,
357
+
@x
,
80
+
@y
,
self
.
width
-
357
,
24
,
password
,
"记住密码"
)
@remember_password
=
Widget_Checkbox
.
new
(
self
,
357
+
@x
,
80
+
@y
,
self
.
width
-
357
,
24
,
password
,
I18n
.
t
(
'login.remember'
)
)
refresh
end
def
refresh
clear
@items
.
each_pair
{
|
index
,
rect
|
draw_item
(
index
,
rect
)}
draw_stroked_text
(
"用户名"
,
105
,
80
+
2
,
1
)
draw_stroked_text
(
"密码"
,
105
,
125
+
2
,
1
)
draw_stroked_text
(
I18n
.
t
(
'login.name'
)
,
105
,
80
+
2
,
1
)
draw_stroked_text
(
I18n
.
t
(
'login.password'
)
,
105
,
125
+
2
,
1
)
end
def
draw_item
(
index
,
rect
,
status
=
0
)
Surface
.
blit
(
@button
,
rect
[
2
]
*
status
,
0
,
rect
[
2
],
rect
[
3
],
@contents
,
rect
[
0
],
rect
[
1
])
draw_stroked_text
(
@items_text
[
index
],
rect
[
0
]
+
24
,
rect
[
1
]
+
9
,
1
,
@font_button
)
draw_stroked_text
(
@items_text
[
index
],
rect
[
0
]
+
center_margin
(
@items_text
[
index
],
rect
[
2
],
@font_button
)
,
rect
[
1
]
+
9
,
1
,
@font_button
)
end
def
mousemoved
(
x
,
y
)
self
.
index
=
@items
.
each_pair
{
|
index
,
rect
|
break
index
if
(
x
-
@x
>=
rect
[
0
]
and
x
-
@x
<
rect
[
0
]
+
rect
[
2
]
and
y
-
@y
>=
rect
[
1
]
and
y
-
@y
<
rect
[
1
]
+
rect
[
3
])}
...
...
lib/window_roomlist.rb
View file @
17ae1837
...
...
@@ -26,10 +26,9 @@ class Window_RoomList < Window_Scrollable
y
=
item_rect
(
index
)[
1
]
room
=
@items
[
index
]
Surface
.
blit
(
@button
,
@width
*
status
,
room
.
full?
?
WLH
:
0
,
@width
,
WLH
,
@contents
,
0
,
y
)
@font
.
draw_blended_utf8
(
@contents
,
room
.
id
.
to_s
,
24
,
y
+
8
,
*
@color
)
@font
.
draw_blended_utf8
(
@contents
,
room
.
id
.
to_s
,
24
,
y
+
8
,
*
@color
)
unless
room
.
id
.
to_s
.
empty?
@font
.
draw_blended_utf8
(
@contents
,
room
.
full?
?
"【决斗中】"
:
room
.
private?
?
"【私密房】"
:
"【等待中】"
,
8
,
y
+
24
,
*
@color
)
@font
.
draw_blended_utf8
(
@contents
,
room
.
name
,
128
,
y
+
8
,
*
room
.
color
)
unless
room
.
name
.
empty?
or
room
.
name
.
size
>
100
$log
.
error
(
'标题过长'
)
{
room
.
name
}
if
room
.
name
.
size
>
100
@font
.
draw_blended_utf8
(
@contents
,
room
.
name
,
128
,
y
+
8
,
*
room
.
color
)
unless
room
.
name
.
nil?
or
room
.
name
.
empty?
or
room
.
name
.
size
>
100
@font
.
draw_blended_utf8
(
@contents
,
room
.
player1
.
name
,
128
,
y
+
24
,
*
room
.
player1
.
color
)
if
room
.
player1
and
!
room
.
player1
.
name
.
empty?
@font
.
draw_blended_utf8
(
@contents
,
room
.
player2
.
name
,
320
,
y
+
24
,
*
room
.
player2
.
color
)
if
room
.
player2
and
!
room
.
player2
.
name
.
empty?
room
.
extra
.
each_with_index
do
|
extra
,
index
|
...
...
lib/ygocore/event.rb
View file @
17ae1837
...
...
@@ -7,20 +7,10 @@ class Game_Event
else
Error
.
new
(
'登录'
,
'用户名或密码错误'
)
end
#when :users
# AllUsers.new data.collect{|user|parse_user(user)}
when
:rooms
rooms_wait
=
[]
rooms_start
=
[]
data
.
each
do
|
room
|
room
=
parse_room
(
room
)
if
room
.
full?
rooms_start
<<
room
else
rooms_wait
<<
room
end
end
AllRooms
.
new
rooms_wait
+
rooms_start
AllRooms
.
new
data
.
collect
{
|
room
|
parse_room
(
room
)}
when
:rooms_update
RoomsUpdate
.
new
data
.
collect
{
|
room
|
parse_room
(
room
)}
#when :newuser
#NewUser.new parse_user data
#when :missinguser
...
...
@@ -29,13 +19,13 @@ class Game_Event
NewRoom
.
new
parse_room
data
when
:missingroom
MissingRoom
.
new
parse_room
data
#
when :chat
#
case data[:channel]
#
when :lobby
#
Chat.new ChatMessage.new User.new(data[:from][:id],data[:from][:name]), data[:message], :lobby
#
else
#
Chat.new ChatMessage.new User.new(data[:from][:id],data[:from][:name]), data[:message], User.new(data[:channel])
#
end
when
:chat
case
data
[
:channel
]
when
:lobby
Chat
.
new
ChatMessage
.
new
User
.
new
(
data
[
:from
][
:id
],
data
[
:from
][
:name
]),
data
[
:message
],
:lobby
else
Chat
.
new
ChatMessage
.
new
User
.
new
(
data
[
:from
][
:id
],
data
[
:from
][
:name
]),
data
[
:message
],
User
.
new
(
data
[
:channel
])
end
end
end
def
self
.
parse_room
(
room
)
...
...
@@ -49,6 +39,11 @@ class Game_Event
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
end
def
self
.
parse_user
(
user
)
...
...
lib/ygocore/game.rb
View file @
17ae1837
This diff is collapsed.
Click to expand it.
lib/ygocore/room.rb
View file @
17ae1837
...
...
@@ -5,6 +5,7 @@ class Room
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
...
...
lib/ygocore/server.yml
View file @
17ae1837
register
:
http://my-card.in/register
api
:
http://
122.0.65.71
:7922/
api
:
http://
master.smdcn.net
:7922/
index
:
http://my-card.in/
server
:
122.0.65.7
1
server
:
122.0.65.7
0
port
:
7911
\ No newline at end of file
lib/ygocore/user.rb
View file @
17ae1837
...
...
@@ -22,13 +22,13 @@ class User
end
def
avatar
(
size
=
:small
)
cache
=
"graphics/avatars/mycard_
#{
@id
}
_
#{
size
}
.png"
result
=
Surface
.
load
(
cache
)
rescue
Surface
.
load
(
"graphics/avatars/loading_
#{
size
}
.
gif
"
)
result
=
Surface
.
load
(
cache
)
rescue
Surface
.
load
(
"graphics/avatars/loading_
#{
size
}
.
png
"
)
scene
=
$scene
if
block_given?
yield
result
Thread
.
new
do
require
'cgi'
open
(
"http://my-card.in/users/
#{
CGI
.
escape
@id
.
to_s
}
.png"
,
'rb'
)
{
|
io
|
open
(
cache
,
'wb'
)
{
|
c
|
c
.
write
io
.
read
}}
rescue
cache
=
"graphics/avatars/
noavatar_
#{
size
}
.gif
"
open
(
"http://my-card.in/users/
#{
CGI
.
escape
@id
.
to_s
}
.png"
,
'rb'
)
{
|
io
|
open
(
cache
,
'wb'
)
{
|
c
|
c
.
write
io
.
read
}}
rescue
cache
=
"graphics/avatars/
error_
#{
size
}
.png
"
(
yield
Surface
.
load
(
cache
)
if
scene
==
$scene
)
rescue
nil
end
else
...
...
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