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

临时提交

parent ac0436ff
This diff was suppressed by a .gitattributes entry.
...@@ -160,13 +160,13 @@ class Action ...@@ -160,13 +160,13 @@ class Action
end end
end end
class Summon < Move class Summon < Move
def initialize(from_player, from_pos, to_pos, card) def initialize(from_player, from_pos, to_pos, card, msg=nil)
super(from_player, from_pos, to_pos, card, nil, :attack) super(from_player, from_pos, to_pos, card, msg, :attack)
end end
end end
class SpecialSummon < Move class SpecialSummon < Move
def initialize(from_player, from_pos, to_pos, card, position=:attack) def initialize(from_player, from_pos, to_pos, card, msg=nil, position=:attack)
super(from_player, from_pos, to_pos, card, nil, position) super(from_player, from_pos, to_pos, card, msg, position)
end end
end end
class SendToGraveyard < Move class SendToGraveyard < Move
......
...@@ -8,6 +8,7 @@ class FPSTimer ...@@ -8,6 +8,7 @@ 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
...@@ -15,7 +16,7 @@ class FPSTimer ...@@ -15,7 +16,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 = get_ticks @old = Time.now.to_f
@skip = 0 @skip = 0
@real_fps = @fps @real_fps = @fps
@frame_count = 0 @frame_count = 0
...@@ -26,19 +27,16 @@ class FPSTimer ...@@ -26,19 +27,16 @@ class FPSTimer
# execute given block and wait # execute given block and wait
def wait_frame def wait_frame
now = get_ticks #sleep 0.01
nxt = @old + (1.0/@fps) #yield
if nxt > now || @skip > @skip_limit nxt = @old + @spf
yield #now =
@skip = 0 yield if nxt > Time.now.to_f
wait(nxt) if (sleeptime = nxt - Time.now.to_f) > 0
@old = nxt sleep(sleeptime)
else
@skip += 1
@total_skip += 1
@old = get_ticks
end end
#end
@old = nxt
calc_real_fps calc_real_fps
end end
......
...@@ -35,7 +35,7 @@ class Iduel ...@@ -35,7 +35,7 @@ class Iduel
info.encode! "UTF-8", :invalid => :replace, :undef => :replace info.encode! "UTF-8", :invalid => :replace, :undef => :replace
puts ">> #{info}" puts ">> #{info}"
Event.parse info Event.parse info
rescue rescue IOError
@conn.close @conn.close
@conn = nil @conn = nil
Event::Error.new(0) Event::Error.new(0)
......
...@@ -198,6 +198,8 @@ class Action ...@@ -198,6 +198,8 @@ class Action
ReturnToExtra.new from_player, parse_pos($2), parse_card($1) ReturnToExtra.new from_player, parse_pos($2), parse_card($1)
when /从#{PosFilter}#{CardFilter}加入手卡/ when /从#{PosFilter}#{CardFilter}加入手卡/
ReturnToHand.new from_player, parse_pos($1), parse_card($2) ReturnToHand.new from_player, parse_pos($1), parse_card($2)
when /#{PosFilter}#{CardFilter}效果发(?:\~){0,1}动/
Effect_Activate.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))
else else
......
...@@ -191,6 +191,7 @@ class Iduel::Event::Error < Iduel::Event ...@@ -191,6 +191,7 @@ class Iduel::Event::Error < Iduel::Event
["错误", "请求的房间无效"] ["错误", "请求的房间无效"]
end end
#Exception.new(@message).raise #Exception.new(@message).raise
p caller
p @title p @title
p @message p @message
#system("pause") #system("pause")
......
...@@ -47,7 +47,10 @@ require_relative 'fpstimer' ...@@ -47,7 +47,10 @@ require_relative 'fpstimer'
require_relative 'widget_msgbox' require_relative 'widget_msgbox'
$fpstimer = FPSTimer.new $fpstimer = FPSTimer.new
$scene = Scene_Title.new $scene = Scene_Title.new
while $scene begin
$scene.main $scene.main while $scene
end #rescue
SDL.quit #这货居然会卡一下///囧 # p $!, $!.backtrace
\ No newline at end of file # Widget_Msgbox.new("程序出错", "程序可能出现了一个bug,请去论坛反馈") { $scene = Scene_Title.new }
# retry
end
\ No newline at end of file
...@@ -19,13 +19,13 @@ class Scene ...@@ -19,13 +19,13 @@ class Scene
end end
def initialize def initialize
@windows = [] @windows = []
@font = TTF.open('fonts/WenQuanYi Micro Hei.ttf', 16)
end end
#-------------------------------------------------------------------------- #--------------------------------------------------------------------------
# ● 开始处理 # ● 开始处理
#-------------------------------------------------------------------------- #--------------------------------------------------------------------------
def start def start
@fps = Window.new(0,0,100,24,500)
@font = TTF.open('fonts/WenQuanYi Micro Hei.ttf', 16)
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)
...@@ -55,10 +55,8 @@ class Scene ...@@ -55,10 +55,8 @@ class Scene
#@fpscount += 1 #@fpscount += 1
$fpstimer.wait_frame do $fpstimer.wait_frame do
$screen.put(@background,0,0) $screen.put(@background,0,0)
@fps.contents.fill_rect(0,0,@fps.contents.w,@fps.contents.h,0x00000000)
@font.draw_solid_utf8(@fps.contents, "%.1f" % $fpstimer.real_fps, 0, 0, 0xFF, 0xFF, 0xFF)
@windows.each do |window| @windows.each do |window|
if window.contents && window.visible && !window.destroted? if window.contents && window.visible && !window.destroyed?
if window.angle.zero? if window.angle.zero?
Surface.blit(window.contents, *window.viewport, $screen, window.x, window.y) Surface.blit(window.contents, *window.viewport, $screen, window.x, window.y)
else else
...@@ -69,6 +67,7 @@ class Scene ...@@ -69,6 +67,7 @@ class Scene
end end
#$screen.put(window.contents, window.x, window.y) if window.contents && window.visible #$screen.put(window.contents, window.x, window.y) if window.contents && window.visible
end end
@font.draw_blended_utf8($screen, "%.1f" % $fpstimer.real_fps, 0, 0, 0xFF, 0xFF, 0xFF)
$screen.update_rect(0,0,0,0) $screen.update_rect(0,0,0,0)
end end
end end
......
#encoding: UTF-8
#============================================================================== #==============================================================================
# Scene_Hall # Scene_Hall
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
...@@ -112,6 +113,8 @@ class Scene_Hall < Scene ...@@ -112,6 +113,8 @@ class Scene_Hall < Scene
@chat.add event.user, event.content @chat.add event.user, event.content
when Iduel::Event::Error when Iduel::Event::Error
Widget_Msgbox.new(event.title, event.message){$scene = Scene_Title.new} Widget_Msgbox.new(event.title, event.message){$scene = Scene_Title.new}
when Iduel::Event::QROOMOK
@joinroom_msgbox.message = "读取房间信息" if @joinroom_msgbox && !@joinroom_msgbox.destroyed?
else else
puts "---unhandled iduel event----" puts "---unhandled iduel event----"
p event p event
...@@ -136,8 +139,10 @@ class Scene_Hall < Scene ...@@ -136,8 +139,10 @@ class Scene_Hall < Scene
return unless @roomlist.index and room = @roomlist.list[@roomlist.index] return unless @roomlist.index and room = @roomlist.list[@roomlist.index]
if room.full? if room.full?
$iduel.watch room $iduel.watch room
@joinroom_msgbox = Widget_Msgbox.new("加入房间", "正在加入观战"){}
else else
$iduel.join room, "test" $iduel.join room, "test"
@joinroom_msgbox = Widget_Msgbox.new("加入房间", "正在加入房间"){}
end end
end end
end end
......
...@@ -81,6 +81,7 @@ class Scene_Title < Scene ...@@ -81,6 +81,7 @@ class Scene_Title < Scene
p event p event
end end
end end
#super #黑历史,title在有那架构之前就已经写好了,暂时懒得动
end end
def determine def determine
return unless @command_window.index return unless @command_window.index
......
...@@ -15,7 +15,7 @@ class Widget_InputBox < Window ...@@ -15,7 +15,7 @@ class Widget_InputBox < Window
bind('Key-Return'){@@active.proc.call(get);delete(0, get.size);@@root.withdraw(true);true} bind('Key-Return'){@@active.proc.call(get);delete(0, get.size);@@root.withdraw(true);true}
pack pack
} }
Thread.new{Tk.mainloop} Thread.new{Tk.mainloop}.priority = 1
def initialize(x,y,width,height,z=300, &block) def initialize(x,y,width,height,z=300, &block)
super(x,y,width,height,z) super(x,y,width,height,z)
@font = TTF.open("fonts/WenQuanYi Micro Hei.ttf", 20) @font = TTF.open("fonts/WenQuanYi Micro Hei.ttf", 20)
......
# To change this template, choose Tools | Templates #encoding: UTF-8
# and open the template in the editor.
class Widget_Msgbox < Window class Widget_Msgbox < Window
def initialize(title, message, buttons={:ok => "确定"}, &proc) def initialize(title, message, buttons={:ok => "确定"}, &proc)
#@background = Surface.load 'graphics/system/msgbox.png'
@contents = Surface.load 'graphics/system/msgbox.png' @contents = Surface.load 'graphics/system/msgbox.png'
@button = Surface.load 'graphics/system/button.png' @button = Surface.load 'graphics/system/button.png'
@font = TTF.open("fonts/WenQuanYi Micro Hei.ttf", 16) @font = TTF.open("fonts/WenQuanYi Micro Hei.ttf", 16)
...@@ -23,9 +22,22 @@ class Widget_Msgbox < Window ...@@ -23,9 +22,22 @@ class Widget_Msgbox < Window
end end
refresh refresh
end end
def title=(title)
@title.replace title
refresh
end
def message=(message)
@message.replace message
refresh
end
def buttons=(buttons)
@buttons.replace buttons
refresh
end
def refresh def refresh
@contents = Surface.load 'graphics/system/msgbox.png'
@font.draw_blended_utf8(@contents, @title, (@width-@font.text_size(@title)[0])/2, 2, 0xFF, 0xFF, 0xFF) @font.draw_blended_utf8(@contents, @title, (@width-@font.text_size(@title)[0])/2, 2, 0xFF, 0xFF, 0xFF)
@font.draw_blended_utf8(@contents, @message, 0, 24, 0xFF, 0xFF, 0x66) @font.draw_blended_utf8(@contents, @message, 2, 24+2, 0xFF, 0xFF, 0x66)
@items.each_key do |index| @items.each_key do |index|
draw_item(index, @index == index ? 1 : 0) draw_item(index, @index == index ? 1 : 0)
end end
......
...@@ -40,12 +40,12 @@ class Window ...@@ -40,12 +40,12 @@ class Window
x > @x && x < @x + @width && y > @y && y < @y + @height x > @x && x < @x + @width && y > @y && y < @y + @height
end end
def destroy def destroy
@destroted = true @destroyed = true
@contents.destroy if @contents @contents.destroy if @contents
$scene.windows.delete self $scene.windows.delete self
end end
def destroted? def destroyed?
@destroted @destroyed
end end
def clear(x, y, width, height) def clear(x, y, width, height)
Surface.blit(@background, x,y,width,height,@contents,x,y) Surface.blit(@background, x,y,width,height,@contents,x,y)
......
...@@ -9,7 +9,8 @@ class Window_CardInfo < Window ...@@ -9,7 +9,8 @@ class Window_CardInfo < Window
self.card = nil self.card = nil
end end
def card=(card) def card=(card)
@card = card || Card.find(nil) return if card.nil? or card == @card or !card.known?
@card = card
refresh refresh
end end
def update def update
......
...@@ -240,7 +240,7 @@ class Window_Field < Window ...@@ -240,7 +240,7 @@ class Window_Field < Window
case $scene.action_window.index case $scene.action_window.index
when 0 when 0
if pos = @field.empty_field(@card) if pos = @field.empty_field(@card)
Action::SpecialSummon.new(true, :extra, pos, @card, :attack).run Action::SpecialSummon.new(true, :extra, pos, @card, nil, :attack).run
else else
p "场位已满" p "场位已满"
end end
...@@ -337,7 +337,7 @@ class Window_Field < Window ...@@ -337,7 +337,7 @@ class Window_Field < Window
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, :attack).run Action::SpecialSummon.new(true, :hand, pos, @card, nil, :attack).run
else else
p "场位已满" p "场位已满"
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