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
a1087bbe
Commit
a1087bbe
authored
Jul 15, 2011
by
神楽坂玲奈
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
发送战报初步
parent
f2bd1309
Changes
10
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
524 additions
and
480 deletions
+524
-480
iduel.cmd
iduel.cmd
+2
-0
lib/action.rb
lib/action.rb
+239
-241
lib/iduel.rb
lib/iduel.rb
+20
-213
lib/iduel_action.rb
lib/iduel_action.rb
+18
-9
lib/iduel_event.rb
lib/iduel_event.rb
+199
-0
lib/scene.rb
lib/scene.rb
+0
-1
lib/scene_duel.rb
lib/scene_duel.rb
+30
-5
lib/scene_hall.rb
lib/scene_hall.rb
+8
-2
lib/ugl.rb
lib/ugl.rb
+0
-9
log.txt
log.txt
+8
-0
No files found.
iduel.cmd
0 → 100644
View file @
a1087bbe
cd
/d
%~dp0
ruby
lib
/main
.rb
>
log
.txt
\ No newline at end of file
lib/action.rb
View file @
a1087bbe
...
@@ -3,12 +3,15 @@ class Action
...
@@ -3,12 +3,15 @@ class Action
CardFilter
=
/(<\[.*?\]\[(?:.*?)\][\s\d]*>|一张怪兽卡|一张魔\/陷卡)/
.
to_s
CardFilter
=
/(<\[.*?\]\[(?:.*?)\][\s\d]*>|一张怪兽卡|一张魔\/陷卡)/
.
to_s
PosFilter
=
/((?:手卡|场上|魔陷区|怪兽区|墓地|额外牌堆|除外区|卡组顶端|\(\d+\)){1,2})/
.
to_s
PosFilter
=
/((?:手卡|场上|魔陷区|怪兽区|墓地|额外牌堆|除外区|卡组顶端|\(\d+\)){1,2})/
.
to_s
PositionFilter
=
/(|攻击表示|防守表示|里侧表示|背面守备表示)/
.
to_s
PositionFilter
=
/(|攻击表示|防守表示|里侧表示|背面守备表示)/
.
to_s
@@id
=
0
attr_reader
:from_player
,
:msg
,
:id
attr_reader
:from_player
,
:msg
def
initialize
(
from_player
,
msg
=
nil
)
def
initialize
(
from_player
,
msg
=
nil
)
@id
=
@@id
@from_player
=
from_player
@from_player
=
from_player
@msg
=
msg
@msg
=
msg
if
@from_player
@@id
+=
1
end
end
end
def
player_field
def
player_field
@from_player
?
@@player_field
:
@@opponent_field
@from_player
?
@@player_field
:
@@opponent_field
...
@@ -22,7 +25,7 @@ class Action
...
@@ -22,7 +25,7 @@ class Action
def
self
.
opponent_field
=
(
field
)
def
self
.
opponent_field
=
(
field
)
@@opponent_field
=
field
@@opponent_field
=
field
end
end
def
do
def
run
end
end
def
self
.
pos
(
pos
)
def
self
.
pos
(
pos
)
if
index
=
pos
.
index
(
"("
)
if
index
=
pos
.
index
(
"("
)
...
@@ -124,28 +127,22 @@ class Action
...
@@ -124,28 +127,22 @@ class Action
end
end
class
Reset
<
Action
;
end
class
Reset
<
Action
;
end
class
Draw
<
Action
class
Draw
<
Action
def
do
def
run
player_field
.
hand
<<
player_field
.
deck
.
shift
player_field
.
hand
<<
player_field
.
deck
.
shift
super
end
end
end
end
class
Deck
<
Action
;
end
class
Deck
<
Action
;
end
class
Side
<
Deck
;
end
class
Side
<
Deck
;
end
class
Go
<
Action
class
Go
<
Action
def
do
def
run
player_field
.
deck
.
shuffle!
player_field
.
deck
.
shuffle!
player_field
.
hand
=
player_field
.
deck
.
shift
(
5
)
player_field
.
hand
=
player_field
.
deck
.
shift
(
5
)
super
end
end
end
end
class
FirstToGo
<
Go
class
FirstToGo
<
Go
;
end
def
escape
class
SecondToGo
<
Go
;
end
"[2011年3月1日禁卡表
\]
#{
"<
#{
@msg
}
>"
if
@msg
}
先攻"
end
end
class
SecondToGo
<
Go
def
escape
"[2011年3月1日禁卡表
\]
#{
"<
#{
@msg
}
>"
if
@msg
}
先攻"
end
end
class
Chat
<
Action
;
end
class
Chat
<
Action
;
end
class
Note
<
Action
class
Note
<
Action
attr_reader
:card
attr_reader
:card
...
@@ -177,7 +174,7 @@ class Action
...
@@ -177,7 +174,7 @@ class Action
@card
=
card
@card
=
card
@position
=
position
@position
=
position
end
end
def
do
def
run
from_field
=
case
@from_pos
from_field
=
case
@from_pos
when
Integer
when
Integer
player_field
.
field
player_field
.
field
...
@@ -230,6 +227,7 @@ class Action
...
@@ -230,6 +227,7 @@ class Action
to_pos
=
to_field
.
size
to_pos
=
to_field
.
size
end
end
to_field
[
to_pos
]
=
@card
to_field
[
to_pos
]
=
@card
super
end
end
end
end
class
Set
<
Move
class
Set
<
Move
...
@@ -270,4 +268,4 @@ class Action
...
@@ -270,4 +268,4 @@ class Action
super
(
from_player
,
from_pos
,
card
,
:opponent
)
super
(
from_player
,
from_pos
,
card
,
:opponent
)
end
end
end
end
end
end
\ No newline at end of file
\ No newline at end of file
lib/iduel.rb
View file @
a1087bbe
...
@@ -15,11 +15,16 @@ class Iduel
...
@@ -15,11 +15,16 @@ class Iduel
require
'socket'
require
'socket'
require
'digest/md5'
require
'digest/md5'
require
'open-uri'
require
'open-uri'
require_relative
'iduel_action'
require_relative
'iduel_event'
@conn
=
TCPSocket
.
open
(
Server
,
Port
)
@conn
=
TCPSocket
.
open
(
Server
,
Port
)
@conn
.
set_encoding
"GBK"
@conn
.
set_encoding
"GBK"
Thread
.
abort_on_exception
=
true
Thread
.
abort_on_exception
=
true
@recv
=
Thread
.
new
{
(
recv
(
@last_info
)
while
@last_info
=
@conn
.
gets
(
RS
))
rescue
Iduel
::
Event
.
push
Event
::
Error
.
new
(
0
)}
@recv
=
Thread
.
new
{
#at_exit{($iduel.qroom(Iduel::Room.new(1,1,1,1,1,1,1));$iduel.quit) if $iduel}
while
@conn
last_info
=
@conn
.
gets
(
RS
)
recv
last_info
end
rescue
Iduel
::
Event
.
push
Event
::
Error
.
new
(
0
)}
end
end
def
send
(
head
,
*
args
)
def
send
(
head
,
*
args
)
info
=
"#
#{
head
.
to_s
(
16
).
upcase
}
|
#{
args
.
join
(
','
)
}
"
.
encode
(
"GBK"
)
+
RS
info
=
"#
#{
head
.
to_s
(
16
).
upcase
}
|
#{
args
.
join
(
','
)
}
"
.
encode
(
"GBK"
)
+
RS
...
@@ -30,49 +35,13 @@ class Iduel
...
@@ -30,49 +35,13 @@ class Iduel
info
.
chomp!
(
RS
)
info
.
chomp!
(
RS
)
info
.
encode!
"UTF-8"
info
.
encode!
"UTF-8"
puts
">>
#{
info
}
"
puts
">>
#{
info
}
"
info
=~
/^\$([A-Z])\|(.*)$/m
Event
.
push
Event
.
parse
info
#建立房间
end
#$F|253¢
def
close
#$R|¢
$iduel
.
quit
#$Q|253,2,zh99998(201448),1¢
@recv
.
exit
#加入房间
@conn
.
close
#$M||¢
@conn
=
nil
#$F|256¢
#$R|¢
#$Q|256,1,zh99997(201629),zh99998(201448)¢
Event
.
push
case
$1
when
"A"
Event
::
Error
when
"B"
Event
::
LOGINOK
when
"C"
Event
::
OLIF
when
"F"
Event
::
JOINROOMOK
when
"G"
Event
::
WATCHROOMSTART
when
"J"
Event
::
UMSG
when
"K"
Event
::
WMSG
when
"M"
Event
::
QROOMOK
#TODO
when
"O"
Event
::
PCHAT
when
"P"
Event
::
RMIF
when
"Q"
Event
::
SingleRoomInfo
when
"R"
Event
::
QROOMOK
#卡表
else
p
$1
,
$2
system
(
"pause"
)
Event
::
UNKNOWN
end
.
new
(
$2
)
end
end
def
checknum
(
head
,
*
args
)
def
checknum
(
head
,
*
args
)
Digest
::
MD5
.
hexdigest
(
"[
#{
head
}
]_
#{
args
.
join
(
'_'
)
}
_SCNERO"
)
Digest
::
MD5
.
hexdigest
(
"[
#{
head
}
]_
#{
args
.
join
(
'_'
)
}
_SCNERO"
)
...
@@ -90,6 +59,9 @@ class Iduel
...
@@ -90,6 +59,9 @@ class Iduel
def
qroom
(
room
)
def
qroom
(
room
)
send
(
10
,
@key
,
room
.
id
,
checknum
(
"QROOM"
,
@session
+
room
.
id
.
to_s
))
send
(
10
,
@key
,
room
.
id
,
checknum
(
"QROOM"
,
@session
+
room
.
id
.
to_s
))
end
end
def
action
(
action
)
send
(
2
,
"
#{
checknum
(
"RMSG"
,
@session
)
}
@
#{
@key
}
"
,
"
#{
action
.
escape
}
▊▊▊000000"
)
#TODO
end
def
host
(
name
,
password
=
""
,
lv
=
0
,
color
=
0
)
def
host
(
name
,
password
=
""
,
lv
=
0
,
color
=
0
)
send
(
6
,
@key
,
name
,
password
,
checknum
(
"JOINROOMMSG"
,
@session
+
name
+
password
+
"0"
),
0
,
color
,
lv
,
0
,
nil
,
nil
)
#TODO:v.ak, v.al
send
(
6
,
@key
,
name
,
password
,
checknum
(
"JOINROOMMSG"
,
@session
+
name
+
password
+
"0"
),
0
,
color
,
lv
,
0
,
nil
,
nil
)
#TODO:v.ak, v.al
end
end
...
@@ -102,7 +74,7 @@ class Iduel
...
@@ -102,7 +74,7 @@ class Iduel
def
quit
def
quit
send
(
11
,
@key
,
checknum
(
"ULO"
,
"
#{
@session
}
"
))
send
(
11
,
@key
,
checknum
(
"ULO"
,
"
#{
@session
}
"
))
end
end
class
Iduel
::
User
class
User
@@all
=
[]
@@all
=
[]
attr_accessor
:id
,
:name
,
:level
,
:exp
attr_accessor
:id
,
:name
,
:level
,
:exp
class
<<
self
class
<<
self
...
@@ -145,7 +117,7 @@ class Iduel
...
@@ -145,7 +117,7 @@ class Iduel
end
end
end
end
class
Iduel
::
Room
class
Room
@@all
=
[]
@@all
=
[]
attr_accessor
:id
,
:name
,
:player1
,
:player2
,
:private
,
:color
attr_accessor
:id
,
:name
,
:player1
,
:player2
,
:private
,
:color
class
<<
self
class
<<
self
...
@@ -176,172 +148,7 @@ class Iduel
...
@@ -176,172 +148,7 @@ class Iduel
alias
private
?
private
alias
private
?
private
end
end
Event
=
Class
.
new
{
@queue
=
[]}
class
<<
Event
def
push
(
event
)
@queue
<<
event
end
def
poll
@queue
.
shift
end
end
class
Event
::
LOGINOK
<
Event
attr_reader
:
user
,
:session
def
initialize
(
info
)
info
=
info
.
split
(
","
)
#>> $B|201629,zh99997,5da9e5fa,Level-1 (总经验:183),,20101118
info
[
3
]
=~
/Level-(\d)+ \(总经验:(\d+)\)/
$iduel
.
user
=
@user
=
User
.
new
(
info
[
0
].
to_i
,
info
[
1
],
$1
.
to_i
,
$2
.
to_i
)
$iduel
.
session
=
@session
=
info
[
2
]
$iduel
.
key
=
(
$iduel
.
user
.
id
-
0x186a0
)
^
0x22133
end
end
class
Event
::
OLIF
<
Event
attr_reader
:users
def
initialize
(
info
)
@users
=
info
.
split
(
','
).
collect
do
|
user
|
Iduel
::
User
.
new
(
user
)
end
end
end
class
Event
::
RMIF
<
Event
attr_reader
:rooms
def
initialize
(
info
)
info
=
info
.
split
(
"|"
)
@rooms
=
[]
templist
=
@rooms
empty
=
false
info
.
each
do
|
room
|
if
room
==
'~~'
empty
=
true
templist
=
[]
else
room
=
room
.
split
(
","
)
templist
<<
if
empty
Iduel
::
Room
.
new
(
room
[
0
].
to_i
,
room
[
1
],
Iduel
::
User
.
new
(
room
[
2
]),
nil
,
room
[
3
]
==
"1"
,
Iduel
::
Color
[
room
[
4
].
to_i
],
nil
,
room
[
6
])
else
Iduel
::
Room
.
new
(
room
[
0
].
to_i
,
room
[
3
],
Iduel
::
User
.
new
(
room
[
1
]),
Iduel
::
User
.
new
(
room
[
2
]),
false
,
Iduel
::
Color
[
room
[
5
].
to_i
],
room
[
3
])
end
end
end
@rooms
=
templist
+
@rooms
end
end
class
Event
::
NOL
<
Event
def
initialize
(
info
)
super
@args
=
@args
.
collect
do
|
user
|
Iduel
::
User
.
new
(
user
)
end
end
end
class
Event
::
DOL
<
Event
def
initialize
(
info
)
super
@args
=
@args
.
collect
do
|
user
|
Iduel
::
User
.
new
(
user
)
end
end
end
class
Event
::
PCHAT
<
Event
attr_reader
:user
,
:content
def
initialize
(
info
)
user
,
@content
=
info
.
split
(
","
,
2
)
@user
=
Iduel
::
User
.
new
user
end
end
class
Event
::
JOINROOMOK
<
Event
attr_reader
:room
def
initialize
(
id
)
@room
=
Iduel
::
Room
.
new
(
id
)
end
end
class
Event
::
QROOMOK
<
Event
end
class
Event
::
SingleRoomInfo
<
Event
def
initialize
(
info
)
id
,
x
,
player1
,
player2
=
info
.
split
(
","
,
4
)
@room
=
Room
.
new
(
id
)
@room
.
player1
=
User
.
new
(
player1
)
@room
.
player2
=
User
.
new
(
player2
)
end
end
#"Q"
#"273,1,zh99998(201448),zh99997(201629)"
class
Event
::
WATCHROOMSTART
<
Event
def
initialize
(
info
)
id
,
name
=
info
.
split
(
","
,
1
)
@room
=
Iduel
::
Room
.
new
(
id
.
to_i
,
name
,
''
,
''
,
false
,
Color
[
0
])
#:name, :player1, :player2, :crypted, :color
end
end
class
Event
::
UMSG
<
Event
attr_reader
:action
def
initialize
(
info
)
@action
=
Action
.
parse
info
p
@action
end
end
class
Event
::
WMSG
<
Event
def
initialize
(
info
)
#black_st(212671), [109] ┊墓地,苍岩┊
#p info
#p $1, $2
info
=~
/(.+)\((\d+)\), \[(\d+)\] (.*)/m
#cchenwor(211650), [27] ◎→<[效果怪兽][盟军·次世代鸟人] 1400 400>攻击8
@args
=
[
$1
,
$2
,
$3
,
$4
]
end
end
class
Event
::
WATCHSTOP
<
Event
end
class
Event
::
Error
<
Event
def
initialize
(
info
)
@title
,
@message
=
case
info
.
to_i
when
0x00
[
"网络错误"
,
"网络连接中断"
]
when
0x65
[
"出错啦~"
,
"服务器程序出现未知错误,请记录好出现错误的事件,并联系管理员。"
]
when
0x66
[
"错误"
,
"通信验证错误"
]
when
0x67
[
"错误"
,
"通信钥匙错误"
]
when
0xc9
[
"登录失败"
,
"错误的帐号名或密码"
]
when
0xca
[
"登录失败"
,
"你的账号还未激活"
]
when
0xcb
[
"登录失败"
,
"你的账号被系统封锁"
]
when
0x12d
[
"错误"
,
"房间已满"
]
when
0x12e
[
"错误"
,
"房间密码错误"
]
when
0x12f
[
"错误"
,
"你没有权限给房间上密码"
]
when
0x130
[
"错误"
,
"你已经加入房间,请不要重新加入"
]
when
0x131
[
"加入房间"
,
"你未达到房间要求的等级限制。"
]
when
0x132
[
"观战错误"
,
"所请求的房间无效,或未开始决斗"
]
when
0x133
[
"观战错误"
,
"你已经在该房间观战"
]
when
0x134
[
"发送信息错误"
,
"你还未加入房间"
]
when
0x135
[
"错误"
,
"请求的房间无效"
]
end
#Exception.new(@message).raise
puts
@title
.
encode!
"GBK"
puts
@message
.
encode!
"GBK"
#system("pause")
end
end
class
Event
::
UNKNOWN
<
Event
def
initialize
(
*
args
)
#puts "Unknown Server Return:#{@last_info}:#{args.inspect}"
end
end
end
end
__END__
__END__
$conn = Iduel.new
$conn = Iduel.new
...
...
lib/iduel_action.rb
View file @
a1087bbe
class
<<
Action
require_relative
'action'
class
Action
CardFilter
=
/(<\[.*?\]\[(?:.*?)\][\s\d]*>|一张怪兽卡|一张魔\/陷卡)/
.
to_s
CardFilter
=
/(<\[.*?\]\[(?:.*?)\][\s\d]*>|一张怪兽卡|一张魔\/陷卡)/
.
to_s
PosFilter
=
/((?:手卡|场上|魔陷区|怪兽区|墓地|额外牌堆|除外区|卡组顶端|\(\d+\)){1,2})/
.
to_s
PosFilter
=
/((?:手卡|场上|魔陷区|怪兽区|墓地|额外牌堆|除外区|卡组顶端|\(\d+\)){1,2})/
.
to_s
PositionFilter
=
/(|攻击表示|防守表示|里侧表示|背面守备表示)/
.
to_s
PositionFilter
=
/(|攻击表示|防守表示|里侧表示|背面守备表示)/
.
to_s
def
parse_pos
(
pos
)
def
self
.
parse_pos
(
pos
)
if
index
=
pos
.
index
(
"("
)
if
index
=
pos
.
index
(
"("
)
index
+=
1
index
+=
1
pos
[
index
,
pos
.
index
(
")"
)
-
index
].
to_i
pos
[
index
,
pos
.
index
(
")"
)
-
index
].
to_i
...
@@ -23,7 +24,7 @@ class <<Action
...
@@ -23,7 +24,7 @@ class <<Action
end
end
end
end
end
end
def
parse_card
(
card
)
def
self
.
parse_card
(
card
)
if
index
=
card
.
rindex
(
"["
)
if
index
=
card
.
rindex
(
"["
)
index
+=
1
index
+=
1
Card
.
find
(
card
[
index
,
card
.
rindex
(
"]"
)
-
index
].
to_sym
)
Card
.
find
(
card
[
index
,
card
.
rindex
(
"]"
)
-
index
].
to_sym
)
...
@@ -31,7 +32,7 @@ class <<Action
...
@@ -31,7 +32,7 @@ class <<Action
Card
.
find
(
nil
)
Card
.
find
(
nil
)
end
end
end
end
def
parse_position
(
position
)
def
self
.
parse_position
(
position
)
case
position
case
position
when
"攻击表示"
when
"攻击表示"
:attack
:attack
...
@@ -41,7 +42,7 @@ class <<Action
...
@@ -41,7 +42,7 @@ class <<Action
:set
:set
end
end
end
end
def
escape_pos
(
pos
)
def
self
.
escape_pos
(
pos
)
case
pos
case
pos
when
0
..
5
when
0
..
5
"魔陷区(
#{
pos
}
)"
"魔陷区(
#{
pos
}
)"
...
@@ -59,7 +60,7 @@ class <<Action
...
@@ -59,7 +60,7 @@ class <<Action
"卡组顶端"
"卡组顶端"
end
end
end
end
def
escape_position
(
position
)
def
self
.
escape_position
(
position
)
case
position
case
position
when
:attack
when
:attack
"攻击表示"
"攻击表示"
...
@@ -69,7 +70,7 @@ class <<Action
...
@@ -69,7 +70,7 @@ class <<Action
"里侧表示"
"里侧表示"
end
end
end
end
def
escape_card
(
card
)
def
self
.
escape_card
(
card
)
if
[:
通常魔法
,
:
永续魔法
,
:
装备魔法
,
:
场地魔法
,
:
通常陷阱
,
:
永续陷阱
,
:
反击陷阱
].
include?
card
.
card_type
if
[:
通常魔法
,
:
永续魔法
,
:
装备魔法
,
:
场地魔法
,
:
通常陷阱
,
:
永续陷阱
,
:
反击陷阱
].
include?
card
.
card_type
if
card
.
position
==
:set
if
card
.
position
==
:set
"一张魔/陷卡"
"一张魔/陷卡"
...
@@ -84,7 +85,7 @@ class <<Action
...
@@ -84,7 +85,7 @@ class <<Action
end
end
end
end
end
end
def
parse
(
str
)
def
self
.
parse
(
str
)
str
=~
/^\[\d+\] (.*)▊▊▊.*?$/m
str
=~
/^\[\d+\] (.*)▊▊▊.*?$/m
from_player
=
false
from_player
=
false
case
$1
case
$1
...
@@ -144,6 +145,14 @@ class <<Action
...
@@ -144,6 +145,14 @@ class <<Action
end
end
end
end
def
escape
def
escape
case
self
when
FirstToGo
"[
#{
@id
}
] ◎→[11年3月1日禁卡表]先攻"
when
Reset
"[
#{
@id
}
] ◎→[11年3月1日禁卡表] Duel!!"
end
end
def
run
$iduel
.
action
self
end
end
end
end
\ No newline at end of file
lib/iduel_event.rb
0 → 100644
View file @
a1087bbe
class
Iduel
Event
=
Class
.
new
{
@queue
=
[]}
#避开SDL::Event问题,所以没有用class Event
class
Event
def
self
.
push
(
event
)
@queue
<<
event
end
def
self
.
poll
@queue
.
shift
end
def
self
.
parse
(
info
)
info
=~
/^\$([A-Z])\|(.*)$/m
Event
.
push
case
$1
when
"A"
Event
::
Error
when
"B"
Event
::
LOGINOK
when
"C"
Event
::
OLIF
when
"F"
Event
::
JOINROOMOK
when
"G"
Event
::
WATCHROOMSTART
when
"J"
Event
::
UMSG
when
"K"
Event
::
WMSG
when
"M"
Event
::
QROOMOK
#TODO
when
"O"
Event
::
PCHAT
when
"P"
Event
::
RMIF
when
"Q"
Event
::
SingleRoomInfo
when
"R"
Event
::
QROOMOK
#卡表
else
p
$1
,
$2
system
(
"pause"
)
Event
::
UNKNOWN
end
.
new
(
$2
)
end
class
LOGINOK
<
Event
attr_reader
:user
,
:session
def
initialize
(
info
)
info
=
info
.
split
(
","
)
#>> $B|201629,zh99997,5da9e5fa,Level-1 (总经验:183),,20101118
info
[
3
]
=~
/Level-(\d)+ \(总经验:(\d+)\)/
$iduel
.
user
=
@user
=
User
.
new
(
info
[
0
].
to_i
,
info
[
1
],
$1
.
to_i
,
$2
.
to_i
)
$iduel
.
session
=
@session
=
info
[
2
]
$iduel
.
key
=
(
$iduel
.
user
.
id
-
0x186a0
)
^
0x22133
end
end
class
OLIF
<
Event
attr_reader
:users
def
initialize
(
info
)
@users
=
info
.
split
(
','
).
collect
do
|
user
|
Iduel
::
User
.
new
(
user
)
end
end
end
class
RMIF
<
Event
attr_reader
:rooms
def
initialize
(
info
)
info
=
info
.
split
(
"|"
)
@rooms
=
[]
templist
=
@rooms
empty
=
false
info
.
each
do
|
room
|
if
room
==
'~~'
empty
=
true
templist
=
[]
else
room
=
room
.
split
(
","
)
templist
<<
if
empty
Iduel
::
Room
.
new
(
room
[
0
].
to_i
,
room
[
1
],
Iduel
::
User
.
new
(
room
[
2
]),
nil
,
room
[
3
]
==
"1"
,
Iduel
::
Color
[
room
[
4
].
to_i
],
nil
,
room
[
6
])
else
Iduel
::
Room
.
new
(
room
[
0
].
to_i
,
room
[
3
],
Iduel
::
User
.
new
(
room
[
1
]),
Iduel
::
User
.
new
(
room
[
2
]),
false
,
Iduel
::
Color
[
room
[
5
].
to_i
],
room
[
3
])
end
end
end
@rooms
=
templist
+
@rooms
end
end
class
NOL
<
Event
def
initialize
(
info
)
super
@args
=
@args
.
collect
do
|
user
|
Iduel
::
User
.
new
(
user
)
end
end
end
class
DOL
<
Event
def
initialize
(
info
)
super
@args
=
@args
.
collect
do
|
user
|
Iduel
::
User
.
new
(
user
)
end
end
end
class
PCHAT
<
Event
attr_reader
:user
,
:content
def
initialize
(
info
)
user
,
@content
=
info
.
split
(
","
,
2
)
@user
=
Iduel
::
User
.
new
user
end
end
class
JOINROOMOK
<
Event
attr_reader
:room
def
initialize
(
id
)
@room
=
Iduel
::
Room
.
new
(
id
)
end
end
class
QROOMOK
<
Event
end
class
SingleRoomInfo
<
Event
def
initialize
(
info
)
id
,
x
,
player1
,
player2
=
info
.
split
(
","
,
4
)
@room
=
Room
.
new
(
id
)
@room
.
player1
=
User
.
new
(
player1
)
@room
.
player2
=
User
.
new
(
player2
)
end
end
#"Q"
#"273,1,zh99998(201448),zh99997(201629)"
class
WATCHROOMSTART
<
Event
def
initialize
(
info
)
id
,
name
=
info
.
split
(
","
,
1
)
@room
=
Iduel
::
Room
.
new
(
id
.
to_i
,
name
,
''
,
''
,
false
,
Color
[
0
])
#:name, :player1, :player2, :crypted, :color
end
end
class
UMSG
<
Event
attr_reader
:action
def
initialize
(
info
)
@action
=
Action
.
parse
info
p
@action
end
end
class
WMSG
<
Event
def
initialize
(
info
)
#black_st(212671), [109] ┊墓地,苍岩┊
#p info
#p $1, $2
info
=~
/(.+)\((\d+)\), \[(\d+)\] (.*)/m
#cchenwor(211650), [27] ◎→<[效果怪兽][盟军·次世代鸟人] 1400 400>攻击8
@args
=
[
$1
,
$2
,
$3
,
$4
]
end
end
class
WATCHSTOP
<
Event
end
class
Error
<
Event
def
initialize
(
info
)
@title
,
@message
=
case
info
.
to_i
when
0x00
[
"网络错误"
,
"网络连接中断"
]
when
0x65
[
"出错啦~"
,
"服务器程序出现未知错误,请记录好出现错误的事件,并联系管理员。"
]
when
0x66
[
"错误"
,
"通信验证错误"
]
when
0x67
[
"错误"
,
"通信钥匙错误"
]
when
0xc9
[
"登录失败"
,
"错误的帐号名或密码"
]
when
0xca
[
"登录失败"
,
"你的账号还未激活"
]
when
0xcb
[
"登录失败"
,
"你的账号被系统封锁"
]
when
0x12d
[
"错误"
,
"房间已满"
]
when
0x12e
[
"错误"
,
"房间密码错误"
]
when
0x12f
[
"错误"
,
"你没有权限给房间上密码"
]
when
0x130
[
"错误"
,
"你已经加入房间,请不要重新加入"
]
when
0x131
[
"加入房间"
,
"你未达到房间要求的等级限制。"
]
when
0x132
[
"观战错误"
,
"所请求的房间无效,或未开始决斗"
]
when
0x133
[
"观战错误"
,
"你已经在该房间观战"
]
when
0x134
[
"发送信息错误"
,
"你还未加入房间"
]
when
0x135
[
"错误"
,
"请求的房间无效"
]
end
#Exception.new(@message).raise
puts
@title
.
encode!
"GBK"
puts
@message
.
encode!
"GBK"
#system("pause")
end
end
class
UNKNOWN
<
Event
def
initialize
(
*
args
)
#puts "Unknown Server Return:#{@last_info}:#{args.inspect}"
end
end
end
end
\ No newline at end of file
lib/scene.rb
View file @
a1087bbe
...
@@ -24,7 +24,6 @@ class Scene
...
@@ -24,7 +24,6 @@ class Scene
def
refresh_rect
(
x
,
y
,
width
,
height
)
def
refresh_rect
(
x
,
y
,
width
,
height
)
Surface
.
blit
(
@background
,
x
,
y
,
width
,
height
,
$screen
,
x
,
y
)
Surface
.
blit
(
@background
,
x
,
y
,
width
,
height
,
$screen
,
x
,
y
)
yield
yield
#p x,y,width, height
$screen
.
update_rect
(
x
,
y
,
width
,
height
)
$screen
.
update_rect
(
x
,
y
,
width
,
height
)
end
end
#--------------------------------------------------------------------------
#--------------------------------------------------------------------------
...
...
lib/scene_duel.rb
View file @
a1087bbe
...
@@ -39,8 +39,11 @@ class Scene_Duel < Scene
...
@@ -39,8 +39,11 @@ class Scene_Duel < Scene
Action
.
opponent_field
=
@opponent
Action
.
opponent_field
=
@opponent
$screen
.
update_rect
(
0
,
0
,
0
,
0
)
$screen
.
update_rect
(
0
,
0
,
0
,
0
)
post_start
end
def
post_start
first_to_go
end
end
def
change_phase
(
phase
)
def
change_phase
(
phase
)
if
phase
==
5
if
phase
==
5
@turn_player
=
!
@turn_player
@turn_player
=
!
@turn_player
...
@@ -51,6 +54,12 @@ class Scene_Duel < Scene
...
@@ -51,6 +54,12 @@ class Scene_Duel < Scene
@phases_window
.
refresh
@phases_window
.
refresh
end
end
end
end
def
reset
Action
::
Reset
.
new
(
true
).
run
end
def
first_to_go
Action
::
FirstToGo
.
new
(
true
).
run
end
def
handle
(
event
)
def
handle
(
event
)
case
event
case
event
when
Event
::
MouseMotion
when
Event
::
MouseMotion
...
@@ -72,15 +81,24 @@ class Scene_Duel < Scene
...
@@ -72,15 +81,24 @@ class Scene_Duel < Scene
@phases_window
.
index
=
@phase
@phases_window
.
index
=
@phase
end
end
end
end
end
when
Event
::
KeyDown
case
event
.
sym
when
Key
::
F1
suffle
when
Key
::
F2
draw
when
Key
::
F5
reset
end
else
else
super
super
end
end
end
end
end
def
handle_iduel
(
event
)
def
handle_iduel
(
event
)
case
event
case
event
when
Iduel
::
Event
::
UMSG
when
Iduel
::
Event
::
Action
event
.
action
.
do
event
.
action
.
run
@player_field_window
.
refresh
@player_field_window
.
refresh
end
end
end
end
...
@@ -90,4 +108,11 @@ class Scene_Duel < Scene
...
@@ -90,4 +108,11 @@ class Scene_Duel < Scene
handle_iduel
(
event
)
handle_iduel
(
event
)
end
end
end
end
def
refresh_rect
(
x
,
y
,
width
,
height
)
return
unless
$scene
=
self
#线程的情况
p
@background
,
$screen
Surface
.
blit
(
@background
,
x
,
y
,
width
,
height
,
$screen
,
x
,
y
)
yield
$screen
.
update_rect
(
x
,
y
,
width
,
height
)
end
end
end
\ No newline at end of file
lib/scene_hall.rb
View file @
a1087bbe
...
@@ -47,10 +47,16 @@ class Scene_Hall < Scene
...
@@ -47,10 +47,16 @@ class Scene_Hall < Scene
when
Key
::
RETURN
when
Key
::
RETURN
@active_window
.
clicked
@active_window
.
clicked
when
Key
::
F5
when
Key
::
F5
if
room
=
@roomlist
.
list
.
find
{
|
room
|
room
.
player1
==
$iduel
.
user
or
room
.
player2
==
$iduel
.
user
}
if
@roomlist
and
room
=
@roomlist
.
list
.
find
{
|
room
|
room
.
player1
==
$iduel
.
user
or
room
.
player2
==
$iduel
.
user
}
$iduel
.
qroom
room
$iduel
.
qroom
room
end
end
$iduel
.
upinfo
$iduel
.
upinfo
when
Key
::
F12
if
@roomlist
and
room
=
@roomlist
.
list
.
find
{
|
room
|
room
.
player1
==
$iduel
.
user
or
room
.
player2
==
$iduel
.
user
}
$iduel
.
qroom
room
end
$iduel
.
close
$scene
=
Scene_Login
.
new
end
end
when
Event
::
KeyUp
when
Event
::
KeyUp
case
event
.
sym
case
event
.
sym
...
@@ -155,7 +161,7 @@ def a
...
@@ -155,7 +161,7 @@ def a
if room.full?
if room.full?
$iduel.watch room
$iduel.watch room
else
else
$iduel.join room, "
test
"
$iduel.join room, "
zh
"
end
end
end
end
when :right
when :right
...
...
lib/ugl.rb
deleted
100644 → 0
View file @
f2bd1309
require_relative
'ugl/sprite'
require_relative
'ugl/graphics'
require_relative
'ugl/event'
require_relative
'ugl/color'
require_relative
'ugl/font'
require_relative
'ugl/image'
require_relative
'ugl/audio'
#require_relative 'ugl/textimage'
require_relative
'ugl/window'
log.txt
0 → 100644
View file @
a1087bbe
#<SDL::Event::Active:0x2b134f0 @gain=false, @state=1>
#<SDL::Event::Active:0x2b13310 @gain=false, @state=2>
#<SDL::Event::Active:0x2b131c0 @gain=true, @state=1>
#<SDL::Event::Active:0x2b13040 @gain=false, @state=1>
#<SDL::Event::Active:0x2b12ed8 @gain=true, @state=6>
#<SDL::Event::Active:0x2b12d70 @gain=true, @state=1>
#<SDL::Event::Active:0x2b127b8 @gain=false, @state=1>
#<SDL::Event::Active:0x2b12668 @gain=true, @state=1>
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