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
xiaoye
mycard
Commits
f3143cf8
Commit
f3143cf8
authored
Mar 05, 2012
by
神楽坂玲奈
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
好友系统
parent
900c79a9
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
66 additions
and
27 deletions
+66
-27
lib/iduel/event.rb
lib/iduel/event.rb
+11
-1
lib/iduel/game.rb
lib/iduel/game.rb
+42
-18
lib/iduel/user.rb
lib/iduel/user.rb
+1
-1
lib/scene_lobby.rb
lib/scene_lobby.rb
+1
-1
lib/user.rb
lib/user.rb
+2
-1
lib/window_userlist.rb
lib/window_userlist.rb
+9
-5
No files found.
lib/iduel/event.rb
View file @
f3143cf8
...
...
@@ -39,6 +39,7 @@ class Game_Event
#>> $B|201629,zh99997,5da9e5fa,Level-1 (总经验:183),,20101118
info
[
3
]
=~
/Level-(\d)+ \(总经验:(\d+)\)/
result
=
self
.
new
User
.
new
(
info
[
0
].
to_i
,
info
[
1
],
$1
.
to_i
,
$2
.
to_i
)
$game
.
get_friends
$game
.
session
=
info
[
2
]
$game
.
key
=
(
$game
.
user
.
id
-
0x186a0
)
^
0x22133
result
...
...
@@ -46,7 +47,16 @@ class Game_Event
end
class
AllUsers
def
self
.
parse
(
info
)
self
.
new
info
.
split
(
','
).
collect
{
|
user
|
User
.
parse
(
user
)}
users
=
[]
info
.
split
(
','
).
each
do
|
user
|
user
=
User
.
parse
(
user
)
if
user
.
friend?
users
.
unshift
user
else
users
<<
user
end
end
self
.
new
users
end
end
class
AllRooms
...
...
lib/iduel/game.rb
View file @
f3143cf8
...
...
@@ -96,6 +96,27 @@ class Iduel < Game
#4|241019,test,2368c6b89b3e2eedb92e1b624a2a157c
end
def
get_friends
$config
[
'iDuel'
][
'friends'
]
||=
[]
$config
[
'iDuel'
][
'friends'
].
each
{
|
id
|
User
.
new
(
id
).
friend
=
true
}
Thread
.
new
do
begin
open
(
"http://www.duelcn.com/home.php?mod=space&uid=
#{
@user
.
id
-
100000
}
&do=friend&view=me&from=space"
)
do
|
file
|
$config
[
'iDuel'
][
'friends'
].
each
{
|
id
|
User
.
new
(
id
).
friend
=
false
}
$config
[
'iDuel'
][
'friends'
].
clear
file
.
set_encoding
"GBK"
,
"UTF-8"
file
.
read
.
scan
(
/<a href="home.php\?mod=space&uid=(\d+)" title=".*" target="_blank">.*<\/a>/
)
do
|
uid
,
others
|
id
=
uid
.
to_i
+
100000
User
.
new
(
id
).
friend
=
true
$config
[
'iDuel'
][
'friends'
]
<<
id
end
save_config
end
rescue
Exception
=>
exception
$log
.
error
(
'读取好友信息'
)
{[
exception
.
inspect
,
*
exception
.
backtrace
].
join
(
"
\n
"
).
encode
(
"UTF-8"
)}
end
end
end
private
def
connect
require
'socket'
...
...
@@ -129,26 +150,29 @@ class Iduel < Game
info
.
gsub!
(
"
\n
"
,
"
\r\n
"
)
(
@conn
.
write
info
)
rescue
Game_Event
.
push
Game_Event
::
Error
.
new
(
$!
.
class
.
to_s
,
$!
.
message
)
end
#公告
$config
[
'iDuel'
][
'announcements'
]
||=
[
Announcement
.
new
(
"正在读取公告..."
,
nil
,
nil
)]
Thread
.
new
do
begin
open
(
'http://www.duelcn.com/topic-Announce.html'
)
do
|
file
|
file
.
set_encoding
"GBK"
announcements
=
[]
file
.
read
.
scan
(
/<li><em>(.*?)<\/em><a href="(.*?)" title="(.*?)" target="_blank">.*?<\/a><\/li>/
).
each
do
|
time
,
url
,
title
|
if
time
=~
/(\d+)-(\d+)-(\d+)/
time
=
Time
.
new
(
$1
,
$2
,
$3
)
else
time
=
nil
def
self
.
get_announcements
#公告
$config
[
'iDuel'
][
'announcements'
]
||=
[
Announcement
.
new
(
"正在读取公告..."
,
nil
,
nil
)]
Thread
.
new
do
begin
open
(
'http://www.duelcn.com/topic-Announce.html'
)
do
|
file
|
file
.
set_encoding
"GBK"
announcements
=
[]
file
.
read
.
scan
(
/<li><em>(.*?)<\/em><a href="(.*?)" title="(.*?)" target="_blank">.*?<\/a><\/li>/
).
each
do
|
time
,
url
,
title
|
if
time
=~
/(\d+)-(\d+)-(\d+)/
time
=
Time
.
new
(
$1
,
$2
,
$3
)
else
time
=
nil
end
announcements
<<
Announcement
.
new
(
title
.
encode
(
"UTF-8"
),
"http://www.duelcn.com/
#{
url
}
"
,
time
)
end
announcements
<<
Announcement
.
new
(
title
.
encode
(
"UTF-8"
),
"http://www.duelcn.com/
#{
url
}
"
,
time
)
$config
[
'iDuel'
][
'announcements'
].
replace
announcements
save_config
end
$config
[
'iDuel'
][
'announcements'
].
replace
announcements
save_config
rescue
Exception
=>
exception
$log
.
error
(
'公告'
)
{[
exception
.
inspect
,
*
exception
.
backtrace
].
join
(
"
\n
"
)}
end
rescue
Exception
=>
exception
$log
.
error
(
'公告'
)
{[
exception
.
inspect
,
*
exception
.
backtrace
].
join
(
"
\n
"
)}
end
end
end
\ No newline at end of file
get_announcements
end
lib/iduel/user.rb
View file @
f3143cf8
...
...
@@ -51,4 +51,4 @@ class User
require
'launchy'
Launchy
.
open
(
"http://www.duelcn.com/home.php?mod=space&uid=
#{
@id
-
100000
}
"
)
end
end
\ No newline at end of file
end
lib/scene_lobby.rb
View file @
f3143cf8
...
...
@@ -69,7 +69,7 @@ class Scene_Lobby < Scene
when
Game_Event
::
AllRooms
@roomlist
.
items
=
$game
.
rooms
when
Game_Event
::
Join
$scene
=
Scene_Duel
.
new
(
event
.
room
,
Deck
.
load
(
"
妖鸟.TXT
"
))
$scene
=
Scene_Duel
.
new
(
event
.
room
,
Deck
.
load
(
"
老I FTK2.txt
"
))
when
Game_Event
::
Watch
require_relative
'scene_watch'
$scene
=
Scene_Watch
.
new
(
event
.
room
)
...
...
lib/user.rb
View file @
f3143cf8
require_relative
'cacheable'
class
User
attr_accessor
:id
,
:name
attr_accessor
:id
,
:name
,
:friend
alias
friend?
friend
extend
Cacheable
def
initialize
(
id
,
name
=
""
)
@id
=
id
...
...
lib/window_userlist.rb
View file @
f3143cf8
...
...
@@ -14,8 +14,9 @@ class Window_UserList < Window_Scrollable
super
(
x
,
y
,
272
,
540
)
@font
=
TTF
.
open
(
"fonts/WenQuanYi Micro Hei.ttf"
,
16
)
@color
=
[
0x03
,
0x11
,
0x22
]
@color_over
=
[
0x03
,
0x11
,
0x22
,
200
,
200
,
255
]
@color_click
=
[
200
,
200
,
255
,
0x03
,
0x11
,
0x22
]
@color_friend
=
[
0
,
128
,
0
]
@color_over
=
[
200
,
200
,
255
]
@color_click
=
[
0x03
,
0x11
,
0x22
]
#@contents.set_alpha(RLEACCEL, 80)
@contents
.
fill_rect
(
0
,
0
,
@width
,
@height
,
0xFFFFFFFF
)
self
.
items
=
items
...
...
@@ -24,13 +25,16 @@ class Window_UserList < Window_Scrollable
def
draw_item
(
index
,
status
=
0
)
case
status
when
0
@font
.
draw_blended_utf8
(
@contents
,
@items
[
index
].
name
,
0
,
item_rect
(
index
)[
1
],
*
@color
)
@font
.
draw_blended_utf8
(
@contents
,
@items
[
index
].
name
,
0
,
item_rect
(
index
)[
1
],
*
(
item_color
(
index
))
)
when
1
@font
.
draw_shaded_utf8
(
@contents
,
@items
[
index
].
name
,
0
,
item_rect
(
index
)[
1
],
*
@color_over
)
@font
.
draw_shaded_utf8
(
@contents
,
@items
[
index
].
name
,
0
,
item_rect
(
index
)[
1
],
*
(
item_color
(
index
)
+
@color_over
)
)
when
2
@font
.
draw_shaded_utf8
(
@contents
,
@items
[
index
].
name
,
0
,
item_rect
(
index
)[
1
],
*
@color_click
)
@font
.
draw_shaded_utf8
(
@contents
,
@items
[
index
].
name
,
0
,
item_rect
(
index
)[
1
],
*
(
item_color
(
index
)
+
@color_click
)
)
end
end
def
item_color
(
index
)
@items
[
index
].
friend?
?
@color_friend
:
@color
end
#def clear(x=0, y=0, width=@width, height=@height)
# Surface.blit(x, )
#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