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
2769226b
Commit
2769226b
authored
Feb 29, 2012
by
神楽坂玲奈
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
各种微调
parent
e7b944ad
Changes
13
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
96 additions
and
46 deletions
+96
-46
Rakefile
Rakefile
+19
-3
lib/action.rb
lib/action.rb
+0
-1
lib/iduel/action.rb
lib/iduel/action.rb
+1
-1
lib/iduel/replay.rb
lib/iduel/replay.rb
+6
-7
lib/main.rb
lib/main.rb
+1
-0
lib/nbx/game.rb
lib/nbx/game.rb
+1
-1
lib/scene.rb
lib/scene.rb
+7
-1
lib/scene_config.rb
lib/scene_config.rb
+2
-0
lib/widget_scrollbar.rb
lib/widget_scrollbar.rb
+1
-1
lib/window_cardinfo.rb
lib/window_cardinfo.rb
+3
-2
lib/window_config.rb
lib/window_config.rb
+41
-19
lib/window_field.rb
lib/window_field.rb
+1
-1
lib/window_lp.rb
lib/window_lp.rb
+13
-9
No files found.
Rakefile
View file @
2769226b
...
...
@@ -7,6 +7,21 @@ require 'rake/rdoctask'
#require 'rake/testtask'
Windows
=
RUBY_PLATFORM
[
"mingw"
]
||
RUBY_PLATFORM
[
"mswin"
]
if
Windows
STDOUT
.
set_encoding
"GBK"
,
"UTF-8"
STDERR
.
set_encoding
"GBK"
,
"UTF-8"
end
#在windows上UTF-8脚本编码环境中 Dir.glob无法列出中文目录下的文件 所以自己写个递归
def
list
(
path
)
result
=
[]
Dir
.
foreach
(
path
)
do
|
file
|
next
if
file
==
"."
or
file
==
".."
result
<<
"
#{
path
}
/
#{
file
}
"
result
.
concat
list
(
result
.
last
)
if
File
.
directory?
result
.
last
end
result
end
spec
=
Gem
::
Specification
.
new
do
|
s
|
s
.
name
=
'mycard'
s
.
version
=
'0.3.9'
...
...
@@ -17,9 +32,10 @@ spec = Gem::Specification.new do |s|
s
.
email
=
'zh99998@gmail.com'
s
.
homepage
=
'http://card.touhou,cc'
# s.executables = ['your_executable_here']
s
.
files
=
%w(LICENSE.txt README.txt replay)
+
Dir
.
glob
(
"{lib,audio,data,fonts,graphics}/**/*"
)
s
.
files
=
%w(LICENSE.txt README.txt replay)
%w{lib audio data fonts graphics}
.
each
{
|
dir
|
s
.
files
.
concat
list
(
dir
)}
if
Windows
s
.
files
+=
%w(mycard.exe)
+
Dir
.
glob
(
"{ruby}/**/*
"
)
s
.
files
+=
%w(mycard.exe)
+
list
(
"ruby
"
)
else
s
.
files
+=
%w(install.sh)
end
...
...
@@ -49,4 +65,4 @@ Rake::RDocTask.new do |rdoc|
rdoc
.
options
<<
'--line-numbers'
end
CLOBBER
.
include
%w(error-程序出错请到论坛反馈.txt log.log profile.log config.yml doc)
+
Dir
.
glob
(
"{replay}/**/*"
)
+
Dir
.
glob
(
"**/Thumbs.db"
)
+
Dir
.
glob
(
"graphics/avatars/*_*.png"
)
\ No newline at end of file
CLOBBER
.
include
%w(error-程序出错请到论坛反馈.txt log.log profile.log config.yml doc)
+
list
(
'replay'
)
+
list
(
'.'
).
keep_if
{
|
file
|
File
.
basename
(
file
)
==
"Thumbs.db"
}
+
list
(
"graphics/avatars"
).
keep_if
{
|
file
|
File
.
basename
(
file
)
=~
/.*_(?:small|middle|large)\.png/
}
\ No newline at end of file
lib/action.rb
View file @
2769226b
...
...
@@ -165,7 +165,6 @@ class Action
else
$log
.
error
(
'移动操作3'
){
'错误的to_pos'
+
self
.
inspect
}
end
p
to_field
end
if
from_field
==
player_field
.
hand
and
!
@card
||
!
@card
.
known?
case
@to_pos
...
...
lib/iduel/action.rb
View file @
2769226b
...
...
@@ -187,7 +187,7 @@ class Action
when
/^┊(.*)┊$/m
Chat
.
new
from_player
,
$1
when
/^※\[(.*)\]\n(.*)\n注释.*$/m
p
card
=
Card
.
find
(
$1
.
to_sym
)
card
=
Card
.
find
(
$1
.
to_sym
)
case
$2
when
/(.+怪兽),种族:(.+),属性:(.+),星级:(\d+),攻击:(\d+|?),防御:(\d+|?),效果:(.+)/
CardInfo
.
new
(
card
,
$1
.
to_sym
,
$5
==
"?"
?
nil
:
$5
.
to_i
,
$6
==
"?"
?
nil
:
$6
.
to_i
,
$3
.
to_sym
,
$2
.
to_sym
,
$4
.
to_sym
,
$7
)
...
...
lib/iduel/replay.rb
View file @
2769226b
#encoding: UTF-8
class
Replay
User_Filter
=
/(.+?)(?:\((\d+)\))?(?:\(\d+:\d+:\d+\))?(?::|:) */
User_Filter
=
/(.+?)(?:\((\d+)\))?(?:\(\d+:\d+:\d+\))?(?::
|:) */
Delimiter
=
/^
#{
User_Filter
}
\n ?/
Player_Filter
=
/
#{
Delimiter
}
\[\d+\] ◎→/
Opponent_Filter
=
/
#{
Delimiter
}
\[\d+\] ●→/
...
...
@@ -27,10 +27,10 @@ class Replay
require
'cgi'
contents
=
CGI
.
unescape_html
(
contents
)
else
result
.
player1
=
User
.
new
(
$2
?
$2
.
to_i
:
:player
,
$1
)
if
contents
=~
Player_Filter
result
.
player2
=
User
.
new
(
$2
?
$2
.
to_i
:
:opponent
,
$1
)
if
contents
=~
Opponent_Filter
result
.
player1
=
User
.
new
(
$2
?
$2
.
to_i
:
$1
.
to_sym
,
$1
)
if
contents
=~
Player_Filter
result
.
player2
=
User
.
new
(
$2
?
$2
.
to_i
:
$1
.
to_sym
,
$1
)
if
contents
=~
Opponent_Filter
from_players
=
contents
.
scan
(
Delimiter
).
collect
do
|
matched
|
id
=
matched
[
1
]
||
:player
id
=
(
matched
[
1
]
||
matched
[
0
]).
to_sym
name
=
matched
[
0
]
if
result
.
player1
and
result
.
player1
.
id
==
id
true
...
...
@@ -48,9 +48,8 @@ class Replay
end
end
end
result
.
player1
||=
User
.
new
(
:player
,
"我"
)
result
.
player2
||=
User
.
new
(
:opponent
,
"对手"
)
p
result
.
player1
,
result
.
player2
result
.
player1
||=
User
.
new
(
$1
.
to_sym
,
"我"
)
result
.
player2
||=
User
.
new
(
$1
.
to_sym
,
"对手"
)
lines
=
contents
.
split
(
Delimiter
)
lines
.
shift
#split后,在第一个操作之前会多出一个空白元素
if
from_players
.
empty?
...
...
lib/main.rb
View file @
2769226b
...
...
@@ -7,6 +7,7 @@ begin
require
'yaml'
$config
=
YAML
.
load_file
(
"config.yml"
)
rescue
{}
$config
||=
{}
$config
[
'bgm'
]
=
true
if
$config
[
'bgm'
].
nil?
$config
[
'screen'
]
||=
{}
$config
[
'screen'
][
'width'
]
||=
1024
$config
[
'screen'
][
'height'
]
||=
768
...
...
lib/nbx/game.rb
View file @
2769226b
...
...
@@ -22,7 +22,7 @@ class NBX < Game
Game_Event
.
push
Game_Event
::
Host
.
new
(
@room
)
send
(
nil
,
"NewRoom"
,
@room
.
player1
.
name
)
@conn_room_server
=
TCPServer
.
new
'0.0.0.0'
,
Port
#为了照顾NBX强制IPv4
@accept_room
=
Thread
.
new
{
Thread
.
start
(
@conn_room_server
.
accept
)
{
|
client
|
accept
(
client
)}
rescue
p
@conn_room_server
while
@conn_room_server
}
@accept_room
=
Thread
.
new
{
(
Thread
.
start
(
@conn_room_server
.
accept
)
{
|
client
|
accept
(
client
)}
while
@conn_room_server
)
rescue
nil
}
end
def
action
(
action
)
if
@room
.
player2
...
...
lib/scene.rb
View file @
2769226b
...
...
@@ -46,7 +46,7 @@ class Scene
# ● 开始处理
#--------------------------------------------------------------------------
def
start
if
@@last_bgm
!=
self
.
class
::
BGM
if
$config
[
'bgm'
]
and
@@last_bgm
!=
self
.
class
::
BGM
@@bgm
.
destroy
if
@@bgm
@@bgm
=
Mixer
::
Music
.
load
"audio/bgm/
#{
self
.
class
::
BGM
}
"
Mixer
.
fade_in_music
(
@@bgm
,
-
1
,
800
)
...
...
@@ -54,6 +54,12 @@ class Scene
@@last_bgm
=
self
.
class
::
BGM
end
end
def
last_bgm
@@last_bgm
end
def
last_bgm
=
(
bgm
)
@@last_bgm
=
bgm
end
def
refresh_rect
(
x
,
y
,
width
,
height
,
background
=
@background
,
ox
=
0
,
oy
=
0
)
Surface
.
blit
(
background
,
x
+
ox
,
y
+
oy
,
width
,
height
,
$screen
,
x
,
y
)
yield
...
...
lib/scene_config.rb
View file @
2769226b
...
...
@@ -7,9 +7,11 @@
class
Scene_Config
<
Scene
require_relative
'window_config'
BGM
=
'title.ogg'
def
start
@background
=
Surface
.
load
(
"graphics/config/background.png"
).
display_format
@config_window
=
Window_Config
.
new
(
0
,
0
)
super
end
def
handle
(
event
)
case
event
...
...
lib/widget_scrollbar.rb
View file @
2769226b
...
...
@@ -57,7 +57,7 @@ class Widget_ScrollBar < Window
end
def
mousemoved
(
x
,
y
)
if
Mouse
.
state
[
2
]
and
@scrolling
and
@scroll_max
>
0
@parent_window
.
scroll
=
[[
0
,
(
y
-
@y
-
@scrolling
)
/
((
@height
-
40
-
24
)
/
@scroll_max
)].
max
,
@scroll_max
].
min
@parent_window
.
scroll
=
[[
0
,
(
y
-
@y
-
@scrolling
)
*
@scroll_max
/
(
@height
-
40
-
24
)].
max
,
@scroll_max
].
min
end
case
y
-
@y
when
0
...
20
#上按钮
...
...
lib/window_cardinfo.rb
View file @
2769226b
...
...
@@ -4,8 +4,9 @@ class Window_CardInfo < Window
def
initialize
(
x
,
y
)
super
(
x
,
y
,
1024
-
x
,
524
,
300
)
@font
=
TTF
.
open
(
"fonts/WenQuanYi Micro Hei.ttf"
,
16
)
self
.
card
=
Game_Card
.
new
Card
.
find
(
'name'
=>
:mycard
,
'number'
=>
:"000000"
,
'lore'
=>
"提示:
\n
快捷键:
\n
F10 退出房间
\n
F12 返回主界面"
,
'card_type'
=>
:"通常魔法"
,
'stats'
=>
""
,
'archettypes'
=>
""
,
"mediums"
=>
""
,
"tokens"
=>
0
)
@card
.
card
.
instance_eval
{
@image
=
Card
::
CardBack
;
@image_small
=
Card
::
CardBack_Small
}
tip
=
Card
.
new
(
'name'
=>
:mycard
,
'number'
=>
:"000000"
,
'lore'
=>
"提示:
\n
快捷键:
\n
F10 退出房间
\n
F12 返回主界面"
,
'card_type'
=>
:"通常魔法"
,
'stats'
=>
""
,
'archettypes'
=>
""
,
"mediums"
=>
""
,
"tokens"
=>
0
)
tip
.
instance_eval
{
@image
=
Card
::
CardBack
;
@image_small
=
Card
::
CardBack_Small
}
self
.
card
=
Game_Card
.
new
tip
end
def
card
=
(
card
)
return
if
card
.
nil?
or
card
==
@card
or
!
card
.
known?
...
...
lib/window_config.rb
View file @
2769226b
...
...
@@ -12,36 +12,46 @@ class Window_Config < Window
@items
=
{
:fullscreen
=>
[
0
,
0
,
120
,
WLH
],
:avatar_cache
=>
[
220
,
WLH
,
@button
.
w
/
3
,
@button
.
h
],
:return
=>
[
0
,
WLH
*
2
,
100
,
WLH
]
:bgm
=>
[
0
,
WLH
,
120
,
WLH
],
:avatar_cache
=>
[
220
,
WLH
*
2
,
@button
.
w
/
3
,
@button
.
h
],
:return
=>
[
0
,
WLH
*
3
+
10
,
100
,
WLH
]
}
refresh
end
def
draw_item
(
index
,
status
=
0
)
case
index
when
:fullscreen
clear
(
0
,
0
,
100
,
WLH
)
Surface
.
blit
(
@checkbox
,
20
*
status
,
$config
[
"fullscreen"
]
?
20
:
0
,
20
,
20
,
@contents
,
0
,
0
)
Surface
.
blit
(
@checkbox
,
20
*
status
,
$config
[
'screen'
][
'fullscreen'
]
?
20
:
0
,
20
,
20
,
@contents
,
0
,
0
)
case
status
when
0
@font
.
draw_blended_utf8
(
@contents
,
"全屏模式"
,
WLH
,
0
,
0x00
,
0x00
,
0x00
)
@font
.
draw_blended_utf8
(
@contents
,
"全屏模式"
,
24
,
0
,
0x00
,
0x00
,
0x00
)
when
1
@font
.
draw_shaded_utf8
(
@contents
,
"全屏模式"
,
WLH
,
0
,
0x00
,
0x00
,
0x00
,
0xEE
,
0xEE
,
0xEE
)
@font
.
draw_shaded_utf8
(
@contents
,
"全屏模式"
,
24
,
0
,
0x00
,
0x00
,
0x00
,
0xEE
,
0xEE
,
0xEE
)
when
2
@font
.
draw_shaded_utf8
(
@contents
,
"全屏模式"
,
WLH
,
0
,
0xEE
,
0xEE
,
0xEE
,
0x00
,
0x00
,
0x00
)
@font
.
draw_shaded_utf8
(
@contents
,
"全屏模式"
,
24
,
0
,
0xEE
,
0xEE
,
0xEE
,
0x00
,
0x00
,
0x00
)
end
when
:bgm
Surface
.
blit
(
@checkbox
,
20
*
status
,
$config
[
'bgm'
]
?
20
:
0
,
20
,
20
,
@contents
,
0
,
WLH
)
case
status
when
0
@font
.
draw_blended_utf8
(
@contents
,
"BGM"
,
24
,
WLH
,
0x00
,
0x00
,
0x00
)
when
1
@font
.
draw_shaded_utf8
(
@contents
,
"BGM"
,
24
,
WLH
,
0x00
,
0x00
,
0x00
,
0xEE
,
0xEE
,
0xEE
)
when
2
@font
.
draw_shaded_utf8
(
@contents
,
"BGM"
,
24
,
WLH
,
0xEE
,
0xEE
,
0xEE
,
0x00
,
0x00
,
0x00
)
end
when
:avatar_cache
clear
(
0
,
WLH
,
220
+
@button
.
w
/
3
,
@button
.
h
)
size
=
0
count
=
0
Dir
.
glob
(
"graphics/avatars/*_*.png"
)
do
|
file
|
count
+=
1
size
+=
File
.
size
(
file
)
end
@font
.
draw_blended_utf8
(
@contents
,
"头像缓存:
#{
count
}
个文件,
#{
filesize_inspect
(
size
)
}
"
,
0
,
WLH
,
0x00
,
0x00
,
0x00
)
Surface
.
blit
(
@button
,
@button
.
w
/
3
*
status
,
0
,
@button
.
w
/
3
,
@button
.
h
,
@contents
,
220
,
WLH
)
@font
.
draw_blended_utf8
(
@contents
,
"头像缓存:
#{
count
}
个文件,
#{
filesize_inspect
(
size
)
}
"
,
0
,
WLH
*
2
,
0x00
,
0x00
,
0x00
)
Surface
.
blit
(
@button
,
@button
.
w
/
3
*
status
,
0
,
@button
.
w
/
3
,
@button
.
h
,
@contents
,
220
,
WLH
*
2
)
@font
.
draw_blended_utf8
(
@contents
,
"清空"
,
220
+
10
,
WLH
*
2
+
5
,
0x00
,
0x00
,
0x00
)
when
:return
@font
.
draw_blended_utf8
(
@contents
,
"回到标题画面"
,
0
,
WLH
*
2
,
0x00
,
0x00
,
0x00
)
@font
.
draw_blended_utf8
(
@contents
,
"回到标题画面"
,
0
,
WLH
*
3
+
10
,
0x00
,
0x00
,
0x00
)
end
end
...
...
@@ -59,6 +69,7 @@ class Window_Config < Window
@index
=
nil
else
@index
=
index
clear
(
*
item_rect
(
@index
))
draw_item
(
@index
,
1
)
end
end
...
...
@@ -70,29 +81,40 @@ class Window_Config < Window
end
end
def
refresh
clear
@items
.
each_key
{
|
index
|
draw_item
(
index
)}
end
def
clicked
case
@index
when
:fullscreen
clear
(
*
item_rect
(
@index
))
$config
[
"fullscreen"
]
=
!
$config
[
"fullscreen"
]
$config
[
'screen'
][
'fullscreen'
]
=
!
$config
[
'screen'
][
'fullscreen'
]
$screen
.
destroy
style
=
HWSURFACE
style
|=
FULLSCREEN
if
$config
[
"fullscreen"
]
$screen
=
Screen
.
open
(
$config
[
"width"
],
$config
[
"height"
],
0
,
style
)
draw_item
(
@index
,
2
)
style
|=
FULLSCREEN
if
$config
[
'screen'
][
"fullscreen"
]
$screen
=
Screen
.
open
(
$config
[
'screen'
][
"width"
],
$config
[
'screen'
][
"height"
],
0
,
style
)
draw_item
(
@index
,
1
)
when
:bgm
clear
(
*
item_rect
(
@index
))
$config
[
'bgm'
]
=
!
$config
[
'bgm'
]
if
$config
[
'bgm'
]
$scene
=
Scene_Config
.
new
else
$scene
.
last_bgm
=
nil
Mixer
.
fade_out_music
(
800
)
end
draw_item
(
@index
,
1
)
when
:avatar_cache
#clear(*item_rect(@index))
Dir
.
glob
(
"graphics/avatars/*_*.png"
)
do
|
file
|
File
.
delete
file
end
draw_item
(
:avatar_cache
)
refresh
#draw_item(:avatar_cache,1)
when
:return
File
.
open
(
"config.yml"
,
"w"
)
do
|
config
|
YAML
.
dump
(
$config
,
config
)
end
$scene
=
Scene_Title
.
new
end
save_config
end
def
filesize_inspect
(
size
)
case
size
...
...
lib/window_field.rb
View file @
2769226b
...
...
@@ -428,7 +428,7 @@ class Window_Field < Window
end
def
clear
(
x
=
0
,
y
=
0
,
width
=
@width
,
height
=
@height
)
super
if
$scene
.
fieldback_window
.
visible?
if
$scene
.
fieldback_window
and
$scene
.
fieldback_window
.
visible?
Surface
.
blit
(
$scene
.
fieldback_window
.
contents
,
@x
+
x
-
$scene
.
fieldback_window
.
x
,
@y
+
y
-
$scene
.
fieldback_window
.
y
,
width
,
height
,
@contents
,
x
,
y
)
end
end
...
...
lib/window_lp.rb
View file @
2769226b
class
Window_LP
<
Window
Avatar_Size
=
48
def
initialize
(
x
,
y
,
player
,
position
=
true
)
#true:左 false:右
super
(
x
,
y
,
3
60
,
72
)
super
(
x
,
y
,
3
55
,
48
)
@position
=
position
@font
=
TTF
.
open
(
"fonts/WenQuanYi Micro Hei.ttf"
,
20
)
@color
=
[
255
,
255
,
255
]
self
.
player
=
player
self
.
lp
=
8000
end
def
player
=
(
player
)
return
if
@player
==
player
clear
@player
=
player
if
@player
@player
.
avatar
do
|
avatar
|
...
...
@@ -17,22 +17,26 @@ class Window_LP < Window
@contents
.
put
avatar
,
@position
?
0
:
@width
-
Avatar_Size
,
0
end
if
@position
@font
.
draw_
soli
d_utf8
(
@contents
,
@player
.
name
,
Avatar_Size
,
24
,
*
@color
)
@font
.
draw_
blende
d_utf8
(
@contents
,
@player
.
name
,
Avatar_Size
,
24
,
*
@color
)
else
@font
.
draw_
soli
d_utf8
(
@contents
,
@player
.
name
,
@width
-
Avatar_Size
-
96
,
24
,
*
@color
)
@font
.
draw_
blende
d_utf8
(
@contents
,
@player
.
name
,
@width
-
Avatar_Size
-
96
,
24
,
*
@color
)
end
end
self
.
lp
=
8000
end
def
lp
=
(
lp
)
return
if
lp
==
@lp
@lp
=
lp
width
=
[
0
,
[(
200
*
lp
/
8000
),
200
].
min
].
max
if
@position
@contents
.
fill_rect
(
64
,
0
,[
0
,
[(
200
*
lp
/
8000
),
200
].
min
].
max
,
24
,
0xFFFF0000
)
@font
.
draw_blended_utf8
(
@contents
,
@lp
.
to_s
,
64
,
0
,
*
@color
)
clear
(
64
,
0
,
200
,
WLH
)
@contents
.
fill_rect
(
48
,
0
,
width
,
WLH
,
0xFFFF0000
)
@font
.
draw_blended_utf8
(
@contents
,
@lp
.
to_s
,
56
,
0
,
*
@color
)
else
width
=
[
0
,
[(
200
*
lp
/
8000
),
200
].
min
].
max
@contents
.
fill_rect
(
@width
-
width
-
64
,
0
,
width
,
24
,
0xFFFF0000
)
@font
.
draw_blended_utf8
(
@contents
,
@lp
.
to_s
,
128
,
0
,
*
@color
)
clear
(
@width
-
200
-
64
,
0
,
200
,
WLH
)
@contents
.
fill_rect
(
@width
-
width
-
48
,
0
,
width
,
WLH
,
0xFFFF0000
)
@font
.
draw_blended_utf8
(
@contents
,
@lp
.
to_s
,
240
,
0
,
*
@color
)
end
end
end
\ No newline at end of file
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