Class: PFM::Nuzlocke
- Defined in:
- scripts/01450 Systems/00204 Nuzlocke/00001 PFM/01600 Nuzlocke.rb
Overview
Class responsive of managing Nuzlocke information and helping to implement the nuzlocke logic
Instance Attribute Summary collapse
-
#game_state ⇒ PFM::GameState
Get the game state responsive of the whole game state.
-
#graveyard ⇒ Array<PFM::Pokemon>
Storage of dead Pokemon to re-use later in other systems.
-
#no_lock_on_duplicate ⇒ Boolean
If we prevent Duplicate from locking catch.
Instance Method Summary collapse
-
#catching_locked?(id) ⇒ Boolean
Tell if catching is locked in the given zone.
-
#catching_locked_here? ⇒ Boolean
Tell if catching is locked in the current zone.
-
#clear_dead_pokemon
(also: #dead)
Function that clears the dead Pokemon from the party and put their item back in the bag.
-
#disable
Disable the Nuzlocke.
-
#enable
Enable the Nuzlocke.
-
#enabled? ⇒ Boolean
Tell if the Nuzlocke is enabled.
-
#initialize(game_state = PFM.game_state) ⇒ Nuzlocke
constructor
Create a new Nuzlocke object.
-
#lock_catch_in_current_zone(pokemon_id)
Lock the current zone (prevent Pokemon from being able to be caught here).
-
#switch(bool)
Switch the enable state of the Nuzlocke.
Constructor Details
#initialize(game_state = PFM.game_state) ⇒ Nuzlocke
Create a new Nuzlocke object
17 18 19 20 21 22 |
# File 'scripts/01450 Systems/00204 Nuzlocke/00001 PFM/01600 Nuzlocke.rb', line 17 def initialize(game_state = PFM.game_state) @catch_locked_zones = [] @no_lock_on_duplicate = false @graveyard = [] @game_state = game_state end |
Instance Attribute Details
#game_state ⇒ PFM::GameState
Get the game state responsive of the whole game state
13 14 15 |
# File 'scripts/01450 Systems/00204 Nuzlocke/00001 PFM/01600 Nuzlocke.rb', line 13 def game_state @game_state end |
#graveyard ⇒ Array<PFM::Pokemon>
Storage of dead Pokemon to re-use later in other systems
10 11 12 |
# File 'scripts/01450 Systems/00204 Nuzlocke/00001 PFM/01600 Nuzlocke.rb', line 10 def graveyard @graveyard end |
#no_lock_on_duplicate ⇒ Boolean
If we prevent Duplicate from locking catch
7 8 9 |
# File 'scripts/01450 Systems/00204 Nuzlocke/00001 PFM/01600 Nuzlocke.rb', line 7 def no_lock_on_duplicate @no_lock_on_duplicate end |
Instance Method Details
#catching_locked?(id) ⇒ Boolean
Tell if catching is locked in the given zone
52 53 54 |
# File 'scripts/01450 Systems/00204 Nuzlocke/00001 PFM/01600 Nuzlocke.rb', line 52 def catching_locked?(id) @catch_locked_zones.include?(id) end |
#catching_locked_here? ⇒ Boolean
Tell if catching is locked in the current zone
58 59 60 |
# File 'scripts/01450 Systems/00204 Nuzlocke/00001 PFM/01600 Nuzlocke.rb', line 58 def catching_locked_here? catching_locked?(@game_state.env.master_zone) end |
#clear_dead_pokemon Also known as: dead
Function that clears the dead Pokemon from the party and put their item back in the bag
26 27 28 29 30 31 32 33 34 35 36 |
# File 'scripts/01450 Systems/00204 Nuzlocke/00001 PFM/01600 Nuzlocke.rb', line 26 def clear_dead_pokemon dead_condition = proc { |pokemon| pokemon.hp <= 0 } # List all the items from dead Pokemon item_ids = @game_state.actors.select(&dead_condition).map(&:item_hold) # Add items back to the bag item_ids.each { |item_id| @game_state.bag.add_item(item_id, 1) if item_id >= 0 } # Storing Pokemon that are dead graveyard.concat(@game_state.actors.select(&dead_condition)) # Remove Pokemon from the party @game_state.actors.delete_if(&dead_condition) end |
#disable
Disable the Nuzlocke
80 81 82 |
# File 'scripts/01450 Systems/00204 Nuzlocke/00001 PFM/01600 Nuzlocke.rb', line 80 def disable switch(false) end |
#enable
Enable the Nuzlocke
75 76 77 |
# File 'scripts/01450 Systems/00204 Nuzlocke/00001 PFM/01600 Nuzlocke.rb', line 75 def enable switch(true) end |
#enabled? ⇒ Boolean
Tell if the Nuzlocke is enabled
70 71 72 |
# File 'scripts/01450 Systems/00204 Nuzlocke/00001 PFM/01600 Nuzlocke.rb', line 70 def enabled? @game_state.game_switches[Yuki::Sw::Nuzlocke_ENA] end |
#lock_catch_in_current_zone(pokemon_id)
This method checks if that's possible to lock before locking
Lock the current zone (prevent Pokemon from being able to be caught here)
42 43 44 45 46 47 |
# File 'scripts/01450 Systems/00204 Nuzlocke/00001 PFM/01600 Nuzlocke.rb', line 42 def lock_catch_in_current_zone(pokemon_id) return if catching_locked_here? || @game_state.game_temp.trainer_battle return if no_lock_on_duplicate && @game_state.pokedex.creature_caught?(pokemon_id) && !@game_state.game_switches[Yuki::Sw::BT_Catch] @catch_locked_zones.push(@game_state.env.master_zone) end |
#switch(bool)
Switch the enable state of the Nuzlocke
64 65 66 |
# File 'scripts/01450 Systems/00204 Nuzlocke/00001 PFM/01600 Nuzlocke.rb', line 64 def switch(bool) @game_state.game_switches[Yuki::Sw::Nuzlocke_ENA] = bool end |