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
e284688b
Commit
e284688b
authored
Apr 04, 2012
by
神楽坂玲奈
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
irc在线列表
parent
fb9bee73
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
13 deletions
+28
-13
lib/ygocore/event.rb
lib/ygocore/event.rb
+0
-11
lib/ygocore/game.rb
lib/ygocore/game.rb
+28
-2
No files found.
lib/ygocore/event.rb
View file @
e284688b
...
...
@@ -62,15 +62,4 @@ class Game_Event
self
.
new
@rooms
end
end
class
AllUsers
<
Game_Event
def
self
.
parse
(
info
)
@users
=
[]
$game
.
rooms
.
each
do
|
room
|
@users
<<
room
.
player1
if
room
.
player1
@users
<<
room
.
player2
if
room
.
player2
end
@users
.
uniq!
self
.
new
@users
end
end
end
\ No newline at end of file
lib/ygocore/game.rb
View file @
e284688b
...
...
@@ -2,6 +2,7 @@
load
'lib/ygocore/window_login.rb'
class
Ygocore
<
Game
attr_reader
:password
attr_reader
:irc_users
@@config
=
YAML
.
load_file
(
"lib/ygocore/server.yml"
)
def
initialize
super
...
...
@@ -10,6 +11,7 @@ class Ygocore < Game
load
'lib/ygocore/room.rb'
load
'lib/ygocore/scene_lobby.rb'
require
'json'
@irc_users
=
[]
end
def
login
(
username
,
password
)
if
username
.
empty?
...
...
@@ -52,6 +54,24 @@ class Ygocore < Game
user
=
User
.
new
(
hexdecode
(
event
.
msg
.
user
).
to_sym
,
hexdecode
(
event
.
nick
))
Game_Event
.
push
Game_Event
::
Chat
.
new
(
ChatMessage
.
new
(
user
,
event
.
message
,
event
.
channel
?
event
.
channel
[
1
,
event
.
channel
.
size
-
1
].
to_sym
:
user
))
}
@irc
.
heard_namreply
{
|
event
|
@irc_users
.
concat
@irc
.
instance_variable_get
(
:@nicklist
).
collect
{
|
user
|
User
.
new
(
hexdecode
(
user
).
to_sym
,
hexdecode
(
user
))
}
Game_Event
.
push
Game_Event
::
AllUsers
.
new
(
@users
|
@irc_users
)
$log
.
info
(
'irc用户列表'
){
user
}
}
@irc
.
heard_join
{
|
event
|
user
=
User
.
new
(
hexdecode
(
event
.
msg
.
user
).
to_sym
,
hexdecode
(
event
.
nick
))
Game_Event
.
push
Game_Event
::
NewUser
.
new
(
user
)
$log
.
info
(
'irc用户上线'
){
user
}
}
@irc
.
heard_quit
{
|
event
|
user
=
User
.
new
(
hexdecode
(
event
.
msg
.
user
).
to_sym
,
hexdecode
(
event
.
nick
))
Game_Event
.
push
Game_Event
::
MissingUser
.
new
(
user
)
$log
.
info
(
'irc用户下线'
){
user
}
}
#@irc.hearing_join {}
$log
.
info
(
'聊天开始监听'
)
@irc
.
start_listening
$log
.
info
(
'聊天加载完毕'
)
...
...
@@ -59,7 +79,6 @@ class Ygocore < Game
$log
.
error
(
'聊天出错'
){[
exception
.
inspect
,
*
exception
.
backtrace
].
collect
{
|
str
|
str
.
encode
(
"UTF-8"
)}.
join
(
"
\n
"
)}
Game_Event
.
push
(
Game_Event
::
Chat
.
new
(
ChatMessage
.
new
(
User
.
new
(
:system
,
'system'
),
'连接聊天服务器失败'
,
:lobby
)))
end
end
def
chat
(
chatmessage
)
$log
.
info
(
'发送聊天消息'
){
chatmessage
.
inspect
}
...
...
@@ -127,7 +146,14 @@ class Ygocore < Game
info
=
file
.
read
.
encode
(
"UTF-8"
)
$log
.
info
(
'刷新大厅信息'
){
'完成'
}
Game_Event
.
push
Game_Event
::
AllRooms
.
parse
info
Game_Event
.
push
Game_Event
::
AllUsers
.
parse
info
@users
.
clear
@rooms
.
each
do
|
room
|
@users
<<
room
.
player1
if
room
.
player1
@users
<<
room
.
player2
if
room
.
player2
end
@users
.
concat
@irc_users
@users
.
uniq!
Game_Event
.
push
Game_Event
::
AllUsers
.
new
(
@users
)
yield
if
block_given?
end
rescue
Exception
=>
exception
...
...
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