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
...
@@ -20,7 +20,7 @@ end
spec
=
Gem
::
Specification
.
new
do
|
s
|
spec
=
Gem
::
Specification
.
new
do
|
s
|
s
.
name
=
'mycard'
s
.
name
=
'mycard'
s
.
version
=
'0.8.
4
'
s
.
version
=
'0.8.
5
'
s
.
extra_rdoc_files
=
[
'README.txt'
,
'LICENSE.txt'
]
s
.
extra_rdoc_files
=
[
'README.txt'
,
'LICENSE.txt'
]
s
.
summary
=
'a card game'
s
.
summary
=
'a card game'
s
.
description
=
s
.
summary
s
.
description
=
s
.
summary
...
...
lib/main.rb
View file @
e77701fc
#!/usr/bin/env ruby
#!/usr/bin/env ruby
begin
begin
Windows
=
RUBY_PLATFORM
[
"win"
]
||
RUBY_PLATFORM
[
"ming"
]
Windows
=
RUBY_PLATFORM
[
"win"
]
||
RUBY_PLATFORM
[
"ming"
]
Dir
.
glob
(
'post_update_*.rb'
).
sort
.
each
{
|
file
|
load
file
}
Dir
.
glob
(
'post_update_*.rb'
).
sort
.
each
{
|
file
|
load
file
}
Thread
.
abort_on_exception
=
true
Thread
.
abort_on_exception
=
true
require_relative
'resolution'
require_relative
'resolution'
require_relative
'announcement'
require_relative
'announcement'
require_relative
'config'
require_relative
'config'
require_relative
'association'
require_relative
'association'
#i18n
#i18n
require
'i18n'
require
'i18n'
require
'locale'
require
'locale'
I18n
.
load_path
+=
Dir
[
'locales/*.yml'
]
I18n
.
load_path
+=
Dir
[
'locales/*.yml'
]
I18n
::
Backend
::
Simple
.
include
(
I18n
::
Backend
::
Fallbacks
)
I18n
::
Backend
::
Simple
.
include
(
I18n
::
Backend
::
Fallbacks
)
#读取配置文件
#读取配置文件
$config
=
Config
.
load
$config
=
Config
.
load
Config
.
save
Config
.
save
#读取命令行参数
#读取命令行参数
log
=
"log.log"
log
=
"log.log"
log_level
=
"INFO"
log_level
=
"INFO"
profile
=
nil
profile
=
nil
ARGV
.
each
do
|
arg
|
ARGV
.
each
do
|
arg
|
arg
=
arg
.
dup
.
force_encoding
(
"UTF-8"
)
arg
=
arg
.
dup
.
force_encoding
(
"UTF-8"
)
arg
.
force_encoding
(
"GBK"
)
unless
arg
.
valid_encoding?
arg
.
force_encoding
(
"GBK"
)
unless
arg
.
valid_encoding?
case
arg
case
arg
when
/--log=(.*)/
when
/--log=(.*)/
log
.
replace
$1
log
.
replace
$1
when
/--log-level=(.*)/
when
/--log-level=(.*)/
log_level
.
replace
$1
log_level
.
replace
$1
when
/--profile=(.*)/
when
/--profile=(.*)/
profile
=
$1
profile
=
$1
when
/^mycard:.*|\.ydk$|\.yrp$|\.deck$/
when
/^mycard:.*|\.ydk$|\.yrp$|\.deck$/
require_relative
'quickstart'
require_relative
'quickstart'
$scene
=
false
$scene
=
false
when
/register_association/
when
/register_association/
Association
.
register
Association
.
register
$scene
=
false
$scene
=
false
end
end
end
end
unless
$scene
==
false
unless
$scene
==
false
#加载文件
#加载文件
require
'logger'
require
'logger'
require
'sdl'
require
'sdl'
include
SDL
include
SDL
require_relative
'dialog'
require_relative
'dialog'
require_relative
'graphics'
require_relative
'graphics'
require_relative
'window'
require_relative
'window'
require_relative
'widget_msgbox'
require_relative
'widget_msgbox'
#日志
#日志
if
log
==
"STDOUT"
#调试用
if
log
==
"STDOUT"
#调试用
log
=
STDOUT
log
=
STDOUT
end
end
$log
=
Logger
.
new
(
log
)
$log
=
Logger
.
new
(
log
,
1
,
1024000
)
$log
.
level
=
Logger
.
const_get
log_level
$log
.
level
=
Logger
.
const_get
log_level
#性能分析
#性能分析
if
profile
if
profile
if
profile
==
"STDOUT"
if
profile
==
"STDOUT"
profile
=
STDOUT
profile
=
STDOUT
else
else
profile
=
open
(
profile
,
'w'
)
profile
=
open
(
profile
,
'w'
)
end
end
require
'profiler'
require
'profiler'
RubyVM
::
InstructionSequence
.
compile_option
=
{
RubyVM
::
InstructionSequence
.
compile_option
=
{
:trace_instruction
=>
true
,
:trace_instruction
=>
true
,
:specialized_instruction
=>
false
:specialized_instruction
=>
false
}
}
Profiler__
::
start_profile
Profiler__
::
start_profile
end
end
SDL
::
Event
::
APPMOUSEFOCUS
=
1
SDL
::
Event
::
APPMOUSEFOCUS
=
1
SDL
::
Event
::
APPINPUTFOCUS
=
2
SDL
::
Event
::
APPINPUTFOCUS
=
2
SDL
::
Event
::
APPACTIVE
=
4
SDL
::
Event
::
APPACTIVE
=
4
SDL
.
putenv
(
"SDL_VIDEO_CENTERED=1"
);
SDL
.
putenv
(
"SDL_VIDEO_CENTERED=1"
);
SDL
.
init
(
INIT_VIDEO
)
SDL
.
init
(
INIT_VIDEO
)
WM
::
set_caption
(
"MyCard"
,
"MyCard"
)
WM
::
set_caption
(
"MyCard"
,
"MyCard"
)
WM
::
icon
=
Surface
.
load
(
"graphics/system/icon.gif"
)
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
TTF
.
init
#声音
#声音
begin
begin
SDL
.
init
(
INIT_AUDIO
)
SDL
.
init
(
INIT_AUDIO
)
Mixer
.
open
(
Mixer
::
DEFAULT_FREQUENCY
,
Mixer
::
DEFAULT_FORMAT
,
Mixer
::
DEFAULT_CHANNELS
,
1536
)
Mixer
.
open
(
Mixer
::
DEFAULT_FREQUENCY
,
Mixer
::
DEFAULT_FORMAT
,
Mixer
::
DEFAULT_CHANNELS
,
1536
)
Mixer
.
set_volume_music
(
60
)
Mixer
.
set_volume_music
(
60
)
rescue
rescue
nil
nil
end
end
#标题场景
#标题场景
require_relative
'scene_title'
require_relative
'scene_title'
$scene
=
Scene_Title
.
new
$scene
=
Scene_Title
.
new
#自动更新, 加载放到SDL前面会崩, 原因不明
#自动更新, 加载放到SDL前面会崩, 原因不明
require_relative
'update'
require_relative
'update'
Update
.
start
Update
.
start
WM
::
set_caption
(
"MyCard v
#{
Update
::
Version
}
"
,
"MyCard"
)
WM
::
set_caption
(
"MyCard v
#{
Update
::
Version
}
"
,
"MyCard"
)
#文件关联
#文件关联
Association
.
start
Association
.
start
#初始化完毕
#初始化完毕
$log
.
info
(
"main"
)
{
"初始化成功"
}
$log
.
info
(
"main"
)
{
"初始化成功"
}
end
end
rescue
Exception
=>
exception
rescue
Exception
=>
exception
open
(
'error-程序出错请到论坛反馈.txt'
,
'w'
)
{
|
f
|
f
.
write
[
exception
.
inspect
,
*
exception
.
backtrace
].
join
(
"
\n
"
)
}
open
(
'error-程序出错请到论坛反馈.txt'
,
'w'
)
{
|
f
|
f
.
write
[
exception
.
inspect
,
*
exception
.
backtrace
].
join
(
"
\n
"
)
}
$scene
=
false
$scene
=
false
end
end
#主循环
#主循环
begin
begin
$scene
.
main
while
$scene
$scene
.
main
while
$scene
rescue
Exception
=>
exception
rescue
Exception
=>
exception
exception
.
backtrace
.
each
{
|
backtrace
|
break
if
backtrace
=~
/^(.*)\.rb:\d+:in `.*'"$/
}
#由于脚本是从main.rb开始执行的,总会有个能匹配成功的文件
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
"
)
}
$log
.
fatal
(
$1
)
{
[
exception
.
inspect
,
*
exception
.
backtrace
].
collect
{
|
str
|
str
.
force_encoding
(
"UTF-8"
)
}.
join
(
"
\n
"
)
}
$game
.
exit
if
$game
$game
.
exit
if
$game
require_relative
'scene_error'
require_relative
'scene_error'
$scene
=
Scene_Error
.
new
$scene
=
Scene_Error
.
new
retry
retry
ensure
ensure
if
profile
if
profile
Profiler__
::
print_profile
(
profile
)
Profiler__
::
print_profile
(
profile
)
profile
.
close
profile
.
close
end
end
$log
.
close
rescue
nil
$log
.
close
rescue
nil
end
end
\ No newline at end of file
lib/scene_lobby.rb
View file @
e77701fc
...
@@ -66,7 +66,7 @@ class Scene_Lobby < Scene
...
@@ -66,7 +66,7 @@ class Scene_Lobby < Scene
when
Game_Event
::
AllUsers
when
Game_Event
::
AllUsers
@userlist
.
items
=
$game
.
users
@userlist
.
items
=
$game
.
users
when
Game_Event
::
AllRooms
,
Game_Event
::
AllServers
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
[
:servers
].
include?
(
room
.
server
)
and
$game
.
filter
[
:waiting_only
]
?
(
room
.
status
==
:
wait
)
:
true
and
$game
.
filter
[
:waiting_only
]
?
(
room
.
status
==
:
wait
)
:
true
and
$game
.
filter
[
:normal_only
]
?
(
!
room
.
tag?
&&
(
room
.
ot
==
0
)
&&
(
room
.
lp
=
8000
))
:
true
$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'
...
@@ -2,7 +2,7 @@ require 'open-uri'
require
"fileutils"
require
"fileutils"
require_relative
'card'
require_relative
'card'
module
Update
module
Update
Version
=
'0.8.
4
'
Version
=
'0.8.
5
'
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_chat.rb
View file @
e77701fc
This diff is collapsed.
Click to expand it.
lib/window_userinfo.rb
View file @
e77701fc
#encoding: UTF-8
#encoding: UTF-8
#==============================================================================
#==============================================================================
# Window_UserInfo
# Window_UserInfo
#------------------------------------------------------------------------------
#------------------------------------------------------------------------------
# 游戏大厅显示用户信息的类
# 游戏大厅显示用户信息的类
#==============================================================================
#==============================================================================
class
Window_UserInfo
<
Window
class
Window_UserInfo
<
Window
def
initialize
(
x
,
y
,
user
)
def
initialize
(
x
,
y
,
user
)
@avatar_boarder
=
Surface
.
load
(
"graphics/lobby/avatar_boader.png"
)
@avatar_boarder
=
Surface
.
load
(
"graphics/lobby/avatar_boader.png"
)
super
(
x
,
y
,
280
,
144
)
super
(
x
,
y
,
280
,
144
)
@font
=
TTF
.
open
(
'fonts/wqy-microhei.ttc'
,
16
)
@font
=
TTF
.
open
(
'fonts/wqy-microhei.ttc'
,
16
)
@user
=
user
@user
=
user
@background
=
Surface
.
load
(
"graphics/lobby/userinfo.png"
).
display_format
@background
=
Surface
.
load
(
"graphics/lobby/userinfo.png"
).
display_format
refresh
refresh
end
end
def
refresh
def
refresh
@contents
.
put
(
@background
,
0
,
0
)
@contents
.
put
(
@background
,
0
,
0
)
@thread
=
@user
.
avatar
(
:middle
)
do
|
avatar
|
@thread
=
@user
.
avatar
(
:middle
)
do
|
avatar
|
clear
(
0
,
0
,
@avatar_boarder
.
w
,
@avatar_boarder
.
h
)
clear
(
0
,
0
,
@avatar_boarder
.
w
,
@avatar_boarder
.
h
)
@contents
.
put
(
avatar
,
12
,
12
)
@contents
.
put
(
avatar
,
12
,
12
)
@contents
.
put
(
@avatar_boarder
,
0
,
0
)
@contents
.
put
(
@avatar_boarder
,
0
,
0
)
end
end
@font
.
draw_blended_utf8
(
@contents
,
@user
.
name
,
160
,
12
,
0x00
,
0x00
,
0x00
)
unless
@user
.
name
.
empty?
@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
,
@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
,
"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
@font
.
draw_blended_utf8
(
@contents
,
"经验:
#{
@user
.
exp
}
"
,
160
,
12
+
16
*
4
,
0x00
,
0x00
,
0x00
)
if
@user
.
respond_to?
:exp
and
@user
.
exp
end
end
def
dispose
def
dispose
@thread
.
exit
@thread
.
exit
super
super
end
end
end
end
lib/ygocore/event.rb
View file @
e77701fc
class
Game_Event
class
Game_Event
def
self
.
parse
(
header
,
data
)
def
self
.
parse
(
header
,
data
)
case
header
case
header
when
:login
#
when :login
if
data
#
if data
Login
.
new
parse_user
data
#
Login.new parse_user data
else
#
else
Error
.
new
(
'登录'
,
'用户名或密码错误'
)
#
Error.new('登录', '用户名或密码错误')
end
#
end
#when :rooms
#when :rooms
#AllRooms.new data.collect{|room|parse_room(room)}
#AllRooms.new data.collect{|room|parse_room(room)}
#when :rooms_update
#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