mirror of
https://github.com/infinitefusion/infinitefusion-e18.git
synced 2025-12-12 07:35:00 +00:00
Created and implemented GameData::Species
This commit is contained in:
@@ -135,16 +135,12 @@ class BugContestState
|
||||
else
|
||||
$game_variables[1]=ContestantNames[cont]
|
||||
end
|
||||
$game_variables[2]=PBSpecies.getName(@places[place][1])
|
||||
$game_variables[2]=GameData::Species.get(@places[place][1]).name
|
||||
$game_variables[3]=@places[place][2]
|
||||
end
|
||||
|
||||
def pbClearIfEnded
|
||||
if !@inProgress
|
||||
if !(@start && @start[0]==$game_map.map_id)
|
||||
clear
|
||||
end
|
||||
end
|
||||
clear if !@inProgress && (!@start || @start[0] != $game_map.map_id)
|
||||
end
|
||||
|
||||
def pbStartJudging
|
||||
@@ -263,18 +259,17 @@ end
|
||||
|
||||
# Returns a score for this Pokemon in the Bug Catching Contest.
|
||||
# Not exactly the HGSS calculation, but it should be decent enough.
|
||||
def pbBugContestScore(pokemon)
|
||||
levelscore=pokemon.level*4
|
||||
ivscore=0
|
||||
for i in pokemon.iv; ivscore+=i; end
|
||||
ivscore=(ivscore*100/186).floor
|
||||
hpscore=(100*pokemon.hp/pokemon.totalhp).floor
|
||||
rareness = pbGetSpeciesData(pokemon.species,pokemon.form,SpeciesData::RARENESS)
|
||||
rarescore=60
|
||||
rarescore+=20 if rareness<=120
|
||||
rarescore+=20 if rareness<=60
|
||||
score=levelscore+ivscore+hpscore+rarescore
|
||||
return score
|
||||
def pbBugContestScore(pkmn)
|
||||
levelscore = pkmn.level * 4
|
||||
ivscore = 0
|
||||
pkmn.iv.each { |iv| ivscore += iv.to_f / Pokemon::IV_STAT_LIMIT }
|
||||
ivscore = (ivscore * 100).floor
|
||||
hpscore = (100.0 * pkmn.hp / pkmn.totalhp).floor
|
||||
catch_rate = pkmn.species_data.catch_rate
|
||||
rarescore = 60
|
||||
rarescore += 20 if catch_rate <= 120
|
||||
rarescore += 20 if catch_rate <= 60
|
||||
return levelscore + ivscore + hpscore + rarescore
|
||||
end
|
||||
|
||||
def pbBugContestState
|
||||
|
||||
@@ -32,10 +32,7 @@ class PBPokemon
|
||||
def self.fromInspected(str)
|
||||
insp=str.gsub(/^\s+/,"").gsub(/\s+$/,"")
|
||||
pieces=insp.split(/\s*;\s*/)
|
||||
species=1
|
||||
if (PBSpecies.const_defined?(pieces[0]) rescue false)
|
||||
species=PBSpecies.const_get(pieces[0])
|
||||
end
|
||||
species = (GameData::Species.exists?(pieces[0])) ? GameData::Species.get(pieces[0]).id : nil
|
||||
item = (GameData::Item.exists?(pieces[1])) ? GameData::Item.get(pieces[1]).id : nil
|
||||
nature=PBNatures.const_get(pieces[2])
|
||||
ev=pieces[3].split(/\s*,\s*/)
|
||||
@@ -95,7 +92,7 @@ class PBPokemon
|
||||
|
||||
def self.fromstring(str)
|
||||
s=str.split(/\s*,\s*/)
|
||||
species=self.constFromStr(PBSpecies,s[1])
|
||||
species=GameData::Species.get(s[1]).id
|
||||
item=s[2].to_sym
|
||||
nature=self.constFromStr(PBNatures,s[3])
|
||||
move1=GameData::Move.get(s[4]).id
|
||||
@@ -129,8 +126,8 @@ class PBPokemon
|
||||
=end
|
||||
|
||||
def inspect
|
||||
c1=getConstantName(PBSpecies,@species)
|
||||
c2=(@item) ? GameData::Item.get(@item).id_to_s : ""
|
||||
c1=GameData::Species.get(@species).id.to_s
|
||||
c2=(@item) ? GameData::Item.get(@item).id.to_s : ""
|
||||
c3=getConstantName(PBNatures,@nature)
|
||||
evlist=""
|
||||
for i in 0...@ev
|
||||
|
||||
@@ -1,26 +1,22 @@
|
||||
def pbBaseStatTotal(species)
|
||||
baseStats = pbGetSpeciesData(species,0,SpeciesData::BASE_STATS)
|
||||
baseStats = GameData::Species.get(species).base_stats
|
||||
ret = 0
|
||||
baseStats.each { |s| ret += s }
|
||||
return ret
|
||||
end
|
||||
|
||||
def pbBalancedLevelFromBST(species)
|
||||
return (113-(pbBaseStatTotal(species)*0.072)).round
|
||||
return (113 - (pbBaseStatTotal(species) * 0.072)).round
|
||||
end
|
||||
|
||||
def pbTooTall?(pkmn,maxHeightInMeters)
|
||||
species = (pkmn.is_a?(Pokemon)) ? pkmn.species : pkmn
|
||||
form = (pkmn.is_a?(Pokemon)) ? pkmn.form : 0
|
||||
height = pbGetSpeciesData(species,form,SpeciesData::HEIGHT)
|
||||
return height>(maxHeightInMeters*10).round
|
||||
def pbTooTall?(pkmn, maxHeightInMeters)
|
||||
height = (pkmn.is_a?(Pokemon)) ? pkmn.height : GameData::Species.get(pkmn).height
|
||||
return height > (maxHeightInMeters * 10).round
|
||||
end
|
||||
|
||||
def pbTooHeavy?(pkmn,maxWeightInKg)
|
||||
species = (pkmn.is_a?(Pokemon)) ? pkmn.species : pkmn
|
||||
form = (pkmn.is_a?(Pokemon)) ? pkmn.form : 0
|
||||
weight = pbGetSpeciesData(species,form,SpeciesData::WEIGHT)
|
||||
return weight>(maxWeightInKg*10).round
|
||||
def pbTooHeavy?(pkmn, maxWeightInKg)
|
||||
weight = (pkmn.is_a?(Pokemon)) ? pkmn.weight : GameData::Species.get(pkmn).weight
|
||||
return weight > (maxWeightInKg * 10).round
|
||||
end
|
||||
|
||||
|
||||
@@ -287,10 +283,7 @@ class SpeciesRestriction
|
||||
end
|
||||
|
||||
def isSpecies?(species,specieslist)
|
||||
for s in specieslist
|
||||
return true if isConst?(species,PBSpecies,s)
|
||||
end
|
||||
return false
|
||||
return specieslist.include?(species)
|
||||
end
|
||||
|
||||
def isValid?(pokemon)
|
||||
@@ -310,10 +303,7 @@ class BannedSpeciesRestriction
|
||||
end
|
||||
|
||||
def isSpecies?(species,specieslist)
|
||||
for s in specieslist
|
||||
return true if isConst?(species,PBSpecies,s)
|
||||
end
|
||||
return false
|
||||
return specieslist.include?(species)
|
||||
end
|
||||
|
||||
def isValid?(pokemon)
|
||||
@@ -328,17 +318,17 @@ end
|
||||
|
||||
|
||||
class BannedItemRestriction
|
||||
def initialize(*specieslist)
|
||||
@specieslist=specieslist.clone
|
||||
def initialize(*itemlist)
|
||||
@itemlist=itemlist.clone
|
||||
end
|
||||
|
||||
def isSpecies?(species,specieslist)
|
||||
return specieslist.any? { |s| species == s }
|
||||
def isSpecies?(item,itemlist)
|
||||
return itemlist.include?(item)
|
||||
end
|
||||
|
||||
def isValid?(pokemon)
|
||||
count=0
|
||||
if pokemon.item && isSpecies?(pokemon.item,@specieslist)
|
||||
if pokemon.item && isSpecies?(pokemon.item,@itemlist)
|
||||
count+=1
|
||||
end
|
||||
return count==0
|
||||
@@ -354,10 +344,7 @@ class RestrictedSpeciesRestriction
|
||||
end
|
||||
|
||||
def isSpecies?(species,specieslist)
|
||||
for s in specieslist
|
||||
return true if isConst?(species,PBSpecies,s)
|
||||
end
|
||||
return false
|
||||
return specieslist.include?(species)
|
||||
end
|
||||
|
||||
def isValid?(team)
|
||||
@@ -390,29 +377,22 @@ end
|
||||
|
||||
|
||||
class StandardRestriction
|
||||
def isValid?(pokemon)
|
||||
return false if !pokemon || pokemon.egg?
|
||||
def isValid?(pkmn)
|
||||
return false if !pkmn || pkmn.egg?
|
||||
# Species with disadvantageous abilities are not banned
|
||||
abilities = pbGetSpeciesData(pokemon.species,pokemon.form,SpeciesData::ABILITIES)
|
||||
abilities = [abilities] if !abilities.is_a?(Array)
|
||||
abilities.each do |a|
|
||||
return true if [:TRUANT, :SLOWSTART].include?(a)
|
||||
pkmn.species_data.abilities.each do |a|
|
||||
return true if [:TRUANT, :SLOWSTART].include?(a[0])
|
||||
end
|
||||
# Certain named species are not banned
|
||||
speciesWhitelist = [:DRAGONITE,:SALAMENCE,:TYRANITAR]
|
||||
for i in speciesWhitelist
|
||||
return true if pokemon.isSpecies?(i)
|
||||
end
|
||||
speciesWhitelist = [:DRAGONITE, :SALAMENCE, :TYRANITAR]
|
||||
return true if speciesWhitelist.include?(pkmn.species)
|
||||
# Certain named species are banned
|
||||
speciesBlacklist = [:WYNAUT,:WOBBUFFET]
|
||||
for i in speciesBlacklist
|
||||
return false if pokemon.isSpecies?(i)
|
||||
end
|
||||
speciesBlacklist = [:WYNAUT, :WOBBUFFET]
|
||||
return false if speciesBlacklist.include?(pkmn.species)
|
||||
# Species with total base stat 600 or more are banned
|
||||
baseStats = pbGetSpeciesData(pokemon.species,pokemon.form,SpeciesData::BASE_STATS)
|
||||
bst = 0
|
||||
baseStats.each { |s| bst += s }
|
||||
return false if bst>=600
|
||||
pkmn.baseStats.each { |s| bst += s }
|
||||
return false if bst >= 600
|
||||
# Is valid
|
||||
return true
|
||||
end
|
||||
@@ -632,28 +612,23 @@ end
|
||||
|
||||
|
||||
module NicknameChecker
|
||||
@@names={}
|
||||
@@namesMaxValue=0
|
||||
@@names = {}
|
||||
|
||||
def getName(species)
|
||||
n=@@names[species]
|
||||
n = @@names[species]
|
||||
return n if n
|
||||
n=PBSpecies.getName(species)
|
||||
@@names[species]=n.upcase
|
||||
n = GameData::Species.get(species).name
|
||||
@@names[species] = n.upcase
|
||||
return n
|
||||
end
|
||||
|
||||
def check(name,species)
|
||||
name=name.upcase
|
||||
return true if name==getName(species)
|
||||
if @@names.values.include?(name)
|
||||
return false
|
||||
end
|
||||
for i in @@namesMaxValue..PBSpecies.maxValue
|
||||
if i!=species
|
||||
n=getName(i)
|
||||
return false if n==name
|
||||
end
|
||||
def check(name, species)
|
||||
name = name.upcase
|
||||
return true if name == getName(species)
|
||||
return false if @@names.values.include?(name)
|
||||
GameData::Species.each do |species_data|
|
||||
next if species_data.species == species || species_data.form != 0
|
||||
return false if getName(species_data.id) == name
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
@@ -40,35 +40,31 @@ def addMove(moves,move,base)
|
||||
end
|
||||
end
|
||||
|
||||
$legalMoves = []
|
||||
$legalMoves = {}
|
||||
$legalMovesLevel = 0
|
||||
$baseStatTotal = []
|
||||
$minimumLevel = []
|
||||
$babySpecies = []
|
||||
$evolutions = []
|
||||
$baseStatTotal = {}
|
||||
$minimumLevel = {}
|
||||
$babySpecies = {}
|
||||
$evolutions = {}
|
||||
$tmMoves = nil
|
||||
|
||||
def pbGetLegalMoves2(species,maxlevel)
|
||||
moves=[]
|
||||
return moves if !species || species<=0
|
||||
moveset = pbGetSpeciesMoveset(species)
|
||||
moveset.each { |m| addMove(moves,m[1],2) if m[0]<=maxlevel }
|
||||
tmData=pbLoadSpeciesTMData
|
||||
species_data = GameData::Species.get(species)
|
||||
moves = []
|
||||
return moves if !species_data
|
||||
# Populate available moves array (moves)
|
||||
species_data.moves.each { |m| addMove(moves, m[1], 2) if m[0] <= maxlevel }
|
||||
if !$tmMoves
|
||||
$tmMoves=[]
|
||||
GameData::Item.each do |i|
|
||||
$tmMoves.push(i.move) if i.move && tmData[i.move]
|
||||
end
|
||||
end
|
||||
for atk in $tmMoves
|
||||
addMove(moves,atk,0) if tmData[atk].include?(species)
|
||||
$tmMoves = []
|
||||
GameData::Item.each { |i| $tmMoves.push(i.move) if i.is_machine? }
|
||||
end
|
||||
species_data.tutor_moves.each { |m| addMove(moves, m, 0) if $tmMoves.include?(m) }
|
||||
babyspecies = babySpecies(species)
|
||||
babyEggMoves = pbGetSpeciesEggMoves(babyspecies)
|
||||
babyEggMoves.each { |m| addMove(moves,m,2) }
|
||||
movedatas=[]
|
||||
GameData::Species.get(babyspecies).egg_moves.each { |m| addMove(moves, m, 2) }
|
||||
#
|
||||
movedatas = []
|
||||
for move in moves
|
||||
movedatas.push([move,GameData::Move.get(move)])
|
||||
movedatas.push([move, GameData::Move.get(move)])
|
||||
end
|
||||
# Delete less powerful moves
|
||||
deleteAll=proc { |a,item|
|
||||
@@ -101,32 +97,24 @@ def pbGetLegalMoves2(species,maxlevel)
|
||||
return moves
|
||||
end
|
||||
|
||||
def baseStatTotal(move)
|
||||
if !$baseStatTotal[move]
|
||||
$baseStatTotal[move]=pbBaseStatTotal(move)
|
||||
end
|
||||
return $baseStatTotal[move]
|
||||
def baseStatTotal(species)
|
||||
$baseStatTotal[species] = pbBaseStatTotal(species) if !$baseStatTotal[species]
|
||||
return $baseStatTotal[species]
|
||||
end
|
||||
|
||||
def babySpecies(move)
|
||||
if !$babySpecies[move]
|
||||
$babySpecies[move]=EvolutionHelper.baby_species(move)
|
||||
end
|
||||
return $babySpecies[move]
|
||||
def babySpecies(species)
|
||||
$babySpecies[species] = EvolutionHelper.baby_species(species) if !$babySpecies[species]
|
||||
return $babySpecies[species]
|
||||
end
|
||||
|
||||
def minimumLevel(move)
|
||||
if !$minimumLevel[move]
|
||||
$minimumLevel[move]=EvolutionHelper.minimum_level(move)
|
||||
end
|
||||
return $minimumLevel[move]
|
||||
$minimumLevel[species] = EvolutionHelper.minimum_level(species) if !$minimumLevel[species]
|
||||
return $minimumLevel[species]
|
||||
end
|
||||
|
||||
def evolutions(move)
|
||||
if !$evolutions[move]
|
||||
$evolutions[move]=EvolutionHelper.evolutions(move, true)
|
||||
end
|
||||
return $evolutions[move]
|
||||
def evolutions(species)
|
||||
$evolutions[species] = EvolutionHelper.evolutions(species, true) if !$evolutions[species]
|
||||
return $evolutions[species]
|
||||
end
|
||||
|
||||
=begin
|
||||
@@ -147,13 +135,14 @@ end
|
||||
|
||||
|
||||
class BaseStatRestriction
|
||||
def initialize(mn,mx)
|
||||
@mn=mn;@mx=mx
|
||||
def initialize(mn, mx)
|
||||
@mn = mn
|
||||
@mx = mx
|
||||
end
|
||||
|
||||
def isValid?(pkmn)
|
||||
bst=baseStatTotal(pkmn.species)
|
||||
return bst>=@mn && bst<=@mx
|
||||
bst = baseStatTotal(pkmn.species)
|
||||
return bst >= @mn && bst <= @mx
|
||||
end
|
||||
end
|
||||
|
||||
@@ -162,9 +151,7 @@ end
|
||||
class NonlegendaryRestriction
|
||||
def isValid?(pkmn)
|
||||
return true if !pkmn.genderless?
|
||||
compatibility = pbGetSpeciesData(pkmn.species,pkmn.form,SpeciesData::COMPATIBILITY)
|
||||
compatibility = [compatibility] if !compatibility.is_a?(Array)
|
||||
compatibility.each { |c| return false if isConst?(c,PBEggGroups,:Undiscovered) }
|
||||
return false if pkmn.species_data.egg_groups.include?(PBEggGroups::Undiscovered)
|
||||
return true
|
||||
end
|
||||
end
|
||||
@@ -260,14 +247,13 @@ def pbRandomPokemonFromRule(rule,trainer)
|
||||
iteration=-1
|
||||
loop do
|
||||
iteration+=1
|
||||
species=0
|
||||
species=nil
|
||||
level=rule.ruleset.suggestedLevel
|
||||
keys = GameData::Species::DATA.keys.sort
|
||||
loop do
|
||||
species=0
|
||||
loop do
|
||||
species=rand(PBSpecies.maxValue)+1
|
||||
cname=getConstantName(PBSpecies,species) rescue nil
|
||||
break if cname
|
||||
species = keys[rand(keys.length)]
|
||||
break if GameData::Species.get(species).form == 0
|
||||
end
|
||||
r=rand(20)
|
||||
bst=baseStatTotal(species)
|
||||
@@ -299,7 +285,7 @@ def pbRandomPokemonFromRule(rule,trainer)
|
||||
break
|
||||
end
|
||||
item = nil
|
||||
$legalMoves=[] if level!=$legalMovesLevel
|
||||
$legalMoves={} if level!=$legalMovesLevel
|
||||
$legalMoves[species]=pbGetLegalMoves2(species,level) if !$legalMoves[species]
|
||||
itemlist=[
|
||||
:ORANBERRY,:SITRUSBERRY,:ADAMANTORB,:BABIRIBERRY,
|
||||
@@ -322,38 +308,33 @@ def pbRandomPokemonFromRule(rule,trainer)
|
||||
next if !item
|
||||
case item
|
||||
when :LIGHTBALL
|
||||
next if !isConst?(species,PBSpecies,:PIKACHU)
|
||||
next if species != :PIKACHU
|
||||
when :SHEDSHELL
|
||||
next if !isConst?(species,PBSpecies,:FORRETRESS) ||
|
||||
!isConst?(species,PBSpecies,:SKARMORY)
|
||||
next if species != :FORRETRESS && species != :SKARMORY
|
||||
when :SOULDEW
|
||||
next if !isConst?(species,PBSpecies,:LATIOS) ||
|
||||
!isConst?(species,PBSpecies,:LATIAS)
|
||||
next if species != :LATIOS && species != :LATIAS
|
||||
when :FOCUSSASH
|
||||
next if baseStatTotal(species)>450 && rand(10)<8
|
||||
when :ADAMANTORB
|
||||
next if !isConst?(species,PBSpecies,:DIALGA)
|
||||
next if species != :DIALGA
|
||||
when :PASSHOBERRY
|
||||
next if !isConst?(species,PBSpecies,:STEELIX)
|
||||
next if species != :STEELIX
|
||||
when :BABIRIBERRY
|
||||
next if !isConst?(species,PBSpecies,:TYRANITAR)
|
||||
next if species != :TYRANITAR
|
||||
when :HABANBERRY
|
||||
next if !isConst?(species,PBSpecies,:GARCHOMP)
|
||||
next if species != :GARCHOMP
|
||||
when :OCCABERRY
|
||||
next if !isConst?(species,PBSpecies,:METAGROSS)
|
||||
next if species != :METAGROSS
|
||||
when :CHOPLEBERRY
|
||||
next if !isConst?(species,PBSpecies,:UMBREON)
|
||||
next if species != :UMBREON
|
||||
when :YACHEBERRY
|
||||
next if !isConst?(species,PBSpecies,:TORTERRA) &&
|
||||
!isConst?(species,PBSpecies,:GLISCOR) &&
|
||||
!isConst?(species,PBSpecies,:DRAGONAIR)
|
||||
next if species != :TORTERRA && species != :GLISCOR && species != :DRAGONAIR
|
||||
when :SHUCABERRY
|
||||
next if !isConst?(species,PBSpecies,:HEATRAN)
|
||||
next if species != :HEATRAN
|
||||
when :DEEPSEATOOTH
|
||||
next if !isConst?(species,PBSpecies,:CLAMPERL)
|
||||
next if species != :CLAMPERL
|
||||
when :THICKCLUB
|
||||
next if !isConst?(species,PBSpecies,:CUBONE) &&
|
||||
!isConst?(species,PBSpecies,:MAROWAK)
|
||||
next if species != :CUBONE && species != :MAROWAK
|
||||
end
|
||||
if item == :LIECHIBERRY && (ev&0x02)==0
|
||||
next if rand(2)==0
|
||||
@@ -459,8 +440,8 @@ def pbRandomPokemonFromRule(rule,trainer)
|
||||
item = :LEFTOVERS
|
||||
end
|
||||
if item == :BLACKSLUDGE
|
||||
type1 = pbGetSpeciesData(species,0,SpeciesData::TYPE1)
|
||||
type2 = pbGetSpeciesData(species,0,SpeciesData::TYPE2) || type1
|
||||
type1 = GameData::Species.get(species).type1
|
||||
type2 = GameData::Species.get(species).type2 || type1
|
||||
item = :LEFTOVERS if type1 != :POISON && type2 != :POISON
|
||||
end
|
||||
if item == :HEATROCK && !moves.any? { |m| m == :SUNNYDAY }
|
||||
@@ -912,9 +893,10 @@ def pbRuledBattle(team1,team2,rule)
|
||||
end
|
||||
|
||||
def getTypes(species)
|
||||
type1 = pbGetSpeciesData(species,0,SpeciesData::TYPE1)
|
||||
type2 = pbGetSpeciesData(species,0,SpeciesData::TYPE2) || type1
|
||||
return type1==type2 ? [type1] : [type1,type2]
|
||||
species_data = GameData::Species.get(species)
|
||||
type1 = species_data.type1
|
||||
type2 = species_data.type2
|
||||
return (type1 == type2) ? [type1] : [type1, type2]
|
||||
end
|
||||
|
||||
def pbTrainerInfo(pokemonlist,trfile,rules)
|
||||
|
||||
@@ -72,19 +72,15 @@ class BattleSwapScene
|
||||
UIHelper.pbConfirm(@sprites["msgwindow"],message) { pbUpdate }
|
||||
end
|
||||
|
||||
def pbGetCommands(list,choices)
|
||||
commands=[]
|
||||
def pbGetCommands(list, choices)
|
||||
commands = []
|
||||
for i in 0...list.length
|
||||
pkmn=list[i]
|
||||
kind=pbGetMessage(MessageTypes::Kinds,pbGetFSpeciesFromForm(pkmn.species,pkn.form))
|
||||
selected=shadowctagFromColor(Color.new(232,0,0))
|
||||
if choices.any?{ |item| item==i }
|
||||
commands.push(selected+_INTL("{1} - {2} POKéMON",
|
||||
PBSpecies.getName(pkmn.species),kind))
|
||||
else
|
||||
commands.push(_INTL("{1} - {2} POKéMON",
|
||||
PBSpecies.getName(pkmn.species),kind))
|
||||
end
|
||||
pkmn = list[i]
|
||||
category = pkmn.species_data.category
|
||||
selected = shadowctagFromColor(Color.new(232, 0, 0))
|
||||
cmd = _INTL("{1} - {2} Pokémon", pkmn.speciesName, category)
|
||||
cmd = selected + cmd if choices.include?(i)
|
||||
commands.push(cmd)
|
||||
end
|
||||
return commands
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user