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
e77701fc
Commit
e77701fc
authored
Dec 20, 2012
by
神楽坂玲奈
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
0.8.5, xmpp
parent
ff51a04b
Changes
8
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
466 additions
and
459 deletions
+466
-459
Rakefile
Rakefile
+1
-1
lib/main.rb
lib/main.rb
+134
-134
lib/scene_lobby.rb
lib/scene_lobby.rb
+1
-1
lib/update.rb
lib/update.rb
+1
-1
lib/window_chat.rb
lib/window_chat.rb
+175
-175
lib/window_userinfo.rb
lib/window_userinfo.rb
+35
-35
lib/ygocore/event.rb
lib/ygocore/event.rb
+6
-6
lib/ygocore/game.rb
lib/ygocore/game.rb
+113
-106
No files found.
Rakefile
View file @
e77701fc
...
...
@@ -20,7 +20,7 @@ end
spec
=
Gem
::
Specification
.
new
do
|
s
|
s
.
name
=
'mycard'
s
.
version
=
'0.8.
4
'
s
.
version
=
'0.8.
5
'
s
.
extra_rdoc_files
=
[
'README.txt'
,
'LICENSE.txt'
]
s
.
summary
=
'a card game'
s
.
description
=
s
.
summary
...
...
lib/main.rb
View file @
e77701fc
#!/usr/bin/env ruby
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'
require_relative
'announcement'
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_level
=
"INFO"
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
end
end
unless
$scene
==
false
#加载文件
require
'logger'
require
'sdl'
include
SDL
require_relative
'dialog'
require_relative
'graphics'
require_relative
'window'
require_relative
'widget_msgbox'
#日志
if
log
==
"STDOUT"
#调试用
log
=
STDOUT
end
$log
=
Logger
.
new
(
log
)
$log
.
level
=
Logger
.
const_get
log_level
#性能分析
if
profile
if
profile
==
"STDOUT"
profile
=
STDOUT
else
profile
=
open
(
profile
,
'w'
)
end
require
'profiler'
RubyVM
::
InstructionSequence
.
compile_option
=
{
:trace_instruction
=>
true
,
:specialized_instruction
=>
false
}
Profiler__
::
start_profile
end
SDL
::
Event
::
APPMOUSEFOCUS
=
1
SDL
::
Event
::
APPINPUTFOCUS
=
2
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
))
TTF
.
init
#声音
begin
SDL
.
init
(
INIT_AUDIO
)
Mixer
.
open
(
Mixer
::
DEFAULT_FREQUENCY
,
Mixer
::
DEFAULT_FORMAT
,
Mixer
::
DEFAULT_CHANNELS
,
1536
)
Mixer
.
set_volume_music
(
60
)
rescue
nil
end
#标题场景
require_relative
'scene_title'
$scene
=
Scene_Title
.
new
#自动更新, 加载放到SDL前面会崩, 原因不明
require_relative
'update'
Update
.
start
WM
::
set_caption
(
"MyCard v
#{
Update
::
Version
}
"
,
"MyCard"
)
#文件关联
Association
.
start
#初始化完毕
$log
.
info
(
"main"
)
{
"初始化成功"
}
end
rescue
Exception
=>
exception
open
(
'error-程序出错请到论坛反馈.txt'
,
'w'
)
{
|
f
|
f
.
write
[
exception
.
inspect
,
*
exception
.
backtrace
].
join
(
"
\n
"
)
}
$scene
=
false
end
#主循环
begin
$scene
.
main
while
$scene
rescue
Exception
=>
exception
exception
.
backtrace
.
each
{
|
backtrace
|
break
if
backtrace
=~
/^(.*)\.rb:\d+:in `.*'"$/
}
#由于脚本是从main.rb开始执行的,总会有个能匹配成功的文件
$log
.
fatal
(
$1
)
{
[
exception
.
inspect
,
*
exception
.
backtrace
].
collect
{
|
str
|
str
.
force_encoding
(
"UTF-8"
)
}.
join
(
"
\n
"
)
}
$game
.
exit
if
$game
require_relative
'scene_error'
$scene
=
Scene_Error
.
new
retry
ensure
if
profile
Profiler__
::
print_profile
(
profile
)
profile
.
close
end
$log
.
close
rescue
nil
#!/usr/bin/env ruby
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'
require_relative
'announcement'
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_level
=
"INFO"
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
end
end
unless
$scene
==
false
#加载文件
require
'logger'
require
'sdl'
include
SDL
require_relative
'dialog'
require_relative
'graphics'
require_relative
'window'
require_relative
'widget_msgbox'
#日志
if
log
==
"STDOUT"
#调试用
log
=
STDOUT
end
$log
=
Logger
.
new
(
log
,
1
,
1024000
)
$log
.
level
=
Logger
.
const_get
log_level
#性能分析
if
profile
if
profile
==
"STDOUT"
profile
=
STDOUT
else
profile
=
open
(
profile
,
'w'
)
end
require
'profiler'
RubyVM
::
InstructionSequence
.
compile_option
=
{
:trace_instruction
=>
true
,
:specialized_instruction
=>
false
}
Profiler__
::
start_profile
end
SDL
::
Event
::
APPMOUSEFOCUS
=
1
SDL
::
Event
::
APPINPUTFOCUS
=
2
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
))
TTF
.
init
#声音
begin
SDL
.
init
(
INIT_AUDIO
)
Mixer
.
open
(
Mixer
::
DEFAULT_FREQUENCY
,
Mixer
::
DEFAULT_FORMAT
,
Mixer
::
DEFAULT_CHANNELS
,
1536
)
Mixer
.
set_volume_music
(
60
)
rescue
nil
end
#标题场景
require_relative
'scene_title'
$scene
=
Scene_Title
.
new
#自动更新, 加载放到SDL前面会崩, 原因不明
require_relative
'update'
Update
.
start
WM
::
set_caption
(
"MyCard v
#{
Update
::
Version
}
"
,
"MyCard"
)
#文件关联
Association
.
start
#初始化完毕
$log
.
info
(
"main"
)
{
"初始化成功"
}
end
rescue
Exception
=>
exception
open
(
'error-程序出错请到论坛反馈.txt'
,
'w'
)
{
|
f
|
f
.
write
[
exception
.
inspect
,
*
exception
.
backtrace
].
join
(
"
\n
"
)
}
$scene
=
false
end
#主循环
begin
$scene
.
main
while
$scene
rescue
Exception
=>
exception
exception
.
backtrace
.
each
{
|
backtrace
|
break
if
backtrace
=~
/^(.*)\.rb:\d+:in `.*'"$/
}
#由于脚本是从main.rb开始执行的,总会有个能匹配成功的文件
$log
.
fatal
(
$1
)
{
[
exception
.
inspect
,
*
exception
.
backtrace
].
collect
{
|
str
|
str
.
force_encoding
(
"UTF-8"
)
}.
join
(
"
\n
"
)
}
$game
.
exit
if
$game
require_relative
'scene_error'
$scene
=
Scene_Error
.
new
retry
ensure
if
profile
Profiler__
::
print_profile
(
profile
)
profile
.
close
end
$log
.
close
rescue
nil
end
\ No newline at end of file
lib/scene_lobby.rb
View file @
e77701fc
...
...
@@ -66,7 +66,7 @@ class Scene_Lobby < Scene
when
Game_Event
::
AllUsers
@userlist
.
items
=
$game
.
users
when
Game_Event
::
AllRooms
,
Game_Event
::
AllServers
@roomlist
.
items
=
p
$game
.
rooms
.
find_all
{
|
room
|
@roomlist
.
items
=
$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 @
e77701fc
...
...
@@ -2,7 +2,7 @@ require 'open-uri'
require
"fileutils"
require_relative
'card'
module
Update
Version
=
'0.8.
4
'
Version
=
'0.8.
5
'
URL
=
"http://my-card.in/mycard/update.json?version=
#{
Version
}
"
class
<<
self
attr_reader
:thumbnails
,
:images
,
:status
...
...
lib/window_chat.rb
View file @
e77701fc
This diff is collapsed.
Click to expand it.
lib/window_userinfo.rb
View file @
e77701fc
#encoding: UTF-8
#==============================================================================
# Window_UserInfo
#------------------------------------------------------------------------------
# 游戏大厅显示用户信息的类
#==============================================================================
class
Window_UserInfo
<
Window
def
initialize
(
x
,
y
,
user
)
@avatar_boarder
=
Surface
.
load
(
"graphics/lobby/avatar_boader.png"
)
super
(
x
,
y
,
280
,
144
)
@font
=
TTF
.
open
(
'fonts/wqy-microhei.ttc'
,
16
)
@user
=
user
@background
=
Surface
.
load
(
"graphics/lobby/userinfo.png"
).
display_format
refresh
end
def
refresh
@contents
.
put
(
@background
,
0
,
0
)
@thread
=
@user
.
avatar
(
:middle
)
do
|
avatar
|
clear
(
0
,
0
,
@avatar_boarder
.
w
,
@avatar_boarder
.
h
)
@contents
.
put
(
avatar
,
12
,
12
)
@contents
.
put
(
@avatar_boarder
,
0
,
0
)
end
@font
.
draw_blended_utf8
(
@contents
,
@user
.
name
,
160
,
12
,
0x00
,
0x00
,
0x00
)
unless
@user
.
name
.
empty?
@font
.
draw_blended_utf8
(
@contents
,
"id:
#{
@user
.
id
}
"
,
160
,
12
+
16
*
2
,
0x00
,
0x00
,
0x00
)
@font
.
draw_blended_utf8
(
@contents
,
"Lv:
#{
@user
.
level
}
"
,
160
,
12
+
16
*
3
,
0x00
,
0x00
,
0x00
)
if
@user
.
respond_to?
:level
and
@user
.
level
#TODO:规范化,level是iduel专属的,但是又不太想让iduel来重定义这个window
@font
.
draw_blended_utf8
(
@contents
,
"经验:
#{
@user
.
exp
}
"
,
160
,
12
+
16
*
4
,
0x00
,
0x00
,
0x00
)
if
@user
.
respond_to?
:exp
and
@user
.
exp
end
def
dispose
@thread
.
exit
super
end
end
#encoding: UTF-8
#==============================================================================
# Window_UserInfo
#------------------------------------------------------------------------------
# 游戏大厅显示用户信息的类
#==============================================================================
class
Window_UserInfo
<
Window
def
initialize
(
x
,
y
,
user
)
@avatar_boarder
=
Surface
.
load
(
"graphics/lobby/avatar_boader.png"
)
super
(
x
,
y
,
280
,
144
)
@font
=
TTF
.
open
(
'fonts/wqy-microhei.ttc'
,
16
)
@user
=
user
@background
=
Surface
.
load
(
"graphics/lobby/userinfo.png"
).
display_format
refresh
end
def
refresh
@contents
.
put
(
@background
,
0
,
0
)
@thread
=
@user
.
avatar
(
:middle
)
do
|
avatar
|
clear
(
0
,
0
,
@avatar_boarder
.
w
,
@avatar_boarder
.
h
)
@contents
.
put
(
avatar
,
12
,
12
)
@contents
.
put
(
@avatar_boarder
,
0
,
0
)
end
@font
.
draw_blended_utf8
(
@contents
,
@user
.
name
,
160
,
12
,
0x00
,
0x00
,
0x00
)
unless
@user
.
name
.
empty?
@font
.
draw_blended_utf8
(
@contents
,
@user
.
id
.
to_s
,
160
,
12
+
16
*
2
,
0x00
,
0x00
,
0x00
)
unless
@user
.
id
.
to_s
.
empty?
@font
.
draw_blended_utf8
(
@contents
,
"Lv:
#{
@user
.
level
}
"
,
160
,
12
+
16
*
3
,
0x00
,
0x00
,
0x00
)
if
@user
.
respond_to?
:level
and
@user
.
level
#TODO:规范化,level是iduel专属的,但是又不太想让iduel来重定义这个window
@font
.
draw_blended_utf8
(
@contents
,
"经验:
#{
@user
.
exp
}
"
,
160
,
12
+
16
*
4
,
0x00
,
0x00
,
0x00
)
if
@user
.
respond_to?
:exp
and
@user
.
exp
end
def
dispose
@thread
.
exit
super
end
end
lib/ygocore/event.rb
View file @
e77701fc
class
Game_Event
def
self
.
parse
(
header
,
data
)
case
header
when
:login
if
data
Login
.
new
parse_user
data
else
Error
.
new
(
'登录'
,
'用户名或密码错误'
)
end
#
when :login
#
if data
#
Login.new parse_user data
#
else
#
Error.new('登录', '用户名或密码错误')
#
end
#when :rooms
#AllRooms.new data.collect{|room|parse_room(room)}
#when :rooms_update
...
...
lib/ygocore/game.rb
View file @
e77701fc
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