Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- %Q(
- JCC - Cards Game
- =================
- Auteur: Zouzaka
- Description: Permet de réaliser un jeu de carte a collection, le principe est
- simple, defier, ganger, collectioner.
- J'ai fait en sorte de rendre le script le plus personalisable possible autant
- pour les debutant que les experimentés, un scripteur peut facilement le modifier
- j'ai canaliser toutes les information dans un seul module "JCC"
- -----------------------------
- Indexs du terrain :
- 0,4,8,12,16 ... (Magie du joueur)
- 1,5,9,13,17 ... (Monstres du joueur)
- 2,6,10,14,18 ... (Monstres de l'ennemi)
- 3,7,11,15,19 ... (Magie de l'ennemi)
- )
- module JCC_Config
- #=============================================================================
- #*Personalisation
- #=============================================================================
- #.~*~.~*~.~*~.~*~.~*~.~*~.~*~.~*~.~*~.~*~.~*~.~*~.~*~.~*~.~*~.~*~.~*~.~*~.~*~.
- #=============================================================================
- #**Default Defi Type
- # 1 => Defi Standard
- # 2 => Limité (par le nombre de tours)
- #-----------------------------------------------------------------------------
- Default_Defi = 1
- #-----------------------------------------------------------------------------
- #**Condition de Victoire
- # 1 => Nombre de PV = 0
- # 2 => Aucun Monstre sur le terrain
- #-----------------------------------------------------------------------------
- Victory_Condition = 1
- #-----------------------------------------------------------------------------
- #**Condition de Victoire
- # true => le premier qui ne peut plus piocher a perdu
- # false => meme si le deck est vide la partie continu
- #-----------------------------------------------------------------------------
- Empty_Deck_Lose = true
- #-----------------------------------------------------------------------------
- #**Pouvoir regarder les cartes magies de l'ennemi
- # true => Oui, ont peut regarder
- # false => Non, ont ne regarde pas !
- #-----------------------------------------------------------------------------
- Show_ennemy_Spell = true
- #-----------------------------------------------------------------------------
- #**Vie de depart (condition de victoire => 1)
- #-----------------------------------------------------------------------------
- Life_Start = 4000
- #-----------------------------------------------------------------------------
- #**Nombre de cartes dans la main
- #-----------------------------------------------------------------------------
- Hand_Size = 5
- #-----------------------------------------------------------------------------
- #**Nombre de Monstre sur le terrain (Max 5)
- #-----------------------------------------------------------------------------
- MonsterField_Size = 3
- #-----------------------------------------------------------------------------
- #**Nombre de Magie sur le terrain (Max 5)
- #-----------------------------------------------------------------------------
- SpellField_Size = 3
- #-----------------------------------------------------------------------------
- #**Nombre de De Tours Pour abondonner
- #-----------------------------------------------------------------------------
- Exit_Condition = 0
- #-----------------------------------------------------------------------------
- #**Limite d'invocation par tour
- #-----------------------------------------------------------------------------
- Monster_Limit = 2
- #-----------------------------------------------------------------------------
- #**Limite de Carte magie par tour
- #-----------------------------------------------------------------------------
- Spell_Limit = 3
- #-----------------------------------------------------------------------------
- #**Chance d'erreur pour l'id
- #cette valeur est un pourcentage qui reflete les chances que l'IA fasse
- #un fail (Max 100)
- #-----------------------------------------------------------------------------
- IA_Fail = 0
- #-----------------------------------------------------------------------------
- #**Nombre Max d'attaque par carte
- #-----------------------------------------------------------------------------
- Fight_Per_Card = 1
- end
- #===============================================================================
- #*Data Manager
- #===============================================================================
- #.~*~.~*~.~*~.~*~.~*~.~*~.~*~.~*~.~*~.~*~.~*~.~*~.~*~.~*~.~*~.~*~.~*~.~*~.~*~.~*
- #===============================================================================
- module DataManager
- class << self
- alias :jcc_load_normal_database :load_normal_database
- def load_normal_database
- jcc_load_normal_database
- $data_jcc = load_cards
- end
- def load_cards
- contents = {:Cards => [], :Decks => []}
- file = File.new("Data/Cards.rvdata2")
- file.lines do |line|
- contents[:Cards] << eval(line)
- end
- file = File.new("Data/Decks.rvdata2")
- file.lines do |line|
- array = []
- eval(line)[:cards].split("|").each do |item|
- array << eval(item)
- end
- contents[:Decks] << [eval(line)[:name],array]
- end
- contents
- end
- end
- end
- #===============================================================================
- #*Cache
- #===============================================================================
- #.~*~.~*~.~*~.~*~.~*~.~*~.~*~.~*~.~*~.~*~.~*~.~*~.~*~.~*~.~*~.~*~.~*~.~*~.~*~.~*
- #===============================================================================
- module Cache
- #--------------------------------------------------------------------------
- # * Get Card Graphic
- #--------------------------------------------------------------------------
- def self.card(filename)
- load_bitmap("Graphics/Cards/", filename)
- end
- end
- #===============================================================================
- #*Module JCC
- #===============================================================================
- #.~*~.~*~.~*~.~*~.~*~.~*~.~*~.~*~.~*~.~*~.~*~.~*~.~*~.~*~.~*~.~*~.~*~.~*~.~*~.~*
- #===============================================================================
- module JCC
- include JCC_Config
- @defi_type = Default_Defi
- @local_deck = []
- @is_monster = false
- def self.start_defi(deck)
- JCC.setup_defi(deck,JCC.defi_type)
- SceneManager.call(Scene_Defi)
- end
- def self.set_deck(deck_name)
- @local_deck = Array.new(JCC.get_deck_cards(deck_name))
- end
- def self.remove_card(card_id)
- @local_deck.slice!(@local_deck.index(card_id))
- end
- def self.remove_hand_card(cible,index)
- eval("@"+cible.to_s+"_hand").slice!(index)
- end
- def self.setup_defi(deck_name,type)
- @ennemy_deck = Array.new(JCC.get_deck_cards(deck_name))
- @defi_type = type
- @life = {:player => Life_Start, :ennemy => Life_Start}
- end
- def self.get_deck_cards(deck_name)
- $data_jcc[:Decks].each do |deck|
- return deck[1] if deck[0]== deck_name
- end
- end
- def self.add_life(sym,value) ; @life[sym] += value ; end
- def self.get_zone ; @zone ; end
- def self.set_zone(zone) ; @zone = zone ; end
- def self.set_defi_type(type) ; @defi_type = type ; end
- def self.set_player_hand(hand) ; @player_hand = hand ; end
- def self.set_ennemy_hand(hand) ; @ennemy_hand = hand ; end
- def self.remove_deck ; @local_deck = [] ; end
- def self.add_card(card_id) ; @local_deck << card_id ; end
- def self.get_deck ; @local_deck ; end
- def self.defi_type ; @defi_type ; end
- def self.player_hand ; @player_hand ; end
- def self.ennemy_hand ; @ennemy_hand ; end
- def self.ennemy_deck ; @ennemy_deck ; end
- def self.defi_type ; @defi_type ; end
- def self.get_life(cible) ; @life[cible] ; end
- def self.is_monster ; @is_monster ; end
- def self.set_is_monster(bool) ; @is_monster = bool ; end
- def self.wait_for(sym) ; @wait_for = sym ; end
- def self.get_wait_for ; @wait_for ; end
- end
- #===============================================================================
- #*Class Card
- #===============================================================================
- class Game_Card
- attr_reader :name
- attr_reader :force
- attr_reader :defense
- attr_reader :type
- attr_reader :cible
- attr_reader :picture
- attr_reader :card_id
- attr_accessor :fight_count
- def initialize(card_id)
- @card_id = card_id
- @name = $data_jcc[:Cards][card_id][:name]
- @force = $data_jcc[:Cards][card_id][:force]
- @defense = $data_jcc[:Cards][card_id][:defense]
- @type = $data_jcc[:Cards][card_id][:type]
- @cible = $data_jcc[:Cards][card_id][:cible]
- @picture = $data_jcc[:Cards][card_id][:picture]
- @fight_count = 0
- end
- def id ; @card_id ; end
- def add_force(new_frc)
- @force += new_frc
- end
- def add_defense(new_def)
- @defense += new_def
- end
- end
- #===============================================================================
- #.~*~.~*~.~*~.~*~.~*~.~*~.~*~.~*~.~*~.~*~.~*~.~*~.~*~.~*~.~*~.~*~.~*~.~*~.~*~.~*
- #===============================================================================
- #*Scene_Defi
- #===============================================================================
- class Scene_Defi < Scene_MenuBase
- include JCC_Config
- def start
- @victory = nil
- super
- load_data
- creat_windows
- set_window_handlers
- variables_declaration
- @info_window.set_text("Que le Duel Commence !")
- end
- def variables_declaration
- JCC.wait_for(:nil)
- JCC.set_zone(:home)
- @in_turn = :player
- @turn = 0
- @invok_in_turn = 0
- @spell_in_turn = 0
- #Fighting local variables
- @actual_card = nil
- @actual_index = 0
- @cible_card = nil
- @cible_index = 0
- end
- def load_data
- #Load Decks
- @player_deck = Array.new(JCC.get_deck)
- @ennemy_deck = Array.new(JCC.ennemy_deck)
- #Load hand cards
- JCC.set_player_hand(load_cards(:player))
- JCC.set_ennemy_hand(load_cards(:ennemy))
- end
- def load_cards(sym)
- @hand = []
- var = ("@"+sym.to_s+"_deck")
- Hand_Size.times do
- @index = rand(eval(var).size)
- @hand << eval(var)[@index]
- eval(var).slice!(@index)
- end
- return @hand
- end
- def creat_windows
- @info_window = Window_JCC_Help.new(1)
- @command_jcc = Window_Command_JCC.new(0,370)
- @window_field = JCC_Field.new(0,@info_window.height,Graphics.width,324)
- @cards_list = Window_Card_Select.new(0,@info_window.height)
- @player_life = Window_Life.new(0,0, :player)
- @ennemy_life = Window_Life.new(Graphics.width - 70,0, :ennemy)
- @action_window = Action_Card.new(@info_window.height,@cards_list.width)
- end
- def set_window_handlers
- @command_jcc.set_handler(:hand, method(:open_hand))
- @command_jcc.set_handler(:next, method(:ennemy_turn))
- @command_jcc.set_handler(:field, method(:open_field))
- @command_jcc.set_handler(:exit, method(:abondonner))
- @cards_list.set_handler(:card, method(:card_choiced))
- @action_window.set_handler(:return, method(:close_action_window))
- end
- def open_hand
- @cards_list.open
- JCC.set_zone(:hand)
- end
- def open_field
- @window_field.activate
- JCC.set_zone(:field)
- end
- def ennemy_turn
- @in_turn = :ennemy
- @invok_in_turn = 0
- @spell_in_turn = 0
- ia_play
- end
- def next_turn
- @in_turn = :player
- phase_pioche
- @turn += 1
- @command_jcc.activate
- @window_field.reset_fight_count
- @invok_in_turn = 0
- @spell_in_turn = 0
- end
- def phase_pioche
- [:ennemy,:player].each do |cible|
- deck = "@"+cible.to_s+"_deck"
- hand = "@"+cible.to_s+"_hand"
- unless eval(deck) == []
- @hand = eval("JCC."+cible.to_s+"_hand")
- @index = rand(eval(deck).size)
- @hand << eval(deck)[@index]
- eval(deck).slice!(@index)
- eval("JCC.set_"+cible.to_s+"_hand(@hand)")
- else
- if Empty_Deck_Lose
- cible == :ennemy ? @victory = true : @victory = true if @victory==nil
- end
- end
- end
- @cards_list.refresh
- end
- =begin
- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
- Cette Zone est pour la gestion de L'IA
- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
- =end
- def ia_play
- @info_window.set_text("Tour de l'adversaire")
- Monster_Limit.times{|i| phase_invocation}
- Graphics.wait(20)
- Spell_Limit.times{|i| phase_spell}
- Graphics.wait(20)
- #~ phase_activation
- Graphics.wait(20)
- #~ phase_attaque
- @info_window.set_text("Votre Tour")
- next_turn
- end
- def phase_spell
- @local = []
- JCC.ennemy_hand.each do |card_id|
- if $data_jcc[:Cards][card_id][:type] == "Spell" ; @local << card_id ; end
- end
- unless @local == []
- @best_choice = @local[0]
- @local.each do |card_id|
- @somme1 = $data_jcc[:Cards][card_id][:force].abs + $data_jcc[:Cards][card_id][:defense].abs
- @somme2 = $data_jcc[:Cards][@best_choice][:force].abs + $data_jcc[:Cards][@best_choice][:defense].abs
- @best_choice = card_id if @somme1 > @somme2
- end
- unless @spell_in_turn > Spell_Limit
- SpellField_Size.times do |placement|
- if @window_field.card_id(3 +4*placement) == nil
- JCC.remove_hand_card(:ennemy,JCC.ennemy_hand.index(@best_choice))
- @window_field.set_card(3 +4*placement,@best_choice)
- @spell_in_turn += 1
- break
- end
- end
- end
- end
- end
- def phase_invocation
- @local = []
- JCC.ennemy_hand.each do |card_id|
- if $data_jcc[:Cards][card_id][:type] == "Monstre" ; @local << card_id ; end
- end
- unless @local == []
- @best_choice = @local[0]
- @local.each do |card_id|
- @somme1 = $data_jcc[:Cards][card_id][:force] + $data_jcc[:Cards][card_id][:defense]
- @somme2 = $data_jcc[:Cards][@best_choice][:force] + $data_jcc[:Cards][@best_choice][:defense]
- @best_choice = card_id if @somme1 > @somme2
- end
- unless @invok_in_turn > Monster_Limit
- MonsterField_Size.times do |placement|
- if @window_field.card_id(2 +4*placement) == nil
- JCC.remove_hand_card(:ennemy,JCC.ennemy_hand.index(@best_choice))
- @window_field.set_card(2 +4*placement,@best_choice)
- @invok_in_turn += 1
- break
- end
- end
- end
- end
- end
- =begin
- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
- Cette Zone est pour la gestion de L'IA
- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
- =end
- def abondonner
- if @turn >= Exit_Condition
- @victory = false
- else
- @info_window.set_text("Il vous reste "+(Exit_Condition-@turn).to_s+" pour abondonner")
- @command_jcc.activate
- end
- end
- def choice_place
- @action_window.close
- @cards_list.close
- @window_field.activate
- end
- def action_atk
- unless @actual_card.fight_count >= Fight_Per_Card
- @action_window.close
- @window_field.activate
- p(@actual_card)
- @empty_placements = 0
- MonsterField_Size.times do |placement|
- if @window_field.card_id(2 +4*placement) != nil
- @empty_placements += 1
- end
- end
- if @empty_placements != 0
- JCC.wait_for(:atk_cible)
- else
- direct_dmgs
- end
- else
- @info_window.set_text("Cette Carte a deja combattu")
- @action_window.close
- end
- end
- def direct_dmgs
- if @turn == 0 ; @info_window.set_text("Action non autorisée")
- else
- @info_window.set_text("Attaque DIRECT !!!")
- if @in_turn == :player
- add_life(:ennemy, -@actual_card.force)
- else
- add_life(:player, -@actual_card.force)
- end
- end
- JCC.wait_for(:nil)
- p("cc")
- end
- def action_activate
- @action_window.close
- @window_field.activate
- @actual_card = @window_field.actual_card
- @actual_index = @window_field.index
- JCC.wait_for(:spell_cible)
- end
- def action_window_set_handler
- if JCC.is_monster
- if JCC.get_zone == :field
- @action_window.set_handler(:atk, method(:action_atk))
- @actual_card = @window_field.actual_card
- @actual_index = @window_field.index
- else
- @action_window.set_handler(:invk, method(:choice_place))
- JCC.wait_for(:invk)
- end
- else
- if JCC.get_zone == :field
- @action_window.set_handler(:activate, method(:action_activate))
- @actual_card = @window_field.actual_card
- @actual_index = @window_field.index
- else
- @action_window.set_handler(:placer, method(:choice_place))
- JCC.wait_for(:placer)
- end
- end
- end
- def open_action_card(card_id)
- if $data_jcc[:Cards][card_id][:type] == "Monstre"
- JCC.set_is_monster(true)
- else
- JCC.set_is_monster(false)
- end
- @action_window.refresh
- action_window_set_handler
- @action_window.activate
- @action_window.select(0)
- @action_window.open
- end
- def card_choiced
- if JCC.get_zone == :hand
- card_id = JCC.player_hand[@cards_list.index]
- open_action_card(card_id)
- end
- end
- def close_action_window
- @action_window.close
- JCC.wait_for(:nil)
- @actual_card = nil
- if JCC.get_zone == :field
- @window_field.activate
- else
- @cards_list.activate
- end
- end
- def add_life(sym, value)
- JCC.add_life(sym, value)
- @player_life.refresh
- @ennemy_life.refresh
- end
- def set_battle_results
- @window_field.set_fight_count(@actual_index,@actual_card.fight_count+1)
- diff = @cible_card.defense - @actual_card.force
- if diff < 0
- @window_field.delete_card(@cible_index)
- if @in_turn == :player
- add_life(:ennemy, diff)
- else
- add_life(:player, diff)
- end
- elsif diff > 0
- if @in_turn == :player
- add_life(:player, -diff)
- else
- add_life(:ennemy, -diff)
- end
- end
- end
- #===============================================================================
- #*Update
- #===============================================================================
- def update
- super
- press_c
- verify_life
- verify_victory
- press_b
- end
- def press_c
- if Input.trigger?(:C)
- if JCC.get_zone == :field
- if JCC.get_wait_for == :nil and not @window_field.card_id(@window_field.index) == nil
- if @window_field.col == 0 or @window_field.col == 1
- open_action_card(@window_field.card_id(@window_field.index))
- @window_field.deactivate
- end
- elsif JCC.get_wait_for == :atk_cible
- unless @window_field.col == 2 or @window_field.card_id(@window_field.index) == nil
- @info_window.set_text("Action non autorisée")
- else
- @cible_card = @window_field.actual_card
- @cible_index = @window_field.index
- set_battle_results
- JCC.wait_for(:nil)
- end
- elsif JCC.get_wait_for == :spell_cible
- unless @window_field.col == 2 or @window_field.col == 1 or @window_field.actual_card == nil
- @info_window.set_text("Action non autorisée")
- else
- @window_field.add_card_def(@actual_card.defense)
- @window_field.add_card_atk(@actual_card.force)
- @window_field.delete_card(@actual_index)
- JCC.wait_for(:nil)
- end
- end
- else
- if @window_field.card_id(@window_field.index) == nil
- if JCC.get_wait_for == :invk
- unless @window_field.col == 1
- Sound.play_buzzer
- @info_window.set_text("Action non autorisée")
- else
- unless @invok_in_turn == Monster_Limit
- @invok_in_turn += 1
- @info_window.set_text("Invocation réussite")
- player_place_card
- else
- @info_window.set_text("Maximum de monstre sur le terrain")
- Sound.play_buzzer
- end
- end
- elsif JCC.get_wait_for == :placer
- unless @window_field.col == 0
- @info_window.set_text("Action non autorisée")
- Sound.play_buzzer
- else
- unless @spell_in_turn == Spell_Limit
- @spell_in_turn += 1
- @info_window.set_text("Carte placée avec succès")
- player_place_card
- else
- @info_window.set_text("Maximum de magie sur le terrain")
- Sound.play_buzzer
- end
- end
- end
- else
- @info_window.set_text("Action non autorisée")
- Sound.play_buzzer
- end
- end
- end
- end
- def player_place_card
- @window_field.set_card(@window_field.index,JCC.player_hand[@cards_list.index])
- JCC.remove_hand_card(:player,@cards_list.index)
- @cards_list.refresh
- @cards_list.select(0)
- JCC.wait_for(:nil)
- @window_field.deactivate
- @cards_list.open
- @cards_list.activate
- end
- def verify_life
- @victory = false if JCC.get_life(:player) <= 0
- @victory = true if JCC.get_life(:ennemy) <= 0
- end
- def verify_victory
- if @victory
- @info_window.set_text("Victoire !!!")
- Graphics.wait(60)
- SceneManager.return
- elsif @victory == false
- @info_window.set_text("Defaite ...")
- Graphics.wait(60)
- SceneManager.return
- end
- end
- def press_b
- if Input.trigger?(:B)
- if JCC.get_zone == :hand
- if JCC.get_wait_for == :invk or JCC.get_wait_for == :placer
- JCC.wait_for(:nil)
- @cards_list.open
- @action_window.open
- @window_field.deactivate
- @action_window.activate
- elsif @action_window.open?
- close_action_window
- @cards_list.activate
- elsif not @action_window.open?
- @cards_list.close
- @command_jcc.activate
- JCC.set_zone(:home)
- end
- elsif JCC.get_zone == :field
- if JCC.get_wait_for == :atk_cible or JCC.get_wait_for == :spell_cible
- @window_field.deactivate
- @action_window.open
- @action_window.activate
- elsif @action_window.open?
- close_action_window
- elsif JCC.get_wait_for == :nil
- @window_field.deactivate
- @command_jcc.activate
- JCC.set_zone(:home)
- end
- end
- end
- end
- end
- #===============================================================================
- #.~*~.~*~.~*~.~*~.~*~.~*~.~*~.~*~.~*~.~*~.~*~.~*~.~*~.~*~.~*~.~*~.~*~.~*~.~*~.~*
- #===============================================================================
- #*Windows for Scene_Defi
- #===============================================================================
- class Window_Command_JCC < Window_HorzCommand
- def initialize(x,y)
- super(x,y)
- select(1)
- end
- def make_command_list
- add_command("Mes Cartes", :hand)
- add_command("Terrain", :field)
- add_command("Passer", :next)
- add_command("Abondonner", :exit)
- end
- def window_width ; Graphics.width ; end
- end
- #===============================================================================
- #*Window for Select Cards
- #===============================================================================
- class Window_Card_Select < Window_Command
- def initialize(x, y)
- super(x, y)
- self.openness = 0
- end
- def make_command_list
- JCC.player_hand.each{|id| add_command("#{id}", :card)}
- end
- def window_width ; 128 ; end
- def item_width ; 100 ; end
- def item_height ; 100 ; end
- def fitting_height(line_number)
- 3 * item_height + standard_padding * 2
- end
- def draw_item(index)
- bitmap = Cache.card($data_jcc[:Cards][JCC.player_hand[index]][:picture])
- rect = item_rect(index)
- contents.blt(rect.x,rect.y,bitmap,Rect.new(0, 0, 100, 100),200)
- end
- end
- #===============================================================================
- #*Window for life
- #===============================================================================
- class Window_Life < Window_Base
- def initialize(x,y, cible)
- super(x,y,70,fitting_height(1))
- @cible = cible
- refresh
- end
- def refresh
- contents.clear
- draw_text_ex(0, 0, JCC.get_life(@cible))
- end
- end
- #===============================================================================
- #*Window for JCC_Help
- #===============================================================================
- class Window_JCC_Help < Window_Base
- def initialize(line_number = 2)
- super(70, 0, Graphics.width-140, fitting_height(line_number))
- end
- def set_text(text)
- if text != @text
- @text = text
- refresh
- end
- end
- def clear ; set_text("") ; end
- def set_item(item) ; set_text(item ? item.description : "") ; end
- def refresh
- contents.clear
- draw_text_ex(4, 0, @text)
- end
- end
- #===============================================================================
- #*Window for JCC_Field
- #===============================================================================
- class JCC_Field < Window_Selectable
- include JCC_Config
- def initialize(x, y, width, height)
- super
- @card = Array.new(col_max*row_max)
- refresh
- select(0)
- end
- def item_rect(index)
- rect = Rect.new
- rect.width = item_width
- rect.height = item_height
- if (index % col_max) == 0 or (index % col_max) == 3 and not (index / col_max) >= SpellField_Size
- rect.x = index % col_max * (item_width + spacing)
- rect.y = index / col_max * item_height
- elsif (index % col_max) == 1 or (index % col_max) == 2 and not (index / col_max) >= MonsterField_Size
- rect.x = index % col_max * (item_width + spacing)
- rect.y = index / col_max * item_height
- end
- rect
- end
- def draw_all_items
- item_max.times do |i|
- if (i % col_max) == 0 or (i % col_max) == 3 and not (i / col_max) >= SpellField_Size
- draw_item(i)
- elsif (i % col_max) == 1 or (i % col_max) == 2 and not (i / col_max) >= MonsterField_Size
- draw_item(i)
- end
- end
- end
- def draw_line
- contents.fill_rect((contents.width/2)-3,0,2,contents.height,Color.new(0,0,0,255))
- end
- def col_max ; return 4 ; end
- def item_max ; col_max*row_max ; end
- def col ; index-row*col_max ; end
- def row_max
- if MonsterField_Size >= SpellField_Size
- return MonsterField_Size
- elsif MonsterField_Size <= SpellField_Size
- return SpellField_Size
- else
- return 5
- end
- end
- def item_width ; return 100 ; end
- def item_height ; return 100 ; end
- def spacing ; return 38 ; end
- def draw_item(index)
- unless @card[index] == nil
- bitmap = Cache.card($data_jcc[:Cards][@card[index].id][:picture])
- bitmap = Cache.card("Default.png") if index.modulo(4) == 3 && !Show_ennemy_Spell
- else
- bitmap = Cache.card("Clean.png")
- end
- rect = item_rect(index)
- contents.blt(rect.x,rect.y,bitmap,Rect.new(0, 0, 100, 100),200)
- end
- def refresh
- super
- draw_line
- end
- #Card Managment
- def card_id(index)
- unless @card[index] == nil ; @card[index].id
- else ; return nil
- end
- end
- def actual_card ; @card[index] ; end
- def card(index) ; @card[index] ; end
- def add_card_def(ndef) ; @card[index].add_defense(ndef) ; end
- def add_card_atk(natk) ; @card[index].add_force(natk) ; end
- def set_fight_count(index,value) ; @card[index].fight_count = value ; end
- def set_card(index,id)
- @card[index] = Game_Card.new(id)
- refresh
- end
- def delete_card(index)
- @card[index] = nil
- refresh
- end
- def reset_fight_count
- @card.each do |card|
- card.fight_count = 0 unless card == nil
- end
- end
- end
- #===============================================================================
- #*Window for Action_Card
- #===============================================================================
- class Action_Card < Window_Command
- def initialize(x, y)
- super(x, y)
- self.openness = 0
- end
- def make_command_list
- if JCC.is_monster
- add_command("Attaquer", :atk) if JCC.get_zone == :field
- add_command("Invoquer", :invk) if JCC.get_zone == :hand
- else
- add_command("Activer", :activate) if JCC.get_zone == :field
- add_command("Placer", :placer) if JCC.get_zone == :hand
- end
- add_command("Retour", :return)
- end
- def window_height ; fitting_height(2) ; end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement