Advertisement
PencilCase27

CardGame Script v1.04

Sep 22nd, 2014
487
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 68.68 KB | None | 0 0
  1. #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  2. #                           CARDGAME SKILL/BATTLE SYSTEM
  3. #                               Author: pencilcase27
  4. #                               Version:       v1.04
  5. #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  6. # v1.00 - Script released
  7. # v1.01 - Added stack, skills now can't revive themself.
  8. #       - Added CardHelp_Window, normal help window is no longer used to draw cards
  9. #       - Item Window is back to normal
  10. # v1.02 - reworked card effects
  11. #       - added deck count and toggle actor to deck build scene
  12. #       - simplified scriptcalls to add and remove cards from collection
  13. #       - Added max_card limit exception
  14. # v1.03 - reworked card effects (again)
  15. #       - added card cost effects
  16. #       - added custom images
  17. # v1.04 - added more script calls
  18. #       - changed card costs slightly
  19. #       - bugfixes
  20. #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  21. #
  22. #                                  Description
  23. #
  24. # This script changes the way actors aquire and use skills. Instead of each
  25. # actor having an own set of skills, the party now has a card collection of
  26. # different cards, each card representing a skill. Out of this collection, each
  27. # actor can now create a custom deck.
  28. # In battle, actors will act in turns. They draw cards and, while an actor is
  29. # active, he can play as many cards and items as he wants, as long as he has
  30. # the recources to do so. Once he is done, he can end his turn and the next
  31. # actor becomes active. When every actor finished his or her turn, the enemys
  32. # use their skills normal.
  33. #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  34. #
  35. #                                  Script Calls
  36. #
  37. # add_card_to_coll(id1, id2, id3, ...)
  38. # Adds cards of the given skill ids to your collection
  39. #
  40. # remove_card?(id)
  41. # Tries to remove a single card of the given skill id from your collection.
  42. # Returns true if successfull and false otherwise.
  43. #
  44. # remove_all_cards(id1, id2, ...)
  45. # Removes all cards of the given skill ids from both the players decks and
  46. # from the collection
  47. #
  48. # has_card?(id)
  49. # Checks if the player has a specific card in his collection or in his deck
  50. #
  51. # count_actor_deck(id)
  52. # Returns the amount of cards in this actors deck
  53. #
  54. # count_all_decks
  55. # Returns the combined deck size of all actors
  56. #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  57. #
  58. #                                   Notetags
  59. #
  60. #           <card id: x>
  61. # The card id of the skill. Each card must have a unique id.
  62. # Important: Every time this script uses the word id, it refers to the skills
  63. # id, not the card id!
  64. #
  65. #           <card type: x>
  66. # The type of the card. Different types can be defined below.
  67. #
  68. #           <card rarity: x>
  69. # The rarity of the card. Different raritys can be defined below.
  70. #
  71. #           <card cost: effect_name>
  72. # Adds the given cost effect to the card. Please read about card effects
  73. # down below.
  74. #
  75. #           <card impact: effect_name>
  76. # Adds the given impact effect to the card. Please read about card effects
  77. # down below.
  78. #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  79. #
  80. #                                Damage Formula
  81. #
  82. # Those commands can be used for a skills damage formula. Make sure they
  83. # always target an actor, since they won't have any effect on enemys. Minor
  84. # scripting knowlegde is required to make the most out of those methods.
  85. #
  86. # a/b.revive_grave(true/false)  
  87. # Shuffles your grave in your deck without penalty. If the argumet is true,
  88. # a message will be shown.
  89. #
  90. # a/b.revive_penalty
  91. # Causes the revive penalty to happen.
  92. #
  93. # a/b.shuffle_deck(true/false)
  94. # Shuffles the actors deck. If the argument is true, a sound will be played.
  95. #
  96. # a/b.card_to_grave?(skill_id)
  97. # Tries to throw the skill with the given ID to the grave. Returns true, if it's
  98. # successfull and false otherwise.
  99. #
  100. # a/b.throw_cards(n)
  101. # Throws n random cards to the grave. If n = 0, the actor will loose all cards.
  102. # Returns how many cards were thrown away.
  103. #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  104. #
  105. #                                Card Effects
  106. #
  107. # Card effects are special, card related effects like "draw x cards" or
  108. # "discard a fire spell to play this card" or "look at the top 5 cards of your
  109. # deck and put them back in any order". Every card effect can be played both as
  110. # a card cost or as a card impact. Costs are handled before the player plays the
  111. # cards, impacts after.
  112. # To set up a card effect, scroll to the end of Options where you will find an
  113. # option called CARD_EFFECT. There you can add a effect name and the effects
  114. # arguments. Then add the effect either as cost or as impact via note tag to
  115. # a skill.
  116. # WARNING: This is not trivial. Read carefully!
  117. #
  118. # Type: Draw
  119. # Simply draws cards
  120. # "effect_name" => [:draw, a, b, c]
  121. # a -> how many cards do you want to draw?
  122. # b -> chance the effect is successfull (between 0 and 100)
  123. # c -> :self to make only the user draw a card, :targ to apply the effect to
  124. #      each target.
  125. # Example:
  126. # "draw2" => [:draw, 2, 100, :self]
  127. # -> The user of this skill will draw 2 cards.
  128. #
  129. # Type: View
  130. # Looks at a certain number of cards taken from location a, and then puts them
  131. # back to location b. Locations can be :deck, :hand and :grave.
  132. # "effect_name" => [ :view, a, b, c]
  133. # a -> how many cards do you want to view? 0 for the entire location.
  134. # b -> from where do you want to take those cards?
  135. # c -> where do you want to put them when you're done?
  136. # Example:
  137. # "view_effect" => [:view, 10, :deck, :deck]
  138. # -> look at the top 10 cards of your deck.
  139. #
  140. # Type: Sort
  141. # Same as view but allows to sort the cards.
  142. # Example:
  143. # "stupid_effect" => [:sort, 0, :hand, :deck]
  144. # -> Put your entire hand ontop of your deck in any order.
  145. #
  146. # Type: Take
  147. # This one is a little bit harder. It allows to take some of the viewed cards
  148. # from one location to another.
  149. # "effect_name" => [:take, a, b, c, d, e, f]
  150. # a, b, c -> same af above
  151. # d -> filter that determines which cards can be choosen,
  152. #      [element_id, type_id, rarity_id], 0 for all id's allowed.
  153. # e -> the location to put the choosen cards.
  154. # f -> how many cards can be choosen.
  155. # Example:
  156. # "search_for_element2" => [:take, 0, :deck, :deck, [2,0,0], :hand, 1]
  157. # -> Search your deck for one card of element 2 and take it to your hand.
  158. # Another Example:
  159. # "discard_cost" => [:take, 0, :hand, :hand, [0,0,0], :grave, 2]
  160. # -> If this is added as a cost effect, the player has to discard two cards
  161. #    from his or her hand to play this card.
  162. #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  163. module PC27
  164.   module CG
  165. #-------------------------------------------------------------------------------
  166. #
  167. #                                   Options
  168. #
  169. #-------------------------------------------------------------------------------
  170.  
  171.  
  172.  #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  173.  #                                   Vocab
  174.  #------------------------------------------------------------------------------
  175.  # DECK             - Name of the actors Deck
  176.  # GRAVE            - Name of the actors Grave
  177.  # COLLECTION       - Name of the Card Collection
  178.  # END_TURN         - Name of the command that will end a players turn
  179.  # DRAW_MESSAGE     - Text that appears when an actor draws a card. Displayed
  180.  #                    as "Actor Name" + DRAW_MESSAGE + "Skill Name"
  181.  # REVIVE_MSG       - Text that appears when you revive your grave
  182.  # CARD_HELP_WINDOW - Help text shown in the deck scene (Use \n to break line)
  183.  # FILTER_TEXT      - First part of the text inside of the filter window
  184.  # F_...            - Second part of the text inside of the filter window
  185.  # CARD_EFF_TEXT    - Text displayed when a card effect is evaluated.
  186.  #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  187.   DECK              = "Deck"
  188.   GRAVE             = "Grave"
  189.   COLLECTION        = "Collection"
  190.   END_TURN          = "End Turn"
  191.   DRAW_MESSAGE      = "draws"
  192.   REVIVE_MSG        = "'s grave was revived"
  193.   CARD_HELP_WINDOW  = "Select: move card\nX(A): open filter"
  194.   FILTER_TEXT       = "Filter by "
  195.   F_ELEMENT         = "element: "
  196.   F_TYPE            = "type:    "
  197.   F_RARITY          = "rarity:  "
  198.   CARD_EFF_TEXT     = "Choose cards:"
  199.  
  200.  
  201.  #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  202.  #                                  Gameplay
  203.  #------------------------------------------------------------------------------
  204.  # USE_ITEMS        - Are items in battle enabeld?
  205.  # START_CARDS      - Cards drawn in Turn 1
  206.  # MAX_DECK_SIZE    - Maximum size of a players deck
  207.  # MAX_SAME_CARDS   - Maximum amount of same cards in each deck
  208.  # DECK_EMPTY       - What happens if an actor tries to draw a card but has an
  209.  #                    empty deck?
  210.  #                    1 -> The actor dies
  211.  #                    2 -> The actor dies if his grave is empty, too. If it
  212.  #                         isn't, he revives his grave, meaning he shuffles his
  213.  #                         grave back into his deck. Revive penalty is applied
  214.  #                    3 -> Like 2, but the actor won't die if the grave is empty
  215.  # REVIVE_PENALTY   - The revive penalty. Types are :hp, :mhp, :mp and :mmp.
  216.  #                    The actor will lose either hp or mp, based on its current
  217.  #                    or maximum value
  218.  # MAX_SAME_EXCEP   - Exceptions to MAX_SAME_CARDS.
  219.  #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  220.   USE_ITEMS         = true
  221.   START_CARDS       = 5
  222.   MAX_DECK_SIZE     = 30
  223.   MAX_SAME_CARDS    = 4
  224.   DECK_EMPTY        = 1
  225.  
  226.  #                    [percent, type]
  227.   REVIVE_PENALTY    = [     50,  :hp]
  228.  
  229.   MAX_SAME_EXCEP    = {
  230.  #                    skill id => max. amount,
  231.                              5 => 2,
  232.                              7 => 1,
  233.   } # do not remove this
  234.  
  235.  
  236.  #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  237.  #                              Icons and Sound
  238.  #------------------------------------------------------------------------------
  239.  # DRAW_SOUND       - Sound that will play when you draw a card
  240.  # PENALTY_SOUND    - Sound that will play when the revive penalty is applied
  241.  # DECK_ICON        - Icon that displays an actors deck size in battle
  242.  #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  243.  #                    ["filename", volume, pitch]  -> ["", 0, 0] means no sound
  244.   DRAW_SOUND        = [   "Book1",    100,   150]
  245.   PENALTY_SOUND     = [ "Attack1",    100,    50]
  246.   DECK_ICON         = 228
  247.  
  248.  
  249.  #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  250.  #                                   Cards
  251.  #------------------------------------------------------------------------------
  252.  # To add custom card images, add an image with the name Card + skill id to your
  253.  # graphics folder (example: Card2). The script will use every picture it can
  254.  # find. Card0 is used when no card is selected. If you choose to do this, most
  255.  # of those options are irrelevant.
  256.  #
  257.  # CUSTOM_CARD_BG   - Name of the windowskin used for cards (in Graphics/System)
  258.  # CARD_BACK_OP     - Background opacity of cards
  259.  # CARD_NAME_UP     - If true, card names will be written in capital letters
  260.  # MP_COLOR         - Textcolor the mana costs are drawn in
  261.  # TP_COLOR         - Textcolor the tp costs are drawn in
  262.  # RARITY           - Name and icon index of the raritys your cards have
  263.  # TYPES            - Different types your cards can have
  264.  # ELEMENT_COLOR    - Background color of your cards based on their element ID
  265.  #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  266.   CUSTOM_CARD_BG    = "Window"   # RPG Maker default is "Window"
  267.   CARD_BACK_OP      = 255
  268.   CARD_NAME_UP      = true
  269.   MP_COLOR          = 4
  270.   TP_COLOR          = 3
  271.  
  272.   RARITY = {
  273.  #      ID => [ icon,     "name"]
  274.          1 => [  127,   "common"],
  275.          2 => [  126, "uncommon"],
  276.          3 => [  125,     "rare"],
  277.   } # do not remove this
  278.  
  279.   TYPE = {
  280.  #      ID => "name"
  281.          1 => "Spell",
  282.          2 => "Support",
  283.          3 => "Buff",
  284.   } # do not remove this
  285.  
  286.   ELEMENT_COLOR = {
  287.  #      ID => [red, grn, blu]
  288.          0 => [  0,   0,   0],   # 0 is used for skills without an element
  289.          1 => [100, 100, 100],
  290.          2 => [200,   0,   0],
  291.          3 => [200, 200,   0],
  292.          4 => [  0,   0, 200],
  293.   } # do not remove this
  294.  
  295.  #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  296.  #                              Card Effects
  297.  #------------------------------------------------------------------------------
  298.  # The first effect called "grave" is available as a command in battle and
  299.  # usually used to view your grave. You can change this effect if you wish, but
  300.  # keep in mind that the player can use this effect as many times as he wants.
  301.  # Please add all other effects below. Do not forget that every effect needs its
  302.  # own name. You can name them however you want, as long as you dont use the
  303.  # same name twice.
  304.  #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  305.   CARD_EFFECT = {
  306.             "grave" => [:view, 0, :grave, :grave],        # Grave command effect
  307.         "foresight" => [:view, 10, :deck, :deck] ,
  308.                 "2" => [:draw, 2, 100, :targ],
  309.      "intervention" => [:sort, 5, :deck, :deck],
  310.              "rise" => [:take, 0, :grave, :grave, [0,0,0], :hand, 1],
  311.               "emp" => [:take, 0, :hand, :hand, [0,0,0], :grave, 2],
  312.        "forestfire" => [:take, 0, :deck, :deck, [2,0,0], :hand, 1],
  313.   } # do not remove this
  314.  
  315. #-------------------------------------------------------------------------------
  316. #
  317. #                                 End Options
  318. #
  319. #-------------------------------------------------------------------------------
  320.  
  321.   end #CG
  322. end #PC27
  323.  
  324. ################################################################################
  325. #                          Start of script                                     #
  326. ################################################################################
  327.  
  328. $imported = {} if $imported.nil?
  329. $imported["PC27: CardGame System"] = true
  330.  
  331.  
  332. #===============================================================================
  333. # Load notetags
  334. #===============================================================================
  335.  
  336. module DataManager
  337.  
  338.   class <<self; alias load_database_pc27_cardgame load_database; end
  339.    
  340.   def self.load_database
  341.     load_database_pc27_cardgame
  342.     load_notetags_pc27_cardgame
  343.   end
  344.  
  345.   def self.load_notetags_pc27_cardgame
  346.     for skill in $data_skills
  347.       next if skill.nil?
  348.       skill.load_notetags_pc27_cardgame_skill
  349.     end
  350.   end
  351.  
  352. end
  353.  
  354.  
  355. class RPG::UsableItem < RPG::BaseItem
  356.  
  357.   attr_accessor :card_id
  358.   attr_accessor :type
  359.   attr_accessor :rarity
  360.   attr_accessor :cost
  361.   attr_accessor :impact
  362.  
  363.   def load_notetags_pc27_cardgame_skill
  364.     @description = wordwrap(@description)
  365.     @card_id = 0
  366.     @type    = 1
  367.     @rarity  = 1
  368.     @cost    = false
  369.     @impact  = false
  370.     self.note.split(/[\r\n]+/).each { |line|
  371.       if /<card[ -_]id: +(?<inr>\d+)>/i =~ line
  372.         @card_id = inr.to_i
  373.       elsif /<card[ -_]type: +(?<tnr>\d+)>/i =~ line
  374.         @type = tnr.to_i
  375.       elsif /<card[ -_]rarity: +(?<rnr>\d+)>/i =~ line
  376.         @rarity = rnr.to_i
  377.       elsif /<card[ -_]cost: +(?<cst>.+)>/i =~ line
  378.         @cost = cst
  379.       elsif /<card[ -_]impact: +(?<imp>.+)>/i =~ line
  380.         @impact = imp
  381.       end
  382.       }
  383.     end
  384.    
  385.   #-----------------------------------------------------------------------------
  386.   # Method to rearange text so it fits inside a window
  387.   #-----------------------------------------------------------------------------
  388.  
  389.   def wordwrap(desc_text, window = nil, default_max_chars = 16)
  390.     max_chars = (window ? (window.width - 2 * window.padding) / 10 : default_max_chars)
  391.     text, line= "", ""
  392.     desc_text.split(/[\r\n ]+/).each { |word|
  393.     if word.size + line.size > max_chars
  394.       text += line+"\n"
  395.       line = word
  396.     else
  397.       line += word
  398.     end
  399.     line += " "
  400.     }
  401.     text += line
  402.     return text
  403.   end
  404.  
  405. end
  406.    
  407. #===============================================================================
  408. # Game_Interpreter
  409. #===============================================================================
  410.  
  411. class Game_Interpreter
  412.  
  413.   def add_card_to_coll(*args)
  414.     for id in args
  415.       $game_party.coll.push($data_skills[id])
  416.     end
  417.   end
  418.  
  419.   def remove_card?(id)
  420.     for i in (0...$game_party.coll.length)
  421.       if $game_party.coll[i].id == id
  422.         $game_party.coll.delete_at(i)
  423.         return true
  424.       end
  425.     end
  426.     return false
  427.   end
  428.  
  429.   def remove_all_cards(*args)
  430.     for id in args
  431.       $game_party.coll -= [$data_skills[id]]
  432.       for actor in $game_party.members
  433.         actor.deck -= [$data_skills[id]]
  434.       end
  435.     end
  436.   end
  437.  
  438.   def has_card?(id)
  439.     for card in $game_party.coll
  440.       return true if card.id == id
  441.     end
  442.     for actor in $game_party.members
  443.       for card in actor.deck
  444.         return true if card.id == id
  445.       end
  446.     end
  447.     return false
  448.   end
  449.  
  450.   def count_actor_deck(id)
  451.     return $game_actors[id].deck.size
  452.   end
  453.  
  454.   def count_all_decks
  455.     nr = 0
  456.     for actor in $game_party.members
  457.       nr += actor.deck.size
  458.     end
  459.     return nr
  460.   end
  461.  
  462. end
  463.    
  464. #===============================================================================
  465. # Game_Battler
  466. #===============================================================================
  467.  
  468. class Game_Battler < Game_BattlerBase
  469.  
  470.   #-----------------------------------------------------------------------------
  471.   # defines card actions for non actors, in case the user messes up
  472.   #-----------------------------------------------------------------------------
  473.   def revive_grave(show = true) ;end
  474.   def revive_penalty            ;end
  475.   def shuffle_deck(sound = true);end
  476.   def card_to_grave?(id)        ;end
  477.   def throw_cards(n)            ;end
  478.   def draw_cards(n)             ;end
  479.  
  480. end
  481.    
  482. #===============================================================================
  483. # Game_Actor
  484. #===============================================================================
  485.  
  486. class Game_Actor < Game_Battler
  487.  
  488.   #-----------------------------------------------------------------------------
  489.   # Attributes
  490.   #-----------------------------------------------------------------------------
  491.   attr_accessor :deck
  492.   attr_accessor :grave
  493.   attr_accessor :hand
  494.   attr_accessor :stack
  495.  
  496.   #-----------------------------------------------------------------------------
  497.   # Adds Hand, Deck, Grave and Stack to an Actor (alias)
  498.   #-----------------------------------------------------------------------------
  499.   alias pc27_cardgame_gameactor_setup                                      setup
  500.   def setup(actor_id)
  501.     pc27_cardgame_gameactor_setup(actor_id)
  502.     @deck  = []
  503.     @hand  = []
  504.     @grave = []
  505.     @stack = []
  506.   end
  507.  
  508.   #-----------------------------------------------------------------------------
  509.   # Draws n cards from the deck (new)
  510.   #-----------------------------------------------------------------------------
  511.   def draw_cards(n, show = true, sound = true)
  512.     n.times do
  513.       if @deck.length == 0
  514.         add_state(1) if PC27::CG::DECK_EMPTY == 1
  515.         return if PC27::CG::DECK_EMPTY == 1
  516.         if @grave.length == 0
  517.           add_state(1) if PC27::CG::DECK_EMPTY == 2
  518.           return
  519.         else
  520.           revive_grave
  521.           revive_penalty if PC27::CG::REVIVE_PENALTY[0] > 0
  522.         end
  523.       end
  524.       RPG::SE.new(*PC27::CG::DRAW_SOUND).play and 30.times { Graphics.update; Input.update } if sound
  525.       skill = @deck.shift
  526.       @hand.push(skill)
  527.       if show
  528.         $game_message.background = 1
  529.         $game_message.position   = 1
  530.         text = @name + " " + PC27::CG::DRAW_MESSAGE + " " + skill.name
  531.         $game_message.add(text)
  532.       end
  533.     end
  534.   end
  535.  
  536.   #-----------------------------------------------------------------------------
  537.   # Puts all cards from your grave back into your deck (new)
  538.   #-----------------------------------------------------------------------------
  539.   def revive_grave(show = true)
  540.     @deck += @grave
  541.     @grave = []
  542.     shuffle_deck(false)
  543.     if show
  544.       $game_message.background = 1
  545.       $game_message.position = 1
  546.       text = @name + PC27::CG::REVIVE_MSG
  547.       $game_message.add(text)
  548.     end
  549.   end
  550.  
  551.   #-----------------------------------------------------------------------------
  552.   # Revive penalty (new)
  553.   #-----------------------------------------------------------------------------
  554.   def revive_penalty
  555.     percent = PC27::CG::REVIVE_PENALTY[0] * 0.01
  556.     case PC27::CG::REVIVE_PENALTY[1]
  557.     when :hp
  558.       @hp  -= (@hp  * percent).round
  559.     when :mhp
  560.       @hp  -= (@mhp * percent).round
  561.     when :mp
  562.       @mp  -= (@mp  * percent).round
  563.     when :mmp
  564.       @mp  -= (@mmp * percent).round
  565.     end
  566.     RPG::SE.new(*PC27::CG::PENALTY_SOUND).play
  567.   end
  568.  
  569.   #-----------------------------------------------------------------------------
  570.   # Shuffles the deck (new)
  571.   #-----------------------------------------------------------------------------
  572.   def shuffle_deck(sound = true)
  573.     if sound
  574.       5.times do
  575.         RPG::SE.new(PC27::CG::DRAW_SOUND[0], 100, 150).play
  576.         20.times { Graphics.update; Input.update }
  577.         RPG::SE.new(PC27::CG::DRAW_SOUND[0], 100, 100).play
  578.         10.times { Graphics.update; Input.update }
  579.       end
  580.     end
  581.     @deck = @deck.shuffle
  582.   end
  583.  
  584.   #-----------------------------------------------------------------------------
  585.   # Sorts Hand, Deck or Grave (new)
  586.   #-----------------------------------------------------------------------------
  587.   def sort_cards(location)
  588.     case location
  589.     when :deck
  590.       @deck.sort!{|a,b| a.card_id <=> b.card_id}
  591.     when :hand
  592.       @hand.sort!{|a,b| a.card_id <=> b.card_id}
  593.     when :grave
  594.       @grave.sort!{|a,b| a.card_id <=> b.card_id}
  595.     end
  596.   end
  597.  
  598.   #-----------------------------------------------------------------------------
  599.   # Tries to put a specific card from your hand to your grave (new)
  600.   #-----------------------------------------------------------------------------
  601.   def card_to_grave?(id)
  602.     for i in (0...@hand.length)
  603.       if @hand[i].id == id
  604.         @grave.push(@hand[i])
  605.         @hand.delete_at(i)
  606.         return true
  607.       end
  608.     end
  609.     return false
  610.   end
  611.  
  612.   #-----------------------------------------------------------------------------
  613.   # Tries to put a specific card from your hand to your stack (new)
  614.   #-----------------------------------------------------------------------------
  615.   def card_to_stack?(id)
  616.     for i in (0...@hand.length)
  617.       if @hand[i].id == id
  618.         @stack.push(@hand[i])
  619.         @hand.delete_at(i)
  620.         return true
  621.       end
  622.     end
  623.     return false
  624.   end
  625.  
  626.   #-----------------------------------------------------------------------------
  627.   # Puts n random cards from your hand to your grave (new)
  628.   #-----------------------------------------------------------------------------
  629.   def throw_cards(n)
  630.     amount_thrown_cards = 0
  631.     if n == 0
  632.       amount_thrown_cards += @hand.size
  633.       @grave += @hand
  634.       @hand = []
  635.     else
  636.       n.times do
  637.         break if @hand.size == 0
  638.         @grave.push(@hand.slice!(rand(@hand.size-1)))
  639.         amount_thrown_cards += 1
  640.       end
  641.     end
  642.     return amount_thrown_cards
  643.   end
  644.  
  645.   #-----------------------------------------------------------------------------
  646.   # Shuffles Deck and draws cards at the begin of each battle (new)
  647.   #-----------------------------------------------------------------------------
  648.   def on_battle_start
  649.     super()
  650.     shuffle_deck(false)
  651.     draw_cards(PC27::CG::START_CARDS, false, false)
  652.   end
  653.  
  654.   #-----------------------------------------------------------------------------
  655.   # Draws a card at the end of each turn (new)
  656.   #-----------------------------------------------------------------------------
  657.   def on_turn_end
  658.     super()
  659.     draw_cards(1, true, true) if $game_party.in_battle && @hp != 0
  660.   end
  661.  
  662.   #-----------------------------------------------------------------------------
  663.   # Restore deck at the end of battle (new)
  664.   #-----------------------------------------------------------------------------
  665.   def on_battle_end
  666.     @deck += @hand + @grave
  667.     @hand, @grave = [],[]
  668.     super()
  669.   end
  670.  
  671. end
  672.  
  673. #===============================================================================
  674. # Game_Party
  675. #===============================================================================
  676.  
  677. class Game_Party < Game_Unit
  678.  
  679.   #-----------------------------------------------------------------------------
  680.   # Attributes
  681.   #-----------------------------------------------------------------------------
  682.   attr_accessor :coll
  683.    
  684.   #-----------------------------------------------------------------------------
  685.   # Adds a card collection to the party (alias)
  686.   #-----------------------------------------------------------------------------
  687.   alias pc27_gameparty_initialize                                     initialize
  688.   def initialize
  689.     pc27_gameparty_initialize
  690.     @coll = []
  691.   end
  692.  
  693. end
  694.  
  695. #===============================================================================
  696. # Window_SkillList
  697. #===============================================================================
  698.  
  699. class Window_SkillList < Window_Selectable
  700.  
  701.   #--------------------------------------------------------------------------
  702.   # Make skill list from @hand, not from @skills (overwrite)
  703.   #--------------------------------------------------------------------------
  704.   def make_item_list
  705.     @actor.sort_cards(:hand)
  706.     @data = @actor.hand
  707.   end
  708.  
  709.   #--------------------------------------------------------------------------
  710.   # Prevents the costs from beeing drawn (overwrite)
  711.   #--------------------------------------------------------------------------
  712.   def draw_item(index)
  713.     skill = @data[index]
  714.     if skill
  715.       rect = item_rect(index)
  716.       draw_item_name(skill, rect.x, rect.y, enable?(skill))
  717.     end
  718.   end
  719.  
  720. end
  721.  
  722. #===============================================================================
  723. # Window_ActorCommand
  724. #===============================================================================
  725.  
  726. class Window_ActorCommand < Window_Command
  727.    
  728.   #--------------------------------------------------------------------------
  729.   # Add "End Turn" command (new)
  730.   #--------------------------------------------------------------------------
  731.   def add_turn_end_command
  732.     add_command(PC27::CG::END_TURN, :end_turn)
  733.   end
  734.  
  735.   #--------------------------------------------------------------------------
  736.   # Add "Grave" command (new)
  737.   #--------------------------------------------------------------------------
  738.   def add_look_at_grave_command
  739.     add_command(PC27::CG::GRAVE, :look_grave)
  740.   end
  741.  
  742.  
  743.   #--------------------------------------------------------------------------
  744.   # Make new command List (overwrite)
  745.   #--------------------------------------------------------------------------
  746.   def make_command_list
  747.     return unless @actor
  748.     add_skill_commands
  749.     add_item_command if PC27::CG::USE_ITEMS
  750.     add_look_at_grave_command
  751.     add_turn_end_command
  752.   end
  753.  
  754. end
  755.  
  756. #===============================================================================
  757. # Window_BattleStatus
  758. #===============================================================================
  759.  
  760. class Window_BattleStatus < Window_Selectable
  761.  
  762.   #--------------------------------------------------------------------------
  763.   # Add deck to Draw Item (alias)
  764.   #--------------------------------------------------------------------------
  765.   alias pc27_cardgame_wndbttlstat_draw_item                            draw_item
  766.   def draw_item(index)
  767.     pc27_cardgame_wndbttlstat_draw_item(index)
  768.     actor = $game_party.battle_members[index]
  769.     draw_deck_area(deck_area_rect(index), actor)
  770.   end
  771.  
  772.   #--------------------------------------------------------------------------
  773.   # Shrink basic rect (overwrite)
  774.   #--------------------------------------------------------------------------
  775.   def basic_area_rect(index)
  776.     rect = item_rect_for_text(index)
  777.     rect.width -= gauge_area_width + deck_area_width + 10
  778.     rect
  779.   end
  780.  
  781.   #--------------------------------------------------------------------------
  782.   # Get Deck rect (new)
  783.   #--------------------------------------------------------------------------
  784.   def deck_area_rect(index)
  785.     rect = item_rect_for_text(index)
  786.     rect.x += rect.width - gauge_area_width - deck_area_width
  787.     rect.width = deck_area_width
  788.     rect
  789.   end
  790.  
  791.   #--------------------------------------------------------------------------
  792.   # Get Deck Area Width (new)
  793.   #--------------------------------------------------------------------------
  794.   def deck_area_width
  795.     return 48
  796.   end
  797.  
  798.   #--------------------------------------------------------------------------
  799.   # Draw Deck Area (new)
  800.   #--------------------------------------------------------------------------
  801.   def draw_deck_area(rect, actor)
  802.     draw_text(rect.x + 24, rect.y, 24, rect.height, actor.deck.size.to_s)
  803.     draw_icon(PC27::CG::DECK_ICON, rect.x, rect.y)
  804.   end
  805.  
  806. end
  807.  
  808. #===============================================================================
  809. # Window_BattleSkill
  810. #===============================================================================
  811.  
  812. class Window_BattleSkill < Window_SkillList
  813.  
  814.   #-----------------------------------------------------------------------------
  815.   # changes the BattleSkillList Window layout (overwrite)
  816.   #-----------------------------------------------------------------------------
  817.   def initialize(help_window, info_viewport)
  818.     y = 0
  819.     super(0, 0, (Graphics.width - 210) * 0.7, info_viewport.rect.y)
  820.     self.visible = false
  821.     @help_window = help_window
  822.     @info_viewport = info_viewport
  823.   end
  824.  
  825.   def col_max
  826.     return 1
  827.   end
  828.  
  829. end
  830.  
  831. #===============================================================================
  832. # Window CardHelp (new)
  833. #===============================================================================
  834.  
  835. class Window_CardHelp < Window_Base
  836.   include PC27::CG
  837.   #-----------------------------------------------------------------------------
  838.   # Enables the Window to draw cards
  839.   #-----------------------------------------------------------------------------
  840.   def draw_card_pic(item)
  841.     if item
  842.       begin
  843.         draw_card_illustration(item)
  844.       rescue
  845.         draw_card_text(item)
  846.       end
  847.     else
  848.       begin
  849.         draw_card_illustration_no_card
  850.       rescue
  851.         draw_card_text_no_card
  852.       end
  853.     end
  854.   end
  855.  
  856.   def draw_horz_line(y)
  857.     line_color       = normal_color
  858.     line_color.alpha = 48
  859.     line_y           = y + line_height / 2 - 1
  860.     contents.fill_rect(0, line_y, self.width, 2, line_color)
  861.   end
  862.  
  863.   def make_cost_text(mp_cost, tp_cost)
  864.     if mp_cost == 0
  865.       if tp_cost == 0
  866.         cost = "-"
  867.         cost_size = 1
  868.       else
  869.         cost = "\\c[" + TP_COLOR.to_s + "]" + tp_cost.to_s
  870.         cost_size = tp_cost.to_s.size
  871.       end
  872.     else
  873.       if tp_cost == 0
  874.         cost = "\\c[" + MP_COLOR.to_s + "]" + mp_cost.to_s
  875.         cost_size = mp_cost.to_s.size
  876.       else
  877.         cost = "\\c[" + MP_COLOR.to_s + "]"  + mp_cost.to_s + "\\c[0]/" + "\\c[" + TP_COLOR.to_s + "]" + tp_cost.to_s
  878.         cost_size = 1 + mp_cost.to_s.size + tp_cost.to_s.size
  879.       end
  880.     end
  881.     draw_text_ex(158-cost_size* 10, 48, cost)
  882.   end
  883.  
  884.   def set_background(element)
  885.     tone.set(*ELEMENT_COLOR[element])
  886.     self.back_opacity = CARD_BACK_OP
  887.   end
  888.  
  889.   def draw_all_lines
  890.     draw_horz_line(36)
  891.     draw_horz_line(60)
  892.     draw_horz_line(204)
  893.   end
  894.    
  895.   def draw_card_text_no_card
  896.     create_contents
  897.     tone.set(*ELEMENT_COLOR[0])
  898.     self.back_opacity = CARD_BACK_OP
  899.   end
  900.  
  901.   def draw_card_text(item)
  902.     create_contents
  903.     self.padding = standard_padding
  904.     id          = item.card_id.to_s
  905.     draw_text_ex(148 - id.size * 10, height - 48, "#" + id)
  906.     make_cost_text(item.mp_cost, item.tp_cost)
  907.     set_background(item.damage ? item.damage.element_id : 0)
  908.     name        = (CARD_NAME_UP ? item.name.upcase : item.name)
  909.     icon        = "\\I[" + RARITY[item.rarity][0].to_s + "]"
  910.     type        = TYPE[item.type]
  911.     name_x      = 0.5 * width - padding - item.name.size * 5
  912.     draw_all_lines
  913.     draw_text_ex(name_x, 9, name)
  914.     draw_text_ex(0,48, type)
  915.     draw_text_ex(0,83, item.description)
  916.     draw_text_ex(0, height - 48, icon)
  917.   end
  918.  
  919.   def draw_card_illustration_no_card
  920.     contents.dispose
  921.     self.contents = Bitmap.new(190, 264)
  922.     bitmap = Cache.picture("Card0")
  923.     self.padding = 0
  924.     rect = Rect.new(0, 0, 190, 264)
  925.     contents.blt(0, 0, bitmap, rect, 255)
  926.     bitmap.dispose
  927.   end
  928.  
  929.   def draw_card_illustration(item)
  930.     contents.dispose
  931.     self.contents = Bitmap.new(190, 264)
  932.     bitmap = Cache.picture("Card" + item.id.to_s)
  933.     self.padding = 0
  934.     rect = Rect.new(0, 0, 190, 264)
  935.     contents.blt(0, 0, bitmap, rect, 255)
  936.     bitmap.dispose
  937.   end
  938.  
  939.   #--------------------------------------------------------------------------
  940.   # Object Initialization
  941.   #--------------------------------------------------------------------------
  942.   def initialize()
  943.     super(Graphics.width - 200, 10, 190, 264)
  944.     self.windowskin = Cache.system(PC27::CG::CUSTOM_CARD_BG) if PC27::CG::CUSTOM_CARD_BG
  945.   end
  946.  
  947.   #--------------------------------------------------------------------------
  948.   # Set Text
  949.   #--------------------------------------------------------------------------
  950.   def set_text(card)
  951.     if card != @card
  952.       @card = card
  953.       refresh
  954.     end
  955.   end
  956.  
  957.   #--------------------------------------------------------------------------
  958.   # Set Item
  959.   #--------------------------------------------------------------------------
  960.   def set_item(item)
  961.     set_text(item)
  962.   end
  963.  
  964.   #--------------------------------------------------------------------------
  965.   # Refresh
  966.   #--------------------------------------------------------------------------
  967.   def refresh
  968.     contents.clear
  969.     draw_card_pic(@card)
  970.   end
  971.  
  972.   def update_tone;    end
  973.   def update_padding; end
  974.  
  975. end
  976.  
  977.  
  978. #===============================================================================
  979. # Window_CardSelect (new)
  980. #===============================================================================
  981.  
  982. class Window_CardSelect < Window_SkillList
  983.  
  984.   attr_accessor :actor
  985.   attr_accessor :cards
  986.   attr_accessor :sort_index
  987.   attr_accessor :filter
  988.  
  989.   def initialize(help_window, info_viewport)
  990.     super(0, 0, (Graphics.width - 210) * 0.7, info_viewport.rect.y)
  991.     self.visible = false
  992.     @help_window = help_window
  993.     @info_viewport = info_viewport
  994.     @filter = [0,0,0]
  995.     @cards  = []
  996.     @sort_index = -1
  997.   end
  998.  
  999.   def col_max
  1000.     return 1
  1001.   end
  1002.  
  1003.   def make_item_list
  1004.     @data = @cards
  1005.   end
  1006.  
  1007.   def enable?(item)
  1008.     return false unless item
  1009.     return false unless item.damage.element_id == @filter[0] || @filter[0] == 0
  1010.     return false unless item.type              == @filter[1] || @filter[1] == 0
  1011.     return false unless item.rarity            == @filter[2] || @filter[2] == 0
  1012.     return @actor
  1013.   end
  1014.  
  1015.   #--------------------------------------------------------------------------
  1016.   # Show Window
  1017.   #--------------------------------------------------------------------------
  1018.   def show
  1019.     select(0)
  1020.     @help_window.show
  1021.     super
  1022.   end
  1023.   #--------------------------------------------------------------------------
  1024.   # Hide Window
  1025.   #--------------------------------------------------------------------------
  1026.   def hide
  1027.     @help_window.hide
  1028.     super
  1029.   end
  1030.  
  1031. end
  1032.  
  1033.  
  1034. #===============================================================================
  1035. # Scene_Battle
  1036. #===============================================================================
  1037. class Scene_Battle < Scene_Base
  1038.  
  1039.   #--------------------------------------------------------------------------
  1040.   # Add end turn command and remove prior command (overwrite)
  1041.   #--------------------------------------------------------------------------
  1042.   def create_actor_command_window
  1043.     @actor_command_window = Window_ActorCommand.new
  1044.     @actor_command_window.viewport = @info_viewport
  1045.     @actor_command_window.set_handler(:skill,      method(:command_skill))
  1046.     @actor_command_window.set_handler(:item,       method(:command_item))
  1047.     @actor_command_window.set_handler(:look_grave, method(:command_look_grave))
  1048.     @actor_command_window.set_handler(:end_turn,   method(:command_end_turn))
  1049.     @actor_command_window.x = Graphics.width
  1050.   end
  1051.  
  1052.   #--------------------------------------------------------------------------
  1053.   # Handles the Look Grave command
  1054.   #--------------------------------------------------------------------------
  1055.   def command_look_grave
  1056.     text = ""
  1057.     for card in BattleManager.actor.grave
  1058.       text += card.name.to_s + " "
  1059.     end
  1060.     msgbox_p(text)
  1061.    
  1062.     array = PC27::CG::CARD_EFFECT["grave"]
  1063.     @temp_effect_data = [] unless @temp_effect_data
  1064.     @temp_effect_data[0] = :impact
  1065.     prepare_select_window(:impact, array[0])
  1066.     process_select_cards("grave")
  1067.   end
  1068.    
  1069.   #--------------------------------------------------------------------------
  1070.   # Clears actions and ends the actors turn
  1071.   #--------------------------------------------------------------------------
  1072.   def command_end_turn
  1073.     BattleManager.actor.clear_actions
  1074.     next_command
  1075.   end
  1076.      
  1077.   #--------------------------------------------------------------------------
  1078.   # Prevents messages from closing windows (overwrite)
  1079.   #--------------------------------------------------------------------------
  1080.   def update_message_open
  1081.   end
  1082.  
  1083.   #--------------------------------------------------------------------------
  1084.   # Shows a different Help Window in Battle (alias)
  1085.   #--------------------------------------------------------------------------
  1086.   alias pc27_cardgame_scenebattle_create_help_window          create_help_window
  1087.   def create_help_window
  1088.     pc27_cardgame_scenebattle_create_help_window
  1089.     @cardhelp_window = Window_CardHelp.new
  1090.     @cardhelp_window.visible = false
  1091.   end
  1092.  
  1093.   #--------------------------------------------------------------------------
  1094.   # Create Skill Window with card help window instead of normal help window (overwrite)
  1095.   #--------------------------------------------------------------------------
  1096.   def create_skill_window
  1097.     @skill_window = Window_BattleSkill.new(@cardhelp_window, @info_viewport)
  1098.     @skill_window.set_handler(:ok,     method(:on_skill_ok))
  1099.     @skill_window.set_handler(:cancel, method(:on_skill_cancel))
  1100.   end
  1101.  
  1102.  
  1103.   #--------------------------------------------------------------------------
  1104.   # Creates the window needed to select cards (new)
  1105.   #--------------------------------------------------------------------------
  1106.   def create_card_select_window
  1107.     @card_select_window = Window_CardSelect.new(@cardhelp_window, @info_viewport)
  1108.   end
  1109.  
  1110.   #--------------------------------------------------------------------------
  1111.   # Adds the select window to the scene (alias)
  1112.   #--------------------------------------------------------------------------
  1113.   alias pc27_cardgame_scenebattle_create_all_windows          create_all_windows
  1114.   def create_all_windows
  1115.     pc27_cardgame_scenebattle_create_all_windows
  1116.     create_card_select_window
  1117.   end
  1118.  
  1119.   #--------------------------------------------------------------------------
  1120.   # On Skill ok checks for card costs
  1121.   #--------------------------------------------------------------------------
  1122.   def on_skill_ok
  1123.     @skill = @skill_window.item
  1124.     BattleManager.actor.card_to_stack?(@skill.id)
  1125.     if @skill.cost
  1126.       invoke_card_cost(@skill.cost)
  1127.       @skill_window.hide
  1128.     else
  1129.       BattleManager.actor.input.set_skill(@skill.id)
  1130.       BattleManager.actor.last_skill.object = @skill
  1131.       if !@skill.need_selection?
  1132.         @skill_window.hide
  1133.         next_command
  1134.       elsif @skill.for_opponent?
  1135.         select_enemy_selection
  1136.       else
  1137.         select_actor_selection
  1138.       end
  1139.     end
  1140.   end
  1141.  
  1142.   alias pc27_cardgame_scenebattle_on_enemy_cancel                on_enemy_cancel
  1143.   def on_enemy_cancel
  1144.     BattleManager.actor.hand += BattleManager.actor.stack
  1145.     BattleManager.actor.stack = []
  1146.     pc27_cardgame_scenebattle_on_enemy_cancel
  1147.   end
  1148.  
  1149.   alias pc27_cardgame_scenebattle_on_actor_cancel                on_actor_cancel
  1150.   def on_actor_cancel
  1151.     BattleManager.actor.hand += BattleManager.actor.stack
  1152.     BattleManager.actor.stack = []
  1153.     pc27_cardgame_scenebattle_on_actor_cancel
  1154.   end
  1155.  
  1156.  
  1157.   #-----------------------------------------------------------------------------
  1158.   # Changes Next Command so it performs Actions (alias)
  1159.   #-----------------------------------------------------------------------------
  1160.   alias pc27_cardgame_scenebattle_next_command                      next_command
  1161.   def next_command
  1162.     return if @card_select_window.active
  1163.     if action?
  1164.       perform_action
  1165.     else
  1166.       pc27_cardgame_scenebattle_next_command
  1167.     end
  1168.   end
  1169.  
  1170.   #--------------------------------------------------------------------------
  1171.   # Checks if there is an Action to use (new)
  1172.   #--------------------------------------------------------------------------
  1173.   def action?
  1174.     return false if BattleManager.actor.nil?
  1175.     return false if BattleManager.actor.input.nil?
  1176.     action = BattleManager.actor.input.item
  1177.     return false if action.nil?
  1178.     return true
  1179.   end
  1180.    
  1181.   #--------------------------------------------------------------------------
  1182.   # Performs Action (new)
  1183.   #--------------------------------------------------------------------------
  1184.   def perform_action
  1185.     @subject = BattleManager.actor
  1186.     hide_instant_action_windows
  1187.     if @subject.current_action.valid?
  1188.       execute_action
  1189.     end
  1190.     process_event
  1191.     loop do
  1192.       @subject.remove_current_action
  1193.       break if $game_troop.all_dead?
  1194.       break unless @subject.current_action
  1195.       @subject.current_action.prepare
  1196.       execute_action if @subject.current_action.valid?
  1197.     end
  1198.     process_action_end
  1199.     @subject.make_actions
  1200.     @subject = nil
  1201.     show_instant_action_windows
  1202.   end
  1203.  
  1204.   #--------------------------------------------------------------------------
  1205.   # From Yanflys Instantcast (new)
  1206.   #--------------------------------------------------------------------------
  1207.   def hide_instant_action_windows
  1208.     if $imported["YEA-BattleEngine"]
  1209.       @info_viewport.visible = true
  1210.       @status_aid_window.hide
  1211.       @status_window.show
  1212.       @actor_command_window.show
  1213.     end
  1214.   end
  1215.  
  1216.   #--------------------------------------------------------------------------
  1217.   # Activates actor (new)
  1218.   #--------------------------------------------------------------------------
  1219.   def show_instant_action_windows
  1220.     if $imported["YEA-BattleEngine"]
  1221.       @info_viewport.visible = true
  1222.     end
  1223.     start_actor_command_selection unless @card_select_window.active
  1224.     status_redraw_target(BattleManager.actor)
  1225.     next_command unless BattleManager.actor.inputable?
  1226.   end
  1227.  
  1228.   #--------------------------------------------------------------------------
  1229.   # Redrwas target after action (new)
  1230.   #--------------------------------------------------------------------------
  1231.   def status_redraw_target(target)
  1232.     return unless target.actor?
  1233.     @status_window.draw_item($game_party.battle_members.index(target))
  1234.   end
  1235.  
  1236.   #--------------------------------------------------------------------------
  1237.   # Handles card costs
  1238.   #--------------------------------------------------------------------------
  1239.   def invoke_card_cost(effect_name)
  1240.     effect_array = PC27::CG::CARD_EFFECT[effect_name]
  1241.     if effect_array[0] == :draw
  1242.       card_effect_draw_cards(effect_array[1], effect_array[2], effect_array[3])
  1243.       BattleManager.actor.input.set_skill(@skill.id)
  1244.       BattleManager.actor.last_skill.object = @skill
  1245.       if !@skill.need_selection?
  1246.         @skill_window.hide
  1247.         next_command
  1248.       elsif @skill.for_opponent?
  1249.         select_enemy_selection
  1250.       else
  1251.         select_actor_selection
  1252.       end
  1253.     else
  1254.       $game_message.background = 1
  1255.       $game_message.position   = 1
  1256.       $game_message.add(PC27::CG::CARD_EFF_TEXT)
  1257.       wait_for_message
  1258.       prepare_select_window(:cost, effect_array[0])
  1259.       @temp_effect_data = [] unless @temp_effect_data
  1260.       @temp_effect_data[0] = :cost
  1261.       process_select_cards(effect_name)
  1262.     end
  1263.   end
  1264.  
  1265.   #--------------------------------------------------------------------------
  1266.   # Evaluates card effects and puts the stack to the grave (alias)
  1267.   #--------------------------------------------------------------------------
  1268.   alias pc27_cardgame_scenebattle_use_item                              use_item
  1269.   def use_item
  1270.     pc27_cardgame_scenebattle_use_item
  1271.     if @subject.is_a?(Game_Actor)
  1272.       effect_name = @subject.current_action.item.impact
  1273.       invoke_card_impact(effect_name) if effect_name
  1274.       @subject.grave += @subject.stack
  1275.       @subject.stack = []
  1276.     end
  1277.   end
  1278.  
  1279.   #--------------------------------------------------------------------------
  1280.   # Card effects
  1281.   #--------------------------------------------------------------------------
  1282.   def invoke_card_impact(effect_name)
  1283.     array = PC27::CG::CARD_EFFECT[effect_name]
  1284.     if array[0] == :draw
  1285.       card_effect_draw_cards(array[1], array[2], array[3])
  1286.     else
  1287.       $game_message.background = 1
  1288.       $game_message.position   = 1
  1289.       $game_message.add(PC27::CG::CARD_EFF_TEXT)
  1290.       wait_for_message
  1291.       prepare_select_window(:impact, array[0])
  1292.       @temp_effect_data = [] unless @temp_effect_data
  1293.       @temp_effect_data[0] = :impact
  1294.       process_select_cards(effect_name)
  1295.     end
  1296.   end
  1297.  
  1298.   #--------------------------------------------------------------------------
  1299.   def card_effect_draw_cards(nr, prob, trg)
  1300.     if trg == :self
  1301.       if rand(100) < prob
  1302.         @subject.draw_cards(nr)
  1303.         need_wait = true
  1304.       end
  1305.     elsif trg == :target
  1306.       targets = @subject.current_action.make_targets.compact
  1307.       for target in targets
  1308.         if rand(100) < prob
  1309.           target.draw_cards(nr)
  1310.           need_wait = true
  1311.         end
  1312.       end
  1313.     end
  1314.     wait_for_message if need_wait
  1315.   end
  1316.    
  1317.   #--------------------------------------------------------------------------
  1318.   def process_select_cards(effect_name)
  1319.     @card_select_window.actor = BattleManager.actor
  1320.     array = PC27::CG::CARD_EFFECT[effect_name]
  1321.     case array[2]
  1322.     when :deck
  1323.       (array[1] == 0 ? amn = @card_select_window.actor.deck.size : amn = array[1])
  1324.       amn.times do
  1325.         next if @card_select_window.actor.deck.size == 0
  1326.         @card_select_window.cards.push(@card_select_window.actor.deck.shift)
  1327.       end
  1328.     when :hand
  1329.       (array[1] == 0 ? amn = @card_select_window.actor.hand.size : amn = array[1])
  1330.       amn.times do
  1331.         next if @card_select_window.actor.hand.size == 0
  1332.         @card_select_window.cards.push(@card_select_window.actor.hand.shift)
  1333.       end
  1334.     when :grave
  1335.       (array[1] == 0 ? amn = @card_select_window.actor.grave.size : amn = array[1])
  1336.       amn.times do
  1337.         next if @card_select_window.actor.grave.size == 0
  1338.         @card_select_window.cards.push(@card_select_window.actor.grave.shift)
  1339.       end
  1340.     end
  1341.     @temp_effect_data[1] = effect_name
  1342.     @temp_effect_data[2] = 0
  1343.     set_select_filter(array)
  1344.     @card_select_window.refresh
  1345.     @card_select_window.show.activate
  1346.   end
  1347.  
  1348.   #--------------------------------------------------------------------------
  1349.   def set_select_filter(array)
  1350.     if array[4]
  1351.       @card_select_window.filter = array[4]
  1352.     elsif array[0] == :view
  1353.       @card_select_window.filter = [-1,-1,-1]
  1354.     else
  1355.       @card_select_window.filter = [0,0,0]
  1356.     end
  1357.   end
  1358.  
  1359.   #--------------------------------------------------------------------------
  1360.   def select_cards_ok_sort
  1361.     if @card_select_window.cards.size == 0
  1362.       select_cancel
  1363.       return
  1364.     end
  1365.     if @card_select_window.sort_index != -1
  1366.     swap_cards(@card_select_window.sort_index, @card_select_window.index)
  1367.       @card_select_window.sort_index = -1
  1368.       @card_select_window.refresh
  1369.     else
  1370.       @card_select_window.sort_index = @card_select_window.index
  1371.     end
  1372.     @card_select_window.activate
  1373.   end
  1374.  
  1375.   #--------------------------------------------------------------------------
  1376.   def select_cards_ok_take
  1377.     if @card_select_window.cards.size == 0
  1378.       select_cancel
  1379.       return
  1380.     end
  1381.     card = @card_select_window.item
  1382.     case PC27::CG::CARD_EFFECT[@temp_effect_data[1]][5]
  1383.     when :hand
  1384.       @card_select_window.actor.hand.push(card)
  1385.     when :deck
  1386.       @card_select_window.actor.deck.push(card)
  1387.       @card_select_window.actor.shuffle_deck(false)
  1388.     when :grave
  1389.       @card_select_window.actor.grave.push(card)
  1390.     end
  1391.     @card_select_window.cards.delete_at(@card_select_window.cards.index(card))
  1392.     @temp_effect_data[2] += 1
  1393.     if PC27::CG::CARD_EFFECT[@temp_effect_data[1]][6] != @temp_effect_data[2]
  1394.       @card_select_window.refresh
  1395.       @card_select_window.activate
  1396.     else
  1397.       proceed_selection
  1398.     end
  1399.   end
  1400.  
  1401.   #--------------------------------------------------------------------------
  1402.   def proceed_selection
  1403.     @card_select_window.hide.deactivate
  1404.     @card_select_window.sort_index = -1
  1405.     restore_selected_cards
  1406.     if @temp_effect_data[0] = :cost
  1407.       BattleManager.actor.input.set_skill(@skill.id)
  1408.       BattleManager.actor.last_skill.object = @skill
  1409.       if !@skill.need_selection?
  1410.         @skill_window.hide
  1411.         next_command
  1412.       elsif @skill.for_opponent?
  1413.         select_enemy_selection
  1414.       else
  1415.         select_actor_selection
  1416.       end
  1417.     elsif @temp_effect_data[0] = :impact
  1418.       start_actor_command_selection
  1419.     end
  1420.   end
  1421.  
  1422.   def select_cancel
  1423.     @card_select_window.hide.deactivate
  1424.     @card_select_window.sort_index = -1
  1425.     restore_selected_cards
  1426.     if @temp_effect_data[0] = :cost
  1427.       BattleManager.actor.hand += BattleManager.actor.stack
  1428.       BattleManager.actor.stack = []
  1429.       on_skill_cancel
  1430.     elsif @temp_effect_data[0] = :impact
  1431.       start_actor_command_selection
  1432.     end
  1433.   end
  1434.  
  1435.   #--------------------------------------------------------------------------
  1436.   def restore_selected_cards
  1437.     array = PC27::CG::CARD_EFFECT[@temp_effect_data[1]]
  1438.     case array[3]
  1439.     when :deck
  1440.       @card_select_window.cards.reverse.each { |card|
  1441.         @card_select_window.actor.deck.unshift(card)
  1442.       }
  1443.       @card_select_window.actor.shuffle_deck if array[0] == :take && @card_select_window.actor.deck.size != 0
  1444.       @status_window.refresh
  1445.     when :hand
  1446.       @card_select_window.cards.reverse.each { |card|
  1447.         @card_select_window.actor.hand.unshift(card)
  1448.       }
  1449.     when :grave
  1450.       @card_select_window.cards.reverse.each { |card|
  1451.         @card_select_window.actor.grave.unshift(card)
  1452.       }
  1453.     end
  1454.     @card_select_window.cards = []
  1455.   end
  1456.  
  1457.   #--------------------------------------------------------------------------
  1458.   def prepare_select_window(moment, type)
  1459.     if moment == :impact
  1460.       if    type == :view
  1461.         @card_select_window.set_handler(:ok,   method(:no_method))
  1462.         @card_select_window.set_handler(:cancel, method(:select_cancel))
  1463.       elsif type == :sort
  1464.         @card_select_window.set_handler(:ok,   method(:select_cards_ok_sort))
  1465.         @card_select_window.set_handler(:cancel, method(:select_cancel))
  1466.       elsif type == :take
  1467.         @card_select_window.set_handler(:ok,   method(:select_cards_ok_take))
  1468.         @card_select_window.set_handler(:cancel, method(:select_cancel))
  1469.       end
  1470.     elsif moment == :cost
  1471.       if    type == :view
  1472.         @card_select_window.set_handler(:ok,   method(:no_method))
  1473.         @card_select_window.set_handler(:cancel, method(:select_cancel))
  1474.       elsif type == :sort
  1475.         @card_select_window.set_handler(:ok,   method(:select_cards_ok_sort))
  1476.         @card_select_window.set_handler(:cancel, method(:proceed_selection))
  1477.       elsif type == :take
  1478.         @card_select_window.set_handler(:ok,   method(:select_cards_ok_take))
  1479.         @card_select_window.set_handler(:cancel, method(:select_cancel))
  1480.       end
  1481.     end
  1482.   end
  1483.  
  1484.   def no_method
  1485.     @card_select_window.activate
  1486.   end
  1487.        
  1488.   #--------------------------------------------------------------------------
  1489.   def swap_cards(index1, index2)
  1490.     @card_select_window.cards[index1], @card_select_window.cards[index2] =
  1491.     @card_select_window.cards[index2], @card_select_window.cards[index1]
  1492.   end
  1493.  
  1494. end
  1495.  
  1496. #===============================================================================
  1497. # Scene_Deck
  1498. #===============================================================================
  1499.  
  1500. class Scene_Deck < Scene_MenuBase
  1501.   include PC27::CG
  1502.   #--------------------------------------------------------------------------
  1503.   # Start
  1504.   #--------------------------------------------------------------------------
  1505.   def start
  1506.     super()
  1507.     create_filter_window
  1508.     create_deck_window
  1509.     create_coll_window
  1510.     create_text_window
  1511.     create_card_window
  1512.     create_info_window
  1513.   end
  1514.  
  1515.   #--------------------------------------------------------------------------
  1516.   # Creates a window to display deck cards
  1517.   #--------------------------------------------------------------------------
  1518.   def create_deck_window
  1519.     @deck_window = Window_Deck.new(0,64)
  1520.     @deck_window.set_handler(:cancel,   method(:return_scene))
  1521.     @deck_window.set_handler(:ok,       method(:deck_to_coll))
  1522.   end
  1523.  
  1524.   #--------------------------------------------------------------------------
  1525.   # Creates a window to display collection cards
  1526.   #--------------------------------------------------------------------------
  1527.   def create_coll_window
  1528.     @coll_window = Window_Coll.new((Graphics.width - 210)*0.5, 64)
  1529.     @coll_window.set_handler(:cancel,   method(:return_scene))
  1530.     @coll_window.set_handler(:ok,       method(:coll_to_deck))
  1531.     @coll_window.deactivate
  1532.   end
  1533.  
  1534.   #--------------------------------------------------------------------------
  1535.   # Creates the window that shows where you are
  1536.   #--------------------------------------------------------------------------
  1537.   def create_text_window
  1538.     @text_window = Window_Base.new(0 ,0, Graphics.width - 210, 64)
  1539.     update_text_window
  1540.   end
  1541.  
  1542.   #--------------------------------------------------------------------------
  1543.   # Creates the window that shows the currently selected card
  1544.   #--------------------------------------------------------------------------
  1545.   def create_card_window
  1546.     @card_window = Window_CardHelp.new()
  1547.     @card_window.windowskin = Cache.system(CUSTOM_CARD_BG) if CUSTOM_CARD_BG
  1548.     @card_window.tone.set(*PC27::CG::ELEMENT_COLOR[0])
  1549.     @card_window.back_opacity = PC27::CG::CARD_BACK_OP
  1550.   end
  1551.  
  1552.   #-----------------------------------------------------------------------------
  1553.   # Creates a info window
  1554.   #-----------------------------------------------------------------------------
  1555.   def create_info_window
  1556.     height = Graphics.height - 284
  1557.     @info_window = Window_Base.new(
  1558.     Graphics.width - 210, Graphics.height - height, 210, height)
  1559.     @info_window.draw_text_ex(0,0,CARD_HELP_WINDOW)
  1560.   end
  1561.  
  1562.   #--------------------------------------------------------------------------
  1563.   # Creates a window to filter cards
  1564.   #--------------------------------------------------------------------------
  1565.   def create_filter_window
  1566.     @filter_window = Window_Filter.new(0,Graphics.height * 0.5 - 48)
  1567.     @filter_window.set_handler(:cancel,   method(:close_filter))
  1568.     @filter_window.set_handler(:ok,       method(:change_filter))
  1569.     @filter_window.z = 150
  1570.     @filter_window.hide
  1571.     @filter_window.deactivate
  1572.   end
  1573.  
  1574.   #-----------------------------------------------------------------------------
  1575.   # Changes between collection and deck window
  1576.   #-----------------------------------------------------------------------------    
  1577.   def change_to_coll
  1578.     @coll_window.activate
  1579.     @deck_window.deactivate
  1580.     Sound.play_cursor
  1581.     Input.update
  1582.   end
  1583.      
  1584.   def change_to_deck
  1585.     @deck_window.activate
  1586.     @coll_window.deactivate
  1587.     Sound.play_cursor
  1588.     Input.update
  1589.   end
  1590.  
  1591.   #--------------------------------------------------------------------------
  1592.   # Adds commands to exchange cards
  1593.   #--------------------------------------------------------------------------
  1594.   def coll_to_deck
  1595.     if $game_party.menu_actor.deck.size >= MAX_DECK_SIZE
  1596.       RPG::SE.new("Buzzer1", 80, 100).play
  1597.       return
  1598.     end
  1599.     /coll(?<skill_id>\d+)/ =~ @coll_window.current_symbol.to_s
  1600.     skill_id  = skill_id.to_i
  1601.     max_cards = (MAX_SAME_EXCEP.has_key?(skill_id) ? MAX_SAME_EXCEP[skill_id] : MAX_SAME_CARDS)
  1602.     if $game_party.menu_actor.deck.count{ |skill| skill.id == skill_id } >= max_cards
  1603.       RPG::SE.new("Buzzer1", 80, 100).play
  1604.       return
  1605.     end
  1606.     for skill in $game_party.coll
  1607.       if skill.id == skill_id
  1608.         $game_party.menu_actor.deck.push(
  1609.         $game_party.coll.slice!($game_party.coll.index(skill)))
  1610.         break
  1611.       end
  1612.     end
  1613.     RPG::SE.new("Cursor1", 80, 100).play
  1614.     @deck_window.refresh
  1615.     @coll_window.refresh
  1616.     update_text_window
  1617.   end
  1618.  
  1619.   def deck_to_coll
  1620.     /deck(?<skill_id>\d+)/ =~ @deck_window.current_symbol.to_s
  1621.     skill_id = skill_id.to_i
  1622.     for skill in $game_party.menu_actor.deck
  1623.       if skill.id == skill_id
  1624.         $game_party.coll.push(
  1625.         $game_party.menu_actor.deck.slice!($game_party.menu_actor.deck.index(skill)))
  1626.         break
  1627.       end
  1628.     end
  1629.     RPG::SE.new("Cursor1", 80, 100).play
  1630.     @deck_window.refresh
  1631.     @coll_window.refresh
  1632.     update_text_window
  1633.   end
  1634.  
  1635.   #--------------------------------------------------------------------------
  1636.   # Activates filter
  1637.   #--------------------------------------------------------------------------
  1638.   def activate_filter
  1639.     @filter_window.show
  1640.     @filter_window.activate
  1641.     @deck_window.deactivate
  1642.     @coll_window.deactivate
  1643.   end
  1644.  
  1645.   #--------------------------------------------------------------------------
  1646.   # Changes filter settings
  1647.   #--------------------------------------------------------------------------
  1648.   def change_filter
  1649.     case @filter_window.current_symbol
  1650.     when :filter_element
  1651.       @coll_window.filter[0]   += 1
  1652.       @filter_window.filter[0] += 1
  1653.       @coll_window.filter[0]    = 0 if $data_system.elements.size == @coll_window.filter[0]
  1654.       @filter_window.filter[0]  = 0 if $data_system.elements.size == @filter_window.filter[0]
  1655.     when :filter_type
  1656.       @coll_window.filter[1]   += 1
  1657.       @filter_window.filter[1] += 1
  1658.       @coll_window.filter[1]    = 0 unless TYPE.has_key?(@coll_window.filter[1])
  1659.       @filter_window.filter[1]  = 0 unless TYPE.has_key?(@filter_window.filter[1])
  1660.     when :filter_rarity
  1661.       @coll_window.filter[2]   += 1
  1662.       @filter_window.filter[2] += 1
  1663.       @coll_window.filter[2]    = 0 unless RARITY.has_key?(@coll_window.filter[2])
  1664.       @filter_window.filter[2]  = 0 unless RARITY.has_key?(@filter_window.filter[2])
  1665.     end
  1666.     @filter_window.refresh
  1667.     @coll_window.refresh
  1668.   end
  1669.  
  1670.   #--------------------------------------------------------------------------
  1671.   # Deativates filter
  1672.   #--------------------------------------------------------------------------
  1673.   def close_filter
  1674.     @filter_window.hide
  1675.     @filter_window.deactivate
  1676.     @coll_window.activate
  1677.     @coll_window.select(0)
  1678.   end
  1679.  
  1680.  
  1681.   #--------------------------------------------------------------------------
  1682.   # * Frame Update
  1683.   #--------------------------------------------------------------------------
  1684.   def update
  1685.     super()
  1686.  
  1687.     #--------------------------------------------------------------------------
  1688.     # Handles input
  1689.     #--------------------------------------------------------------------------
  1690.     if @filter_window.visible == false
  1691.       change_to_coll  if Input.trigger?(:RIGHT)
  1692.       change_to_deck  if Input.trigger?(:LEFT)
  1693.       activate_filter if Input.trigger?(:X)
  1694.       next_actor      if Input.trigger?(:R)
  1695.       prev_actor      if Input.trigger?(:L)
  1696.     end
  1697.    
  1698.     #--------------------------------------------------------------------------
  1699.     # Redraws card, if neccessary
  1700.     #--------------------------------------------------------------------------
  1701.     if @coll_window.active
  1702.       symbol = @coll_window.current_symbol
  1703.     elsif @deck_window.active
  1704.       symbol = @deck_window.current_symbol
  1705.     end
  1706.    
  1707.     if symbol != @symbol
  1708.       @symbol = symbol
  1709.       /[kl](?<id>\d+)/ =~ @symbol.to_s
  1710.       skill = ( id ? $data_skills[id.to_i] : nil)
  1711.       @card_window.set_item(skill)
  1712.     end
  1713.    
  1714.   end
  1715.  
  1716.   def on_actor_change
  1717.     RPG::SE.new("Cursor2", 80, 100).play
  1718.     @deck_window.refresh
  1719.     @deck_window.select(0)
  1720.     @coll_window.select(0)
  1721.     update_text_window
  1722.   end
  1723.  
  1724.   def update_text_window
  1725.     @text_window.contents.clear
  1726.     text_name = $game_party.menu_actor.name + "s " + DECK
  1727.     @text_window.draw_text_ex(0, 8, text_name)
  1728.     text_deck = $game_party.menu_actor.deck.size.to_s + "/" + MAX_DECK_SIZE.to_s
  1729.     xpos = @text_window.width - 10*(text_deck.size+1) - @text_window.padding
  1730.     @text_window.draw_text_ex(xpos, 8, text_deck)
  1731.   end
  1732.  
  1733. end
  1734.  
  1735.  
  1736. class Window_Deck < Window_Command
  1737.  
  1738.   #--------------------------------------------------------------------------
  1739.   # Makes Command List
  1740.   #--------------------------------------------------------------------------
  1741.   def make_command_list
  1742.     add_deck_commands
  1743.   end
  1744.  
  1745.   #--------------------------------------------------------------------------
  1746.   # Add Card Commands to List
  1747.   #--------------------------------------------------------------------------
  1748.   def add_deck_commands
  1749.     $game_party.menu_actor.sort_cards(:deck)
  1750.     deck = $game_party.menu_actor.deck
  1751.     if deck.empty?
  1752.       add_command("---", :nothing)
  1753.       return
  1754.     end
  1755.     hash = {}
  1756.     for skill in deck
  1757.       if hash.has_key?(skill.id)
  1758.         hash[skill.id] += 1
  1759.       else
  1760.         hash[skill.id] = 1
  1761.       end
  1762.     end
  1763.     hash.each_key do |id|
  1764.       add_command(hash[id].to_s + "x " + $data_skills[id].name, ("deck" + id.to_s).to_sym)
  1765.     end
  1766.   end
  1767.  
  1768.   #--------------------------------------------------------------------------
  1769.   # Get Window Height
  1770.   #--------------------------------------------------------------------------
  1771.   def window_height
  1772.     Graphics.height - 64
  1773.   end
  1774.  
  1775.   #--------------------------------------------------------------------------
  1776.   # Get Window width
  1777.   #--------------------------------------------------------------------------
  1778.   def window_width
  1779.     (Graphics.width - 210) * 0.5
  1780.   end
  1781.  
  1782.   #--------------------------------------------------------------------------
  1783.   # Overwrite process_ok so the window won't be disabled
  1784.   #--------------------------------------------------------------------------
  1785.   def process_ok
  1786.     if current_item_enabled?
  1787.       Input.update
  1788.       call_ok_handler
  1789.       select(index - 1) unless current_symbol
  1790.     else
  1791.       Sound.play_buzzer
  1792.     end
  1793.   end
  1794.  
  1795. end
  1796.  
  1797.  
  1798. class Window_Coll < Window_Command
  1799.  
  1800.   attr_accessor :filter
  1801.    
  1802.   def initialize(width, heigth)
  1803.     @filter = [0,0,0]
  1804.     super(width, heigth)
  1805.   end
  1806.  
  1807.   #--------------------------------------------------------------------------
  1808.   # Makes Command List
  1809.   #--------------------------------------------------------------------------
  1810.   def make_command_list
  1811.     add_coll_commands
  1812.   end
  1813.  
  1814.   #--------------------------------------------------------------------------
  1815.   # Add Collection Commands to List
  1816.   #--------------------------------------------------------------------------
  1817.   def add_coll_commands
  1818.     $game_party.coll.sort!{|a,b| a.id <=> b.id}
  1819.     coll = $game_party.coll
  1820.     if coll.empty?
  1821.       add_command("---", :nothing)
  1822.       return
  1823.     end
  1824.     hash = {}
  1825.     for skill in coll
  1826.       next unless match_filter?(skill)
  1827.       if hash.has_key?(skill.id)
  1828.         hash[skill.id] += 1
  1829.       else
  1830.         hash[skill.id] = 1
  1831.       end
  1832.     end
  1833.     hash.each_key do |id|
  1834.       add_command(hash[id].to_s + "x " + $data_skills[id].name, ("coll" + id.to_s).to_sym)
  1835.     end
  1836.   end
  1837.  
  1838.   #--------------------------------------------------------------------------
  1839.   # Checks if a card meets the specified filter criteria
  1840.   #--------------------------------------------------------------------------
  1841.   def match_filter?(skill)
  1842.     return false unless skill.damage.element_id  == @filter[0] || @filter[0] == 0
  1843.     return false unless skill.type        == @filter[1] || @filter[1] == 0
  1844.     return false unless skill.rarity      == @filter[2] || @filter[2] == 0
  1845.     return true
  1846.   end
  1847.  
  1848.  
  1849.   #--------------------------------------------------------------------------
  1850.   # Get Window Height
  1851.   #--------------------------------------------------------------------------
  1852.   def window_height
  1853.     Graphics.height - 64
  1854.   end
  1855.  
  1856.   #--------------------------------------------------------------------------
  1857.   # Get Window width
  1858.   #--------------------------------------------------------------------------
  1859.   def window_width
  1860.     (Graphics.width - 210) * 0.5
  1861.   end
  1862.  
  1863.   def process_ok
  1864.     if current_item_enabled?
  1865.       Input.update
  1866.       call_ok_handler
  1867.       select(index - 1) unless current_symbol
  1868.     else
  1869.       Sound.play_buzzer
  1870.     end
  1871.   end
  1872.  
  1873. end
  1874.  
  1875.  
  1876. class Window_Filter < Window_Command
  1877.   include PC27::CG
  1878.  
  1879.   attr_accessor :filter
  1880.  
  1881.   def initialize(width, heigth)
  1882.     @filter = [0,0,0]
  1883.     super(width, heigth)
  1884.     hide
  1885.   end
  1886.    
  1887.   #--------------------------------------------------------------------------
  1888.   # Makes Command List
  1889.   #--------------------------------------------------------------------------
  1890.   def make_command_list
  1891.     add_filter_commands
  1892.   end
  1893.  
  1894.   #--------------------------------------------------------------------------
  1895.   # Add Collection Commands to List
  1896.   #--------------------------------------------------------------------------
  1897.   def add_filter_commands
  1898.     add_command(FILTER_TEXT + F_ELEMENT + (@filter[0]==0 ? "---" : $data_system.elements[@filter[0]] ), :filter_element)
  1899.     add_command(FILTER_TEXT + F_TYPE    + (@filter[1]==0 ? "---" : TYPE[@filter[1]]),        :filter_type)
  1900.     add_command(FILTER_TEXT + F_RARITY  + (@filter[2]==0 ? "---" : RARITY[@filter[2]][1]),   :filter_rarity)
  1901.   end
  1902.  
  1903.   #--------------------------------------------------------------------------
  1904.   # Get Window Height
  1905.   #--------------------------------------------------------------------------
  1906.   def window_height
  1907.     96
  1908.   end
  1909.   #--------------------------------------------------------------------------
  1910.   # Get Window width
  1911.   #--------------------------------------------------------------------------
  1912.   def window_width
  1913.     Graphics.width
  1914.   end
  1915.  
  1916.   def process_ok
  1917.     if current_item_enabled?
  1918.       RPG::SE.new("Cursor1", 80, 100)
  1919.       Input.update
  1920.       call_ok_handler
  1921.     else
  1922.       Sound.play_buzzer
  1923.     end
  1924.   end
  1925.  
  1926. end
  1927.  
  1928.  
  1929. class Window_MenuCommand < Window_Command
  1930.  
  1931.   #--------------------------------------------------------------------------
  1932.   # Replaces skills with Deck (overwrite)
  1933.   #--------------------------------------------------------------------------
  1934.  
  1935.   def add_main_commands
  1936.     add_command(Vocab::item,    :item,   main_commands_enabled)
  1937.     add_command(PC27::CG::DECK, :deck,   main_commands_enabled)
  1938.     add_command(Vocab::equip,   :equip,  main_commands_enabled)
  1939.     add_command(Vocab::status,  :status, main_commands_enabled)
  1940.   end
  1941.  
  1942. end
  1943.  
  1944.  
  1945. class Scene_Menu < Scene_MenuBase  
  1946.  
  1947.   #--------------------------------------------------------------------------
  1948.   # Adds a handler to access the deck scene (alias)
  1949.   #--------------------------------------------------------------------------
  1950.   alias pc27_cardgame_scenemenu_create_cmd_wdw             create_command_window
  1951.   def create_command_window
  1952.     pc27_cardgame_scenemenu_create_cmd_wdw
  1953.     @command_window.set_handler(:deck,    method(:command_personal))
  1954.   end
  1955.  
  1956.  
  1957.   #--------------------------------------------------------------------------
  1958.   # Adds :deck to the personal command process (alias)
  1959.   #--------------------------------------------------------------------------
  1960.   alias pc27_cardgame_scenemenu_on_personal_ok                    on_personal_ok
  1961.   def on_personal_ok
  1962.     pc27_cardgame_scenemenu_on_personal_ok
  1963.     case @command_window.current_symbol
  1964.     when :deck
  1965.       SceneManager.call(Scene_Deck)
  1966.     end
  1967.   end
  1968.  
  1969. end
  1970.  
  1971. ################################################################################
  1972. #                            End of script                                     #
  1973. ################################################################################
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement