Mattsuharu1991

Card Game Script updated by Matt

Jul 31st, 2022 (edited)
287
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 110.53 KB | None | 0 0
  1. ##=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  2. #                           CARDGAME SKILL/BATTLE SYSTEM
  3. #                               Author: pencilcase27
  4. #                               Version:       v1.09
  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. # v1.05 - bugfixes
  21. # v1.06 - added initial decks for actors
  22. # v1.07 - fixed a bug with item canceling
  23. #       - fixed a bug with the draw card effect
  24. # v1.08 - added Attack and Guard command
  25. #       - added two notetags for equip
  26. # v1.09 - fixed an issue with attack and guard
  27. #       - added limitations on how many cards can be played each turn
  28. #       - added a feature to instantly empty your deck
  29. #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  30. #
  31. #                                  Description
  32. #
  33. # This script changes the way actors aquire and use skills. Instead of each
  34. # actor having an own set of skills, the party now has a card collection of
  35. # different cards, each card representing a skill. Out of this collection, each
  36. # actor can now create a custom deck.
  37. # In battle, actors will act in turns. They draw cards and, while an actor is
  38. # active, he can play as many cards and items as he wants, as long as he has
  39. # the recources to do so. Once he is done, he can end his turn and the next
  40. # actor becomes active. When every actor finished his or her turn, the enemys
  41. # use their skills normal.
  42. #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  43. #
  44. #                                  Script Calls
  45. #
  46. # add_card_to_coll(id1, id2, id3, ...)
  47. # Adds cards of the given skill ids to your collection
  48. #
  49. # remove_card?(id)
  50. # Tries to remove a single card of the given skill id from your collection.
  51. # Returns true if successfull and false otherwise.
  52. #
  53. # remove_all_cards(id1, id2, ...)
  54. # Removes all cards of the given skill ids from both the players decks and
  55. # from the collection
  56. #
  57. # has_card?(id)
  58. # Checks if the player has a specific card in his collection or in his deck
  59. #
  60. # has_card_in_deck?(id)
  61. # Checks if the player has a specific card in his deck
  62. #
  63. # has_card_in_grave?(id)
  64. # Checks if the player has a specific card in his graveyard
  65. #
  66. # has_x_cards_in_grave?(id, count)
  67. # Checks if the player has a specific cards in his graveyard
  68. #
  69. # has_card_in_banish?(id)
  70. # Checks if the player has a specific card in his banish
  71. #
  72. # has_x_cards_in_banish?(id, count)
  73. # Checks if the player has a specific cards in his banish
  74. #
  75. # has_card_in_hand?(id)
  76. # Checks if the player has a specific card in his hand
  77. #
  78. # add_card_deck(id1, id2, id3, ...)
  79. # Adds cards of the given skill ids to the designed actor deck
  80. #
  81. # remove_card_deck(id1, id2, id3, ...)
  82. # Remove cards of the given skill ids to the designed actor deck
  83. #
  84. # add_card_hand(id1, id2, id3, ...)
  85. # Adds cards of the given skill ids to the designed actor hand
  86. #
  87. # remove_card_hand(id1, id2, id3, ...)
  88. # Remove cards of the given skill ids to the designed actor hand
  89. #
  90. # count_actor_deck(id)
  91. # Returns the amount of cards in this actors deck
  92. #
  93. # count_all_decks
  94. # Returns the combined deck size of all actors
  95. #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  96. #
  97. #                                Skill Notetags
  98. #
  99. #           <card id: x>
  100. # The card id of the skill. Each card must have a unique id.
  101. # Important: Every time this script uses the word id, it refers to the skills
  102. # id, not the card id! The card id is only used to sort cards.
  103. #
  104. #           <card type: x>
  105. # The type of the card. Different types can be defined below.
  106. #
  107. #           <card rarity: x>
  108. # The rarity of the card. Different raritys can be defined below.
  109. #
  110. #           <card cost: effect_name>
  111. # Adds the given cost effect to the card. Please read about card effects
  112. # down below.
  113. #
  114. #           <card impact: effect_name>
  115. # Adds the given impact effect to the card. Please read about card effects
  116. # down below.
  117. #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  118. #
  119. #                             Armor/Weapon Notetags
  120. #
  121. #           <extra start cards: x>
  122. # Draws x extra cards at the begin of each battle
  123. #
  124. #           <extra turn cards: x>
  125. # Draws x extra cards at the begin of each turn
  126. #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  127. #
  128. #                                Damage Formula
  129. #
  130. # Those commands can be used for a skills damage formula. Make sure they
  131. # always target an actor, since they won't have any effect on enemys. Minor
  132. # scripting knowlegde is required to make the most out of those methods.
  133. #
  134. # a/b.revive_grave(true/false)  
  135. # Shuffles your grave in your deck without penalty. If the argumet is true,
  136. # a message will be shown.
  137. #
  138. # a/b.revive_penalty
  139. # Causes the revive penalty to happen.
  140. #
  141. # a/b.shuffle_deck(true/false)
  142. # Shuffles the actors deck. If the argument is true, a sound will be played.
  143. #
  144. # a/b.card_to_grave?(skill_id)
  145. # Tries to throw the skill with the given ID to the grave. Returns true, if it's
  146. # successfull and false otherwise.
  147. #
  148. # a/b.throw_cards(n)
  149. # Throws n random cards to the grave. If n = 0, the actor will loose all cards.
  150. # Returns how many cards were thrown away.
  151. #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  152. #
  153. #                                Card Effects
  154. #
  155. # Card effects are special, card related effects like "draw x cards" or
  156. # "discard a fire spell to play this card" or "look at the top 5 cards of your
  157. # deck and put them back in any order". Every card effect can be played both as
  158. # a card cost or as a card impact. Costs are handled before the player plays the
  159. # cards, impacts after.
  160. # To set up a card effect, scroll to the end of Options where you will find an
  161. # option called CARD_EFFECT. There you can add a effect name and the effects
  162. # arguments. Then add the effect either as cost or as impact via note tag to
  163. # a skill.
  164. # Each skill can have one cost effect and one impact effect.
  165. # Each item can have one impact effect.
  166. # WARNING: This is not trivial. Read carefully!
  167. #
  168. # Type: Draw
  169. # Simply draws cards
  170. # "effect_name" => [:draw, a, b, c]
  171. # a -> how many cards do you want to draw?
  172. # b -> chance the effect is successfull (between 0 and 100)
  173. # c -> :self to make only the user draw a card, :target to apply the effect to
  174. #      each target.
  175. # Example:
  176. # "draw2" => [:draw, 2, 100, :self]
  177. # -> The user of this skill will draw 2 cards.
  178. #
  179. # Type: View (impact only)
  180. # Looks at a certain number of cards taken from location a, and then puts them
  181. # back to location b. Locations can be :deck, :hand and :grave.
  182. # "effect_name" => [ :view, a, b, c]
  183. # a -> how many cards do you want to view? 0 for the entire location.
  184. # b -> from where do you want to take those cards?
  185. # c -> where do you want to put them when you're done?
  186. # Example:
  187. # "view_effect" => [:view, 10, :deck, :deck]
  188. # -> look at the top 10 cards of your deck.
  189. #
  190. # Type: Sort
  191. # Same as view but allows to sort the cards.
  192. # Example:
  193. # "stupid_effect" => [:sort, 0, :hand, :deck]
  194. # -> Put your entire hand ontop of your deck in any order.
  195. #
  196. # Type: Take
  197. # This one is a little bit harder. It allows to take some of the viewed cards
  198. # from one location to another.
  199. # "effect_name" => [:take, a, b, c, d, e, f]
  200. # a, b, c -> same as above
  201. # d -> filter that determines which cards can be choosen,
  202. #      [element_id, type_id, rarity_id], 0 for all id's allowed.
  203. # e -> the location to put the choosen cards.
  204. # f -> how many cards can be choosen.
  205. # Example:
  206. # "search_for_element2" => [:take, 0, :deck, :deck, [2,0,0], :hand, 1]
  207. # -> Search your deck for one card of element 2 and take it to your hand.
  208. # Another Example:
  209. # "discard_cost" => [:take, 0, :hand, :hand, [0,0,0], :grave, 2]
  210. # -> If this is added as a cost effect, the player has to discard two cards
  211. #    from his or her hand to play this card.
  212. #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  213. module PC27
  214.   module CG
  215. #-------------------------------------------------------------------------------
  216. #
  217. #                                   Options
  218. #
  219. #-------------------------------------------------------------------------------
  220.  
  221.  
  222.  #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  223.  #                                   Vocab
  224.  #------------------------------------------------------------------------------
  225.  # DECK             - Name of the actors Deck
  226.  # GRAVE            - Name of the actors Grave
  227.  # COLLECTION       - Name of the Card Collection
  228.  # END_TURN         - Name of the command that will end a players turn
  229.  # DRAW_MESSAGE     - Text that appears when an actor draws a card. Displayed
  230.  #                    as "Actor Name" + DRAW_MESSAGE + "Skill Name"
  231.  # REVIVE_MSG       - Text that appears when you revive your grave
  232.  # CARD_HELP_WINDOW - Help text shown in the deck scene (Use \n to break line)
  233.  # FILTER_TEXT      - First part of the text inside of the filter window
  234.  # F_...            - Second part of the text inside of the filter window
  235.  # EMPTY_DECK       - Text in filter window that allows to empty the entire deck
  236.  # CONFIRM          - Confirmation for EMPTY_DECK
  237.  # CARD_EFF_TEXT    - Text displayed when a card effect is evaluated.
  238.  #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  239.   DECK              = "Deck"
  240.   GRAVE             = "Grave"
  241.   BANISH            = "Banish"
  242.   EXTRA             = "Extra"
  243.   FIELD             = "Field"
  244.   COLLECTION        = "Collection"
  245.   END_TURN          = "End"
  246.   DRAW_MESSAGE      = "draws:"
  247.   REVIVE_MSG        = "'s deck was restored!"
  248.   CARD_HELP_WINDOW  = "(Z): Move card\n(A): Open filter\n(Shift): Change to\nExtra Deck"
  249.   FILTER_TEXT       = "Filter by "
  250.   F_ELEMENT         = "Attribute: "
  251.   F_TYPE            = "Type:    "
  252.   F_RARITY          = "Rarity:  "
  253.   F_SUBTYPE         = "Sub Type:  "
  254.   F_LEVEL           = "Level:  "
  255.   EMPTY_DECK        = "Clean Deck"
  256.   CONFIRM           = "Are you sure?"
  257.   CARD_EFF_TEXT     = "Choose the cards:"
  258.  
  259.  
  260.  #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  261.  #                                  Gameplay
  262.  #------------------------------------------------------------------------------
  263.  # USE_ATTACK       - Enables the regular attack command in battle.
  264.  # USE_GUARD        - Enables the regular guard command in battle.
  265.  # USE_ITEMS        - Are items in battle enabeld?
  266.  # START_CARDS      - Cards drawn in Turn 1
  267.  # MAX_DECK_SIZE    - Maximum size of a players deck
  268.  # MAX_SAME_CARDS   - Maximum amount of same cards in each deck
  269.  # MAX_ACTIONS      - Maximum amount of cards an actor can use each turn
  270.  # DECK_EMPTY       - What happens if an actor tries to draw a card but has an
  271.  #                    empty deck?
  272.  #                    1 -> The actor dies
  273.  #                    2 -> The actor dies if his grave is empty, too. If it
  274.  #                         isn't, he revives his grave, meaning he shuffles his
  275.  #                         grave back into his deck. Revive penalty is applied
  276.  #                    3 -> Like 2, but the actor won't die if the grave is empty
  277.  # REVIVE_PENALTY   - The revive penalty. Types are :hp, :mhp, :mp and :mmp.
  278.  #                    The actor will lose either hp or mp, based on its current
  279.  #                    or maximum value
  280.  # MAX_SAME_EXCEP   - Exceptions to MAX_SAME_CARDS
  281.  #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  282.   USE_ATTACK        = true
  283.   USE_GUARD         = true
  284.   USE_ITEMS         = true
  285.   START_CARDS       = 5
  286.   MONSTER_ZONE_COUNT = 3
  287.   SPELL_TRAP_ZONE_COUNT = 3
  288.   MAX_DECK_SIZE     = 60
  289.   MIN_DECK_SIZE     = 39
  290.   MAX_EXTRA_SIZE    = 15
  291.   MAX_SAME_CARDS    = 3
  292.   MAX_ACTIONS       = 0  # if this is 0, an actor can play infinite cards
  293.                          # (until he's out of mana or cards)
  294.   DECK_EMPTY        = 1
  295.  
  296.  #                    [percent, type]
  297.   REVIVE_PENALTY    = [     50,  :hp]
  298.  
  299.   MAX_SAME_EXCEP    = {
  300.  #                    skill id => max. amount,
  301.                             67 => 1,
  302.                             45 => 1,
  303.                             #7 => 1,
  304.   } # do not remove this
  305.  
  306.  
  307.  #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  308.  #                              Icons and Sound
  309.  #------------------------------------------------------------------------------
  310.  # DRAW_SOUND       - Sound that will play when you draw a card
  311.  # PENALTY_SOUND    - Sound that will play when the revive penalty is applied
  312.  # DECK_ICON        - Icon that displays an actors deck size in battle
  313.  #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  314.  #                    ["filename", volume, pitch]  -> ["", 0, 0] means no sound
  315.   DRAW_SOUND        = [   "draw",    100,   150]
  316.   PENALTY_SOUND     = [ "Attack1",    100,    50]
  317.   DECK_ICON         = 804
  318.  
  319.  
  320.  #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  321.  #                                   Cards
  322.  #------------------------------------------------------------------------------
  323.  # To add custom card images, add an image with the name Card + skill id to your
  324.  # graphics folder (example: Card2). The script will use every picture it can
  325.  # find. Card0 is used when no card is selected. If you choose to do this, most
  326.  # of those options are irrelevant.
  327.  #
  328.  # CUSTOM_CARD_BG   - Name of the windowskin used for cards (in Graphics/System)
  329.  # CARD_BACK_OP     - Background opacity of cards (0-255)
  330.  # CARD_NAME_UP     - If true, card names will be written in capital letters
  331.  # MP_COLOR         - Textcolor the mana costs are drawn in
  332.  # TP_COLOR         - Textcolor the tp costs are drawn in
  333.  # RARITY           - Name and icon index of the raritys your cards have
  334.  # TYPES            - Different types your cards can have
  335.  # ELEMENT_COLOR    - Background color of your cards based on their element ID
  336.  #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  337.   CUSTOM_CARD_BG    = "Window"   # RPG Maker default is "Window"
  338.   CARD_BACK_OP      = 255
  339.   CARD_NAME_UP      = true
  340.   MP_COLOR          = 4
  341.   TP_COLOR          = 3
  342.  
  343.   RARITY = {
  344.  #      ID => [ icon,     "name"]
  345.          1 => [  798,   "Normal"],
  346.          2 => [  797,   "Rare"],
  347.          3 => [  796,   "Super Rare"],
  348.          4 => [  795,   "Ultra Rare"],
  349.   } # do not remove this
  350.  
  351.   SUBTYPE = {
  352.  #      ID => [ icon,     "name"]
  353.          1 =>  [  896,  "Dragon"],
  354.          2 =>  [  897,  "Zombie"],
  355.          3 =>  [  898,  "Fiend"],
  356.          4 =>  [  899,  "Pyro"],
  357.          5 =>  [  900,  "Sea-Serpent"],
  358.          6 =>  [  901,  "Rock"],
  359.          7 =>  [  902,  "Machine"],
  360.          8 =>  [  903,  "Fish"],
  361.          9 =>  [  904,  "Dinosaur"],
  362.          10 => [  905,  "Insect"],
  363.          11 => [  906,  "Beast"],
  364.          12 => [  907,  "Beast-Warrior"],
  365.          13 => [  908,  "Plant"],
  366.          14 => [  909,  "Aqua"],
  367.          15 => [  910,  "Warrior"],
  368.          16 => [  911,  "Winged-Beast"],
  369.          17 => [  912,  "Fairy"],
  370.          18 => [  913,  "Spellcaster"],
  371.          19 => [  914,  "Thunder"],
  372.          20 => [  915,  "Reptile"],
  373.          21 => [  916,  "Psychic"],
  374.          22 => [  917,  "Wyrm"],
  375.          23 => [  918,  "Divine-Beast"],
  376.          24 => [  913,  "Normal Spell"],
  377.          25 => [  914,  "Quick-Play Spell"],
  378.          26 => [  915,  "Continuous Spell"],
  379.          27 => [  916,  "Field Spell"],
  380.          28 => [  917,  "Equip Spell"],
  381.          29 => [  918,  "Normal Trap"],
  382.          30 => [  917,  "Continuous Trap"],
  383.          31 => [  918,  "Counter Trap"],
  384.   } # do not remove this
  385.    
  386.   LEVEL = {
  387.  #      ID => [ icon,     "name"]
  388.          1  => [ 803,   "Level 1"],
  389.          2  => [ 803,   "Level 2"],
  390.          3  => [ 803,   "Level 3"],
  391.          4  => [ 803,   "Level 4"],
  392.          5  => [ 803,   "Level 5"],
  393.          6  => [ 803,   "Level 6"],
  394.          7  => [ 803,   "Level 7"],
  395.          8  => [ 803,   "Level 8"],
  396.          9  => [ 803,   "Level 9"],
  397.          10 => [ 803,   "Level 10"],
  398.          11 => [ 803,   "Level 11"],
  399.          12 => [ 803,   "Level 12"],
  400.  
  401.   } # do not remove this
  402.      
  403.   NORMEFF = {
  404.  #      ID => [ icon,     "name"]
  405.          1  => [ 803,   "None"],
  406.          2  => [ 803,   "Effect"],
  407.          3  => [ 803,   "Normal"],
  408.          
  409.   } # do not remove this
  410.  
  411.   FRAME = {
  412.  #      ID => [ icon,     "name"]
  413.          1  => [ 803,   "Fusion"],
  414.          2  => [ 803,   "Synchro"],
  415.          3  => [ 803,   "Ritual"],
  416.          4  => [ 803,   "Tuner"],
  417.          5  => [ 803,   "Token"],
  418.          6  => [ 803,   "Normal"],
  419.          7  => [ 803,   "Effect"],
  420.          
  421.   } # do not remove this
  422.  
  423.   ARCHETYPE = {
  424.  #      ID => [ icon,     "name"]
  425.          1  => [ 803,   "X-Saber"],
  426.          2  => [ 803,   "Ice Barrier"],
  427.          3  => [ 803,   "Mist Valley"],
  428.          4  => [ 803,   "Flamvell"],
  429.          5  => [ 803,   "Dragunity"],
  430.          6  => [ 803,   "Gishki"],
  431.          7  => [ 803,   "Dragunity"],
  432.          8  => [ 803,   "Jurrac"],
  433.          9  => [ 803,   "Worm"],
  434.          10 => [ 803,   "Fabled"],
  435.          11 => [ 803,   "Polymerization"],
  436.          12 => [ 803,   "Kuriboh"],
  437.  
  438.          
  439.   } # do not remove this
  440.  
  441.   SPECIAL = {
  442.  #      ID => [ icon,     "name"]
  443.          1 => [  782,   "Exodia"],
  444.          2 => [  782,   "Thunder Dragon"],
  445.          3 => [  782,   "Consonance"],
  446.          4 => [  782,   "exceptjarofavarice"],
  447.          5 => [  782,   "non-Effect"],
  448.          6 => [  782,   "Normal"],
  449.          7 => [  782,   "knowledge"],
  450.   } # do not remove this
  451.  
  452.   TYPE = {
  453.  #      ID => "name"
  454.          1 => "Spell",
  455.          2 => "Trap",
  456.          3 => "Monster",
  457.          4 => "Extra",
  458.   } # do not remove this
  459.  
  460.   ELEMENT_COLOR = {
  461.  #      ID => [red, grn, blu]
  462.          0 => [  0,   0,   0],   # 0 is used for skills without an element
  463.          1 => [200,   0, 100],
  464.          2 => [200,   0,   0],
  465.          3 => [200, 200,   0],
  466.          4 => [  0,   0, 200],
  467.          5 => [  0,   0, 200],
  468.          6 => [  0,   0, 200],
  469.          7 => [  0,   0, 200],
  470.          8 => [  0,   0, 200],
  471.          9 => [  0,   0, 200],
  472.   } # do not remove this
  473.  
  474.  #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  475.  #                              Start Decks
  476.  #------------------------------------------------------------------------------
  477.  # Those are the initial decks for each actor. If an actors id is not listed
  478.  # below, his initial deck will be empty.
  479.  #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  480.   START_DECKS = {
  481.           1 =>  [],
  482.          22 =>  [97,97,97,108,108,108,250,250,250],
  483.          12 =>  [235,235,235,237,237,237,231,231,231,232,232,232,189,189,189,21,21,21,22,22,22,23,23,23,24,24,24,25,25,25,26,26,26,27,27,27,28,28,28,29,29,29],
  484.          14 =>  [169,169,169,169,167,167,167,168,26,26,26,26,26],
  485.          6 =>   [97,97,97,108,108,108,109,109,109],
  486.          15 =>  [21,21,21,205,205,205,195,195,195,193,193,193,188,189,190,191,192],
  487.          16 =>  [186,186,186,186,186,186,186,186,186,186,186,101,101,101,112,189,190,191,192,74,74,74,193,193,193],
  488.          17 =>  [186,186,186,186,186,186,186,186,186,186,186,186,186,186,186,186,186,186,186,186,186,186,186,186,186,186,186,186,186,188,189,190,191,192,74,74,74,193,193,193],
  489.          18 =>  [186,186,186,186,186,186,186,186,186,186,186,186,186,186,193,193,193,74,74,74],
  490.          19 =>  [21,21,21,205,205,205,195,195,195,193,193,193,188,189,190,191,192],
  491.          20 =>  [186,186,186,186,186,186,186,186,186,186,186,101,101,101,112,189,190,191,192,74,74,74,193,193,193],
  492.          21 =>  [186,186,186,186,186,186,186,186,186,186,186,186,186,186,186,186,186,186,186,186,186,186,186,186,186,186,186,186,186,188,189,190,191,192,74,74,74,193,193,193],
  493.          23 =>  [186,186,186,186,186,186,186,186,186,186,186,186,186,186,193,193,193,74,74,74],
  494.          24 =>  [21,21,21,205,205,205,195,195,195,193,193,193,188,189,190,191,192],
  495.          25 =>  [186,186,186,186,186,186,186,186,186,186,186,101,101,101,112,189,190,191,192,74,74,74,193,193,193],
  496.          } # do not remove this
  497.  
  498.  #------------------------------------------------------------------------------
  499.  # The first effect called "grave" is available as a command in battle and
  500.  # usually used to view your grave. You can change this effect if you wish, but
  501.  # keep in mind that the player can use this effect as many times as he wants.
  502.  # Please add all other effects below. Do not forget that every effect needs its
  503.  # own name. You can name them however you want, as long as you dont use the
  504.  # same name twice.
  505.  #[Attritube, Type, Rarity, Subtype, Level, Normal/Effect, Frame, Archetype, ATK, DEF, Special]
  506.  #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  507.   CARD_EFFECT = {
  508.       "grave"       => [:view, 0, :grave, :grave],    # Grave command effect
  509.       "banish"      => [:view, 0, :banish, :banish],  # Banish command effect
  510.       "extra"       => [:view, 0, :extra, :extra],    # Extra command effect
  511.       "field"       => [:view, 0, :field, :field],    # Extra command effect
  512.       "draw1"       => [:draw, 1, 100, :self],
  513.       "draw2"       => [:draw, 2, 100, :self],
  514.       "draw3"       => [:draw, 3, 100, :self],
  515.       "draw4"       => [:draw, 4, 100, :self],
  516.       "draw5"       => [:draw, 5, 100, :self],
  517.       "draw6"       => [:draw, 6, 100, :self],
  518.       "exodia"      => [:take, 0, :hand, :hand,     [0,0,0,0,0,0,0,0,0,0,1], :grave, 4],
  519.       "discard1"    => [:takem, 0, :hand, :hand,    [0,0,0,0,0,0,0,0,0,0,0], :grave, 1],
  520.       "discard2"    => [:takem, 0, :hand, :hand,    [0,0,0,0,0,0,0,0,0,0,0], :grave, 2],
  521.       "discard5"    => [:take, 0, :hand, :hand,     [0,0,0,0,0,0,0,0,0,0,0], :grave, 5],
  522.       "discardlv9"  => [:take, 0, :hand, :hand,     [0,0,0,0,9,0,0,0,0,0,0], :grave, 1],
  523.       "discardhand" => [:takem, 0, :hand, :hand,    [0,0,0,0,0,0,0,0,0,0,0], :grave, 0],
  524.       "disc1monst"  => [:take, 0, :hand, :hand,     [0,3,0,0,0,0,0,0,0,0,0], :grave, 1],
  525.       "disc3monst"  => [:take, 0, :hand, :hand,     [0,3,0,0,0,0,0,0,0,0,0], :grave, 3],
  526.       "beginning"   => [:take, 0, :grave,:grave,    [5,0,0,0,0,0,0,0,0,0,0], :banish, 5],
  527.       "allureres"   => [:takem, 0, :hand, :hand,    [5,0,0,0,0,0,0,0,0,0,0], :banish, 1],
  528.       "avarice"     => [:take, 0, :grave, :grave,   [0,3,0,0,0,0,0,0,0,0,0], :deck, 5],
  529.       "shuffle1"    => [:take, 0, :hand, :hand,     [0,0,0,0,0,0,0,0,0,0,0], :deck, 1],
  530.       "jaravarice"  => [:take, 0, :grave, :grave,   [0,0,0,0,0,0,0,0,0,0,[*0..3, *5..99]], :deck, 5],
  531.       "moray"       => [:take, 0, :hand, :hand,     [4,3,0,0,0,0,0,0,0,0,0], :deck, 2],
  532.       "duality"     => [:takem, 3, :deck, :deck,    [0,0,0,0,0,0,0,0,0,0,0], :hand, 1],
  533.       "prosperity"  => [:takem, 6, :deck, :deck,    [0,0,0,0,0,0,0,0,0,0,0], :hand, 1],
  534.       "discardlv8"  => [:take, 0, :hand, :hand,     [0,0,0,0,8,0,0,0,0,0,0], :grave, 1],
  535.       "consonance"  => [:take, 0, :hand, :hand,     [0,3,0,1,0,0,4,0,0..1000,0,0], :grave, 1],
  536.       "addlv1"      => [:takem, 0, :deck,:deck,     [0,3,0,0,1,0,0,0,0,0,0], :hand, 1],
  537.       "teleport"    => [:take, 0, :deck,:deck,      [0,3,0,21,1..3,0,0,0,0,0,0], :hand, 1],
  538.       "desires"     => [:takem, 10, :deck,:deck,    [0,0,0,0,0,0,0,0,0,0,0], :banish, 10],
  539.       "acqui"       => [:take, 0, :banish, :banish, [0,3,0,0,0,0,0,0,0,0,0], :deck, 3],
  540.       "banishlv7"   => [:take, 0, :hand, :hand,     [0,3,0,0,7,0,0,0,0,0,0], :banish, 1],
  541.       "elephant"    => [:take, 0, :hand, :hand,     [0,3,0,0,0,3,0,0,0,0,0], :grave, 1],
  542.   "banish1normal"   => [:take, 0, :hand, :hand,     [0,3,0,0,0,3,0,0,0,0,0], :banish, 1],
  543.       "knowledge"   => [:take, 0, :hand, :hand,     [0,3,0,18,0,0,0,0,0,0,0], :grave, 1],
  544.       "brightf"     => [:take, 0, :banish, :banish, [0,0,3,21,0,0,0,0,0,0,0], :grave, 2],
  545.       "overload"    => [:take, 0, :grave, :grave,   [0,0,0,21,0,0,0,0,0,0,0], :deck, 3],
  546.       "backup"      => [:take, 0, :grave, :grave,   [0,0,0,0,0,3,0,0,0,0,0], :hand, 3],
  547.       "addpoly"     => [:take, 0, :deck, :deck,     [0,0,0,0,0,0,0,11,0,0,0], :hand, 1],
  548.       "miracledig"  => [:take, 0, :banish, :banish, [0,3,0,0,0,0,0,0,0,0,0], :grave, 3],
  549.       "kuriboh"     => [:take, 0, :hand, :hand,     [0,3,0,0,0,0,0,12,0,0,0], :grave, 1],
  550.       "release"     => [:takem, 0, :grave, :grave,  [0,0,0,0,0,0,0,0,0,0,0], :banish, 5],
  551.       "fossildig"   => [:take, 0, :deck, :deck,     [0,3,0,9,1..6,0,0,0,0,0,0], :hand, 1],
  552.       "lightload"   => [:takem, 0, :hand, :hand,    [0,3,0,0,7..12,0,0,0,0,0,0], :deck, 1],
  553.     "foolishburial" => [:take, 0, :deck, :deck,     [0,3,0,0,0,0,0,0,0,0,0], :grave, 1],
  554.       "banish1wb"   => [:take, 0, :deck, :deck,     [0,3,0,11,0,0,0,0,0,0,0], :banish, 1],
  555.       "banish1b"    => [:take, 0, :deck, :deck,     [0,3,0,16,0,0,0,0,0,0,0], :banish, 1],
  556.       "rota"        => [:take, 0, :deck, :deck,     [0,3,0,15,1..4,0,0,0,0,0,0], :hand, 1],
  557.     "reincarnation" => [:take, 0, :grave, :grave,   [0,3,0,0,0,0,0,0,0,0,0], :hand, 1],
  558.     "throwextra"    => [:take, 0, :extra, :extra,   [0,0,0,0,0,0,0,0,0,0,0], :grave, 1],
  559.     "prosp3"        => [:take, 0, :extra, :extra,   [0,0,0,0,0,0,0,0,0,0,0], :banish, 3],
  560.     "prosp6"        => [:take, 0, :extra, :extra,   [0,0,0,0,0,0,0,0,0,0,0], :banish, 6],
  561.     "bombardment"   => [:take, 0, :deck, :deck,     [0,3,0,6,0,0,0,0,0,0,0], :grave, 1],
  562.      
  563.   } # do not remove this
  564.  
  565. #-------------------------------------------------------------------------------
  566. #
  567. #                                 End Options
  568. #
  569. #-------------------------------------------------------------------------------
  570.  
  571.   end #CG
  572. end #PC27
  573.  
  574. ################################################################################
  575. #                          Start of script                                     #
  576. ################################################################################
  577.  
  578. $imported = {} if $imported.nil?
  579. $imported["PC27: CardGame System"] = true
  580.  
  581. #===============================================================================
  582. # Load notetags
  583. #===============================================================================
  584.  
  585. module DataManager
  586.  
  587.   class <<self; alias load_database_pc27_cardgame load_database; end
  588.    
  589.   def self.load_database
  590.     load_database_pc27_cardgame
  591.     load_notetags_pc27_cardgame
  592.   end
  593.  
  594.   def self.load_notetags_pc27_cardgame
  595.     for skill in $data_skills
  596.       next if skill.nil?
  597.       skill.load_notetags_pc27_cardgame_skill
  598.     end
  599.     for item in $data_items
  600.       next if item.nil?
  601.       item.load_notetags_pc27_cardgame_item
  602.     end
  603.     for state in $data_states
  604.       next if state.nil?
  605.       state.load_notetags_pc27_cardgame_states
  606.     end
  607.     for equip_type in [$data_weapons, $data_armors]
  608.       for obj in equip_type
  609.         next if obj.nil?
  610.         obj.load_notetags_pc27_cardgame_equip
  611.       end
  612.     end
  613.    
  614.   end
  615.  
  616. end
  617.  
  618. class RPG::UsableItem < RPG::BaseItem
  619.   attr_accessor :card_id
  620.   attr_accessor :type
  621.   attr_accessor :rarity
  622.   attr_accessor :subtype
  623.   attr_accessor :level
  624.   attr_accessor :normeff
  625.   attr_accessor :frame
  626.   attr_accessor :archetype
  627.   attr_accessor :atk
  628.   attr_accessor :def
  629.   attr_accessor :special
  630.   attr_accessor :cost
  631.   attr_accessor :impact
  632.  
  633.  
  634.   #-----------------------------------------------------------------------------
  635.   # Add card attributes
  636.   #-----------------------------------------------------------------------------
  637.   def load_notetags_pc27_cardgame_skill
  638.     @description = wordwrap(@description)
  639.     @card_id = 0
  640.     @type    = 1
  641.     @rarity  = 1
  642.     @subtype = 1
  643.     @level   = 1
  644.     @normeff = 1
  645.     @frame   = 1
  646.   @archetype = 1
  647.     @atk     = 1
  648.     @def     = 1
  649.     @special = 1
  650.     @cost    = false
  651.     @impact  = false
  652.     self.note.split(/[\r\n]+/).each { |line|
  653.       if /<card[ -_]id: +(?<inr>\d+)>/i =~ line
  654.         @card_id = inr.to_i
  655.       elsif /<card[ -_]type: +(?<tnr>\d+)>/i =~ line
  656.         @type = tnr.to_i
  657.       elsif /<card[ -_]rarity: +(?<rnr>\d+)>/i =~ line
  658.         @rarity = rnr.to_i
  659.       elsif /<card[ -_]subtype: +(?<stnr>\d+)>/i =~ line
  660.         @subtype = stnr.to_i
  661.       elsif /<card[ -_]level: +(?<lvnr>\d+)>/i =~ line
  662.         @level = lvnr.to_i
  663.       elsif /<card[ -_]normeff: +(?<nenr>\d+)>/i =~ line
  664.         @normeff = nenr.to_i
  665.       elsif /<card[ -_]frame: +(?<frnr>\d+)>/i =~ line
  666.         @frame = frnr.to_i
  667.       elsif /<card[ -_]archetype: +(?<arnr>\d+)>/i =~ line
  668.         @archetype = arnr.to_i
  669.       elsif /<card[ -_]atk: +(?<atnr>\d+)>/i =~ line
  670.         @atk = atnr.to_i
  671.       elsif /<card[ -_]def: +(?<dfnr>\d+)>/i =~ line
  672.         @def = dfnr.to_i
  673.       elsif /<card[ -_]special: +(?<spnr>\d+)>/i =~ line
  674.         @special = spnr.to_i
  675.       elsif /<card[ -_]cost: +(?<cst>.+)>/i =~ line
  676.         @cost = cst
  677.       elsif /<card[ -_]impact: +(?<imp>.+)>/i =~ line
  678.         @impact = imp
  679.       end
  680.       }
  681.     end
  682.    
  683.     def load_notetags_pc27_cardgame_item
  684.       @impact = false
  685.       self.note.split(/[\r\n]+/).each { |line|
  686.         if /<card[ -_]impact: +(?<imp>.+)>/i =~ line
  687.           @impact = imp
  688.         end
  689.         }
  690.     end
  691.    
  692.   #-----------------------------------------------------------------------------
  693.   # Method to rearange text so it fits inside a window
  694.   #-----------------------------------------------------------------------------
  695.   def wordwrap(desc_text, window = nil, default_max_chars = 16)
  696.     max_chars = (window ? (window.width - 2 * window.padding) / 10 : default_max_chars)
  697.     text, line= "", ""
  698.     desc_text.split(/[\r\n ]+/).each { |word|
  699.     if word.size + line.size > max_chars
  700.       text += line+"\n"
  701.       line = word
  702.     else
  703.       line += word
  704.     end
  705.     line += " "
  706.     }
  707.     text += line
  708.     return text
  709.   end
  710.  
  711. end
  712.  
  713. class RPG::EquipItem < RPG::BaseItem
  714.   attr_accessor :extra_turn_cards
  715.   attr_accessor :extra_start_cards
  716.  
  717.   def load_notetags_pc27_cardgame_equip
  718.     @extra_turn_cards = 0
  719.     @extra_start_cards = 0
  720.     self.note.split(/[\r\n]+/).each { |line|
  721.       if /<extra[ -_]turn[ -_]cards: +(?<tnr>\d+)>/i =~ line
  722.         @extra_turn_cards = tnr.to_i
  723.       elsif /<extra[ -_]start[ -_]cards: +(?<snr>\d+)>/i =~ line
  724.         @extra_start_cards = snr.to_i
  725.       end
  726.     }
  727.   end
  728. end
  729.  
  730. class RPG::State < RPG::BaseItem
  731.   attr_reader :limited_actions
  732.  
  733.   def load_notetags_pc27_cardgame_states
  734.     @limited_actions = 0
  735.     self.note.split(/[\r\n]+/).each { |line|
  736.       if /<limited[ -_]actions: +(?<lnr>\d+)>/i =~ line
  737.         @limited_actions = lnr.to_i
  738.       end
  739.     }
  740.   end
  741. end
  742.  
  743.  
  744. #===============================================================================
  745. # Game_Interpreter
  746. #===============================================================================
  747.  
  748. class Game_Interpreter
  749.  
  750.   def add_card_to_coll(*args)
  751.     for id in args
  752.       $game_party.coll.push($data_skills[id])
  753.     end
  754.   end
  755.  
  756.   def remove_card?(id)
  757.     for i in (0...$game_party.coll.length)
  758.       if $game_party.coll[i].id == id
  759.         $game_party.coll.delete_at(i)
  760.         return true
  761.       end
  762.     end
  763.     return false
  764.   end
  765.  
  766.   def remove_all_cards(*args)
  767.     for id in args
  768.       $game_party.coll -= [$data_skills[id]]
  769.       for actor in $game_party.members
  770.         actor.deck -= [$data_skills[id]]
  771.       end
  772.     end
  773.   end
  774.  
  775.   def has_card?(id)
  776.     for card in $game_party.coll
  777.       return true if card.id == id
  778.     end
  779.     for actor in $game_party.members
  780.       for card in actor.deck
  781.         return true if card.id == id
  782.       end
  783.     end
  784.     return false
  785.   end
  786.  
  787.   def atributes_in_grave(id, count)
  788.     return true if
  789.     self.grave.count { |card| skill.damage.element_id == id} <= count
  790.   else
  791.     return false
  792.     end
  793.  
  794.   def has_card_in_deck?(id)
  795.         for card in self.deck
  796.           return true if card.id == id
  797.         end
  798.       return false
  799.     end
  800.    
  801.     def has_many_card_in_deck?(count)
  802.       return self.deck.count { |card| } >= count
  803.     end
  804.  
  805.   def has_x_cards?(id, count)
  806.     return self.deck.count { |card| card.id == id } >= count
  807.   end
  808.  
  809.     def has_card_in_hand?(id)
  810.         for card in self.hand
  811.           return true if card.id == id
  812.         end
  813.       return false
  814.     end
  815.  
  816.     def has_card_in_grave?(id)
  817.       actor = $game_actors[$game_variables[27]]
  818.         for card in actor.grave
  819.           return true if card.id == id
  820.         end
  821.       return false
  822.     end
  823.    
  824.   def has_x_cards_in_grave?(id, count)
  825.     actor = $game_actors[$game_variables[27]]
  826.     return actor.grave.count { |card| card.id == id } >= count
  827.   end
  828.  
  829.   def numinous_in_grave
  830.     nr = 0
  831.     for actor in $game_party.members
  832.       nr += actor.grave.count { |card| card.id == 29 }
  833.     end
  834.     return nr
  835.     end
  836.   end
  837.  
  838.   def has_card_in_banish?(id)
  839.       actor = $game_actors[$game_variables[27]]
  840.         for card in actor.banish
  841.           return true if card.id == id
  842.         end
  843.       return false
  844.     end
  845.    
  846.   def has_x_cards_in_banish?(id, count)
  847.     actor = $game_actors[$game_variables[27]]
  848.     return actor.banish.count { |card| card.id == id } >= count
  849.   end
  850.  
  851.   def add_card_deck(*args)
  852.     for id in args
  853.       actor = $game_actors[$game_variables[27]]
  854.       actor.deck += [$data_skills[id]]
  855.     end
  856.   end
  857.    
  858.   def remove_card_deck(*args)
  859.     for id in args
  860.       actor = $game_actors[$game_variables[27]]
  861.       actor.deck -= [$data_skills[id]]
  862.     end
  863.   end
  864.  
  865.     def add_card_hand(*args)
  866.     for id in args
  867.       self.hand += [$data_skills[id]]
  868.     end
  869.   end
  870.  
  871.   def summon_token(*args)
  872.     for id in args
  873.       self.field += [$data_skills[id]]
  874.     end
  875.   end
  876.    
  877.       def add_card_hand_2(*args)
  878.     for id in args
  879.       actor = $game_actors[$game_variables[27]]
  880.       actor.hand += [$data_skills[id]]
  881.     end
  882.   end
  883.  
  884.     def remove_card_hand(*args)
  885.     for id in args
  886.       self.hand -= [$data_skills[id]]
  887.     end
  888.   end
  889.  
  890.   def send_card_from_hand_to_grave(*args)
  891.     for id in args
  892.       actor = $game_actors[$game_variables[42]]
  893.       actor.hand -= [$data_skills[id]]
  894.       actor.grave += [$data_skills[id]]
  895.     end
  896.   end
  897.  
  898.   def send_card_from_hand_to_grave_2(id)
  899.     actor = $game_actors[$game_variables[42]]
  900.     for i in (0...actor.hand.length)
  901.       if actor.hand[i].id == id
  902.         actor.grave.push(@hand[i])
  903.         actor.hand.delete_at(i)
  904.         return true
  905.       end
  906.     end
  907.     return false
  908.   end
  909.  
  910.   def count_actor_deck(id)
  911.     return $game_actors[id].deck.size
  912.   end
  913.  
  914.   def count_all_decks
  915.     nr = 0
  916.     for actor in $game_party.members
  917.       nr += actor.deck.size
  918.     end
  919.     return nr
  920.   end
  921.  
  922. #===============================================================================
  923. # Game_Battler
  924. #===============================================================================
  925.  
  926. class Game_Battler < Game_BattlerBase
  927.  
  928.   #-----------------------------------------------------------------------------
  929.   # defines card actions for non actors, in case the user messes up
  930.   #-----------------------------------------------------------------------------
  931.   def revive_grave(show = true) ;end
  932.   def revive_penalty            ;end
  933.   def shuffle_deck(sound = true);end
  934.   def card_to_grave?(id)        ;end
  935.   def throw_cards(n)            ;end
  936.   def draw_cards(n)             ;end
  937.    
  938. end
  939.  
  940. #===============================================================================
  941. # Game_Actor
  942. #===============================================================================
  943.  
  944. class Game_Actor < Game_Battler
  945.  
  946.   #-----------------------------------------------------------------------------
  947.   # Attributes
  948.   #-----------------------------------------------------------------------------
  949.   attr_accessor :deck
  950.   attr_accessor :grave
  951.   attr_accessor :banish
  952.   attr_accessor :extra
  953.   attr_accessor :hand
  954.   attr_accessor :field
  955.   attr_accessor :monster_zones
  956.   attr_accessor :spell_trap_zones
  957.   attr_accessor :stack
  958.   attr_accessor :turn_actions
  959.  
  960.   #-----------------------------------------------------------------------------
  961.   # Adds Hand, Deck, Grave, Banish, Extra, Field and Stack to an Actor (alias)
  962.   #-----------------------------------------------------------------------------
  963.   alias pc27_cardgame_gameactor_setup                                      setup
  964.   def setup(actor_id)
  965.     pc27_cardgame_gameactor_setup(actor_id)
  966.     setup_start_deck(actor_id)
  967.     @hand   = []
  968.     @grave  = []
  969.     @banish = []
  970.     @extra  = []
  971.     @field  = []
  972.     @stack  = []
  973.     @turn_actions = { :can_attack => true,
  974.                       :can_guard  => true,
  975.                       :actions    =>    0, }
  976.   end
  977.  
  978.   #-----------------------------------------------------------------------------
  979.   # Setup for the initial deck (new)
  980.   #-----------------------------------------------------------------------------
  981.   def setup_start_deck(actor_id)
  982.     @deck  = []
  983.     if PC27::CG::START_DECKS.has_key?(actor_id)
  984.       PC27::CG::START_DECKS[actor_id].each { |card| @deck.push($data_skills[card]) }
  985.     end
  986.   end
  987.  
  988.   #-----------------------------------------------------------------------------
  989.   # Setup for the initial extra (new)
  990.   #-----------------------------------------------------------------------------
  991.   def setup_start_extra(actor_id)
  992.     @extra  = []
  993.     if PC27::CG::START_EXTRA.has_key?(actor_id)
  994.       PC27::CG::START_EXTRA[actor_id].each { |card| @extra.push($data_skills[card]) }
  995.     end
  996.   end
  997.  
  998.   #-----------------------------------------------------------------------------
  999.   # Draws n cards from the deck (new)
  1000.   #-----------------------------------------------------------------------------
  1001.   def draw_cards(n, show = true, sound = true)
  1002.     n.times do
  1003.       if @deck.length == 0
  1004.         add_state(1) if PC27::CG::DECK_EMPTY == 1
  1005.         return if PC27::CG::DECK_EMPTY == 1
  1006.         if @grave.length == 0
  1007.           add_state(1) if PC27::CG::DECK_EMPTY == 2
  1008.           return
  1009.         else
  1010.           revive_grave
  1011.           revive_penalty if PC27::CG::REVIVE_PENALTY[0] > 0
  1012.         end
  1013.       end
  1014.       RPG::SE.new(*PC27::CG::DRAW_SOUND).play and 30.times { Graphics.update; Input.update } if sound
  1015.       skill = @deck.shift
  1016.       @hand.push(skill)
  1017.       if show
  1018.         $game_message.background = 1
  1019.         $game_message.position   = 1
  1020.         text = @name + " " + PC27::CG::DRAW_MESSAGE + " " + skill.name
  1021.         $game_message.add(text)
  1022.       end
  1023.     end
  1024.   end
  1025.  
  1026.   #-----------------------------------------------------------------------------
  1027.   # Puts all cards from your grave back into your deck (new)
  1028.   #-----------------------------------------------------------------------------
  1029.   def revive_grave(show = true)
  1030.     @deck += @grave
  1031.     @grave = []
  1032.     shuffle_deck(false)
  1033.     if show
  1034.       $game_message.background = 1
  1035.       $game_message.position = 1
  1036.       text = @name + PC27::CG::REVIVE_MSG
  1037.       $game_message.add(text)
  1038.     end
  1039.   end
  1040.  
  1041.   #-----------------------------------------------------------------------------
  1042.   # Revive penalty (new)
  1043.   #-----------------------------------------------------------------------------
  1044.   def revive_penalty
  1045.     percent = PC27::CG::REVIVE_PENALTY[0] * 0.01
  1046.     case PC27::CG::REVIVE_PENALTY[1]
  1047.     when :hp
  1048.       @hp  -= (@hp  * percent).round
  1049.     when :mhp
  1050.       @hp  -= (@mhp * percent).round
  1051.     when :mp
  1052.       @mp  -= (@mp  * percent).round
  1053.     when :mmp
  1054.       @mp  -= (@mmp * percent).round
  1055.     end
  1056.     RPG::SE.new(*PC27::CG::PENALTY_SOUND).play
  1057.   end
  1058.  
  1059.   #-----------------------------------------------------------------------------
  1060.   # Shuffles the deck (new)
  1061.   #-----------------------------------------------------------------------------
  1062.   def shuffle_deck(sound = true)
  1063.     if sound
  1064.       5.times do
  1065.         RPG::SE.new(PC27::CG::DRAW_SOUND[0], 100, 150).play
  1066.         20.times { Graphics.update; Input.update }
  1067.         RPG::SE.new(PC27::CG::DRAW_SOUND[0], 100, 100).play
  1068.         10.times { Graphics.update; Input.update }
  1069.       end
  1070.     end
  1071.     @deck = @deck.shuffle
  1072.   end
  1073.  
  1074.   #-----------------------------------------------------------------------------
  1075.   # Sorts Hand, Deck or Grave (new)
  1076.   #-----------------------------------------------------------------------------
  1077.   def sort_cards(location)
  1078.     case location
  1079.     when :deck
  1080.       @deck.sort!{|a,b| a.card_id <=> b.card_id}
  1081.     when :hand
  1082.       @hand.sort!{|a,b| a.card_id <=> b.card_id}
  1083.     when :grave
  1084.       @grave.sort!{|a,b| a.card_id <=> b.card_id}
  1085.     when :banish
  1086.       @banish.sort!{|a,b| a.card_id <=> b.card_id}
  1087.     when :extra
  1088.       @extra.sort!{|a,b| a.card_id <=> b.card_id}
  1089.     when :field
  1090.       @field.sort!{|a,b| a.card_id <=> b.card_id}
  1091.     end
  1092.   end
  1093.  
  1094.   #-----------------------------------------------------------------------------
  1095.   # Tries to put a specific card from your hand to your grave (new)
  1096.   #-----------------------------------------------------------------------------
  1097.   def card_to_grave?(id)
  1098.     for i in (0...@hand.length)
  1099.       if @hand[i].id == id
  1100.         @grave.push(@hand[i])
  1101.         @hand.delete_at(i)
  1102.         return true
  1103.       end
  1104.     end
  1105.     return false
  1106.   end
  1107.  
  1108.   #-----------------------------------------------------------------------------
  1109.   # Tries to put a specific card from your deck to your grave (new)
  1110.   #-----------------------------------------------------------------------------
  1111.   def card_from_deck_to_grave?(id)
  1112.     for i in (0...@deck.length)
  1113.       if @deck[i].id == id
  1114.         @grave.push(@deck[i])
  1115.         @deck.delete_at(i)
  1116.         return true
  1117.       end
  1118.     end
  1119.     return false
  1120.   end
  1121.  
  1122.   #-----------------------------------------------------------------------------
  1123.   # Tries to put a specific card from your hand to your banish (new)
  1124.   #-----------------------------------------------------------------------------
  1125.   def card_to_banish?(id)
  1126.     for i in (0...@hand.length)
  1127.       if @hand[i].id == id
  1128.         @banish.push(@hand[i])
  1129.         @hand.delete_at(i)
  1130.         return true
  1131.       end
  1132.     end
  1133.     return false
  1134.   end
  1135.  
  1136.   #-----------------------------------------------------------------------------
  1137.   # Tries to put a specific card from your hand to your stack (new)
  1138.   #-----------------------------------------------------------------------------
  1139.   def card_to_stack?(id)
  1140.     for i in (0...@hand.length)
  1141.       if @hand[i].id == id
  1142.         @stack.push(@hand[i])
  1143.         @hand.delete_at(i)
  1144.         return true
  1145.       end
  1146.     end
  1147.     return false
  1148.   end
  1149.  
  1150.   #-----------------------------------------------------------------------------
  1151.   # Tries to put a specific card from your hand to your field (new)
  1152.   #-----------------------------------------------------------------------------
  1153.   def card_to_field?(id)
  1154.     for i in (0...@hand.length)
  1155.       if @hand[i].id == id
  1156.         @field.push(@hand[i])
  1157.         @hand.delete_at(i)
  1158.         return true
  1159.       end
  1160.     end
  1161.     return false
  1162.   end
  1163.  
  1164.   #-----------------------------------------------------------------------------
  1165.   # Puts n random cards from your hand to your grave (new)
  1166.   #-----------------------------------------------------------------------------
  1167.   def throw_cards(n)
  1168.     amount_thrown_cards = 0
  1169.     if n == 0
  1170.       amount_thrown_cards += @hand.size
  1171.       @grave += @hand
  1172.       @hand = []
  1173.     else
  1174.       n.times do
  1175.         break if @hand.size == 0
  1176.         @grave.push(@hand.slice!(rand(@hand.size-1)))
  1177.         amount_thrown_cards += 1
  1178.       end
  1179.     end
  1180.     $game_variables[46] = amount_thrown_cards
  1181.     return amount_thrown_cards
  1182.   end
  1183.  
  1184.   #-----------------------------------------------------------------------------
  1185.   # Mill n random cards from your deck to your grave (new)
  1186.   #-----------------------------------------------------------------------------
  1187.   def mill_cards(n)
  1188.     amount_mill_cards = 0
  1189.     if n == 0
  1190.       amount_mill_cards += @deck.size
  1191.       @grave += @deck
  1192.       @deck = []
  1193.     else
  1194.       n.times do
  1195.         break if @deck.size == 0
  1196.         @grave.push(@deck.slice!(rand(@deck.size-1)))
  1197.         amount_mill_cards += 1
  1198.       end
  1199.     end
  1200.    
  1201.   end
  1202.  
  1203.   #-----------------------------------------------------------------------------
  1204.   # Puts n random cards from your hand to your banish (new)
  1205.   #-----------------------------------------------------------------------------
  1206.   def banish_cards(n)
  1207.     amount_banish_cards = 0
  1208.     if n == 0
  1209.       amount_banish_cards += @hand.size
  1210.       @banish += @hand
  1211.       @hand = []
  1212.     else
  1213.       n.times do
  1214.         break if @hand.size == 0
  1215.         @banish.push(@hand.slice!(rand(@hand.size-1)))
  1216.         amount_banish_cards += 1
  1217.       end
  1218.     end
  1219.     $game_variables[51] = amount_banish_cards
  1220.     return amount_banish_cards
  1221.   end
  1222.  
  1223.   #-----------------------------------------------------------------------------
  1224.   # Mill n random cards from your deck to your banish (new)
  1225.   #-----------------------------------------------------------------------------
  1226.   def mill_banish_cards(n)
  1227.     amount_mill_banish_cards = 0
  1228.     if n == 0
  1229.       amount_mill_banish_cards += @deck.size
  1230.       @banish += @deck
  1231.       @deck = []
  1232.     else
  1233.       n.times do
  1234.         break if @deck.size == 0
  1235.         @banish.push(@deck.slice!(rand(@deck.size-1)))
  1236.         amount_mill_banish_cards += 1
  1237.       end
  1238.     end
  1239.   end
  1240.  
  1241.   #-----------------------------------------------------------------------------
  1242.   # Banish n random cards from your extra (new)
  1243.   #-----------------------------------------------------------------------------
  1244.   def banish_extra_cards(n)
  1245.     amount_banish_extra_cards = 0
  1246.     if n == 0
  1247.       amount_banish_extra_cards += @extra.size
  1248.       @banish += @extra
  1249.       @extra = []
  1250.     else
  1251.       n.times do
  1252.         break if @extra.size == 0
  1253.         @banish.push(@extra.slice!(rand(@extra.size-1)))
  1254.         amount_banish_extra_cards += 1
  1255.       end
  1256.     end
  1257.   end
  1258.  
  1259.   #-----------------------------------------------------------------------------
  1260.   # Shuffles Deck and draws cards at the begin of each battle (new)
  1261.   #-----------------------------------------------------------------------------
  1262.   def on_battle_start
  1263.     super()
  1264.     shuffle_deck(false)
  1265.     draw_cards(starting_cards, false, false)
  1266.     @turn_actions[:can_attack] = true
  1267.     @turn_actions[:can_guard]  = true
  1268.     @turn_actions[:actions]    = available_actions
  1269.   end
  1270.  
  1271.   #-----------------------------------------------------------------------------
  1272.   # Starting Cards (new)
  1273.   #-----------------------------------------------------------------------------
  1274.   def starting_cards
  1275.     x = PC27::CG::START_CARDS
  1276.     @equips.each { |equip|
  1277.       next unless equip
  1278.       next unless equip.object
  1279.       x += equip.object.extra_start_cards
  1280.     }
  1281.     return x
  1282.   end
  1283.  
  1284.   #-----------------------------------------------------------------------------
  1285.   # Draws a card at the end of each turn (new)
  1286.   #-----------------------------------------------------------------------------
  1287.   def on_turn_end
  1288.     super()
  1289.     if $game_party.in_battle && !death_state?
  1290.       draw_cards(turn_cards, false, true)
  1291.       @turn_actions[:can_attack] = true
  1292.       @turn_actions[:can_guard]  = true
  1293.       @turn_actions[:actions]    = available_actions
  1294.     end
  1295.   end
  1296.  
  1297.   #-----------------------------------------------------------------------------
  1298.   # Determines the amount of actions an actor can make (new)
  1299.   #-----------------------------------------------------------------------------
  1300.   def available_actions
  1301.     for id in @states
  1302.       state = $data_states[id]
  1303.       if state.limited_actions != 0
  1304.         x = state.limited_actions if x.nil? || x > state.limited_actions
  1305.       end
  1306.     end
  1307.     if PC27::CG::MAX_ACTIONS <= 0
  1308.       return (x ? x : -1)
  1309.     else
  1310.       return (x ? [x, PC27::CG::MAX_ACTIONS].min : PC27::CG::MAX_ACTIONS)
  1311.     end
  1312.   end
  1313.  
  1314.   #-----------------------------------------------------------------------------
  1315.   # Turn Cards(new)
  1316.   #-----------------------------------------------------------------------------
  1317.   def turn_cards
  1318.     x = 1
  1319.     if state?(82)
  1320.       x = 0
  1321.       end
  1322.     @equips.each { |equip|
  1323.       next unless equip
  1324.       next unless equip.object
  1325.       x += equip.object.extra_turn_cards
  1326.       if state?(82)
  1327.       x = 0
  1328.       end
  1329.     }
  1330.     return x
  1331.   end
  1332.  
  1333.   #-----------------------------------------------------------------------------
  1334.   # Restore deck at the end of battle (new)
  1335.   #-----------------------------------------------------------------------------
  1336.   def on_battle_end
  1337.     @deck += @hand + @grave + @banish + @field
  1338.     @deck.select! { |card| card.frame != 5 }
  1339.     @deck.select! { |card| card.type != 4 }
  1340.     @extra += @hand + @grave + @banish + @field
  1341.     @extra.select! { |card| card.type == 4 }
  1342.     @hand, @grave, @banish, @field = [],[],[],[]
  1343.     super()
  1344.     end
  1345.  
  1346.   #--------------------------------------------------------------------------
  1347.   # * Determine Usability of Attack
  1348.   #--------------------------------------------------------------------------
  1349.   def attack_usable?
  1350.     super && @turn_actions[:can_attack]
  1351.   end
  1352.  
  1353.   #--------------------------------------------------------------------------
  1354.   # * Determine Usability of Guard
  1355.   #--------------------------------------------------------------------------
  1356.   def guard_usable?
  1357.     super && @turn_actions[:can_guard]
  1358.   end
  1359.  
  1360. end
  1361.  
  1362. #===============================================================================
  1363. # Game_Party
  1364. #===============================================================================
  1365.  
  1366. class Game_Party < Game_Unit
  1367.  
  1368.   #-----------------------------------------------------------------------------
  1369.   # Attributes
  1370.   #-----------------------------------------------------------------------------
  1371.   attr_accessor :coll
  1372.    
  1373.   #-----------------------------------------------------------------------------
  1374.   # Adds a card collection to the party (alias)
  1375.   #-----------------------------------------------------------------------------
  1376.   alias pc27_gameparty_initialize                                     initialize
  1377.   def initialize
  1378.     pc27_gameparty_initialize
  1379.     @coll = []
  1380.   end
  1381.  
  1382. end
  1383.  
  1384. #===============================================================================
  1385. # Window_SkillList
  1386. #===============================================================================
  1387.  
  1388. class Window_SkillList < Window_Selectable
  1389.  
  1390.   #--------------------------------------------------------------------------
  1391.   # Make skill list from @hand, not from @skills (overwrite)
  1392.   #--------------------------------------------------------------------------
  1393.   def make_item_list
  1394.     @actor.sort_cards(:hand)
  1395.     @data = @actor.hand
  1396.   end
  1397.  
  1398.   #--------------------------------------------------------------------------
  1399.   # Prevents the costs from beeing drawn (overwrite)
  1400.   #--------------------------------------------------------------------------
  1401.   def draw_item(index)
  1402.     skill = @data[index]
  1403.     if skill
  1404.       rect = item_rect(index)
  1405.       draw_item_name(skill, rect.x, rect.y, enable?(skill))
  1406.     end
  1407.   end
  1408.  
  1409. end
  1410.  
  1411. #===============================================================================
  1412. # Window_ActorCommand
  1413. #===============================================================================
  1414.  
  1415. class Window_ActorCommand < Window_Command
  1416.    
  1417.   #--------------------------------------------------------------------------
  1418.   # Add "End Turn" command (new)
  1419.   #--------------------------------------------------------------------------
  1420.   def add_turn_end_command
  1421.     add_command(PC27::CG::END_TURN, :end_turn)
  1422.   end
  1423.  
  1424.   #--------------------------------------------------------------------------
  1425.   # Add "Grave" command (new)
  1426.   #--------------------------------------------------------------------------
  1427.   def add_look_at_grave_command
  1428.     add_command(PC27::CG::GRAVE, :look_grave)
  1429.   end
  1430.  
  1431.   #--------------------------------------------------------------------------
  1432.   # Add "Banish" command (new)
  1433.   #--------------------------------------------------------------------------
  1434.   def add_look_at_banish_command
  1435.     add_command(PC27::CG::BANISH, :look_banish)
  1436.   end
  1437.  
  1438.   #--------------------------------------------------------------------------
  1439.   # Add "Extra" command (new)
  1440.   #--------------------------------------------------------------------------
  1441.   def add_look_at_extra_command
  1442.     add_command(PC27::CG::EXTRA, :look_extra)
  1443.   end
  1444.  
  1445.   #--------------------------------------------------------------------------
  1446.   # Add "Field" command (new)
  1447.   #--------------------------------------------------------------------------
  1448.   def add_look_at_field_command
  1449.     add_command(PC27::CG::FIELD, :look_field)
  1450.   end
  1451.  
  1452.   #--------------------------------------------------------------------------
  1453.   # Make new command List (overwrite)
  1454.   #--------------------------------------------------------------------------
  1455.   def make_command_list
  1456.     return unless @actor
  1457.     add_attack_command if PC27::CG::USE_ATTACK
  1458.     add_guard_command if PC27::CG::USE_GUARD
  1459.     add_skill_commands
  1460.     add_item_command if PC27::CG::USE_ITEMS
  1461.     add_look_at_grave_command
  1462.     add_look_at_banish_command
  1463.     add_look_at_extra_command
  1464.     add_look_at_field_command
  1465.     add_turn_end_command
  1466.   end
  1467.  
  1468. end
  1469.  
  1470. #===============================================================================
  1471. # Window_BattleStatus
  1472. #===============================================================================
  1473.  
  1474. class Window_BattleStatus < Window_Selectable
  1475.  
  1476.   #--------------------------------------------------------------------------
  1477.   # Add deck to Draw Item (alias)
  1478.   #--------------------------------------------------------------------------
  1479.   alias pc27_cardgame_wndbttlstat_draw_item                            draw_item
  1480.   def draw_item(index)
  1481.     pc27_cardgame_wndbttlstat_draw_item(index)
  1482.     actor = $game_party.battle_members[index]
  1483.     draw_deck_area(deck_area_rect(index), actor)
  1484.   end
  1485.  
  1486.   #--------------------------------------------------------------------------
  1487.   # Shrink basic rect (overwrite)
  1488.   #--------------------------------------------------------------------------
  1489.   def basic_area_rect(index)
  1490.     rect = item_rect_for_text(index)
  1491.     rect.width -= gauge_area_width + deck_area_width + 10
  1492.     rect
  1493.   end
  1494.  
  1495.   #--------------------------------------------------------------------------
  1496.   # Get Deck rect (new)
  1497.   #--------------------------------------------------------------------------
  1498.   def deck_area_rect(index)
  1499.     rect = item_rect_for_text(index)
  1500.     rect.x += rect.width - gauge_area_width - deck_area_width
  1501.     rect.width = deck_area_width
  1502.     rect
  1503.   end
  1504.  
  1505.   #--------------------------------------------------------------------------
  1506.   # Get Deck Area Width (new)
  1507.   #--------------------------------------------------------------------------
  1508.   def deck_area_width
  1509.     return 48
  1510.   end
  1511.  
  1512.   #--------------------------------------------------------------------------
  1513.   # Draw Deck Area (new)
  1514.   #--------------------------------------------------------------------------
  1515.   def draw_deck_area(rect, actor)
  1516.     draw_icon(PC27::CG::DECK_ICON, rect.x + 246, rect.y + 43)
  1517.     draw_text(rect.x + 248, rect.y + 12, 80, rect.height, actor.deck.size.to_s)
  1518.   end
  1519. end
  1520.  
  1521.  
  1522. #===============================================================================
  1523. # Window_BattleSkill
  1524. #===============================================================================
  1525.  
  1526. class Window_BattleSkill < Window_SkillList
  1527.  
  1528.   #-----------------------------------------------------------------------------
  1529.   # changes the BattleSkillList Window layout (overwrite)
  1530.   #-----------------------------------------------------------------------------
  1531.   def initialize(help_window, info_viewport)
  1532.     y = 0
  1533.     super(0, 0, (Graphics.width - 210) * 0.7, info_viewport.rect.y)
  1534.     self.visible = false
  1535.     @help_window = help_window
  1536.     @info_viewport = info_viewport
  1537.   end
  1538.  
  1539.   #-----------------------------------------------------------------------------
  1540.   # changes the max. amount of collums to 1 (overwrite)
  1541.   #-----------------------------------------------------------------------------
  1542.   def col_max
  1543.     return 1
  1544.   end
  1545.  
  1546.   #--------------------------------------------------------------------------
  1547.   # * Display Skill in Active State?
  1548.   #--------------------------------------------------------------------------
  1549.   def enable?(item)
  1550.     super && @actor.turn_actions[:actions] != 0
  1551.   end
  1552.  
  1553. end
  1554.  
  1555. #===============================================================================
  1556. # Window CardHelp (new)
  1557. #===============================================================================
  1558.  
  1559. class Window_CardHelp < Window_Base
  1560.   include PC27::CG
  1561.  
  1562.   #-----------------------------------------------------------------------------
  1563.   # Enables the Window to draw cards
  1564.   #-----------------------------------------------------------------------------
  1565.   def draw_card_pic(item)
  1566.     if item
  1567.       begin
  1568.         draw_card_illustration(item)
  1569.       rescue
  1570.         draw_card_text(item)
  1571.       end
  1572.     else
  1573.       begin
  1574.         draw_card_illustration_no_card
  1575.       rescue
  1576.         draw_card_text_no_card
  1577.       end
  1578.     end
  1579.   end
  1580.  
  1581.   def draw_horz_line(y)
  1582.     line_color       = normal_color
  1583.     line_color.alpha = 48
  1584.     line_y           = y + line_height / 2 - 1
  1585.     contents.fill_rect(0, line_y, self.width, 2, line_color)
  1586.   end
  1587.  
  1588.   def make_cost_text(mp_cost, tp_cost)
  1589.     if mp_cost == 0
  1590.       if tp_cost == 0
  1591.         cost = "-"
  1592.         cost_size = 1
  1593.       else
  1594.         cost = "\\c[" + TP_COLOR.to_s + "]" + tp_cost.to_s
  1595.         cost_size = tp_cost.to_s.size
  1596.       end
  1597.     else
  1598.       if tp_cost == 0
  1599.         cost = "\\c[" + MP_COLOR.to_s + "]" + mp_cost.to_s
  1600.         cost_size = mp_cost.to_s.size
  1601.       else
  1602.         cost = "\\c[" + MP_COLOR.to_s + "]"  + mp_cost.to_s + "\\c[0]/" + "\\c[" + TP_COLOR.to_s + "]" + tp_cost.to_s
  1603.         cost_size = 1 + mp_cost.to_s.size + tp_cost.to_s.size
  1604.       end
  1605.     end
  1606.     draw_text_ex(158-cost_size* 10, 48, cost)
  1607.   end
  1608.  
  1609.   def set_background(element)
  1610.     tone.set(*ELEMENT_COLOR[element])
  1611.     self.back_opacity = CARD_BACK_OP
  1612.   end
  1613.  
  1614.   def draw_all_lines
  1615.     draw_horz_line(36)
  1616.     draw_horz_line(60)
  1617.     draw_horz_line(204)
  1618.   end
  1619.    
  1620.   def draw_card_text_no_card
  1621.     create_contents
  1622.     tone.set(*ELEMENT_COLOR[0])
  1623.     self.back_opacity = CARD_BACK_OP
  1624.   end
  1625.  
  1626.   def draw_card_text(item)
  1627.     create_contents
  1628.     self.padding = standard_padding
  1629.     id          = item.card_id.to_s
  1630.     draw_text_ex(148 - id.size * 10, height - 48, "#" + id)
  1631.     make_cost_text(item.mp_cost, item.tp_cost)
  1632.     set_background(item.damage ? item.damage.element_id : 0)
  1633.     name        = (CARD_NAME_UP ? item.name.upcase : item.name)
  1634.     icon        = "\\I[" + RARITY[item.rarity][0].to_s + "]"
  1635.     type        = TYPE[item.type]
  1636.     name_x      = 0.5 * width - padding - item.name.size * 5
  1637.     draw_all_lines
  1638.     draw_text_ex(name_x, 9, name)
  1639.     draw_text_ex(0,48, type)
  1640.     draw_text_ex(0,83, item.description)
  1641.     draw_text_ex(0, height - 48, icon)
  1642.   end
  1643.  
  1644.   def draw_card_illustration_no_card
  1645.     contents.dispose
  1646.     self.contents = Bitmap.new(190, 264)
  1647.     bitmap = Cache.picture("Card0")
  1648.     self.padding = 0
  1649.     rect = Rect.new(0, 0, 190, 264)
  1650.     contents.blt(0, 0, bitmap, rect, 255)
  1651.     bitmap.dispose
  1652.   end
  1653.  
  1654.   def draw_card_illustration(item)
  1655.     contents.dispose
  1656.     self.contents = Bitmap.new(190, 264)
  1657.     bitmap = Cache.picture("Card" + item.id.to_s)
  1658.     self.padding = 0
  1659.     rect = Rect.new(0, 0, 190, 264)
  1660.     contents.blt(0, 0, bitmap, rect, 255)
  1661.     bitmap.dispose
  1662.   end
  1663.  
  1664.   #--------------------------------------------------------------------------
  1665.   # Object Initialization
  1666.   #--------------------------------------------------------------------------
  1667.   def initialize()
  1668.     super(Graphics.width - 200, 10, 190, 264)
  1669.     self.windowskin = Cache.system(PC27::CG::CUSTOM_CARD_BG) if PC27::CG::CUSTOM_CARD_BG
  1670.   end
  1671.  
  1672.   #--------------------------------------------------------------------------
  1673.   # Set Text
  1674.   #--------------------------------------------------------------------------
  1675.   def set_text(card)
  1676.     if card != @card
  1677.       @card = card
  1678.       refresh
  1679.     end
  1680.   end
  1681.  
  1682.   #--------------------------------------------------------------------------
  1683.   # Set Item
  1684.   #--------------------------------------------------------------------------
  1685.   def set_item(item)
  1686.     set_text(item)
  1687.   end
  1688.  
  1689.   #--------------------------------------------------------------------------
  1690.   # Refresh
  1691.   #--------------------------------------------------------------------------
  1692.   def refresh
  1693.     contents.clear
  1694.     draw_card_pic(@card)
  1695.   end
  1696.  
  1697.   def update_tone;    end
  1698.   def update_padding; end
  1699.  
  1700. end
  1701. #===============================================================================
  1702. # Window_CardSelect (new)
  1703. #===============================================================================
  1704.  
  1705. class Window_CardSelect < Window_SkillList
  1706.  
  1707.   attr_accessor :actor
  1708.   attr_accessor :cards
  1709.   attr_accessor :sort_index
  1710.   attr_accessor :filter
  1711.  
  1712.   def initialize(help_window, info_viewport)
  1713.     super(0, 0, (Graphics.width - 210) * 0.7, info_viewport.rect.y)
  1714.     self.visible = false
  1715.     @help_window = help_window
  1716.     @info_viewport = info_viewport
  1717.     @filter = [0,0,0,0,0,0,0,0,0,0]
  1718.     @cards  = []
  1719.     @sort_index = -1
  1720.   end
  1721.  
  1722.   def col_max
  1723.     return 1
  1724.   end
  1725.  
  1726.   def make_item_list
  1727.     @data = @cards
  1728.   end
  1729.  
  1730.   def enable?(item)
  1731.     return false unless item
  1732.     return false unless item.damage.element_id == @filter[0] || @filter[0] == 0
  1733.     return false unless item.type              == @filter[1] || @filter[1] == 0
  1734.     return false unless item.rarity            == @filter[2] || @filter[2] == 0
  1735.     return false unless item.subtype           == @filter[3] || @filter[3] == 0
  1736.     return false unless item.level             == @filter[4] || @filter[4] == 0
  1737.     return false unless item.normeff           == @filter[5] || @filter[5] == 0
  1738.     return false unless item.frame             == @filter[6] || @filter[6] == 0
  1739.     return false unless item.archetype         == @filter[7] || @filter[7] == 0
  1740.     return false unless item.atk               == @filter[8] || @filter[8] == 0
  1741.     return false unless item.def               == @filter[9] || @filter[9] == 0
  1742.     return false unless item.special           == @filter[10] || @filter[10] == 0
  1743.     return @actor
  1744.   end
  1745.  
  1746.   #--------------------------------------------------------------------------
  1747.   # Show Window
  1748.   #--------------------------------------------------------------------------
  1749.   def show
  1750.     select(0)
  1751.     @help_window.show
  1752.     super
  1753.   end
  1754.   #--------------------------------------------------------------------------
  1755.   # Hide Window
  1756.   #--------------------------------------------------------------------------
  1757.   def hide
  1758.     @help_window.hide
  1759.     super
  1760.   end
  1761.  
  1762. end
  1763. #===============================================================================
  1764. # Scene_Battle
  1765. #===============================================================================
  1766. class Scene_Battle < Scene_Base
  1767.  
  1768.   #--------------------------------------------------------------------------
  1769.   # Add end turn command and remove prior command (overwrite)
  1770.   #--------------------------------------------------------------------------
  1771.   def create_actor_command_window
  1772.     @actor_command_window = Window_ActorCommand.new
  1773.     @actor_command_window.viewport = @info_viewport
  1774.     @actor_command_window.set_handler(:attack,      method(:command_attack))
  1775.     @actor_command_window.set_handler(:skill,       method(:command_skill))
  1776.     @actor_command_window.set_handler(:guard,       method(:command_guard))
  1777.     @actor_command_window.set_handler(:item,        method(:command_item))
  1778.     @actor_command_window.set_handler(:look_grave,  method(:command_look_grave))
  1779.     @actor_command_window.set_handler(:look_banish, method(:command_look_banish))
  1780.     @actor_command_window.set_handler(:look_extra,  method(:command_look_extra))
  1781.     @actor_command_window.set_handler(:look_field,  method(:command_look_field))
  1782.     @actor_command_window.set_handler(:end_turn,    method(:command_end_turn))
  1783.     @actor_command_window.x = Graphics.width
  1784.   end
  1785.  
  1786.   #--------------------------------------------------------------------------
  1787.   # Handles the Look Grave command
  1788.   #--------------------------------------------------------------------------
  1789.   def command_look_grave
  1790.     array = PC27::CG::CARD_EFFECT["grave"]
  1791.     @temp_effect_data = [] unless @temp_effect_data
  1792.     @temp_effect_data[0] = :impact
  1793.     prepare_select_window(:impact, array[0])
  1794.     process_select_cards("grave")
  1795.   end
  1796.  
  1797.   #--------------------------------------------------------------------------
  1798.   # Handles the Look Banish command
  1799.   #--------------------------------------------------------------------------
  1800.   def command_look_banish
  1801.     array = PC27::CG::CARD_EFFECT["banish"]
  1802.     @temp_effect_data = [] unless @temp_effect_data
  1803.     @temp_effect_data[0] = :impact
  1804.     prepare_select_window(:impact, array[0])
  1805.     process_select_cards("banish")
  1806.   end
  1807.  
  1808.   #--------------------------------------------------------------------------
  1809.   # Handles the Look Extra command
  1810.   #--------------------------------------------------------------------------
  1811.   def command_look_extra
  1812.     array = PC27::CG::CARD_EFFECT["extra"]
  1813.     @temp_effect_data = [] unless @temp_effect_data
  1814.     @temp_effect_data[0] = :impact
  1815.     prepare_select_window(:impact, array[0])
  1816.     process_select_cards("extra")
  1817.   end
  1818.  
  1819.   #--------------------------------------------------------------------------
  1820.   # Handles the Look Field command
  1821.   #--------------------------------------------------------------------------
  1822.   def command_look_field
  1823.     array = PC27::CG::CARD_EFFECT["field"]
  1824.     @temp_effect_data = [] unless @temp_effect_data
  1825.     @temp_effect_data[0] = :impact
  1826.     prepare_select_window(:impact, array[0])
  1827.     process_select_cards("field")
  1828.   end
  1829.  
  1830.   #--------------------------------------------------------------------------
  1831.   # Clears actions and ends the actors turn
  1832.   #--------------------------------------------------------------------------
  1833.   def command_end_turn
  1834.     BattleManager.actor.clear_actions
  1835.     next_command
  1836.   end
  1837.      
  1838.   #--------------------------------------------------------------------------
  1839.   # Prevents messages from closing windows (overwrite)
  1840.   #--------------------------------------------------------------------------
  1841.   def update_message_open
  1842.   end
  1843.  
  1844.   #--------------------------------------------------------------------------
  1845.   # Shows a different Help Window in Battle (alias)
  1846.   #--------------------------------------------------------------------------
  1847.   alias pc27_cardgame_scenebattle_create_help_window          create_help_window
  1848.   def create_help_window
  1849.     pc27_cardgame_scenebattle_create_help_window
  1850.     @cardhelp_window = Window_CardHelp.new
  1851.     @cardhelp_window.visible = false
  1852.   end
  1853.  
  1854.   #--------------------------------------------------------------------------
  1855.   # Create Skill Window with card help window instead of normal help window (overwrite)
  1856.   #--------------------------------------------------------------------------
  1857.   def create_skill_window
  1858.     @skill_window = Window_BattleSkill.new(@cardhelp_window, @info_viewport)
  1859.     @skill_window.set_handler(:ok,     method(:on_skill_ok))
  1860.     @skill_window.set_handler(:cancel, method(:on_skill_cancel))
  1861.   end
  1862.  
  1863.   #--------------------------------------------------------------------------
  1864.   # Create Extra Window with card help window instead of normal help window (overwrite)
  1865.   #--------------------------------------------------------------------------
  1866.   def create_extra_window
  1867.     @extra_window = Window_BattleSkill.new(@cardhelp_window, @info_viewport)
  1868.     @extra_window.set_handler(:ok,     method(:on_skill_ok))
  1869.     @extra_window.set_handler(:cancel, method(:on_skill_cancel))
  1870.   end
  1871.  
  1872.   #--------------------------------------------------------------------------
  1873.   # Creates the window needed to select cards (new)
  1874.   #--------------------------------------------------------------------------
  1875.   def create_card_select_window
  1876.     @card_select_window = Window_CardSelect.new(@cardhelp_window, @info_viewport)
  1877.   end
  1878.  
  1879.   #--------------------------------------------------------------------------
  1880.   # Adds the select window to the scene (alias)
  1881.   #--------------------------------------------------------------------------
  1882.   alias pc27_cardgame_scenebattle_create_all_windows          create_all_windows
  1883.   def create_all_windows
  1884.     pc27_cardgame_scenebattle_create_all_windows
  1885.     create_card_select_window
  1886.   end
  1887.  
  1888.   #--------------------------------------------------------------------------
  1889.   # On Skill Ok checks for card costs
  1890.   #--------------------------------------------------------------------------
  1891.   alias pc27_cardgame_scene_battle_on_skill_ok                       on_skill_ok
  1892.   def on_skill_ok
  1893.     @skill = @skill_window.item
  1894.     $game_temp.battle_aid = @skill
  1895.     BattleManager.actor.card_to_stack?(@skill.id)
  1896.     if @skill.cost
  1897.       invoke_card_cost(@skill.cost)
  1898.       @skill_window.hide
  1899.     else
  1900.       BattleManager.actor.input.set_skill(@skill.id)
  1901.       BattleManager.actor.last_skill.object = @skill
  1902.       if !@skill.need_selection?
  1903.         @skill_window.hide
  1904.         next_command
  1905.       elsif @skill.for_opponent?
  1906.         select_enemy_selection
  1907.       else
  1908.         select_actor_selection
  1909.       end
  1910.     end
  1911.   end
  1912.  
  1913.   def def state_monster_field
  1914.     @field.each do |monster|
  1915.     monster = skill.id
  1916.     if @field.include?(card.type == 3)
  1917.     @actor.add_state(monster)
  1918.     update
  1919.   end
  1920.   end
  1921.   end
  1922.  
  1923.   def on_enemy_cancel
  1924.     restore_taken_cards(:cancel)
  1925.     BattleManager.actor.hand += BattleManager.actor.stack
  1926.     BattleManager.actor.stack = []
  1927.     @enemy_window.hide
  1928.     @skill_window.hide
  1929.     @item_window.hide
  1930.     @actor_command_window.activate
  1931.   end
  1932.  
  1933.   def on_actor_cancel
  1934.     restore_taken_cards(:cancel)
  1935.     BattleManager.actor.hand += BattleManager.actor.stack
  1936.     BattleManager.actor.stack = []
  1937.     @actor_window.hide
  1938.     @skill_window.hide
  1939.     @item_window.hide
  1940.     @actor_command_window.activate
  1941.   end
  1942.  
  1943.   #-----------------------------------------------------------------------------
  1944.   # Changes Next Command so it performs Actions (alias)
  1945.   #-----------------------------------------------------------------------------
  1946.   alias pc27_cardgame_scenebattle_next_command                      next_command
  1947.   def next_command
  1948.     return if @card_select_window.active
  1949.     if action?
  1950.       evaluate_item(BattleManager.actor, BattleManager.actor.input.item)
  1951.       perform_action
  1952.     else
  1953.       pc27_cardgame_scenebattle_next_command
  1954.     end
  1955.   end
  1956.  
  1957.   #-----------------------------------------------------------------------------
  1958.   # Disables stuff based on used skill (new)
  1959.   #-----------------------------------------------------------------------------
  1960.   def evaluate_item(actor, item)
  1961.     case item.id
  1962.     when actor.attack_skill_id
  1963.       actor.turn_actions[:can_attack] = false
  1964.       actor.turn_actions[:can_guard]  = false
  1965.       actor.turn_actions[:actions]    -= 1 unless actor.turn_actions[:actions] == -1
  1966.     when actor.guard_skill_id
  1967.       actor.turn_actions[:can_attack] = false
  1968.       actor.turn_actions[:can_guard]  = false
  1969.       actor.turn_actions[:actions]    -= 1 unless actor.turn_actions[:actions] == -1
  1970.     end
  1971.   end
  1972.  
  1973.   #--------------------------------------------------------------------------
  1974.   # Checks if there is an Action to use (new)
  1975.   #--------------------------------------------------------------------------
  1976.   def action?
  1977.     return false if BattleManager.actor.nil?
  1978.     return false if BattleManager.actor.input.nil?
  1979.     action = BattleManager.actor.input.item
  1980.     return false if action.nil?
  1981.     return true
  1982.   end
  1983.    
  1984.   #--------------------------------------------------------------------------
  1985.   # Performs Action (new)
  1986.   #--------------------------------------------------------------------------
  1987.   def perform_action
  1988.     @subject = BattleManager.actor
  1989.     hide_instant_action_windows
  1990.     if @subject.current_action.valid?
  1991.       execute_action
  1992.     end
  1993.     process_event
  1994.     loop do
  1995.       @subject.remove_current_action
  1996.       break if $game_troop.all_dead?
  1997.       break unless @subject.current_action
  1998.       @subject.current_action.prepare
  1999.       execute_action if @subject.current_action.valid?
  2000.     end
  2001.     process_action_end
  2002.     @subject.make_actions
  2003.     @subject = nil
  2004.     show_instant_action_windows
  2005.   end
  2006.  
  2007.   #--------------------------------------------------------------------------
  2008.   # From Yanflys Instantcast (new)
  2009.   #--------------------------------------------------------------------------
  2010.   def hide_instant_action_windows
  2011.     if $imported["YEA-BattleEngine"]
  2012.       @info_viewport.visible = true
  2013.       @status_aid_window.hide
  2014.       @status_window.show
  2015.       @actor_command_window.show
  2016.     end
  2017.   end
  2018.  
  2019.   #--------------------------------------------------------------------------
  2020.   # Activates actor (new)
  2021.   #--------------------------------------------------------------------------
  2022.   def show_instant_action_windows
  2023.     if $imported["YEA-BattleEngine"]
  2024.       @info_viewport.visible = true
  2025.     end
  2026.     start_actor_command_selection unless @card_select_window.active
  2027.     status_redraw_target(BattleManager.actor)
  2028.     next_command unless BattleManager.actor.inputable?
  2029.   end
  2030.  
  2031.   #--------------------------------------------------------------------------
  2032.   # Redrawas target after action (new)
  2033.   #--------------------------------------------------------------------------
  2034.   def status_redraw_target(target)
  2035.     return unless target.actor?
  2036.     @status_window.draw_item($game_party.battle_members.index(target))
  2037.   end
  2038.  
  2039.   #--------------------------------------------------------------------------
  2040.   # Handles card costs
  2041.   #--------------------------------------------------------------------------
  2042.   def invoke_card_cost(effect_name)
  2043.     effect_array = PC27::CG::CARD_EFFECT[effect_name]
  2044.     if effect_array[0] == :draw
  2045.       card_effect_draw_cards(effect_array[1], effect_array[2], effect_array[3])
  2046.       BattleManager.actor.input.set_skill(@skill.id)
  2047.       BattleManager.actor.last_skill.object = @skill
  2048.       if !@skill.need_selection?
  2049.         @skill_window.hide
  2050.         next_command
  2051.       elsif @skill.for_opponent?
  2052.         select_enemy_selection
  2053.       else
  2054.         select_actor_selection
  2055.       end
  2056.     else
  2057.       $game_message.background = 1
  2058.       $game_message.position   = 1
  2059.       $game_message.add(PC27::CG::CARD_EFF_TEXT)
  2060.       wait_for_message
  2061.       prepare_select_window(:cost, effect_array[0])
  2062.       @temp_effect_data = [] unless @temp_effect_data
  2063.       @temp_effect_data[0] = :cost
  2064.       process_select_cards(effect_name)
  2065.     end
  2066.   end
  2067.  
  2068.   #-----------------------------------------------------------------------------
  2069.   # Evaluates card effects and puts the stack to the grave (alias)
  2070.   #-----------------------------------------------------------------------------
  2071.   alias pc27_cardgame_scenebattle_use_item                              use_item
  2072.   def use_item
  2073.     pc27_cardgame_scenebattle_use_item
  2074.     if @subject.is_a?(Game_Actor)
  2075.       effect_name = @subject.current_action.item.impact
  2076.       invoke_card_impact(effect_name) if effect_name
  2077.       @subject.field += @subject.stack unless @subject.current_action.item.frame == 5
  2078.       @subject.stack = []
  2079.       restore_taken_cards(:proceed)
  2080.       wait_for_message
  2081.     end
  2082.   end
  2083.  
  2084.   #-----------------------------------------------------------------------------
  2085.   # Card effects
  2086.   #-----------------------------------------------------------------------------
  2087.   def invoke_card_impact(effect_name)
  2088.     array = PC27::CG::CARD_EFFECT[effect_name]
  2089.     if array[0] == :draw
  2090.       card_effect_draw_cards(array[1], array[2], array[3])
  2091.     else
  2092.       $game_message.background = 1
  2093.       $game_message.position   = 1
  2094.       $game_message.add(PC27::CG::CARD_EFF_TEXT)
  2095.       wait_for_message
  2096.       prepare_select_window(:impact, array[0])
  2097.       @temp_effect_data = [] unless @temp_effect_data
  2098.       @temp_effect_data[0] = :impact
  2099.       process_select_cards(effect_name)
  2100.     end
  2101.   end
  2102.  
  2103.   #-----------------------------------------------------------------------------
  2104.   def card_effect_draw_cards(nr, prob, trg)
  2105.     if trg == :self
  2106.       if rand(100) < prob
  2107.         @subject.draw_cards(nr)
  2108.         need_wait = true
  2109.       end
  2110.     elsif trg == :target
  2111.       targets = @subject.current_action.make_targets.compact
  2112.       for target in targets
  2113.         if rand(100) < prob
  2114.           target.draw_cards(nr)
  2115.           need_wait = true
  2116.         end
  2117.       end
  2118.     end
  2119.     wait_for_message if need_wait
  2120.   end
  2121.    
  2122.   #-----------------------------------------------------------------------------
  2123.   def process_select_cards(effect_name)
  2124.     @card_select_window.actor = BattleManager.actor
  2125.     array = PC27::CG::CARD_EFFECT[effect_name]
  2126.     case array[2]
  2127.     when :deck
  2128.       (array[1] == 0 ? amn = @card_select_window.actor.deck.size : amn = array[1])
  2129.       amn.times do
  2130.         next if @card_select_window.actor.deck.size == 0
  2131.         @card_select_window.cards.push(@card_select_window.actor.deck.shift)
  2132.       end
  2133.     when :hand
  2134.       (array[1] == 0 ? amn = @card_select_window.actor.hand.size : amn = array[1])
  2135.       amn.times do
  2136.         next if @card_select_window.actor.hand.size == 0
  2137.         @card_select_window.cards.push(@card_select_window.actor.hand.shift)
  2138.       end
  2139.     when :grave
  2140.       (array[1] == 0 ? amn = @card_select_window.actor.grave.size : amn = array[1])
  2141.       amn.times do
  2142.         next if @card_select_window.actor.grave.size == 0
  2143.         @card_select_window.cards.push(@card_select_window.actor.grave.shift)
  2144.       end
  2145.     when :banish
  2146.       (array[1] == 0 ? amn = @card_select_window.actor.banish.size : amn = array[1])
  2147.       amn.times do
  2148.         next if @card_select_window.actor.banish.size == 0
  2149.         @card_select_window.cards.push(@card_select_window.actor.banish.shift)
  2150.       end
  2151.     when :extra
  2152.       (array[1] == 0 ? amn = @card_select_window.actor.extra.size : amn = array[1])
  2153.       amn.times do
  2154.         next if @card_select_window.actor.extra.size == 0
  2155.         @card_select_window.cards.push(@card_select_window.actor.extra.shift)
  2156.       end
  2157.     when :field
  2158.       (array[1] == 0 ? amn = @card_select_window.actor.field.size : amn = array[1])
  2159.       amn.times do
  2160.         next if @card_select_window.actor.field.size == 0
  2161.         @card_select_window.cards.push(@card_select_window.actor.field.shift)
  2162.       end
  2163.     end
  2164.     @temp_effect_data[1] = effect_name
  2165.     @temp_effect_data[2] = 0
  2166.     set_select_filter(array)
  2167.     @card_select_window.refresh
  2168.     @card_select_window.show.activate
  2169.   end
  2170.  
  2171.   #-----------------------------------------------------------------------------
  2172.   def set_select_filter(array)
  2173.     if array[4]
  2174.       @card_select_window.filter = array[4]
  2175.     elsif array[0] == :view
  2176.       @card_select_window.filter = [-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1]
  2177.     else
  2178.       @card_select_window.filter = [0,0,0,0,0,0,0,0,0,0,0]
  2179.     end
  2180.   end
  2181.  
  2182.   #-----------------------------------------------------------------------------
  2183.   def select_cards_ok_sort
  2184.     if @card_select_window.cards.size == 0
  2185.       select_cancel
  2186.       return
  2187.     end
  2188.     if @card_select_window.sort_index != -1
  2189.     swap_cards(@card_select_window.sort_index, @card_select_window.index)
  2190.       @card_select_window.sort_index = -1
  2191.       @card_select_window.refresh
  2192.     else
  2193.       @card_select_window.sort_index = @card_select_window.index
  2194.     end
  2195.     @card_select_window.activate
  2196.   end
  2197.  
  2198.   #-----------------------------------------------------------------------------
  2199.   def select_cards_ok_take
  2200.     if @card_select_window.cards.size == 0
  2201.       select_cancel
  2202.       return
  2203.     end
  2204.     card = @card_select_window.item
  2205.     @temp_effect_data[3] = [] unless @temp_effect_data[3]
  2206.     @temp_effect_data[3].push(card) unless @card_select_window.item.frame == 5
  2207.     @card_select_window.cards.delete_at(@card_select_window.cards.index(card))
  2208.     @temp_effect_data[2] += 1
  2209.     if PC27::CG::CARD_EFFECT[@temp_effect_data[1]][6] != @temp_effect_data[2]
  2210.       @card_select_window.refresh
  2211.       @card_select_window.activate
  2212.     else
  2213.       proceed_selection
  2214.     end
  2215.   end
  2216.   #-----------------------------------------------------------------------------
  2217.   def proceed_selection
  2218.     @card_select_window.hide.deactivate
  2219.     @card_select_window.sort_index = -1
  2220.     restore_selected_cards
  2221.     if @temp_effect_data[0] == :cost
  2222.       BattleManager.actor.input.set_skill(@skill.id)
  2223.       BattleManager.actor.last_skill.object = @skill
  2224.       if !@skill.need_selection?
  2225.         @skill_window.hide
  2226.         next_command
  2227.       elsif @skill.for_opponent?
  2228.         select_enemy_selection
  2229.       else
  2230.         select_actor_selection
  2231.       end
  2232.     elsif @temp_effect_data[0] == :impact
  2233.       restore_taken_cards(:proceed)
  2234.       start_actor_command_selection
  2235.       @card_select_window.actor.shuffle_deck(false)
  2236.     end
  2237.   end
  2238.  
  2239.   def select_cancel
  2240.     @card_select_window.hide.deactivate
  2241.     @card_select_window.sort_index = -1
  2242.     restore_taken_cards(:cancel)
  2243.     restore_selected_cards
  2244.     if @temp_effect_data[0] == :cost
  2245.       BattleManager.actor.hand += BattleManager.actor.stack
  2246.       BattleManager.actor.stack = []
  2247.       on_skill_cancel
  2248.     elsif @temp_effect_data[0] == :impact
  2249.       start_actor_command_selection
  2250.     end
  2251.   end
  2252.  
  2253.  
  2254.   def restore_taken_cards(target)
  2255.     return unless @temp_effect_data && @temp_effect_data[3] && @temp_effect_data[3] != []
  2256.     if target == :proceed
  2257.       case PC27::CG::CARD_EFFECT[@temp_effect_data[1]][5]
  2258.       when :hand
  2259.         @card_select_window.actor.hand += @temp_effect_data[3]
  2260.       when :deck
  2261.         @card_select_window.actor.deck += @temp_effect_data[3]
  2262.         @card_select_window.actor.shuffle_deck(false)
  2263.       when :grave
  2264.         @card_select_window.actor.grave += @temp_effect_data[3]
  2265.       when :banish
  2266.         @card_select_window.actor.banish += @temp_effect_data[3]
  2267.       when :extra
  2268.         @card_select_window.actor.extra += @temp_effect_data[3]
  2269.       when :field
  2270.         @card_select_window.actor.field += @temp_effect_data[3]
  2271.       end
  2272.     elsif target == :cancel
  2273.       case PC27::CG::CARD_EFFECT[@temp_effect_data[1]][2]
  2274.       when :hand
  2275.         @card_select_window.actor.hand += @temp_effect_data[3]
  2276.       when :deck
  2277.         @card_select_window.actor.deck += @temp_effect_data[3]
  2278.       when :grave
  2279.         @card_select_window.actor.grave += @temp_effect_data[3]
  2280.       when :banish
  2281.         @card_select_window.actor.banish += @temp_effect_data[3]
  2282.       when :extra
  2283.         @card_select_window.actor.extra += @temp_effect_data[3]
  2284.       when :field
  2285.         @card_select_window.actor.field += @temp_effect_data[3]
  2286.       end
  2287.     end
  2288.     @temp_effect_data[3] = []
  2289.   end
  2290.  
  2291.   #-----------------------------------------------------------------------------
  2292.   def restore_selected_cards
  2293.     array = PC27::CG::CARD_EFFECT[@temp_effect_data[1]]
  2294.     case array[3]
  2295.     when :deck
  2296.       @card_select_window.cards.reverse.each { |card|
  2297.         @card_select_window.actor.deck.unshift(card)
  2298.       }
  2299.       @card_select_window.actor.shuffle_deck if array[0] == :take && @card_select_window.actor.deck.size != 0
  2300.       @status_window.refresh
  2301.     when :hand
  2302.       @card_select_window.cards.reverse.each { |card|
  2303.         @card_select_window.actor.hand.unshift(card)
  2304.       }
  2305.     when :grave
  2306.       @card_select_window.cards.reverse.each { |card|
  2307.         @card_select_window.actor.grave.unshift(card)
  2308.       }
  2309.     when :banish
  2310.       @card_select_window.cards.reverse.each { |card|
  2311.         @card_select_window.actor.banish.unshift(card)
  2312.       }
  2313.     when :extra
  2314.       @card_select_window.cards.reverse.each { |card|
  2315.         @card_select_window.actor.extra.unshift(card)
  2316.       }
  2317.     when :field
  2318.       @card_select_window.cards.reverse.each { |card|
  2319.         @card_select_window.actor.field.unshift(card)
  2320.       }
  2321.     end
  2322.     @card_select_window.cards = []
  2323.   end
  2324.  
  2325.   #-----------------------------------------------------------------------------
  2326.   def prepare_select_window(moment, type)
  2327.     if moment == :impact
  2328.       if    type == :view
  2329.         @card_select_window.set_handler(:ok,   method(:no_method))
  2330.         @card_select_window.set_handler(:cancel, method(:select_cancel))
  2331.       elsif type == :sort
  2332.         @card_select_window.set_handler(:ok,   method(:select_cards_ok_sort))
  2333.         @card_select_window.set_handler(:cancel, method(:select_cancel))
  2334.       elsif type == :take
  2335.         @card_select_window.set_handler(:ok,   method(:select_cards_ok_take))
  2336.         @card_select_window.set_handler(:cancel, method(:proceed_selection))
  2337.       elsif type == :takem
  2338.         @card_select_window.set_handler(:ok,   method(:select_cards_ok_take))
  2339.         @card_select_window.set_handler(:cancel, method(:no_method))
  2340.       end
  2341.     elsif moment == :cost
  2342.       if    type == :view
  2343.         @card_select_window.set_handler(:ok,   method(:no_method))
  2344.         @card_select_window.set_handler(:cancel, method(:proceed_selection))
  2345.       elsif type == :sort
  2346.         @card_select_window.set_handler(:ok,   method(:select_cards_ok_sort))
  2347.         @card_select_window.set_handler(:cancel, method(:proceed_selection))
  2348.       elsif type == :take
  2349.         @card_select_window.set_handler(:ok,   method(:select_cards_ok_take))
  2350.         @card_select_window.set_handler(:cancel, method(:select_cancel))
  2351.       elsif type == :takem
  2352.         @card_select_window.set_handler(:ok,   method(:select_cards_ok_take))
  2353.         @card_select_window.set_handler(:cancel, method(:no_method))
  2354.       elsif type == :takeup
  2355.         @card_select_window.set_handler(:ok,   method(:select_cards_ok_take))
  2356.         @card_select_window.set_handler(:cancel, method(:proceed_selection))
  2357.       end
  2358.     end
  2359.   end
  2360.  
  2361.   def no_method
  2362.     @card_select_window.activate
  2363.   end
  2364.        
  2365.   #-----------------------------------------------------------------------------
  2366.   def swap_cards(index1, index2)
  2367.     @card_select_window.cards[index1], @card_select_window.cards[index2] =
  2368.     @card_select_window.cards[index2], @card_select_window.cards[index1]
  2369.   end
  2370. end
  2371.  
  2372. #===============================================================================
  2373. # Scene_Deck
  2374. #===============================================================================
  2375.  
  2376. class Scene_Deck < Scene_MenuBase
  2377.   include PC27::CG
  2378.   #-----------------------------------------------------------------------------
  2379.   # Start
  2380.   #-----------------------------------------------------------------------------
  2381.   def start
  2382.     super()
  2383.     create_filter_window
  2384.     create_deck_window
  2385.     create_extra_window
  2386.     create_coll_window
  2387.     create_text_window
  2388.     create_card_window
  2389.     create_info_window
  2390.   end
  2391.  
  2392.   def return_scene
  2393.     if $game_party.menu_actor.deck.size <= 39
  2394.     RPG::SE.new("Buzzer1", 80, 100).play
  2395.     $game_message.add('Your deck has less than 40 cards.')
  2396.     else
  2397.     SceneManager.return
  2398.   end
  2399.   end
  2400.  
  2401.   #-----------------------------------------------------------------------------
  2402.   # Creates a window to display deck cards
  2403.   #-----------------------------------------------------------------------------
  2404.   def create_deck_window
  2405.     @deck_window = Window_Deck.new(0,64)
  2406.     @deck_window.set_handler(:cancel,   method(:return_scene))
  2407.     @deck_window.set_handler(:ok,       method(:deck_to_coll))
  2408.   end
  2409.  
  2410.   #-----------------------------------------------------------------------------
  2411.   # Creates a window to display extra deck cards
  2412.   #-----------------------------------------------------------------------------
  2413.   def create_extra_window
  2414.     @extra_window = Window_Extra.new(0,280)
  2415.     @extra_window.set_handler(:cancel,   method(:return_scene))
  2416.     @extra_window.set_handler(:ok,       method(:extra_to_coll))
  2417.   end
  2418.  
  2419.   #-----------------------------------------------------------------------------
  2420.   # Creates a window to display collection cards
  2421.   #-----------------------------------------------------------------------------
  2422.   def create_coll_window
  2423.     @coll_window = Window_Coll.new((Graphics.width - 210)*0.5, 64)
  2424.     @coll_window.set_handler(:cancel,   method(:return_scene))
  2425.     @coll_window.set_handler(:ok,       method(:coll_to_deck))
  2426.     @coll_window.deactivate
  2427.   end
  2428.  
  2429.   #-----------------------------------------------------------------------------
  2430.   # Creates the window that shows where you are
  2431.   #-----------------------------------------------------------------------------
  2432.   def create_text_window
  2433.     @text_window = Window_Base.new(0 ,0, Graphics.width - 210, 64)
  2434.     update_text_window
  2435.   end
  2436.  
  2437.   #-----------------------------------------------------------------------------
  2438.   # Creates the window that shows the currently selected card
  2439.   #-----------------------------------------------------------------------------
  2440.   def create_card_window
  2441.     @card_window = Window_CardHelp.new()
  2442.     @card_window.windowskin = Cache.system(CUSTOM_CARD_BG) if CUSTOM_CARD_BG
  2443.     @card_window.tone.set(*PC27::CG::ELEMENT_COLOR[0])
  2444.     @card_window.back_opacity = PC27::CG::CARD_BACK_OP
  2445.   end
  2446.  
  2447.   #-----------------------------------------------------------------------------
  2448.   # Creates a info window
  2449.   #-----------------------------------------------------------------------------
  2450.   def create_info_window
  2451.     height = Graphics.height - 284
  2452.     @info_window = Window_Base.new(
  2453.     Graphics.width - 210, Graphics.height - height, 210, height)
  2454.     @info_window.draw_text_ex(0,0,CARD_HELP_WINDOW)
  2455.   end
  2456.  
  2457.   #-----------------------------------------------------------------------------
  2458.   # Creates a window to filter cards
  2459.   #-----------------------------------------------------------------------------
  2460.   def create_filter_window
  2461.     @filter_window = Window_Filter.new(0,Graphics.height * 0.5 - 48)
  2462.     @filter_window.set_handler(:cancel,   method(:close_filter))
  2463.     @filter_window.set_handler(:ok,       method(:change_filter))
  2464.     @filter_window.z = 150
  2465.     @filter_window.hide
  2466.     @filter_window.deactivate
  2467.   end
  2468.  
  2469.   #-----------------------------------------------------------------------------
  2470.   # Changes between collection and deck window
  2471.   #-----------------------------------------------------------------------------    
  2472.   def change_to_coll
  2473.     @coll_window.activate
  2474.     @deck_window.deactivate
  2475.     @extra_window.deactivate
  2476.     Sound.play_cursor
  2477.     Input.update
  2478.   end
  2479.      
  2480.   def change_to_deck
  2481.     @deck_window.activate
  2482.     @coll_window.deactivate
  2483.     @extra_window.deactivate
  2484.     Sound.play_cursor
  2485.     Input.update
  2486.   end
  2487.  
  2488.   def change_to_extra
  2489.     @deck_window.deactivate
  2490.     @coll_window.deactivate
  2491.     @extra_window.activate
  2492.     Sound.play_cursor
  2493.     Input.update
  2494.   end
  2495.  
  2496.   #-----------------------------------------------------------------------------
  2497.   # Adds commands to exchange cards
  2498.   #-----------------------------------------------------------------------------
  2499.   def coll_to_deck
  2500.     for skill in $game_party.coll
  2501.     /coll(?<skill_id>\d+)/ =~ @coll_window.current_symbol.to_s
  2502.     skill_id  = skill_id.to_i
  2503.     max_cards = (MAX_SAME_EXCEP.has_key?(skill_id) ? MAX_SAME_EXCEP[skill_id] : MAX_SAME_CARDS)
  2504.       if skill.id == skill_id && skill.type == 4
  2505.         if $game_party.menu_actor.extra.size >= MAX_EXTRA_SIZE
  2506.         RPG::SE.new("Buzzer1", 80, 100).play
  2507.         return
  2508.         end
  2509.         if $game_party.menu_actor.extra.count{ |skill| skill.id == skill_id } >= max_cards
  2510.         RPG::SE.new("Buzzer1", 80, 100).play
  2511.         return
  2512.         end
  2513.         $game_party.menu_actor.extra.push(
  2514.         $game_party.coll.slice!($game_party.coll.index(skill)))
  2515.         break
  2516.         elsif skill.id == skill_id
  2517.         if $game_party.menu_actor.deck.size >= MAX_DECK_SIZE
  2518.         RPG::SE.new("Buzzer1", 80, 100).play
  2519.         return
  2520.         end
  2521.         if $game_party.menu_actor.deck.count{ |skill| skill.id == skill_id } >= max_cards
  2522.         RPG::SE.new("Buzzer1", 80, 100).play
  2523.         return
  2524.         end
  2525.         $game_party.menu_actor.deck.push(
  2526.         $game_party.coll.slice!($game_party.coll.index(skill)))
  2527.         break
  2528.         end
  2529.       end
  2530.     RPG::SE.new("Cursor1", 80, 100).play
  2531.     @deck_window.refresh
  2532.     @extra_window.refresh
  2533.     @coll_window.refresh
  2534.     update_text_window
  2535.   end
  2536.  
  2537.   def deck_to_coll
  2538.     /deck(?<skill_id>\d+)/ =~ @deck_window.current_symbol.to_s
  2539.     skill_id = skill_id.to_i
  2540.     for skill in $game_party.menu_actor.deck
  2541.       if skill.id == skill_id
  2542.         $game_party.coll.push(
  2543.         $game_party.menu_actor.deck.slice!($game_party.menu_actor.deck.index(skill)))
  2544.         break
  2545.       end
  2546.     end
  2547.     RPG::SE.new("Cursor1", 80, 100).play
  2548.     @deck_window.refresh
  2549.     @coll_window.refresh
  2550.     update_text_window
  2551.   end
  2552.  
  2553.   def extra_to_coll
  2554.     /extra(?<skill_id>\d+)/ =~ @extra_window.current_symbol.to_s
  2555.     skill_id = skill_id.to_i
  2556.     for skill in $game_party.menu_actor.extra
  2557.       if skill.id == skill_id
  2558.         $game_party.coll.push(
  2559.         $game_party.menu_actor.extra.slice!($game_party.menu_actor.extra.index(skill)))
  2560.         break
  2561.       end
  2562.     end
  2563.     RPG::SE.new("Cursor1", 80, 100).play
  2564.     @extra_window.refresh
  2565.     @coll_window.refresh
  2566.     update_text_window
  2567.   end
  2568.  
  2569.   #-----------------------------------------------------------------------------
  2570.   # Activates filter
  2571.   #-----------------------------------------------------------------------------
  2572.   def activate_filter
  2573.     @filter_window.show
  2574.     @filter_window.activate
  2575.     @deck_window.deactivate
  2576.     @extra_window.deactivate
  2577.     @coll_window.deactivate
  2578.   end
  2579.  
  2580.   #-----------------------------------------------------------------------------
  2581.   # Changes filter settings
  2582.   #-----------------------------------------------------------------------------
  2583.   def change_filter
  2584.     case @filter_window.current_symbol
  2585.     when :filter_element
  2586.       @coll_window.filter[0]   += 1
  2587.       @filter_window.filter[0] += 1
  2588.       @coll_window.filter[0]    = 0 if $data_system.elements.size == @coll_window.filter[0]
  2589.       @filter_window.filter[0]  = 0 if $data_system.elements.size == @filter_window.filter[0]
  2590.     when :filter_type
  2591.       @coll_window.filter[1]   += 1
  2592.       @filter_window.filter[1] += 1
  2593.       @coll_window.filter[1]    = 0 unless TYPE.has_key?(@coll_window.filter[1])
  2594.       @filter_window.filter[1]  = 0 unless TYPE.has_key?(@filter_window.filter[1])
  2595.     when :filter_rarity
  2596.       @coll_window.filter[2]   += 1
  2597.       @filter_window.filter[2] += 1
  2598.       @coll_window.filter[2]    = 0 unless RARITY.has_key?(@coll_window.filter[2])
  2599.       @filter_window.filter[2]  = 0 unless RARITY.has_key?(@filter_window.filter[2])
  2600.     when :filter_subtype
  2601.       @coll_window.filter[3]   += 1
  2602.       @filter_window.filter[3] += 1
  2603.       @coll_window.filter[3]    = 0 unless SUBTYPE.has_key?(@coll_window.filter[3])
  2604.       @filter_window.filter[3]  = 0 unless SUBTYPE.has_key?(@filter_window.filter[3])
  2605.     when :filter_level
  2606.       @coll_window.filter[4]   += 1
  2607.       @filter_window.filter[4] += 1
  2608.       @coll_window.filter[4]    = 0 unless LEVEL.has_key?(@coll_window.filter[4])
  2609.       @filter_window.filter[4]  = 0 unless LEVEL.has_key?(@filter_window.filter[4])
  2610.     when :filter_normeff
  2611.       @coll_window.filter[5]   += 1
  2612.       @filter_window.filter[5] += 1
  2613.       @coll_window.filter[5]    = 0 unless NORMEFF.has_key?(@coll_window.filter[5])
  2614.       @filter_window.filter[5]  = 0 unless NORMEFF.has_key?(@filter_window.filter[5])
  2615.     when :filter_frame
  2616.       @coll_window.filter[6]   += 1
  2617.       @filter_window.filter[6] += 1
  2618.       @coll_window.filter[6]    = 0 unless FRAME.has_key?(@coll_window.filter[6])
  2619.       @filter_window.filter[6]  = 0 unless FRAME.has_key?(@filter_window.filter[6])
  2620.     when :filter_archetype
  2621.       @coll_window.filter[7]   += 1
  2622.       @filter_window.filter[7] += 1
  2623.       @coll_window.filter[7]    = 0 unless ARCHETYPE.has_key?(@coll_window.filter[7])
  2624.       @filter_window.filter[7]  = 0 unless ARCHETYPE.has_key?(@filter_window.filter[7])
  2625.     when :filter_atk
  2626.       @coll_window.filter[8]   += 1
  2627.       @filter_window.filter[8] += 1
  2628.       @coll_window.filter[8]    = 0 unless ATK.has_key?(@coll_window.filter[8])
  2629.       @filter_window.filter[8]  = 0 unless ATK.has_key?(@filter_window.filter[8])
  2630.       when :filter_DEF
  2631.       @coll_window.filter[9]   += 1
  2632.       @filter_window.filter[9] += 1
  2633.       @coll_window.filter[9]    = 0 unless DEF.has_key?(@coll_window.filter[9])
  2634.       @filter_window.filter[9]  = 0 unless DEF.has_key?(@filter_window.filter[9])
  2635.     when :filter_special
  2636.       @coll_window.filter[10]   += 1
  2637.       @filter_window.filter[10] += 1
  2638.       @coll_window.filter[10]    = 0 unless SPECIAL.has_key?(@coll_window.filter[10])
  2639.       @filter_window.filter[10]  = 0 unless SPECIAL.has_key?(@filter_window.filter[10])
  2640.     when :confirm
  2641.       $game_party.coll += $game_party.menu_actor.deck + $game_party.menu_actor.extra
  2642.       $game_party.menu_actor.deck = []
  2643.       $game_party.menu_actor.extra = []
  2644.       @filter_window.confirm = false
  2645.       @filter_window.refresh
  2646.     when :call_confirm
  2647.       @filter_window.confirm = true
  2648.       @filter_window.refresh
  2649.     end
  2650.     @filter_window.refresh
  2651.     @coll_window.refresh
  2652.     @deck_window.refresh
  2653.     @extra_window.refresh
  2654.     update_text_window
  2655.   end
  2656.  
  2657.   #-----------------------------------------------------------------------------
  2658.   # Deativates filter
  2659.   #-----------------------------------------------------------------------------
  2660.   def close_filter
  2661.     @filter_window.hide
  2662.     @filter_window.deactivate
  2663.     @coll_window.activate
  2664.     @coll_window.select(0)
  2665.   end
  2666.  
  2667.  
  2668.   #-----------------------------------------------------------------------------
  2669.   # * Frame Update
  2670.   #-----------------------------------------------------------------------------
  2671.   def update
  2672.     super()
  2673.  
  2674.   def next_actor
  2675.     if $game_party.menu_actor.deck.size <= 39
  2676.     RPG::SE.new("Buzzer1", 80, 100).play
  2677.     $game_message.add('Your deck has less than 40 cards.')
  2678.     else
  2679.     @actor = $game_party.menu_actor_next
  2680.     on_actor_change
  2681.   end
  2682.   end
  2683.  
  2684.   def prev_actor
  2685.     if $game_party.menu_actor.deck.size <= 39
  2686.     RPG::SE.new("Buzzer1", 80, 100).play
  2687.     $game_message.add('Your deck has less than 40 cards.')
  2688.     else
  2689.     @actor = $game_party.menu_actor_prev
  2690.     on_actor_change
  2691.     end
  2692.   end
  2693.    
  2694.     #---------------------------------------------------------------------------
  2695.     # Handles input
  2696.     #---------------------------------------------------------------------------
  2697.     if @filter_window.visible == false
  2698.       change_to_coll  if Input.trigger?(:RIGHT)
  2699.       change_to_deck  if Input.trigger?(:LEFT)
  2700.       change_to_extra if Input.trigger?(:A)
  2701.       activate_filter if Input.trigger?(:X)
  2702.       next_actor      if Input.trigger?(:R)
  2703.       prev_actor      if Input.trigger?(:L)
  2704.     end
  2705.    
  2706.     #---------------------------------------------------------------------------
  2707.     # Redraws card, if neccessary
  2708.     #---------------------------------------------------------------------------
  2709.     if @coll_window.active
  2710.       symbol = @coll_window.current_symbol
  2711.     elsif @deck_window.active
  2712.       symbol = @deck_window.current_symbol
  2713.     elsif @extra_window.active
  2714.       symbol = @extra_window.current_symbol
  2715.     end
  2716.    
  2717.     if symbol != @symbol
  2718.       @symbol = symbol
  2719.       /[kl](?<id>\d+)/ =~ @symbol.to_s
  2720.       skill = ( id ? $data_skills[id.to_i] : nil)
  2721.       @card_window.set_item(skill)
  2722.     end
  2723.    
  2724.   end
  2725.  
  2726.   def on_actor_change
  2727.     RPG::SE.new("Cursor2", 80, 100).play
  2728.     @deck_window.refresh
  2729.     @extra_window.refresh
  2730.     @deck_window.select(0)
  2731.     @extra_window.select(0)
  2732.     @coll_window.select(0)
  2733.     update_text_window
  2734.   end
  2735.  
  2736.   def update_text_window
  2737.     @text_window.contents.clear
  2738.     text_name = $game_party.menu_actor.name + "'s Main " + DECK + ":"
  2739.     @text_window.draw_text_ex(0, -3, text_name)
  2740.     text_deck = $game_party.menu_actor.deck.size.to_s + "/" + MAX_DECK_SIZE.to_s
  2741.     xpos = @text_window.width - 10*(text_deck.size+2) - @text_window.padding
  2742.     @text_window.draw_text_ex(xpos, -3, text_deck)
  2743.     text_extra = "Extra Deck: " + $game_party.menu_actor.extra.size.to_s + "/" + MAX_EXTRA_SIZE.to_s
  2744.     @text_window.draw_text_ex(2, 19, text_extra)
  2745.   end
  2746.  
  2747. end
  2748.  
  2749. class Window_Deck < Window_Command
  2750.  
  2751.   #--------------------------------------------------------------------------
  2752.   # Makes Command List
  2753.   #--------------------------------------------------------------------------
  2754.   def make_command_list
  2755.     add_deck_commands
  2756.   end
  2757.  
  2758.   #--------------------------------------------------------------------------
  2759.   # Add Card Commands to List
  2760.   #--------------------------------------------------------------------------
  2761.   def add_deck_commands
  2762.     $game_party.menu_actor.sort_cards(:deck)
  2763.     deck = $game_party.menu_actor.deck
  2764.     if deck.empty?
  2765.       add_command("---", :nothing)
  2766.       return
  2767.     end
  2768.     hash = {}
  2769.     for skill in deck
  2770.       if hash.has_key?(skill.id)
  2771.         hash[skill.id] += 1
  2772.       else
  2773.         hash[skill.id] = 1
  2774.       end
  2775.     end
  2776.     hash.each_key do |id|
  2777.       add_command(hash[id].to_s + "x " + $data_skills[id].name, ("deck" + id.to_s).to_sym)
  2778.     end
  2779.   end
  2780.  
  2781.   #--------------------------------------------------------------------------
  2782.   # Get Window Height
  2783.   #--------------------------------------------------------------------------
  2784.   def window_height
  2785.     Graphics.height - 200
  2786.   end
  2787.  
  2788.   #--------------------------------------------------------------------------
  2789.   # Get Window width
  2790.   #--------------------------------------------------------------------------
  2791.   def window_width
  2792.     (Graphics.width - 210) * 0.5
  2793.   end
  2794.  
  2795.   #--------------------------------------------------------------------------
  2796.   # Overwrite process_ok so the window won't be disabled
  2797.   #--------------------------------------------------------------------------
  2798.   def process_ok
  2799.     if current_item_enabled?
  2800.       Input.update
  2801.       call_ok_handler
  2802.       select(index - 1) unless current_symbol
  2803.     else
  2804.       Sound.play_buzzer
  2805.     end
  2806.   end
  2807.  
  2808. end
  2809.  
  2810. class Window_Extra < Window_Command
  2811.  
  2812.   #--------------------------------------------------------------------------
  2813.   # Makes Command List
  2814.   #--------------------------------------------------------------------------
  2815.   def make_command_list
  2816.     add_extra_commands
  2817.   end
  2818.  
  2819.   #--------------------------------------------------------------------------
  2820.   # Add Card Commands to List
  2821.   #--------------------------------------------------------------------------
  2822.   def add_extra_commands
  2823.     $game_party.menu_actor.sort_cards(:extra)
  2824.     extra = $game_party.menu_actor.extra
  2825.     if extra.empty?
  2826.       add_command("---", :nothing)
  2827.       return
  2828.     end
  2829.     hash = {}
  2830.     for skill in extra
  2831.       if hash.has_key?(skill.id)
  2832.         hash[skill.id] += 1
  2833.       else
  2834.         hash[skill.id] = 1
  2835.       end
  2836.     end
  2837.     hash.each_key do |id|
  2838.       add_command(hash[id].to_s + "x " + $data_skills[id].name, ("extra" + id.to_s).to_sym)
  2839.     end
  2840.   end
  2841.  
  2842.   #--------------------------------------------------------------------------
  2843.   # Get Window Height
  2844.   #--------------------------------------------------------------------------
  2845.   def window_height
  2846.     136
  2847.   end
  2848.  
  2849.   #--------------------------------------------------------------------------
  2850.   # Get Window width
  2851.   #--------------------------------------------------------------------------
  2852.   def window_width
  2853.     (Graphics.width - 210) * 0.5
  2854.   end
  2855.  
  2856.   #--------------------------------------------------------------------------
  2857.   # Overwrite process_ok so the window won't be disabled
  2858.   #--------------------------------------------------------------------------
  2859.   def process_ok
  2860.     if current_item_enabled?
  2861.       Input.update
  2862.       call_ok_handler
  2863.       select(index - 1) unless current_symbol
  2864.     else
  2865.       Sound.play_buzzer
  2866.     end
  2867.   end
  2868.  
  2869. end
  2870.  
  2871. class Window_Coll < Window_Command
  2872.  
  2873.   attr_accessor :filter
  2874.    
  2875.   def initialize(width, heigth)
  2876.     @filter = [0,0,0,0,0,0,0,0,0,0,0]
  2877.     super(width, heigth)
  2878.   end
  2879.  
  2880.   #--------------------------------------------------------------------------
  2881.   # Makes Command List
  2882.   #--------------------------------------------------------------------------
  2883.   def make_command_list
  2884.     add_coll_commands
  2885.   end
  2886.  
  2887.   #--------------------------------------------------------------------------
  2888.   # Add Collection Commands to List
  2889.   #--------------------------------------------------------------------------
  2890.   def add_coll_commands
  2891.     $game_party.coll.sort!{|a,b| a.id <=> b.id}
  2892.     coll = $game_party.coll
  2893.     if coll.empty?
  2894.       add_command("---", :nothing)
  2895.       return
  2896.     end
  2897.     hash = {}
  2898.     for skill in coll
  2899.       next unless match_filter?(skill)
  2900.       if hash.has_key?(skill.id)
  2901.         hash[skill.id] += 1
  2902.       else
  2903.         hash[skill.id] = 1
  2904.       end
  2905.     end
  2906.     hash.each_key do |id|
  2907.       add_command(hash[id].to_s + "x " + $data_skills[id].name, ("coll" + id.to_s).to_sym)
  2908.     end
  2909.   end
  2910.  
  2911.   #--------------------------------------------------------------------------
  2912.   # Checks if a card meets the specified filter criteria
  2913.   #--------------------------------------------------------------------------
  2914.   def match_filter?(skill)
  2915.     return false unless skill.damage.element_id  == @filter[0] || @filter[0] == 0
  2916.     return false unless skill.type               == @filter[1] || @filter[1] == 0
  2917.     return false unless skill.rarity             == @filter[2] || @filter[2] == 0
  2918.     return false unless skill.subtype            == @filter[3] || @filter[3] == 0
  2919.     return false unless skill.level              == @filter[4] || @filter[4] == 0
  2920.     return false unless skill.normeff            == @filter[5] || @filter[5] == 0
  2921.     return false unless skill.frame              == @filter[6] || @filter[6] == 0
  2922.     return false unless skill.archetype          == @filter[7] || @filter[7] == 0
  2923.     return false unless skill.atk                == @filter[8] || @filter[8] == 0
  2924.     return false unless skill.def                == @filter[9] || @filter[9] == 0
  2925.     return false unless skill.special            == @filter[10] || @filter[10] == 0
  2926.     return true
  2927.   end
  2928.  
  2929.  
  2930.   #--------------------------------------------------------------------------
  2931.   # Get Window Height
  2932.   #--------------------------------------------------------------------------
  2933.   def window_height
  2934.     Graphics.height - 64
  2935.   end
  2936.  
  2937.   #--------------------------------------------------------------------------
  2938.   # Get Window width
  2939.   #--------------------------------------------------------------------------
  2940.   def window_width
  2941.     (Graphics.width - 210) * 0.5
  2942.   end
  2943.  
  2944.   def process_ok
  2945.     if current_item_enabled?
  2946.       Input.update
  2947.       call_ok_handler
  2948.       select(index - 1) unless current_symbol
  2949.     else
  2950.       Sound.play_buzzer
  2951.     end
  2952.   end
  2953.  
  2954. end
  2955.  
  2956.  
  2957. class Window_Filter < Window_Command
  2958.   include PC27::CG
  2959.  
  2960.   attr_accessor :filter
  2961.   attr_accessor :confirm
  2962.  
  2963.   def initialize(width, heigth)
  2964.     @filter = [0,0,0,0,0,0,0,0,0,0,0]
  2965.     @confirm = false
  2966.     super(width, heigth)
  2967.     hide
  2968.   end
  2969.    
  2970.   #--------------------------------------------------------------------------
  2971.   # Makes Command List
  2972.   #--------------------------------------------------------------------------
  2973.   def make_command_list
  2974.     add_filter_commands
  2975.   end
  2976.  
  2977.   #--------------------------------------------------------------------------
  2978.   # Add Collection Commands to List
  2979.   #--------------------------------------------------------------------------
  2980.   def add_filter_commands
  2981.     add_command(FILTER_TEXT + F_ELEMENT + (@filter[0]==0 ? "---" : $data_system.elements[@filter[0]] ), :filter_element)
  2982.     add_command(FILTER_TEXT + F_TYPE    + (@filter[1]==0 ? "---" : TYPE[@filter[1]]),        :filter_type)
  2983.     add_command(FILTER_TEXT + F_RARITY  + (@filter[2]==0 ? "---" : RARITY[@filter[2]][1]),   :filter_rarity)
  2984.     add_command(FILTER_TEXT + F_SUBTYPE + (@filter[3]==0 ? "---" : SUBTYPE[@filter[3]][1]),   :filter_subtype)
  2985.     add_command(FILTER_TEXT + F_LEVEL   + (@filter[4]==0 ? "---" : LEVEL[@filter[4]][1]),   :filter_level)
  2986.     add_empty_deck_command
  2987.   end
  2988.   #--------------------------------------------------------------------------
  2989.   # Get Window Height
  2990.   #--------------------------------------------------------------------------
  2991.   def window_height
  2992.     96
  2993.   end
  2994.   #--------------------------------------------------------------------------
  2995.   # Get Window width
  2996.   #--------------------------------------------------------------------------
  2997.   def window_width
  2998.     Graphics.width
  2999.   end
  3000.  
  3001.   def process_ok
  3002.     if current_item_enabled?
  3003.       RPG::SE.new("Cursor1", 80, 100)
  3004.       Input.update
  3005.       call_ok_handler
  3006.     else
  3007.       Sound.play_buzzer
  3008.     end
  3009.   end
  3010.  
  3011.   def add_empty_deck_command
  3012.     if @confirm
  3013.       add_command(CONFIRM, :confirm)
  3014.     else
  3015.       add_command(EMPTY_DECK, :call_confirm)
  3016.     end
  3017.   end
  3018.  
  3019.   def hide
  3020.     @confirm = false
  3021.     super
  3022.   end
  3023. end
  3024.  
  3025.  
  3026. class Window_MenuCommand < Window_Command
  3027.  
  3028.   #--------------------------------------------------------------------------
  3029.   # Replaces skills with Deck (overwrite)
  3030.   #--------------------------------------------------------------------------
  3031.  
  3032.   def add_main_commands
  3033.     add_command(Vocab::item,    :item,   main_commands_enabled)
  3034.     add_command(PC27::CG::DECK, :deck,   main_commands_enabled)
  3035.     add_command(Vocab::equip,   :equip,  main_commands_enabled)
  3036.     add_command(Vocab::status,  :status, main_commands_enabled)
  3037.   end
  3038.  
  3039. end
  3040.  
  3041.  
  3042. class Scene_Menu < Scene_MenuBase  
  3043.  
  3044.   #--------------------------------------------------------------------------
  3045.   # Adds a handler to access the deck scene (alias)
  3046.   #--------------------------------------------------------------------------
  3047.   alias pc27_cardgame_scenemenu_create_cmd_wdw             create_command_window
  3048.   def create_command_window
  3049.     pc27_cardgame_scenemenu_create_cmd_wdw
  3050.     @command_window.set_handler(:deck,    method(:command_personal))
  3051.   end
  3052.  
  3053.   #--------------------------------------------------------------------------
  3054.   # Adds :deck to the personal command process (alias)
  3055.   #--------------------------------------------------------------------------
  3056.   alias pc27_cardgame_scenemenu_on_personal_ok                    on_personal_ok
  3057.   def on_personal_ok
  3058.     pc27_cardgame_scenemenu_on_personal_ok
  3059.     case @command_window.current_symbol
  3060.     when :deck
  3061.       SceneManager.call(Scene_Deck)
  3062.     end
  3063.   end
  3064.  
  3065. end
  3066.  
  3067. ################################################################################
  3068. #                            End of script                                     #
  3069. ################################################################################
Add Comment
Please, Sign In to add comment