Commit f3143cf8 authored by 神楽坂玲奈's avatar 神楽坂玲奈

好友系统

parent 900c79a9
...@@ -39,6 +39,7 @@ class Game_Event ...@@ -39,6 +39,7 @@ class Game_Event
#>> $B|201629,zh99997,5da9e5fa,Level-1 (总经验:183),,20101118 #>> $B|201629,zh99997,5da9e5fa,Level-1 (总经验:183),,20101118
info[3] =~ /Level-(\d)+ \(总经验:(\d+)\)/ info[3] =~ /Level-(\d)+ \(总经验:(\d+)\)/
result = self.new User.new(info[0].to_i, info[1], $1.to_i, $2.to_i) 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.session = info[2]
$game.key = ($game.user.id - 0x186a0) ^ 0x22133 $game.key = ($game.user.id - 0x186a0) ^ 0x22133
result result
...@@ -46,7 +47,16 @@ class Game_Event ...@@ -46,7 +47,16 @@ class Game_Event
end end
class AllUsers class AllUsers
def self.parse(info) 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
end end
class AllRooms class AllRooms
......
...@@ -96,6 +96,27 @@ class Iduel < Game ...@@ -96,6 +96,27 @@ class Iduel < Game
#4|241019,test,2368c6b89b3e2eedb92e1b624a2a157c #4|241019,test,2368c6b89b3e2eedb92e1b624a2a157c
end 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&amp;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 private
def connect def connect
require 'socket' require 'socket'
...@@ -129,6 +150,7 @@ class Iduel < Game ...@@ -129,6 +150,7 @@ class Iduel < Game
info.gsub!("\n", "\r\n") info.gsub!("\n", "\r\n")
(@conn.write info) rescue Game_Event.push Game_Event::Error.new($!.class.to_s, $!.message) (@conn.write info) rescue Game_Event.push Game_Event::Error.new($!.class.to_s, $!.message)
end end
def self.get_announcements
#公告 #公告
$config['iDuel']['announcements'] ||= [Announcement.new("正在读取公告...", nil, nil)] $config['iDuel']['announcements'] ||= [Announcement.new("正在读取公告...", nil, nil)]
Thread.new do Thread.new do
...@@ -151,4 +173,6 @@ class Iduel < Game ...@@ -151,4 +173,6 @@ class Iduel < Game
$log.error('公告') {[exception.inspect, *exception.backtrace].join("\n")} $log.error('公告') {[exception.inspect, *exception.backtrace].join("\n")}
end end
end end
end
get_announcements
end end
...@@ -69,7 +69,7 @@ class Scene_Lobby < Scene ...@@ -69,7 +69,7 @@ class Scene_Lobby < Scene
when Game_Event::AllRooms when Game_Event::AllRooms
@roomlist.items = $game.rooms @roomlist.items = $game.rooms
when Game_Event::Join 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 when Game_Event::Watch
require_relative 'scene_watch' require_relative 'scene_watch'
$scene = Scene_Watch.new(event.room) $scene = Scene_Watch.new(event.room)
......
require_relative 'cacheable' require_relative 'cacheable'
class User class User
attr_accessor :id, :name attr_accessor :id, :name, :friend
alias friend? friend
extend Cacheable extend Cacheable
def initialize(id, name="") def initialize(id, name="")
@id = id @id = id
......
...@@ -14,8 +14,9 @@ class Window_UserList < Window_Scrollable ...@@ -14,8 +14,9 @@ class Window_UserList < Window_Scrollable
super(x,y,272,540) super(x,y,272,540)
@font = TTF.open("fonts/WenQuanYi Micro Hei.ttf", 16) @font = TTF.open("fonts/WenQuanYi Micro Hei.ttf", 16)
@color = [0x03, 0x11, 0x22] @color = [0x03, 0x11, 0x22]
@color_over = [0x03, 0x11, 0x22, 200,200,255] @color_friend = [0, 128, 0]
@color_click = [200,200,255, 0x03, 0x11, 0x22] @color_over = [200,200,255]
@color_click = [0x03, 0x11, 0x22]
#@contents.set_alpha(RLEACCEL, 80) #@contents.set_alpha(RLEACCEL, 80)
@contents.fill_rect(0,0,@width,@height,0xFFFFFFFF) @contents.fill_rect(0,0,@width,@height,0xFFFFFFFF)
self.items = items self.items = items
...@@ -24,13 +25,16 @@ class Window_UserList < Window_Scrollable ...@@ -24,13 +25,16 @@ class Window_UserList < Window_Scrollable
def draw_item(index, status=0) def draw_item(index, status=0)
case status case status
when 0 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 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 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
end end
def item_color(index)
@items[index].friend? ? @color_friend : @color
end
#def clear(x=0, y=0, width=@width, height=@height) #def clear(x=0, y=0, width=@width, height=@height)
# Surface.blit(x, ) # Surface.blit(x, )
#end #end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment