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
c1878166
Commit
c1878166
authored
Feb 25, 2013
by
神楽坂玲奈
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avatar and match
parent
c95825ee
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
133 additions
and
112 deletions
+133
-112
lib/scene_lobby.rb
lib/scene_lobby.rb
+1
-1
lib/update.rb
lib/update.rb
+1
-1
lib/window_lobbybuttons.rb
lib/window_lobbybuttons.rb
+27
-2
lib/ygocore/game.rb
lib/ygocore/game.rb
+95
-106
lib/ygocore/user.rb
lib/ygocore/user.rb
+9
-2
No files found.
lib/scene_lobby.rb
View file @
c1878166
...
@@ -25,7 +25,7 @@ class Scene_Lobby < Scene
...
@@ -25,7 +25,7 @@ class Scene_Lobby < Scene
@userlist
=
Window_UserList
.
new
(
24
,
204
,
$game
.
users
)
@userlist
=
Window_UserList
.
new
(
24
,
204
,
$game
.
users
)
@roomlist
=
Window_RoomList
.
new
(
320
,
50
,
$game
.
rooms
)
@roomlist
=
Window_RoomList
.
new
(
320
,
50
,
$game
.
rooms
)
@userinfo
=
Window_UserInfo
.
new
(
24
,
24
,
$game
.
user
)
@userinfo
=
Window_UserInfo
.
new
(
24
,
24
,
$game
.
user
)
@host_window
=
Window_LobbyButtons
.
new
(
678
,
18
)
@host_window
=
Window_LobbyButtons
.
new
(
595
,
18
)
@active_window
=
@roomlist
@active_window
=
@roomlist
@chat_window
=
Window_Chat
.
new
(
313
,
$config
[
'screen'
][
'height'
]
-
225
,
698
,
212
)
@chat_window
=
Window_Chat
.
new
(
313
,
$config
[
'screen'
][
'height'
]
-
225
,
698
,
212
)
@count
=
0
@count
=
0
...
...
lib/update.rb
View file @
c1878166
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
require
"fileutils"
require
"fileutils"
require_relative
'card'
require_relative
'card'
module
Update
module
Update
Version
=
'0.9.
4
'
Version
=
'0.9.
6
'
URL
=
"http://my-card.in/mycard/update.json?version=
#{
Version
}
"
URL
=
"http://my-card.in/mycard/update.json?version=
#{
Version
}
"
class
<<
self
class
<<
self
attr_reader
:thumbnails
,
:images
,
:status
attr_reader
:thumbnails
,
:images
,
:status
...
...
lib/window_lobbybuttons.rb
View file @
c1878166
require_relative
'window_host'
require_relative
'window_host'
class
Window_LobbyButtons
<
Window_List
class
Window_LobbyButtons
<
Window_List
def
initialize
(
x
,
y
)
def
initialize
(
x
,
y
)
@items
=
[
I18n
.
t
(
'lobby.faq'
),
I18n
.
t
(
'lobby.filter'
),
I18n
.
t
(
'lobby.editdeck'
),
I18n
.
t
(
'lobby.newroom'
)]
@items
=
[
I18n
.
t
(
'lobby.faq'
),
I18n
.
t
(
'lobby.filter'
),
I18n
.
t
(
'lobby.editdeck'
),
I18n
.
t
(
'lobby.newroom'
)
,
"自动匹配"
]
@button
=
Surface
.
load
(
"graphics/lobby/button.png"
)
@button
=
Surface
.
load
(
"graphics/lobby/button.png"
)
super
(
x
,
y
,
@items
.
size
*
@button
.
w
/
3
+
@items
.
size
*
4
,
30
)
super
(
x
,
y
,
@items
.
size
*
@button
.
w
/
3
+
@items
.
size
*
4
,
30
)
@font
=
TTF
.
open
(
"fonts/wqy-microhei.ttc"
,
15
)
@font
=
TTF
.
open
(
"fonts/wqy-microhei.ttc"
,
15
)
...
@@ -11,7 +11,7 @@ class Window_LobbyButtons < Window_List
...
@@ -11,7 +11,7 @@ class Window_LobbyButtons < Window_List
def
draw_item
(
index
,
status
=
0
)
def
draw_item
(
index
,
status
=
0
)
x
,
y
,
width
=
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
)
Surface
.
blit
(
@button
,
status
*
@button
.
w
/
3
,
0
,
@button
.
w
/
3
,
@button
.
h
,
@contents
,
x
,
y
)
draw_stroked_text
(
@items
[
index
],
x
+
center_margin
(
@items
[
index
],
width
,
@font
),
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
end
def
item_rect
(
index
)
def
item_rect
(
index
)
...
@@ -46,10 +46,35 @@ class Window_LobbyButtons < Window_List
...
@@ -46,10 +46,35 @@ class Window_LobbyButtons < Window_List
$game
.
class
.
deck_edit
$game
.
class
.
deck_edit
when
3
#建立房间
when
3
#建立房间
@host_window
=
Window_Host
.
new
(
300
,
200
)
@host_window
=
Window_Host
.
new
(
300
,
200
)
when
4
#自动匹配
return
if
@waiting
@waiting
=
true
waiting_window
=
Widget_Msgbox
.
new
(
"自动匹配"
,
"正在等待对手"
)
require
'open-uri'
Thread
.
new
{
begin
open
(
'http://mycard-server.my-card.in:9997/match.json'
)
{
|
f
|
@waiting
=
false
if
f
.
read
=~
/^mycard:\/\/([\d\.]+):(\d+)\/(.*)$/
room
=
Room
.
new
(
0
,
$3
.
to_s
)
room
.
server
=
Server
.
new
(
nil
,
nil
,
$1
,
$2
.
to_i
,
false
)
$game
.
join
(
room
)
else
$log
.
error
(
'自动匹配非法回复'
){
f
.
read
}
Widget_Msgbox
.
new
(
"自动匹配"
,
"错误:
#{
exception
}
"
,
ok:
"确定"
)
end
}
rescue
Exception
=>
exception
@waiting
=
false
$log
.
error
(
'自动匹配出错'
){
exception
}
Widget_Msgbox
.
new
(
"自动匹配"
,
"匹配失败:
#{
exception
}
"
,
ok:
"确定"
)
end
}
end
end
end
end
def
update
def
update
@host_window
.
update
if
@host_window
and
!
@host_window
.
destroyed?
@host_window
.
update
if
@host_window
and
!
@host_window
.
destroyed?
end
end
end
end
lib/ygocore/game.rb
View file @
c1878166
...
@@ -48,12 +48,6 @@ class Ygocore < Game
...
@@ -48,12 +48,6 @@ class Ygocore < Game
$log
.
error
(
'聊天出错'
)
{
[
exception
,
c
,
where
]
}
$log
.
error
(
'聊天出错'
)
{
[
exception
,
c
,
where
]
}
Game_Event
.
push
(
Game_Event
::
Chat
.
new
(
ChatMessage
.
new
(
User
.
new
(
:system
,
'System'
),
'聊天服务连接中断: '
+
exception
.
to_s
)))
Game_Event
.
push
(
Game_Event
::
Chat
.
new
(
ChatMessage
.
new
(
User
.
new
(
:system
,
'System'
),
'聊天服务连接中断: '
+
exception
.
to_s
)))
end
end
@@im
.
add_message_callback
do
|
m
|
p
m
end
@@im
.
add_presence_callback
do
|
m
|
p
m
end
@@im_room
.
add_message_callback
do
|
m
|
@@im_room
.
add_message_callback
do
|
m
|
user
=
m
.
from
.
resource
==
nickname
?
@user
:
User
.
new
(
m
.
from
.
resource
.
to_sym
,
m
.
from
.
resource
)
user
=
m
.
from
.
resource
==
nickname
?
@user
:
User
.
new
(
m
.
from
.
resource
.
to_sym
,
m
.
from
.
resource
)
Game_Event
.
push
Game_Event
::
Chat
.
new
ChatMessage
.
new
(
user
,
m
.
body
,
:lobby
)
rescue
$log
.
error
(
'收到聊天消息'
)
{
$!
}
Game_Event
.
push
Game_Event
::
Chat
.
new
ChatMessage
.
new
(
user
,
m
.
body
,
:lobby
)
rescue
$log
.
error
(
'收到聊天消息'
)
{
$!
}
...
@@ -126,13 +120,8 @@ class Ygocore < Game
...
@@ -126,13 +120,8 @@ class Ygocore < Game
connected
=
false
connected
=
false
if
@@im
.
jid
.
domain
==
"my-card.in"
if
@@im
.
jid
.
domain
==
"my-card.in"
begin
@@im
.
connect
(
"ygopro-server.my-card.in"
,
5223
)
rescue
Game_Event
.
push
Game_Event
::
Error
.
new
(
'登录'
,
'连接服务器失败'
)
@@im
.
connect
(
"chat.my-card.in"
,
5223
)
connected
=
true
connected
=
true
rescue
Game_Event
.
push
Game_Event
::
Error
.
new
(
'登录'
,
'连接服务器失败'
)
Thread
.
exit
end
else
else
srv
=
[]
srv
=
[]
Resolv
::
DNS
.
open
{
|
dns
|
Resolv
::
DNS
.
open
{
|
dns
|
...
...
lib/ygocore/user.rb
View file @
c1878166
...
@@ -21,14 +21,21 @@ class User
...
@@ -21,14 +21,21 @@ class User
end
end
end
end
def
avatar
(
size
=
:small
)
def
avatar
(
size
=
:small
)
cache
=
"graphics/avatars/mycard_
#{
@id
}
_
#{
size
}
.png"
id
=
(
@id
.
respond_to?
(
:bare
)
?
@id
.
bare
:
@id
).
to_s
cache
=
"graphics/avatars/mycard_
#{
id
}
_
#{
size
}
.png"
result
=
Surface
.
load
(
cache
)
rescue
Surface
.
load
(
"graphics/avatars/loading_
#{
size
}
.png"
)
result
=
Surface
.
load
(
cache
)
rescue
Surface
.
load
(
"graphics/avatars/loading_
#{
size
}
.png"
)
scene
=
$scene
scene
=
$scene
if
block_given?
if
block_given?
yield
result
yield
result
Thread
.
new
do
Thread
.
new
do
require
'cgi'
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/error_
#{
size
}
.png"
$log
.
info
(
'读取头像'
){
"http://my-card.in/users/
#{
CGI
.
escape
id
.
to_s
}
.png"
}
begin
open
(
"http://my-card.in/users/
#{
CGI
.
escape
id
.
to_s
}
.png"
,
'rb'
)
{
|
io
|
open
(
cache
,
'wb'
)
{
|
c
|
c
.
write
io
.
read
}}
rescue
Exception
=>
exception
$log
.
error
(
'下载头像'
){[
exception
.
inspect
,
*
exception
.
backtrace
].
join
(
"
\n
"
).
force_encoding
(
"UTF-8"
)}
cache
=
"graphics/avatars/error_
#{
size
}
.png"
end
(
yield
Surface
.
load
(
cache
)
if
scene
==
$scene
)
rescue
nil
(
yield
Surface
.
load
(
cache
)
if
scene
==
$scene
)
rescue
nil
end
end
else
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