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

0.8.4

parent 03bca965
......@@ -20,7 +20,7 @@ end
spec = Gem::Specification.new do |s|
s.name = 'mycard'
s.version = '0.8.2'
s.version = '0.8.4'
s.extra_rdoc_files = ['README.txt', 'LICENSE.txt']
s.summary = 'a card game'
s.description = s.summary
......
......@@ -9,4 +9,7 @@ module Cacheable
@@all[self][id] = super(id, *args)
end
end
def find(id)
@@all[self][id]
end
end
\ No newline at end of file
......@@ -66,8 +66,8 @@ class Scene_Lobby < Scene
when Game_Event::AllUsers
@userlist.items = $game.users
when Game_Event::AllRooms, Game_Event::AllServers
@roomlist.items = $game.rooms.find_all { |room|
$game.filter[:servers].collect { |server| server.id }.include?(room.server_id) and
@roomlist.items = p $game.rooms.find_all { |room|
$game.filter[:servers].include?(room.server) and
$game.filter[:waiting_only] ? (room.status == :wait) : true and
$game.filter[:normal_only] ? (!room.tag? && (room.ot == 0) && (room.lp = 8000)) : true
}
......
......@@ -2,7 +2,7 @@ require 'open-uri'
require "fileutils"
require_relative 'card'
module Update
Version = '0.8.2'
Version = '0.8.4'
URL = "http://my-card.in/mycard/update.json?version=#{Version}"
class <<self
attr_reader :thumbnails, :images, :status
......
......@@ -11,6 +11,7 @@ class Window_Filter < Window
@servers = $game.servers.each_with_index.collect do |server, index|
result = Widget_Checkbox.new(self, 4+@x,@y+WLH+WLH*index,@width-8,24,true,server.name){|checked|checked ? $game.filter[:servers].push(server) : $game.filter[:servers].delete(server) ; Game_Event.push(Game_Event::AllRooms.new($game.rooms))}
result.background = @background.copy_rect(4,WLH+WLH*index,@width-8,24)
result.checked = $game.filter[:servers].include? server
result.refresh
result
end
......
......@@ -7,22 +7,22 @@ class Game_Event
else
Error.new('登录', '用户名或密码错误')
end
when :rooms
AllRooms.new data.collect{|room|parse_room(room)}
when :rooms_update
RoomsUpdate.new data.collect{|room|parse_room(room)}
when :servers
servers = data.collect{|server|parse_server(server)}
$game.filter[:servers].concat (servers - $game.servers)
AllServers.new servers
#when :rooms
#AllRooms.new data.collect{|room|parse_room(room)}
#when :rooms_update
#RoomsUpdate.new data.collect{|room|parse_room(room)}
#when :servers
# servers = data.collect{|server|parse_server(server)}
# $game.filter[:servers].concat (servers - $game.servers)
# AllServers.new servers
#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 :newroom
# NewRoom.new parse_room data
#when :missingroom
# MissingRoom.new parse_room data
when :chat
case data[:channel]
when :lobby
......@@ -33,25 +33,25 @@ class Game_Event
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.private = room[:private]
result.pvp = room[:pvp]
result.match = room[:match]
result.tag = room[:tag]
result.ot = room[:ot]
result.status = room[:status]
result.lp = room[:lp]
result._deleted = room[:_deleted]
result.server_id = room[:server_id]
result.server_ip = room[:server_ip]
result.server_port = room[:server_port]
result.server_auth = room[:server_auth]
result = Room.new(room['id'], room['name'])
result.private = room['private']
result.pvp = room['pvp']
result.match = room['mode'] == 1
result.tag = room['mode'] == 2
result.ot = room['rule'] || 0
result.status = room['status'].to_sym
result.lp = room['start_lp'] || 8000
result.player1 = room['users'][0] && parse_user(room['users'][0])
result.player2 = room['users'][1] && parse_user(room['users'][1])
result.server = Server.find room['server_id']
result._deleted = room['_deleted']
result
end
def self.parse_user(user)
User.new(user[:id], user[:name], user[:certified])
User.new(user['id'] || user[:id], user['name'] || user[:name], user['certified'] || user[:certified])
end
def self.parse_server(server)
Server.new(server[:id], server[:name], server[:ip], server[:port], server[:auth])
......
This diff is collapsed.
......@@ -5,7 +5,7 @@ class Room
attr_accessor :ot
attr_accessor :lp
attr_accessor :status
attr_accessor :server_id, :server_ip, :server_port, :server_auth
attr_accessor :server
alias pvp? pvp
alias match? match
alias tag? tag
......@@ -38,4 +38,19 @@ class Room
end
result
end
def host_server
servers = $game.servers
servers.select!{|server|server.auth} if @pvp
s = servers & $game.filter[:servers]
servers = s if !s.empty?
server = servers.min_by{|server|$game.rooms.select{|room|room.server == server}.size}
p server
server ||= Server.new(nil, "", $game.server, $game.port, true)
self.server = server
server
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