Mattsuharu1991

Card game script for chat gpt

Feb 2nd, 2025
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 119.94 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. 13 => [ 803, "Dark World"],
  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 => [238,238,238,240,240,240,242,242,242,186,186,186,193,193,193,97,97,97],
  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], :field, 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. "genta" => [:take, 0, :deck, :deck, [0,0,0,27,0,0,0,13,0,0,0], :hand, 1],
  563. "costgatesdw" => [:take, 0, :grave, :grave, [0,0,0,3,0,0,0,0,0,0,0], :banish, 1],
  564. "effgatesdw" => [:takem, 0, :hand, :hand, [0,0,0,3,0,0,0,0,0,0,0], :grave, 1],
  565.  
  566. } # do not remove this
  567.  
  568. #-------------------------------------------------------------------------------
  569. #
  570. # End Options
  571. #
  572. #-------------------------------------------------------------------------------
  573.  
  574. end #CG
  575. end #PC27
  576.  
  577. ################################################################################
  578. # Start of script #
  579. ################################################################################
  580.  
  581. $imported = {} if $imported.nil?
  582. $imported["PC27: CardGame System"] = true
  583.  
  584. #===============================================================================
  585. # Load notetags
  586. #===============================================================================
  587.  
  588. module DataManager
  589.  
  590. class <<self; alias load_database_pc27_cardgame load_database; end
  591.  
  592. def self.load_database
  593. load_database_pc27_cardgame
  594. load_notetags_pc27_cardgame
  595. end
  596.  
  597. def self.load_notetags_effect
  598. for skill in $data_skills
  599. next if skill.nil?
  600. skill.load_notetags_effect
  601. end
  602. end
  603.  
  604. def self.load_notetags_pc27_cardgame
  605. for skill in $data_skills
  606. next if skill.nil?
  607. skill.load_notetags_pc27_cardgame_skill
  608. end
  609. for item in $data_items
  610. next if item.nil?
  611. item.load_notetags_pc27_cardgame_item
  612. end
  613. for state in $data_states
  614. next if state.nil?
  615. state.load_notetags_pc27_cardgame_states
  616. end
  617. for equip_type in [$data_weapons, $data_armors]
  618. for obj in equip_type
  619. next if obj.nil?
  620. obj.load_notetags_pc27_cardgame_equip
  621. end
  622. end
  623. end
  624. end
  625.  
  626. class RPG::UsableItem < RPG::BaseItem
  627. attr_accessor :card_id
  628. attr_accessor :type
  629. attr_accessor :rarity
  630. attr_accessor :subtype
  631. attr_accessor :level
  632. attr_accessor :normeff
  633. attr_accessor :frame
  634. attr_accessor :archetype
  635. attr_accessor :atk
  636. attr_accessor :def
  637. attr_accessor :special
  638. attr_accessor :cost
  639. attr_accessor :impact
  640. attr_accessor :impact2
  641. attr_accessor :fieldeff
  642. attr_accessor :graveeff
  643. attr_accessor :handeff
  644.  
  645. #-----------------------------------------------------------------------------
  646. # Add card attributes
  647. #-----------------------------------------------------------------------------
  648. def load_notetags_pc27_cardgame_skill
  649. @description = wordwrap(@description)
  650. @card_id = 0
  651. @type = 1
  652. @rarity = 1
  653. @subtype = 1
  654. @level = 1
  655. @normeff = 1
  656. @frame = 1
  657. @archetype = 1
  658. @atk = 1
  659. @def = 1
  660. @special = 1
  661. @cost = false
  662. @impact = false
  663. @fieldeff = 0
  664. @graveeff = 0
  665. self.note.split(/[\r\n]+/).each { |line|
  666. if /<card[ -_]id: +(?<inr>\d+)>/i =~ line
  667. @card_id = inr.to_i
  668. elsif /<card[ -_]type: +(?<tnr>\d+)>/i =~ line
  669. @type = tnr.to_i
  670. elsif /<card[ -_]rarity: +(?<rnr>\d+)>/i =~ line
  671. @rarity = rnr.to_i
  672. elsif /<card[ -_]subtype: +(?<stnr>\d+)>/i =~ line
  673. @subtype = stnr.to_i
  674. elsif /<card[ -_]level: +(?<lvnr>\d+)>/i =~ line
  675. @level = lvnr.to_i
  676. elsif /<card[ -_]normeff: +(?<nenr>\d+)>/i =~ line
  677. @normeff = nenr.to_i
  678. elsif /<card[ -_]frame: +(?<frnr>\d+)>/i =~ line
  679. @frame = frnr.to_i
  680. elsif /<card[ -_]archetype: +(?<arnr>\d+)>/i =~ line
  681. @archetype = arnr.to_i
  682. elsif /<card[ -_]atk: +(?<atnr>\d+)>/i =~ line
  683. @atk = atnr.to_i
  684. elsif /<card[ -_]def: +(?<dfnr>\d+)>/i =~ line
  685. @def = dfnr.to_i
  686. elsif /<card[ -_]special: +(?<spnr>\d+)>/i =~ line
  687. @special = spnr.to_i
  688. elsif /<card[ -_]cost: +(?<cst>.+)>/i =~ line
  689. @cost = cst
  690. elsif /<card[ -_]impact: +(?<imp>.+)>/i =~ line
  691. @impact = imp
  692. elsif /<card[ -_]impact2: +(?<imp2>.+)>/i =~ line
  693. @impact2 = imp2
  694. elsif /<(?:field)[ ](\d+)>/i =~ line
  695. @fieldeff = $1.to_i
  696. elsif /<(?:grave)[ ](\d+)>/i =~ line
  697. @graveeff = $1.to_i
  698. elsif /<(?:hand)[ ](\d+)>/i =~ line
  699. @handeff = $1.to_i
  700. end
  701. }
  702. end
  703.  
  704. def load_notetags_pc27_cardgame_item
  705. @impact = false
  706. @impact2 = false
  707. @fieldeff = 0
  708. @graveeff = 0
  709. @handeff = 0
  710. self.note.split(/[\r\n]+/).each { |line|
  711. if /<card[ -_]impact: +(?<imp>.+)>/i =~ line
  712. @impact = imp
  713. elsif /<card[ -_]impact2: +(?<imp2>.+)>/i =~ line
  714. @impact2 = imp2
  715. elsif /<(?:field)[ ](\d+)>/i =~ line
  716. @fieldeff = $1.to_i
  717. elsif /<(?:grave)[ ](\d+)>/i =~ line
  718. @graveeff = $1.to_i
  719. elsif /<(?:hand)[ ](\d+)>/i =~ line
  720. @handeff = $1.to_i
  721. end
  722. }
  723. end
  724.  
  725. #-----------------------------------------------------------------------------
  726. # Method to rearange text so it fits inside a window
  727. #-----------------------------------------------------------------------------
  728. def wordwrap(desc_text, window = nil, default_max_chars = 16)
  729. max_chars = (window ? (window.width - 2 * window.padding) / 10 : default_max_chars)
  730. text, line= "", ""
  731. desc_text.split(/[\r\n ]+/).each { |word|
  732. if word.size + line.size > max_chars
  733. text += line+"\n"
  734. line = word
  735. else
  736. line += word
  737. end
  738. line += " "
  739. }
  740. text += line
  741. return text
  742. end
  743.  
  744. end
  745.  
  746. class RPG::EquipItem < RPG::BaseItem
  747. attr_accessor :extra_turn_cards
  748. attr_accessor :extra_start_cards
  749.  
  750. def load_notetags_pc27_cardgame_equip
  751. @extra_turn_cards = 0
  752. @extra_start_cards = 0
  753. self.note.split(/[\r\n]+/).each { |line|
  754. if /<extra[ -_]turn[ -_]cards: +(?<tnr>\d+)>/i =~ line
  755. @extra_turn_cards = tnr.to_i
  756. elsif /<extra[ -_]start[ -_]cards: +(?<snr>\d+)>/i =~ line
  757. @extra_start_cards = snr.to_i
  758. end
  759. }
  760. end
  761. end
  762.  
  763. class RPG::State < RPG::BaseItem
  764. attr_reader :limited_actions
  765.  
  766. def load_notetags_pc27_cardgame_states
  767. @limited_actions = 0
  768. self.note.split(/[\r\n]+/).each { |line|
  769. if /<limited[ -_]actions: +(?<lnr>\d+)>/i =~ line
  770. @limited_actions = lnr.to_i
  771. end
  772. }
  773. end
  774. end
  775.  
  776. #===============================================================================
  777. # Game_Interpreter
  778. #===============================================================================
  779. class Game_Interpreter
  780.  
  781. def add_card_to_coll(*args)
  782. for id in args
  783. $game_party.coll.push($data_skills[id])
  784. end
  785. end
  786.  
  787. def remove_card?(id)
  788. for i in (0...$game_party.coll.length)
  789. if $game_party.coll[i].id == id
  790. $game_party.coll.delete_at(i)
  791. return true
  792. end
  793. end
  794. return false
  795. end
  796.  
  797. def remove_all_cards(*args)
  798. for id in args
  799. $game_party.coll -= [$data_skills[id]]
  800. for actor in $game_party.members
  801. actor.deck -= [$data_skills[id]]
  802. end
  803. end
  804. end
  805.  
  806. def has_card?(id)
  807. for card in $game_party.coll
  808. return true if card.id == id
  809. end
  810. for actor in $game_party.members
  811. for card in actor.deck
  812. return true if card.id == id
  813. end
  814. end
  815. return false
  816. end
  817.  
  818. def atributes_in_grave(id, count)
  819. if self.grave.count { |card| skill.damage.element_id == id} <= count
  820. return true
  821. else
  822. return false
  823. end
  824. end
  825.  
  826. def has_card_in_deck?(id)
  827. for card in self.deck
  828. return true if card.id == id
  829. end
  830. return false
  831. end
  832.  
  833. def has_card_in_field?(id)
  834. for card in self.field
  835. return true if card.id == id
  836. end
  837. return false
  838. end
  839.  
  840. def has_many_card_in_deck?(count)
  841. return self.deck.count { |card| } >= count
  842. end
  843.  
  844. def has_x_cards?(id, count)
  845. return self.deck.count { |card| card.id == id } >= count
  846. end
  847.  
  848. def has_card_in_hand?(id)
  849. for card in self.hand
  850. return true if card.id == id
  851. end
  852. return false
  853. end
  854.  
  855. def has_card_in_grave?(id)
  856. actor = $game_actors[$game_variables[27]]
  857. for card in actor.grave
  858. return true if card.id == id
  859. end
  860. return false
  861. end
  862.  
  863. def has_x_cards_in_grave?(id, count)
  864. actor = $game_actors[$game_variables[27]]
  865. return actor.grave.count { |card| card.id == id } >= count
  866. end
  867.  
  868. def numinous_in_grave
  869. nr = 0
  870. for actor in $game_party.members
  871. nr += actor.grave.count { |card| card.id == 29 }
  872. end
  873. return nr
  874. end
  875.  
  876. def has_card_in_banish?(id)
  877. actor = $game_actors[$game_variables[27]]
  878. for card in actor.banish
  879. return true if card.id == id
  880. end
  881. return false
  882. end
  883.  
  884. def has_x_cards_in_banish?(id, count)
  885. actor = $game_actors[$game_variables[27]]
  886. return actor.banish.count { |card| card.id == id } >= count
  887. end
  888.  
  889. def add_card_deck(*args)
  890. for id in args
  891. actor = $game_actors[$game_variables[27]]
  892. actor.deck += [$data_skills[id]]
  893. end
  894. end
  895.  
  896. def remove_card_deck(*args)
  897. for id in args
  898. actor = $game_actors[$game_variables[27]]
  899. actor.deck -= [$data_skills[id]]
  900. end
  901. end
  902.  
  903. def add_card_hand(*args)
  904. for id in args
  905. self.hand += [$data_skills[id]]
  906. end
  907. end
  908.  
  909. def summon_token(*args)
  910. for id in args
  911. self.field += [$data_skills[id]]
  912. end
  913. end
  914.  
  915. def add_card_hand_2(*args)
  916. for id in args
  917. actor = $game_actors[$game_variables[27]]
  918. actor.hand += [$data_skills[id]]
  919. end
  920. end
  921.  
  922. def remove_card_hand(*args)
  923. for id in args
  924. self.hand -= [$data_skills[id]]
  925. end
  926. end
  927.  
  928. def send_card_from_hand_to_grave(*args)
  929. for id in args
  930. actor = $game_actors[$game_variables[42]]
  931. actor.hand -= [$data_skills[id]]
  932. actor.grave += [$data_skills[id]]
  933. end
  934. end
  935.  
  936. def send_card_from_hand_to_grave_2(id)
  937. actor = $game_actors[$game_variables[42]]
  938. for i in (0...actor.hand.length)
  939. if actor.hand[i].id == id
  940. actor.grave.push(@hand[i])
  941. actor.hand.delete_at(i)
  942. return true
  943. end
  944. end
  945. return false
  946. end
  947.  
  948. def count_actor_deck(id)
  949. return $game_actors[id].deck.size
  950. end
  951.  
  952. def count_all_decks
  953. nr = 0
  954. for actor in $game_party.members
  955. nr += actor.deck.size
  956. end
  957. return nr
  958. end
  959. end
  960.  
  961. #===============================================================================
  962. # Game_Battler
  963. #===============================================================================
  964.  
  965. class Game_Battler < Game_BattlerBase
  966.  
  967. #-----------------------------------------------------------------------------
  968. # defines card actions for non actors, in case the user messes up
  969. #-----------------------------------------------------------------------------
  970. def revive_grave(show = true) ;end
  971. def revive_penalty ;end
  972. def shuffle_deck(sound = true);end
  973. def card_to_grave?(id) ;end
  974. def throw_cards(n) ;end
  975. def draw_cards(n) ;end
  976.  
  977. end
  978.  
  979. #===============================================================================
  980. # Game_Actor
  981. #===============================================================================
  982.  
  983. class Game_Actor < Game_Battler
  984.  
  985. #-----------------------------------------------------------------------------
  986. # Attributes
  987. #-----------------------------------------------------------------------------
  988. attr_accessor :deck
  989. attr_accessor :grave
  990. attr_accessor :banish
  991. attr_accessor :extra
  992. attr_accessor :hand
  993. attr_accessor :field
  994. attr_accessor :monster_zones
  995. attr_accessor :spell_trap_zones
  996. attr_accessor :stack
  997. attr_accessor :turn_actions
  998.  
  999. #-----------------------------------------------------------------------------
  1000. # Adds Hand, Deck, Grave, Banish, Extra, Field and Stack to an Actor (alias)
  1001. #-----------------------------------------------------------------------------
  1002. alias pc27_cardgame_gameactor_setup setup
  1003. def setup(actor_id)
  1004. pc27_cardgame_gameactor_setup(actor_id)
  1005. setup_start_deck(actor_id)
  1006. @hand = []
  1007. @grave = []
  1008. @banish = []
  1009. @extra = []
  1010. @field = []
  1011. @stack = []
  1012. @turn_actions = { :can_attack => true,
  1013. :can_guard => true,
  1014. :actions => 0, }
  1015. end
  1016.  
  1017. #-----------------------------------------------------------------------------
  1018. # Setup for the initial deck (new)
  1019. #-----------------------------------------------------------------------------
  1020. def setup_start_deck(actor_id)
  1021. @deck = []
  1022. if PC27::CG::START_DECKS.has_key?(actor_id)
  1023. PC27::CG::START_DECKS[actor_id].each { |card| @deck.push($data_skills[card]) }
  1024. end
  1025. end
  1026.  
  1027. #-----------------------------------------------------------------------------
  1028. # Setup for the initial extra (new)
  1029. #-----------------------------------------------------------------------------
  1030. def setup_start_extra(actor_id)
  1031. @extra = []
  1032. if PC27::CG::START_EXTRA.has_key?(actor_id)
  1033. PC27::CG::START_EXTRA[actor_id].each { |card| @extra.push($data_skills[card]) }
  1034. end
  1035. end
  1036.  
  1037. #-----------------------------------------------------------------------------
  1038. # Draws n cards from the deck (new)
  1039. #-----------------------------------------------------------------------------
  1040. def draw_cards(n, show = true, sound = true)
  1041. n.times do
  1042. if @deck.length == 0
  1043. add_state(1) if PC27::CG::DECK_EMPTY == 1
  1044. return if PC27::CG::DECK_EMPTY == 1
  1045. if @grave.length == 0
  1046. add_state(1) if PC27::CG::DECK_EMPTY == 2
  1047. return
  1048. else
  1049. revive_grave
  1050. revive_penalty if PC27::CG::REVIVE_PENALTY[0] > 0
  1051. end
  1052. end
  1053. RPG::SE.new(*PC27::CG::DRAW_SOUND).play and 30.times { Graphics.update; Input.update } if sound
  1054. skill = @deck.shift
  1055. @hand.push(skill)
  1056. if show
  1057. $game_message.background = 1
  1058. $game_message.position = 1
  1059. text = @name + " " + PC27::CG::DRAW_MESSAGE + " " + skill.name
  1060. $game_message.add(text)
  1061. end
  1062. end
  1063. end
  1064.  
  1065. #-----------------------------------------------------------------------------
  1066. # Puts all cards from your grave back into your deck (new)
  1067. #-----------------------------------------------------------------------------
  1068. def revive_grave(show = true)
  1069. @deck += @grave
  1070. @grave = []
  1071. shuffle_deck(false)
  1072. if show
  1073. $game_message.background = 1
  1074. $game_message.position = 1
  1075. text = @name + PC27::CG::REVIVE_MSG
  1076. $game_message.add(text)
  1077. end
  1078. end
  1079.  
  1080. #-----------------------------------------------------------------------------
  1081. # Revive penalty (new)
  1082. #-----------------------------------------------------------------------------
  1083. def revive_penalty
  1084. percent = PC27::CG::REVIVE_PENALTY[0] * 0.01
  1085. case PC27::CG::REVIVE_PENALTY[1]
  1086. when :hp
  1087. @hp -= (@hp * percent).round
  1088. when :mhp
  1089. @hp -= (@mhp * percent).round
  1090. when :mp
  1091. @mp -= (@mp * percent).round
  1092. when :mmp
  1093. @mp -= (@mmp * percent).round
  1094. end
  1095. RPG::SE.new(*PC27::CG::PENALTY_SOUND).play
  1096. end
  1097.  
  1098. #-----------------------------------------------------------------------------
  1099. # Shuffles the deck (new)
  1100. #-----------------------------------------------------------------------------
  1101. def shuffle_deck(sound = true)
  1102. if sound
  1103. 5.times do
  1104. RPG::SE.new(PC27::CG::DRAW_SOUND[0], 100, 150).play
  1105. 20.times { Graphics.update; Input.update }
  1106. RPG::SE.new(PC27::CG::DRAW_SOUND[0], 100, 100).play
  1107. 10.times { Graphics.update; Input.update }
  1108. end
  1109. end
  1110. @deck = @deck.shuffle
  1111. end
  1112.  
  1113. #-----------------------------------------------------------------------------
  1114. # Sorts Hand, Deck or Grave (new)
  1115. #-----------------------------------------------------------------------------
  1116. def sort_cards(location)
  1117. case location
  1118. when :deck
  1119. @deck.sort!{|a,b| a.card_id <=> b.card_id}
  1120. when :hand
  1121. @hand.sort!{|a,b| a.card_id <=> b.card_id}
  1122. when :grave
  1123. @grave.sort!{|a,b| a.card_id <=> b.card_id}
  1124. when :banish
  1125. @banish.sort!{|a,b| a.card_id <=> b.card_id}
  1126. when :extra
  1127. @extra.sort!{|a,b| a.card_id <=> b.card_id}
  1128. when :field
  1129. @field.sort!{|a,b| a.card_id <=> b.card_id}
  1130. end
  1131. end
  1132.  
  1133. #-----------------------------------------------------------------------------
  1134. # Tries to put a specific card from your hand to your grave (new)
  1135. #-----------------------------------------------------------------------------
  1136. def card_to_grave?(id)
  1137. for i in ([email protected])
  1138. if @hand[i].id == id
  1139. @grave.push(@hand[i])
  1140. @hand.delete_at(i)
  1141. return true
  1142. end
  1143. end
  1144. return false
  1145. end
  1146.  
  1147. #-----------------------------------------------------------------------------
  1148. # Tries to put a specific card from your deck to your grave (new)
  1149. #-----------------------------------------------------------------------------
  1150. def card_from_deck_to_grave?(id)
  1151. for i in ([email protected])
  1152. if @deck[i].id == id
  1153. @grave.push(@deck[i])
  1154. @deck.delete_at(i)
  1155. return true
  1156. end
  1157. end
  1158. return false
  1159. end
  1160.  
  1161. #-----------------------------------------------------------------------------
  1162. # Tries to put a specific card from your hand to your banish (new)
  1163. #-----------------------------------------------------------------------------
  1164. def card_to_banish?(id)
  1165. for i in ([email protected])
  1166. if @hand[i].id == id
  1167. @banish.push(@hand[i])
  1168. @hand.delete_at(i)
  1169. return true
  1170. end
  1171. end
  1172. return false
  1173. end
  1174.  
  1175. #-----------------------------------------------------------------------------
  1176. # Tries to put a specific card from your hand to your stack (new)
  1177. #-----------------------------------------------------------------------------
  1178. def card_to_stack?(id)
  1179. for i in ([email protected])
  1180. if @hand[i].id == id
  1181. @stack.push(@hand[i])
  1182. @hand.delete_at(i)
  1183. return true
  1184. end
  1185. end
  1186. return false
  1187. end
  1188.  
  1189. #-----------------------------------------------------------------------------
  1190. # Tries to put a specific card from your field to your stack (new)
  1191. #-----------------------------------------------------------------------------
  1192. def card_to_field?(id)
  1193. for i in ([email protected])
  1194. if @field[i].id == id
  1195. @stack.push(@field[i])
  1196. @field.delete_at(i)
  1197. return true
  1198. end
  1199. end
  1200. return false
  1201. end
  1202.  
  1203. #-----------------------------------------------------------------------------
  1204. # Tries to put a specific card from your field to your graveyard (new)
  1205. #-----------------------------------------------------------------------------
  1206. def field_to_grave?(id)
  1207. for i in ([email protected])
  1208. if @field[i].id == id
  1209. @grave.push(@field[i])
  1210. @field.delete_at(i)
  1211. return true
  1212. end
  1213. end
  1214. return false
  1215. end
  1216.  
  1217. #-----------------------------------------------------------------------------
  1218. # Puts n random cards from your field to your grave (new)
  1219. #-----------------------------------------------------------------------------
  1220. def send_field(n)
  1221. amount_send_field = 0
  1222. if n == 0
  1223. amount_send_field += @field.size
  1224. @grave += @field
  1225. @field = []
  1226. else
  1227. n.times do
  1228. break if @field.size == 0
  1229. @grave.push(@field.slice!(rand(@field.size-1)))
  1230. amount_send_field += 1
  1231. end
  1232. end
  1233. end
  1234.  
  1235. #-----------------------------------------------------------------------------
  1236. # Puts n random card(s) TYPE from your field to your grave (new)
  1237. #-----------------------------------------------------------------------------
  1238. def send_card_from_field(n)
  1239. for i in ([email protected])
  1240. if @field[i].type == n
  1241. @grave.push(@field[i])
  1242. @field.delete_at(i)
  1243. return true
  1244. end
  1245. end
  1246. return false
  1247. end
  1248.  
  1249. #-----------------------------------------------------------------------------
  1250. # Puts n random cards from your hand to your grave (new)
  1251. #-----------------------------------------------------------------------------
  1252. def throw_cards(n)
  1253. amount_thrown_cards = 0
  1254. if n == 0
  1255. amount_thrown_cards += @hand.size
  1256. @grave += @hand
  1257. @hand = []
  1258. else
  1259. n.times do
  1260. break if @hand.size == 0
  1261. @grave.push(@hand.slice!(rand(@hand.size-1)))
  1262. amount_thrown_cards += 1
  1263. end
  1264. end
  1265. $game_variables[46] = amount_thrown_cards
  1266. return amount_thrown_cards
  1267. end
  1268.  
  1269. #-----------------------------------------------------------------------------
  1270. # Mill n random cards from your deck to your grave (new)
  1271. #-----------------------------------------------------------------------------
  1272. def mill_cards(n)
  1273. amount_mill_cards = 0
  1274. if n == 0
  1275. amount_mill_cards += @deck.size
  1276. @grave += @deck
  1277. @deck = []
  1278. else
  1279. n.times do
  1280. break if @deck.size == 0
  1281. @grave.push(@deck.slice!(rand(@deck.size-1)))
  1282. amount_mill_cards += 1
  1283. end
  1284. end
  1285. end
  1286.  
  1287. #-----------------------------------------------------------------------------
  1288. # Puts n random cards from your hand to your banish (new)
  1289. #-----------------------------------------------------------------------------
  1290. def banish_cards(n)
  1291. amount_banish_cards = 0
  1292. if n == 0
  1293. amount_banish_cards += @hand.size
  1294. @banish += @hand
  1295. @hand = []
  1296. else
  1297. n.times do
  1298. break if @hand.size == 0
  1299. @banish.push(@hand.slice!(rand(@hand.size-1)))
  1300. amount_banish_cards += 1
  1301. end
  1302. end
  1303. $game_variables[51] = amount_banish_cards
  1304. return amount_banish_cards
  1305. end
  1306.  
  1307. #-----------------------------------------------------------------------------
  1308. # Mill n random cards from your deck to your banish (new)
  1309. #-----------------------------------------------------------------------------
  1310. def mill_banish_cards(n)
  1311. amount_mill_banish_cards = 0
  1312. if n == 0
  1313. amount_mill_banish_cards += @deck.size
  1314. @banish += @deck
  1315. @deck = []
  1316. else
  1317. n.times do
  1318. break if @deck.size == 0
  1319. @banish.push(@deck.slice!(rand(@deck.size-1)))
  1320. amount_mill_banish_cards += 1
  1321. end
  1322. end
  1323. end
  1324.  
  1325. #-----------------------------------------------------------------------------
  1326. # Banish n random cards from your extra (new)
  1327. #-----------------------------------------------------------------------------
  1328. def banish_extra_cards(n)
  1329. amount_banish_extra_cards = 0
  1330. if n == 0
  1331. amount_banish_extra_cards += @extra.size
  1332. @banish += @extra
  1333. @extra = []
  1334. else
  1335. n.times do
  1336. break if @extra.size == 0
  1337. @banish.push(@extra.slice!(rand(@extra.size-1)))
  1338. amount_banish_extra_cards += 1
  1339. end
  1340. end
  1341. end
  1342.  
  1343. #-----------------------------------------------------------------------------
  1344. # Replace Field Spell
  1345. #-----------------------------------------------------------------------------
  1346. def replace_field_spell(id)
  1347. for i in ([email protected])
  1348. if @field[i].subtype == id
  1349. @grave.push(@field[i])
  1350. @field.delete_at(i)
  1351. return true
  1352. end
  1353. end
  1354. return false
  1355. end
  1356.  
  1357. #-----------------------------------------------------------------------------
  1358. # Shuffles Deck and draws cards at the begin of each battle (new)
  1359. #-----------------------------------------------------------------------------
  1360. def on_battle_start
  1361. super()
  1362. shuffle_deck(false)
  1363. draw_cards(starting_cards, false, false)
  1364. @turn_actions[:can_attack] = true
  1365. @turn_actions[:can_guard] = true
  1366. @turn_actions[:actions] = available_actions
  1367. end
  1368.  
  1369. #-----------------------------------------------------------------------------
  1370. # Starting Cards (new)
  1371. #-----------------------------------------------------------------------------
  1372. def starting_cards
  1373. x = PC27::CG::START_CARDS
  1374. @equips.each { |equip|
  1375. next unless equip
  1376. next unless equip.object
  1377. x += equip.object.extra_start_cards
  1378. }
  1379. return x
  1380. end
  1381.  
  1382. #-----------------------------------------------------------------------------
  1383. # Draws a card at the end of each turn (new)
  1384. #-----------------------------------------------------------------------------
  1385. def on_turn_end
  1386. super()
  1387. if $game_party.in_battle && !death_state?
  1388. draw_cards(turn_cards, false, true)
  1389. @turn_actions[:can_attack] = true
  1390. @turn_actions[:can_guard] = true
  1391. @turn_actions[:actions] = available_actions
  1392. end
  1393. end
  1394.  
  1395. #-----------------------------------------------------------------------------
  1396. # Determines the amount of actions an actor can make (new)
  1397. #-----------------------------------------------------------------------------
  1398. def available_actions
  1399. for id in @states
  1400. state = $data_states[id]
  1401. if state.limited_actions != 0
  1402. x = state.limited_actions if x.nil? || x > state.limited_actions
  1403. end
  1404. end
  1405. if PC27::CG::MAX_ACTIONS <= 0
  1406. return (x ? x : -1)
  1407. else
  1408. return (x ? [x, PC27::CG::MAX_ACTIONS].min : PC27::CG::MAX_ACTIONS)
  1409. end
  1410. end
  1411.  
  1412. #-----------------------------------------------------------------------------
  1413. # Turn Cards(new)
  1414. #-----------------------------------------------------------------------------
  1415. def turn_cards
  1416. x = 1
  1417. if state?(82)
  1418. x = 0
  1419. end
  1420. @equips.each { |equip|
  1421. next unless equip
  1422. next unless equip.object
  1423. x += equip.object.extra_turn_cards
  1424. if state?(82)
  1425. x = 0
  1426. end
  1427. }
  1428. return x
  1429. end
  1430.  
  1431. #-----------------------------------------------------------------------------
  1432. # Restore deck at the end of battle (new)
  1433. #-----------------------------------------------------------------------------
  1434. def on_battle_end
  1435. @deck += @hand + @grave + @banish + @field
  1436. @deck.select! { |card| card.frame != 5 }
  1437. @deck.select! { |card| card.type != 4 }
  1438. @extra += @hand + @grave + @banish + @field
  1439. @extra.select! { |card| card.type == 4 }
  1440. @hand, @grave, @banish, @field = [],[],[],[]
  1441. super()
  1442. end
  1443.  
  1444. #--------------------------------------------------------------------------
  1445. # * Determine Usability of Attack
  1446. #--------------------------------------------------------------------------
  1447. def attack_usable?
  1448. super && @turn_actions[:can_attack]
  1449. end
  1450.  
  1451. #--------------------------------------------------------------------------
  1452. # * Determine Usability of Guard
  1453. #--------------------------------------------------------------------------
  1454. def guard_usable?
  1455. super && @turn_actions[:can_guard]
  1456. end
  1457.  
  1458. end
  1459.  
  1460. #===============================================================================
  1461. # Game_Party
  1462. #===============================================================================
  1463.  
  1464. class Game_Party < Game_Unit
  1465.  
  1466. #-----------------------------------------------------------------------------
  1467. # Attributes
  1468. #-----------------------------------------------------------------------------
  1469. attr_accessor :coll
  1470.  
  1471. #-----------------------------------------------------------------------------
  1472. # Adds a card collection to the party (alias)
  1473. #-----------------------------------------------------------------------------
  1474. alias pc27_gameparty_initialize initialize
  1475. def initialize
  1476. pc27_gameparty_initialize
  1477. @coll = []
  1478. end
  1479.  
  1480. end
  1481.  
  1482. #===============================================================================
  1483. # Window_SkillList
  1484. #===============================================================================
  1485. class Window_SkillList < Window_Selectable
  1486.  
  1487. def initialize(x, y, width, height)
  1488. super(x, y, Graphics.width, 300) # Full width, bottom half
  1489. @data = []
  1490. make_item_list # Populate @data
  1491. refresh
  1492. end
  1493.  
  1494. def make_item_list
  1495. @actor ||= $game_party.battle_members[0] # Ensure actor is valid
  1496. if @actor.nil?
  1497. @data = []
  1498. return
  1499. end
  1500.  
  1501. # Sort and populate @data
  1502. if $game_variables[55] == 1
  1503. @actor.sort_cards(:hand)
  1504. @data = @actor.hand || []
  1505. else
  1506. @data = []
  1507. end
  1508. end
  1509.  
  1510. def refresh
  1511. contents.clear
  1512. return unless @data && [email protected]?
  1513.  
  1514. selected_index = self.index
  1515. selected_index = nil if selected_index.nil? || selected_index < 0 || selected_index >= @data.size
  1516.  
  1517. # Default stacking order (right to left, leftmost on top)
  1518. stacking_order = ([email protected]).to_a.reverse
  1519.  
  1520. # Ensure last selected card appears **right before the selected card**
  1521. if @last_index && @last_index != selected_index
  1522. stacking_order.delete(@last_index) # Remove from its old position
  1523. insert_position = stacking_order.index(selected_index) || -1
  1524. stacking_order.insert(insert_position, @last_index) # Place it right before selected
  1525. end
  1526.  
  1527. # Always add selected card last (on top)
  1528. stacking_order.delete(selected_index)
  1529. stacking_order << selected_index if selected_index
  1530.  
  1531. # Draw in new stacking order
  1532. stacking_order.each do |index|
  1533. draw_item(index) if index
  1534. end
  1535.  
  1536. # Debugging
  1537. puts "Stacking order: #{stacking_order}, Last selected: #{@last_index}, Selected: #{selected_index}"
  1538.  
  1539. # Update last selected index
  1540. @last_index = selected_index
  1541. end
  1542.  
  1543. def draw_item(index)
  1544. card = @data[index]
  1545. return unless card
  1546.  
  1547. rect = item_rect(index)
  1548.  
  1549. # Adjust for selected card
  1550. if index == self.index
  1551. rect.y -= 3 # Bring to the front visually
  1552. end
  1553.  
  1554. contents.clear_rect(rect)
  1555. draw_card_illustration(card, rect.x, rect.y)
  1556. end
  1557.  
  1558. def draw_card_illustration(card, x, y)
  1559. bitmap = Cache.picture("Card" + card.id.to_s) # Load the card image
  1560. return unless bitmap
  1561.  
  1562. rect = Rect.new(0, 0, 190, 264) # Card dimensions
  1563. contents.blt(x, y, bitmap, rect) # Draw the card at the specified position
  1564. end
  1565.  
  1566. def item_rect(index)
  1567. return Rect.new(0, 0, 0, 0) unless @data && [email protected]? # Safeguard for nil or empty @data
  1568.  
  1569. total_cards = @data.size # Total number of cards in the hand
  1570. card_width = 190 # Fixed width of each card
  1571. usable_width = width - standard_padding * 2 # Width of the window minus padding
  1572.  
  1573. # Calculate overlap dynamically to fit all cards within the usable width
  1574. if total_cards > 1
  1575. overlap = [(card_width * total_cards - usable_width) / (total_cards - 1), card_width].min
  1576. overlap = [overlap, 0].max # Ensure overlap is non-negative
  1577. else
  1578. overlap = 0 # No overlap for a single card
  1579. end
  1580.  
  1581. # Calculate card position
  1582. x = index * (card_width - overlap) # Adjust x based on overlap
  1583. y = 0 # Cards are horizontally stacked; no vertical shift
  1584. Rect.new(x, y, card_width, 264) # Adjust height if necessary
  1585. end
  1586.  
  1587. def update
  1588. super
  1589. if @last_index != self.index
  1590. puts "Cursor moved: Previous index #{@last_index}, Current index #{self.index}" # Debug
  1591. @last_index = self.index # Update the last known cursor position
  1592. refresh # Redraw the hand with the correct stacking order
  1593. end
  1594. end
  1595.  
  1596. end
  1597.  
  1598. #===============================================================================
  1599. # Window_ActorCommand
  1600. #===============================================================================
  1601.  
  1602. class Window_ActorCommand < Window_Command
  1603.  
  1604. #--------------------------------------------------------------------------
  1605. # Add "End Turn" command (new)
  1606. #--------------------------------------------------------------------------
  1607. def add_turn_end_command
  1608. add_command(PC27::CG::END_TURN, :end_turn)
  1609. end
  1610.  
  1611. #--------------------------------------------------------------------------
  1612. # Add "Grave" command (new)
  1613. #--------------------------------------------------------------------------
  1614. def add_look_at_grave_command
  1615. add_command(PC27::CG::GRAVE, :look_grave)
  1616. end
  1617.  
  1618. #--------------------------------------------------------------------------
  1619. # Add "Banish" command (new)
  1620. #--------------------------------------------------------------------------
  1621. def add_look_at_banish_command
  1622. add_command(PC27::CG::BANISH, :look_banish)
  1623. end
  1624.  
  1625. #--------------------------------------------------------------------------
  1626. # Add "Extra" command (new)
  1627. #--------------------------------------------------------------------------
  1628. def add_look_at_extra_command
  1629. add_command(PC27::CG::EXTRA, :look_extra)
  1630. end
  1631.  
  1632. #--------------------------------------------------------------------------
  1633. # Add "Field" command (new)
  1634. #--------------------------------------------------------------------------
  1635. def add_look_at_field_command
  1636. add_command(PC27::CG::FIELD, :look_field)
  1637. end
  1638.  
  1639. #--------------------------------------------------------------------------
  1640. # Make new command List (overwrite)
  1641. #--------------------------------------------------------------------------
  1642. def make_command_list
  1643. return unless @actor
  1644. add_attack_command if PC27::CG::USE_ATTACK
  1645. add_guard_command if PC27::CG::USE_GUARD
  1646. add_skill_commands
  1647. add_item_command if PC27::CG::USE_ITEMS
  1648. add_look_at_grave_command
  1649. add_look_at_banish_command
  1650. add_look_at_extra_command
  1651. add_look_at_field_command
  1652. add_turn_end_command
  1653. end
  1654.  
  1655. end
  1656.  
  1657. #===============================================================================
  1658. # Window_BattleStatus
  1659. #===============================================================================
  1660.  
  1661. class Window_BattleStatus < Window_Selectable
  1662.  
  1663. #--------------------------------------------------------------------------
  1664. # Add deck to Draw Item (alias)
  1665. #--------------------------------------------------------------------------
  1666. alias pc27_cardgame_wndbttlstat_draw_item draw_item
  1667. def draw_item(index)
  1668. pc27_cardgame_wndbttlstat_draw_item(index)
  1669. actor = $game_party.battle_members[index]
  1670. draw_deck_area(deck_area_rect(index), actor)
  1671. end
  1672.  
  1673. #--------------------------------------------------------------------------
  1674. # Shrink basic rect (overwrite)
  1675. #--------------------------------------------------------------------------
  1676. def basic_area_rect(index)
  1677. rect = item_rect_for_text(index)
  1678. rect.width -= gauge_area_width + deck_area_width + 10
  1679. rect
  1680. end
  1681.  
  1682. #--------------------------------------------------------------------------
  1683. # Get Deck rect (new)
  1684. #--------------------------------------------------------------------------
  1685. def deck_area_rect(index)
  1686. rect = item_rect_for_text(index)
  1687. rect.x += rect.width - gauge_area_width - deck_area_width
  1688. rect.width = deck_area_width
  1689. rect
  1690. end
  1691.  
  1692. #--------------------------------------------------------------------------
  1693. # Get Deck Area Width (new)
  1694. #--------------------------------------------------------------------------
  1695. def deck_area_width
  1696. return 48
  1697. end
  1698.  
  1699. #--------------------------------------------------------------------------
  1700. # Draw Deck Area (new)
  1701. #--------------------------------------------------------------------------
  1702. def draw_deck_area(rect, actor)
  1703. draw_icon(PC27::CG::DECK_ICON, rect.x + 246, rect.y + 43)
  1704. draw_text(rect.x + 248, rect.y + 12, 80, rect.height, actor.deck.size.to_s)
  1705. end
  1706. end
  1707.  
  1708.  
  1709. #===============================================================================
  1710. # Window_BattleSkill
  1711. #===============================================================================
  1712.  
  1713. class Window_BattleSkill < Window_SkillList
  1714.  
  1715. #-----------------------------------------------------------------------------
  1716. # changes the BattleSkillList Window layout (overwrite)
  1717. #-----------------------------------------------------------------------------
  1718. def initialize(help_window, info_viewport)
  1719. y = 0
  1720. super(0, 0, (Graphics.width - 210) * 0.7, info_viewport.rect.y)
  1721. self.visible = false
  1722. @help_window = help_window
  1723. @info_viewport = info_viewport
  1724. end
  1725.  
  1726. def draw_card_illustration(card, x, y)
  1727. super # Call the parent method (optional if no additional logic is needed)
  1728. end
  1729.  
  1730. #-----------------------------------------------------------------------------
  1731. # changes the max. amount of collums to 1 (overwrite)
  1732. #-----------------------------------------------------------------------------
  1733. # def col_max
  1734. # return 1
  1735. # end
  1736.  
  1737. #--------------------------------------------------------------------------
  1738. # * Display Skill in Active State?
  1739. #--------------------------------------------------------------------------
  1740. def enable?(item)
  1741. super && @actor.turn_actions[:actions] != 0
  1742. end
  1743.  
  1744. end
  1745.  
  1746. #===============================================================================
  1747. # Window CardHelp (new)
  1748. #===============================================================================
  1749.  
  1750. class Window_CardHelp < Window_Base
  1751. include PC27::CG
  1752.  
  1753. def draw_card_text_no_card
  1754. create_contents
  1755. tone.set(*ELEMENT_COLOR[0])
  1756. self.back_opacity = CARD_BACK_OP
  1757. end
  1758.  
  1759. def draw_card_text(item)
  1760. create_contents
  1761. self.padding = standard_padding
  1762. id = item.card_id.to_s
  1763. draw_text_ex(148 - id.size * 10, height - 48, "#" + id)
  1764. make_cost_text(item.mp_cost, item.tp_cost)
  1765. set_background(item.damage ? item.damage.element_id : 0)
  1766. name = (CARD_NAME_UP ? item.name.upcase : item.name)
  1767. icon = "\\I[" + RARITY[item.rarity][0].to_s + "]"
  1768. type = TYPE[item.type]
  1769. name_x = 0.5 * width - padding - item.name.size * 5
  1770. draw_all_lines
  1771. draw_text_ex(name_x, 9, name)
  1772. draw_text_ex(0,48, type)
  1773. draw_text_ex(0,83, item.description)
  1774. draw_text_ex(0, height - 48, icon)
  1775. end
  1776.  
  1777. def draw_card_illustration_no_card
  1778. contents.dispose
  1779. self.contents = Bitmap.new(190, 264)
  1780. bitmap = Cache.picture("Card0")
  1781. self.padding = 0
  1782. rect = Rect.new(0, 0, 190, 264)
  1783. contents.blt(0, 0, bitmap, rect, 255)
  1784. bitmap.dispose
  1785. end
  1786.  
  1787. def draw_card_illustration(item)
  1788. contents.dispose
  1789. self.contents = Bitmap.new(190, 264)
  1790. bitmap = Cache.picture("Card" + item.id.to_s)
  1791. self.padding = 0
  1792. rect = Rect.new(0, 0, 190, 264)
  1793. contents.blt(0, 0, bitmap, rect, 255)
  1794. bitmap.dispose
  1795. end
  1796.  
  1797. #--------------------------------------------------------------------------
  1798. # Object Initialization
  1799. #--------------------------------------------------------------------------
  1800. def initialize()
  1801. super(Graphics.width - 200, 10, 190, 264)
  1802. self.windowskin = Cache.system(PC27::CG::CUSTOM_CARD_BG) if PC27::CG::CUSTOM_CARD_BG
  1803. end
  1804.  
  1805. #--------------------------------------------------------------------------
  1806. # Set Text
  1807. #--------------------------------------------------------------------------
  1808. def set_text(card)
  1809. if card != @card
  1810. @card = card
  1811. refresh
  1812. end
  1813. end
  1814.  
  1815. #--------------------------------------------------------------------------
  1816. # Set Item
  1817. #--------------------------------------------------------------------------
  1818. def set_item(item)
  1819. set_text(item)
  1820. end
  1821.  
  1822. #--------------------------------------------------------------------------
  1823. # Refresh
  1824. #--------------------------------------------------------------------------
  1825. def refresh
  1826. contents.clear
  1827. end
  1828.  
  1829. def update_tone; end
  1830. def update_padding; end
  1831.  
  1832. end
  1833. #===============================================================================
  1834. # Window_CardSelect (new)
  1835. #===============================================================================
  1836.  
  1837. class Window_CardSelect < Window_SkillList
  1838.  
  1839. attr_accessor :actor
  1840. attr_accessor :cards
  1841. attr_accessor :sort_index
  1842. attr_accessor :filter
  1843.  
  1844. def initialize(help_window, info_viewport)
  1845. super(0, 0, (Graphics.width - 210) * 0.7, info_viewport.rect.y)
  1846. self.visible = false
  1847. @help_window = help_window
  1848. @info_viewport = info_viewport
  1849. @filter = [0,0,0,0,0,0,0,0,0,0]
  1850. @cards = []
  1851. @sort_index = -1
  1852. end
  1853.  
  1854. def col_max
  1855. return 1
  1856. end
  1857.  
  1858. def make_item_list
  1859. @data = @cards
  1860. end
  1861.  
  1862. def enable?(item)
  1863. return false unless item
  1864. return false unless item.damage.element_id == @filter[0] || @filter[0] == 0
  1865. return false unless item.type == @filter[1] || @filter[1] == 0
  1866. return false unless item.rarity == @filter[2] || @filter[2] == 0
  1867. return false unless item.subtype == @filter[3] || @filter[3] == 0
  1868. return false unless item.level == @filter[4] || @filter[4] == 0
  1869. return false unless item.normeff == @filter[5] || @filter[5] == 0
  1870. return false unless item.frame == @filter[6] || @filter[6] == 0
  1871. return false unless item.archetype == @filter[7] || @filter[7] == 0
  1872. return false unless item.atk == @filter[8] || @filter[8] == 0
  1873. return false unless item.def == @filter[9] || @filter[9] == 0
  1874. return false unless item.special == @filter[10] || @filter[10] == 0
  1875. return @actor
  1876. end
  1877.  
  1878. #--------------------------------------------------------------------------
  1879. # Show Window
  1880. #--------------------------------------------------------------------------
  1881. def show
  1882. select(0)
  1883. @help_window.show
  1884. super
  1885. end
  1886. #--------------------------------------------------------------------------
  1887. # Hide Window
  1888. #--------------------------------------------------------------------------
  1889. def hide
  1890. @help_window.hide
  1891. super
  1892. end
  1893.  
  1894. end
  1895. #===============================================================================
  1896. # Scene_Battle
  1897. #===============================================================================
  1898. class Scene_Battle < Scene_Base
  1899.  
  1900. def command_skill
  1901. @skill_window.make_item_list
  1902. @skill_window.refresh
  1903. @skill_window.show
  1904. @skill_window.activate
  1905. end
  1906.  
  1907. #--------------------------------------------------------------------------
  1908. # Add end turn command and remove prior command (overwrite)
  1909. #--------------------------------------------------------------------------
  1910. def create_actor_command_window
  1911. @actor_command_window = Window_ActorCommand.new
  1912. @actor_command_window.viewport = @info_viewport
  1913. @actor_command_window.set_handler(:attack, method(:command_attack))
  1914. @actor_command_window.set_handler(:skill, method(:command_look_hand))
  1915. @actor_command_window.set_handler(:guard, method(:command_guard))
  1916. @actor_command_window.set_handler(:item, method(:command_item))
  1917. @actor_command_window.set_handler(:look_grave, method(:command_look_grave))
  1918. @actor_command_window.set_handler(:look_banish, method(:command_look_banish))
  1919. @actor_command_window.set_handler(:look_extra, method(:command_look_extra))
  1920. @actor_command_window.set_handler(:look_field, method(:command_look_field))
  1921. @actor_command_window.set_handler(:end_turn, method(:command_end_turn))
  1922. @actor_command_window.x = Graphics.width
  1923. end
  1924.  
  1925. #--------------------------------------------------------------------------
  1926. # Handles the Look Grave command
  1927. #--------------------------------------------------------------------------
  1928. def command_look_grave
  1929. array = PC27::CG::CARD_EFFECT["grave"]
  1930. @temp_effect_data = [] unless @temp_effect_data
  1931. @temp_effect_data[0] = :impact
  1932. prepare_select_window(:impact, array[0])
  1933. process_select_cards("grave")
  1934. end
  1935.  
  1936. #--------------------------------------------------------------------------
  1937. # Handles the Look Banish command
  1938. #--------------------------------------------------------------------------
  1939. def command_look_banish
  1940. array = PC27::CG::CARD_EFFECT["banish"]
  1941. @temp_effect_data = [] unless @temp_effect_data
  1942. @temp_effect_data[0] = :impact
  1943. prepare_select_window(:impact, array[0])
  1944. process_select_cards("banish")
  1945. end
  1946.  
  1947. #--------------------------------------------------------------------------
  1948. # Handles the Look Extra command
  1949. #--------------------------------------------------------------------------
  1950. def command_look_extra
  1951. array = PC27::CG::CARD_EFFECT["extra"]
  1952. @temp_effect_data = [] unless @temp_effect_data
  1953. @temp_effect_data[0] = :impact
  1954. prepare_select_window(:impact, array[0])
  1955. process_select_cards("extra")
  1956. end
  1957.  
  1958. #--------------------------------------------------------------------------
  1959. # Handles the Look Field command
  1960. #--------------------------------------------------------------------------
  1961. def command_look_field
  1962. $game_variables[55] = 2
  1963. @skill_window.actor = BattleManager.actor
  1964. @skill_window.stype_id = @actor_command_window.current_ext
  1965. @skill_window.refresh
  1966. @skill_window.show.activate
  1967. end
  1968.  
  1969. #--------------------------------------------------------------------------
  1970. # Handles the Look Hand command
  1971. #--------------------------------------------------------------------------
  1972. def command_look_hand
  1973. $game_variables[55] = 1
  1974. @skill_window.actor = BattleManager.actor
  1975. @skill_window.make_item_list
  1976. @skill_window.select(0) # Reset the cursor to the first item
  1977. @skill_window.show.activate
  1978. @skill_window.refresh
  1979. end
  1980.  
  1981. #--------------------------------------------------------------------------
  1982. # Clears actions and ends the actors turn
  1983. #--------------------------------------------------------------------------
  1984. def command_end_turn
  1985. BattleManager.actor.clear_actions
  1986. next_command
  1987. end
  1988.  
  1989. #--------------------------------------------------------------------------
  1990. # Prevents messages from closing windows (overwrite)
  1991. #--------------------------------------------------------------------------
  1992. def update_message_open
  1993. end
  1994.  
  1995. #--------------------------------------------------------------------------
  1996. # Shows a different Help Window in Battle (alias)
  1997. #--------------------------------------------------------------------------
  1998. alias pc27_cardgame_scenebattle_create_help_window create_help_window
  1999. def create_help_window
  2000. pc27_cardgame_scenebattle_create_help_window
  2001. @cardhelp_window = Window_CardHelp.new
  2002. @cardhelp_window.visible = false
  2003. end
  2004.  
  2005. #--------------------------------------------------------------------------
  2006. # Create Skill Window with card help window instead of normal help window (overwrite)
  2007. #--------------------------------------------------------------------------
  2008. def create_skill_window
  2009. @skill_window = Window_BattleSkill.new(@cardhelp_window, @info_viewport)
  2010. @skill_window.set_handler(:ok, method(:on_skill_ok))
  2011. @skill_window.set_handler(:cancel, method(:on_skill_cancel))
  2012. end
  2013.  
  2014. #--------------------------------------------------------------------------
  2015. # Create Extra Window with card help window instead of normal help window (overwrite)
  2016. #--------------------------------------------------------------------------
  2017. def create_extra_window
  2018. @extra_window = Window_BattleSkill.new(@cardhelp_window, @info_viewport)
  2019. @extra_window.set_handler(:ok, method(:on_skill_ok))
  2020. @extra_window.set_handler(:cancel, method(:on_skill_cancel))
  2021. end
  2022.  
  2023. #--------------------------------------------------------------------------
  2024. # Creates the window needed to select cards (new)
  2025. #--------------------------------------------------------------------------
  2026. def create_card_select_window
  2027. @card_select_window = Window_CardSelect.new(@cardhelp_window, @info_viewport)
  2028. end
  2029.  
  2030. #--------------------------------------------------------------------------
  2031. # Adds the select window to the scene (alias)
  2032. #--------------------------------------------------------------------------
  2033. alias pc27_cardgame_scenebattle_create_all_windows create_all_windows
  2034. def create_all_windows
  2035. pc27_cardgame_scenebattle_create_all_windows
  2036. create_card_select_window
  2037. end
  2038.  
  2039. #--------------------------------------------------------------------------
  2040. # On Skill Ok checks for card costs
  2041. #--------------------------------------------------------------------------
  2042. alias pc27_cardgame_scene_battle_on_skill_ok on_skill_ok
  2043. def on_skill_ok
  2044. @subject = BattleManager.actor
  2045. @skill = @skill_window.item
  2046. if $game_variables[55] == 1 #Effect on Hand
  2047. if @skill.type == 1
  2048. BattleManager.actor.card_to_stack?(@skill.id)
  2049. params = [["Activate","Cancel"], 2]
  2050. params[0].each {|s| $game_message.choices.push(s) }
  2051. $game_message.choice_cancel_type = params[1]
  2052. $game_message.choice_proc = Proc.new {|n|
  2053. case n
  2054. when 0; skill_select(1)
  2055. when 1; on_actor_cancel
  2056. end
  2057. }
  2058. elsif @skill.type == 2
  2059. BattleManager.actor.card_to_stack?(@skill.id)
  2060. params = [["Set","Cancel"], 2]
  2061. params[0].each {|s| $game_message.choices.push(s) }
  2062. $game_message.choice_cancel_type = params[1]
  2063. $game_message.choice_proc = Proc.new {|n|
  2064. case n
  2065. when 0; skill_select(1)
  2066. when 1; on_actor_cancel
  2067. end
  2068. }
  2069. elsif @skill.type == 3
  2070. if @subject.tp >= @skill.tp_cost
  2071. BattleManager.actor.card_to_stack?(@skill.id)
  2072. params = [["Activate","Summon","Cancel"], 3]
  2073. params[0].each {|s| $game_message.choices.push(s) }
  2074. $game_message.choice_cancel_type = params[1]
  2075. $game_message.choice_proc = Proc.new {|n|
  2076. case n
  2077. when 0; skill_select(0)
  2078. when 1; skill_select(1)
  2079. when 2; on_actor_cancel
  2080. end
  2081. }
  2082. else
  2083. BattleManager.actor.card_to_stack?(@skill.id)
  2084. params = [["Activate","Cancel"], 2]
  2085. params[0].each {|s| $game_message.choices.push(s) }
  2086. $game_message.choice_cancel_type = params[1]
  2087. $game_message.choice_proc = Proc.new {|n|
  2088. case n
  2089. when 0; skill_select(0)
  2090. when 2; on_actor_cancel
  2091. end
  2092. }
  2093. end
  2094. end
  2095. elsif $game_variables[55] == 2 #Effect on Field
  2096. if @skill.type == 1
  2097. if @skill.fieldeff >= 1
  2098. params = [["Activate","Cancel"], 2]
  2099. params[0].each {|s| $game_message.choices.push(s) }
  2100. $game_message.choice_cancel_type = params[1]
  2101. $game_message.choice_proc = Proc.new {|n|
  2102. case n
  2103. when 0; skill_field_select(1)
  2104. when 1; on_actor_cancel
  2105. end
  2106. }
  2107. end
  2108. elsif @skill.type == 2
  2109. if @skill.fieldeff >= 1
  2110. params = [["Activate","Cancel"], 2]
  2111. params[0].each {|s| $game_message.choices.push(s) }
  2112. $game_message.choice_cancel_type = params[1]
  2113. $game_message.choice_proc = Proc.new {|n|
  2114. case n
  2115. when 0; skill_field_select(1)
  2116. when 1; on_actor_cancel
  2117. end
  2118. }
  2119. end
  2120. elsif @skill.type == 3
  2121. if @skill.fieldeff >= 1
  2122. params = [["Activate","Cancel"], 2]
  2123. params[0].each {|s| $game_message.choices.push(s) }
  2124. $game_message.choice_cancel_type = params[1]
  2125. $game_message.choice_proc = Proc.new {|n|
  2126. case n
  2127. when 0; skill_field_select(0)
  2128. when 1; on_actor_cancel
  2129. end
  2130. }
  2131. else
  2132. on_actor_cancel
  2133. end
  2134. end
  2135. end
  2136. end
  2137.  
  2138. def skill_select(value)
  2139. $game_message.clear
  2140. $game_message.visible = false
  2141. if @skill.cost
  2142. invoke_card_cost(@skill.cost)
  2143. @skill_window.hide
  2144. else
  2145. effect = @skill.handeff if value == 0
  2146. effect = @skill.id if value == 1
  2147. $game_variables[60] = 1 if value == 0
  2148. $game_variables[60] = 2 if value == 1
  2149. BattleManager.actor.replace_field_spell(27) if @skill.subtype == 27
  2150. BattleManager.actor.input.set_skill(effect)
  2151. BattleManager.actor.last_skill.object = @skill
  2152. if [email protected]_selection?
  2153. @skill_window.hide
  2154. next_command
  2155. elsif @skill.for_opponent?
  2156. select_enemy_selection
  2157. else
  2158. select_actor_selection
  2159. end
  2160. end
  2161. end
  2162.  
  2163. def skill_field_select(value)
  2164. $game_message.clear
  2165. $game_message.visible = false
  2166. if @skill.cost
  2167. invoke_card_cost(@skill.cost)
  2168. @skill_window.hide
  2169. else
  2170. @skill.id = @skill.fieldeff if value == 1
  2171. BattleManager.actor.input.set_skill(@skill.id)
  2172. BattleManager.actor.last_skill.object = @skill
  2173. if [email protected]_selection?
  2174. @skill_window.hide
  2175. next_command
  2176. elsif @skill.for_opponent?
  2177. select_enemy_selection
  2178. else
  2179. select_actor_selection
  2180. end
  2181. end
  2182. end
  2183.  
  2184. def on_enemy_cancel
  2185. restore_taken_cards(:cancel)
  2186. BattleManager.actor.hand += BattleManager.actor.stack
  2187. BattleManager.actor.stack = []
  2188. @enemy_window.hide
  2189. @skill_window.hide
  2190. @item_window.hide
  2191. @actor_command_window.activate
  2192. end
  2193.  
  2194. def on_actor_cancel
  2195. restore_taken_cards(:cancel)
  2196. BattleManager.actor.hand += BattleManager.actor.stack
  2197. BattleManager.actor.stack = []
  2198. @actor_window.hide
  2199. @skill_window.hide
  2200. @item_window.hide
  2201. @actor_command_window.activate
  2202. end
  2203.  
  2204. #-----------------------------------------------------------------------------
  2205. # Changes Next Command so it performs Actions (alias)
  2206. #-----------------------------------------------------------------------------
  2207. alias pc27_cardgame_scenebattle_next_command next_command
  2208. def next_command
  2209. return if @card_select_window.active
  2210. if action?
  2211. evaluate_item(BattleManager.actor, BattleManager.actor.input.item)
  2212. perform_action
  2213. else
  2214. pc27_cardgame_scenebattle_next_command
  2215. end
  2216. end
  2217.  
  2218. #-----------------------------------------------------------------------------
  2219. # Disables stuff based on used skill (new)
  2220. #-----------------------------------------------------------------------------
  2221. def evaluate_item(actor, item)
  2222. case item.id
  2223. when actor.attack_skill_id
  2224. actor.turn_actions[:can_attack] = false
  2225. actor.turn_actions[:can_guard] = false
  2226. actor.turn_actions[:actions] -= 1 unless actor.turn_actions[:actions] == -1
  2227. when actor.guard_skill_id
  2228. actor.turn_actions[:can_attack] = false
  2229. actor.turn_actions[:can_guard] = false
  2230. actor.turn_actions[:actions] -= 1 unless actor.turn_actions[:actions] == -1
  2231. end
  2232. end
  2233.  
  2234. #--------------------------------------------------------------------------
  2235. # Checks if there is an Action to use (new)
  2236. #--------------------------------------------------------------------------
  2237. def action?
  2238. return false if BattleManager.actor.nil?
  2239. return false if BattleManager.actor.input.nil?
  2240. action = BattleManager.actor.input.item
  2241. return false if action.nil?
  2242. return true
  2243. end
  2244.  
  2245. #--------------------------------------------------------------------------
  2246. # Performs Action (new)
  2247. #--------------------------------------------------------------------------
  2248. def perform_action
  2249. @subject = BattleManager.actor
  2250. hide_instant_action_windows
  2251. if @subject.current_action.valid?
  2252. execute_action
  2253. end
  2254. process_event
  2255. loop do
  2256. @subject.remove_current_action
  2257. break if $game_troop.all_dead?
  2258. break unless @subject.current_action
  2259. @subject.current_action.prepare
  2260. execute_action if @subject.current_action.valid?
  2261. end
  2262. process_action_end
  2263. @subject.make_actions
  2264. @subject = nil
  2265. show_instant_action_windows
  2266. end
  2267.  
  2268. def set_card
  2269. @subject = BattleManager.actor
  2270. @subject.field += @subject.stack
  2271. @subject.stack = []
  2272. restore_taken_cards(:proceed)
  2273. @skill_window.hide
  2274. @actor_command_window.activate
  2275. end
  2276.  
  2277. #--------------------------------------------------------------------------
  2278. # From Yanflys Instantcast (new)
  2279. #--------------------------------------------------------------------------
  2280. def hide_instant_action_windows
  2281. if $imported["YEA-BattleEngine"]
  2282. @info_viewport.visible = true
  2283. @status_aid_window.hide
  2284. @status_window.show
  2285. @actor_command_window.show
  2286. end
  2287. end
  2288.  
  2289. #--------------------------------------------------------------------------
  2290. # Activates actor (new)
  2291. #--------------------------------------------------------------------------
  2292. def show_instant_action_windows
  2293. if $imported["YEA-BattleEngine"]
  2294. @info_viewport.visible = true
  2295. end
  2296. start_actor_command_selection unless @card_select_window.active
  2297. status_redraw_target(BattleManager.actor)
  2298. next_command unless BattleManager.actor.inputable?
  2299. end
  2300.  
  2301. #--------------------------------------------------------------------------
  2302. # Redrawas target after action (new)
  2303. #--------------------------------------------------------------------------
  2304. def status_redraw_target(target)
  2305. return unless target.actor?
  2306. @status_window.draw_item($game_party.battle_members.index(target))
  2307. end
  2308.  
  2309. #--------------------------------------------------------------------------
  2310. # Handles card costs
  2311. #--------------------------------------------------------------------------
  2312. def invoke_card_cost(effect_name)
  2313. effect_array = PC27::CG::CARD_EFFECT[effect_name]
  2314. if effect_array[0] == :draw
  2315. card_effect_draw_cards(effect_array[1], effect_array[2], effect_array[3])
  2316. BattleManager.actor.input.set_skill(@skill.id)
  2317. BattleManager.actor.last_skill.object = @skill
  2318. if [email protected]_selection?
  2319. @skill_window.hide
  2320. next_command
  2321. elsif @skill.for_opponent?
  2322. select_enemy_selection
  2323. else
  2324. select_actor_selection
  2325. end
  2326. else
  2327. $game_message.background = 1
  2328. $game_message.position = 1
  2329. $game_message.add(PC27::CG::CARD_EFF_TEXT)
  2330. wait_for_message
  2331. prepare_select_window(:cost, effect_array[0])
  2332. @temp_effect_data = [] unless @temp_effect_data
  2333. @temp_effect_data[0] = :cost
  2334. process_select_cards(effect_name)
  2335. end
  2336. end
  2337.  
  2338. #-----------------------------------------------------------------------------
  2339. # Evaluates card effects and puts the stack to the grave (alias)
  2340. #-----------------------------------------------------------------------------
  2341. alias pc27_cardgame_scenebattle_use_item use_item
  2342. def use_item
  2343. pc27_cardgame_scenebattle_use_item
  2344. if @subject.is_a?(Game_Actor)
  2345. effect_name = @subject.current_action.item.impact
  2346. invoke_card_impact(effect_name) if effect_name && $game_variables[60] == 1
  2347. wait_for_message
  2348. if $game_variables[55] == 1
  2349. if $game_variables[60] == 1
  2350. @subject.grave += @subject.stack
  2351. @subject.stack = []
  2352. restore_taken_cards(:proceed)
  2353. elsif $game_variables[60] == 2
  2354. @subject.field += @subject.stack
  2355. @subject.stack = []
  2356. restore_taken_cards(:proceed)
  2357. end
  2358. end
  2359. end
  2360. end
  2361.  
  2362. #-----------------------------------------------------------------------------
  2363. # Card effects
  2364. #-----------------------------------------------------------------------------
  2365. def invoke_card_impact(effect_name)
  2366. array = PC27::CG::CARD_EFFECT[effect_name]
  2367. if array[0] == :draw
  2368. card_effect_draw_cards(array[1], array[2], array[3])
  2369. else
  2370. $game_message.background = 1
  2371. $game_message.position = 1
  2372. $game_message.add(PC27::CG::CARD_EFF_TEXT)
  2373. wait_for_message
  2374. prepare_select_window(:impact, array[0])
  2375. @temp_effect_data = [] unless @temp_effect_data
  2376. @temp_effect_data[0] = :impact
  2377. process_select_cards(effect_name)
  2378. end
  2379. wait_for_message
  2380. end
  2381.  
  2382. #-----------------------------------------------------------------------------
  2383. def card_effect_draw_cards(nr, prob, trg)
  2384. if trg == :self
  2385. if rand(100) < prob
  2386. @subject.draw_cards(nr)
  2387. need_wait = true
  2388. end
  2389. elsif trg == :target
  2390. targets = @subject.current_action.make_targets.compact
  2391. for target in targets
  2392. if rand(100) < prob
  2393. target.draw_cards(nr)
  2394. need_wait = true
  2395. end
  2396. end
  2397. end
  2398. wait_for_message if need_wait
  2399. end
  2400.  
  2401. #-----------------------------------------------------------------------------
  2402. def process_select_cards(effect_name)
  2403. @card_select_window.actor = BattleManager.actor
  2404. array = PC27::CG::CARD_EFFECT[effect_name]
  2405. case array[2]
  2406. when :deck
  2407. (array[1] == 0 ? amn = @card_select_window.actor.deck.size : amn = array[1])
  2408. amn.times do
  2409. next if @card_select_window.actor.deck.size == 0
  2410. @card_select_window.cards.push(@card_select_window.actor.deck.shift)
  2411. end
  2412. when :hand
  2413. (array[1] == 0 ? amn = @card_select_window.actor.hand.size : amn = array[1])
  2414. amn.times do
  2415. next if @card_select_window.actor.hand.size == 0
  2416. @card_select_window.cards.push(@card_select_window.actor.hand.shift)
  2417. end
  2418. when :grave
  2419. (array[1] == 0 ? amn = @card_select_window.actor.grave.size : amn = array[1])
  2420. amn.times do
  2421. next if @card_select_window.actor.grave.size == 0
  2422. @card_select_window.cards.push(@card_select_window.actor.grave.shift)
  2423. end
  2424. when :banish
  2425. (array[1] == 0 ? amn = @card_select_window.actor.banish.size : amn = array[1])
  2426. amn.times do
  2427. next if @card_select_window.actor.banish.size == 0
  2428. @card_select_window.cards.push(@card_select_window.actor.banish.shift)
  2429. end
  2430. when :extra
  2431. (array[1] == 0 ? amn = @card_select_window.actor.extra.size : amn = array[1])
  2432. amn.times do
  2433. next if @card_select_window.actor.extra.size == 0
  2434. @card_select_window.cards.push(@card_select_window.actor.extra.shift)
  2435. end
  2436. when :field
  2437. (array[1] == 0 ? amn = @card_select_window.actor.field.size : amn = array[1])
  2438. amn.times do
  2439. next if @card_select_window.actor.field.size == 0
  2440. @card_select_window.cards.push(@card_select_window.actor.field.shift)
  2441. end
  2442. end
  2443. @temp_effect_data[1] = effect_name
  2444. @temp_effect_data[2] = 0
  2445. set_select_filter(array)
  2446. @card_select_window.refresh
  2447. @card_select_window.show.activate
  2448. end
  2449.  
  2450. #-----------------------------------------------------------------------------
  2451. def set_select_filter(array)
  2452. if array[4]
  2453. @card_select_window.filter = array[4]
  2454. elsif array[0] == :view
  2455. @card_select_window.filter = [-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1]
  2456. else
  2457. @card_select_window.filter = [0,0,0,0,0,0,0,0,0,0,0]
  2458. end
  2459. end
  2460.  
  2461. #-----------------------------------------------------------------------------
  2462. def select_cards_ok_sort
  2463. if @card_select_window.cards.size == 0
  2464. select_cancel
  2465. return
  2466. end
  2467. if @card_select_window.sort_index != -1
  2468. swap_cards(@card_select_window.sort_index, @card_select_window.index)
  2469. @card_select_window.sort_index = -1
  2470. @card_select_window.refresh
  2471. else
  2472. @card_select_window.sort_index = @card_select_window.index
  2473. end
  2474. @card_select_window.activate
  2475. end
  2476.  
  2477. #-----------------------------------------------------------------------------
  2478. def select_cards_ok_take
  2479. if @card_select_window.cards.size == 0
  2480. select_cancel
  2481. return
  2482. end
  2483. card = @card_select_window.item
  2484. @temp_effect_data[3] = [] unless @temp_effect_data[3]
  2485. @temp_effect_data[3].push(card) unless @card_select_window.item.frame == 5
  2486. @card_select_window.cards.delete_at(@card_select_window.cards.index(card))
  2487. @temp_effect_data[2] += 1
  2488. if PC27::CG::CARD_EFFECT[@temp_effect_data[1]][6] != @temp_effect_data[2]
  2489. @card_select_window.refresh
  2490. @card_select_window.activate
  2491. else
  2492. proceed_selection
  2493. end
  2494. end
  2495. #-----------------------------------------------------------------------------
  2496. def proceed_selection
  2497. @card_select_window.hide.deactivate
  2498. @card_select_window.sort_index = -1
  2499. restore_selected_cards
  2500. if @temp_effect_data[0] == :cost
  2501. BattleManager.actor.input.set_skill(@skill.id)
  2502. BattleManager.actor.last_skill.object = @skill
  2503. if [email protected]_selection?
  2504. @skill_window.hide
  2505. next_command
  2506. elsif @skill.for_opponent?
  2507. select_enemy_selection
  2508. else
  2509. select_actor_selection
  2510. end
  2511. elsif @temp_effect_data[0] == :impact
  2512. restore_taken_cards(:proceed)
  2513. start_actor_command_selection
  2514. @card_select_window.actor.shuffle_deck(false)
  2515. end
  2516. end
  2517.  
  2518. def select_cancel
  2519. @card_select_window.hide.deactivate
  2520. @card_select_window.sort_index = -1
  2521. restore_taken_cards(:cancel)
  2522. restore_selected_cards
  2523. if @temp_effect_data[0] == :cost
  2524. BattleManager.actor.hand += BattleManager.actor.stack
  2525. BattleManager.actor.stack = []
  2526. on_skill_cancel
  2527. elsif @temp_effect_data[0] == :impact
  2528. start_actor_command_selection
  2529. end
  2530. end
  2531.  
  2532. def restore_taken_cards(target)
  2533. return unless @temp_effect_data && @temp_effect_data[3] && @temp_effect_data[3] != []
  2534. if target == :proceed
  2535. case PC27::CG::CARD_EFFECT[@temp_effect_data[1]][5]
  2536. when :hand
  2537. @card_select_window.actor.hand += @temp_effect_data[3]
  2538. when :deck
  2539. @card_select_window.actor.deck += @temp_effect_data[3]
  2540. @card_select_window.actor.shuffle_deck(false)
  2541. when :grave
  2542. @card_select_window.actor.grave += @temp_effect_data[3]
  2543. when :banish
  2544. @card_select_window.actor.banish += @temp_effect_data[3]
  2545. when :extra
  2546. @card_select_window.actor.extra += @temp_effect_data[3]
  2547. when :field
  2548. @card_select_window.actor.field += @temp_effect_data[3]
  2549. end
  2550. elsif target == :cancel
  2551. case PC27::CG::CARD_EFFECT[@temp_effect_data[1]][2]
  2552. when :hand
  2553. @card_select_window.actor.hand += @temp_effect_data[3]
  2554. when :deck
  2555. @card_select_window.actor.deck += @temp_effect_data[3]
  2556. when :grave
  2557. @card_select_window.actor.grave += @temp_effect_data[3]
  2558. when :banish
  2559. @card_select_window.actor.banish += @temp_effect_data[3]
  2560. when :extra
  2561. @card_select_window.actor.extra += @temp_effect_data[3]
  2562. when :field
  2563. @card_select_window.actor.field += @temp_effect_data[3]
  2564. end
  2565. end
  2566. @temp_effect_data[3] = []
  2567. end
  2568.  
  2569. #-----------------------------------------------------------------------------
  2570. def restore_selected_cards
  2571. array = PC27::CG::CARD_EFFECT[@temp_effect_data[1]]
  2572. case array[3]
  2573. when :deck
  2574. @card_select_window.cards.reverse.each { |card|
  2575. @card_select_window.actor.deck.unshift(card)
  2576. }
  2577. @card_select_window.actor.shuffle_deck if array[0] == :take && @card_select_window.actor.deck.size != 0
  2578. @status_window.refresh
  2579. when :hand
  2580. @card_select_window.cards.reverse.each { |card|
  2581. @card_select_window.actor.hand.unshift(card)
  2582. }
  2583. when :grave
  2584. @card_select_window.cards.reverse.each { |card|
  2585. @card_select_window.actor.grave.unshift(card)
  2586. }
  2587. when :banish
  2588. @card_select_window.cards.reverse.each { |card|
  2589. @card_select_window.actor.banish.unshift(card)
  2590. }
  2591. when :extra
  2592. @card_select_window.cards.reverse.each { |card|
  2593. @card_select_window.actor.extra.unshift(card)
  2594. }
  2595. when :field
  2596. @card_select_window.cards.reverse.each { |card|
  2597. @card_select_window.actor.field.unshift(card)
  2598. }
  2599. end
  2600. @card_select_window.cards = []
  2601. end
  2602.  
  2603. #-----------------------------------------------------------------------------
  2604. def prepare_select_window(moment, type)
  2605. if moment == :impact
  2606. if type == :view
  2607. @card_select_window.set_handler(:ok, method(:no_method))
  2608. @card_select_window.set_handler(:cancel, method(:select_cancel))
  2609. elsif type == :sort
  2610. @card_select_window.set_handler(:ok, method(:select_cards_ok_sort))
  2611. @card_select_window.set_handler(:cancel, method(:select_cancel))
  2612. elsif type == :take
  2613. @card_select_window.set_handler(:ok, method(:select_cards_ok_take))
  2614. @card_select_window.set_handler(:cancel, method(:proceed_selection))
  2615. elsif type == :takem
  2616. @card_select_window.set_handler(:ok, method(:select_cards_ok_take))
  2617. @card_select_window.set_handler(:cancel, method(:no_method))
  2618. end
  2619. elsif moment == :cost
  2620. if type == :view
  2621. @card_select_window.set_handler(:ok, method(:no_method))
  2622. @card_select_window.set_handler(:cancel, method(:proceed_selection))
  2623. elsif type == :sort
  2624. @card_select_window.set_handler(:ok, method(:select_cards_ok_sort))
  2625. @card_select_window.set_handler(:cancel, method(:proceed_selection))
  2626. elsif type == :take
  2627. @card_select_window.set_handler(:ok, method(:select_cards_ok_take))
  2628. @card_select_window.set_handler(:cancel, method(:select_cancel))
  2629. elsif type == :takem
  2630. @card_select_window.set_handler(:ok, method(:select_cards_ok_take))
  2631. @card_select_window.set_handler(:cancel, method(:no_method))
  2632. elsif type == :takeup
  2633. @card_select_window.set_handler(:ok, method(:select_cards_ok_take))
  2634. @card_select_window.set_handler(:cancel, method(:proceed_selection))
  2635. end
  2636. end
  2637. end
  2638.  
  2639. def no_method
  2640. @card_select_window.activate
  2641. end
  2642.  
  2643. #-----------------------------------------------------------------------------
  2644. def swap_cards(index1, index2)
  2645. @card_select_window.cards[index1], @card_select_window.cards[index2] =
  2646. @card_select_window.cards[index2], @card_select_window.cards[index1]
  2647. end
  2648.  
  2649. end
  2650.  
  2651. #===============================================================================
  2652. # Scene_Deck
  2653. #===============================================================================
  2654.  
  2655. class Scene_Deck < Scene_MenuBase
  2656. include PC27::CG
  2657. #-----------------------------------------------------------------------------
  2658. # Start
  2659. #-----------------------------------------------------------------------------
  2660. def start
  2661. super()
  2662. create_filter_window
  2663. create_deck_window
  2664. create_extra_window
  2665. create_coll_window
  2666. create_text_window
  2667. create_card_window
  2668. create_info_window
  2669. end
  2670.  
  2671. def return_scene
  2672. if $game_party.menu_actor.deck.size <= 39
  2673. RPG::SE.new("Buzzer1", 80, 100).play
  2674. $game_message.add('Your deck has less than 40 cards.')
  2675. SceneManager.return if $game_party.menu_actor.deck.size == 0
  2676. else
  2677. SceneManager.return
  2678. end
  2679. end
  2680.  
  2681. #-----------------------------------------------------------------------------
  2682. # Creates a window to display deck cards
  2683. #-----------------------------------------------------------------------------
  2684. def create_deck_window
  2685. @deck_window = Window_Deck.new(0,64)
  2686. @deck_window.set_handler(:cancel, method(:return_scene))
  2687. @deck_window.set_handler(:ok, method(:deck_to_coll))
  2688. end
  2689.  
  2690. #-----------------------------------------------------------------------------
  2691. # Creates a window to display extra deck cards
  2692. #-----------------------------------------------------------------------------
  2693. def create_extra_window
  2694. @extra_window = Window_Extra.new(0,280)
  2695. @extra_window.set_handler(:cancel, method(:return_scene))
  2696. @extra_window.set_handler(:ok, method(:extra_to_coll))
  2697. end
  2698.  
  2699. #-----------------------------------------------------------------------------
  2700. # Creates a window to display collection cards
  2701. #-----------------------------------------------------------------------------
  2702. def create_coll_window
  2703. @coll_window = Window_Coll.new((Graphics.width - 210)*0.5, 64)
  2704. @coll_window.set_handler(:cancel, method(:return_scene))
  2705. @coll_window.set_handler(:ok, method(:coll_to_deck))
  2706. @coll_window.deactivate
  2707. end
  2708.  
  2709. #-----------------------------------------------------------------------------
  2710. # Creates the window that shows where you are
  2711. #-----------------------------------------------------------------------------
  2712. def create_text_window
  2713. @text_window = Window_Base.new(0 ,0, Graphics.width - 210, 64)
  2714. update_text_window
  2715. end
  2716.  
  2717. #-----------------------------------------------------------------------------
  2718. # Creates the window that shows the currently selected card
  2719. #-----------------------------------------------------------------------------
  2720. def create_card_window
  2721. @card_window = Window_CardHelp.new()
  2722. @card_window.windowskin = Cache.system(CUSTOM_CARD_BG) if CUSTOM_CARD_BG
  2723. @card_window.tone.set(*PC27::CG::ELEMENT_COLOR[0])
  2724. @card_window.back_opacity = PC27::CG::CARD_BACK_OP
  2725. end
  2726.  
  2727. #-----------------------------------------------------------------------------
  2728. # Creates a info window
  2729. #-----------------------------------------------------------------------------
  2730. def create_info_window
  2731. height = Graphics.height - 284
  2732. @info_window = Window_Base.new(
  2733. Graphics.width - 210, Graphics.height - height, 210, height)
  2734. @info_window.draw_text_ex(0,0,CARD_HELP_WINDOW)
  2735. end
  2736.  
  2737. #-----------------------------------------------------------------------------
  2738. # Creates a window to filter cards
  2739. #-----------------------------------------------------------------------------
  2740. def create_filter_window
  2741. @filter_window = Window_Filter.new(0,Graphics.height * 0.5 - 48)
  2742. @filter_window.set_handler(:cancel, method(:close_filter))
  2743. @filter_window.set_handler(:ok, method(:change_filter))
  2744. @filter_window.z = 150
  2745. @filter_window.hide
  2746. @filter_window.deactivate
  2747. end
  2748.  
  2749. #-----------------------------------------------------------------------------
  2750. # Changes between collection and deck window
  2751. #-----------------------------------------------------------------------------
  2752. def change_to_coll
  2753. @coll_window.activate
  2754. @deck_window.deactivate
  2755. @extra_window.deactivate
  2756. Sound.play_cursor
  2757. Input.update
  2758. end
  2759.  
  2760. def change_to_deck
  2761. @deck_window.activate
  2762. @coll_window.deactivate
  2763. @extra_window.deactivate
  2764. Sound.play_cursor
  2765. Input.update
  2766. end
  2767.  
  2768. def change_to_extra
  2769. @deck_window.deactivate
  2770. @coll_window.deactivate
  2771. @extra_window.activate
  2772. Sound.play_cursor
  2773. Input.update
  2774. end
  2775.  
  2776. #-----------------------------------------------------------------------------
  2777. # Adds commands to exchange cards
  2778. #-----------------------------------------------------------------------------
  2779. def coll_to_deck
  2780. for skill in $game_party.coll
  2781. /coll(?<skill_id>\d+)/ =~ @coll_window.current_symbol.to_s
  2782. skill_id = skill_id.to_i
  2783. max_cards = (MAX_SAME_EXCEP.has_key?(skill_id) ? MAX_SAME_EXCEP[skill_id] : MAX_SAME_CARDS)
  2784. if skill.id == skill_id && skill.type == 4
  2785. if $game_party.menu_actor.extra.size >= MAX_EXTRA_SIZE
  2786. RPG::SE.new("Buzzer1", 80, 100).play
  2787. return
  2788. end
  2789. if $game_party.menu_actor.extra.count{ |skill| skill.id == skill_id } >= max_cards
  2790. RPG::SE.new("Buzzer1", 80, 100).play
  2791. return
  2792. end
  2793. $game_party.menu_actor.extra.push(
  2794. $game_party.coll.slice!($game_party.coll.index(skill)))
  2795. break
  2796. elsif skill.id == skill_id
  2797. if $game_party.menu_actor.deck.size >= MAX_DECK_SIZE
  2798. RPG::SE.new("Buzzer1", 80, 100).play
  2799. return
  2800. end
  2801. if $game_party.menu_actor.deck.count{ |skill| skill.id == skill_id } >= max_cards
  2802. RPG::SE.new("Buzzer1", 80, 100).play
  2803. return
  2804. end
  2805. $game_party.menu_actor.deck.push(
  2806. $game_party.coll.slice!($game_party.coll.index(skill)))
  2807. break
  2808. end
  2809. end
  2810. RPG::SE.new("Cursor1", 80, 100).play
  2811. @deck_window.refresh
  2812. @extra_window.refresh
  2813. @coll_window.refresh
  2814. update_text_window
  2815. end
  2816.  
  2817. def deck_to_coll
  2818. /deck(?<skill_id>\d+)/ =~ @deck_window.current_symbol.to_s
  2819. skill_id = skill_id.to_i
  2820. for skill in $game_party.menu_actor.deck
  2821. if skill.id == skill_id
  2822. $game_party.coll.push(
  2823. $game_party.menu_actor.deck.slice!($game_party.menu_actor.deck.index(skill)))
  2824. break
  2825. end
  2826. end
  2827. RPG::SE.new("Cursor1", 80, 100).play
  2828. @deck_window.refresh
  2829. @coll_window.refresh
  2830. update_text_window
  2831. end
  2832.  
  2833. def extra_to_coll
  2834. /extra(?<skill_id>\d+)/ =~ @extra_window.current_symbol.to_s
  2835. skill_id = skill_id.to_i
  2836. for skill in $game_party.menu_actor.extra
  2837. if skill.id == skill_id
  2838. $game_party.coll.push(
  2839. $game_party.menu_actor.extra.slice!($game_party.menu_actor.extra.index(skill)))
  2840. break
  2841. end
  2842. end
  2843. RPG::SE.new("Cursor1", 80, 100).play
  2844. @extra_window.refresh
  2845. @coll_window.refresh
  2846. update_text_window
  2847. end
  2848.  
  2849. #-----------------------------------------------------------------------------
  2850. # Activates filter
  2851. #-----------------------------------------------------------------------------
  2852. def activate_filter
  2853. @filter_window.show
  2854. @filter_window.activate
  2855. @deck_window.deactivate
  2856. @extra_window.deactivate
  2857. @coll_window.deactivate
  2858. end
  2859.  
  2860. #-----------------------------------------------------------------------------
  2861. # Changes filter settings
  2862. #-----------------------------------------------------------------------------
  2863. def change_filter
  2864. case @filter_window.current_symbol
  2865. when :filter_element
  2866. @coll_window.filter[0] += 1
  2867. @filter_window.filter[0] += 1
  2868. @coll_window.filter[0] = 0 if $data_system.elements.size == @coll_window.filter[0]
  2869. @filter_window.filter[0] = 0 if $data_system.elements.size == @filter_window.filter[0]
  2870. when :filter_type
  2871. @coll_window.filter[1] += 1
  2872. @filter_window.filter[1] += 1
  2873. @coll_window.filter[1] = 0 unless TYPE.has_key?(@coll_window.filter[1])
  2874. @filter_window.filter[1] = 0 unless TYPE.has_key?(@filter_window.filter[1])
  2875. when :filter_rarity
  2876. @coll_window.filter[2] += 1
  2877. @filter_window.filter[2] += 1
  2878. @coll_window.filter[2] = 0 unless RARITY.has_key?(@coll_window.filter[2])
  2879. @filter_window.filter[2] = 0 unless RARITY.has_key?(@filter_window.filter[2])
  2880. when :filter_subtype
  2881. @coll_window.filter[3] += 1
  2882. @filter_window.filter[3] += 1
  2883. @coll_window.filter[3] = 0 unless SUBTYPE.has_key?(@coll_window.filter[3])
  2884. @filter_window.filter[3] = 0 unless SUBTYPE.has_key?(@filter_window.filter[3])
  2885. when :filter_level
  2886. @coll_window.filter[4] += 1
  2887. @filter_window.filter[4] += 1
  2888. @coll_window.filter[4] = 0 unless LEVEL.has_key?(@coll_window.filter[4])
  2889. @filter_window.filter[4] = 0 unless LEVEL.has_key?(@filter_window.filter[4])
  2890. when :filter_normeff
  2891. @coll_window.filter[5] += 1
  2892. @filter_window.filter[5] += 1
  2893. @coll_window.filter[5] = 0 unless NORMEFF.has_key?(@coll_window.filter[5])
  2894. @filter_window.filter[5] = 0 unless NORMEFF.has_key?(@filter_window.filter[5])
  2895. when :filter_frame
  2896. @coll_window.filter[6] += 1
  2897. @filter_window.filter[6] += 1
  2898. @coll_window.filter[6] = 0 unless FRAME.has_key?(@coll_window.filter[6])
  2899. @filter_window.filter[6] = 0 unless FRAME.has_key?(@filter_window.filter[6])
  2900. when :filter_archetype
  2901. @coll_window.filter[7] += 1
  2902. @filter_window.filter[7] += 1
  2903. @coll_window.filter[7] = 0 unless ARCHETYPE.has_key?(@coll_window.filter[7])
  2904. @filter_window.filter[7] = 0 unless ARCHETYPE.has_key?(@filter_window.filter[7])
  2905. when :filter_atk
  2906. @coll_window.filter[8] += 1
  2907. @filter_window.filter[8] += 1
  2908. @coll_window.filter[8] = 0 unless ATK.has_key?(@coll_window.filter[8])
  2909. @filter_window.filter[8] = 0 unless ATK.has_key?(@filter_window.filter[8])
  2910. when :filter_DEF
  2911. @coll_window.filter[9] += 1
  2912. @filter_window.filter[9] += 1
  2913. @coll_window.filter[9] = 0 unless DEF.has_key?(@coll_window.filter[9])
  2914. @filter_window.filter[9] = 0 unless DEF.has_key?(@filter_window.filter[9])
  2915. when :filter_special
  2916. @coll_window.filter[10] += 1
  2917. @filter_window.filter[10] += 1
  2918. @coll_window.filter[10] = 0 unless SPECIAL.has_key?(@coll_window.filter[10])
  2919. @filter_window.filter[10] = 0 unless SPECIAL.has_key?(@filter_window.filter[10])
  2920. when :confirm
  2921. $game_party.coll += $game_party.menu_actor.deck + $game_party.menu_actor.extra
  2922. $game_party.menu_actor.deck = []
  2923. $game_party.menu_actor.extra = []
  2924. @filter_window.confirm = false
  2925. @filter_window.refresh
  2926. when :call_confirm
  2927. @filter_window.confirm = true
  2928. @filter_window.refresh
  2929. end
  2930. @filter_window.refresh
  2931. @coll_window.refresh
  2932. @deck_window.refresh
  2933. @extra_window.refresh
  2934. update_text_window
  2935. end
  2936.  
  2937. #-----------------------------------------------------------------------------
  2938. # Deativates filter
  2939. #-----------------------------------------------------------------------------
  2940. def close_filter
  2941. @filter_window.hide
  2942. @filter_window.deactivate
  2943. @coll_window.activate
  2944. @coll_window.select(0)
  2945. end
  2946.  
  2947.  
  2948. def next_actor
  2949. if $game_party.menu_actor.deck.size <= 39
  2950. RPG::SE.new("Buzzer1", 80, 100).play
  2951. $game_message.add('Your deck has less than 40 cards.')
  2952. else
  2953. @actor = $game_party.menu_actor_next
  2954. on_actor_change
  2955. end
  2956. end
  2957.  
  2958. def prev_actor
  2959. if $game_party.menu_actor.deck.size <= 39
  2960. RPG::SE.new("Buzzer1", 80, 100).play
  2961. $game_message.add('Your deck has less than 40 cards.')
  2962. else
  2963. @actor = $game_party.menu_actor_prev
  2964. on_actor_change
  2965. end
  2966. end
  2967.  
  2968. #-----------------------------------------------------------------------------
  2969. # * Frame Update
  2970. #-----------------------------------------------------------------------------
  2971. def update
  2972. super()
  2973.  
  2974. #---------------------------------------------------------------------------
  2975. # Handles input
  2976. #---------------------------------------------------------------------------
  2977. if @filter_window.visible == false
  2978. change_to_coll if Input.trigger?(:RIGHT)
  2979. change_to_deck if Input.trigger?(:LEFT)
  2980. change_to_extra if Input.trigger?(:A)
  2981. activate_filter if Input.trigger?(:X)
  2982. next_actor if Input.trigger?(:R)
  2983. prev_actor if Input.trigger?(:L)
  2984. end
  2985.  
  2986. #---------------------------------------------------------------------------
  2987. # Redraws card, if neccessary
  2988. #---------------------------------------------------------------------------
  2989. if @coll_window.active
  2990. symbol = @coll_window.current_symbol
  2991. elsif @deck_window.active
  2992. symbol = @deck_window.current_symbol
  2993. elsif @extra_window.active
  2994. symbol = @extra_window.current_symbol
  2995. end
  2996.  
  2997. if symbol != @symbol
  2998. @symbol = symbol
  2999. /[kl](?<id>\d+)/ =~ @symbol.to_s
  3000. skill = ( id ? $data_skills[id.to_i] : nil)
  3001. @card_window.set_item(skill)
  3002. end
  3003.  
  3004. end
  3005.  
  3006. def on_actor_change
  3007. RPG::SE.new("Cursor2", 80, 100).play
  3008. @deck_window.refresh
  3009. @extra_window.refresh
  3010. @deck_window.select(0)
  3011. @extra_window.select(0)
  3012. @coll_window.select(0)
  3013. update_text_window
  3014. end
  3015.  
  3016. def update_text_window
  3017. @text_window.contents.clear
  3018. text_name = $game_party.menu_actor.name + "'s Main " + DECK + ":"
  3019. @text_window.draw_text_ex(0, -3, text_name)
  3020. text_deck = $game_party.menu_actor.deck.size.to_s + "/" + MAX_DECK_SIZE.to_s
  3021. xpos = @text_window.width - 10*(text_deck.size+2) - @text_window.padding
  3022. @text_window.draw_text_ex(xpos, -3, text_deck)
  3023. text_extra = "Extra Deck: " + $game_party.menu_actor.extra.size.to_s + "/" + MAX_EXTRA_SIZE.to_s
  3024. @text_window.draw_text_ex(2, 19, text_extra)
  3025. end
  3026.  
  3027. end
  3028.  
  3029. class Window_Deck < Window_Command
  3030.  
  3031. #--------------------------------------------------------------------------
  3032. # Makes Command List
  3033. #--------------------------------------------------------------------------
  3034. def make_command_list
  3035. add_deck_commands
  3036. end
  3037.  
  3038. #--------------------------------------------------------------------------
  3039. # Add Card Commands to List
  3040. #--------------------------------------------------------------------------
  3041. def add_deck_commands
  3042. $game_party.menu_actor.sort_cards(:deck)
  3043. deck = $game_party.menu_actor.deck
  3044. if deck.empty?
  3045. add_command("---", :nothing)
  3046. return
  3047. end
  3048. hash = {}
  3049. for skill in deck
  3050. if hash.has_key?(skill.id)
  3051. hash[skill.id] += 1
  3052. else
  3053. hash[skill.id] = 1
  3054. end
  3055. end
  3056. hash.each_key do |id|
  3057. add_command(hash[id].to_s + "x " + $data_skills[id].name, ("deck" + id.to_s).to_sym)
  3058. end
  3059. end
  3060.  
  3061. #--------------------------------------------------------------------------
  3062. # Get Window Height
  3063. #--------------------------------------------------------------------------
  3064. def window_height
  3065. Graphics.height - 200
  3066. end
  3067.  
  3068. #--------------------------------------------------------------------------
  3069. # Get Window width
  3070. #--------------------------------------------------------------------------
  3071. def window_width
  3072. (Graphics.width - 210) * 0.5
  3073. end
  3074.  
  3075. #--------------------------------------------------------------------------
  3076. # Overwrite process_ok so the window won't be disabled
  3077. #--------------------------------------------------------------------------
  3078. def process_ok
  3079. if current_item_enabled?
  3080. Input.update
  3081. call_ok_handler
  3082. select(index - 1) unless current_symbol
  3083. else
  3084. Sound.play_buzzer
  3085. end
  3086. end
  3087.  
  3088. end
  3089.  
  3090. class Window_Extra < Window_Command
  3091.  
  3092. #--------------------------------------------------------------------------
  3093. # Makes Command List
  3094. #--------------------------------------------------------------------------
  3095. def make_command_list
  3096. add_extra_commands
  3097. end
  3098.  
  3099. #--------------------------------------------------------------------------
  3100. # Add Card Commands to List
  3101. #--------------------------------------------------------------------------
  3102. def add_extra_commands
  3103. $game_party.menu_actor.sort_cards(:extra)
  3104. extra = $game_party.menu_actor.extra
  3105. if extra.empty?
  3106. add_command("---", :nothing)
  3107. return
  3108. end
  3109. hash = {}
  3110. for skill in extra
  3111. if hash.has_key?(skill.id)
  3112. hash[skill.id] += 1
  3113. else
  3114. hash[skill.id] = 1
  3115. end
  3116. end
  3117. hash.each_key do |id|
  3118. add_command(hash[id].to_s + "x " + $data_skills[id].name, ("extra" + id.to_s).to_sym)
  3119. end
  3120. end
  3121.  
  3122. #--------------------------------------------------------------------------
  3123. # Get Window Height
  3124. #--------------------------------------------------------------------------
  3125. def window_height
  3126. 136
  3127. end
  3128.  
  3129. #--------------------------------------------------------------------------
  3130. # Get Window width
  3131. #--------------------------------------------------------------------------
  3132. def window_width
  3133. (Graphics.width - 210) * 0.5
  3134. end
  3135.  
  3136. #--------------------------------------------------------------------------
  3137. # Overwrite process_ok so the window won't be disabled
  3138. #--------------------------------------------------------------------------
  3139. def process_ok
  3140. if current_item_enabled?
  3141. Input.update
  3142. call_ok_handler
  3143. select(index - 1) unless current_symbol
  3144. else
  3145. Sound.play_buzzer
  3146. end
  3147. end
  3148.  
  3149. end
  3150.  
  3151. class Window_Coll < Window_Command
  3152.  
  3153. attr_accessor :filter
  3154.  
  3155. def initialize(width, heigth)
  3156. @filter = [0,0,0,0,0,0,0,0,0,0,0]
  3157. super(width, heigth)
  3158. end
  3159.  
  3160. #--------------------------------------------------------------------------
  3161. # Makes Command List
  3162. #--------------------------------------------------------------------------
  3163. def make_command_list
  3164. add_coll_commands
  3165. end
  3166.  
  3167. #--------------------------------------------------------------------------
  3168. # Add Collection Commands to List
  3169. #--------------------------------------------------------------------------
  3170. def add_coll_commands
  3171. $game_party.coll.sort!{|a,b| a.id <=> b.id}
  3172. coll = $game_party.coll
  3173. if coll.empty?
  3174. add_command("---", :nothing)
  3175. return
  3176. end
  3177. hash = {}
  3178. for skill in coll
  3179. next unless match_filter?(skill)
  3180. if hash.has_key?(skill.id)
  3181. hash[skill.id] += 1
  3182. else
  3183. hash[skill.id] = 1
  3184. end
  3185. end
  3186. hash.each_key do |id|
  3187. add_command(hash[id].to_s + "x " + $data_skills[id].name, ("coll" + id.to_s).to_sym)
  3188. end
  3189. end
  3190.  
  3191. #--------------------------------------------------------------------------
  3192. # Checks if a card meets the specified filter criteria
  3193. #--------------------------------------------------------------------------
  3194. def match_filter?(skill)
  3195. return false unless skill.damage.element_id == @filter[0] || @filter[0] == 0
  3196. return false unless skill.type == @filter[1] || @filter[1] == 0
  3197. return false unless skill.rarity == @filter[2] || @filter[2] == 0
  3198. return false unless skill.subtype == @filter[3] || @filter[3] == 0
  3199. return false unless skill.level == @filter[4] || @filter[4] == 0
  3200. return false unless skill.normeff == @filter[5] || @filter[5] == 0
  3201. return false unless skill.frame == @filter[6] || @filter[6] == 0
  3202. return false unless skill.archetype == @filter[7] || @filter[7] == 0
  3203. return false unless skill.atk == @filter[8] || @filter[8] == 0
  3204. return false unless skill.def == @filter[9] || @filter[9] == 0
  3205. return false unless skill.special == @filter[10] || @filter[10] == 0
  3206. return true
  3207. end
  3208.  
  3209.  
  3210. #--------------------------------------------------------------------------
  3211. # Get Window Height
  3212. #--------------------------------------------------------------------------
  3213. def window_height
  3214. Graphics.height - 64
  3215. end
  3216.  
  3217. #--------------------------------------------------------------------------
  3218. # Get Window width
  3219. #--------------------------------------------------------------------------
  3220. def window_width
  3221. (Graphics.width - 210) * 0.5
  3222. end
  3223.  
  3224. def process_ok
  3225. if current_item_enabled?
  3226. Input.update
  3227. call_ok_handler
  3228. select(index - 1) unless current_symbol
  3229. else
  3230. Sound.play_buzzer
  3231. end
  3232. end
  3233.  
  3234. end
  3235.  
  3236.  
  3237. class Window_Filter < Window_Command
  3238. include PC27::CG
  3239.  
  3240. attr_accessor :filter
  3241. attr_accessor :confirm
  3242.  
  3243. def initialize(width, heigth)
  3244. @filter = [0,0,0,0,0,0,0,0,0,0,0]
  3245. @confirm = false
  3246. super(width, heigth)
  3247. hide
  3248. end
  3249.  
  3250. #--------------------------------------------------------------------------
  3251. # Makes Command List
  3252. #--------------------------------------------------------------------------
  3253. def make_command_list
  3254. add_filter_commands
  3255. end
  3256.  
  3257. #--------------------------------------------------------------------------
  3258. # Add Collection Commands to List
  3259. #--------------------------------------------------------------------------
  3260. def add_filter_commands
  3261. add_command(FILTER_TEXT + F_ELEMENT + (@filter[0]==0 ? "---" : $data_system.elements[@filter[0]] ), :filter_element)
  3262. add_command(FILTER_TEXT + F_TYPE + (@filter[1]==0 ? "---" : TYPE[@filter[1]]), :filter_type)
  3263. add_command(FILTER_TEXT + F_RARITY + (@filter[2]==0 ? "---" : RARITY[@filter[2]][1]), :filter_rarity)
  3264. add_command(FILTER_TEXT + F_SUBTYPE + (@filter[3]==0 ? "---" : SUBTYPE[@filter[3]][1]), :filter_subtype)
  3265. add_command(FILTER_TEXT + F_LEVEL + (@filter[4]==0 ? "---" : LEVEL[@filter[4]][1]), :filter_level)
  3266. add_empty_deck_command
  3267. end
  3268. #--------------------------------------------------------------------------
  3269. # Get Window Height
  3270. #--------------------------------------------------------------------------
  3271. def window_height
  3272. 96
  3273. end
  3274. #--------------------------------------------------------------------------
  3275. # Get Window width
  3276. #--------------------------------------------------------------------------
  3277. def window_width
  3278. Graphics.width
  3279. end
  3280.  
  3281. def process_ok
  3282. if current_item_enabled?
  3283. RPG::SE.new("Cursor1", 80, 100)
  3284. Input.update
  3285. call_ok_handler
  3286. else
  3287. Sound.play_buzzer
  3288. end
  3289. end
  3290.  
  3291. def add_empty_deck_command
  3292. if @confirm
  3293. add_command(CONFIRM, :confirm)
  3294. else
  3295. add_command(EMPTY_DECK, :call_confirm)
  3296. end
  3297. end
  3298.  
  3299. def hide
  3300. @confirm = false
  3301. super
  3302. end
  3303. end
  3304.  
  3305.  
  3306. class Window_MenuCommand < Window_Command
  3307.  
  3308. #--------------------------------------------------------------------------
  3309. # Replaces skills with Deck (overwrite)
  3310. #--------------------------------------------------------------------------
  3311.  
  3312. def add_main_commands
  3313. add_command(Vocab::item, :item, main_commands_enabled)
  3314. add_command(PC27::CG::DECK, :deck, main_commands_enabled)
  3315. add_command(Vocab::equip, :equip, main_commands_enabled)
  3316. add_command(Vocab::status, :status, main_commands_enabled)
  3317. end
  3318.  
  3319. end
  3320.  
  3321.  
  3322. class Scene_Menu < Scene_MenuBase
  3323.  
  3324. #--------------------------------------------------------------------------
  3325. # Adds a handler to access the deck scene (alias)
  3326. #--------------------------------------------------------------------------
  3327. alias pc27_cardgame_scenemenu_create_cmd_wdw create_command_window
  3328. def create_command_window
  3329. pc27_cardgame_scenemenu_create_cmd_wdw
  3330. @command_window.set_handler(:deck, method(:command_personal))
  3331. end
  3332.  
  3333. #--------------------------------------------------------------------------
  3334. # Adds :deck to the personal command process (alias)
  3335. #--------------------------------------------------------------------------
  3336. alias pc27_cardgame_scenemenu_on_personal_ok on_personal_ok
  3337. def on_personal_ok
  3338. pc27_cardgame_scenemenu_on_personal_ok
  3339. case @command_window.current_symbol
  3340. when :deck
  3341. SceneManager.call(Scene_Deck)
  3342. end
  3343. end
  3344.  
  3345. end
  3346.  
  3347. ################################################################################
  3348. # End of script #
  3349. ################################################################################
Add Comment
Please, Sign In to add comment