Additional refactoring, made #mail=(value) into a method that checks whether the passed value is valid

This commit is contained in:
jonisavo
2020-09-08 12:13:47 +03:00
parent 1b3a1f3f3c
commit 234f435a75

View File

@@ -31,15 +31,20 @@ class PokeBattle_Pokemon
attr_accessor :genderflag attr_accessor :genderflag
# @return [Integer] forces a particular nature (nature ID) # @return [Integer] forces a particular nature (nature ID)
attr_accessor :natureflag attr_accessor :natureflag
attr_accessor :natureOverride # Overrides nature's stat-changing effects # @return [Integer] overrides nature's stat-changing effects
attr_accessor :shinyflag # Forces the shininess (true/false) attr_accessor :natureOverride
attr_accessor :moves # Moves (PBMove) # @return [Boolean] whether shininess should be forced
attr_accessor :firstmoves # The moves known when this Pokémon was obtained attr_accessor :shinyflag
attr_accessor :item # Held item # @return [Array<PBMove>] moves known by this Pokémon
attr_writer :mail # Mail attr_accessor :moves
attr_accessor :fused # The Pokémon fused into this one # @return [Array<Integer>] IDs of moves known by this Pokémon when it was obtained
attr_accessor :iv # Array of 6 Individual Values for HP, Atk, Def, attr_accessor :firstmoves
# Speed, Sp Atk, and Sp Def # @return [Integer] id of the item held by this Pokémon (0 = no held item)
attr_accessor :item
# @return [PokeBattle_Pokemon, nil] the Pokémon fused into this one (nil if there is none)
attr_accessor :fused
# @return [Array<Integer>] array of IV values for HP, Atk, Def, Speed, Sp. Atk and Sp. Def
attr_accessor :iv
attr_writer :ivMaxed # Array of booleans that max each IV value attr_writer :ivMaxed # Array of booleans that max each IV value
attr_accessor :ev # Effort Values attr_accessor :ev # Effort Values
attr_accessor :happiness # Current happiness attr_accessor :happiness # Current happiness
@@ -663,13 +668,21 @@ class PokeBattle_Pokemon
return ret return ret
end end
# Returns this Pokémon's mail. # @return [PokemonMail, nil] mail held by this Pokémon (nil if there is none)
def mail def mail
return nil if !@mail return nil if !@mail
@mail = nil if @mail.item==0 || !hasItem?(@mail.item) @mail = nil if @mail.item==0 || !hasItem?(@mail.item)
return @mail return @mail
end end
# @param mail [PokemonMail, nil] mail to be held by this Pokémon (nil if mail is to be removed)
def mail=(mail)
if !mail.nil? && !mail.is_a?(PokemonMail)
raise ArgumentError, _INTL('Invalid value {1} given',mail.inspect)
end
@mail = mail
end
#============================================================================= #=============================================================================
# Other # Other
#============================================================================= #=============================================================================