Advertisement
Mattsuharu1991

Code Error

Feb 18th, 2023
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.07 KB | None | 0 0
  1. class Game_Battler < Game_BattlerBase
  2.  
  3. # Maximum number of monster zones and spell/trap zones
  4. MAX_MONSTER_ZONES = 3
  5. MAX_SPELL_TRAP_ZONES = 3
  6.  
  7. def initialize
  8. @field = []
  9. @hand = []
  10. @monster_zones = Array.new(MAX_MONSTER_ZONES)
  11. @spell_trap_zones = Array.new(MAX_SPELL_TRAP_ZONES)
  12. super
  13. end
  14.  
  15. # Returns the number of available monster zones
  16. def available_monster_zones
  17. @monster_zones.count(nil)
  18. end
  19.  
  20. # Returns the number of available spell/trap zones
  21. def available_spell_trap_zones
  22. @spell_trap_zones.count(nil)
  23. end
  24.  
  25. # Places a card from the hand into a monster zone
  26. def place_monster_card(card, zone_index)
  27. if zone_index >= MAX_MONSTER_ZONES || @monster_zones[zone_index]
  28. return false
  29. end
  30.  
  31. @hand.delete(card)
  32. @monster_zones[zone_index] = card
  33. return true
  34. end
  35.  
  36. # Places a card from the hand into a spell/trap zone
  37. def place_spell_trap_card(card, zone_index)
  38. if zone_index >= MAX_SPELL_TRAP_ZONES || @spell_trap_zones[zone_index]
  39. return false
  40. end
  41.  
  42. @hand.delete(card)
  43. @spell_trap_zones[zone_index] = card
  44. return true
  45. end
  46.  
  47. # Activates a spell card in a spell/trap zone
  48. def activate_spell_card(zone_index)
  49. card = @spell_trap_zones[zone_index]
  50. if !card || card.card_type != :spell
  51. return false
  52. end
  53.  
  54. # Add logic for spell card effects
  55. @spell_trap_zones[zone_index] = nil
  56. return true
  57. end
  58.  
  59. # Sets a trap card in a spell/trap zone
  60. def set_trap_card(card, zone_index)
  61. if zone_index >= MAX_SPELL_TRAP_ZONES || @spell_trap_zones[zone_index]
  62. return false
  63. end
  64.  
  65. @hand.delete(card)
  66. @spell_trap_zones[zone_index] = card
  67. card.face_down = true
  68. return true
  69. end
  70.  
  71. # Activates a trap card in a spell/trap zone
  72. def activate_trap_card(zone_index)
  73. card = @spell_trap_zones[zone_index]
  74. if !card || card.card_type != :trap || !card.face_down
  75. return false
  76. end
  77.  
  78. # Add logic for trap card effects
  79. @spell_trap_zones[zone_index] = nil
  80. return true
  81. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement