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

URL protocol加强

parent 5f588e30
require 'json'
require_relative 'game' require_relative 'game'
require_relative 'user' require_relative 'user'
require_relative 'room' require_relative 'room'
require_relative 'ygocore/game' require_relative 'ygocore/game'
$game = Ygocore.new $game = Ygocore.new
uri = ARGV.first[9, ARGV.first.size-9]
args = JSON.parse ARGV.first[7, ARGV.first.size-7].unpack('m').first case uri
$game.user = User.new(args["username"].to_sym, args["username"]) when /^(.*)\:(.*)\@(.*)\:(\d+)\/(.*)$/
$game.password = args["password"] $game.user = User.new($1.to_sym, $1)
$game.server = args['server_ip'] $game.password = $2
$game.port = args['server_port'] $game.server = $3
Ygocore.run_ygocore Room.new(0, args['room_name']), true $game.port = $4.to_i
\ No newline at end of file Ygocore.run_ygocore Room.new(0, $5), true
when /^(.*\.yrp)$/
require 'open-uri'
open("http://"+$1, 'rb') { |src|
Dir.mkdir("replay") unless File.directory?("replay")
open('replay/' + File.basename($1), 'wb'){|dest|
dest.write src.read
}
}
Ygocore.replay('replay/' + File.basename($1), true)
when /^(.*\.ydk)$/
require 'open-uri'
open("http://"+$1, 'rb') { |src|
Dir.mkdir('ygocore/deck') unless File.directory?("ygocore/deck")
open('ygocore/deck/' + File.basename($1), 'wb'){|dest|
dest.write src.read
}
}
Ygocore.run_ygocore(File.basename($1, '.ydk'), true)
end
\ No newline at end of file
...@@ -139,6 +139,23 @@ class Ygocore < Game ...@@ -139,6 +139,23 @@ class Ygocore < Game
args = '-r' args = '-r'
when :deck when :deck
args = '-d' args = '-d'
when String
system_conf = {}
begin
IO.readlines('system.conf').each do |line|
line.force_encoding "UTF-8"
next if line[0,1] == '#'
field, contents = line.chomp.split(' = ',2)
system_conf[field] = contents
end
rescue
system_conf['antialias'] = 2
system_conf['textfont'] = 'c:/windows/fonts/simsun.ttc 14'
system_conf['numfont'] = 'c:/windows/fonts/arialbd.ttf'
end
system_conf['lastdeck'] = option
open('system.conf', 'w') {|file|file.write system_conf.collect{|key,value|"#{key} = #{value}"}.join("\n")}
args = '-d'
end end
IO.popen("ygopro_vs.exe #{args}") IO.popen("ygopro_vs.exe #{args}")
WM.iconify rescue nil WM.iconify rescue nil
...@@ -164,11 +181,11 @@ class Ygocore < Game ...@@ -164,11 +181,11 @@ class Ygocore < Game
end end
end end
end end
def self.replay(file) def self.replay(file, skip_image_downloading = false)
require 'fileutils' require 'fileutils'
FileUtils.mv Dir.glob('ygocore/replay/*.yrp'), 'replay/' FileUtils.mv Dir.glob('ygocore/replay/*.yrp'), 'replay/'
FileUtils.copy_file(file, "ygocore/replay/#{File.basename(file)}") FileUtils.copy_file(file, "ygocore/replay/#{File.basename(file)}")
run_ygocore(:replay) run_ygocore(:replay, skip_image_downloading)
end end
private private
......
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