mirror of
https://github.com/infinitefusion/infinitefusion-e18.git
synced 2025-12-06 06:01:46 +00:00
Made more use of nil_or_empty?, fixed incorrect default species body shape, fixed Illusion, fixed potential foreign Pokémon with blank names
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
# Using mkxp-z v2.1.1 - https://gitlab.com/mkxp-z/mkxp-z/-/releases/v2.1.1
|
||||
# Using mkxp-z v2.1.2 - https://gitlab.com/mkxp-z/mkxp-z/-/releases/v2.1.2
|
||||
$VERBOSE = nil
|
||||
Font.default_shadow = false if Font.respond_to?(:default_shadow)
|
||||
Graphics.frame_rate = 40
|
||||
|
||||
@@ -181,7 +181,7 @@ module RTP
|
||||
@rtpPaths = nil
|
||||
|
||||
def self.exists?(filename,extensions=[])
|
||||
return false if !filename || filename==""
|
||||
return false if nil_or_empty?(filename)
|
||||
eachPathFor(filename) { |path|
|
||||
return true if safeExists?(path)
|
||||
for ext in extensions
|
||||
@@ -200,7 +200,7 @@ module RTP
|
||||
end
|
||||
|
||||
def self.getPath(filename,extensions=[])
|
||||
return filename if !filename || filename==""
|
||||
return filename if nil_or_empty?(filename)
|
||||
eachPathFor(filename) { |path|
|
||||
return path if safeExists?(path)
|
||||
for ext in extensions
|
||||
|
||||
@@ -405,7 +405,7 @@ class Messages
|
||||
if msgs.is_a?(Array)
|
||||
f.write("[#{secname}]\r\n")
|
||||
for j in 0...msgs.length
|
||||
next if msgs[j]==nil || msgs[j]==""
|
||||
next if nil_or_empty?(msgs[j])
|
||||
value=Messages.normalizeValue(msgs[j])
|
||||
origValue=""
|
||||
if origMessages
|
||||
@@ -421,7 +421,7 @@ class Messages
|
||||
f.write("[#{secname}]\r\n")
|
||||
keys=msgs.keys
|
||||
for key in keys
|
||||
next if msgs[key]==nil || msgs[key]==""
|
||||
next if nil_or_empty?(msgs[key])
|
||||
value=Messages.normalizeValue(msgs[key])
|
||||
valkey=Messages.normalizeValue(key)
|
||||
# key is already serialized
|
||||
|
||||
@@ -438,7 +438,7 @@ module PluginManager
|
||||
message += "#{$!.class} occurred.\r\n"
|
||||
# go through message content
|
||||
for line in $!.message.split("\r\n")
|
||||
next if !line || line == ""
|
||||
next if nil_or_empty?(line)
|
||||
n = line[/\d+/]
|
||||
err = line.split(":")[-1].strip
|
||||
lms = line.split(":")[0].strip
|
||||
|
||||
@@ -423,7 +423,7 @@ def pbGetPlayerCharset(meta,charset,trainer=nil,force=false)
|
||||
end
|
||||
$game_player.charsetData = [$Trainer.character_ID,charset,outfit] if $game_player
|
||||
ret = meta[charset]
|
||||
ret = meta[1] if !ret || ret==""
|
||||
ret = meta[1] if nil_or_empty?(ret)
|
||||
if pbResolveBitmap("Graphics/Characters/"+ret+"_"+outfit.to_s)
|
||||
ret = ret+"_"+outfit.to_s
|
||||
end
|
||||
|
||||
@@ -81,15 +81,15 @@ module MessageConfig
|
||||
if skin && skin!=""
|
||||
skin=pbResolveBitmap("Graphics/Windowskins/"+skin) || ""
|
||||
end
|
||||
skin=pbResolveBitmap("Graphics/System/Window") if !skin || skin==""
|
||||
skin=pbResolveBitmap("Graphics/Windowskins/001-Blue01") if !skin || skin==""
|
||||
skin=pbResolveBitmap("Graphics/System/Window") if nil_or_empty?(skin)
|
||||
skin=pbResolveBitmap("Graphics/Windowskins/001-Blue01") if nil_or_empty?(skin)
|
||||
return skin || ""
|
||||
end
|
||||
|
||||
def self.pbGetSystemFrame
|
||||
if !@@systemFrame
|
||||
skin=MessageConfig.pbDefaultSystemFrame
|
||||
skin=MessageConfig.pbDefaultWindowskin if !skin || skin==""
|
||||
skin=MessageConfig.pbDefaultWindowskin if nil_or_empty?(skin)
|
||||
@@systemFrame=skin || ""
|
||||
end
|
||||
return @@systemFrame
|
||||
@@ -98,7 +98,7 @@ module MessageConfig
|
||||
def self.pbGetSpeechFrame
|
||||
if !@@defaultTextSkin
|
||||
skin=MessageConfig.pbDefaultSpeechFrame
|
||||
skin=MessageConfig.pbDefaultWindowskin if !skin || skin==""
|
||||
skin=MessageConfig.pbDefaultWindowskin if nil_or_empty?(skin)
|
||||
@@defaultTextSkin=skin || ""
|
||||
end
|
||||
return @@defaultTextSkin
|
||||
|
||||
@@ -868,7 +868,7 @@ class SpriteWindow_Base < SpriteWindow
|
||||
@customskin.dispose if @customskin
|
||||
@customskin=nil
|
||||
resolvedName=pbResolveBitmap(skin)
|
||||
return if !resolvedName || resolvedName==""
|
||||
return if nil_or_empty?(resolvedName)
|
||||
@customskin=AnimatedBitmap.new(resolvedName)
|
||||
RPG::Cache.retain(resolvedName)
|
||||
__setWindowskin(@customskin.bitmap)
|
||||
|
||||
@@ -164,7 +164,7 @@ module GameData
|
||||
@height = hash[:height] || 1
|
||||
@weight = hash[:weight] || 1
|
||||
@color = hash[:color] || :Red
|
||||
@shape = hash[:shape] || :Body
|
||||
@shape = hash[:shape] || :Head
|
||||
@habitat = hash[:habitat] || :None
|
||||
@generation = hash[:generation] || 0
|
||||
@mega_stone = hash[:mega_stone]
|
||||
|
||||
@@ -344,7 +344,7 @@ class PokeBattle_Battler
|
||||
def hasActiveAbility?(check_ability, ignore_fainted = false)
|
||||
return false if !abilityActive?(ignore_fainted)
|
||||
return check_ability.include?(@ability_id) if check_ability.is_a?(Array)
|
||||
return check_ability == self.ability
|
||||
return self.ability == check_ability
|
||||
end
|
||||
alias hasWorkingAbility hasActiveAbility?
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ class PokeBattle_Battler
|
||||
@battle.pbHideAbilitySplash(target)
|
||||
pbItemHPHealCheck
|
||||
else
|
||||
msg = _INTL("{1} had its energy drained!",target.pbThis) if !msg || msg==""
|
||||
msg = _INTL("{1} had its energy drained!",target.pbThis) if nil_or_empty?(msg)
|
||||
@battle.pbDisplay(msg)
|
||||
if canHeal?
|
||||
amt = (amt*1.3).floor if hasActiveItem?(:BIGROOT)
|
||||
|
||||
@@ -484,7 +484,7 @@ class PokeBattle_Battler
|
||||
def pbConfuse(msg=nil)
|
||||
@effects[PBEffects::Confusion] = pbConfusionDuration
|
||||
@battle.pbCommonAnimation("Confusion",self)
|
||||
msg = _INTL("{1} became confused!",pbThis) if !msg || msg==""
|
||||
msg = _INTL("{1} became confused!",pbThis) if nil_or_empty?(msg)
|
||||
@battle.pbDisplay(msg)
|
||||
PBDebug.log("[Lingering effect] #{pbThis}'s confusion count is #{@effects[PBEffects::Confusion]}")
|
||||
# Confusion cures
|
||||
@@ -551,7 +551,7 @@ class PokeBattle_Battler
|
||||
def pbAttract(user,msg=nil)
|
||||
@effects[PBEffects::Attract] = user.index
|
||||
@battle.pbCommonAnimation("Attract",self)
|
||||
msg = _INTL("{1} fell in love!",pbThis) if !msg || msg==""
|
||||
msg = _INTL("{1} fell in love!",pbThis) if nil_or_empty?(msg)
|
||||
@battle.pbDisplay(msg)
|
||||
# Destiny Knot
|
||||
if hasActiveItem?(:DESTINYKNOT) && user.pbCanAttract?(self,false)
|
||||
|
||||
@@ -401,7 +401,7 @@ class PokeBattle_Battle
|
||||
party.each_with_index do |pkmn,i|
|
||||
next if i<idxPartyStart || i>=idxPartyEnd # Check the team only
|
||||
next if !pkmn || !pkmn.able? # Can't copy a non-fainted Pokémon or egg
|
||||
ret = i if partyOrders[i]>partyOrders[ret]
|
||||
ret = i if ret < 0 || partyOrders[i] > partyOrders[ret]
|
||||
end
|
||||
return ret
|
||||
end
|
||||
|
||||
@@ -170,7 +170,7 @@ class PokeBattle_Battle
|
||||
enemyParty = pbParty(idxBattler)
|
||||
if enemyParty[idxPartyNew].ability == :ILLUSION
|
||||
new_index = pbLastInTeam(idxBattler)
|
||||
idxPartyForName = new_index if new_index >= 0
|
||||
idxPartyForName = new_index if new_index >= 0 && new_index != idxPartyNew
|
||||
end
|
||||
if pbDisplayConfirm(_INTL("{1} is about to send in {2}. Will you switch your Pokémon?",
|
||||
opponent.full_name, enemyParty[idxPartyForName].name))
|
||||
@@ -257,7 +257,7 @@ class PokeBattle_Battle
|
||||
newPkmnName = party[idxParty].name
|
||||
if party[idxParty].ability == :ILLUSION
|
||||
new_index = pbLastInTeam(idxBattler)
|
||||
newPkmnName = party[new_index].name if new_index >= 0
|
||||
newPkmnName = party[new_index].name if new_index >= 0 && new_index != idxParty
|
||||
end
|
||||
if pbOwnedByPlayer?(idxBattler)
|
||||
opposing = @battlers[idxBattler].pbDirectOpposing
|
||||
|
||||
@@ -147,9 +147,7 @@ class PokeBattle_Battle
|
||||
@scene.pbRefreshOne(idxBattler)
|
||||
pbCommonAnimation("MegaEvolution2",battler)
|
||||
megaName = battler.pokemon.megaName
|
||||
if !megaName || megaName==""
|
||||
megaName = _INTL("Mega {1}", battler.pokemon.speciesName)
|
||||
end
|
||||
megaName = _INTL("Mega {1}", battler.pokemon.speciesName) nil_or_empty?(megaName)
|
||||
pbDisplay(_INTL("{1} has Mega Evolved into {2}!",battler.pbThis,megaName))
|
||||
side = battler.idxOwnSide
|
||||
owner = pbGetOwnerIndexFromBattlerIndex(idxBattler)
|
||||
|
||||
@@ -538,7 +538,7 @@ class TargetMenuDisplay < BattleMenuBase
|
||||
@overlay.bitmap.clear
|
||||
textpos = []
|
||||
@buttons.each_with_index do |button,i|
|
||||
next if !button || @texts[i].nil? || @texts[i]==""
|
||||
next if !button || nil_or_empty?(@texts[i])
|
||||
x = button.x-self.x+button.src_rect.width/2
|
||||
y = button.y-self.y+2
|
||||
textpos.push([@texts[i],x,y,2,TEXT_BASE_COLOR,TEXT_SHADOW_COLOR])
|
||||
|
||||
@@ -480,7 +480,7 @@ class PokeBattle_Scene
|
||||
|
||||
# Plays a common animation.
|
||||
def pbCommonAnimation(animName,user=nil,target=nil)
|
||||
return if !animName || animName==""
|
||||
return if nil_or_empty?(animName)
|
||||
target = target[0] if target && target.is_a?(Array)
|
||||
animations = pbLoadBattleAnimations
|
||||
return if !animations
|
||||
|
||||
@@ -946,7 +946,7 @@ ItemHandlers::UseOnPokemon.add(:DNASPLICERS,proc { |item,pkmn,scene|
|
||||
next false
|
||||
end
|
||||
# Fusing
|
||||
if pkmn.fused==nil
|
||||
if pkmn.fused.nil?
|
||||
chosen = scene.pbChoosePokemon(_INTL("Fuse with which Pokémon?"))
|
||||
next false if chosen<0
|
||||
poke2 = $Trainer.party[chosen]
|
||||
@@ -999,7 +999,7 @@ ItemHandlers::UseOnPokemon.add(:NSOLARIZER,proc { |item,pkmn,scene|
|
||||
next false
|
||||
end
|
||||
# Fusing
|
||||
if pkmn.fused==nil
|
||||
if pkmn.fused.nil?
|
||||
chosen = scene.pbChoosePokemon(_INTL("Fuse with which Pokémon?"))
|
||||
next false if chosen<0
|
||||
poke2 = $Trainer.party[chosen]
|
||||
@@ -1048,7 +1048,7 @@ ItemHandlers::UseOnPokemon.add(:NLUNARIZER,proc { |item,pkmn,scene|
|
||||
next false
|
||||
end
|
||||
# Fusing
|
||||
if pkmn.fused==nil
|
||||
if pkmn.fused.nil?
|
||||
chosen = scene.pbChoosePokemon(_INTL("Fuse with which Pokémon?"))
|
||||
next false if chosen<0
|
||||
poke2 = $Trainer.party[chosen]
|
||||
|
||||
@@ -554,7 +554,7 @@ class PokemonSummary_Scene
|
||||
# Write map name Pokémon was received on
|
||||
mapname = pbGetMapNameFromId(@pokemon.obtain_map)
|
||||
mapname = @pokemon.obtain_text if @pokemon.obtain_text && !@pokemon.obtain_text.empty?
|
||||
mapname = _INTL("Faraway place") if !mapname || mapname==""
|
||||
mapname = _INTL("Faraway place") if nil_or_empty?(mapname)
|
||||
memo += sprintf("<c3=F83820,E09890>%s\n",mapname)
|
||||
# Write how Pokémon was obtained
|
||||
mettext = [_INTL("Met at Lv. {1}.",@pokemon.obtain_level),
|
||||
@@ -573,7 +573,7 @@ class PokemonSummary_Scene
|
||||
memo += _INTL("<c3=404040,B0B0B0>{1} {2}, {3}\n",date,month,year)
|
||||
end
|
||||
mapname = pbGetMapNameFromId(@pokemon.hatched_map)
|
||||
mapname = _INTL("Faraway place") if !mapname || mapname==""
|
||||
mapname = _INTL("Faraway place") if nil_or_empty?(mapname)
|
||||
memo += sprintf("<c3=F83820,E09890>%s\n",mapname)
|
||||
memo += _INTL("<c3=404040,B0B0B0>Egg hatched.\n")
|
||||
else
|
||||
|
||||
@@ -248,7 +248,7 @@ end
|
||||
|
||||
def pbGetStorageCreator
|
||||
creator = Settings.storage_creator_name
|
||||
creator = _INTL("Bill") if !creator || creator==""
|
||||
creator = _INTL("Bill") if nil_or_empty?(creator)
|
||||
return creator
|
||||
end
|
||||
|
||||
|
||||
@@ -138,7 +138,7 @@ def pbManageMysteryGifts
|
||||
pbMessageDisplay(msgwindow,_INTL("Searching for online gifts...\\wtnp[0]"))
|
||||
online = pbDownloadToString(MysteryGift::URL)
|
||||
pbDisposeMessageWindow(msgwindow)
|
||||
if online==""
|
||||
if nil_or_empty?(online)
|
||||
pbMessage(_INTL("No online Mystery Gifts found.\\wtnp[20]"))
|
||||
online=[]
|
||||
else
|
||||
@@ -245,7 +245,7 @@ def pbDownloadMysteryGift(trainer)
|
||||
sprites["msgwindow"]=pbCreateMessageWindow
|
||||
pbMessageDisplay(sprites["msgwindow"],_INTL("Searching for a gift.\nPlease wait...\\wtnp[0]"))
|
||||
string = pbDownloadToString(MysteryGift::URL)
|
||||
if string==""
|
||||
if nil_or_empty?(string)
|
||||
pbMessageDisplay(sprites["msgwindow"],_INTL("No new gifts are available."))
|
||||
else
|
||||
online=pbMysteryGiftDecrypt(string)
|
||||
@@ -334,7 +334,7 @@ def pbMysteryGiftEncrypt(gift)
|
||||
end
|
||||
|
||||
def pbMysteryGiftDecrypt(gift)
|
||||
return [] if gift==""
|
||||
return [] if nil_or_empty?(gift)
|
||||
ret = Marshal.restore(Zlib::Inflate.inflate(gift.unpack("m")[0]))
|
||||
if ret
|
||||
ret.each do |gift|
|
||||
|
||||
@@ -80,7 +80,7 @@ class PBPokemon
|
||||
end
|
||||
for i in 1..maxconst
|
||||
val=mod.getName(i)
|
||||
next if !val || val==""
|
||||
next if nil_or_empty?(val)
|
||||
return i if val==str
|
||||
end
|
||||
return 0
|
||||
|
||||
@@ -89,19 +89,19 @@ end
|
||||
|
||||
# Unused
|
||||
def hasConst?(mod,constant)
|
||||
return false if !mod || !constant || constant==""
|
||||
return false if !mod || nil_or_empty?(constant)
|
||||
return mod.const_defined?(constant.to_sym) rescue false
|
||||
end
|
||||
|
||||
# Unused
|
||||
def getConst(mod,constant)
|
||||
return nil if !mod || !constant || constant==""
|
||||
return nil if !mod || nil_or_empty?(constant)
|
||||
return mod.const_get(constant.to_sym) rescue nil
|
||||
end
|
||||
|
||||
# Unused
|
||||
def getID(mod,constant)
|
||||
return nil if !mod || !constant || constant==""
|
||||
return nil if !mod || nil_or_empty?(constant)
|
||||
if constant.is_a?(Symbol) || constant.is_a?(String)
|
||||
if (mod.const_defined?(constant.to_sym) rescue false)
|
||||
return mod.const_get(constant.to_sym) rescue 0
|
||||
|
||||
@@ -120,7 +120,7 @@ def pbAddForeignPokemon(pkmn, level = 1, owner_name = nil, nickname = nil, owner
|
||||
# Set original trainer to a foreign one
|
||||
pkmn.owner = Pokemon::Owner.new_foreign(owner_name || "", owner_gender)
|
||||
# Set nickname
|
||||
pkmn.name = nickname[0, Pokemon::MAX_NAME_SIZE]
|
||||
pkmn.name = nickname[0, Pokemon::MAX_NAME_SIZE] if !nil_or_empty?(nickname)
|
||||
# Recalculate stats
|
||||
pkmn.calc_stats
|
||||
if owner_name
|
||||
|
||||
@@ -68,7 +68,7 @@ end
|
||||
#===============================================================================
|
||||
def pbPlayTrainerIntroME(trainer_type)
|
||||
trainer_type_data = GameData::TrainerType.get(trainer_type)
|
||||
return if !trainer_type_data.intro_ME || trainer_type_data.intro_ME == ""
|
||||
return if nil_or_empty?(trainer_type_data.intro_ME)
|
||||
bgm = pbStringToAudioFile(trainer_type_data.intro_ME)
|
||||
pbMEPlay(bgm)
|
||||
end
|
||||
|
||||
@@ -416,7 +416,7 @@ def pbTrainerTypeEditorNew(default_name)
|
||||
# Choose a name
|
||||
name = pbMessageFreeText(_INTL("Please enter the trainer type's name."),
|
||||
(default_name) ? default_name.gsub(/_+/, " ") : "", false, 30)
|
||||
if name == ""
|
||||
if nil_or_empty?(name)
|
||||
return nil if !default_name
|
||||
name = default_name
|
||||
end
|
||||
@@ -585,7 +585,7 @@ def pbTrainerBattleEditor
|
||||
end
|
||||
next if !tr_type
|
||||
tr_name = pbMessageFreeText(_INTL("Now enter the trainer's name."), "", false, 30)
|
||||
next if tr_name == ""
|
||||
next if nil_or_empty?(tr_name)
|
||||
tr_version = pbGetFreeTrainerParty(tr_type, tr_name)
|
||||
if tr_version < 0
|
||||
pbMessage(_INTL("There is no room to create a trainer of that type and name."))
|
||||
@@ -891,7 +891,7 @@ def pbItemEditorNew(default_name)
|
||||
# Choose a name
|
||||
name = pbMessageFreeText(_INTL("Please enter the item's name."),
|
||||
(default_name) ? default_name.gsub(/_+/, " ") : "", false, 30)
|
||||
if name == ""
|
||||
if nil_or_empty?(name)
|
||||
return if !default_name
|
||||
name = default_name
|
||||
end
|
||||
|
||||
@@ -840,12 +840,12 @@ DebugMenuCommands.register("renameplayer", {
|
||||
"description" => _INTL("Rename the player."),
|
||||
"effect" => proc {
|
||||
trname = pbEnterPlayerName("Your name?", 0, Settings::MAX_PLAYER_NAME_SIZE, $Trainer.name)
|
||||
if trname == "" && pbConfirmMessage(_INTL("Give yourself a default name?"))
|
||||
if nil_or_empty?(trname) && pbConfirmMessage(_INTL("Give yourself a default name?"))
|
||||
trainertype = $Trainer.trainer_type
|
||||
gender = pbGetTrainerTypeGender(trainertype)
|
||||
trname = pbSuggestTrainerName(gender)
|
||||
end
|
||||
if trname == ""
|
||||
if nil_or_empty?(trname)
|
||||
pbMessage(_INTL("The player's name remained {1}.", $Trainer.name))
|
||||
else
|
||||
$Trainer.name = trname
|
||||
@@ -865,11 +865,11 @@ DebugMenuCommands.register("randomid", {
|
||||
})
|
||||
|
||||
#===============================================================================
|
||||
# Information options
|
||||
# Information editors
|
||||
#===============================================================================
|
||||
DebugMenuCommands.register("editorsmenu", {
|
||||
"parent" => "main",
|
||||
"name" => _INTL("Information options..."),
|
||||
"name" => _INTL("Information editors..."),
|
||||
"description" => _INTL("Edit information in the PBS files, terrain tags, battle animations, etc."),
|
||||
"always_show" => true
|
||||
})
|
||||
|
||||
@@ -82,21 +82,21 @@ class SpriteWindow_DebugVariables < Window_DrawableCommand
|
||||
name = $data_system.switches[index+1]
|
||||
codeswitch = (name[/^s\:/])
|
||||
val = (codeswitch) ? (eval($~.post_match) rescue nil) : $game_switches[index+1]
|
||||
if val==nil
|
||||
if val.nil?
|
||||
status = "[-]"
|
||||
colors = 0
|
||||
codeswitch = true
|
||||
elsif val
|
||||
elsif val # true
|
||||
status = "[ON]"
|
||||
colors = 2
|
||||
else
|
||||
else # false
|
||||
status = "[OFF]"
|
||||
colors = 1
|
||||
end
|
||||
else
|
||||
name = $data_system.variables[index+1]
|
||||
status = $game_variables[index+1].to_s
|
||||
status = "\"__\"" if !status || status==""
|
||||
status = "\"__\"" if nil_or_empty?(status)
|
||||
end
|
||||
name = '' if name==nil
|
||||
id_text = sprintf("%04d:",index+1)
|
||||
|
||||
@@ -77,7 +77,7 @@ module Compiler
|
||||
end
|
||||
|
||||
def csvQuote(str,always=false)
|
||||
return "" if !str || str==""
|
||||
return "" if nil_or_empty?(str)
|
||||
if always || str[/[,\"]/] # || str[/^\s/] || str[/\s$/] || str[/^#/]
|
||||
str = str.gsub(/[\"]/,"\\\"")
|
||||
str = "\"#{str}\""
|
||||
@@ -316,7 +316,7 @@ module Compiler
|
||||
def checkEnumField(ret,enumer)
|
||||
if enumer.is_a?(Module)
|
||||
begin
|
||||
if ret=="" || !enumer.const_defined?(ret)
|
||||
if nil_or_empty?(ret) || !enumer.const_defined?(ret)
|
||||
raise _INTL("Undefined value {1} in {2}\r\n{3}",ret,enumer.name,FileLineData.linereport)
|
||||
end
|
||||
rescue NameError
|
||||
@@ -327,7 +327,7 @@ module Compiler
|
||||
if !Kernel.const_defined?(enumer.to_sym) && GameData.const_defined?(enumer.to_sym)
|
||||
enumer = GameData.const_get(enumer.to_sym)
|
||||
begin
|
||||
if ret == "" || !enumer.exists?(ret.to_sym)
|
||||
if nil_or_empty?(ret) || !enumer.exists?(ret.to_sym)
|
||||
raise _INTL("Undefined value {1} in {2}\r\n{3}", ret, enumer.name, FileLineData.linereport)
|
||||
end
|
||||
rescue NameError
|
||||
@@ -337,7 +337,7 @@ module Compiler
|
||||
end
|
||||
enumer = Object.const_get(enumer.to_sym)
|
||||
begin
|
||||
if ret=="" || !enumer.const_defined?(ret)
|
||||
if nil_or_empty?(ret) || !enumer.const_defined?(ret)
|
||||
raise _INTL("Undefined value {1} in {2}\r\n{3}",ret,enumer.name,FileLineData.linereport)
|
||||
end
|
||||
rescue NameError
|
||||
@@ -362,16 +362,16 @@ module Compiler
|
||||
|
||||
def checkEnumFieldOrNil(ret,enumer)
|
||||
if enumer.is_a?(Module)
|
||||
return nil if ret=="" || !(enumer.const_defined?(ret) rescue false)
|
||||
return nil if nil_or_empty?(ret) || !(enumer.const_defined?(ret) rescue false)
|
||||
return enumer.const_get(ret.to_sym)
|
||||
elsif enumer.is_a?(Symbol) || enumer.is_a?(String)
|
||||
if GameData.const_defined?(enumer.to_sym)
|
||||
enumer = GameData.const_get(enumer.to_sym)
|
||||
return nil if ret == "" || !enumer.exists?(ret.to_sym)
|
||||
return nil if nil_or_empty?(re) || !enumer.exists?(ret.to_sym)
|
||||
return ret.to_sym
|
||||
end
|
||||
enumer = Object.const_get(enumer.to_sym)
|
||||
return nil if ret=="" || !(enumer.const_defined?(ret) rescue false)
|
||||
return nil if nil_or_empty?(ret) || !(enumer.const_defined?(ret) rescue false)
|
||||
return enumer.const_get(ret.to_sym)
|
||||
elsif enumer.is_a?(Array)
|
||||
idx = findIndex(enumer) { |item| ret==item }
|
||||
@@ -402,7 +402,7 @@ module Compiler
|
||||
record.push(csvInt!(rec,lineno))
|
||||
when "I" # Optional integer
|
||||
field = csvfield!(rec)
|
||||
if field==""
|
||||
if nil_or_empty?(field)
|
||||
record.push(nil)
|
||||
elsif !field[/^\-?\d+$/]
|
||||
raise _INTL("Field {1} is not an integer\r\n{2}",field,FileLineData.linereport)
|
||||
@@ -413,7 +413,7 @@ module Compiler
|
||||
record.push(csvPosInt!(rec,lineno))
|
||||
when "U" # Optional positive integer or zero
|
||||
field = csvfield!(rec)
|
||||
if field==""
|
||||
if nil_or_empty?(field)
|
||||
record.push(nil)
|
||||
elsif !field[/^\d+$/]
|
||||
raise _INTL("Field '{1}' must be 0 or greater\r\n{2}",field,FileLineData.linereport)
|
||||
@@ -426,7 +426,7 @@ module Compiler
|
||||
record.push(field)
|
||||
when "V" # Optional positive integer
|
||||
field = csvfield!(rec)
|
||||
if field==""
|
||||
if nil_or_empty?(field)
|
||||
record.push(nil)
|
||||
elsif !field[/^\d+$/]
|
||||
raise _INTL("Field '{1}' must be greater than 0\r\n{2}",field,FileLineData.linereport)
|
||||
@@ -443,7 +443,7 @@ module Compiler
|
||||
record.push(field.hex)
|
||||
when "X" # Optional hexadecimal number
|
||||
field = csvfield!(rec)
|
||||
if field==""
|
||||
if nil_or_empty?(field)
|
||||
record.push(nil)
|
||||
elsif !field[/^[A-Fa-f0-9]+$/]
|
||||
raise _INTL("Field '{1}' is not a hexadecimal number\r\n{2}",field,FileLineData.linereport)
|
||||
@@ -454,7 +454,7 @@ module Compiler
|
||||
record.push(csvFloat!(rec,lineno))
|
||||
when "F" # Optional floating point number
|
||||
field = csvfield!(rec)
|
||||
if field==""
|
||||
if nil_or_empty?(field)
|
||||
record.push(nil)
|
||||
elsif !field[/^\-?^\d*\.?\d*$/]
|
||||
raise _INTL("Field {1} is not a floating point number\r\n{2}",field,FileLineData.linereport)
|
||||
@@ -465,7 +465,7 @@ module Compiler
|
||||
record.push(csvBoolean!(rec,lineno))
|
||||
when "B" # Optional Boolean
|
||||
field = csvfield!(rec)
|
||||
if field==""
|
||||
if nil_or_empty?(field)
|
||||
record.push(nil)
|
||||
elsif field[/^1|[Tt][Rr][Uu][Ee]|[Yy][Ee][Ss]|[Tt]|[Yy]$/]
|
||||
record.push(true)
|
||||
@@ -480,7 +480,7 @@ module Compiler
|
||||
record.push(field)
|
||||
when "N" # Optional name
|
||||
field = csvfield!(rec)
|
||||
if field==""
|
||||
if nil_or_empty?(field)
|
||||
record.push(nil)
|
||||
elsif !field[/^(?![0-9])\w+$/]
|
||||
raise _INTL("Field '{1}' must contain only letters, digits, and\r\nunderscores and can't begin with a number.\r\n{2}",field,FileLineData.linereport)
|
||||
@@ -491,12 +491,12 @@ module Compiler
|
||||
record.push(csvfield!(rec))
|
||||
when "S" # Optional string
|
||||
field = csvfield!(rec)
|
||||
record.push((field=="") ? nil : field)
|
||||
record.push((nil_or_empty?(field)) ? nil : field)
|
||||
when "q" # Unformatted text
|
||||
record.push(rec)
|
||||
rec = ""
|
||||
when "Q" # Optional unformatted text
|
||||
if !rec || rec==""
|
||||
if nil_or_empty?(rec)
|
||||
record.push(nil)
|
||||
else
|
||||
record.push(rec)
|
||||
@@ -512,7 +512,7 @@ module Compiler
|
||||
record.push(csvEnumFieldOrInt!(field,schema[2+i-start],"",FileLineData.linereport))
|
||||
when "Y" # Optional enumerable or integer
|
||||
field = csvfield!(rec)
|
||||
if field==""
|
||||
if nil_or_empty?(field)
|
||||
record.push(nil)
|
||||
elsif field[/^\-?\d+$/]
|
||||
record.push(field.to_i)
|
||||
@@ -521,7 +521,7 @@ module Compiler
|
||||
end
|
||||
end
|
||||
end
|
||||
break if repeat && rec==""
|
||||
break if repeat && nil_or_empty?(rec)
|
||||
end while repeat
|
||||
return (schema[1].length==1) ? record[0] : record
|
||||
end
|
||||
|
||||
@@ -398,7 +398,7 @@ module Compiler
|
||||
for key in schema.keys
|
||||
# Skip empty properties, or raise an error if a required property is
|
||||
# empty
|
||||
if contents[key].nil? || contents[key] == ""
|
||||
if nil_or_empty?(contents[key])
|
||||
if ["Name", "InternalName"].include?(key)
|
||||
raise _INTL("The entry {1} is required in PBS/pokemon.txt section {2}.", key, species_number)
|
||||
end
|
||||
@@ -583,7 +583,7 @@ module Compiler
|
||||
# Go through schema hash of compilable data and compile this section
|
||||
for key in schema.keys
|
||||
# Skip empty properties (none are required)
|
||||
if contents[key].nil? || contents[key] == ""
|
||||
if nil_or_empty?(contents[key])
|
||||
contents[key] = nil
|
||||
next
|
||||
end
|
||||
@@ -922,7 +922,7 @@ module Compiler
|
||||
end
|
||||
new_format = true
|
||||
values = $~[1].split(',').collect! { |v| v.strip.to_i }
|
||||
values[1] = 0 if !values[1] || values[1] == ""
|
||||
values[1] = 0 if nil_or_empty?(values[1])
|
||||
map_number = values[0]
|
||||
map_version = values[1]
|
||||
# Add map encounter's data to records
|
||||
|
||||
Reference in New Issue
Block a user