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

临时提交

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