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

版本0.5.3 大厅实时刷新

parent d4b6da98
......@@ -24,7 +24,7 @@ end
spec = Gem::Specification.new do |s|
s.name = 'mycard'
s.version = '0.5.2'
s.version = '0.5.3'
s.extra_rdoc_files = ['README.txt', 'LICENSE.txt']
s.summary = 'a card game'
s.description = s.summary
......
......@@ -34,6 +34,9 @@ class Game
end
def self.deck_edit
end
def refresh_interval
5
end
end
......@@ -69,10 +69,15 @@ class Game_Event
attr_reader :room
def initialize(room)
@room = room
$game.rooms << @room unless $game.rooms.include? @room
unless $game.rooms.include? @room
if @room.full?
$game.rooms << @room
else
$game.rooms.unshift @room
end
end
end
end
class MissingRoom < AllRooms
attr_reader :room
def initialize(room)
......
......@@ -88,7 +88,7 @@ class Scene_Lobby < Scene
def update
@chat_window.update
@host_window.update
if @count >= 600
if @count >= $game.refresh_interval*60
$game.refresh
@count = 0
end
......
......@@ -2,7 +2,7 @@ require 'open-uri'
require "fileutils"
require_relative 'card'
module Update
Version = '0.5.2'
Version = '0.5.3'
URL = "http://card.touhou.cc/mycard/update.json?version=#{Version}"
class <<self
attr_reader :thumbnails, :images, :status
......
......@@ -3,22 +3,32 @@ class Game_Event
case header
when :login
if data
Login.new User.new(data[:id], data[:name])
Login.new parse_user data
else
Error.new('登录', '用户名或密码错误')
end
when :users
AllUsers.new data.collect{|user|User.new(user[:id], user[:name], user[:certified])}
AllUsers.new data.collect{|user|parse_user(user)}
when :rooms
AllRooms.new data.collect{|room|
result = Room.new(room[:id], room[:name])
result.player1 = room[:player1] && User.new(room[:player1][:id], room[:player1][:name])
result.player2 = room[:player2] && User.new(room[:player2][:id], room[:player2][:name])
result.pvp = room[:pvp]
result.match = room[:match]
result.status = room[:status]
result
}.sort_by{|room|room.full? ? 1 : 0}
rooms_wait = []
rooms_start = []
data.each do |room|
room = parse_room(room)
if room.full?
rooms_start << room
else
rooms_wait << room
end
end
AllRooms.new rooms_wait + rooms_start
when :newuser
NewUser.new parse_user data
when :missinguser
MissingUser.new parse_user data
when :newroom
NewRoom.new parse_room data
when :missingroom
MissingRoom.new parse_room data
when :chat
case data[:channel]
when :lobby
......@@ -28,4 +38,16 @@ class Game_Event
end
end
end
def self.parse_room(room)
result = Room.new(room[:id], room[:name])
result.player1 = room[:player1] && parse_user(room[:player1])
result.player2 = room[:player2] && parse_user(room[:player2])
result.pvp = room[:pvp]
result.match = room[:match]
result.status = room[:status]
result
end
def self.parse_user(user)
User.new(user[:id], user[:name], user[:certified])
end
end
\ No newline at end of file
......@@ -14,6 +14,9 @@ class Ygocore < Game
load 'lib/ygocore/scene_lobby.rb'
require 'json'
end
def refresh_interval
60
end
def login(username, password)
@username = username
@password = password
......
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