Commit 2342d619 authored by 神楽坂玲奈's avatar 神楽坂玲奈

放假前提交下。这个版本无法使用

parent a1087bbe
No preview for this file type
This diff was suppressed by a .gitattributes entry.
This diff was suppressed by a .gitattributes entry.
This diff was suppressed by a .gitattributes entry.
This diff was suppressed by a .gitattributes entry.
This diff was suppressed by a .gitattributes entry.
This diff was suppressed by a .gitattributes entry.
This diff was suppressed by a .gitattributes entry.
This diff was suppressed by a .gitattributes entry.
This diff was suppressed by a .gitattributes entry.
This diff was suppressed by a .gitattributes entry.
This diff was suppressed by a .gitattributes entry.
This diff was suppressed by a .gitattributes entry.
This diff was suppressed by a .gitattributes entry.
This diff was suppressed by a .gitattributes entry.
This diff was suppressed by a .gitattributes entry.
#encoding: UTF-8
class Action
CardFilter = /(<\[.*?\]\[(?:.*?)\][\s\d]*>|一张怪兽卡|一张魔\/陷卡)/.to_s
PosFilter = /((?:手卡|场上|魔陷区|怪兽区|墓地|额外牌堆|除外区|卡组顶端|\(\d+\)){1,2})/.to_s
PositionFilter = /(|攻击表示|防守表示|里侧表示|背面守备表示)/.to_s
@@id = 0
attr_reader :from_player, :msg, :id
def initialize(from_player, msg=nil)
......@@ -26,104 +23,7 @@ class Action
@@opponent_field = field
end
def run
end
def self.pos(pos)
if index = pos.index("(")
index += 1
pos[index, pos.index(")")-index].to_i
else
case pos
when "手卡"
:hand
when "场上", "魔陷区", "怪兽区"
:field
when "墓地"
:graveyard
when "额外牌堆"
:extra
when "除外区"
:removed
when "卡组顶端"
:deck
end
end
end
def self.card(card)
if index = card.rindex("[")
index += 1
Card.find(card[index, card.rindex("]")-index].to_sym)
else
Card.find(nil)
end
end
def self.position(position)
case position
when "攻击表示"
:attack
when "防守表示"
:defense
when "里侧表示", "背面守备表示"
:set
end
end
def self.parse(str)
str =~ /^\[\d+\] (.*)▊▊▊.*?$/m
from_player = false
case $1
when /^┊(.*)┊$/m
Chat.new from_player, $1
when /^※\[(.*)\]\r\n(.*)\r\n注释$/m
Note.new from_player, $2, Card.find($1.to_sym)
when /^※(.*)$/
Chat.new from_player, $1
when /^(?:(.*)\r\n){0,1}(◎|●)→(.*)$/
from_player = $2 == "◎"
msg = $1
case $3
when /^\[\d+年\d+月\d+日禁卡表\] Duel!!/
Reset.new from_player
when /(.*)抽牌/
Draw.new from_player, $1
when "开启更换卡组"
Deck.new from_player
when "更换新卡组-检查卡组中..."
Reset.new from_player
when "换SIDE……"
Side.new from_player
when /\[\d+年\d+月\d+日禁卡表\](?:<(.+)> ){0,1}先攻/
FirstToGo.new from_player, $1
when /\[\d+年\d+月\d+日禁卡表\](?:<(.+)> ){0,1}后攻/
SecondToGo.new from_player, $1
when /(.*)掷骰子,结果为 (\d+)/
Dice.new from_player, $2.to_i, $1
when /(.*)抛硬币,结果为(.+)/
Coin.new from_player, $2=="正面", $1
when /从#{PosFilter}~发动#{CardFilter}#{PosFilter}/
Activate.new from_player, pos($1), pos($3), card($2), msg
when /从#{PosFilter}~召唤#{CardFilter}#{PosFilter}/
Summon.new from_player, pos($1), pos($3), card($2), msg
when /从#{PosFilter}~特殊召唤#{CardFilter}#{PosFilter}#{PositionFilter}/
SpecialSummon.new from_player, pos($1), pos($3), card($2), msg, position($4)
when /从手卡~取#{CardFilter}盖到#{PosFilter}/
Set.new from_player, pos($2), card($1)
when /将#{CardFilter}从~#{PosFilter}~送往墓地/
SendToGraveyard.new(from_player, pos($2), card($1))
when /将#{PosFilter}#{CardFilter}从游戏中除外/
Remove.new from_player, pos($1), card($2)
when /#{CardFilter}#{PosFilter}~放回卡组顶端/
ReturnToDeck.new from_player, pos($2), card($1)
when /#{CardFilter}#{PosFilter}返回额外牌堆/
ReturnToExtra.new from_player, pos($2), card($1)
when /从#{PosFilter}#{CardFilter}加入手卡/
ReturnToHand.new from_player, pos($1), card($2)
else
p str, 1
system("pause")
end
else
p str, 2
system("pause")
end
#子类定义
end
class Reset < Action; end
class Draw < Action
......@@ -165,6 +65,13 @@ class Action
@result = result
end
end
class ChangePhase < Action
attr_reader :phase
def initialize(from_player, phase)
super(from_player)
@phase = phase
end
end
class Move < Action
attr_reader :from_pos, :to_pos, :card, :position
def initialize(from_player, from_pos, to_pos, card, msg=nil, position=:attack)
......@@ -268,4 +175,23 @@ class Action
super(from_player, from_pos, card, :opponent)
end
end
class Refresh_Field < Action
attr_reader :lp, :hand_count, :deck_count, :graveyard_count, :removed_count, :field
def initialize(from_player, msg, lp, hand_count, deck_count, graveyard_count, removed_count, field)
super(from_player, msg)
@lp = lp
@hand_count = hand_count
@deck_count = deck_count
@graveyard_count = graveyard_count
@removed_count = removed_count
@field = field
end
end
class Turn_End < Refresh_Field
attr_reader :turn
def initialize(from_player, msg, lp, hand_count, deck_count, graveyard_count, removed_count, field, turn)
super(from_player, msg, lp, hand_count, deck_count, graveyard_count, removed_count, field)
@turn = turn
end
end
end
\ No newline at end of file
......@@ -11,7 +11,7 @@ class Card
@count = @db.get_first_value("select COUNT(*) from YGODATA") rescue 0
@db.results_as_hash = true
PicPath = 'E:/game/yu-gi-oh/YGODATA/YGOPIC'
CardBack = Surface.load "graphics/field/card.png"
class << self
def find(id, order_by=nil)
case id
......@@ -21,7 +21,8 @@ class Card
row = @db.get_first_row("select * from YGODATA where name = '#{id}'")
@all[row['id'].to_i] || old_new(row)
when nil
Card.find(1)
Card.find(1).instance_eval{@image = CardBack} unless @all[1]
@all[1]
else
sql = "select * from YGODATA where " << id
sql << " order by #{order_by}" if order_by
......@@ -57,34 +58,6 @@ class Card
sql = ""
while !records.EOF
=begin 坑爹呢...多行插入居然比单行慢= =
sql << "select
#{records.Fields.Item("CardID").value},
'#{records.Fields.Item("CardPass").value}',
'#{records.Fields.Item("SCCardName").value}',
'#{records.Fields.Item("SCCardType").value}',
'#{records.Fields.Item("SCDCardType").value.empty? ? NULL : records.Fields.Item("SCDCardType").value}',
#{records.Fields.Item("CardATK").value || "NULL"},
#{records.Fields.Item("CardDef").value || "NULL"},
'#{records.Fields.Item("SCCardAttribute").value.empty? ? NULL : records.Fields.Item("SCCardAttribute").value}',
'#{records.Fields.Item("SCCardRace").value.empty? ? NULL : records.Fields.Item("SCCardRace").value}',
#{records.Fields.Item("CardStarNum").value || "NULL"},
'#{records.Fields.Item("SCCardDepict").value}',
#{case records.Fields.Item("ENCardBan").value; when "Normal"; 3; when "SubConfine"; 2; when "Confine"; 1; else; 0; end},
'#{records.Fields.Item("CardEfficeType").value}',
'#{records.Fields.Item("CardPhal").value}',
'#{records.Fields.Item("CardCamp").value.gsub("、", "\t")}',
'#{records.Fields.Item("CardISTKEN").value.zero? ? "NULL" : ("1\t" * records.Fields.Item("CardISTKEN").value).chomp("\t")}' "
records.MoveNext
unless records.EOF
if sqlite_max_compound_select % 500 == 0
sql << "; INSERT INTO YGODATA
(id,number,name,card_type,monster_type,atk,def,attribute,type,level,lore,status,stats,archettypes,mediums,tokens) "
else
sql << "union"
end
end
=end
sql << "INSERT INTO YGODATA VALUES(
#{records.Fields.Item("CardID").value},
'#{records.Fields.Item("CardPass").value}',
......@@ -105,6 +78,8 @@ class Card
);"
records.MoveNext
end
@db.execute('begin transaction')
@db.execute('DROP TABLE "main"."YGODATA";') rescue nil
@db.execute('CREATE TABLE "YGODATA" (
"id" INTEGER NOT NULL,
......@@ -125,8 +100,6 @@ class Card
"tokens" TEXT,
PRIMARY KEY ("id")
);')
open("1.txt", "w"){|f|f.write sql}
@db.execute('begin transaction')
@db.execute_batch(sql)
@db.execute('commit transaction')
......@@ -166,16 +139,14 @@ class Card
@tokens = hash['tokens'] && hash['tokens'].split("\t").collect{|token|token.to_i}
Card.cache[@id] = self
end
def image
@image ||= Surface.load "#{PicPath}/#{@id-1}.jpg"
end
def image_small
#SDL::Surface#transform_surface(bgcolor,angle,xscale,yscale,flags)
@image_small ||= image.transform_surface(0,0,54.0/image.w, 81.0/image.h,0)
end
def unknown?
@id == 1
end
end
end
\ No newline at end of file
#Card.load_from_ycff3
\ No newline at end of file
......@@ -20,15 +20,11 @@ class Iduel
@conn = TCPSocket.open(Server, Port)
@conn.set_encoding "GBK"
Thread.abort_on_exception = true
@recv = Thread.new {
while @conn
last_info = @conn.gets(RS)
recv last_info
end rescue Iduel::Event.push Event::Error.new(0)}
@recv = Thread.new { recv @conn.gets(RS) while @conn }
end
def send(head, *args)
info = "##{head.to_s(16).upcase}|#{args.join(',')}".encode("GBK") + RS
puts ">> #{info}"
puts "<< #{info}"
(@conn.write info) rescue Iduel::Event.push Event::Error.new(0)
end
def recv(info)
......@@ -74,7 +70,9 @@ class Iduel
def quit
send(11, @key, checknum("ULO", "#{@session}"))
end
class User
end
class Iduel::User
@@all = []
attr_accessor :id, :name, :level, :exp
class << self
......@@ -115,9 +113,9 @@ class Iduel
end rescue p("http://www.duelcn.com/uc_server/avatar.php?uid=#{id-100000}&size=#{size}") if block_given?
Surface.load cache rescue Surface.load "graphics/avatars/noavatar_#{size}.gif"
end
end
end
class Room
class Iduel::Room
@@all = []
attr_accessor :id, :name, :player1, :player2, :private, :color
class << self
......@@ -146,18 +144,4 @@ class Iduel
end
alias full? player2
alias private? private
end
end
__END__
$conn = Iduel.new
$conn.login "zh99997", "111111"
loop{$conn.update;sleep 0.1}
$conn.joinroom 221, "zh" unless $conn.room_id
p $conn.room_id
sleep 5
puts "-----------------END----------------"
while c = @conn.getc
print c
end
\ No newline at end of file
require_relative 'action'
class Action
CardFilter = /(<\[.*?\]\[(?:.*?)\][\s\d]*>|一张怪兽卡|一张魔\/陷卡)/.to_s
CardFilter = /(<(?:\[.*?\]\[(?:.*?)\]){0,1}[\s\d]*>|一张怪兽卡|一张魔\/陷卡)/.to_s
#FieldCardFilter = /(<>|<??>|<(?:(?:表攻|表守|里守)\|){0,1}\[.*?\]\[(?:.*?)\]){0,1}[\s\d]*>)/.to_s
PosFilter = /((?:手卡|场上|魔陷区|怪兽区|墓地|额外牌堆|除外区|卡组顶端|\(\d+\)){1,2})/.to_s
PositionFilter = /(|攻击表示|防守表示|里侧表示|背面守备表示)/.to_s
PhaseFilter = /(抽卡`阶段|准备`阶段|主`阶段1|战斗`阶段|主`阶段2|结束`阶段)/.to_s
def self.parse_pos(pos)
if index = pos.index("(")
index += 1
......@@ -32,6 +34,16 @@ class Action
Card.find(nil)
end
end
def self.parse_fieldcard(card)
case card
when "<>"
[nil, nil]
when "<??>"
[:set, Card.find(nil)]
else
[card["表守"] ? :defense : card["里守"] ? :set : :attack, parse_card(card)]
end
end
def self.parse_position(position)
case position
when "攻击表示"
......@@ -42,6 +54,22 @@ class Action
:set
end
end
def self.parse_phase(phase)
case phase
when "抽卡`阶段"
:DP
when "准备`阶段"
:SP
when "主`阶段1"
:M1
when "战斗`阶段"
:BP
when "主`阶段2"
:M2
when "结束`阶段"
:EP
end
end
def self.escape_pos(pos)
case pos
when 0..5
......@@ -85,6 +113,22 @@ class Action
end
end
end
def self.escape_phase(phase)
case phase
when :DP
"抽卡`阶段"
when :SP
"准备`阶段"
when :M1
"主`阶段1"
when :BP
"战斗`阶段"
when :M2
"主`阶段2"
when :EP
"结束`阶段"
end
end
def self.parse(str)
str =~ /^\[\d+\] (.*)▊▊▊.*?$/m
from_player = false
......@@ -95,7 +139,9 @@ class Action
Note.new from_player, $2, Card.find($1.to_sym)
when /^※(.*)$/
Chat.new from_player, $1
when /^(?:(.*)\r\n){0,1}(◎|●)→(.*)$/
when /^(◎|●)→=\[0:0:0\]==回合结束==<(\d+)>=\[0\]\r\nLP:(\d+)\r\n手卡:(\d+)\r\n卡组:(\d+)\r\n墓地:(\d+)\r\n除外:(\d+)\r\n前场:\r\n #{PosotionFilter}#{CardFilter}\r\n #{CardFilter}\r\n #{CardFilter}\r\n #{CardFilter}\r\n #{CardFilter}\r\n后场:#{CardFilter}#{CardFilter}#{CardFilter}#{CardFilter}#{CardFilter}\r\n场地|#{CardFilter}\r\n◎→\\(.*)$/
Turn_End.new($1 == "◎", $19, $3.to_i, $4.to_i, $5.to_i, $6.to_i, $7.to_i, [parse_fieldcard($18), parse_fieldcard($13), parse_fieldcard($14), parse_fieldcard($15), parse_fieldcard($16), parse_fieldcard($17), parse_fieldcard($8), parse_fieldcard($9), parse_fieldcard($10), parse_fieldcard($11), parse_fieldcard($12)], $2.to_i)
when /^(?:(.*)\r\n){0,1}(◎|●)→(.*)$/m
from_player = $2 == "◎"
msg = $1
case $3
......@@ -118,23 +164,25 @@ class Action
when /(.*)抛硬币,结果为(.+)/
Coin.new from_player, $2=="正面", $1
when /从#{PosFilter}~发动#{CardFilter}#{PosFilter}/
Activate.new from_player, pos($1), pos($3), card($2), msg
Activate.new from_player, parse_pos($1), parse_pos($3), parse_card($2), msg
when /从#{PosFilter}~召唤#{CardFilter}#{PosFilter}/
Summon.new from_player, pos($1), pos($3), card($2), msg
Summon.new from_player, parse_pos($1), parse_pos($3), parse_card($2), msg
when /从#{PosFilter}~特殊召唤#{CardFilter}#{PosFilter}#{PositionFilter}/
SpecialSummon.new from_player, pos($1), pos($3), card($2), msg, position($4)
SpecialSummon.new from_player, parse_pos($1), parse_pos($3), card($2), msg, parse_position($4)
when /从手卡~取#{CardFilter}盖到#{PosFilter}/
Set.new from_player, pos($2), card($1)
Set.new from_player, parse_pos($2), parse_card($1)
when /将#{CardFilter}从~#{PosFilter}~送往墓地/
SendToGraveyard.new(from_player, pos($2), card($1))
SendToGraveyard.new(from_player, parse_pos($2), parse_card($1))
when /将#{PosFilter}#{CardFilter}从游戏中除外/
Remove.new from_player, pos($1), card($2)
Remove.new from_player, parse_pos($1), parse_card($2)
when /#{CardFilter}#{PosFilter}~放回卡组顶端/
ReturnToDeck.new from_player, pos($2), card($1)
ReturnToDeck.new from_player, parse_pos($2), parse_card($1)
when /#{CardFilter}#{PosFilter}返回额外牌堆/
ReturnToExtra.new from_player, pos($2), card($1)
ReturnToExtra.new from_player, parse_pos($2), parse_card($1)
when /从#{PosFilter}#{CardFilter}加入手卡/
ReturnToHand.new from_player, pos($1), card($2)
ReturnToHand.new from_player, parse_pos($1), parse_card($2)
when /#{PhaseFilter}/
ChangePhase.new(from_player, parse_phase($1))
else
p str, 1
system("pause")
......@@ -150,9 +198,29 @@ class Action
"[#{@id}] ◎→[11年3月1日禁卡表]先攻"
when Reset
"[#{@id}] ◎→[11年3月1日禁卡表] Duel!!"
when ChangePhase
"[#{@id}] ◎→#{Action.escape_phase(@phase)}"
end
end
def run
$iduel.action self
$iduel.action self if @from_player
end
end
=begin
LP:8000
手卡数:5
卡组:38
墓地:0
除外:0
前场:
<>
<>
<>
<>
<>
后场:<><><><><>
场地|<无>
◎→\\
=end
\ No newline at end of file
class Iduel
Event = Class.new{@queue = []} #避开SDL::Event问题,所以没有用class Event
class Event
Iduel::Event = Class.new #避开SDL::Event问题,所以没有用class Iduel::Event::Event
class Iduel::Event
@queue = []
def self.push(event)
@queue << event
end
......@@ -9,57 +9,57 @@ class Iduel
end
def self.parse(info)
info =~ /^\$([A-Z])\|(.*)$/m
Event.push case $1
case $1
when "A"
Event::Error
Iduel::Event::Error
when "B"
Event::LOGINOK
Iduel::Event::LOGINOK
when "C"
Event::OLIF
Iduel::Event::OLIF
when "F"
Event::JOINROOMOK
Iduel::Event::JOINROOMOK
when "G"
Event::WATCHROOMSTART
Iduel::Event::WATCHROOMSTART
when "J"
Event::UMSG
Iduel::Event::Action
when "K"
Event::WMSG
Iduel::Event::WMSG
when "M"
Event::QROOMOK #TODO
Iduel::Event::QROOMOK #TODO
when "O"
Event::PCHAT
Iduel::Event::PCHAT
when "P"
Event::RMIF
Iduel::Event::RMIF
when "Q"
Event::SingleRoomInfo
Iduel::Event::SingleRoomInfo
when "R"
Event::QROOMOK #卡表
Iduel::Event::QROOMOK #卡表
else
p $1, $2
system("pause")
Event::UNKNOWN
Iduel::Event::UNKNOWN
end.new($2)
end
class LOGINOK < Event
end
class Iduel::Event::LOGINOK < Iduel::Event
attr_reader :user, :session
def initialize(info)
info = info.split(",")
#>> $B|201629,zh99997,5da9e5fa,Level-1 (总经验:183),,20101118
info[3] =~ /Level-(\d)+ \(总经验:(\d+)\)/
$iduel.user = @user = User.new(info[0].to_i, info[1], $1.to_i, $2.to_i)
$iduel.user = @user = Iduel::User.new(info[0].to_i, info[1], $1.to_i, $2.to_i)
$iduel.session = @session = info[2]
$iduel.key = ($iduel.user.id - 0x186a0) ^ 0x22133
end
end
class OLIF < Event
end
class Iduel::Event::OLIF < Iduel::Event
attr_reader :users
def initialize(info)
@users = info.split(',').collect do |user|
Iduel::User.new(user)
end
end
end
class RMIF < Event
end
class Iduel::Event::RMIF < Iduel::Event
attr_reader :rooms
def initialize(info)
info = info.split("|")
......@@ -81,62 +81,63 @@ class Iduel
end
@rooms = templist + @rooms
end
end
class NOL < Event
end
class Iduel::Event::NOL < Iduel::Event
def initialize(info)
super
@args = @args.collect do |user|
Iduel::User.new(user)
end
end
end
class DOL < Event
end
class Iduel::Event::DOL < Iduel::Event
def initialize(info)
super
@args = @args.collect do |user|
Iduel::User.new(user)
end
end
end
class PCHAT < Event
end
class Iduel::Event::PCHAT < Iduel::Event
attr_reader :user, :content
def initialize(info)
user, @content = info.split(",", 2)
@user = Iduel::User.new user
end
end
class JOINROOMOK < Event
end
class Iduel::Event::JOINROOMOK < Iduel::Event
attr_reader :room
def initialize(id)
@room = Iduel::Room.new(id)
end
end
class QROOMOK < Event
end
class SingleRoomInfo < Event
end
class Iduel::Event::QROOMOK < Iduel::Event
end
class Iduel::Event::SingleRoomInfo < Iduel::Event
def initialize(info)
id, x, player1, player2 = info.split(",", 4)
@room = Room.new(id)
@room.player1 = User.new(player1)
@room.player2 = User.new(player2)
end
@room = Iduel::Room.new(id)
@room.player1 = Iduel::User.new(player1)
@room.player2 = Iduel::User.new(player2)
end
#"Q"
#"273,1,zh99998(201448),zh99997(201629)"
class WATCHROOMSTART < Event
end
#"Q"
#"273,1,zh99998(201448),zh99997(201629)"
class Iduel::Event::WATCHROOMSTART < Iduel::Event
def initialize(info)
id, name = info.split(",", 1)
@room = Iduel::Room.new(id.to_i, name, '', '', false, Color[0])#:name, :player1, :player2, :crypted, :color
end
@room = Iduel::Room.new(id.to_i, name, '', '', false, Iduel::Color[0])#:name, :player1, :player2, :crypted, :color
end
class UMSG < Event
end
class Iduel::Event::Action < Iduel::Event
attr_reader :action
def initialize(info)
@action = Action.parse info
info["◎"] = "●" if info =~ /^\[\d+\] (?:.*\r\n){0,1}(◎)→.*▊▊▊.*$/
@action = ::Action.parse info
p @action
end
end
class WMSG < Event
end
class Iduel::Event::WMSG < Iduel::Event
def initialize(info)
#black_st(212671), [109] ┊墓地,苍岩┊
#p info
......@@ -145,10 +146,10 @@ class Iduel
info =~ /(.+)\((\d+)\), \[(\d+)\] (.*)/m #cchenwor(211650), [27] ◎→<[效果怪兽][盟军·次世代鸟人] 1400 400>攻击8
@args = [$1, $2, $3, $4]
end
end
class WATCHSTOP < Event
end
class Error < Event
end
class Iduel::Event::WATCHSTOP < Iduel::Event
end
class Iduel::Event::Error < Iduel::Event
def initialize(info)
@title, @message = case info.to_i
when 0x00
......@@ -189,11 +190,11 @@ class Iduel
puts @message.encode! "GBK"
#system("pause")
end
end
class UNKNOWN < Event
end
class Iduel::Event::UNKNOWN < Iduel::Event
def initialize(*args)
#puts "Unknown Server Return:#{@last_info}:#{args.inspect}"
end
end
puts '--------UnKnown Iduel Event-------'
p $1, $2, args
system("pause")
end
end
\ No newline at end of file
......@@ -15,9 +15,9 @@ require 'yaml'
$config = YAML.load_file("config.yml") rescue YAML.load_file("data/config_default.yml")
SDL.init(INIT_VIDEO | INIT_AUDIO)
WM::set_caption("iDuel - 享受决斗", "graphics/system/icon.ico")
WM::set_caption("iDuel - 享受决斗", "graphics/system/iDuelPanel_32512.ico")
WM::icon = Surface.load("graphics/system/icon.ico")
WM::icon = Surface.load("graphics/system/iDuelPanel_32512.ico")
style = HWSURFACE
style |= FULLSCREEN if $config["fullscreen"]
$screen = Screen.open($config["width"], $config["height"], 0, style)
......
......@@ -22,7 +22,7 @@ class Scene_Duel < Scene
$iduel.upinfo
@bgm = Mixer::Music.load "audio/bgm/title.ogg"
Mixer.fade_in_music(@bgm, 8000, -1)
@background = Surface.load "graphics/frm/frmmain.png"
@background = Surface.load "graphics/field/main.png"
Surface.blit(@background, 0, 0, 0, 0, $screen, 0, 0)
@player1_lp = Window_LP.new(0,0, @room.player1, true)
......@@ -31,24 +31,23 @@ class Scene_Duel < Scene
@phases_window = Window_Phases.new(124, 357)
@turn_player = true
@player = Game_Field.new(Deck.load("test1.TXT"))
@opponent = Game_Field.new
@player_field = Game_Field.new(Deck.load("test1.TXT"))
@opponent_field = Game_Field.new
@player_field_window = Window_Field.new(4, 398, @player)
Action.player_field = @player
Action.opponent_field = @opponent
@player_field_window = Window_Field.new(4, 398, @player_field, true)
@opponent_field_window = Window_Field.new(4, 60, @opponent_field, false)
Action.player_field = @player_field
Action.opponent_field = @opponent_field
$screen.update_rect(0,0,0,0)
post_start
end
def post_start
first_to_go
end
def change_phase(phase)
if phase == 5
@turn_player = !@turn_player
@phase = 0
@phases_window.player = @turn_player
Action::Turn_End.new(field)
else
@phase = @phases_window.phase = phase
@phases_window.refresh
......@@ -100,6 +99,7 @@ class Scene_Duel < Scene
when Iduel::Event::Action
event.action.run
@player_field_window.refresh
@opponent_field_window.refresh
end
end
def update
......@@ -109,9 +109,8 @@ class Scene_Duel < Scene
end
end
def refresh_rect(x, y, width, height)
return unless $scene = self #线程的情况
p @background,$screen
Surface.blit(@background,x,y,width,height,$screen,x,y)
return unless $scene == self #线程的情况
Surface.blit(@background,x,y,width,height,$screen,x,y) rescue p "------奇怪的nil错误----", @background,x,y,width,height,$screen,x,y
yield
$screen.update_rect(x, y, width, height)
end
......
......@@ -47,12 +47,12 @@ class Scene_Hall < Scene
when Key::RETURN
@active_window.clicked
when Key::F5
if @roomlist and room = @roomlist.list.find{|room|room.player1 == $iduel.user or room.player2 == $iduel.user}
if @roomlist.list and room = @roomlist.list.find{|room|room.player1 == $iduel.user or room.player2 == $iduel.user}
$iduel.qroom room
end
$iduel.upinfo
when Key::F12
if @roomlist and room = @roomlist.list.find{|room|room.player1 == $iduel.user or room.player2 == $iduel.user}
if @roomlist.list and room = @roomlist.list.find{|room|room.player1 == $iduel.user or room.player2 == $iduel.user}
$iduel.qroom room
end
$iduel.close
......@@ -95,6 +95,7 @@ class Scene_Hall < Scene
require_relative 'scene_watch'
$scene = Scene_Watch.new(event.room)
else
puts "---unhandled iduel event----"
p event
end
end
......@@ -123,80 +124,3 @@ class Scene_Hall < Scene
end
end
\ No newline at end of file
__END__
def a
@count = 0
Iduel::Event::NOL.callback do |event|
@playerlist.list += event.args
end
Iduel::Event::DOL.callback do |event|
@playerlist.list -= event.args
end
Iduel::Event::RMIF.callback do |event|
@roomlist.list = event.args
end
Iduel::Event::JOINROOMOK.callback do |event|
$graphics.scene = Scene_Duel.new(event.room)
end
Iduel::Event::QROOMOK.callback do |event|
$iduel.upinfo
end
Iduel::Event::WATCHROOMSTART.callback do |event|
$graphics.scene = Scene_Watch.new(event.room)
end
Iduel::Event::PCHAT.callback do |event|
@chat.add(event.user, event.content)
end
MouseClickEvent.callback do |event|
case
when event.x.between?(@roomlist.x, @roomlist.x + @roomlist.width) && event.y.between?(@roomlist.y, @roomlist.y + @roomlist.height)
#房间列表
case event.key
when :left
room = @roomlist.list[(event.y - @roomlist.y) / 48]
if room
if room.full?
$iduel.watch room
else
$iduel.join room, "zh"
end
end
when :right
room = @roomlist.list[(event.y - @roomlist.y) / 48]
if room
$iduel.qroom(room)
$iduel.upinfo
end
when :scroll_up
when :scroll_down
end
end
end
#$iduel.join("test", "123")
#@x = Window.new(0,500,100,500)
#@x = Sprite.new( Image.from_text "0000" )
#@x.contents[0].fill Color::Blue
#@x.show
#$iduel.upinfo
#$iduel.quitwatchroom
#$iduel.joinroom Iduel::Room.new(1679,'','','','','',''), '123'
end
# def update
#@x.contents[0].fill Color::Blue
#@x.contents[0].clear
#@x.contents[0].draw_text(rand(10000).to_s)
# if @count >= 600
# $iduel.upinfo
# @count = 0
# end
# @count += 1
#end
end
......@@ -34,7 +34,7 @@ class Scene_Title < Scene
end
when Event::MouseButtonDown
case event.button
when SDL::Mouse::BUTTON_LEFT
when Mouse::BUTTON_LEFT
if @command_window.include?(event.x, event.y)
@command_window.click((event.y - @command_window.y) / @command_window.class::Button_Height)
end
......@@ -45,7 +45,7 @@ class Scene_Title < Scene
end
when Event::MouseButtonUp
case event.button
when SDL::Mouse::BUTTON_LEFT
when Mouse::BUTTON_LEFT
if @command_window.include?(event.x, event.y)
@command_window.index = (event.y - @command_window.y) / @command_window.class::Button_Height
determine
......
......@@ -12,20 +12,26 @@ class Window_Field
Graveyard_Pos = [598,0] #墓地
Removed_Pos = [657,0] #除外区
Hand_Pos = [0, 201, 62, 8] #手卡: x, y, width, 间距
def initialize(x, y, field)
def initialize(x, y, field,player=true)
@x = x
@y = y
@width = 711
@height = 281
@height = 282
@field = field
@player = player
refresh
end
def refresh
$scene.refresh_rect(@x,@y,@width,@height) do
@field.field.each_with_index {|card, index|Surface.blit(card.image_small, 0,0,0,0, $screen, @x+Field_Pos[index][0], @y+Field_Pos[index][1]) if card}
hand_width = @field.hand.size * Hand_Pos[2] + (@field.hand.size-1) * Hand_Pos[3]
hand_x = (@width - hand_width) / 2
$scene.refresh_rect(@x,@y,@width,@height) do
if @player
@field.field.each_with_index {|card, index|Surface.blit(card.image_small, 0,0,0,0, $screen, @x+Field_Pos[index][0], @y+Field_Pos[index][1]) if card}
@field.hand.each_with_index {|card, index|Surface.blit(card.image_small, 0,0,0,0, $screen, @x+hand_x+index*Hand_Pos[2], @y+Hand_Pos[1]) if card}
else
@field.field.each_with_index {|card, index|Surface.transform_blit(card.image_small, $screen, 180, 1, 1, 0, 0, @x+@width-Field_Pos[index][0], @y+@height-Field_Pos[index][1],0) if card}
@field.hand.each_with_index {|card, index|Surface.blit(card.image_small, 0,0,0,0, $screen, @x+@width-hand_x-index*Hand_Pos[2]-card.image_small.w, @y+@height-Hand_Pos[1]-card.image_small.h) if card}
end
end
end
end
\ No newline at end of file
......@@ -34,7 +34,6 @@ class Window_List
end
def refresh
$scene.refresh_rect(@x, @y, @width, @height) do
p @x, @y, @width, @height
@item_max.times do |index|
draw_item(index)
end
......
......@@ -22,7 +22,7 @@ class Window_Title
$screen.update_rect(@x, @y+Button_Height*@index, @width, @single_height)
end
if index
SDL::Mixer.play_channel(-1,@cursor_se,0)
Mixer.play_channel(-1,@cursor_se,0)
$scene.clear(@x, @y+Button_Height*index, @width, @single_height)
Surface.blit(@button, @width,@single_height*index,@width,@single_height,$screen, @x, @y + Button_Height*index)
$screen.update_rect(@x, @y+Button_Height*index, @width, @single_height)
......
#<SDL::Event::Active:0x2b134f0 @gain=false, @state=1>
#<SDL::Event::Active:0x2b13310 @gain=false, @state=2>
#<SDL::Event::Active:0x2b131c0 @gain=true, @state=1>
#<SDL::Event::Active:0x2b13040 @gain=false, @state=1>
#<SDL::Event::Active:0x2b12ed8 @gain=true, @state=6>
#<SDL::Event::Active:0x2b12d70 @gain=true, @state=1>
#<SDL::Event::Active:0x2b127b8 @gain=false, @state=1>
#<SDL::Event::Active:0x2b12668 @gain=true, @state=1>
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