summaryrefslogtreecommitdiffstats
path: root/pokemod/Nature.cpp
diff options
context:
space:
mode:
authorBen Boeckel <MathStuf@gmail.com>2007-07-03 04:20:36 +0000
committerBen Boeckel <MathStuf@gmail.com>2007-07-03 04:20:36 +0000
commit65cc463f1d91fe99acf1c4dd9bce7e0038593022 (patch)
tree95644c3c42a4a23db50dc42722cdeb4489427e14 /pokemod/Nature.cpp
parent9102febc37475af113681eaaee02ecc2ea04b4da (diff)
Fixed Logging, minor fixes, got rid of NatureEffect, and started migration from wxGTK to Qt
git-svn-id: https://pokegen.svn.sourceforge.net/svnroot/pokegen/trunk@22 6ecfd1a5-f3ed-3746-8530-beee90d26b22
Diffstat (limited to 'pokemod/Nature.cpp')
-rw-r--r--pokemod/Nature.cpp216
1 files changed, 74 insertions, 142 deletions
diff --git a/pokemod/Nature.cpp b/pokemod/Nature.cpp
index 519a9e1c..fdc724a5 100644
--- a/pokemod/Nature.cpp
+++ b/pokemod/Nature.cpp
@@ -24,9 +24,11 @@
#include "Nature.h"
PokeGen::PokeMod::Nature::Nature(const Pokemod *par, const unsigned _id) :
- name("")
+ name("")
{
- LogCtor("Nature", _id);
+ LogCtor("Nature", _id);
+ for (unsigned i = 0; i < STH_END_GSC; ++i)
+ stats[i].Set(1, 1, true);
id = _id;
pokemod = par;
}
@@ -52,95 +54,10 @@ void PokeGen::PokeMod::Nature::Validate()
{
LogVarNotSet("Nature", id, "name");
isValid = false;
- }
- std::map<unsigned, unsigned> idChecker;
- std::map<String, unsigned> effectChecker;
- if (GetNatureEffectCount())
- {
- for (std::vector<NatureEffect>::iterator i = effects.begin(); i != effects.end(); ++i)
- {
- LogSubmoduleIterate("Nature", id, "effect", i->GetId(), name);
- if (!i->IsValid())
- isValid = false;
- ++idChecker[i->GetId()];
- ++effectChecker[i->GetStatString()];
- }
- for (std::map<unsigned, unsigned>::const_iterator i = idChecker.begin(); i != idChecker.end(); ++i)
- {
- if (1 < i->second)
- {
- LogDuplicateId("Nature", id, "effect", i->first, name);
- isValid = false;
- }
- }
- for (std::map<String, unsigned>::const_iterator i = effectChecker.begin(); i != effectChecker.end(); ++i)
- {
- if (1 < i->second)
- {
- LogDuplicateSubmodule("Nature", id, "effect", i->first, name);
- isValid = false;
- }
- }
- }
- else
- {
- LogSubmoduleEmpty("Nature", id, "effects", name);
- isValid = false;
- }
+ }
LogValidateOver("Nature", id, isValid, name);
}
-#ifdef PG_DEBUG_WINDOW
-void PokeGen::PokeMod::Nature::Validate(const wxListBox &output)
-{
- LogValidateStart("Nature", id, name);
- if (name == "")
- {
- LogVarNotSet("Nature", id, "name");
- output.Append(ConsoleLogVarNotSet("Nature", id, "name"));
- isValid = false;
- }
- std::map<unsigned, unsigned> idChecker;
- std::map<String, unsigned> effectChecker;
- if (GetNatureEffectCount())
- {
- for (std::vector<NatureEffect>::iterator i = effects.begin(); i != effects.end(); ++i)
- {
- LogSubmoduleIterate("Nature", id, "effect", i->GetId(), name);
- if (!i->IsValid())
- isValid = false;
- ++idChecker[i->GetId()];
- ++effectChecker[i->GetEffectString()];
- }
- for (std::map<unsigned, unsigned>::const_iterator i = idChecker.begin(); i != idChecker.end(); ++i)
- {
- if (1 < i->second)
- {
- LogDuplicateId("Nature", id, "effect", i->first, name);
- output.Append(ConsoleLogDuplicateId("Nature", id, "effect", i->first, name));
- isValid = false;
- }
- }
- for (std::map<String, unsigned>::const_iterator i = effectChecker.begin(); i != effectChecker.end(); ++i)
- {
- if (1 < i->second)
- {
- LogDuplicateSubmodule("Nature", id, "effect", i->first, name);
- output.Append(ConsoleLogDuplicateSubmodule("Nature", id, "effect", i->first, name));
- isValid = false;
- }
- }
- }
- else
- {
- LogSubmoduleEmpty("Nature", id, "effects", name);
- output.Append(ConsoleLogSubmoduleEmpty("Nature", id, "effects", name));
- isValid = false;
- }
- LogValidateOver("Nature", id, isValid, name);
-}
-#endif
-
void PokeGen::PokeMod::Nature::ImportIni(Ini &ini, const unsigned _id)
{
LogImportStart("Nature");
@@ -152,9 +69,16 @@ void PokeGen::PokeMod::Nature::ImportIni(Ini &ini, const unsigned _id)
LogIdNotFound("Nature");
}
else
- id = _id;
+ id = _id;
+ unsigned i;
+ unsigned j;
ini.GetValue("name", name);
- effects.clear();
+ for (unsigned k = 0; k < STH_END_GSC; ++k)
+ {
+ ini.GetValue(String("stat-%u-n", k), i, 1);
+ ini.GetValue(String("stat-%u-n", k), j, 1);
+ stats[k].Set(1, 1, true);
+ }
LogImportOver("Nature");
}
@@ -162,10 +86,13 @@ void PokeGen::PokeMod::Nature::ExportIni(std::ofstream &fout) const
{
LogExportStart("Nature", id, name);
Ini exNature("nature");
- exNature.AddField("name", name);
- exNature.Export(fout);
- for (std::vector<NatureEffect>::const_iterator i = effects.begin(); i != effects.end(); ++i)
- i->ExportIni(fout, name);
+ exNature.AddField("name", name);
+ for (unsigned i = 0; i < STH_END_GSC; ++i)
+ {
+ exNature.AddField(String("stat-%u-n", i), stats[i].GetNum());
+ exNature.AddField(String("stat-%u-d", i), stats[i].GetNum());
+ }
+ exNature.Export(fout);
LogExportOver("Nature", id, name);
}
@@ -173,57 +100,62 @@ void PokeGen::PokeMod::Nature::SetName(const String &n)
{
LogSetVar("Nature", id, "name", n);
name = n;
-}
-
+}
+
+void PokeGen::PokeMod::Nature::SetStat(const unsigned s, const Frac &m)
+{
+ LogSetVar("Nature", id, String("stat[%u]", s), m.GetNum(), m.GetDenom(), name);
+ if (s < (pokemod->IsSpecialSplit() ? STH_END_GSC : STH_END_RBY))
+ stats[s] = m;
+}
+
+void PokeGen::PokeMod::Nature::SetStat(const unsigned s, const unsigned n, const unsigned d)
+{
+ LogSetVar("Nature", id, String("stat[%u]", s), n, d, name);
+ if (s < (pokemod->IsSpecialSplit() ? STH_END_GSC : STH_END_RBY))
+ stats[s].Set(n, d);
+}
+
+void PokeGen::PokeMod::Nature::SetStatNum(const unsigned s, const unsigned n)
+{
+ LogSetVar("Nature", id, String("stat[%u] numerator", s), n, name);
+ if (s < (pokemod->IsSpecialSplit() ? STH_END_GSC : STH_END_RBY))
+ stats[s].SetNum(n);
+}
+
+void PokeGen::PokeMod::Nature::SetStatDenom(const unsigned s, const unsigned d)
+{
+ LogSetVar("Nature", id, String("stat[%u] denominator", s), d, name);
+ if (s < (pokemod->IsSpecialSplit() ? STH_END_GSC : STH_END_RBY))
+ stats[s].SetDenom(d);
+}
+
PokeGen::PokeMod::String PokeGen::PokeMod::Nature::GetName() const
{
LogFetchVar("Nature", id, "name", name);
return name;
}
-const PokeGen::PokeMod::NatureEffect *PokeGen::PokeMod::Nature::GetNatureEffect(const unsigned _id) const
-{
- LogSubmoduleFetch("Nature", id, "effect", _id, name);
- for (unsigned i = 0; i < GetNatureEffectCount(); ++i)
- {
- if (effects[i].GetId() == _id)
- return &effects[i];
- }
- LogSubmoduleFetchFail("Nature", id, "effect", _id, name);
- return NULL;
-}
-
-unsigned PokeGen::PokeMod::Nature::GetNatureEffectCount() const
-{
- LogSubmoduleCount("Nature", id, "effects", name);
- return effects.size();
-}
-
-void PokeGen::PokeMod::Nature::NewNatureEffect(Ini *const ini)
-{
- unsigned i = 0;
- for (; i < GetNatureEffectCount(); ++i)
- {
- if (!GetNatureEffect(i))
- break;
- }
- NatureEffect newNatureEffect(pokemod, i);
- if (ini)
- newNatureEffect.ImportIni(*ini);
- LogSubmoduleNew("Nature", id, "effect", i, name);
- effects.push_back(newNatureEffect);
-}
-
-void PokeGen::PokeMod::Nature::DeleteNatureEffect(const unsigned _id)
-{
- LogSubmoduleRemoveStart("Nature", id, "effect", _id, name);
- for (std::vector<NatureEffect>::iterator i = effects.begin(); i != effects.end(); ++i)
- {
- if (i->GetId() == _id)
- {
- LogSubmoduleRemoved("Nature", id, "effect", _id, name);
- effects.erase(i);
- }
- }
- LogSubmoduleRemoveFail("Nature", id, "effect", _id, name);
-}
+PokeGen::PokeMod::Frac PokeGen::PokeMod::Nature::GetStat(const unsigned s) const
+{
+ LogFetchVar("Nature", id, String("stat[%u]", s), 0, name);
+ if (s < (pokemod->IsSpecialSplit() ? STH_END_GSC : STH_END_RBY))
+ return stats[s];
+ return Frac(1, 1, true);
+}
+
+unsigned PokeGen::PokeMod::Nature::GetStatNum(const unsigned s) const
+{
+ LogFetchVar("Nature", id, String("stat[%u] numerator", s), 0, name);
+ if (s < (pokemod->IsSpecialSplit() ? STH_END_GSC : STH_END_RBY))
+ return stats[s].GetNum();
+ return 1;
+}
+
+unsigned PokeGen::PokeMod::Nature::GetStatDenom(const unsigned s) const
+{
+ LogFetchVar("Nature", id, String("stat[%u] denominator", s), 0, name);
+ if (s < (pokemod->IsSpecialSplit() ? STH_END_GSC : STH_END_RBY))
+ return stats[s].GetDenom();
+ return 1;
+}