Implemented GameData::Move

This commit is contained in:
Maruno17
2020-11-19 21:00:29 +00:00
parent 52ffae9e8a
commit 3cd8d59918
71 changed files with 1443 additions and 1584 deletions

View File

@@ -179,7 +179,7 @@ end
def pbLoadSpeciesTMData
$PokemonTemp = PokemonTemp.new if !$PokemonTemp
if !$PokemonTemp.speciesTMData
$PokemonTemp.speciesTMData = load_data("Data/tm.dat") || []
$PokemonTemp.speciesTMData = load_data("Data/tm.dat") || {}
end
return $PokemonTemp.speciesTMData
end

View File

@@ -0,0 +1,89 @@
module GameData
class Move
attr_reader :id
attr_reader :id_number
attr_reader :real_name
attr_reader :function_code
attr_reader :base_damage
attr_reader :type
attr_reader :category
attr_reader :accuracy
attr_reader :total_pp
attr_reader :effect_chance
attr_reader :target
attr_reader :priority
attr_reader :flags
attr_reader :real_description
DATA = {}
DATA_FILENAME = "moves.dat"
extend ClassMethods
include InstanceMethods
def initialize(hash)
validate hash => Hash, hash[:id] => Symbol
@id = hash[:id]
@id_number = hash[:id_number] || -1
@real_name = hash[:name] || "Unnamed"
@function_code = hash[:function_code]
@base_damage = hash[:base_damage]
@type = hash[:type]
@category = hash[:category]
@accuracy = hash[:accuracy]
@total_pp = hash[:total_pp]
@effect_chance = hash[:effect_chance]
@target = hash[:target]
@priority = hash[:priority]
@flags = hash[:flags]
@real_description = hash[:description] || "???"
end
# @return [String] the translated name of this move
def name
return pbGetMessage(MessageTypes::Moves, @id_number)
end
# @return [String] the translated description of this move
def description
return pbGetMessage(MessageTypes::MoveDescriptions, @id_number)
end
def hidden_move?
GameData::Item.each do |i|
return true if i.is_HM? && i.move == @id
end
return false
end
end
end
#===============================================================================
# Deprecated methods
#===============================================================================
module MoveData
ID = 0
INTERNAL_NAME = 1
NAME = 2
FUNCTION_CODE = 3
BASE_DAMAGE = 4
TYPE = 5
CATEGORY = 6
ACCURACY = 7
TOTAL_PP = 8
EFFECT_CHANCE = 9
TARGET = 10
PRIORITY = 11
FLAGS = 12
DESCRIPTION = 13
end
def pbGetMoveData(move_id, move_data_type = -1)
Deprecation.warn_method('pbGetMoveData', 'v20', 'GameData::Move.get(move_id)')
return GameData::Move.get(move_id)
end
def pbIsHiddenMove?(move)
Deprecation.warn_method('pbIsHiddenMove?', 'v20', 'GameData::Move.get(move).hidden_move?')
return GameData::Move.get(move).hidden_move?
end

View File

@@ -84,7 +84,7 @@ module SpeciesData
"Weight" => [WEIGHT, "f"],
"Color" => [COLOR, "e", :PBColors],
"Shape" => [SHAPE, "u"],
"Moves" => [0, "*ue", nil, :PBMoves],
"Moves" => [0, "*ue", nil, :Move],
"Kind" => [0, "s"],
"Pokedex" => [0, "q"]
}
@@ -114,14 +114,14 @@ module SpeciesData
"BattlerAltitude" => [METRIC_ALTITUDE, "i"],
"BattlerShadowX" => [METRIC_SHADOW_X, "i"],
"BattlerShadowSize" => [METRIC_SHADOW_SIZE, "u"],
"EggMoves" => [0, "*e", :PBMoves],
"EggMoves" => [0, "*e", :Move],
"FormName" => [0, "q"],
"Evolutions" => [0, "*ses", nil, :PBEvolution, nil]
}
if compilingForms
ret["PokedexForm"] = [POKEDEX_FORM, "u"]
ret["MegaStone"] = [MEGA_STONE, "e", :Item]
ret["MegaMove"] = [MEGA_MOVE, "e", :PBMoves]
ret["MegaMove"] = [MEGA_MOVE, "e", :Move]
ret["UnmegaForm"] = [UNMEGA_FORM, "u"]
ret["MegaMessage"] = [MEGA_MESSAGE, "u"]
else

View File

@@ -1,111 +1,43 @@
module MoveData
ID = 0
INTERNAL_NAME = 1
NAME = 2
FUNCTION_CODE = 3
BASE_DAMAGE = 4
TYPE = 5
CATEGORY = 6
ACCURACY = 7
TOTAL_PP = 8
EFFECT_CHANCE = 9
TARGET = 10
PRIORITY = 11
FLAGS = 12
DESCRIPTION = 13
end
class PokemonTemp
attr_accessor :movesData
end
def pbLoadMovesData
$PokemonTemp = PokemonTemp.new if !$PokemonTemp
if !$PokemonTemp.movesData
if pbRgssExists?("Data/moves.dat")
$PokemonTemp.movesData = load_data("Data/moves.dat")
else
$PokemonTemp.movesData = []
end
end
return $PokemonTemp.movesData
end
def pbGetMoveData(move_id, move_data_type = -1)
meta = pbLoadMovesData
if move_data_type < 0
return meta[move_id] || []
end
return meta[move_id][move_data_type] if meta[move_id]
return nil
end
alias __moveData__pbClearData pbClearData
def pbClearData
$PokemonTemp.movesData = nil if $PokemonTemp
__moveData__pbClearData
end
#===============================================================================
# Move objects known by Pokémon.
#===============================================================================
class PBMove
attr_reader(:id) # This move's ID
attr_accessor(:pp) # The amount of PP remaining for this move
attr_accessor(:ppup) # The number of PP Ups used for this move
attr_reader :id # This move's ID
attr_accessor :pp # The amount of PP remaining for this move
attr_accessor :ppup # The number of PP Ups used on this move
# Initializes this object to the specified move ID.
def initialize(move_id)
@id = move_id
@pp = pbGetMoveData(move_id, MoveData::TOTAL_PP) || 0
@id = GameData::Move.get(move_id).id
@ppup = 0
@pp = total_pp
end
# Changes this move's ID, and caps the PP amount if it is now greater than the
# new move's total PP.
def id=(value)
old_id = @id
@id = value
@pp = [@pp, totalpp].min if old_id > 0
end
# Gets this move's type.
def type
return pbGetMoveData(@id, MoveData::TYPE) || 0
@id = GameData::Move.get(value).id
@pp = [@pp, total_pp].min
end
# Gets the maximum PP for this move.
def totalpp
max_pp = pbGetMoveData(@id, MoveData::TOTAL_PP) || 0
def total_pp
max_pp = GameData::Move.get(@id).total_pp
return max_pp + max_pp * @ppup / 5
end
end
alias totalpp total_pp
#===============================================================================
# Object containing move data. Not used for much.
#===============================================================================
class PBMoveData
attr_reader :function, :basedamage, :type, :accuracy, :category
attr_reader :totalpp, :addlEffect, :target, :priority, :flags
def initialize(move_id)
move_data = pbGetMoveData(move_id)
@function = move_data[MoveData::FUNCTION_CODE]
@basedamage = move_data[MoveData::BASE_DAMAGE]
@type = move_data[MoveData::TYPE]
@category = move_data[MoveData::CATEGORY]
@accuracy = move_data[MoveData::ACCURACY]
@totalpp = move_data[MoveData::TOTAL_PP]
@addlEffect = move_data[MoveData::EFFECT_CHANCE]
@target = move_data[MoveData::TARGET]
@priority = move_data[MoveData::PRIORITY]
@flags = move_data[MoveData::FLAGS]
end
end
def pbIsHiddenMove?(move)
GameData::Item.each do |i|
return true if i.is_HM? && move == i.move
end
return false
def function_code; return GameData::Move.get(@id).function_code; end
def base_damage; return GameData::Move.get(@id).base_damage; end
def type; return GameData::Move.get(@id).type; end
def category; return GameData::Move.get(@id).category; end
def accuracy; return GameData::Move.get(@id).accuracy; end
def effect_chance; return GameData::Move.get(@id).effect_chance; end
def target; return GameData::Move.get(@id).target; end
def priority; return GameData::Move.get(@id).priority; end
def flags; return GameData::Move.get(@id).flags; end
def name; return GameData::Move.get(@id).name; end
def description; return GameData::Move.get(@id).description; end
def hidden_move?; return GameData::Move.get(@id).hidden_move?; end
end