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
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'
Windows
=
RUBY_PLATFORM
[
"mingw"
]
||
RUBY_PLATFORM
[
"mswin"
]
spec
=
Gem
::
Specification
.
new
do
|
s
|
s
.
name
=
'mycard'
s
.
version
=
'0.
2.1
'
s
.
version
=
'0.
3.0
'
s
.
extra_rdoc_files
=
[
'README.txt'
,
'LICENSE.txt'
]
s
.
summary
=
'a card game'
s
.
description
=
s
.
summary
...
...
lib/iduel/game.rb
View file @
7fdf9abd
...
...
@@ -19,22 +19,20 @@ class Iduel < Game
def
connect
require
'socket'
require
'open-uri'
begin
@conn
=
TCPSocket
.
open
(
Server
,
Port
)
@conn
.
set_encoding
"GBK"
,
"UTF-8"
,
:invalid
=>
:replace
,
:undef
=>
:replace
@recv
=
Thread
.
new
do
begin
recv
@conn
.
gets
(
RS
)
while
@conn
rescue
=>
exception
Game_Event
.
push
Game_Event
::
Error
.
new
(
exception
.
class
.
to_s
,
exception
.
message
)
$log
.
error
[
exception
.
inspect
,
*
exception
.
backtrace
].
join
(
"
\n
"
)
ensure
self
.
exit
end
@conn
=
TCPSocket
.
new
(
Server
,
Port
)
#TODO: 阻塞优化,注意login。下面注释掉的两句实现connect无阻塞,但是login依然会阻塞所以只优化这里没有意义
#@conn = Socket.new(:INET, :STREAM)
@conn
.
set_encoding
"GBK"
,
"UTF-8"
,
:invalid
=>
:replace
,
:undef
=>
:replace
@recv
=
Thread
.
new
do
begin
#@conn.connect Socket.pack_sockaddr_in(Port, Server)
recv
@conn
.
gets
(
RS
)
while
@conn
rescue
=>
exception
Game_Event
.
push
Game_Event
::
Error
.
new
(
exception
.
class
.
to_s
,
exception
.
message
)
$log
.
error
[
exception
.
inspect
,
*
exception
.
backtrace
].
join
(
"
\n
"
)
ensure
self
.
exit
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
...
...
lib/iduel/window_login.rb
View file @
7fdf9abd
...
...
@@ -3,9 +3,10 @@ class Window_Login
def
clicked
case
@index
when
:login
Widget_Msgbox
.
new
(
"iduel"
,
"正在登陆"
)
$scene
.
draw
#强制重绘一次,下面会阻塞
$game
=
Iduel
.
new
$game
.
login
(
@username_inputbox
.
value
,
@password_inputbox
.
value
)
Widget_Msgbox
.
new
(
"iduel"
,
"正在登陆"
)
when
:register
require
'launchy'
Launchy
.
open
(
Iduel
::
Register_Url
)
...
...
lib/replay.rb
View file @
7fdf9abd
...
...
@@ -8,7 +8,8 @@ class Replay
action
=
action
.
escape
if
action
.
is_a?
Action
@file
.
write
action
+
"
\n
"
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
File
.
rename
(
@file
.
path
,
File
.
expand_path
(
filename
,
ReplayPath
))
end
...
...
lib/scene.rb
View file @
7fdf9abd
...
...
@@ -21,21 +21,22 @@ class Scene
start
while
$scene
==
self
update
@@fpstimer
.
wait_frame
do
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
@@fpstimer
.
wait_frame
{
draw
}
end
terminate
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
if
event
.
room
==
$game
.
room
@player_lp_window
.
player
=
$game
.
room
.
player1
@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
...
...
@@ -173,7 +178,9 @@ class Scene_Duel < Scene
super
end
def
notify_send
(
title
,
msg
)
puts
"notify-send -i graphics/system/icon.ico
#{
title
}
#{
msg
}
"
system
(
"notify-send -i graphics/system/icon.ico
#{
title
}
#{
msg
}
"
)
command
=
"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
\ No newline at end of file
lib/scene_watch.rb
View file @
7fdf9abd
...
...
@@ -9,13 +9,24 @@ class Scene_Watch < Scene_Duel
def
create_action_window
end
def
action
(
action
)
if
action
.
from_player
==
:me
super
end
end
def
start
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
def
handle_game
(
event
)
case
event
...
...
lib/window_roomchat.rb
View file @
7fdf9abd
# To change this template, choose Tools | Templates
# and open the template in the editor.
require_relative
'scene_watch'
class
Window_RoomChat
<
Window
WLH
=
16
require_relative
'widget_scrollbar'
...
...
@@ -8,12 +6,7 @@ class Window_RoomChat < Window
Opponent_Color
=
[
0
,
0x66
,
0
]
def
initialize
(
x
,
y
,
width
,
height
)
super
(
x
,
y
,
width
,
height
-
WLH
)
@chat_input
=
Widget_InputBox
.
new
(
@x
,
@y
+
@height
,
@width
,
WLH
){
|
text
|
$game
.
action
=
Action
::
Chat
.
new
(
true
,
text
)
action
.
from_player
=
:me
$scene
.
action
action
}
@chat_input
=
Widget_InputBox
.
new
(
@x
,
@y
+
@height
,
@width
,
WLH
){
|
text
|
(
$scene
.
is_a?
(
Scene_Watch
)
?
$game
:
$scene
).
action
Action
::
Chat
.
new
(
true
,
text
)}
@font
=
TTF
.
open
(
"fonts/WenQuanYi Micro Hei.ttf"
,
14
)
@contents
.
fill_rect
(
0
,
0
,
@width
,
@height
,
0x99FFFFFF
)
@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