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
7fdf9abd
Commit
7fdf9abd
authored
Dec 28, 2011
by
神楽坂玲奈
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
版本0.3.0
parent
7f4e6bb8
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
58 additions
and
46 deletions
+58
-46
Rakefile
Rakefile
+1
-1
lib/iduel/game.rb
lib/iduel/game.rb
+13
-15
lib/iduel/window_login.rb
lib/iduel/window_login.rb
+2
-1
lib/replay.rb
lib/replay.rb
+2
-1
lib/scene.rb
lib/scene.rb
+13
-12
lib/scene_duel.rb
lib/scene_duel.rb
+10
-3
lib/scene_watch.rb
lib/scene_watch.rb
+15
-4
lib/window_roomchat.rb
lib/window_roomchat.rb
+2
-9
No files found.
Rakefile
View file @
7fdf9abd
...
@@ -8,7 +8,7 @@ require 'rake/gempackagetask'
...
@@ -8,7 +8,7 @@ require 'rake/gempackagetask'
Windows
=
RUBY_PLATFORM
[
"mingw"
]
||
RUBY_PLATFORM
[
"mswin"
]
Windows
=
RUBY_PLATFORM
[
"mingw"
]
||
RUBY_PLATFORM
[
"mswin"
]
spec
=
Gem
::
Specification
.
new
do
|
s
|
spec
=
Gem
::
Specification
.
new
do
|
s
|
s
.
name
=
'mycard'
s
.
name
=
'mycard'
s
.
version
=
'0.
2.1
'
s
.
version
=
'0.
3.0
'
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/iduel/game.rb
View file @
7fdf9abd
...
@@ -19,22 +19,20 @@ class Iduel < Game
...
@@ -19,22 +19,20 @@ class Iduel < Game
def
connect
def
connect
require
'socket'
require
'socket'
require
'open-uri'
require
'open-uri'
begin
@conn
=
TCPSocket
.
open
(
Server
,
Port
)
@conn
=
TCPSocket
.
new
(
Server
,
Port
)
#TODO: 阻塞优化,注意login。下面注释掉的两句实现connect无阻塞,但是login依然会阻塞所以只优化这里没有意义
@conn
.
set_encoding
"GBK"
,
"UTF-8"
,
:invalid
=>
:replace
,
:undef
=>
:replace
#@conn = Socket.new(:INET, :STREAM)
@recv
=
Thread
.
new
do
@conn
.
set_encoding
"GBK"
,
"UTF-8"
,
:invalid
=>
:replace
,
:undef
=>
:replace
begin
@recv
=
Thread
.
new
do
recv
@conn
.
gets
(
RS
)
while
@conn
begin
rescue
=>
exception
#@conn.connect Socket.pack_sockaddr_in(Port, Server)
Game_Event
.
push
Game_Event
::
Error
.
new
(
exception
.
class
.
to_s
,
exception
.
message
)
recv
@conn
.
gets
(
RS
)
while
@conn
$log
.
error
[
exception
.
inspect
,
*
exception
.
backtrace
].
join
(
"
\n
"
)
rescue
=>
exception
ensure
Game_Event
.
push
Game_Event
::
Error
.
new
(
exception
.
class
.
to_s
,
exception
.
message
)
self
.
exit
$log
.
error
[
exception
.
inspect
,
*
exception
.
backtrace
].
join
(
"
\n
"
)
end
ensure
self
.
exit
end
end
rescue
=>
exception
Game_Event
.
push
Game_Event
::
Error
.
new
(
exception
.
class
.
to_s
,
exception
.
message
)
$log
.
error
[
exception
.
inspect
,
*
exception
.
backtrace
].
join
(
"
\n
"
)
end
end
end
end
...
...
lib/iduel/window_login.rb
View file @
7fdf9abd
...
@@ -3,9 +3,10 @@ class Window_Login
...
@@ -3,9 +3,10 @@ class Window_Login
def
clicked
def
clicked
case
@index
case
@index
when
:login
when
:login
Widget_Msgbox
.
new
(
"iduel"
,
"正在登陆"
)
$scene
.
draw
#强制重绘一次,下面会阻塞
$game
=
Iduel
.
new
$game
=
Iduel
.
new
$game
.
login
(
@username_inputbox
.
value
,
@password_inputbox
.
value
)
$game
.
login
(
@username_inputbox
.
value
,
@password_inputbox
.
value
)
Widget_Msgbox
.
new
(
"iduel"
,
"正在登陆"
)
when
:register
when
:register
require
'launchy'
require
'launchy'
Launchy
.
open
(
Iduel
::
Register_Url
)
Launchy
.
open
(
Iduel
::
Register_Url
)
...
...
lib/replay.rb
View file @
7fdf9abd
...
@@ -8,7 +8,8 @@ class Replay
...
@@ -8,7 +8,8 @@ class Replay
action
=
action
.
escape
if
action
.
is_a?
Action
action
=
action
.
escape
if
action
.
is_a?
Action
@file
.
write
action
+
"
\n
"
@file
.
write
action
+
"
\n
"
end
end
def
save
(
filename
=
"
#{
Time
.
now
.
strftime
(
"%Y%m%d%H%M%S"
)
}
_
#{
$game
.
room
.
player1
.
name
}
(
#{
$game
.
room
.
player1
.
id
}
)_
#{
$game
.
room
.
player2
.
name
}
(
#{
$game
.
room
.
player2
.
id
}
).txt"
)
def
save
(
filename
=
"
#{
$game
.
room
.
player1
.
name
}
(
#{
$game
.
room
.
player1
.
id
}
)_
#{
$game
.
room
.
player2
.
name
}
(
#{
$game
.
room
.
player2
.
id
}
)_
#{
Time
.
now
.
strftime
(
"%m%d%H%M"
)
}
.txt"
)
p
filename
close
close
File
.
rename
(
@file
.
path
,
File
.
expand_path
(
filename
,
ReplayPath
))
File
.
rename
(
@file
.
path
,
File
.
expand_path
(
filename
,
ReplayPath
))
end
end
...
...
lib/scene.rb
View file @
7fdf9abd
...
@@ -21,21 +21,22 @@ class Scene
...
@@ -21,21 +21,22 @@ class Scene
start
start
while
$scene
==
self
while
$scene
==
self
update
update
@@fpstimer
.
wait_frame
do
@@fpstimer
.
wait_frame
{
draw
}
if
@background
$screen
.
put
(
@background
,
0
,
0
)
else
$screen
.
fill_rect
(
0
,
0
,
$screen
.
w
,
$screen
.
h
,
0x000000
)
end
@windows
.
each
do
|
window
|
window
.
draw
(
$screen
)
end
@font
.
draw_blended_utf8
(
$screen
,
"%.1f"
%
@@fpstimer
.
real_fps
,
0
,
0
,
0xFF
,
0xFF
,
0xFF
)
$screen
.
update_rect
(
0
,
0
,
0
,
0
)
end
end
end
terminate
terminate
end
end
def
draw
if
@background
$screen
.
put
(
@background
,
0
,
0
)
else
$screen
.
fill_rect
(
0
,
0
,
$screen
.
w
,
$screen
.
h
,
0x000000
)
end
@windows
.
each
do
|
window
|
window
.
draw
(
$screen
)
end
@font
.
draw_blended_utf8
(
$screen
,
"%.1f"
%
@@fpstimer
.
real_fps
,
0
,
0
,
0xFF
,
0xFF
,
0xFF
)
$screen
.
update_rect
(
0
,
0
,
0
,
0
)
end
#--------------------------------------------------------------------------
#--------------------------------------------------------------------------
# ● 开始处理
# ● 开始处理
#--------------------------------------------------------------------------
#--------------------------------------------------------------------------
...
...
lib/scene_duel.rb
View file @
7fdf9abd
...
@@ -142,7 +142,12 @@ class Scene_Duel < Scene
...
@@ -142,7 +142,12 @@ class Scene_Duel < Scene
if
event
.
room
==
$game
.
room
if
event
.
room
==
$game
.
room
@player_lp_window
.
player
=
$game
.
room
.
player1
@player_lp_window
.
player
=
$game
.
room
.
player1
@opponent_lp_window
.
player
=
$game
.
room
.
player2
@opponent_lp_window
.
player
=
$game
.
room
.
player2
notify_send
(
"mycard"
,
"对手加入房间"
)
player
=
$game
.
room
.
player1
==
$game
.
user
?
$game
.
room
.
player2
:
$game
.
room
.
player1
if
player
notify_send
(
"对手加入房间"
,
"
#{
player
.
name
}
(
#{
player
.
id
}
)"
)
else
notify_send
(
"对手离开房间"
,
"对手离开房间"
)
end
end
end
end
end
end
end
...
@@ -173,7 +178,9 @@ class Scene_Duel < Scene
...
@@ -173,7 +178,9 @@ class Scene_Duel < Scene
super
super
end
end
def
notify_send
(
title
,
msg
)
def
notify_send
(
title
,
msg
)
puts
"notify-send -i graphics/system/icon.ico
#{
title
}
#{
msg
}
"
command
=
"notify-send -i graphics/system/icon.ico
#{
title
}
#{
msg
}
"
system
(
"notify-send -i graphics/system/icon.ico
#{
title
}
#{
msg
}
"
)
command
=
"start ruby/bin/
#{
command
}
"
.
encode
"GBK"
if
RUBY_PLATFORM
[
"win"
]
||
RUBY_PLATFORM
[
"ming"
]
system
(
command
)
$log
.
info
command
end
end
end
end
\ No newline at end of file
lib/scene_watch.rb
View file @
7fdf9abd
...
@@ -9,13 +9,24 @@ class Scene_Watch < Scene_Duel
...
@@ -9,13 +9,24 @@ class Scene_Watch < Scene_Duel
def
create_action_window
def
create_action_window
end
end
def
action
(
action
)
def
action
(
action
)
if
action
.
from_player
==
:me
super
end
end
end
def
start
def
start
super
super
#$game.action Action::Chat.new(true, "#{$game.user.name}(#{$game.user.id})进入了观战")
$game
.
action
Action
::
Chat
.
new
(
true
,
"
#{
$game
.
user
.
name
}
(
#{
$game
.
user
.
id
}
)进入了观战"
)
end
def
handle
(
event
)
case
event
when
Event
::
KeyDown
case
event
.
sym
when
Key
::
F10
$game
.
action
Action
::
Chat
.
new
(
true
,
"
#{
$game
.
user
.
name
}
(
#{
$game
.
user
.
id
}
)离开了观战"
)
$game
.
leave
else
super
end
else
super
end
end
end
def
handle_game
(
event
)
def
handle_game
(
event
)
case
event
case
event
...
...
lib/window_roomchat.rb
View file @
7fdf9abd
# To change this template, choose Tools | Templates
require_relative
'scene_watch'
# and open the template in the editor.
class
Window_RoomChat
<
Window
class
Window_RoomChat
<
Window
WLH
=
16
WLH
=
16
require_relative
'widget_scrollbar'
require_relative
'widget_scrollbar'
...
@@ -8,12 +6,7 @@ class Window_RoomChat < Window
...
@@ -8,12 +6,7 @@ class Window_RoomChat < Window
Opponent_Color
=
[
0
,
0x66
,
0
]
Opponent_Color
=
[
0
,
0x66
,
0
]
def
initialize
(
x
,
y
,
width
,
height
)
def
initialize
(
x
,
y
,
width
,
height
)
super
(
x
,
y
,
width
,
height
-
WLH
)
super
(
x
,
y
,
width
,
height
-
WLH
)
@chat_input
=
Widget_InputBox
.
new
(
@x
,
@y
+
@height
,
@width
,
WLH
){
|
text
|
@chat_input
=
Widget_InputBox
.
new
(
@x
,
@y
+
@height
,
@width
,
WLH
){
|
text
|
(
$scene
.
is_a?
(
Scene_Watch
)
?
$game
:
$scene
).
action
Action
::
Chat
.
new
(
true
,
text
)}
$game
.
action
=
Action
::
Chat
.
new
(
true
,
text
)
action
.
from_player
=
:me
$scene
.
action
action
}
@font
=
TTF
.
open
(
"fonts/WenQuanYi Micro Hei.ttf"
,
14
)
@font
=
TTF
.
open
(
"fonts/WenQuanYi Micro Hei.ttf"
,
14
)
@contents
.
fill_rect
(
0
,
0
,
@width
,
@height
,
0x99FFFFFF
)
@contents
.
fill_rect
(
0
,
0
,
@width
,
@height
,
0x99FFFFFF
)
@scroll
=
Widget_ScrollBar
.
new
(
@x
+
@width
-
20
,
@y
,
@height
,
0
)
@scroll
=
Widget_ScrollBar
.
new
(
@x
+
@width
-
20
,
@y
,
@height
,
0
)
...
...
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