Commit 57c1bb43 authored by XiaoXiaoMN's avatar XiaoXiaoMN

mac

parent cd60e054
/nbproject/
/.idea/
Thumbs.db
/fonts/
/replay/
/ygocore/
/mycard.exe
/config.yml
/log.log
/profile.log
/error-程序出错请到论坛反馈.txt
/ruby/
/pkg/
/nbproject/
/.idea/
.DS_Store
Thumbs.db
/fonts/
/replay/
/ygocore/
/mycard.exe
/config.yml
/log.log
/profile.log
/error-程序出错请到论坛反馈.txt
/ruby/
/pkg/
/Gemfile.lock
\ No newline at end of file
#encoding: UTF-8
require 'rubygems'
require 'rake'
require 'rake/clean'
require 'rubygems/package_task'
require 'rdoc/task'
#require 'rake/testtask'
Windows = RUBY_PLATFORM["mingw"] || RUBY_PLATFORM["mswin"]
#在windows上UTF-8脚本编码环境中 Dir.glob无法列出中文目录下的文件 所以自己写个递归
def list(path)
result = []
Dir.foreach(path) do |file|
next if file == "." or file == ".."
result << "#{path}/#{file}"
result.concat list(result.last) if File.directory? result.last
end rescue p $!
result
end
spec = Gem::Specification.new do |s|
s.name = 'mycard'
s.version = '1.1.3'
s.extra_rdoc_files = ['README.txt', 'LICENSE.txt']
s.summary = 'a card game platform'
s.description = s.summary
s.author = 'zh99998'
s.email = 'zh99998@gmail.com'
s.homepage = 'http://my-card.in/'
# s.executables = ['your_executable_here']
s.files = %w(LICENSE.txt README.txt replay)
%w{lib audio data locales graphics ygocore}.each{|dir|s.files.concat list(dir)}
if Windows
s.files += %w(mycard.exe) + list("ruby") + list("fonts")
else
s.files += %w(mycard.sh)
s.platform = Gem::Platform::CURRENT
end
s.require_path = "lib"
#s.bindir = "bin"
end
Gem::PackageTask.new(spec) do |p|
p.gem_spec = spec
if Windows
p.need_zip = true
p.zip_command = '7z a'
def p.zip_file
"#{package_name}-win32.7z"
end
else
p.need_tar_gz = true
end
end
Rake::RDocTask.new do |rdoc|
files =['README.txt', 'LICENSE.txt', 'lib/**/*.rb']
rdoc.rdoc_files.add(files)
rdoc.main = "README.txt" # page to start on
rdoc.title = "Mycard Docs"
rdoc.rdoc_dir = 'doc/rdoc' # rdoc output folder
rdoc.options << '--line-numbers'
end
CLOBBER.include %w(error-程序出错请到论坛反馈.txt log.log profile.log config.yml doc ygocore/pics) + list('replay') + list('ygocore/replay') + list('.').keep_if{|file|File.basename(file) == "Thumbs.db"} + list("graphics/avatars").reject{|file|File.basename(file) =~ /(?:error|loading)_(?:small|middle|large)\.png/} + list("ygocore/deck").keep_if{|file|File.basename(file) != 'sample.ydk'}
#encoding: UTF-8
require 'rubygems'
require 'rake'
require 'rake/clean'
require 'rubygems/package_task'
require 'rdoc/task'
#require 'rake/testtask'
Windows = RUBY_PLATFORM["mingw"] || RUBY_PLATFORM["mswin"]
#在windows上UTF-8脚本编码环境中 Dir.glob无法列出中文目录下的文件 所以自己写个递归
def list(path)
result = []
Dir.foreach(path) do |file|
next if file == "." or file == ".."
result << "#{path}/#{file}"
result.concat list(result.last) if File.directory? result.last
end rescue p $!
result
end
spec = Gem::Specification.new do |s|
s.name = 'mycard'
s.version = '1.1.3'
s.extra_rdoc_files = ['README.txt', 'LICENSE.txt']
s.summary = 'a card game platform'
s.description = s.summary
s.author = 'zh99998'
s.email = 'zh99998@gmail.com'
s.homepage = 'http://my-card.in/'
# s.executables = ['your_executable_here']
s.files = %w(LICENSE.txt README.txt replay)
%w{lib audio data locales graphics ygocore}.each{|dir|s.files.concat list(dir)}
if Windows
s.files += %w(mycard.exe) + list("ruby") + list("fonts")
else
s.files += %w(mycard.sh)
s.platform = Gem::Platform::CURRENT
end
s.require_path = "lib"
#s.bindir = "bin"
end
Gem::PackageTask.new(spec) do |p|
p.gem_spec = spec
if Windows
p.need_zip = true
p.zip_command = '7z a'
def p.zip_file
"#{package_name}-win32.7z"
end
else
p.need_tar_gz = true
end
end
Rake::RDocTask.new do |rdoc|
files =['README.txt', 'LICENSE.txt', 'lib/**/*.rb']
rdoc.rdoc_files.add(files)
rdoc.main = "README.txt" # page to start on
rdoc.title = "Mycard Docs"
rdoc.rdoc_dir = 'doc/rdoc' # rdoc output folder
rdoc.options << '--line-numbers'
end
CLOBBER.include %w(error-程序出错请到论坛反馈.txt log.log profile.log config.yml doc ygocore/pics) + list('replay') + list('ygocore/replay') + list('.').keep_if{|file|File.basename(file) == "Thumbs.db"} + list("graphics/avatars").reject{|file|File.basename(file) =~ /(?:error|loading)_(?:small|middle|large)\.png/} + list("ygocore/deck").keep_if{|file|File.basename(file) != 'sample.ydk'}
......@@ -7,7 +7,7 @@ class Card
@diy = {}
@count = @db.get_first_value("select COUNT(*) from `yu-gi-oh`") rescue 0
@db.results_as_hash = true
PicPath = if RUBY_PLATFORM["win"] || RUBY_PLATFORM["ming"]
PicPath = if Windows
require 'win32/registry'
ospicpath = Win32::Registry::HKEY_CURRENT_USER.open('Software\OCGSOFT\Cards'){|reg|reg['Path']} rescue ''
ospicpath.force_encoding "GBK"
......
......@@ -20,16 +20,24 @@ class ChatMessage
end
def name_color
case user.role
when :moderator
case user.affiliation
when :owner
[220,20,60]
when :admin
[148,43,226]
else
user == $game.user ? [0, 128, 0] : [0, 0, 255]
if user.id == :subject
[128,128,128]
else
user == $game.user ? [0, 128, 0] : [0, 0, 255]
end
end
end
def message_color
if name_visible?
if user.id == :subject
[128,128,128]
elsif name_visible?
[0, 0, 0]
elsif user == $game.user or ($game.room and !$game.room.include?($user) and user == $game.room.player1)
[0, 128, 0]
......
......@@ -19,7 +19,7 @@ class Game_Event
attr_reader :user
def initialize(user)
@user = user
@user = user
$game.user = @user
end
end
......@@ -42,6 +42,7 @@ class Game_Event
class AllServers < Game_Event
attr_reader :servers
def initialize(servers)
$game.servers.replace servers
end
......@@ -52,14 +53,21 @@ class Game_Event
def initialize(user)
@user = user
unless $game.users.include? @user
if @user.friend? or @user.role == :moderator
$game.users.unshift @user
#p $game.users
#$a = 2
case @user.affiliation
when :owner
if index = $game.users.find_index { |user| user.affiliation != :owner }
$game.users.insert(index, @user)
else
$game.users << @user
end
when :admin
if index = $game.users.find_index { |user| user.affiliation != :owner and user.affiliation != :admin }
$game.users.insert(index, @user)
else
$game.users << @user
end
else
$game.users << @user
end
end
end
......@@ -129,7 +137,7 @@ class Game_Event
attr_reader :room
def initialize(room)
@room = room
@room = room
$game.room = @room
end
end
......@@ -139,7 +147,7 @@ class Game_Event
attr_reader :room
def initialize(room)
@room = room
@room = room
$game.room = @room
end
end
......@@ -151,7 +159,7 @@ class Game_Event
attr_reader :user
def initialize(user)
@user = user
@user = user
$game.room.player2 = @user
end
end
......@@ -166,7 +174,7 @@ class Game_Event
def initialize(action, str=action.escape)
@action = action
@str = str
@str = str
end
end
......@@ -175,9 +183,9 @@ class Game_Event
attr_reader :title, :message, :fatal
def initialize(title, message, fatal=true)
@title = title
@title = title
@message = message
@fatal = fatal
@fatal = fatal
$log.error(@fatal ? "致命错误" : "一般错误") { "#{@title}: #{@message} #{caller}" }
end
end
......
#!/usr/bin/env ruby
begin
Windows = RUBY_PLATFORM["win"] || RUBY_PLATFORM["ming"]
Font = ['fonts/wqy-microhei.ttc', '/usr/share/fonts/wqy-microhei/wqy-microhei.ttc', '/usr/share/fonts/truetype/wqy/wqy-microhei.ttc'].find{|file|File.file? file}
Windows = RUBY_PLATFORM["mswin"] || RUBY_PLATFORM["ming"]
Font = ['fonts/wqy-microhei.ttc', '/usr/share/fonts/wqy-microhei/wqy-microhei.ttc', '/usr/share/fonts/truetype/wqy/wqy-microhei.ttc', '/Library/Fonts/Hiragino Sans GB W3.otf'].find{|file|File.file? file}
#System_Encoding = Windows ? "CP#{`chcp`.scan(/\d+$/)}" : `locale |grep LANG |awk -F '=' '{print $2}'`
Dir.glob('post_update_*.rb').sort.each { |file| load file }
......
......@@ -14,7 +14,7 @@ module Resolution
get_system_metrics = Win32API.new "User32.dll", "GetSystemMetrics", ["L"], "L"
[get_system_metrics.call(0), get_system_metrics.call(1)]
else
`xdpyinfo`.scan(/dimensions: (\d+)x(\d+) pixels/).flatten.collect { |n| n.to_i }
`xdpyinfo`.scan(/dimensions: (\d+)x(\d+) pixels/).flatten.collect { |n| n.to_i } rescue [1440, 900]
end
end
......
......@@ -17,7 +17,7 @@ class Scene_Title < Scene
@background = Surface.load(title).display_format
Surface.blit(@background,0,0,0,0,$screen,0,0)
@command_window = Window_Title.new(title["left"] ? 200 : title["right"] ? 600 : title["special"] ? 42 : 400, title["special"] ? 321 : $config['screen']['height']/2-100)
@decision_se = Mixer::Wave.load("audio/se/decision.ogg") if SDL.inited_system(INIT_AUDIO) != 0
(@decision_se = Mixer::Wave.load("audio/se/decision.ogg") if SDL.inited_system(INIT_AUDIO) != 0) rescue nil
super
end
def clear(x,y,width,height)
......@@ -25,7 +25,7 @@ class Scene_Title < Scene
end
def determine
return unless @command_window.index
Mixer.play_channel(-1,@decision_se,0) if SDL.inited_system(INIT_AUDIO) != 0
Mixer.play_channel(-1,@decision_se,0) if @decision_se
case @command_window.index
when 0
require_relative 'scene_login'
......
......@@ -2,7 +2,7 @@
require "fileutils"
require_relative 'card'
module Update
Version = '1.1.3'
Version = '1.1.5'
URL = "https://my-card.in/mycard/update.json?version=#{Version}"
class <<self
attr_reader :thumbnails, :images, :status
......
require_relative 'cacheable'
class User
attr_accessor :id, :name, :friend, :role
attr_accessor :id, :name, :friend, :affiliation
alias friend? friend
extend Cacheable
def initialize(id, name="")
......
......@@ -27,7 +27,7 @@ class Window_Chat < Window_Scrollable
if !@chat_input.value.empty?
chatmessage = ChatMessage.new($game.user, @chat_input.value, @channel)
$game.chat chatmessage
Game_Event.push Game_Event::Chat.new(chatmessage) if !$game.is_a? Ygocore
Game_Event.push Game_Event::Chat.new(chatmessage) if @channel != :lobby
true
end
end
......
......@@ -8,12 +8,12 @@ class Window_Title < Window_List
@button.set_alpha(RLEACCEL,255)
@single_height = @button.h / Button_Count
super(x,y,@button.w / 3,WLH * Button_Count - (WLH - @button.h / Button_Count))
@cursor_se = Mixer::Wave.load 'audio/se/cursor.ogg' if SDL.inited_system(INIT_AUDIO) != 0
@cursor_se = (Mixer::Wave.load 'audio/se/cursor.ogg' if SDL.inited_system(INIT_AUDIO) != 0) rescue nil
self.items = [:决斗开始, :单人模式, :卡组编成, :选项设置, :退出游戏]
end
def index=(index)
if index and @index != index
Mixer.play_channel(-1,@cursor_se,0) if SDL.inited_system(INIT_AUDIO) != 0
Mixer.play_channel(-1,@cursor_se,0) if @cursor_se
end
super
end
......
......@@ -49,6 +49,9 @@ class Ygocore < Game
Game_Event.push(Game_Event::Chat.new(ChatMessage.new(User.new(:system, 'System'), '聊天服务连接中断: ' + exception.to_s)))
end
@@im_room.add_message_callback do |m|
if m.from.resource.nil? and m.subject
Game_Event.push Game_Event::Chat.new ChatMessage.new(User.new(:subject, '主题'), m.subject, :lobby) rescue $log.error('收到聊天消息') { $! }
end
if m.from.resource and m.body
user = m.from.resource == nickname ? @user : User.new(m.from.resource.to_sym, m.from.resource)
Game_Event.push Game_Event::Chat.new ChatMessage.new(user, m.body, :lobby) rescue $log.error('收到聊天消息') { $! }
......@@ -62,7 +65,7 @@ class Ygocore < Game
end
@@im_room.add_join_callback do |m|
user = User.new m.from.resource.to_sym, m.from.resource
user.role = m.x.first_element('item').role rescue nil
user.affiliation = m.x('http://jabber.org/protocol/muc#user').first_element('item').affiliation rescue nil
Game_Event.push Game_Event::NewUser.new user
end
@@im_room.add_leave_callback do |m|
......
class User
attr_reader :certified
def initialize(id, name = "", certified = true)
@id = id
@name = name
@certified = certified
end
def set(id, name = :keep, certified = :keep)
@id = id unless id == :keep
@name = name unless name == :keep
@certified = certified unless certified == :keep
end
def color
case @role
when :moderator
[148,43,226]
else
@certified ? [0,0,0] : [128,128,128]
case @affiliation
when :owner
[220,20,60]
when :admin
[148, 43, 226]
else
@certified ? [0, 0, 0] : [128, 128, 128]
end
end
def space
if @certified
Dialog.web "https://my-card.in/users/#{CGI.escape @id.to_s}"
......@@ -25,8 +31,9 @@ class User
Widget_Msgbox.new("查看资料", "用户#{@name}没有注册", :ok => "确定")
end
end
def avatar(size = :small)
id = (@id.respond_to?(:bare) ? @id.bare : @id).to_s
id = (@id.respond_to?(:bare) ? @id.bare : @id).to_s
cache = "graphics/avatars/mycard_#{id}_#{size}.png"
result = Surface.load(cache) rescue Surface.load("graphics/avatars/loading_#{size}.png")
scene = $scene
......@@ -34,13 +41,13 @@ class User
yield result
Thread.new do
require 'cgi'
$log.info('读取头像'){"https://my-card.in/users/#{CGI.escape id.to_s}.png"}
begin
open("https://my-card.in/users/#{CGI.escape id.to_s}.png", 'rb') {|io|open(cache, 'wb') {|c|c.write io.read}}
rescue Exception => exception
$log.error('下载头像'){[exception.inspect, *exception.backtrace].join("\n").force_encoding("UTF-8")}
cache = "graphics/avatars/error_#{size}.png"
end
$log.info('读取头像') { "https://my-card.in/users/#{CGI.escape id.to_s}.png" }
begin
open("https://my-card.in/users/#{CGI.escape id.to_s}.png", 'rb') { |io| open(cache, 'wb') { |c| c.write io.read } }
rescue Exception => exception
$log.error('下载头像') { [exception.inspect, *exception.backtrace].join("\n").force_encoding("UTF-8") }
cache = "graphics/avatars/error_#{size}.png"
end
(yield Surface.load(cache) if scene == $scene) rescue nil
end
else
......
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