Commit 74d56beb authored by 神楽坂玲奈's avatar 神楽坂玲奈

完善登陆观战replay

parent 4faa1e51
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
/ruby/ /ruby/
/pkg/ /pkg/
/log.log /log.log
/err.log
/replay/* /replay/*
/graphics/avatars/*_*.png /graphics/avatars/*_*.png
Thumbs.db Thumbs.db
\ No newline at end of file
This diff was suppressed by a .gitattributes entry.
This diff was suppressed by a .gitattributes entry.
...@@ -149,8 +149,7 @@ class Action ...@@ -149,8 +149,7 @@ class Action
end end
else else
card = @card == :deck ? player_field.deck.first : Game_Card.new(@card) card = @card == :deck ? player_field.deck.first : Game_Card.new(@card)
$log.info "似乎凭空产生了卡片?" $log.warn("似乎凭空产生了卡片?"){self.inspect}
p self
end end
if @position if @position
if @position == :"face-up" if @position == :"face-up"
...@@ -160,7 +159,7 @@ class Action ...@@ -160,7 +159,7 @@ class Action
card.position = :attack card.position = :attack
end end
else else
card.position = :attack card.position = @position
end end
end end
if @to_pos if @to_pos
......
...@@ -8,7 +8,6 @@ class FPSTimer ...@@ -8,7 +8,6 @@ class FPSTimer
# +accurary+ is the accurary of sleep/SDL.delay in milisecond # +accurary+ is the accurary of sleep/SDL.delay in milisecond
def initialize(fps = 60, accurary = 10, skip_limit = 15) def initialize(fps = 60, accurary = 10, skip_limit = 15)
@fps = fps @fps = fps
@spf = (1.0/@fps)
@accurary = accurary / 1000.0 @accurary = accurary / 1000.0
@skip_limit = skip_limit @skip_limit = skip_limit
reset reset
...@@ -16,7 +15,7 @@ class FPSTimer ...@@ -16,7 +15,7 @@ class FPSTimer
# reset timer, you should call just before starting loop # reset timer, you should call just before starting loop
def reset def reset
@old = Time.now.to_f @old = get_ticks
@skip = 0 @skip = 0
@real_fps = @fps @real_fps = @fps
@frame_count = 0 @frame_count = 0
...@@ -27,25 +26,27 @@ class FPSTimer ...@@ -27,25 +26,27 @@ class FPSTimer
# execute given block and wait # execute given block and wait
def wait_frame def wait_frame
nxt = @old + @spf now = get_ticks
if (sleeptime = nxt - Time.now.to_f) > 0 nxt = @old + (1.0/@fps)
sleep(sleeptime) if nxt > now || @skip > @skip_limit
yield yield
@skip = 0
wait(nxt)
@old = nxt
else
@skip += 1
@total_skip += 1
@old = get_ticks
end end
@old = nxt
calc_real_fps calc_real_fps
end end
private private
def wait(nxt) def wait(nxt)
while nxt > get_ticks + @accurary p nxt
sleep(@accurary - 0.005) sleeptime = nxt-get_ticks
@count_sleep += 1 sleep(sleeptime) if sleeptime > 0
end
while nxt > get_ticks
# busy loop, do nothing
end
end end
def get_ticks def get_ticks
...@@ -61,4 +62,4 @@ class FPSTimer ...@@ -61,4 +62,4 @@ class FPSTimer
@fps_old = now @fps_old = now
end end
end end
end end
\ No newline at end of file
...@@ -313,7 +313,7 @@ class Action ...@@ -313,7 +313,7 @@ class Action
end end
class TurnEnd class TurnEnd
def escape def escape
"[#{@id}] #{from_player ? '◎' : '●'}→=[0:0:0]==回合结束==<#{@turn}>=[0]\n"+ @field.escape "[#{@id}] #{from_player ? '◎' : '●'}→=[0:0:0]==回合结束==<#{@turn}>=[0]\n"+ @field.escape + "#{from_player ? '◎' : '●'}→\\"
end end
end end
class Shuffle class Shuffle
...@@ -478,8 +478,7 @@ class Game_Field ...@@ -478,8 +478,7 @@ class Game_Field
@field[6..10].collect{|card|" <#{"#{Action.escape_position_short(card)}|#{card.position == :set ? '??' : "[#{card.card_type}][#{card.name}] #{card.atk}#{' '+card.def.to_s}"}" if card}>\n"}.join + @field[6..10].collect{|card|" <#{"#{Action.escape_position_short(card)}|#{card.position == :set ? '??' : "[#{card.card_type}][#{card.name}] #{card.atk}#{' '+card.def.to_s}"}" if card}>\n"}.join +
"后场:" + "后场:" +
@field[1..5].collect{|card|"<#{card.position == :set ? '??' : card.escape if card}>"}.join + @field[1..5].collect{|card|"<#{card.position == :set ? '??' : card.escape if card}>"}.join +
"\n场地|<#{@field[0] ? @field[0].escape : '无'}>\n" + "\n场地|<#{@field[0] ? @field[0].escape : '无'}>\n"
"◎→\\"
end end
def self.parse(str) def self.parse(str)
......
...@@ -19,23 +19,26 @@ class Iduel < Game ...@@ -19,23 +19,26 @@ class Iduel < Game
def connect def connect
require 'socket' require 'socket'
require 'open-uri' require 'open-uri'
begin
@conn = TCPSocket.new(Server, Port) #TODO: 阻塞优化,注意login。下面注释掉的两句实现connect无阻塞,但是login依然会阻塞所以只优化这里没有意义 @conn = TCPSocket.new(Server, Port) #TODO: 阻塞优化,注意login。下面注释掉的两句实现connect无阻塞,但是login依然会阻塞所以只优化这里没有意义
#@conn = Socket.new(:INET, :STREAM) #@conn = Socket.new(:INET, :STREAM)
@conn.set_encoding "GBK", "UTF-8", :invalid => :replace, :undef => :replace @conn.set_encoding "GBK", "UTF-8", :invalid => :replace, :undef => :replace
@recv = Thread.new do @recv = Thread.new do
begin begin
#@conn.connect Socket.pack_sockaddr_in(Port, Server) #@conn.connect Socket.pack_sockaddr_in(Port, Server)
recv @conn.gets(RS) while @conn recv @conn.gets(RS) while @conn
rescue => exception rescue => exception
Game_Event.push Game_Event::Error.new(exception.class.to_s, exception.message) Game_Event.push Game_Event::Error.new(exception.class.to_s, exception.message)
$log.error [exception.inspect, *exception.backtrace].join("\n") $log.error [exception.inspect, *exception.backtrace].join("\n")
ensure ensure
self.exit self.exit
end
end end
rescue => exception
Game_Event.push Game_Event::Error.new(exception.class.to_s, exception.message)
$log.error [exception.inspect, *exception.backtrace].join("\n")
end end
end end
def login(username, password) def login(username, password)
connect connect
md5 = Digest::MD5.hexdigest(password) md5 = Digest::MD5.hexdigest(password)
......
name: iduel name: iDuel
\ No newline at end of file \ No newline at end of file
...@@ -5,8 +5,8 @@ class Replay ...@@ -5,8 +5,8 @@ class Replay
Opponent_Filter =/^(.+?)\((\d+)\)\(\d+:\d+:\d+\): (?:\r)?\n \[\d+\] ●→/ Opponent_Filter =/^(.+?)\((\d+)\)\(\d+:\d+:\d+\): (?:\r)?\n \[\d+\] ●→/
attr_accessor :room, :player1, :player2, :actions attr_accessor :room, :player1, :player2, :actions
def add(action) def add(action)
# user = action.from_player ? $game.player1 : $game.player2 # user = action.from_player ? $game.player1 : $game.player2
# @file.write("#{user.name}(#{user.id}):\r\n#{action.escape}\r\n") # @file.write("#{user.name}(#{user.id}):\r\n#{action.escape}\r\n")
end end
def self.load(filename) def self.load(filename)
#TODO:效率优化 #TODO:效率优化
...@@ -14,10 +14,16 @@ class Replay ...@@ -14,10 +14,16 @@ class Replay
file.set_encoding "GBK", "UTF-8", :invalid => :replace, :undef => :replace file.set_encoding "GBK", "UTF-8", :invalid => :replace, :undef => :replace
result = self.new(file) result = self.new(file)
contents = file.read contents = file.read
contents =~ Player_Filter if contents =~ Player_Filter
result.player1 = User.new($2.to_i, $1) result.player1 = User.new($2.to_i, $1)
contents =~ Opponent_Filter else
result.player2 = User.new($2.to_i, $1) result.player1 = User.new(0, "我")
end
if contents =~ Opponent_Filter
result.player2 = User.new($2.to_i, $1)
else
result.player2 = User.new(1, "对手")
end
result.actions = contents.split(Delimiter).collect do |action_str| result.actions = contents.split(Delimiter).collect do |action_str|
action_str.chomp! action_str.chomp!
action = Action.parse action_str action = Action.parse action_str
......
...@@ -23,11 +23,11 @@ class User ...@@ -23,11 +23,11 @@ class User
cache = "graphics/avatars/#{@id}_#{size}.png" cache = "graphics/avatars/#{@id}_#{size}.png"
result = Surface.load(cache) rescue Surface.load("graphics/avatars/loading_#{size}.gif") result = Surface.load(cache) rescue Surface.load("graphics/avatars/loading_#{size}.gif")
if block_given? if block_given?
yield result
Thread.new do Thread.new do
open("http://www.duelcn.com/uc_server/avatar.php?uid=#{id-100000}&size=#{size}", 'rb') {|io|open(cache, 'wb') {|c|c.write io.read}} rescue cache = "graphics/avatars/noavatar_#{size}.gif" open("http://www.duelcn.com/uc_server/avatar.php?uid=#{id-100000}&size=#{size}", 'rb') {|io|open(cache, 'wb') {|c|c.write io.read}} rescue cache = "graphics/avatars/noavatar_#{size}.gif"
yield Surface.load cache yield Surface.load cache
end end
yield result
else else
result result
end end
...@@ -47,4 +47,8 @@ class User ...@@ -47,4 +47,8 @@ class User
def room def room
$game.rooms.find{|room|room.include? self} $game.rooms.find{|room|room.include? self}
end end
def space
require 'launchy'
Launchy.open("http://www.duelcn.com/home.php?mod=space&uid=#{@id-100000}")
end
end end
\ No newline at end of file
...@@ -10,6 +10,16 @@ class Window_Login ...@@ -10,6 +10,16 @@ class Window_Login
when :register when :register
require 'launchy' require 'launchy'
Launchy.open(Iduel::Register_Url) Launchy.open(Iduel::Register_Url)
when :replay
require 'tk'
#由于Tk对话框点击取消的时候SDL会再识别一次点击,所以这里做一下处理,对两次间隔小于1s的点击忽略
return if @replay_clicked and Time.now - @replay_clicked < 1
file = Tk.getOpenFile
@replay_clicked = Time.now
return if file.empty?
$game = Iduel.new
$game.user = User.new(0)
$scene = Scene_Replay.new Replay.load file
end end
end end
end end
...@@ -6,6 +6,15 @@ begin ...@@ -6,6 +6,15 @@ begin
require 'yaml' require 'yaml'
$config = YAML.load_file("config.yml") $config = YAML.load_file("config.yml")
#读取命令行参数
log = "log.log"
ARGV.each do |arg|
case arg
when /--log=(.*)/
log.replace $1
end
end
#初始化SDL #初始化SDL
require 'sdl' require 'sdl'
include SDL include SDL
...@@ -22,12 +31,11 @@ begin ...@@ -22,12 +31,11 @@ begin
#初始化日志 #初始化日志
require 'logger' require 'logger'
if false #调试用,由于将$DEBUG设成true时tk库会输出一大坨奇怪的东西,所以这里不能使用$DEBUG if log == "STDOUT" #调试用
STDOUT.set_encoding "GBK", "UTF-8", :invalid => :replace, :undef => :replace if RUBY_PLATFORM["win"] || RUBY_PLATFORM["ming"] log = STDOUT
$log = Logger.new(STDOUT) log.set_encoding "GBK", "UTF-8", :invalid => :replace, :undef => :replace if RUBY_PLATFORM["win"] || RUBY_PLATFORM["ming"]
else
$log = Logger.new("log.log")
end end
$log = Logger.new(log)
$log.info("main"){"初始化成功"} $log.info("main"){"初始化成功"}
rescue Exception => exception rescue Exception => exception
open('error-程序出错请到论坛反馈.txt', 'w'){|f|f.write [exception.inspect, *exception.backtrace].join("\n")} open('error-程序出错请到论坛反馈.txt', 'w'){|f|f.write [exception.inspect, *exception.backtrace].join("\n")}
......
...@@ -5,7 +5,8 @@ class Action ...@@ -5,7 +5,8 @@ class Action
PosFilter = /((?:手卡|手牌|场上|魔陷区|怪兽区|墓地|额外牌堆|除外区|卡组|卡组顶端|\(\d+\)){1,2})/ PosFilter = /((?:手卡|手牌|场上|魔陷区|怪兽区|墓地|额外牌堆|除外区|卡组|卡组顶端|\(\d+\)){1,2})/
PositionFilter = /(表攻|表守|里守|攻击表示|防守表示|里侧表示|背面守备表示)/ PositionFilter = /(表攻|表守|里守|攻击表示|防守表示|里侧表示|背面守备表示)/
PhaseFilter = /(抽卡`阶段|准备`阶段|主`阶段1|战斗`阶段|主`阶段2|结束`阶段)/ PhaseFilter = /(抽卡`阶段|准备`阶段|主`阶段1|战斗`阶段|主`阶段2|结束`阶段)/
FieldFilter = /(?:LP:(\d+)\n手卡(?:数)?:(\d+)\n卡组:(\d+)\n墓地:(\d+)\n除外:(\d+)\n前场:\n <(?:#{PositionFilter}\|#{CardFilter})?>\n <(?:#{PositionFilter}\|#{CardFilter})?>\n <(?:#{PositionFilter}\|#{CardFilter})?>\n <(?:#{PositionFilter}\|#{CardFilter})?>\n <(?:#{PositionFilter}\|#{CardFilter})?>\n后场:<#{CardFilter}?><#{CardFilter}?><#{CardFilter}?><#{CardFilter}?><#{CardFilter}?>\n场地\|<(?:无|#{CardFilter})>\n(?:◎|●)→\\)/ CountersFilter = /\((\d+)\)/
FieldFilter = /(?:LP:(\d+)\n手卡(?:数)?:(\d+)\n卡组:(\d+)\n墓地:(\d+)\n除外:(\d+)\n前场:\n <(?:#{CountersFilter}?#{PositionFilter}\|#{CardFilter})?>\n <(?:#{CountersFilter}?#{PositionFilter}\|#{CardFilter})?>\n <(?:#{CountersFilter}?#{PositionFilter}\|#{CardFilter})?>\n <(?:#{CountersFilter}?#{PositionFilter}\|#{CardFilter})?>\n <(?:#{CountersFilter}?#{PositionFilter}\|#{CardFilter})?>\n后场:<#{CardFilter}?><#{CardFilter}?><#{CardFilter}?><#{CardFilter}?><#{CardFilter}?>\n场地\|<(?:无|#{CardFilter})>\n(?:◎|●)→\\)/
def self.parse_pos(pos) def self.parse_pos(pos)
if index = pos.index("(") if index = pos.index("(")
index += 1 index += 1
...@@ -54,17 +55,17 @@ class Action ...@@ -54,17 +55,17 @@ class Action
:deck => arr[2].to_i, :deck => arr[2].to_i,
:graveyard => arr[3].to_i, :graveyard => arr[3].to_i,
:removed => arr[4].to_i, :removed => arr[4].to_i,
6 => arr[5] && {:position => parse_position(arr[5]), :card => parse_card(arr[6])}, 6 => arr[7] && {:counters => arr[5].to_i, :position => parse_position(arr[6]), :card => parse_card(arr[7])},
7 => arr[7] && {:position => parse_position(arr[7]), :card => parse_card(arr[8])}, 7 => arr[10] && {:counters => arr[8].to_i, :position => parse_position(arr[9]), :card => parse_card(arr[10])},
8 => arr[9] && {:position => parse_position(arr[9]), :card => parse_card(arr[10])}, 8 => arr[13] && {:counters => arr[11].to_i, :position => parse_position(arr[12]), :card => parse_card(arr[13])},
9=> arr[11] && {:position => parse_position(arr[11]), :card => parse_card(arr[12])}, 9 => arr[16] && {:counters => arr[14].to_i, :position => parse_position(arr[15]), :card => parse_card(arr[16])},
10 => arr[13] && {:position => parse_position(arr[13]), :card => parse_card(arr[14])}, 10 => arr[19] && {:counters => arr[17].to_i, :position => parse_position(arr[18]), :card => parse_card(arr[19])},
1 => arr[15] && {:position => arr[15] == "??" ? :set : :attack, :card => parse_card(arr[15])}, 1 => arr[20] && {:position => arr[20] == "??" ? :set : :attack, :card => parse_card(arr[20])},
2 => arr[16] && {:position => arr[16] == "??" ? :set : :attack, :card => parse_card(arr[16])}, 2 => arr[21] && {:position => arr[21] == "??" ? :set : :attack, :card => parse_card(arr[21])},
3 => arr[17] && {:position => arr[17] == "??" ? :set : :attack, :card => parse_card(arr[17])}, 3 => arr[22] && {:position => arr[22] == "??" ? :set : :attack, :card => parse_card(arr[22])},
4 => arr[18] && {:position => arr[18] == "??" ? :set : :attack, :card => parse_card(arr[18])}, 4 => arr[23] && {:position => arr[23] == "??" ? :set : :attack, :card => parse_card(arr[23])},
5 => arr[19] && {:position => arr[19] == "??" ? :set : :attack, :card => parse_card(arr[19])}, 5 => arr[24] && {:position => arr[24] == "??" ? :set : :attack, :card => parse_card(arr[24])},
0 => arr[20] && {:position => arr[20] == "??" ? :set : :attack, :card => parse_card(arr[20])} 0 => arr[25] && {:position => arr[25] == "??" ? :set : :attack, :card => parse_card(arr[25])}
} }
end end
def self.parse_position(position) def self.parse_position(position)
...@@ -166,7 +167,7 @@ class Action ...@@ -166,7 +167,7 @@ class Action
end end
end end
def self.parse(str) def self.parse(str)
from_player = false from_player = nil
case str case str
when /^\[(\d+)\] (.*)$/m when /^\[(\d+)\] (.*)$/m
id = $1.to_i id = $1.to_i
...@@ -206,7 +207,7 @@ class Action ...@@ -206,7 +207,7 @@ class Action
when "卡组洗切", "切洗卡组" when "卡组洗切", "切洗卡组"
Shuffle.new from_player Shuffle.new from_player
when "查看卡组" when "查看卡组"
ViewDeck.new "查看卡组" ViewDeck.new from_player
when "将顶牌放回卡组底部" when "将顶牌放回卡组底部"
ReturnToDeckBottom.new(from_player, :deck) ReturnToDeckBottom.new(from_player, :deck)
when /抽取\((\d+)\)张卡/ when /抽取\((\d+)\)张卡/
...@@ -261,6 +262,8 @@ class Action ...@@ -261,6 +262,8 @@ class Action
Flip.new(from_player, parse_pos($1), parse_card($2)) Flip.new(from_player, parse_pos($1), parse_card($2))
when /#{PhaseFilter}/ when /#{PhaseFilter}/
ChangePhase.new(from_player, parse_phase($1)) ChangePhase.new(from_player, parse_phase($1))
when /LP(损失|回复|变成)<(-?\d+)>/
LP.new(from_player, case $1 when "损失"; :lose; when "回复"; :increase; when "变成"; :become end, $2.to_i)
else else
Unknown.new str Unknown.new str
end end
...@@ -278,9 +281,6 @@ class Action ...@@ -278,9 +281,6 @@ class Action
def escape def escape
inspect inspect
end end
def run
$game.action self if @from_player
end
class FirstToGo class FirstToGo
def escape def escape
"[#{@id}] #{from_player ? '◎' : '●'}→[11年3月1日禁卡表]先攻" "[#{@id}] #{from_player ? '◎' : '●'}→[11年3月1日禁卡表]先攻"
...@@ -313,7 +313,7 @@ class Action ...@@ -313,7 +313,7 @@ class Action
end end
class TurnEnd class TurnEnd
def escape def escape
"[#{@id}] #{from_player ? '◎' : '●'}→=[0:0:0]==回合结束==<#{@turn}>=[0]\n"+ @field.escape "[#{@id}] #{from_player ? '◎' : '●'}→=[0:0:0]==回合结束==<#{@turn}>=[0]\n"+ @field.escape + "#{from_player ? '◎' : '●'}→\\"
end end
end end
class Shuffle class Shuffle
...@@ -478,8 +478,7 @@ class Game_Field ...@@ -478,8 +478,7 @@ class Game_Field
@field[6..10].collect{|card|" <#{"#{Action.escape_position_short(card)}|#{card.position == :set ? '??' : "[#{card.card_type}][#{card.name}] #{card.atk}#{' '+card.def.to_s}"}" if card}>\n"}.join + @field[6..10].collect{|card|" <#{"#{Action.escape_position_short(card)}|#{card.position == :set ? '??' : "[#{card.card_type}][#{card.name}] #{card.atk}#{' '+card.def.to_s}"}" if card}>\n"}.join +
"后场:" + "后场:" +
@field[1..5].collect{|card|"<#{card.position == :set ? '??' : card.escape if card}>"}.join + @field[1..5].collect{|card|"<#{card.position == :set ? '??' : card.escape if card}>"}.join +
"\n场地|<#{@field[0] ? @field[0].escape : '无'}>\n" + "\n场地|<#{@field[0] ? @field[0].escape : '无'}>\n"
"◎→\\"
end end
def self.parse(str) def self.parse(str)
......
...@@ -11,12 +11,16 @@ class NBX < Game ...@@ -11,12 +11,16 @@ class NBX < Game
require 'open-uri' require 'open-uri'
load File.expand_path('action.rb', File.dirname(__FILE__)) load File.expand_path('action.rb', File.dirname(__FILE__))
load File.expand_path('event.rb', File.dirname(__FILE__)) load File.expand_path('event.rb', File.dirname(__FILE__))
begin
@conn_hall = UDPSocket.new @conn_hall = UDPSocket.new
@conn_hall.setsockopt(Socket::SOL_SOCKET, Socket::SO_BROADCAST, true) @conn_hall.setsockopt(Socket::SOL_SOCKET, Socket::SO_BROADCAST, true)
@conn_hall.bind('0.0.0.0', Port) @conn_hall.bind('0.0.0.0', Port)
@recv_hall = Thread.new { recv *@conn_hall.recvfrom(1024) while @conn_hall } @recv_hall = Thread.new { recv *@conn_hall.recvfrom(1024) while @conn_hall }
Thread.abort_on_exception = true Thread.abort_on_exception = true
rescue => exception
Game_Event.push Game_Event::Error.new(exception.class.to_s, exception.message)
$log.error [exception.inspect, *exception.backtrace].join("\n")
end
end end
def send(user, head, *args) def send(user, head, *args)
case user case user
...@@ -25,7 +29,7 @@ class NBX < Game ...@@ -25,7 +29,7 @@ class NBX < Game
when nil #大厅里的广播 when nil #大厅里的广播
@conn_hall.send("#{head}|#{args.join(',')}", 0, '<broadcast>', Port) @conn_hall.send("#{head}|#{args.join(',')}", 0, '<broadcast>', Port)
when :room #房间里,发给对手和观战者 when :room #房间里,发给对手和观战者
@conn_room.write(head.encode("GBK") + RS) @conn_room.write(head.gsub("\n", "\r\n") + RS)
when :watchers #房间里,发给观战者 when :watchers #房间里,发给观战者
end end
...@@ -35,8 +39,8 @@ class NBX < Game ...@@ -35,8 +39,8 @@ class NBX < Game
def login(username) def login(username)
Game_Event.push Game_Event::Login.new(User.new('localhost', username)) Game_Event.push Game_Event::Login.new(User.new('localhost', username))
end end
def host def host(name=@user.name)
@room = Room.new(@user.id, @user.name, @user) @room = Room.new(@user.id, name, @user)
Game_Event.push Game_Event::Host.new(@room) Game_Event.push Game_Event::Host.new(@room)
send(nil, "NewRoom", @room.player1.name) send(nil, "NewRoom", @room.player1.name)
@conn_room_server = TCPServer.new '0.0.0.0', Port #为了照顾NBX强制IPv4 @conn_room_server = TCPServer.new '0.0.0.0', Port #为了照顾NBX强制IPv4
...@@ -53,21 +57,26 @@ class NBX < Game ...@@ -53,21 +57,26 @@ class NBX < Game
if @conn_room #如果已经连接了,进入观战 if @conn_room #如果已经连接了,进入观战
else #连接 else #连接
@conn_room = client begin
@conn_room.set_encoding "GBK", "UTF-8", :invalid => :replace, :undef => :replace @conn_room = client
send(:room, "[LinkOK]|#{Version}") @conn_room.set_encoding "GBK", "UTF-8", :invalid => :replace, :undef => :replace
send(:room, "▓SetName:#{@user.name}▓") send(:room, "[LinkOK]|#{Version}")
send(:room, "[☆]开启 游戏王NetBattleX Version 2.7.0\r\n[10年3月1日禁卡表]\r\n▊▊▊E8CB04") send(:room, "▓SetName:#{@user.name}▓")
@room.player2 = User.new(client.addr[2], "对手") send(:room, "[☆]开启 游戏王NetBattleX Version 2.7.0\r\n[10年3月1日禁卡表]\r\n▊▊▊E8CB04")
while info = @conn_room.gets(RS) @room.player2 = User.new(client.addr[2], "对手")
recv_room(info) while info = @conn_room.gets(RS)
recv_room(info)
end
@conn_room.close
@conn_room = nil
rescue Exception
p $!
end end
@conn_room.close
#send(:room, "▓SetName:zh▓") #原版协议里还要重复声明一次名字,不过似乎没什么用处,就给省略了
end end
end end
def recv_room(info) def recv_room(info)
info.chomp!(RS) info.chomp!(RS)
info.gsub!("\r\n", "\n")
$log.info ">> #{info}" $log.info ">> #{info}"
Game_Event.push Game_Event.parse info Game_Event.push Game_Event.parse info
end end
......
...@@ -2,14 +2,13 @@ class Replay ...@@ -2,14 +2,13 @@ class Replay
ReplayPath = 'replay' ReplayPath = 'replay'
LastReplay = 'lastreplay.txt' LastReplay = 'lastreplay.txt'
def initialize(filename=LastReplay) def initialize(filename=LastReplay)
@file = open(File.expand_path(filename, ReplayPath), 'w') @file = open(File.expand_path(filename, ReplayPath), 'w') unless filename.is_a? IO
end end
def add(action) def add(action)
action = action.escape if action.is_a? Action action = action.escape if action.is_a? Action
@file.write action + "\n" @file.write action + "\n"
end end
def save(filename="#{$game.room.player1.name}(#{$game.room.player1.id})_#{$game.room.player2.name}(#{$game.room.player2.id})_#{Time.now.strftime("%m%d%H%M")}.txt") def save(filename="#{$game.room.player1.name}(#{$game.room.player1.id})_#{$game.room.player2.name}(#{$game.room.player2.id})_#{Time.now.strftime("%m%d%H%M")}.txt")
p filename
close close
File.rename(@file.path, File.expand_path(filename, ReplayPath)) File.rename(@file.path, File.expand_path(filename, ReplayPath))
end end
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
#  游戏中全部画面的超级类。 #  游戏中全部画面的超级类。
#============================================================================== #==============================================================================
require_relative 'fpstimer' require_relative 'fpstimer'
require_relative 'game'
class Scene class Scene
attr_reader :windows attr_reader :windows
attr_reader :background attr_reader :background
...@@ -41,7 +42,7 @@ class Scene ...@@ -41,7 +42,7 @@ class Scene
# ● 开始处理 # ● 开始处理
#-------------------------------------------------------------------------- #--------------------------------------------------------------------------
def start def start
end end
def refresh_rect(x, y, width, height, background=@background, ox=0,oy=0) def refresh_rect(x, y, width, height, background=@background, ox=0,oy=0)
Surface.blit(background,x+ox,y+oy,width,height,$screen,x,y) Surface.blit(background,x+ox,y+oy,width,height,$screen,x,y)
...@@ -66,6 +67,10 @@ class Scene ...@@ -66,6 +67,10 @@ class Scene
while event = Event.poll while event = Event.poll
handle(event) handle(event)
end end
#要不要放到一个Scene_Game里来处理这个?
while event = Game_Event.poll
handle_game(event)
end
end end
def handle(event) def handle(event)
case event case event
...@@ -81,8 +86,25 @@ class Scene ...@@ -81,8 +86,25 @@ class Scene
when 5 when 5
@active_window.cursor_down @active_window.cursor_down
end end
when Event::KeyDown
case event.sym
when Key::F12
$scene = Scene_Title.new
else
$log.debug('unhandled event'){event.inspect}
end
when Event::Quit when Event::Quit
$scene = nil $scene = nil
else
$log.debug('unhandled event'){event.inspect}
end
end
def handle_game(event)
case event
when Game_Event::Error
Widget_Msgbox.new(event.title, event.message, :ok => "确定"){$scene = Scene_Title.new}
else
$log.debug event
end end
end end
#-------------------------------------------------------------------------- #--------------------------------------------------------------------------
...@@ -94,7 +116,6 @@ class Scene ...@@ -94,7 +116,6 @@ class Scene
# ● 结束处理 # ● 结束处理
#-------------------------------------------------------------------------- #--------------------------------------------------------------------------
def terminate def terminate
#$screen.fill_rect(0,0,$screen.w, $screen.h, 0xFF000000)
end end
def update_active_window(x, y) def update_active_window(x, y)
self.windows.reverse.each do |window| self.windows.reverse.each do |window|
......
...@@ -58,7 +58,7 @@ class Scene_Duel < Scene ...@@ -58,7 +58,7 @@ class Scene_Duel < Scene
@replay = Replay.new @replay = Replay.new
end end
def save_replay def save_replay
@replay.save if @replay #@replay.save if @replay #功能尚不可用
end end
def init_game def init_game
$game.player_field = Game_Field.new @deck $game.player_field = Game_Field.new @deck
...@@ -153,15 +153,6 @@ class Scene_Duel < Scene ...@@ -153,15 +153,6 @@ class Scene_Duel < Scene
end end
def update def update
@cardinfo_window.update @cardinfo_window.update
if $game
while event = Game_Event.poll
handle_game(event)
end
elsif $game
while event = Game_Event.poll
handle_game(event)
end
end
super super
end end
def refresh def refresh
......
...@@ -86,20 +86,12 @@ class Scene_Hall < Scene ...@@ -86,20 +86,12 @@ class Scene_Hall < Scene
$scene = Scene_Watch.new(event.room) $scene = Scene_Watch.new(event.room)
when Game_Event::Chat when Game_Event::Chat
@chat.add event.user, event.content @chat.add event.user, event.content
when Game_Event::Error
Widget_Msgbox.new(event.title, event.message){$scene = Scene_Title.new}
#when Game_Event::QROOMOK
# @joinroom_msgbox.message = "读取房间信息" if @joinroom_msgbox && !@joinroom_msgbox.destroyed?
else else
$log.info "---unhandled game event----" super
$log.debug event
end end
end end
def update def update
while event = Game_Event.poll
handle_game(event)
end
if @count >= 600 if @count >= 600
$game.refresh $game.refresh
@count = 0 @count = 0
......
...@@ -6,28 +6,26 @@ ...@@ -6,28 +6,26 @@
#============================================================================== #==============================================================================
require_relative 'window_gameselect' require_relative 'window_gameselect'
require_relative 'window_login' require_relative 'window_login'
require_relative 'game' require_relative 'scene_replay'
class Scene_Login < Scene class Scene_Login < Scene
Vocab_Logging = "Logging" Vocab_Logging = "Logging"
def start def start
@background = Surface.load("graphics/login/background.png") @background = Surface.load("graphics/login/background.png")
@gameselect_window = Window_GameSelect.new(117,269,$config["game"]) @gameselect_window = Window_GameSelect.new(117,269,$config["game"])
end end
def update #def handle(event)
while event = Game_Event.poll # case event
handle_game(event) # when Event::Active
end # if event.gain
super # end
end #end
def handle_game(event) def handle_game(event)
case event case event
when Game_Event::Login when Game_Event::Login
require_relative 'scene_hall' require_relative 'scene_hall'
$scene = Scene_Hall.new $scene = Scene_Hall.new
when Game_Event::Error
Widget_Msgbox.new(event.title, event.message, :ok => "确定"){$scene = Scene_Title.new}
else else
$log.debug event super
end end
end end
end end
\ No newline at end of file
#encoding: UTF-8 #encoding: UTF-8
require 'Scene_Watch' require 'scene_watch'
class Scene_Replay < Scene_Watch class Scene_Replay < Scene_Watch
def initialize(replay) def initialize(replay)
@replay = replay @replay = replay
...@@ -11,13 +11,13 @@ class Scene_Replay < Scene_Watch ...@@ -11,13 +11,13 @@ class Scene_Replay < Scene_Watch
def save_replay def save_replay
end end
def update def update
if @count >= 60 if @count >= 10#60
event = @replay.get event = @replay.get
if event if event
Game_Event.push event Game_Event.push event
@count = 0 @count = 0
else else
Widget_Msgbox.new("回放", "战报回放完毕") { $scene = Scene_Title.new } Widget_Msgbox.new("回放", "战报回放完毕", :ok => "确定") { $scene = Scene_Login.new }
end end
end end
@count += 1 @count += 1
......
...@@ -48,7 +48,8 @@ class Scene_Title < Scene ...@@ -48,7 +48,8 @@ class Scene_Title < Scene
end end
def terminate def terminate
@command_window.destroy @command_window.destroy
@background.destroy @background.destroy
super
end end
end end
...@@ -27,4 +27,7 @@ class User ...@@ -27,4 +27,7 @@ class User
def room def room
$game && $game.rooms.find{|room|room.player1 == self or room.player2 == self} $game && $game.rooms.find{|room|room.player1 == self or room.player2 == self}
end end
def viewinfo
end
end end
\ No newline at end of file
...@@ -73,4 +73,10 @@ class Window ...@@ -73,4 +73,10 @@ class Window
def lostfocus(active_window=nil) def lostfocus(active_window=nil)
#子类定义 #子类定义
end end
def cursor_up
#子类定义
end
def cursor_down
#子类定义
end
end end
\ No newline at end of file
...@@ -38,7 +38,7 @@ class Window_Action < Window_List ...@@ -38,7 +38,7 @@ class Window_Action < Window_List
@contents.put(@down, 0, @height-15) @contents.put(@down, 0, @height-15)
end end
def index=(index) def index=(index)
if index and index > 0 and index < @item_max if index and index >= 0 and index < @item_max
super(index) super(index)
refresh refresh
end end
......
...@@ -13,7 +13,7 @@ class Window_Chat < Window ...@@ -13,7 +13,7 @@ class Window_Chat < Window
super(x,y,width,height) super(x,y,width,height)
@chat_input = Widget_InputBox.new(416,723,586,24){|text|$game.chat text; add($game.user, text)} @chat_input = Widget_InputBox.new(416,723,586,24){|text|$game.chat text; add($game.user, text)}
@font = TTF.open("fonts/WenQuanYi Micro Hei.ttf", 16) @font = TTF.open("fonts/WenQuanYi Micro Hei.ttf", 16)
@contents.fill_rect(0,0,@width, @height, 0xFFFFFFFF) #@contents.fill_rect(0,0,@width, @height, 0xFFFFFFFF)
@scroll = Widget_ScrollBar.new(@x+@width-20,@y,@height,0) @scroll = Widget_ScrollBar.new(@x+@width-20,@y,@height,0)
@list = [] @list = []
end end
...@@ -22,7 +22,7 @@ class Window_Chat < Window ...@@ -22,7 +22,7 @@ class Window_Chat < Window
refresh refresh
end end
def refresh def refresh
@contents.fill_rect(0,0,@width, @height, 0x66FFFFFF) #@contents.fill_rect(0,0,@width, @height, 0x66FFFFFF)
@list.last(7).each_with_index do |chat, index| @list.last(7).each_with_index do |chat, index|
user, content = *chat user, content = *chat
@font.draw_blended_utf8(@contents, user.name, 0, index*WLH, *User_Color) @font.draw_blended_utf8(@contents, user.name, 0, index*WLH, *User_Color)
......
...@@ -224,25 +224,25 @@ class Window_Field < Window ...@@ -224,25 +224,25 @@ class Window_Field < Window
when 0 when 0
Action::Draw.new(true) Action::Draw.new(true)
when 1 when 1
Widget_Msgbox.new("查看卡组", "功能未实现") Widget_Msgbox.new("查看卡组", "功能未实现", :ok => "确定")
when 2 when 2
Action::Shuffle.new(true) Action::Shuffle.new(true)
when 3 when 3
Widget_Msgbox.new("抽卡并确认", "功能未实现") Widget_Msgbox.new("抽卡并确认", "功能未实现", :ok => "确定")
when 4 when 4
Widget_Msgbox.new("顶牌回卡组底", "功能未实现") Widget_Msgbox.new("顶牌回卡组底", "功能未实现", :ok => "确定")
when 5 when 5
Action::SendToGraveyard.new(true, :deck, @card) Action::SendToGraveyard.new(true, :deck, @card)
when 6 when 6
Action::Remove.new(true, :deck, @card) Action::Remove.new(true, :deck, @card)
when 7 when 7
Widget_Msgbox.new("顶牌背面除外", "功能未实现") Widget_Msgbox.new("顶牌背面除外", "功能未实现", :ok => "确定")
when 8 when 8
Widget_Msgbox.new("确认顶牌", "功能未实现") Widget_Msgbox.new("确认顶牌", "功能未实现")
when 9 when 9
Widget_Msgbox.new("双方确认顶牌", "功能未实现") Widget_Msgbox.new("双方确认顶牌", "功能未实现", :ok => "确定")
when 10 when 10
Widget_Msgbox.new("对方确认顶牌", "功能未实现") Widget_Msgbox.new("对方确认顶牌", "功能未实现", :ok => "确定")
end end
when :extra when :extra
case @action_window.index case @action_window.index
...@@ -252,7 +252,7 @@ class Window_Field < Window ...@@ -252,7 +252,7 @@ class Window_Field < Window
if pos = @field.empty_field(@card) if pos = @field.empty_field(@card)
Action::SpecialSummon.new(true, :extra, pos, @card, nil, :attack) Action::SpecialSummon.new(true, :extra, pos, @card, nil, :attack)
else else
Widget_Msgbox.new("特殊召唤", "场位已满") Widget_Msgbox.new("特殊召唤", "场位已满", :ok => "确定")
end end
when 2 when 2
Action::EffectActivate.new(true, :extra, @card) Action::EffectActivate.new(true, :extra, @card)
...@@ -264,12 +264,12 @@ class Window_Field < Window ...@@ -264,12 +264,12 @@ class Window_Field < Window
when :removed when :removed
case @action_window.index case @action_window.index
when 0 when 0
Widget_Msgbox.new("查看", "功能未实现") Widget_Msgbox.new("查看", "功能未实现", :ok => "确定")
when 1 #特殊召唤 when 1 #特殊召唤
if pos = @field.empty_field(@card) if pos = @field.empty_field(@card)
Action::SpecialSummon.new(true, :removed, pos, @card) Action::SpecialSummon.new(true, :removed, pos, @card)
else else
Widget_Msgbox.new("特殊召唤", "场位已满") Widget_Msgbox.new("特殊召唤", "场位已满", :ok => "确定")
end end
when 2 #效果发动 when 2 #效果发动
Action::EffectActivate.new(true, :removed, @card) Action::EffectActivate.new(true, :removed, @card)
...@@ -283,12 +283,12 @@ class Window_Field < Window ...@@ -283,12 +283,12 @@ class Window_Field < Window
when :graveyard when :graveyard
case @action_window.index case @action_window.index
when 0 when 0
Widget_Msgbox.new("查看", "功能未实现") Widget_Msgbox.new("查看", "功能未实现", :ok => "确定")
when 1 #特殊召唤 when 1 #特殊召唤
if pos = @field.empty_field(@card) if pos = @field.empty_field(@card)
Action::SpecialSummon.new(true, :graveyard, pos, @card) Action::SpecialSummon.new(true, :graveyard, pos, @card)
else else
Widget_Msgbox.new("特殊召唤", "场位已满") Widget_Msgbox.new("特殊召唤", "场位已满", :ok => "确定")
end end
when 2 #效果发动 when 2 #效果发动
Action::EffectActivate.new(true, :graveyard, @card) Action::EffectActivate.new(true, :graveyard, @card)
...@@ -329,9 +329,9 @@ class Window_Field < Window ...@@ -329,9 +329,9 @@ class Window_Field < Window
when 5 when 5
Action::EffectActivate.new(true, @index, @card) Action::EffectActivate.new(true, @index, @card)
when 6 when 6
Widget_Msgbox.new("攻击宣言", "功能未实现") Widget_Msgbox.new("攻击宣言", "功能未实现", :ok => "确定")
when 7 when 7
Widget_Msgbox.new("转移控制权", "功能未实现") Widget_Msgbox.new("转移控制权", "功能未实现", :ok => "确定")
when 8 when 8
Action::ReturnToDeck.new(true, @index, @card) Action::ReturnToDeck.new(true, @index, @card)
when 9 when 9
...@@ -347,25 +347,25 @@ class Window_Field < Window ...@@ -347,25 +347,25 @@ class Window_Field < Window
if pos = @field.empty_field(@card) if pos = @field.empty_field(@card)
Action::Summon.new(true, :hand, pos, @card) Action::Summon.new(true, :hand, pos, @card)
else else
Widget_Msgbox.new("召唤", "场位已满") Widget_Msgbox.new("召唤", "场位已满", :ok => "确定")
end end
when 1 #特殊召唤 when 1 #特殊召唤
if pos = @field.empty_field(@card) if pos = @field.empty_field(@card)
Action::SpecialSummon.new(true, :hand, pos, @card, nil, :attack) Action::SpecialSummon.new(true, :hand, pos, @card, nil, :attack)
else else
Widget_Msgbox.new("特殊召唤", "场位已满") Widget_Msgbox.new("特殊召唤", "场位已满", :ok => "确定")
end end
when 2 #发动 when 2 #发动
if pos = @field.empty_field(@card) if pos = @field.empty_field(@card)
Action::Activate.new(true, :hand, pos, @card) Action::Activate.new(true, :hand, pos, @card)
else else
Widget_Msgbox.new("发动", "场位已满") Widget_Msgbox.new("发动", "场位已满", :ok => "确定")
end end
when 3 #放置 when 3 #放置
if pos = @field.empty_field(@card) if pos = @field.empty_field(@card)
Action::Set.new(true, :hand, pos, @card) Action::Set.new(true, :hand, pos, @card)
else else
Widget_Msgbox.new("放置", "场位已满") Widget_Msgbox.new("放置", "场位已满", :ok => "确定")
end end
when 4 #返回卡组 when 4 #返回卡组
Action::ReturnToDeck.new(true, :hand, @card) Action::ReturnToDeck.new(true, :hand, @card)
......
...@@ -27,12 +27,7 @@ class Window_GameSelect < Window_List ...@@ -27,12 +27,7 @@ class Window_GameSelect < Window_List
refresh refresh
end end
def draw_item(index, status=0) def draw_item(index, status=0)
case status Surface.blit(@button, @button.w/3*status, 0, @button.w/3, @button.h, @contents, 0, WLH*index)
when 0
Surface.blit(@button, 0, 0, @button.w, @button.h, @contents, 0, WLH*index)
when 1
2.times{Surface.blit(@button, 0, 0, @button.w, @button.h, @contents, 0, WLH*index)} #我自重
end
draw_stroked_text(@list[index]["name"], 24, WLH*index+14, 2) draw_stroked_text(@list[index]["name"], 24, WLH*index+14, 2)
end end
def item_rect(index) def item_rect(index)
......
...@@ -20,12 +20,14 @@ class Window_Login < Window ...@@ -20,12 +20,14 @@ class Window_Login < Window
@items = { @items = {
#:username => [192,80,165,WLH], #:username => [192,80,165,WLH],
#:password => [192,125,165,WLH], #:password => [192,125,165,WLH],
:login => [192,200,80,36], :login => [192,200,@button.w/3,@button.h],
:register => [285,200,80,36] :register => [285,200,@button.w/3,@button.h],
:replay => [378,200,@button.w/3,@button.h]
} }
@items_text = { @items_text = {
:login => "登陆", :login => "登陆",
:register => "注册" :register => "注册",
:replay => "战报"
} }
#self.index = nil #self.index = nil
refresh refresh
...@@ -44,14 +46,29 @@ class Window_Login < Window ...@@ -44,14 +46,29 @@ class Window_Login < Window
draw_stroked_text("密码", 105,125+2,1) draw_stroked_text("密码", 105,125+2,1)
end end
def draw_item(index, rect, status=0) def draw_item(index, rect, status=0)
Surface.blit(@button,0,0,rect[2],rect[3],@contents,rect[0],rect[1]) Surface.blit(@button,rect[2]*status,0,rect[2],rect[3],@contents,rect[0],rect[1])
draw_stroked_text(@items_text[index], rect[0]+20, rect[1]+9,1,@font_button) draw_stroked_text(@items_text[index], rect[0]+24, rect[1]+9,1,@font_button)
end end
def mousemoved(x,y) def mousemoved(x,y)
@items.each_pair{|index, rect|return self.index = index if (x-@x >= rect[0] and x-@x < rect[0]+rect[2] and y-@y >= rect[1] and y-@y < rect[1]+rect[3])} self.index = @items.each_pair{|index, rect|break index if (x-@x >= rect[0] and x-@x < rect[0]+rect[2] and y-@y >= rect[1] and y-@y < rect[1]+rect[3])}
end
def lostfocus(active_window=nil)
self.index = nil
end
def item_rect(index)
@items[index]
end end
def index=(index) def index=(index)
index = nil if !@items.has_key?(index)
return if @index == index return if @index == index
if @index
clear(*item_rect(@index))
draw_item(@index, item_rect(@index), 0)
end
@index = index @index = index
if @index
clear(*item_rect(@index))
draw_item(@index, item_rect(@index), 1)
end
end end
end end
...@@ -32,7 +32,7 @@ class Window_LP < Window ...@@ -32,7 +32,7 @@ class Window_LP < Window
else else
width = [0, [(200*lp/8000), 200].min].max width = [0, [(200*lp/8000), 200].min].max
@contents.fill_rect(@width-width-64,0,width , 24, 0xFFFF0000) @contents.fill_rect(@width-width-64,0,width , 24, 0xFFFF0000)
@font.draw_blended_utf8(@contents, @lp.to_s, @width-width-64, 0, *@color) @font.draw_blended_utf8(@contents, @lp.to_s, @width-128, 0, *@color)
end end
end end
end end
\ No newline at end of file
...@@ -17,9 +17,8 @@ class Window_User < Window_List ...@@ -17,9 +17,8 @@ class Window_User < Window_List
end end
def refresh def refresh
@thread.kill if @thread @thread.kill if @thread
@contents.put(@background, 0,0) super
@thread = @user.avatar(:middle) do |avatar| @thread = @user.avatar(:middle) do |avatar|
clear(12,12,144,144)
@contents.put(avatar, 24, 24) @contents.put(avatar, 24, 24)
@contents.put(@avatar_boarder, 12, 12) @contents.put(@avatar_boarder, 12, 12)
end end
...@@ -27,9 +26,11 @@ class Window_User < Window_List ...@@ -27,9 +26,11 @@ class Window_User < Window_List
@font.draw_blended_utf8(@contents, @user.name, 172, 24, 0x00,0x00,0x00) @font.draw_blended_utf8(@contents, @user.name, 172, 24, 0x00,0x00,0x00)
@font.draw_blended_utf8(@contents, "id: #{@user.id}" , 172, 32+WLH, 0x00,0x00,0x00) @font.draw_blended_utf8(@contents, "id: #{@user.id}" , 172, 32+WLH, 0x00,0x00,0x00)
@font.draw_blended_utf8(@contents, "#{'房间' + @user.room.id.to_s + ' ' if @user.room}#{case @user.status;when :hall;'大厅';when :dueling;'决斗中';when :waiting;'等待中';end}", 172, 32+WLH*2, 0x00,0x00,0x00) @font.draw_blended_utf8(@contents, "#{'房间' + @user.room.id.to_s + ' ' if @user.room}#{case @user.status;when :hall;'大厅';when :dueling;'决斗中';when :waiting;'等待中';end}", 172, 32+WLH*2, 0x00,0x00,0x00)
super
end
def clear(x=0,y=0,width=@width,height=@height)
Surface.blit(@background, x,y,width,height,@contents,x,y)
end end
def draw_item(index, status=0) def draw_item(index, status=0)
@font.draw_blended_utf8(@contents, @list[index] , 172, 96+index*WLH, 0x00,0x00,0x00) @font.draw_blended_utf8(@contents, @list[index] , 172, 96+index*WLH, 0x00,0x00,0x00)
...@@ -42,8 +43,7 @@ class Window_User < Window_List ...@@ -42,8 +43,7 @@ class Window_User < Window_List
when 0 when 0
#发送消息 #发送消息
when 1 when 1
require 'launchy' @user.space
Launchy.open("http://google.com")
when 2 when 2
if @user.status == :waiting if @user.status == :waiting
$game.join(@user.room) $game.join(@user.room)
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
#  title #  title
#============================================================================== #==============================================================================
require_relative 'window_user'
class Window_UserList < Window_List class Window_UserList < Window_List
attr_reader :x, :y, :width, :height attr_reader :x, :y, :width, :height
WLH = 20 WLH = 20
...@@ -36,9 +36,9 @@ class Window_UserList < Window_List ...@@ -36,9 +36,9 @@ class Window_UserList < Window_List
def item_rect(index) def item_rect(index)
[0, WLH*index, @width, WLH] [0, WLH*index, @width, WLH]
end end
def clear(x=0,y=0,width=@width,height=@height) #def clear(x=0,y=0,width=@width,height=@height)
@contents.fill_rect(x,y,width,height,0x66FFFFFF) # @contents.fill_rect(x,y,width,height,0x66FFFFFF)
end #end
def clicked def clicked
#$scene.refresh_rect(*item_rect(@index)){draw_item(@index, 2)} if @index #$scene.refresh_rect(*item_rect(@index)){draw_item(@index, 2)} if @index
@userwindow = Window_User.new(100,100,@list[@index]) @userwindow = Window_User.new(100,100,@list[@index])
......
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