Commit 2cc864c5 authored by 神楽坂玲奈's avatar 神楽坂玲奈

nothing

parent 1d260837
# Auto detect text files and perform LF normalization # Auto detect text files and perform LF normalization
* text=auto * text=auto
# Custom for Visual Studio *.rb text
*.cs diff=csharp *.yml text
*.sln merge=union
*.csproj merge=union
*.vbproj merge=union
*.fsproj merge=union
*.dbproj merge=union
# Standard to msysgit *.html text
*.doc diff=astextplain *.js text
*.DOC diff=astextplain *.coffee text
*.docx diff=astextplain *.css text
*.DOCX diff=astextplain *.less text
*.dot diff=astextplain
*.DOT diff=astextplain *.png binary
*.pdf diff=astextplain *.jpg binary
*.PDF diff=astextplain \ No newline at end of file
*.rtf diff=astextplain
*.RTF diff=astextplain
#游戏适配器的抽象类 #游戏适配器的抽象类
require_relative 'game_event' require_relative 'game_event'
require_relative 'action' require_relative 'action'
require_relative 'user' require_relative 'user'
require_relative 'room' require_relative 'room'
require_relative 'server' require_relative 'server'
class Game class Game
attr_reader :users, :rooms, :servers, :filter attr_reader :users, :rooms, :servers, :filter
attr_accessor :user, :room, :player_field, :opponent_field, :turn, :turn_player, :phase attr_accessor :user, :room, :player_field, :opponent_field, :turn, :turn_player, :phase
def initialize def initialize
@users = [] @users = []
@rooms = [] @rooms = []
@servers = [] @servers = []
@filter = {servers: [], waiting_only: false, normal_only: false} @filter = {servers: [], waiting_only: false, normal_only: false}
end end
def login(username, password=nil) def login(username, password=nil)
end end
def refresh def refresh
end end
def host(room_name, room_config) def host(room_name, room_config)
end end
def join(room) def join(room)
end end
def watch(room) def watch(room)
end end
def leave def leave
end end
def action(action) def action(action)
end end
def chat(chatmessage) def chat(chatmessage)
end end
def exit def exit
$scene = Scene_Login.new if $scene $scene = Scene_Login.new if $scene
end end
def watching? def watching?
@room and @room.include? @user @room and @room.include? @user
end end
def self.deck_edit def self.deck_edit
require_relative 'window_deck' require_relative 'window_deck'
@deck_window = Window_Deck.new @deck_window = Window_Deck.new
end end
def refresh_interval def refresh_interval
5 5
end end
def show_chat_self def show_chat_self
false false
end end
end end
#!/usr/bin/env ruby #!/usr/bin/env ruby
begin begin
Windows = RUBY_PLATFORM["win"] || RUBY_PLATFORM["ming"] Windows = RUBY_PLATFORM["win"] || RUBY_PLATFORM["ming"]
Dir.glob('post_update_*.rb').sort.each { |file| load file } Dir.glob('post_update_*.rb').sort.each { |file| load file }
Thread.abort_on_exception = true Thread.abort_on_exception = true
require_relative 'resolution' require_relative 'resolution'
require_relative 'announcement' require_relative 'announcement'
require_relative 'config' require_relative 'config'
require_relative 'association' require_relative 'association'
#i18n #i18n
require 'i18n' require 'i18n'
require 'locale' require 'locale'
I18n.load_path += Dir['locales/*.yml'] I18n.load_path += Dir['locales/*.yml']
I18n::Backend::Simple.include(I18n::Backend::Fallbacks) I18n::Backend::Simple.include(I18n::Backend::Fallbacks)
#读取配置文件 #读取配置文件
$config = Config.load $config = Config.load
Config.save Config.save
#读取命令行参数 #读取命令行参数
log = "log.log" log = "log.log"
log_level = "INFO" log_level = "INFO"
profile = nil profile = nil
ARGV.each do |arg| ARGV.each do |arg|
arg = arg.dup.force_encoding("UTF-8") arg = arg.dup.force_encoding("UTF-8")
arg.force_encoding("GBK") unless arg.valid_encoding? arg.force_encoding("GBK") unless arg.valid_encoding?
case arg case arg
when /--log=(.*)/ when /--log=(.*)/
log.replace $1 log.replace $1
when /--log-level=(.*)/ when /--log-level=(.*)/
log_level.replace $1 log_level.replace $1
when /--profile=(.*)/ when /--profile=(.*)/
profile = $1 profile = $1
when /^mycard:.*|\.ydk$|\.yrp$|\.deck$/ when /^mycard:.*|\.ydk$|\.yrp$|\.deck$/
require_relative 'quickstart' require_relative 'quickstart'
$scene = false $scene = false
when /register_association/ when /register_association/
Association.register Association.register
$scene = false $scene = false
end end
end end
unless $scene == false unless $scene == false
#加载文件 #加载文件
require 'logger' require 'logger'
require 'sdl' require 'sdl'
include SDL include SDL
require_relative 'dialog' require_relative 'dialog'
require_relative 'graphics' require_relative 'graphics'
require_relative 'window' require_relative 'window'
require_relative 'widget_msgbox' require_relative 'widget_msgbox'
#日志 #日志
if log == "STDOUT" #调试用 if log == "STDOUT" #调试用
log = STDOUT log = STDOUT
end end
$log = Logger.new(log, 1, 1024000) $log = Logger.new(log, 1, 1024000)
$log.level = Logger.const_get log_level $log.level = Logger.const_get log_level
#性能分析 #性能分析
if profile if profile
if profile == "STDOUT" if profile == "STDOUT"
profile = STDOUT profile = STDOUT
else else
profile = open(profile, 'w') profile = open(profile, 'w')
end end
require 'profiler' require 'profiler'
RubyVM::InstructionSequence.compile_option = { RubyVM::InstructionSequence.compile_option = {
:trace_instruction => true, :trace_instruction => true,
:specialized_instruction => false :specialized_instruction => false
} }
Profiler__::start_profile Profiler__::start_profile
end end
SDL::Event::APPMOUSEFOCUS = 1 SDL::Event::APPMOUSEFOCUS = 1
SDL::Event::APPINPUTFOCUS = 2 SDL::Event::APPINPUTFOCUS = 2
SDL::Event::APPACTIVE = 4 SDL::Event::APPACTIVE = 4
SDL.putenv ("SDL_VIDEO_CENTERED=1"); SDL.putenv ("SDL_VIDEO_CENTERED=1");
SDL.init(INIT_VIDEO) SDL.init(INIT_VIDEO)
WM::set_caption("MyCard", "MyCard") WM::set_caption("MyCard", "MyCard")
WM::icon = Surface.load("graphics/system/icon.gif") WM::icon = Surface.load("graphics/system/icon.gif")
$screen = Screen.open($config['screen']['width'], $config['screen']['height'], 0, HWSURFACE | ($config['screen']['fullscreen'] ? FULLSCREEN : 0)) $screen = Screen.open($config['screen']['width'], $config['screen']['height'], 0, HWSURFACE | ($config['screen']['fullscreen'] ? FULLSCREEN : 0))
TTF.init TTF.init
#声音 #声音
begin begin
SDL.init(INIT_AUDIO) SDL.init(INIT_AUDIO)
Mixer.open(Mixer::DEFAULT_FREQUENCY, Mixer::DEFAULT_FORMAT, Mixer::DEFAULT_CHANNELS, 1536) Mixer.open(Mixer::DEFAULT_FREQUENCY, Mixer::DEFAULT_FORMAT, Mixer::DEFAULT_CHANNELS, 1536)
Mixer.set_volume_music(60) Mixer.set_volume_music(60)
rescue rescue
nil nil
end end
#标题场景 #标题场景
require_relative 'scene_title' require_relative 'scene_title'
$scene = Scene_Title.new $scene = Scene_Title.new
#自动更新, 加载放到SDL前面会崩, 原因不明 #自动更新, 加载放到SDL前面会崩, 原因不明
require_relative 'update' require_relative 'update'
Update.start Update.start
WM::set_caption("MyCard v#{Update::Version}", "MyCard") WM::set_caption("MyCard v#{Update::Version}", "MyCard")
#文件关联 #文件关联
Association.start Association.start
#初始化完毕 #初始化完毕
$log.info("main") { "初始化成功" } $log.info("main") { "初始化成功" }
end end
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") }
$scene = false $scene = false
end end
#主循环 #主循环
begin begin
$scene.main while $scene $scene.main while $scene
rescue Exception => exception rescue Exception => exception
exception.backtrace.each { |backtrace| break if backtrace =~ /^(.*)\.rb:\d+:in `.*'"$/ } #由于脚本是从main.rb开始执行的,总会有个能匹配成功的文件 exception.backtrace.each { |backtrace| break if backtrace =~ /^(.*)\.rb:\d+:in `.*'"$/ } #由于脚本是从main.rb开始执行的,总会有个能匹配成功的文件
$log.fatal($1) { [exception.inspect, *exception.backtrace].collect { |str| str.force_encoding("UTF-8") }.join("\n") } $log.fatal($1) { [exception.inspect, *exception.backtrace].collect { |str| str.force_encoding("UTF-8") }.join("\n") }
$game.exit if $game $game.exit if $game
require_relative 'scene_error' require_relative 'scene_error'
$scene = Scene_Error.new $scene = Scene_Error.new
retry retry
ensure ensure
if profile if profile
Profiler__::print_profile(profile) Profiler__::print_profile(profile)
profile.close profile.close
end end
$log.close rescue nil $log.close rescue nil
end end
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
require_relative 'window_host' require_relative 'window_host'
class Window_LobbyButtons < Window_List class Window_LobbyButtons < Window_List
def initialize(x, y) def initialize(x, y)
@items = [I18n.t('lobby.faq'), I18n.t('lobby.filter'), I18n.t('lobby.editdeck'), I18n.t('lobby.newroom')] @items = [I18n.t('lobby.faq'), I18n.t('lobby.filter'), I18n.t('lobby.editdeck'), I18n.t('lobby.newroom')]
@button = Surface.load("graphics/lobby/button.png") @button = Surface.load("graphics/lobby/button.png")
super(x, y, @items.size*@button.w/3+@items.size*4, 30) super(x, y, @items.size*@button.w/3+@items.size*4, 30)
@font = TTF.open("fonts/wqy-microhei.ttc", 15) @font = TTF.open("fonts/wqy-microhei.ttc", 15)
refresh refresh
end end
def draw_item(index, status=0) def draw_item(index, status=0)
x, y, width=item_rect(index) x, y, width=item_rect(index)
Surface.blit(@button, status*@button.w/3, 0, @button.w/3, @button.h, @contents, x, y) Surface.blit(@button, status*@button.w/3, 0, @button.w/3, @button.h, @contents, x, y)
draw_stroked_text(@items[index], x+center_margin(@items[index],width,@font), y+3, 2, @font, [0xdf, 0xf1, 0xff], [0x27, 0x43, 0x59]) draw_stroked_text(@items[index], x+center_margin(@items[index],width,@font), y+3, 2, @font, [0xdf, 0xf1, 0xff], [0x27, 0x43, 0x59])
end end
def item_rect(index) def item_rect(index)
[index*@button.w/3+(index)*4, 0, @button.w/3, @height] [index*@button.w/3+(index)*4, 0, @button.w/3, @height]
end end
def mousemoved(x, y) def mousemoved(x, y)
if (x-@x) % (@button.w/3+4) >= @button.w/3 if (x-@x) % (@button.w/3+4) >= @button.w/3
self.index = nil self.index = nil
else else
self.index = (x-@x)/(@button.w/3+4) self.index = (x-@x)/(@button.w/3+4)
end end
end end
def lostfocus(active_window = nil) def lostfocus(active_window = nil)
self.index = nil self.index = nil
end end
def clicked def clicked
case @index case @index
when 0 #常见问题 when 0 #常见问题
require_relative 'dialog' require_relative 'dialog'
Dialog.web "http://my-card.in/login?user[name]=#{CGI.escape $game.user.name}&user[password]=#{CGI.escape $game.password}&continue=/topics/1453" Dialog.web "http://my-card.in/login?user[name]=#{CGI.escape $game.user.name}&user[password]=#{CGI.escape $game.password}&continue=/topics/1453"
when 1 #房间筛选 when 1 #房间筛选
if @filter_window and !@filter_window.destroyed? if @filter_window and !@filter_window.destroyed?
@filter_window.destroy @filter_window.destroy
else else
@filter_window = Window_Filter.new(678, 44) @filter_window = Window_Filter.new(678, 44)
end end
when 2 #卡组编辑 when 2 #卡组编辑
require_relative 'deck' require_relative 'deck'
$game.class.deck_edit $game.class.deck_edit
when 3 #建立房间 when 3 #建立房间
@host_window = Window_Host.new(300, 200) @host_window = Window_Host.new(300, 200)
end end
end end
def update def update
@host_window.update if @host_window and !@host_window.destroyed? @host_window.update if @host_window and !@host_window.destroyed?
end end
end end
#encoding: UTF-8 #encoding: UTF-8
#============================================================================== #==============================================================================
# Window_UserInfo # Window_UserInfo
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
# 游戏大厅显示用户信息的类 # 游戏大厅显示用户信息的类
#============================================================================== #==============================================================================
class Window_UserInfo < Window class Window_UserInfo < Window
def initialize(x, y, user) def initialize(x, y, user)
@avatar_boarder = Surface.load("graphics/lobby/avatar_boader.png") @avatar_boarder = Surface.load("graphics/lobby/avatar_boader.png")
super(x,y,280,144) super(x,y,280,144)
@font = TTF.open('fonts/wqy-microhei.ttc', 16) @font = TTF.open('fonts/wqy-microhei.ttc', 16)
@user = user @user = user
@background = Surface.load("graphics/lobby/userinfo.png").display_format @background = Surface.load("graphics/lobby/userinfo.png").display_format
refresh refresh
end end
def refresh def refresh
@contents.put(@background, 0, 0) @contents.put(@background, 0, 0)
@thread = @user.avatar(:middle) do |avatar| @thread = @user.avatar(:middle) do |avatar|
clear(0,0,@avatar_boarder.w, @avatar_boarder.h) clear(0,0,@avatar_boarder.w, @avatar_boarder.h)
@contents.put(avatar, 12, 12) @contents.put(avatar, 12, 12)
@contents.put(@avatar_boarder, 0, 0) @contents.put(@avatar_boarder, 0, 0)
end end
@font.draw_blended_utf8(@contents, @user.name, 160, 12, 0x00,0x00,0x00) unless @user.name.empty? @font.draw_blended_utf8(@contents, @user.name, 160, 12, 0x00,0x00,0x00) unless @user.name.empty?
@font.draw_blended_utf8(@contents, @user.id.to_s , 160, 12+16*2, 0x00,0x00,0x00) unless @user.id.to_s.empty? @font.draw_blended_utf8(@contents, @user.id.to_s , 160, 12+16*2, 0x00,0x00,0x00) unless @user.id.to_s.empty?
@font.draw_blended_utf8(@contents, "Lv: #{@user.level}" , 160, 12+16*3, 0x00,0x00,0x00) if @user.respond_to? :level and @user.level #TODO:规范化,level是iduel专属的,但是又不太想让iduel来重定义这个window @font.draw_blended_utf8(@contents, "Lv: #{@user.level}" , 160, 12+16*3, 0x00,0x00,0x00) if @user.respond_to? :level and @user.level #TODO:规范化,level是iduel专属的,但是又不太想让iduel来重定义这个window
@font.draw_blended_utf8(@contents, "经验: #{@user.exp}", 160, 12+16*4, 0x00,0x00,0x00) if @user.respond_to? :exp and @user.exp @font.draw_blended_utf8(@contents, "经验: #{@user.exp}", 160, 12+16*4, 0x00,0x00,0x00) if @user.respond_to? :exp and @user.exp
end end
def dispose def dispose
@thread.exit @thread.exit
super super
end end
end end
This diff is collapsed.
class Room class Room
attr_accessor :pvp attr_accessor :pvp
attr_accessor :match attr_accessor :match
attr_accessor :tag attr_accessor :tag
attr_accessor :ot attr_accessor :ot
attr_accessor :lp attr_accessor :lp
attr_accessor :status attr_accessor :status
attr_accessor :server attr_accessor :server
alias pvp? pvp alias pvp? pvp
alias match? match alias match? match
alias tag? tag alias tag? tag
def lp def lp
@lp ||= 8000 @lp ||= 8000
end end
def ot def ot
@ot ||= 0 @ot ||= 0
end end
def full? def full?
$game.is_a?(Ygocore) ? (@status == :start) : player2 #不规范修正iduel房间识别问题 $game.is_a?(Ygocore) ? (@status == :start) : player2 #不规范修正iduel房间识别问题
end end
def extra def extra
result = {} result = {}
if pvp? if pvp?
result["[竞技场]"] = [255,0,0] result["[竞技场]"] = [255,0,0]
end end
if tag? if tag?
result["[TAG双打]"] = [128,0,255] result["[TAG双打]"] = [128,0,255]
elsif match? elsif match?
result["[三回决斗]"] = [0xff,0x72,0] result["[三回决斗]"] = [0xff,0x72,0]
end end
if ot == 1 if ot == 1
result["[TCG]"] = [255,0,0] result["[TCG]"] = [255,0,0]
elsif ot == 2 elsif ot == 2
result["[O/T混]"] = [255,0,0] result["[O/T混]"] = [255,0,0]
end end
if lp != 8000 if lp != 8000
result["[LP: #{lp}]"] = [255,0,0] result["[LP: #{lp}]"] = [255,0,0]
end end
result result
end end
def host_server def host_server
servers = $game.servers servers = $game.servers
servers.select!{|server|server.auth} if @pvp servers.select!{|server|server.auth} if @pvp
s = servers & $game.filter[:servers] s = servers & $game.filter[:servers]
servers = s if !s.empty? servers = s if !s.empty?
server = servers.min_by{|server|$game.rooms.select{|room|room.server == server}.size} server = servers.min_by{|server|$game.rooms.select{|room|room.server == server}.size}
p server p server
server ||= Server.new(nil, "", $game.server, $game.port, true) server ||= Server.new(nil, "", $game.server, $game.port, true)
self.server = server self.server = server
server server
end end
end end
ja: ja:
name: "日本語" name: "日本語"
\ No newline at end of file
zh-OS: zh-OS:
name: "中文(OcgSoft)" name: "中文(OcgSoft)"
\ No newline at end of file
zh-TW: zh-TW:
name: "中文(繁体)" name: "中文(繁体)"
\ No newline at end of file
en: en:
lang: "中文" lang: "中文"
chat: chat:
room: "lobby.zh" room: "lobby.zh"
server: "conference.my-card.in" server: "conference.my-card.in"
login: login:
name: "用户名" name: "用户名"
password: "密码" password: "密码"
login: "登录" login: "登录"
register: "注册" register: "注册"
remember: "记住密码" remember: "记住密码"
replay: "录像" replay: "录像"
lobby: lobby:
faq: "常见问题" faq: "常见问题"
editdeck: "卡组编辑" editdeck: "卡组编辑"
newroom: "建立房间" newroom: "建立房间"
lobby: "大厅" lobby: "大厅"
filter: "房间筛选" filter: "房间筛选"
waiting_only: "仅等待中" waiting_only: "仅等待中"
normal_only: "仅标准房" normal_only: "仅标准房"
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