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
2250ddb1
Commit
2250ddb1
authored
Oct 13, 2012
by
神楽坂玲奈
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
temp
parent
eafab06b
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
273 additions
and
314 deletions
+273
-314
lib/ygocore/game.rb
lib/ygocore/game.rb
+273
-314
No files found.
lib/ygocore/game.rb
View file @
2250ddb1
#encoding: UTF-8
load
'lib/ygocore/window_login.rb'
require
'eventmachine'
require
'open-uri'
require
'yaml'
class
Ygocore
<
Game
...
...
@@ -272,44 +271,4 @@ class Ygocore < Game
private
def
self
.
get_announcements
#公告
$config
[
'ygocore'
]
||=
{}
$config
[
'ygocore'
][
'announcements'
]
||=
[
Announcement
.
new
(
"正在读取公告..."
,
nil
,
nil
)]
Thread
.
new
do
begin
open
(
@@config
[
'api'
])
do
|
file
|
file
.
set_encoding
"GBK"
announcements
=
[]
file
.
read
.
encode
(
"UTF-8"
).
scan
(
/<div style="color:red" >公告:(.*?)<\/div>/
).
each
do
|
title
,
others
|
announcements
<<
Announcement
.
new
(
title
,
@@config
[
'index'
],
nil
)
end
$config
[
'ygocore'
][
'announcements'
].
replace
announcements
Config
.
save
end
rescue
Exception
=>
exception
$log
.
error
(
'公告读取失败'
)
{
[
exception
.
inspect
,
*
exception
.
backtrace
].
collect
{
|
str
|
str
.
encode
(
"UTF-8"
)
}.
join
(
"
\n
"
)
}
end
end
end
module
Client
MycardChannel
=
EM
::
Channel
.
new
include
EM
::
P
::
ObjectProtocol
def
post_init
send_object
header: :login
,
data:
{
name:
$game
.
username
,
password:
$game
.
password
}
MycardChannel
.
subscribe
{
|
msg
|
send_object
(
msg
)
}
end
def
receive_object
obj
$log
.
info
(
'收到消息'
)
{
obj
.
inspect
}
Game_Event
.
push
Game_Event
.
parse
obj
[
:header
],
obj
[
:data
]
end
def
unbind
Game_Event
.
push
Game_Event
::
Error
.
new
(
'ygocore'
,
'网络连接中断'
,
true
)
end
end
get_announcements
end
\ No newline at end of file
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