Merge pull request #10 from jonisavo/additional-refactoring

Additional #isSpecies? and #hasItem? refactoring
This commit is contained in:
Maruno17
2020-09-06 19:21:17 +01:00
committed by GitHub
8 changed files with 13 additions and 17 deletions

View File

@@ -164,7 +164,7 @@ class PokeBattle_Move
return
end
# Disguise will take the damage
if !@battle.moldBreaker && isConst?(target.species,PBSpecies,:MIMIKYU) &&
if !@battle.moldBreaker && target.isSpecies?(:MIMIKYU) &&
target.form==0 && isConst?(target.ability,PBAbilities,:DISGUISE)
target.damageState.disguise = true
return

View File

@@ -852,7 +852,7 @@ BattleHandlers::DamageCalcTargetItem.add(:COLBURBERRY,
BattleHandlers::DamageCalcTargetItem.add(:DEEPSEASCALE,
proc { |item,user,target,move,mults,baseDmg,type|
if isConst?(target.species,PBSpecies,:CLAMPERL) && move.specialMove?
if target.isSpecies?(:CLAMPERL) && move.specialMove?
mults[DEF_MULT] *= 2
end
}
@@ -889,8 +889,7 @@ BattleHandlers::DamageCalcTargetItem.add(:KEBIABERRY,
BattleHandlers::DamageCalcTargetItem.add(:METALPOWDER,
proc { |item,user,target,move,mults,baseDmg,type|
if isConst?(target.species,PBSpecies,:DITTO) &&
!target.effects[PBEffects::Transform]
if target.isSpecies?(:DITTO) && !target.effects[PBEffects::Transform]
mults[DEF_MULT] = (mults[DEF_MULT]*1.5).round
end
}
@@ -935,8 +934,7 @@ BattleHandlers::DamageCalcTargetItem.add(:SHUCABERRY,
BattleHandlers::DamageCalcTargetItem.add(:SOULDEW,
proc { |item,user,target,move,mults,baseDmg,type|
next if NEWEST_BATTLE_MECHANICS
next if !isConst?(target.species,PBSpecies,:LATIAS) &&
!isConst?(target.species,PBSpecies,:LATIOS)
next if !target.isSpecies?(:LATIAS) && !target.isSpecies?(:LATIOS)
if move.specialMove? && !user.battle.rules["souldewclause"]
mults[DEF_MULT] = (mults[DEF_MULT]*1.5).round
end

View File

@@ -338,9 +338,9 @@ class PokemonEncounters
end
firstPkmn = $Trainer.firstPokemon
if firstPkmn
if isConst?(firstPkmn.item,PBItems,:CLEANSETAG)
if firstPkmn.hasItem?(:CLEANSETAG)
encount = encount*2/3
elsif isConst?(firstPkmn.item,PBItems,:PUREINCENSE)
elsif firstPkmn.hasItem?(:PUREINCENSE)
encount = encount*2/3
else # Ignore ability effects if an item effect applies
if isConst?(firstPkmn.ability,PBAbilities,:STENCH)

View File

@@ -220,7 +220,7 @@ def pbDayCareGenerateEgg
isConst?(babyspecies,PBSpecies,:ROCKRUFF) ||
isConst?(babyspecies,PBSpecies,:MINIOR)
newForm = mother.form
newForm = 0 if isConst?(mother.species,PBSpecies,:MOTHIM)
newForm = 0 if mother.isSpecies?(:MOTHIM)
egg.form = newForm
end
# Inheriting Alolan form
@@ -280,13 +280,11 @@ def pbDayCareGenerateEgg
end
# Volt Tackle
lightball = false
if (isConst?(father.species,PBSpecies,:PIKACHU) ||
isConst?(father.species,PBSpecies,:RAICHU)) &&
if (father.isSpecies?(:PIKACHU) || father.isSpecies?(:RAICHU)) &&
father.hasItem?(:LIGHTBALL)
lightball = true
end
if (isConst?(mother.species,PBSpecies,:PIKACHU) ||
isConst?(mother.species,PBSpecies,:RAICHU)) &&
if (mother.isSpecies?(:PIKACHU) || mother.isSpecies?(:RAICHU)) &&
mother.hasItem?(:LIGHTBALL)
lightball = true
end

View File

@@ -796,7 +796,7 @@ class PokeBattle_Pokemon
if gain>0
gain += 1 if @obtainMap==$game_map.map_id
gain += 1 if self.ballused==pbGetBallType(:LUXURYBALL)
gain = (gain*1.5).floor if isConst?(self.item,PBItems,:SOOTHEBELL)
gain = (gain*1.5).floor if self.hasItem?(:SOOTHEBELL)
end
@happiness += gain
@happiness = [[255,@happiness].min,0].max

View File

@@ -1715,7 +1715,7 @@ class PokemonStorageScreen
if heldpoke || selected[0]==-1
p = (heldpoke) ? heldpoke : @storage[-1,index]
p.formTime = nil if p.respond_to?("formTime")
p.form = 0 if isConst?(p.species,PBSpecies,:SHAYMIN)
p.form = 0 if p.isSpecies?(:SHAYMIN)
p.heal
end
@scene.pbStore(selected,heldpoke,destbox,firstfree)

View File

@@ -587,7 +587,7 @@ class PokemonEvolutionScene
# Modify Pokémon to make it evolved
@pokemon.species = @newspecies
@pokemon.name = newspeciesname if @pokemon.name==oldspeciesname
@pokemon.form = 0 if isConst?(@pokemon.species,PBSpecies,:MOTHIM)
@pokemon.form = 0 if @pokemon.isSpecies?(:MOTHIM)
@pokemon.calcStats
# See and own evolved species
$Trainer.seen[@newspecies] = true

View File

@@ -182,7 +182,7 @@ class PurifyChamber # German: der Kryptorbis
return false if !shadow
return false if shadow.heartgauge!=0
# Define an exception for Lugia
if isConst?(shadow.species,PBSpecies,:LUGIA)
if shadow.isSpecies?(:LUGIA)
maxtempo=PurifyChamber.maximumTempo()
for i in 0...NUMSETS
return false if @sets[i].tempo!=maxtempo