[wip] pokedex refactor for fusions - functional base

- reste synchro + optimisations dans consultation pokedex
This commit is contained in:
infinitefusion
2022-04-16 19:16:39 -04:00
parent 801706ed0d
commit 8ae1ff072e
17 changed files with 156 additions and 77 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -22,24 +22,55 @@ class Player < Trainer
# Clears the Pokédex. # Clears the Pokédex.
def clear def clear
@seen = {} @seen = {} #deprecated
@owned = {} @owned = {} #deprecated
@seen_fusion = {} @seen_standard = initStandardDexArray()
@owned_fusion = {} @owned_standard = initStandardDexArray()
@seen_forms = {} @seen_fusion = initFusionDexArray()
@owned_fusion = initFusionDexArray()
@seen_forms = {}
@last_seen_forms = {} @last_seen_forms = {}
@owned_shadow = {} @owned_shadow = {}
self.refresh_accessible_dexes self.refresh_accessible_dexes
end end
def initStandardDexArray()
dex_array = []
for poke in 0..NB_POKEMON
if poke == 0
dex_array << nil
end
dex_array << false
end
return dex_array
end
def initFusionDexArray()
head_array = []
for head in 0..NB_POKEMON
body_array = []
if head == 0
head_array << nil
end
for body in 0..NB_POKEMON
if body == 0
body_array << nil
end
body_array << false
end
head_array << body_array
end
return head_array
end
def isFusion(species) def isFusion(species)
num = getDexNumberForSpecies(species) num = getDexNumberForSpecies(species)
return num > Settings::NB_POKEMON && num < Settings::ZAPMOLCUNO_NB return num > Settings::NB_POKEMON && num < Settings::ZAPMOLCUNO_NB
end end
#=========================================================================== #===========================================================================
# Sets the given species as seen in the Pokédex. # Sets the given species as seen in the Pokédex.
@@ -47,21 +78,22 @@ class Player < Trainer
# @param should_refresh_dexes [Boolean] whether Dex accessibility should be recalculated # @param should_refresh_dexes [Boolean] whether Dex accessibility should be recalculated
def set_seen_fusion(species) def set_seen_fusion(species)
bodyId = getBodyID(species) bodyId = getBodyID(species)
headId = getHeadID(species,bodyId) headId = getHeadID(species, bodyId)
@seen_fusion[headId][bodyId] = true @seen_fusion[headId][bodyId] = true
p @seen_fusion
end end
# def set_seen_normalDex(species)
# species_id = GameData::Species.try_get(species)&.species
# return if species_id.nil?
# @seen[species_id] = true
# end
def set_seen_normalDex(species) def set_seen_normalDex(species)
species_id = GameData::Species.try_get(species)&.species dex_num = getDexNumberForSpecies(species)
return if species_id.nil? @seen_standard[dex_num] = true
@seen[species_id] = true
end end
def set_seen(species, should_refresh_dexes = true) def set_seen(species, should_refresh_dexes = true)
return #TODO
if isFusion(species) if isFusion(species)
set_seen_fusion(species) set_seen_fusion(species)
else else
@@ -75,20 +107,20 @@ class Player < Trainer
def seen_fusion?(species) def seen_fusion?(species)
bodyId = getBodyID(species) bodyId = getBodyID(species)
headId = getHeadID(species,bodyId) headId = getHeadID(species, bodyId)
return @seen_fusion[headId][bodyId] return @seen_fusion[headId][bodyId]
end end
# def seen_normalDex?(species)
# species_id = GameData::Species.try_get(species)&.species
# return false if species_id.nil?
# return @seen[species_id] == true
# end
def seen_normalDex?(species) def seen_normalDex?(species)
species_id = GameData::Species.try_get(species)&.species return @seen_standard[getDexNumberForSpecies(species)]
return false if species_id.nil?
return @seen[species_id] == true
end end
def seen?(species) def seen?(species)
return false#TODO
if isFusion(species) if isFusion(species)
return seen_fusion?(species) return seen_fusion?(species)
else else
@@ -101,7 +133,7 @@ class Player < Trainer
# @param form [Integer] form to check # @param form [Integer] form to check
# @return [Boolean] whether the species of the given gender and form is seen # @return [Boolean] whether the species of the given gender and form is seen
def seen_form?(species, gender, form) def seen_form?(species, gender, form)
return true return false
# species_id = GameData::Species.try_get(species)&.species # species_id = GameData::Species.try_get(species)&.species
# return false if species_id.nil? # return false if species_id.nil?
# @seen_forms[species_id] ||= [[], []] # @seen_forms[species_id] ||= [[], []]
@@ -113,8 +145,10 @@ class Player < Trainer
# in that region. # in that region.
# @param dex [Integer] region ID # @param dex [Integer] region ID
def seen_count(dex = -1) def seen_count(dex = -1)
validate dex => Integer if @seen_standard == nil || @owned_standard == nil
return self.count_species(@seen, dex) resync_pokedex()
end
count_dex(@seen_standard,@seen_fusion)
end end
# Returns whether there are any seen Pokémon. # Returns whether there are any seen Pokémon.
@@ -123,29 +157,38 @@ class Player < Trainer
# @param region [Integer] region ID # @param region [Integer] region ID
# @return [Boolean] whether there are any seen Pokémon # @return [Boolean] whether there are any seen Pokémon
def seen_any?(dex = -1) def seen_any?(dex = -1)
validate dex => Integer return seen_count >= 1
if dex == -1
GameData::Species.each { |s| return true if s.form == 0 && @seen[s.species] }
else
pbAllRegionalSpecies(dex).each { |s| return true if s && @seen[s] }
end
return false
end end
# def seen_any?(dex = -1)
# validate dex => Integer
# if dex == -1
# GameData::Species.each { |s| return true if s.form == 0 && @seen[s.species] }
# else
# pbAllRegionalSpecies(dex).each { |s| return true if s && @seen[s] }
# end
# return false
# end
# Returns the amount of seen forms for the given species. # Returns the amount of seen forms for the given species.
# @param species [Symbol, GameData::Species] Pokémon species # @param species [Symbol, GameData::Species] Pokémon species
# @return [Integer] amount of seen forms # @return [Integer] amount of seen forms
def seen_forms_count(species) def seen_forms_count(species)
species_id = GameData::Species.try_get(species)&.species return 0
return 0 if species_id.nil?
ret = 0
@seen_forms[species_id] ||= [[], []]
array = @seen_forms[species_id]
for i in 0...[array[0].length, array[1].length].max
ret += 1 if array[0][i] || array[1][i]
end
return ret
end end
# def seen_forms_count(species)
# species_id = GameData::Species.try_get(species)&.species
# return 0 if species_id.nil?
# ret = 0
# @seen_forms[species_id] ||= [[], []]
# array = @seen_forms[species_id]
# for i in 0...[array[0].length, array[1].length].max
# ret += 1 if array[0][i] || array[1][i]
# end
# return ret
# end
# @param species [Symbol, GameData::Species] Pokémon species # @param species [Symbol, GameData::Species] Pokémon species
def last_form_seen(species) def last_form_seen(species)
@@ -167,22 +210,21 @@ class Player < Trainer
# @param should_refresh_dexes [Boolean] whether Dex accessibility should be recalculated # @param should_refresh_dexes [Boolean] whether Dex accessibility should be recalculated
def set_owned_fusion(species) def set_owned_fusion(species)
bodyId = getBodyID(species) bodyId = getBodyID(species)
headId = getHeadID(species,bodyId) headId = getHeadID(species, bodyId)
@owned_fusion[headId][bodyId]=true @owned_fusion[headId][bodyId] = true
p @owned_fusion
end end
# def set_owned_normalDex(species)
# species_id = GameData::Species.try_get(species)&.species
# return if species_id.nil?
# @owned[species_id] = true
# end
def set_owned_normalDex(species) def set_owned_normalDex(species)
species_id = GameData::Species.try_get(species)&.species @owned_standard[getDexNumberForSpecies(species)] = true
return if species_id.nil?
@owned[species_id] = true
end end
def set_owned(species, should_refresh_dexes = true) def set_owned(species, should_refresh_dexes = true)
return #TODO
if isFusion(species) if isFusion(species)
set_owned_fusion(species) set_owned_fusion(species)
else else
@@ -205,21 +247,11 @@ class Player < Trainer
# @return [Boolean] whether the species is owned # @return [Boolean] whether the species is owned
def owned_fusion?(species) def owned_fusion?(species)
bodyId = getBodyID(species) bodyId = getBodyID(species)
headId = getHeadID(species,bodyId) headId = getHeadID(species, bodyId)
return @owned_fusion[headId][bodyId] == true
p @owned
p @owned[headId]
return @owned[headId][bodyId] == true
end end
def owned?(species) def owned?(species)
return false #TODO
if isFusion(species) if isFusion(species)
return owned_fusion?(species) return owned_fusion?(species)
else else
@@ -227,13 +259,14 @@ class Player < Trainer
end end
end end
# def owned_normalDex?(species)
# species_id = GameData::Species.try_get(species)&.species
# return false if species_id.nil?
# return @owned[species_id] == true
# end
def owned_normalDex?(species) def owned_normalDex?(species)
species_id = GameData::Species.try_get(species)&.species return @owned_standard[getDexNumberForSpecies(species)]
return false if species_id.nil?
return @owned[species_id] == true
end end
# @param species [Symbol, GameData::Species] species to check # @param species [Symbol, GameData::Species] species to check
# @return [Boolean] whether a Shadow Pokémon of the species is owned # @return [Boolean] whether a Shadow Pokémon of the species is owned
def owned_shadow_pokemon?(species) def owned_shadow_pokemon?(species)
@@ -248,18 +281,52 @@ class Player < Trainer
# in that region. # in that region.
# @param region [Integer] region ID # @param region [Integer] region ID
def owned_count(dex = -1) def owned_count(dex = -1)
validate dex => Integer if @owned_standard == nil || @owned_fusion == nil
return self.count_species(@owned, dex) resync_pokedex()
end
count_dex(@owned_standard,@owned_fusion)
#
# validate dex => Integer
# return self.count_species(@owned, dex)
end end
def count_dex(standardList,fusedList)
owned_standard = count_true(standardList)
owned_fused = 0
for head_poke_list in fusedList
if head_poke_list != nil
owned_fused += count_true(head_poke_list)
end
end
return owned_standard + owned_fused
end
def count_true(list)
count=0
for owned in list
if owned
count+=1
end
end
return count
end
#todo:
# loop on @owned and @seen and add the pokemon in @owned_standard/fusion @seen_standard/fusion
# then clear @owned and @seen
def resync_pokedex()
self.clear
end
#=========================================================================== #===========================================================================
# @param pkmn [Pokemon, Symbol, GameData::Species] Pokemon to register as seen # @param pkmn [Pokemon, Symbol, GameData::Species] Pokemon to register as seen
# @param gender [Integer] gender to register (0=male, 1=female, 2=genderless) # @param gender [Integer] gender to register (0=male, 1=female, 2=genderless)
# @param form [Integer] form to register # @param form [Integer] form to register
def register(species, gender = 0, form = 0, should_refresh_dexes = true) def register(species, gender = 0, form = 0, should_refresh_dexes = true)
set_owned(species,should_refresh_dexes) set_seen(species, should_refresh_dexes)
set_seen(species,should_refresh_dexes)
# return # return
# if species.is_a?(Pokemon) # if species.is_a?(Pokemon)
# species_data = species.species_data # species_data = species.species_data
@@ -330,11 +397,12 @@ class Player < Trainer
@accessible_dexes[0] = region if self.seen_any?(region) @accessible_dexes[0] = region if self.seen_any?(region)
return return
end end
if dexes_count == 1 # Only National Dex is defined if dexes_count == 1 # Only National Dex is defined
if self.unlocked?(0) && self.seen_any? if self.unlocked?(0) && self.seen_any?
@accessible_dexes.push(-1) @accessible_dexes.push(-1)
end end
else # Regional Dexes + National Dex else
# Regional Dexes + National Dex
for i in 0...dexes_count for i in 0...dexes_count
dex_list_to_check = (i == dexes_count - 1) ? -1 : i dex_list_to_check = (i == dexes_count - 1) ? -1 : i
if self.unlocked?(i) && self.seen_any?(dex_list_to_check) if self.unlocked?(i) && self.seen_any?(dex_list_to_check)

View File

@@ -25,7 +25,11 @@ class Window_Pokedex < Window_DrawableCommand
end end
def species def species
return (@commands.length==0) ? 0 : @commands[self.index][0] if self.index > @commands.size
self.index = 0
end
current_position= self.index
return (@commands.length==0) ? 0 : @commands[current_position][0]
end end
def itemCount def itemCount

View File

@@ -708,14 +708,14 @@ class PokemonFusionScene
#first check if hidden ability #first check if hidden ability
hiddenAbility1 = @pokemon1.ability == @pokemon1.getAbilityList[0][-1] hiddenAbility1 = @pokemon1.ability == @pokemon1.getAbilityList[0][-1]
hiddenAbility2 = @pokemon2.ability == @pokemon2.getAbilityList[0][-1] hiddenAbility2 = @pokemon2.ability == @pokemon2.getAbilityList[0][-1]
setFusionMoves(@pokemon1, @pokemon2) if !noMoves
#change species
@pokemon1.species = newSpecies
@pokemon1.ability = pbChooseAbility(@pokemon1, hiddenAbility1, hiddenAbility2) @pokemon1.ability = pbChooseAbility(@pokemon1, hiddenAbility1, hiddenAbility2)
if superSplicer if superSplicer
@pokemon1.nature = pbChooseNature(@pokemon1.nature, @pokemon2.nature) @pokemon1.nature = pbChooseNature(@pokemon1.nature, @pokemon2.nature)
end end
setFusionMoves(@pokemon1, @pokemon2) if !noMoves
#change species
@pokemon1.species = newSpecies
#Check moves for new species #Check moves for new species
# movelist = @pokemon1.getMoveList # movelist = @pokemon1.getMoveList
# for i in movelist # for i in movelist

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -178,3 +178,10 @@ Resistances=NORMAL,ROCK,GHOST,STEEL,GRASS,PSYCHIC,DRAGON,DARK,FAIRY,WATER,GRASS,
Immunities=POISON Immunities=POISON
[26]
Name=Bug/Steel/Psychic
InternalName=BUGSTEELPSYCHIC
IsSpecialType=true
Weaknesses=FIRE
Resistances=PSYCHIC,NORMAL,STEEL,GRASS,PSYCHIC,ICE,DRAGON,FAIRY,FIGHTING,GRASS
Immunities=POISON