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
fe974547
Commit
fe974547
authored
Dec 18, 2011
by
神楽坂玲奈
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
iduel观战初步
parent
aebd808b
Changes
21
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
21 changed files
with
487 additions
and
409 deletions
+487
-409
lib/action.rb
lib/action.rb
+3
-0
lib/cacheable.rb
lib/cacheable.rb
+6
-3
lib/game.rb
lib/game.rb
+2
-2
lib/game_event.rb
lib/game_event.rb
+5
-2
lib/iduel/action.rb
lib/iduel/action.rb
+187
-95
lib/iduel/event.rb
lib/iduel/event.rb
+176
-173
lib/iduel/iduel.rb
lib/iduel/iduel.rb
+41
-39
lib/iduel/room.rb
lib/iduel/room.rb
+0
-30
lib/iduel/user.rb
lib/iduel/user.rb
+12
-27
lib/nbx/event.rb
lib/nbx/event.rb
+4
-4
lib/nbx/nbx.rb
lib/nbx/nbx.rb
+0
-2
lib/nbx/room.rb
lib/nbx/room.rb
+0
-2
lib/nbx/user.rb
lib/nbx/user.rb
+0
-2
lib/room.rb
lib/room.rb
+16
-1
lib/scene_duel.rb
lib/scene_duel.rb
+5
-2
lib/scene_hall.rb
lib/scene_hall.rb
+1
-1
lib/scene_login.rb
lib/scene_login.rb
+20
-19
lib/scene_watch.rb
lib/scene_watch.rb
+3
-1
lib/user.rb
lib/user.rb
+6
-2
lib/window_action.rb
lib/window_action.rb
+0
-1
lib/window_field.rb
lib/window_field.rb
+0
-1
No files found.
lib/action.rb
View file @
fe974547
...
...
@@ -95,6 +95,9 @@ class Action
player_field
.
extra
when
:removed
player_field
.
removed
else
puts
'奇怪的from_field'
puts
end
if
@from_pos
.
is_a?
Integer
...
...
lib/cacheable.rb
View file @
fe974547
...
...
@@ -2,8 +2,11 @@ module Cacheable
@@all
=
{}
def
new
(
id
,
*
args
)
@@all
[
self
]
||=
{}
@@all
[
self
][
id
]
||=
super
()
@@all
[
self
][
id
].
set
(
id
,
*
args
)
@@all
[
self
][
id
]
if
result
=
@@all
[
self
][
id
]
result
.
set
(
id
,
*
args
)
result
else
@@all
[
self
][
id
]
=
super
(
id
,
*
args
)
end
end
end
\ No newline at end of file
lib/game.rb
View file @
fe974547
...
...
@@ -8,10 +8,10 @@ class Game
@users
=
[]
@rooms
=
[]
end
def
refresh
end
def
login
(
username
,
password
=
nil
)
end
def
refresh
end
def
host
end
def
join
(
room
)
...
...
lib/game_event.rb
View file @
fe974547
...
...
@@ -98,7 +98,10 @@ class Game_Event
$game
.
room
=
@room
end
end
class
Leave
<
Game_Event
def
initialize
end
end
class
PlayerJoin
<
Game_Event
attr_reader
:user
def
initialize
(
user
)
...
...
@@ -114,7 +117,7 @@ class Game_Event
class
Action
<
Game_Event
attr_reader
:action
,
:str
def
initialize
(
action
,
str
=
A
ction
.
escape
)
def
initialize
(
action
,
str
=
a
ction
.
escape
)
@action
=
action
@str
=
str
end
...
...
lib/iduel/action.rb
View file @
fe974547
This diff is collapsed.
Click to expand it.
lib/iduel/event.rb
View file @
fe974547
#encoding: UTF-8
Game_Event
=
Class
.
new
#避开SDL::Event问题,所以没有用class Game_Event::Event
class
Game_Event
@queue
=
[]
def
self
.
push
(
event
)
@queue
<<
event
end
def
self
.
poll
@queue
.
shift
end
def
self
.
parse
(
info
)
info
=~
/^\$([A-Z])\|(.*)$/m
case
$1
when
"A"
Game_Event
::
Error
Error
when
"B"
Game_Event
::
LOGINOK
Login
when
"C"
Game_Event
::
AllUsers
AllUsers
when
"F"
Game_Event
::
JOINROOMOK
Join
when
"G"
Game_Event
::
WATCHROOMSTART
Watch
when
"H"
Leave
when
"J"
Game_Event
::
Action
Action
when
"K"
Game_Event
::
WMSG
WatchAction
when
"M"
Game_Event
::
QROOMOK
#TODO
QROOMOK
#TODO
when
"O"
Game_Event
::
PCHAT
Chat
when
"P"
Game_Event
::
AllRooms
AllRooms
when
"Q"
Game_Event
::
NewRoom
NewRoom
when
"R"
Game_Event
::
QROOMOK
#卡表
QROOMOK
#卡表
else
Game_Event
::
UNKNOWN
end
.
new
(
$2
)
Unknown
end
.
parse
(
$2
)
end
end
class
Game_Event
::
LOGINOK
<
Game_Event
attr_reader
:user
,
:sessio
n
def
initializ
e
(
info
)
class
Logi
n
def
self
.
pars
e
(
info
)
info
=
info
.
split
(
","
)
#>> $B|201629,zh99997,5da9e5fa,Level-1 (总经验:183),,20101118
info
[
3
]
=~
/Level-(\d)+ \(总经验:(\d+)\)/
$game
.
user
=
@user
=
Iduel
::
User
.
new
(
info
[
0
].
to_i
,
info
[
1
],
$1
.
to_i
,
$2
.
to_i
)
$game
.
session
=
@
session
=
info
[
2
]
result
=
self
.
new
User
.
new
(
info
[
0
].
to_i
,
info
[
1
],
$1
.
to_i
,
$2
.
to_i
)
$game
.
session
=
info
[
2
]
$game
.
key
=
(
$game
.
user
.
id
-
0x186a0
)
^
0x22133
result
end
end
class
Game_Event
::
AllUsers
<
Game_Event
attr_reader
:users
def
initialize
(
info
)
@users
=
info
.
split
(
','
).
collect
do
|
user
|
Iduel
::
User
.
new
(
user
)
end
class
AllUsers
def
self
.
parse
(
info
)
self
.
new
info
.
split
(
','
).
collect
{
|
user
|
User
.
parse
(
user
)}
end
end
end
class
Game_Event
::
AllRooms
<
Game_Event
attr_reader
:rooms
def
initialize
(
info
)
class
AllRooms
def
self
.
parse
(
info
)
info
=
info
.
split
(
"|"
)
@
rooms
=
[]
templist
=
@
rooms
rooms
=
[]
templist
=
rooms
empty
=
false
info
.
each
do
|
room
|
if
room
==
'~~'
...
...
@@ -74,89 +64,87 @@ class Game_Event::AllRooms < Game_Event
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
])
Room
.
new
(
room
[
0
].
to_i
,
room
[
1
],
User
.
parse
(
room
[
2
]),
nil
,
room
[
3
]
==
"1"
,
Room
::
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
])
Room
.
new
(
room
[
0
].
to_i
,
room
[
3
],
User
.
parse
(
room
[
1
]),
User
.
parse
(
room
[
2
]),
false
,
Room
::
Color
[
room
[
5
].
to_i
],
room
[
3
])
end
end
end
@rooms
=
templist
+
@
rooms
$game
.
rooms
=
@
rooms
rooms
=
templist
+
rooms
self
.
new
rooms
end
end
class
Game_Event
::
NOL
<
Game_Event
def
initialize
(
info
)
super
@args
=
@args
.
collect
do
|
user
|
Iduel
::
User
.
new
(
user
)
end
class
NewUser
def
self
.
parse
(
info
)
p
info
#super
#@args = @args.collect do |user|
# User.new(user)
#end
end
end
class
Game_Event
::
DOL
<
Game_Event
def
initialize
(
info
)
super
@args
=
@args
.
collect
do
|
user
|
Iduel
::
User
.
new
(
user
)
end
class
MissingUser
def
self
.
parse
(
info
)
p
info
#super
#@args = @args.collect do |user|
# User.new(user)
#end
end
end
end
class
Game_Event
::
PCHAT
<
Game_Event
attr_reader
:user
,
:content
def
initialize
(
info
)
user
,
@content
=
info
.
split
(
","
,
2
)
@user
=
user
==
"System"
?
Iduel
::
User
.
new
(
100000
,
"iDuel管理中心"
)
:
Iduel
::
User
.
new
(
user
)
class
Join
def
self
.
parse
(
info
)
self
.
new
Room
.
new
(
info
.
to_i
)
end
end
class
Game_Event
::
JOINROOMOK
<
Game_Event
attr_reader
:room
def
initialize
(
id
)
@room
=
Iduel
::
Room
.
new
(
id
)
end
end
class
Game_Event
::
QROOMOK
<
Game_Event
end
class
Game_Event
::
NewRoom
<
Game_Event
def
initialize
(
info
)
class
Leave
def
self
.
parse
(
info
)
self
.
new
end
end
class
NewRoom
def
self
.
parse
(
info
)
id
,
x
,
player1
,
player2
=
info
.
split
(
","
,
4
)
@room
=
Iduel
::
Room
.
new
(
id
)
@room
.
player1
=
Iduel
::
User
.
new
(
player1
)
@room
.
player2
=
Iduel
::
User
.
new
(
player2
)
$game
.
rooms
<<
@room
unless
$game
.
rooms
.
include?
@
room
room
=
Room
.
new
(
id
)
room
.
player1
=
User
.
parse
(
player1
)
room
.
player2
=
User
.
parse
(
player2
)
self
.
new
room
end
end
#"Q"
#"273,1,zh99998(201448),zh99997(201629)"
class
Game_Event
::
WATCHROOMSTART
<
Game_Event
end
#"Q"
#"273,1,zh99998(201448),zh99997(201629)"
class
Watch
attr_reader
:room
def
initializ
e
(
info
)
id
,
name
=
info
.
split
(
","
,
1
)
@room
=
Iduel
::
Room
.
new
(
id
.
to_i
,
name
,
''
,
''
,
false
,
Iduel
::
Color
[
0
])
#:name, :player1, :player2, :crypted, :color
def
self
.
pars
e
(
info
)
id
,
name
=
info
.
split
(
","
,
2
)
self
.
new
Room
.
new
(
id
.
to_i
,
name
)
end
end
class
Game_Event
::
Action
<
Game_Event
end
class
Action
attr_reader
:action
def
initialize
(
info
)
info
[
"◎"
]
=
"●"
if
info
=~
/^\[\d+\] (?:.*\r\n){0,1}(◎)→.*▊▊▊.*$/
@action
=
::
Action
.
parse
info
p
@action
def
self
.
parse
(
info
)
info
=~
/(.*)▊▊▊.*?$/
info
=
$1
info
[
"◎"
]
=
"●"
if
info
[
"◎"
]
self
.
new
::
Action
.
parse
info
end
end
class
Game_Event
::
WMSG
<
Game_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
Game_Event
::
WATCHSTOP
<
Game_Event
end
class
Game_Event
::
Error
<
Game_Event
class
Leave
end
class
Chat
attr_reader
:user
,
:content
alias
old_initialize
initialize
def
self
.
parse
(
info
)
user
,
content
=
info
.
split
(
","
,
2
)
user
=
user
==
"System"
?
User
.
new
(
100000
,
"iDuel管理中心"
)
:
User
.
parse
(
user
)
self
.
new
(
user
,
content
,
:hall
)
end
end
class
Error
attr_reader
:title
,
:message
def
initializ
e
(
info
)
@title
,
@
message
=
case
info
.
to_i
def
self
.
pars
e
(
info
)
title
,
message
=
case
info
.
to_i
when
0x00
[
"网络错误"
,
"网络连接中断"
]
when
0x65
...
...
@@ -190,17 +178,32 @@ class Game_Event::Error < Game_Event
when
0x135
[
"错误"
,
"请求的房间无效"
]
end
#Exception.new(@message).raise
p
caller
p
@title
p
@message
#system("pause")
self
.
new
title
,
message
end
end
class
Game_Event
::
UNKNOWN
<
Game_Event
def
initializ
e
(
*
args
)
puts
'--------UnK
nown Iduel Event-------'
end
class
Unknown
def
self
.
pars
e
(
*
args
)
puts
'--------Unk
nown Iduel Event-------'
p
$1
,
$2
,
args
system
(
"pause"
)
end
end
#以下iduel专有
class
WatchAction
<
Action
attr_reader
:user
def
initialize
(
action
,
str
,
user
)
@user
=
user
super
(
action
,
str
)
@action
.
from_player
=
@user
==
$game
.
room
.
player1
end
def
self
.
parse
(
info
)
info
=~
/(.+)\((\d+)\), (.*)/m
self
.
new
::
Action
.
parse
(
$3
),
$3
,
User
.
new
(
$2
.
to_i
,
$1
)
end
end
class
QROOMOK
<
Game_Event
end
end
\ No newline at end of file
lib/iduel/iduel.rb
View file @
fe974547
...
...
@@ -5,81 +5,83 @@ class Iduel < Game
Port
=
38522
RS
=
"
\xA1\xE9
"
.
force_encoding
"GBK"
Color
=
[[
0
,
0
,
0
],
[
255
,
0
,
0
],
[
0
,
255
,
0
],
[
0
,
0
,
255
],
[
255
,
165
,
0
]]
attr_accessor
:session
attr_accessor
:key
def
initialize
super
require
'socket'
require
'digest/md5'
require
'open-uri'
require_relative
'action'
require_relative
'event'
require_relative
'user'
require_relative
'room'
@conn
=
TCPSocket
.
open
(
Server
,
Port
)
@conn
.
set_encoding
"GBK"
Thread
.
abort_on_exception
=
true
@recv
=
Thread
.
new
{
recv
@conn
.
gets
(
RS
)
while
@conn
}
end
def
login
(
username
,
password
)
md5
=
Digest
::
MD5
.
hexdigest
(
password
)
send
(
0
,
username
,
md5
,
checknum
(
"LOGINMSG"
,
username
,
md5
),
VERSION
)
end
def
refresh
send
(
1
,
@key
,
checknum
(
"UPINFOMSG"
,
@session
))
end
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
end
def
join
(
room
,
password
=
""
)
send
(
6
,
@key
,
room
.
id
,
password
,
checknum
(
"JOINROOMMSG"
,
@session
+
room
.
id
.
to_s
+
password
+
"1"
),
1
)
end
def
watch
(
room
,
password
=
""
)
send
(
5
,
@key
,
room
.
id
,
password
,
checknum
(
"WATCHROOMMSG"
,
"
#{
@session
}#{
room
.
id
}#{
password
}
"
))
end
def
leave
if
@room
.
include?
@user
#
else
send
(
"QUITWATCHROOM"
,
@key
,
checknum
(
"QUITWATCHROOM"
,
@session
))
end
end
def
action
(
action
)
send
(
2
,
"
#{
checknum
(
"RMSG"
,
@session
)
}
@
#{
@key
}
"
,
"
#{
action
.
escape
}
▊▊▊000000"
)
if
@room
.
include?
@user
#TODO:iduel校验字串
end
def
exit
send
(
11
,
@key
,
checknum
(
"ULO"
,
"
#{
@session
}
"
))
@recv
.
exit
@conn
.
close
@conn
=
nil
end
def
send
(
head
,
*
args
)
info
=
"#
#{
head
.
to_s
(
16
).
upcase
}
|
#{
args
.
join
(
','
)
}
"
.
encode
(
"GBK"
)
+
RS
puts
"<<
#{
info
}
"
(
@conn
.
write
info
)
rescue
Event
.
push
Event
::
Error
.
new
(
0
)
(
@conn
.
write
info
)
rescue
Game_Event
.
push
Game_
Event
::
Error
.
new
(
0
)
end
def
recv
(
info
)
if
info
.
nil?
@conn
.
close
@conn
=
nil
Event
::
Error
.
new
(
0
)
Game_
Event
::
Error
.
new
(
0
)
else
info
.
chomp!
(
RS
)
info
.
encode!
"UTF-8"
,
:invalid
=>
:replace
,
:undef
=>
:replace
puts
">>
#{
info
}
"
Event
.
push
Event
.
parse
info
Game_Event
.
push
Game_
Event
.
parse
info
end
end
def
close
$game
.
quit
@recv
.
exit
@conn
.
close
@conn
=
nil
end
def
checknum
(
head
,
*
args
)
Digest
::
MD5
.
hexdigest
(
"[
#{
head
}
]_
#{
args
.
join
(
'_'
)
}
_SCNERO"
)
end
def
login
(
username
,
password
)
md5
=
Digest
::
MD5
.
hexdigest
(
password
)
send
(
0
,
username
,
md5
,
checknum
(
"LOGINMSG"
,
username
,
md5
),
VERSION
)
end
def
refresh
send
(
1
,
@key
,
checknum
(
"UPINFOMSG"
,
@session
))
end
def
join
(
room
,
password
=
""
)
send
(
6
,
@key
,
room
.
id
,
password
,
checknum
(
"JOINROOMMSG"
,
@session
+
room
.
id
.
to_s
+
password
+
"1"
),
1
)
end
def
qroom
(
room
)
send
(
10
,
@key
,
room
.
id
,
checknum
(
"QROOM"
,
@session
+
room
.
id
.
to_s
))
end
def
action
(
action
)
send
(
2
,
"
#{
checknum
(
"RMSG"
,
@session
)
}
@
#{
@key
}
"
,
"
#{
action
.
escape
}
▊▊▊000000"
)
#TODO:iduel校验字串
end
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
end
def
watch
(
room
,
password
=
""
)
send
(
5
,
@key
,
room
.
id
,
password
,
checknum
(
"WATCHROOMMSG"
,
"
#{
@session
}#{
room
.
id
}#{
password
}
"
))
end
def
chat
(
msg
)
send
(
4
,
@key
,
msg
,
checknum
(
"CHATP"
,
@session
))
#4|241019,test,2368c6b89b3e2eedb92e1b624a2a157c
end
def
quitwatchroom
send
(
"QUITWATCHROOM"
,
@key
,
checknum
(
"QUITWATCHROOM"
,
@session
))
end
def
quit
send
(
11
,
@key
,
checknum
(
"ULO"
,
"
#{
@session
}
"
))
end
end
\ No newline at end of file
lib/iduel/room.rb
deleted
100644 → 0
View file @
aebd808b
class
Iduel
::
Room
@@all
=
[]
attr_accessor
:id
,
:name
,
:player1
,
:player2
,
:private
,
:color
class
<<
self
alias
old_new
new
def
new
(
id
,
*
args
)
id
=
id
.
to_i
room
=
@@all
.
find
{
|
room
|
room
.
id
==
id
}
if
room
room
else
room
=
old_new
(
id
,
*
args
)
@@all
<<
room
room
end
end
end
def
initialize
(
id
,
name
,
player1
,
player2
,
private
,
color
,
session
=
nil
,
forbid
=
nil
)
@id
=
id
@name
=
name
@player1
=
player1
@player2
=
player2
@private
=
private
@color
=
color
@forbid
=
forbid
@session
=
session
end
alias
full?
player2
alias
private
?
private
end
\ No newline at end of file
lib/iduel/user.rb
View file @
fe974547
class
Iduel
::
User
@@all
=
[]
attr_accessor
:id
,
:name
,
:level
,
:exp
class
<<
self
alias
old_new
new
def
new
(
id
,
name
=
""
,
level
=
nil
,
exp
=
nil
)
if
id
.
is_a?
String
and
id
=~
/(.*)\((\d+)\)/
id
=
$2
.
to_i
name
=
$1
else
id
=
id
.
to_i
end
user
=
@@all
.
find
{
|
user
|
user
.
id
==
id
}
if
user
user
.
name
=
name
if
name
user
.
level
=
level
if
level
user
.
exp
=
exp
if
exp
user
else
user
=
old_new
(
id
,
name
,
level
,
exp
)
@@all
<<
user
user
end
end
class
User
attr_accessor
:level
,
:exp
def
self
.
parse
(
info
)
info
=~
/(.+)\((\d+)\)/
new
$2
.
to_i
,
$1
end
def
initialize
(
id
,
name
=
""
,
level
=
nil
,
exp
=
nil
)
@id
=
id
@name
=
name
@level
=
level
@exp
=
exp
#@status = :waiting
#@room = nil
end
def
set
(
id
,
name
=
:keep
,
level
=
:keep
,
exp
=
:keep
)
@id
=
id
unless
id
==
:keep
@name
=
name
unless
name
==
:keep
@level
=
level
unless
level
==
:keep
@exp
=
exp
unless
exp
==
:keep
end
def
avatar
(
size
=
:small
)
cache
=
"graphics/avatars/
#{
@id
}
_
#{
size
}
.png"
...
...
@@ -57,6 +42,6 @@ class Iduel::User
result
end
def
room
$game
.
rooms
.
find
{
|
room
|
room
.
player1
==
self
or
room
.
player2
==
self
}
$game
.
rooms
.
find
{
|
room
|
room
.
include?
self
}
end
end
\ No newline at end of file
lib/nbx/event.rb
View file @
fe974547
...
...
@@ -2,7 +2,7 @@
class
Game_Event
def
self
.
parse
(
info
,
host
=
nil
)
result
=
(
if
host
#来自大厅的udp消息
if
host
#来自大厅的udp消息
info
=~
/^(\w*)\|(.*)$/m
case
$1
when
"NewUser"
...
...
@@ -31,9 +31,7 @@ class Game_Event
else
Error
end
.
parse
(
$1
)
end
)
p
info
,
result
result
end
end
...
...
@@ -79,6 +77,8 @@ class Game_Event
self
.
new
::
Action
.
parse
(
info
),
info
end
end
#以下NBX专有
class
VerInf
def
self
.
parse
(
info
)
...
...
lib/nbx/nbx.rb
View file @
fe974547
...
...
@@ -10,8 +10,6 @@ class NBX < Game
require
'open-uri'
require_relative
'action'
require_relative
'event'
require_relative
'user'
require_relative
'room'
@conn_hall
=
UDPSocket
.
new
@conn_hall
.
setsockopt
(
Socket
::
SOL_SOCKET
,
Socket
::
SO_BROADCAST
,
true
)
...
...
lib/nbx/room.rb
deleted
100644 → 0
View file @
aebd808b
#class NBX::Room < Room
#end
\ No newline at end of file
lib/nbx/user.rb
deleted
100644 → 0
View file @
aebd808b
#class NBX::User < User
#end
\ No newline at end of file
lib/room.rb
View file @
fe974547
class
Room
Color
=
[[
0
,
0
,
0
],
[
255
,
0
,
0
],
[
0
,
255
,
0
],
[
0
,
0
,
255
],
[
255
,
165
,
0
]]
extend
Cacheable
attr_accessor
:id
,
:name
,
:player1
,
:player2
,
:private
,
:color
,
:forbid
def
set
(
id
,
name
,
player1
,
player2
=
nil
,
private
=
false
,
color
=
[
0
,
0
,
0
]
,
forbid
=
nil
)
def
initialize
(
id
,
name
=
""
,
player1
=
nil
,
player2
=
nil
,
private
=
false
,
color
=
[
0
,
0
,
0
],
session
=
nil
,
forbid
=
nil
)
@id
=
id
@name
=
name
@player1
=
player1
@player2
=
player2
@private
=
private
@color
=
color
@session
=
session
@forbid
=
forbid
end
def
set
(
id
=
:keep
,
name
=
:keep
,
player1
=
:keep
,
player2
=
:keep
,
private
=
:keep
,
color
=
:keep
,
session
=
nil
,
forbid
=
:keep
)
@id
=
id
unless
id
==
:keep
@name
=
name
unless
name
==
:keep
@player1
=
player1
unless
player1
==
:keep
@player2
=
player2
unless
player2
==
:keep
@private
=
private
unless
private
==
:keep
@color
=
color
unless
color
==
:keep
@session
=
session
unless
session
==
:keep
@forbid
=
forbid
unless
forbid
==
:keep
end
def
include?
(
user
)
@player1
==
user
or
@player2
==
user
end
alias
full?
player2
alias
private
?
private
end
\ No newline at end of file
lib/scene_duel.rb
View file @
fe974547
...
...
@@ -21,9 +21,10 @@ class Scene_Duel < Scene
attr_reader
:player_field_window
attr_reader
:opponent_field_window
attr_reader
:fieldback_window
def
initialize
(
room
)
def
initialize
(
room
,
deck
=
nil
)
super
()
@room
=
room
@deck
=
deck
end
def
start
$game
.
refresh
if
$game
...
...
@@ -37,7 +38,7 @@ class Scene_Duel < Scene
@phases_window
=
Window_Phases
.
new
(
124
,
357
)
@turn_player
=
true
$game
.
player_field
=
Game_Field
.
new
Deck
.
load
(
"test1.TXT"
)
$game
.
player_field
=
Game_Field
.
new
@deck
$game
.
opponent_field
=
Game_Field
.
new
@fieldback_window
=
Window_FieldBack
.
new
(
130
,
174
)
...
...
@@ -135,6 +136,8 @@ class Scene_Duel < Scene
@opponent_field_window
.
refresh
when
Game_Event
::
Error
Widget_Msgbox
.
new
(
event
.
title
,
event
.
message
){
$scene
=
Scene_Title
.
new
}
when
Game_Event
::
Leave
$scene
=
Scene_Hall
.
new
end
end
def
update
...
...
lib/scene_hall.rb
View file @
fe974547
...
...
@@ -80,7 +80,7 @@ class Scene_Hall < Scene
@roomlist
.
list
=
$game
.
rooms
when
Game_Event
::
Join
require_relative
'scene_duel'
$scene
=
Scene_Duel
.
new
(
event
.
room
)
$scene
=
Scene_Duel
.
new
(
event
.
room
,
Deck
.
load
(
"test1.TXT"
)
)
when
Game_Event
::
Watch
require_relative
'scene_watch'
$scene
=
Scene_Watch
.
new
(
event
.
room
)
...
...
lib/scene_login.rb
View file @
fe974547
...
...
@@ -16,24 +16,25 @@ class Scene_Login < Scene
end
end
def
login
@font
.
draw_blended_utf8
(
$screen
,
Vocab_Logging
,
0
,
0
,
255
,
0
,
255
)
$screen
.
update_rect
(
0
,
0
,
100
,
24
)
$game
=
Iduel
.
new
$game
.
login
(
@username
,
@password
)
end
def
update
while
event
=
Event
.
poll
while
event
=
Game_Event
.
poll
handle_game
(
event
)
end
super
end
def
handle
(
event
)
case
event
when
Event
::
Quit
$scene
=
nil
end
end
while
event
=
Game_Event
.
poll
def
handle_game
(
event
)
case
event
when
Game_Event
::
LOGINOK
when
Game_Event
::
Login
require_relative
'scene_hall'
$scene
=
Scene_Hall
.
new
when
Game_Event
::
Error
...
...
@@ -42,5 +43,5 @@ class Scene_Login < Scene
p
event
end
end
end
end
lib/scene_watch.rb
View file @
fe974547
...
...
@@ -5,6 +5,8 @@
#==============================================================================
require_relative
'scene_duel'
class
Scene_Watch
<
Scene_Duel
def
action
(
action
)
action
.
run
end
end
lib/user.rb
View file @
fe974547
class
User
attr_accessor
:id
,
:name
extend
Cacheable
def
set
(
id
,
name
=
""
)
def
initialize
(
id
,
name
=
""
)
@id
=
id
@name
=
name
if
name
@name
=
name
end
def
set
(
id
,
name
=
:keep
)
@id
=
id
@name
=
name
unless
name
==
:keep
end
def
avatar
(
size
=
:small
)
Surface
.
new
(
SWSURFACE
,
1
,
1
,
32
,
0
,
0
,
0
,
0
)
...
...
lib/window_action.rb
View file @
fe974547
...
...
@@ -25,7 +25,6 @@ class Window_Action < Window_List
@list_available
=
list
.
values
@height
=
@viewport
[
3
]
=
@list
.
size
*
WLH
+
15
*
2
@item_max
=
@list
.
size
p
list
@index
=
@list_available
.
find_index
(
true
)
||
0
refresh
@visible
=
true
...
...
lib/window_field.rb
View file @
fe974547
...
...
@@ -78,7 +78,6 @@ class Window_Field < Window
Surface
.
transform_draw
(
@cards
[
index
].
image_small
,
@contents
,
90
,
1
,
1
,
0
,
0
,
@items
[
index
][
0
]
+
Card_Size
[
1
],
@items
[
index
][
1
],
Surface
::
TRANSFORM_SAFE
)
@contents
.
put
(
@border_horizontal
,
@items
[
index
][
0
]
-
1
,
@items
[
index
][
1
]
-
1
)
if
status
==
1
else
p
index
,
@cards
[
index
]
@contents
.
put
(
@cards
[
index
].
image_small
,
@items
[
index
][
0
],
@items
[
index
][
1
])
@contents
.
put
(
@border
,
@items
[
index
][
0
]
-
1
,
@items
[
index
][
1
]
-
1
)
if
status
==
1
end
...
...
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