mirror of
https://github.com/infinitefusion/infinitefusion-e18.git
synced 2025-12-07 21:24:59 +00:00
234 lines
6.9 KiB
Ruby
234 lines
6.9 KiB
Ruby
module GameData
|
|
class FusedSpecies < GameData::Species
|
|
attr_reader :growth_rate
|
|
|
|
def initialize(id)
|
|
if id.is_a?(Integer)
|
|
body_id = getBodyID(id)
|
|
head_id = getHeadID(id, body_id)
|
|
pokemon_id = getFusedPokemonIdFromDexNum(body_id, head_id)
|
|
return GameData::FusedSpecies.new(pokemon_id)
|
|
end
|
|
head_id = get_head_id_from_symbol(id)
|
|
body_id = get_body_id_from_symbol(id)
|
|
|
|
@body_pokemon = GameData::Species.get(head_id)
|
|
@head_pokemon = GameData::Species.get(body_id)
|
|
|
|
@id = id
|
|
@id_number = calculate_dex_number()
|
|
@species = @id
|
|
@form = 0
|
|
@real_name = calculate_name() #todo
|
|
@real_form_name = nil
|
|
@real_category = "???" #todo
|
|
@real_pokedex_entry = calculate_dex_entry() #todo
|
|
@pokedex_form = @form
|
|
#todo type exceptions
|
|
@type1 = @head_pokemon.type1
|
|
@type2 = @body_pokemon.type2
|
|
|
|
#Stats
|
|
@base_stats = calculate_base_stats()
|
|
@evs = calculate_evs() #todo
|
|
adjust_stats_with_evs()
|
|
|
|
@base_exp = calculate_base_exp()
|
|
@growth_rate = calculate_growth_rate() #todo
|
|
@gender_ratio = calculate_gender() #todo
|
|
@catch_rate = calculate_catch_rate()
|
|
@happiness = calculate_base_happiness()
|
|
|
|
#Moves
|
|
@moves = calculate_moveset()
|
|
@tutor_moves = calculate_tutor_moves() # hash[:tutor_moves] || []
|
|
@egg_moves = calculate_egg_moves() # hash[:egg_moves] || []
|
|
|
|
#Abilities
|
|
@abilities = calculate_abilities(@body_pokemon, @head_pokemon) # hash[:abilities] || []
|
|
@hidden_abilities = calculate_hidden_abilities(@body_pokemon, @head_pokemon) # hash[:hidden_abilities] || []
|
|
|
|
@evolutions = [] # hash[:evolutions] || []
|
|
|
|
#todo : all below
|
|
|
|
|
|
@wild_item_common = [] # hash[:wild_item_common]
|
|
@wild_item_uncommon = [] # hash[:wild_item_uncommon]
|
|
@wild_item_rare = [] # hash[:wild_item_rare]
|
|
@egg_groups = [:Undiscovered] # hash[:egg_groups] || [:Undiscovered]
|
|
@hatch_steps = 1 # hash[:hatch_steps] || 1
|
|
@incense = nil #hash[:incense]
|
|
@height = 1 # hash[:height] || 1
|
|
@weight = 1 #hash[:weight] || 1
|
|
@color = :Red #hash[:color] || :Red
|
|
@shape = :Head #hash[:shape] || :Head
|
|
@habitat = :None #hash[:habitat] || :None
|
|
@generation = 0 #hash[:generation] || 0
|
|
@mega_stone = nil
|
|
@mega_move = nil
|
|
@unmega_form = 0
|
|
@mega_message = 0
|
|
@back_sprite_x = 0 # hash[:back_sprite_x] || 0
|
|
@back_sprite_y = 0 # hash[:back_sprite_y] || 0
|
|
@front_sprite_x = 0 # hash[:front_sprite_x] || 0
|
|
@front_sprite_y = 0 # hash[:front_sprite_y] || 0
|
|
@front_sprite_altitude = 0 # hash[:front_sprite_altitude] || 0
|
|
@shadow_x = 0 # hash[:shadow_x] || 0
|
|
@shadow_size = 2 # hash[:shadow_size] || 2
|
|
@alwaysUseGeneratedSprite = false
|
|
end
|
|
|
|
def get_body_id_from_symbol(id)
|
|
return id.to_s.match(/\d+/)[0].to_i
|
|
end
|
|
|
|
def get_head_id_from_symbol(id)
|
|
return id.to_s.match(/(?<=H)\d+/)[0].to_i
|
|
end
|
|
|
|
def adjust_stats_with_evs
|
|
GameData::Stat.each_main do |s|
|
|
@base_stats[s.id] = 1 if !@base_stats[s.id] || @base_stats[s.id] <= 0
|
|
@evs[s.id] = 0 if !@evs[s.id] || @evs[s.id] < 0
|
|
end
|
|
end
|
|
|
|
#FUSION CALCULATIONS
|
|
|
|
def calculate_dex_number()
|
|
return (@head_pokemon.id_number * NB_POKEMON) + @body_pokemon.id_number
|
|
end
|
|
|
|
def calculate_base_stats()
|
|
head_stats = @head_pokemon.base_stats
|
|
body_stats = @body_pokemon.base_stats
|
|
|
|
fused_stats = {}
|
|
|
|
#Head dominant stats
|
|
fused_stats[:HP] = calculate_fused_stats(head_stats[:HP], body_stats[:HP])
|
|
fused_stats[:SPECIAL_DEFENSE] = calculate_fused_stats(head_stats[:SPECIAL_DEFENSE], body_stats[:SPECIAL_DEFENSE])
|
|
fused_stats[:SPECIAL_ATTACK] = calculate_fused_stats(head_stats[:SPECIAL_ATTACK], body_stats[:SPECIAL_ATTACK])
|
|
|
|
#Body dominant stats
|
|
fused_stats[:ATTACK] = calculate_fused_stats(body_stats[:ATTACK], head_stats[:ATTACK])
|
|
fused_stats[:DEFENSE] = calculate_fused_stats(body_stats[:DEFENSE], head_stats[:DEFENSE])
|
|
fused_stats[:SPEED] = calculate_fused_stats(body_stats[:SPEED], head_stats[:SPEED])
|
|
|
|
return fused_stats
|
|
end
|
|
|
|
def calculate_base_exp()
|
|
head_exp = @head_pokemon.base_exp
|
|
body_exp = @body_pokemon.base_exp
|
|
return average_values(head_exp, body_exp)
|
|
end
|
|
|
|
def calculate_catch_rate
|
|
return get_lowest_value(@body_pokemon.catch_rate, @head_pokemon.catch_rate)
|
|
end
|
|
|
|
def calculate_base_happiness
|
|
return @head_pokemon.happiness
|
|
end
|
|
|
|
def calculate_moveset
|
|
return combine_arrays(@body_pokemon.moves, @head_pokemon.moves)
|
|
end
|
|
|
|
def calculate_egg_moves
|
|
return combine_arrays(@body_pokemon.egg_moves, @head_pokemon.egg_moves)
|
|
end
|
|
|
|
def calculate_tutor_moves
|
|
return combine_arrays(@body_pokemon.tutor_moves, @head_pokemon.tutor_moves)
|
|
end
|
|
|
|
def calculate_abilities(pokemon1, pokemon2)
|
|
abilities_hash = []
|
|
|
|
ability1 = pokemon1.abilities[0]
|
|
ability2 = pokemon2.abilities[1]
|
|
if !ability2
|
|
ability2 = pokemon2.abilities[0]
|
|
end
|
|
abilities_hash << ability1
|
|
abilities_hash << ability2
|
|
return abilities_hash
|
|
end
|
|
|
|
def calculate_hidden_abilities(pokemon1, pokemon2)
|
|
#First two spots are the other abilities of the two pokemon
|
|
abilities_hash = calculate_abilities(pokemon2, pokemon1)
|
|
#add the hidden ability for the two base pokemon
|
|
abilities_hash << @body_pokemon.hidden_abilities[0]
|
|
abilities_hash << @head_pokemon.hidden_abilities[0]
|
|
return abilities_hash
|
|
end
|
|
|
|
#TODO
|
|
# ################## UNFINISHED ####################
|
|
|
|
#todo
|
|
def calculate_name()
|
|
prefix = GameData::SPLIT_NAMES[@body_pokemon.id_number][0]
|
|
suffix = GameData::SPLIT_NAMES[@head_pokemon.id_number][1]
|
|
if prefix[-1] == suffix[0]
|
|
prefix = prefix[0..-2]
|
|
end
|
|
return prefix + suffix
|
|
end
|
|
|
|
#todo
|
|
def calculate_evs()
|
|
return {}
|
|
end
|
|
|
|
#todo
|
|
def calculate_growth_rate
|
|
return :Medium
|
|
end
|
|
|
|
#todo
|
|
def calculate_dex_entry
|
|
return "this is a fused pokemon bro"
|
|
end
|
|
|
|
#todo
|
|
def calculate_gender
|
|
return :Genderless
|
|
end
|
|
|
|
############################# UTIL METHODS ###############################
|
|
#
|
|
def calculate_fused_stats(dominantStat, otherStat)
|
|
return ((2 * dominantStat) / 3) + (otherStat / 3).floor
|
|
end
|
|
|
|
def average_values(value1, value2)
|
|
return ((value1 + value2) / 2).floor
|
|
end
|
|
|
|
def average_map_values(map1, map2)
|
|
averaged_map = map1.merge(map2) do |key, value1, value2|
|
|
((value1 + value2) / 2.0).floor
|
|
end
|
|
return averaged_map
|
|
end
|
|
|
|
def get_highest_value(value1, value2)
|
|
return value1 > value2 ? value1 : value2
|
|
end
|
|
|
|
def get_lowest_value(value1, value2)
|
|
return value1 < value2 ? value1 : value2
|
|
end
|
|
|
|
def combine_arrays(array1, array2)
|
|
return array1 + array2
|
|
end
|
|
|
|
end
|
|
end
|