Commit 7b2a9fed authored by zh99998's avatar zh99998

换行 readme

parent 5a87a77c
# Auto detect text files and perform LF normalization
* text=auto
# Custom for Visual Studio
*.cs diff=csharp
*.sln merge=union
*.csproj merge=union
*.vbproj merge=union
*.fsproj merge=union
*.dbproj merge=union
# Standard to msysgit
*.doc diff=astextplain
*.DOC diff=astextplain
*.docx diff=astextplain
*.DOCX diff=astextplain
*.dot diff=astextplain
*.DOT diff=astextplain
*.pdf diff=astextplain
*.PDF diff=astextplain
*.rtf diff=astextplain
*.RTF diff=astextplain
== mycard
这是一个游戏王对战器,与iDuel、ygocore协议兼容
目前开发进度约60%,iDuel实现了观战、播放Replay和几个简单的战斗指令,ygocore的大厅
目前开发进度约70%,iDuel实现了观战、播放Replay和几个简单的战斗指令,ygocore的对战平台
快捷键:
F12 返回标题画面
......@@ -15,7 +15,7 @@ A: 请注意mycard左上角是否在自动更新,如果显示正在下载更
Q: 程序崩溃或无任何提示自动退出 或提示 【程序可能出现了一个bug,请到论坛反馈】
A: 重试一次。如果仍然这样 请联系作者
作者联系方式:
1. mycard的论坛(http://card.touhou.cc/boards)留言。
2. E-mail/QQ/GT: zh99998@gmail.com
3. 在iduel社区或nwbbs的mycard发布帖回复
\ No newline at end of file
1. mycard的论坛 http://card.touhou.cc/boards
2. E-mail/QQ/GT: zh99998@gmail.com
\ No newline at end of file
#encoding: UTF-8
#==============================================================================
# ■ Scene_Title
#------------------------------------------------------------------------------
#  title
#==============================================================================
class Deck
attr_accessor :main
attr_accessor :side
attr_accessor :extra
attr_accessor :temp
#DeckPath = '/media/44CACC1DCACC0D5C/game/yu-gi-oh/deck'
DeckPath = 'E:/game/yu-gi-oh/deck'
def initialize(main, side=[], extra=[], temp=[])
@main = main
@side = side
@extra = extra
@temp = temp
end
def self.load(name)
main = []
side = []
extra = []
temp = []
now = main
open(File.expand_path(name, DeckPath)) do |file|
file.set_encoding "GBK", "UTF-8", :invalid => :replace, :undef => :replace
while line = file.readline.chomp!
case line
when /^\[(.+?)\](?:\#.*\#)?$/
now << Card.find($1.to_sym)
when "####"
now = side
when "===="
now = extra
when "$$$$"
now = temp
end
break if file.eof?
end
end
self.new(main, side, extra, temp)
end
end
#encoding: UTF-8
#==============================================================================
# ■ Scene_Title
#------------------------------------------------------------------------------
#  title
#==============================================================================
class Deck
attr_accessor :main
attr_accessor :side
attr_accessor :extra
attr_accessor :temp
#DeckPath = '/media/44CACC1DCACC0D5C/game/yu-gi-oh/deck'
DeckPath = 'E:/game/yu-gi-oh/deck'
def initialize(main, side=[], extra=[], temp=[])
@main = main
@side = side
@extra = extra
@temp = temp
end
def self.load(name)
main = []
side = []
extra = []
temp = []
now = main
open(File.expand_path(name, DeckPath)) do |file|
file.set_encoding "GBK", "UTF-8", :invalid => :replace, :undef => :replace
while line = file.readline.chomp!
case line
when /^\[(.+?)\](?:\#.*\#)?$/
now << Card.find($1.to_sym)
when "####"
now = side
when "===="
now = extra
when "$$$$"
now = temp
end
break if file.eof?
end
end
self.new(main, side, extra, temp)
end
end
require_relative 'game'
require_relative 'user'
require_relative 'room'
require_relative 'ygocore/game'
$game = Ygocore.new
uri = URI.unescape URI.unescape ARGV.first[9, ARGV.first.size-9]
case uri
when /^(.*\.yrp)$/
require 'open-uri'
open("http://"+ URI.escape($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://" + URI.escape($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)
when /^(?:(.*)\:(.*)\@)?(.*)\:(\d+)\/(.*)$/
require 'uri'
$game.user = User.new($1.to_sym, $1) if $1
$game.password = $2 if $2
$game.server = $3
$game.port = $4.to_i
Ygocore.run_ygocore Room.new(0, $5), true
require_relative 'game'
require_relative 'user'
require_relative 'room'
require_relative 'ygocore/game'
$game = Ygocore.new
uri = URI.unescape URI.unescape ARGV.first[9, ARGV.first.size-9]
case uri
when /^(.*\.yrp)$/
require 'open-uri'
open("http://"+ URI.escape($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://" + URI.escape($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)
when /^(?:(.*)\:(.*)\@)?(.*)\:(\d+)\/(.*)$/
require 'uri'
$game.user = User.new($1.to_sym, $1) if $1
$game.password = $2 if $2
$game.server = $3
$game.port = $4.to_i
Ygocore.run_ygocore Room.new(0, $5), true
end
\ No newline at end of file
#encoding: UTF-8
#==============================================================================
# ■ Scene_Config
#------------------------------------------------------------------------------
#  config
#==============================================================================
class Scene_Config < Scene
require_relative 'window_config'
BGM = 'title.ogg'
def start
@background = Surface.load("graphics/config/background.png").display_format
@config_window = Window_Config.new(0,0)
super
end
def handle(event)
case event
when Event::MouseMotion
self.windows.reverse.each do |window|
if window.include? event.x, event.y
@active_window = window
@active_window.mousemoved(event.x, event.y)
break
end
end
when Event::MouseButtonDown
case event.button
when Mouse::BUTTON_LEFT
@active_window.mousemoved(event.x, event.y)
@active_window.clicked
when 4
@active_window.cursor_up
when 5
@active_window.cursor_down
end
else
super
end
end
#encoding: UTF-8
#==============================================================================
# ■ Scene_Config
#------------------------------------------------------------------------------
#  config
#==============================================================================
class Scene_Config < Scene
require_relative 'window_config'
BGM = 'title.ogg'
def start
@background = Surface.load("graphics/config/background.png").display_format
@config_window = Window_Config.new(0,0)
super
end
def handle(event)
case event
when Event::MouseMotion
self.windows.reverse.each do |window|
if window.include? event.x, event.y
@active_window = window
@active_window.mousemoved(event.x, event.y)
break
end
end
when Event::MouseButtonDown
case event.button
when Mouse::BUTTON_LEFT
@active_window.mousemoved(event.x, event.y)
@active_window.clicked
when 4
@active_window.cursor_up
when 5
@active_window.cursor_down
end
else
super
end
end
end
\ No newline at end of file
#encoding: UTF-8
#==============================================================================
# ■ Scene_Title
#------------------------------------------------------------------------------
#  title
#==============================================================================
class Scene_Deck < Scene
def start
@deck_window = Window.new(600,0,400,800)
loaddeck
@deck_window.contents.blt(@deck.main.first.pic, 200, 0)
@deck.main.each_with_index do |card, index|
@deck_window.contents.draw_text(0, index*24, card.name)
end
super
end
def loaddeck(file='/media/本地磁盘/zh99998/yu-gi-oh/token.txt')
src = IO.read(file)
src.force_encoding "GBK"
src.encode! 'UTF-8'
cards = {:main => [], :side => [], :extra => [], :temp => []}
now = :main
src.each_line do |line|
if line =~ /\[(.+)\]##(.*)\r\n/
cards[now] << Card.find($1.to_sym)
elsif line['####']
now = :side
elsif line['====']
now = :extra
elsif line['$$$$']
now = :temp
end
end
@deck = Deck.new(cards[:main], cards[:side], cards[:extra], cards[:temp])
end
def update
end
end
#encoding: UTF-8
#==============================================================================
# ■ Scene_Title
#------------------------------------------------------------------------------
#  title
#==============================================================================
class Scene_Deck < Scene
def start
@deck_window = Window.new(600,0,400,800)
loaddeck
@deck_window.contents.blt(@deck.main.first.pic, 200, 0)
@deck.main.each_with_index do |card, index|
@deck_window.contents.draw_text(0, index*24, card.name)
end
super
end
def loaddeck(file='/media/本地磁盘/zh99998/yu-gi-oh/token.txt')
src = IO.read(file)
src.force_encoding "GBK"
src.encode! 'UTF-8'
cards = {:main => [], :side => [], :extra => [], :temp => []}
now = :main
src.each_line do |line|
if line =~ /\[(.+)\]##(.*)\r\n/
cards[now] << Card.find($1.to_sym)
elsif line['####']
now = :side
elsif line['====']
now = :extra
elsif line['$$$$']
now = :temp
end
end
@deck = Deck.new(cards[:main], cards[:side], cards[:extra], cards[:temp])
end
def update
end
end
#encoding: UTF-8
#==============================================================================
# ■ Scene_Login
#------------------------------------------------------------------------------
#  login
#==============================================================================
require_relative 'window_gameselect'
require_relative 'window_announcements'
require_relative 'window_login'
require_relative 'scene_replay'
require_relative 'scene_lobby'
class Scene_Login < Scene
def start
WM::set_caption("MyCard v#{Update::Version}", "MyCard")
@background = Surface.load("graphics/login/background.png").display_format
@gameselect_window = Window_GameSelect.new(117,269)
super
end
def update
@gameselect_window.update
super
end
def handle_game(event)
case event
when Game_Event::Login
require_relative 'scene_lobby'
$scene = Scene_Lobby.new
else
super
end
end
#def terminate
# @gameselect_window.destroy
#end
#encoding: UTF-8
#==============================================================================
# ■ Scene_Login
#------------------------------------------------------------------------------
#  login
#==============================================================================
require_relative 'window_gameselect'
require_relative 'window_announcements'
require_relative 'window_login'
require_relative 'scene_replay'
require_relative 'scene_lobby'
class Scene_Login < Scene
def start
WM::set_caption("MyCard v#{Update::Version}", "MyCard")
@background = Surface.load("graphics/login/background.png").display_format
@gameselect_window = Window_GameSelect.new(117,269)
super
end
def update
@gameselect_window.update
super
end
def handle_game(event)
case event
when Game_Event::Login
require_relative 'scene_lobby'
$scene = Scene_Lobby.new
else
super
end
end
#def terminate
# @gameselect_window.destroy
#end
end
\ No newline at end of file
#==============================================================================
# ■ Scene_Title
#------------------------------------------------------------------------------
#  title
#==============================================================================
require_relative 'window_user'
require_relative 'window_scrollable'
class Window_UserList < Window_Scrollable
attr_reader :x, :y, :width, :height
WLH = 20
def initialize(x, y, items)
#@contents = Surface.load "graphics/lobby/useritems.png"
#@background = Surface.load "graphics/lobby/useritems.png"
super(x,y,272,540)
@font = TTF.open("fonts/wqy-microhei.ttc", 16)
@color = [0x03, 0x11, 0x22]
@color_friend = [0, 128, 0]
@color_over = [200,200,255]
@color_click = [0x03, 0x11, 0x22]
#@contents.set_alpha(RLEACCEL, 80)
@contents.fill_rect(0,0,@width,@height,0xFFFFFFFF)
self.items = items
end
def draw_item(index, status=0)
case status
when 0
@font.draw_blended_utf8(@contents, @items[index].name, 0, item_rect(index)[1], *@items[index].color)
when 1
@font.draw_shaded_utf8(@contents, @items[index].name, 0, item_rect(index)[1], *(@items[index].color+@color_over))
when 2
@font.draw_shaded_utf8(@contents, @items[index].name, 0, item_rect(index)[1], *(@items[index].color+@color_click))
end
end
def clicked
return unless @index
@userwindow = Window_User.new(100,100,@items[@index])
end
def mousemoved(x,y)
return unless include?(x,y)
self.index = (y - @y) / WLH + @scroll
end
#==============================================================================
# ■ Scene_Title
#------------------------------------------------------------------------------
#  title
#==============================================================================
require_relative 'window_user'
require_relative 'window_scrollable'
class Window_UserList < Window_Scrollable
attr_reader :x, :y, :width, :height
WLH = 20
def initialize(x, y, items)
#@contents = Surface.load "graphics/lobby/useritems.png"
#@background = Surface.load "graphics/lobby/useritems.png"
super(x,y,272,540)
@font = TTF.open("fonts/wqy-microhei.ttc", 16)
@color = [0x03, 0x11, 0x22]
@color_friend = [0, 128, 0]
@color_over = [200,200,255]
@color_click = [0x03, 0x11, 0x22]
#@contents.set_alpha(RLEACCEL, 80)
@contents.fill_rect(0,0,@width,@height,0xFFFFFFFF)
self.items = items
end
def draw_item(index, status=0)
case status
when 0
@font.draw_blended_utf8(@contents, @items[index].name, 0, item_rect(index)[1], *@items[index].color)
when 1
@font.draw_shaded_utf8(@contents, @items[index].name, 0, item_rect(index)[1], *(@items[index].color+@color_over))
when 2
@font.draw_shaded_utf8(@contents, @items[index].name, 0, item_rect(index)[1], *(@items[index].color+@color_click))
end
end
def clicked
return unless @index
@userwindow = Window_User.new(100,100,@items[@index])
end
def mousemoved(x,y)
return unless include?(x,y)
self.index = (y - @y) / WLH + @scroll
end
end
\ No newline at end of file
class Game_Event
def self.parse(header, data)
case header
when :login
if data
Login.new parse_user data
else
Error.new('登录', '用户名或密码错误')
end
when :users
AllUsers.new data.collect{|user|parse_user(user)}
when :rooms
rooms_wait = []
rooms_start = []
data.each do |room|
room = parse_room(room)
if room.full?
rooms_start << room
else
rooms_wait << room
end
end
AllRooms.new rooms_wait + rooms_start
when :newuser
NewUser.new parse_user data
when :missinguser
MissingUser.new parse_user data
when :newroom
NewRoom.new parse_room data
when :missingroom
MissingRoom.new parse_room data
when :chat
case data[:channel]
when :lobby
Chat.new ChatMessage.new User.new(data[:from][:id],data[:from][:name]), data[:message], :lobby
else
Chat.new ChatMessage.new User.new(data[:from][:id],data[:from][:name]), data[:message], User.new(data[:channel])
end
end
end
def self.parse_room(room)
result = Room.new(room[:id], room[:name])
result.player1 = room[:player1] && parse_user(room[:player1])
result.player2 = room[:player2] && parse_user(room[:player2])
result.private = room[:private]
result.pvp = room[:pvp]
result.match = room[:match]
result.tag = room[:tag]
result.ot = room[:ot]
result.status = room[:status]
result.lp = room[:lp]
result
end
def self.parse_user(user)
User.new(user[:id], user[:name], user[:certified])
end
end
class Game_Event
def self.parse(header, data)
case header
when :login
if data
Login.new parse_user data
else
Error.new('登录', '用户名或密码错误')
end
when :users
AllUsers.new data.collect{|user|parse_user(user)}
when :rooms
rooms_wait = []
rooms_start = []
data.each do |room|
room = parse_room(room)
if room.full?
rooms_start << room
else
rooms_wait << room
end
end
AllRooms.new rooms_wait + rooms_start
when :newuser
NewUser.new parse_user data
when :missinguser
MissingUser.new parse_user data
when :newroom
NewRoom.new parse_room data
when :missingroom
MissingRoom.new parse_room data
when :chat
case data[:channel]
when :lobby
Chat.new ChatMessage.new User.new(data[:from][:id],data[:from][:name]), data[:message], :lobby
else
Chat.new ChatMessage.new User.new(data[:from][:id],data[:from][:name]), data[:message], User.new(data[:channel])
end
end
end
def self.parse_room(room)
result = Room.new(room[:id], room[:name])
result.player1 = room[:player1] && parse_user(room[:player1])
result.player2 = room[:player2] && parse_user(room[:player2])
result.private = room[:private]
result.pvp = room[:pvp]
result.match = room[:match]
result.tag = room[:tag]
result.ot = room[:ot]
result.status = room[:status]
result.lp = room[:lp]
result
end
def self.parse_user(user)
User.new(user[:id], user[:name], user[:certified])
end
end
register: http://card.touhou.cc/register
api: http://122.0.65.71:7922/
index: http://card.touhou.cc/
server: 122.0.65.71
register: http://card.touhou.cc/register
api: http://122.0.65.71:7922/
index: http://card.touhou.cc/
server: 122.0.65.71
port: 7911
\ No newline at end of file
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