diff options
Diffstat (limited to 'pokemod/MapEffect.cpp')
| -rw-r--r-- | pokemod/MapEffect.cpp | 234 |
1 files changed, 222 insertions, 12 deletions
diff --git a/pokemod/MapEffect.cpp b/pokemod/MapEffect.cpp index 2735fd78..bcafce8d 100644 --- a/pokemod/MapEffect.cpp +++ b/pokemod/MapEffect.cpp @@ -23,9 +23,7 @@ #include "MapEffect.h"
-extern PokeGen::PokeMod::Pokemod curPokeMod;
-
-PokeGen::PokeMod::MapEffect::MapEffect(const unsigned _id) :
+PokeGen::PokeMod::MapEffect::MapEffect(const Pokemod *par, const unsigned _id) :
name(""),
coordinate(0, 0),
existFlag(0, 0),
@@ -35,15 +33,18 @@ PokeGen::PokeMod::MapEffect::MapEffect(const unsigned _id) : val2(UINT_MAX),
direction(UINT_MAX),
isTransparent(false),
+ canMove(false),
dialog(UINT_MAX)
{
LogCtor("MapEffect", _id);
id = _id;
+ pokemod = par;
}
-PokeGen::PokeMod::MapEffect::MapEffect(Ini &ini, const unsigned _id)
+PokeGen::PokeMod::MapEffect::MapEffect(const Pokemod *par, Ini &ini, const unsigned _id)
{
LogCtorIni("MapEffect", _id);
+ pokemod = par;
ImportIni(ini, _id);
if (id == UINT_MAX)
LogIdError("MapEffect");
@@ -57,15 +58,148 @@ PokeGen::PokeMod::MapEffect::~MapEffect() void PokeGen::PokeMod::MapEffect::Validate()
{
LogValidateStart("MapEffect", id, name);
- // TODO (Validation#1#): MapEffect validation
-# warning "MapEffect Validation"
+ if (name == "")
+ {
+ LogVarNotSet("MapEffect", id, "name");
+ isValid = false;
+ }
+ if (FV_END <= existFlag.GetStatus())
+ {
+ LogVarNotValid("MapEffect", id, "existFlag value", name);
+ isValid = false;
+ }
+ if (!skin.DoesExist())
+ {
+ if (skin == "")
+ LogVarNotSet("MapEffect", id, "skin", name);
+ else
+ LogVarNotValid("MapEffect", id, "skin", name);
+ isValid = false;
+ }
+ if (effect < MAPE_END)
+ {
+ switch (effect)
+ {
+ case MAPE_ITEM:
+ if (!pokemod->GetItem(val2))
+ {
+ LogVarNotValid("MapEffect", id, "val2", name);
+ isValid = false;
+ }
+ break;
+ case MAPE_PC:
+ if (PCT_END <= val2)
+ {
+ LogVarNotValid("MapEffect", id, "val2", name);
+ isValid = false;
+ }
+ break;
+ case MAPE_STRENGTH_BLOCK:
+ case MAPE_BUTTON:
+ if (FV_END <= val2)
+ {
+ LogVarNotValid("MapEffect", id, "val2", name);
+ isValid = false;
+ }
+ }
+ }
+ else
+ {
+ LogVarNotValid("MapEffect", id, "effect", name);
+ isValid = false;
+ }
+ if (DIR_END <= direction)
+ {
+ LogVarNotValid("MapEffect", id, "direction", name);
+ isValid = false;
+ }
+ if (!pokemod->GetDialog(dialog))
+ {
+ LogVarNotValid("MapEffect", id, "dialog", name);
+ isValid = false;
+ }
LogValidateOver("MapEffect", id, isValid, name);
}
#ifdef PG_DEBUG_WINDOW
void PokeGen::PokeMod::MapEffect::Validate(const wxListBox &output)
{
-
+ LogValidateStart("MapEffect", id, name);
+ if (name == "")
+ {
+ LogVarNotSet("MapEffect", id, "name");
+ output.Append(ConsoleLogVarNotSet("MapEffect", id, "name"));
+ isValid = false;
+ }
+ if (FV_END <= existFlag.GetStatus())
+ {
+ LogVarNotValid("MapEffect", id, "existFlag value", name);
+ output.Append(ConsoleLogVarNotValid("MapEffect", id, "existFlag value", name));
+ isValid = false;
+ }
+ if (!skin.DoesExist())
+ {
+ if (skin == "")
+ {
+ LogVarNotSet("MapEffect", id, "skin", name);
+ output.Append(ConsoleLogVarNotSet("MapEffect", id, "skin", name));
+ }
+ else
+ {
+ LogVarNotValid("MapEffect", id, "skin", name);
+ output.Append(ConsoleLogVarNotValid("MapEffect", id, "skin", name));
+ }
+ isValid = false;
+ }
+ if (MAPE_END <= effect)
+ {
+ LogVarNotValid("MapEffect", id, "effect", name);
+ output.Append(ConsoleLogVarNotValid("MapEffect", id, "effect", name));
+ isValid = false;
+ }
+ else
+ {
+ switch (effect)
+ {
+ case MAPE_ITEM:
+ if (!pokemod->GetItem(val2))
+ {
+ LogVarNotValid("MapEffect", id, "val2", name);
+ output.Append(ConsoleLogVarNotValid("MapEffect", id, "val2", name));
+ isValid = false;
+ }
+ break;
+ case MAPE_PC:
+ if (PCT_END <= val2)
+ {
+ LogVarNotValid("MapEffect", id, "val2", name);
+ output.Append(ConsoleLogVarNotValid("MapEffect", id, "val2", name));
+ isValid = false;
+ }
+ break;
+ case MAPE_STRENGTH_BLOCK:
+ case MAPE_BUTTON:
+ if (FV_END <= val2)
+ {
+ LogVarNotValid("MapEffect", id, "val2", name);
+ output.Append(ConsoleLogVarNotValid("MapEffect", id, "val2", name));
+ isValid = false;
+ }
+ }
+ }
+ if (DIR_END <= direction)
+ {
+ LogVarNotValid("MapEffect", id, "direction", name);
+ output.Append(ConsoleLogVarNotValid("MapEffect", id, "direction", name));
+ isValid = false;
+ }
+ if (!pokemod->GetDialog(dialog))
+ {
+ LogVarNotValid("MapEffect", id, "dialog", name);
+ output.Append(ConsoleLogVarNotValid("MapEffect", id, "dialog", name));
+ isValid = false;
+ }
+ LogValidateOver("MapEffect", id, isValid, name);
}
#endif
@@ -94,7 +228,8 @@ void PokeGen::PokeMod::MapEffect::ImportIni(Ini &ini, const unsigned _id) ini.GetValue("val1", val1);
ini.GetValue("val2", val2);
ini.GetValue("direction", direction);
- ini.GetValue("isTransparetn", isTransparent);
+ ini.GetValue("isTransparent", isTransparent);
+ ini.GetValue("canMove", canMove);
ini.GetValue("dialog", dialog);
LogImportOver("MapEffect", id, name);
}
@@ -115,6 +250,7 @@ void PokeGen::PokeMod::MapEffect::ExportIni(std::ofstream &fout, const String &m exMapEffect.AddField("val2", val2);
exMapEffect.AddField("direction", direction);
exMapEffect.AddField("isTransparent", isTransparent);
+ exMapEffect.AddField("canMove", canMove);
exMapEffect.AddField("dialog", dialog);
exMapEffect.Export(fout);
LogExportOver("MapEffect", id, name);
@@ -202,12 +338,22 @@ void PokeGen::PokeMod::MapEffect::SetEffect(const String &e) SetEffect(FindIn(MAPE_END, e, MapEffectStr));
}
-// TODO (Ben#1#): effect values
void PokeGen::PokeMod::MapEffect::SetVal1(const unsigned v1)
{
LogSetVar("MapEffect", id, "val1", v1, name);
switch (effect)
{
+ case MAPE_ITEM:
+ case MAPE_PC:
+ case MAPE_ROCK_SMASH:
+ case MAPE_SLOT_MACHINE:
+ case MAPE_CARD_FLIP_GAME:
+ LogNoUse("MapEffect", id, "val1", v1, "effect", MapEffectStr[effect]);
+ break;
+ case MAPE_STRENGTH_BLOCK:
+ case MAPE_BUTTON:
+ val1 = v1;
+ break;
default:
LogNotSet("MapEffect", id, "val1", v1, "effect");
}
@@ -218,6 +364,30 @@ void PokeGen::PokeMod::MapEffect::SetVal2(const unsigned v2) LogSetVar("MapEffect", id, "val2", v2, name);
switch (effect)
{
+ case MAPE_ITEM:
+ if (pokemod->GetItem(v2))
+ val2 = v2;
+ else
+ LogOutOfRange("MapEffect", id, "val2", v2, "effect", "Item");
+ break;
+ case MAPE_PC:
+ if (v2 < PCT_END)
+ val2 = v2;
+ else
+ LogOutOfRange("MapEffect", id, "val2", v2, "effect", "PC");
+ break;
+ case MAPE_STRENGTH_BLOCK:
+ case MAPE_BUTTON:
+ if (v2 < FV_END)
+ val2 = v2;
+ else
+ LogOutOfRange("MapEffect", id, "val2", v2, "effect", MapEffectStr[effect]);
+ break;
+ case MAPE_ROCK_SMASH:
+ case MAPE_SLOT_MACHINE:
+ case MAPE_CARD_FLIP_GAME:
+ LogNoUse("MapEffect", id, "val2", v2, "effect", MapEffectStr[effect]);
+ break;
default:
LogNotSet("MapEffect", id, "val2", v2, "effect");
}
@@ -227,6 +397,22 @@ void PokeGen::PokeMod::MapEffect::SetVal2(const String &v2) {
switch (effect)
{
+ case MAPE_ITEM:
+ if (const Item *i = pokemod->GetItem(v2))
+ SetVal2(i->GetId());
+ break;
+ case MAPE_PC:
+ SetVal2(FindIn(PCT_END, v2, PCTypeStr));
+ break;
+ case MAPE_STRENGTH_BLOCK:
+ case MAPE_BUTTON:
+ SetVal2(FindIn(FV_END, v2, FlagValueStr));
+ break;
+ case MAPE_ROCK_SMASH:
+ case MAPE_SLOT_MACHINE:
+ case MAPE_CARD_FLIP_GAME:
+ LogNoUse("MapEffect", id, "val2", v2, "effect", MapEffectStr[effect]);
+ break;
default:
LogNotSet("MapEffect", id, "val2", v2, "effect");
}
@@ -250,10 +436,16 @@ void PokeGen::PokeMod::MapEffect::SetIsTransparent(const bool i) isTransparent = i;
}
+void PokeGen::PokeMod::MapEffect::SetCanMove(const bool c)
+{
+ LogSetVar("MapEffect", id, "canMove", c, name);
+ canMove = c;
+}
+
void PokeGen::PokeMod::MapEffect::SetDialog(const unsigned d)
{
LogSetVar("MapEffect", id, "dialog", d, name);
- if (curPokeMod.GetDialog(d))
+ if (pokemod->GetDialog(d))
dialog = d;
}
@@ -343,7 +535,19 @@ PokeGen::PokeMod::String PokeGen::PokeMod::MapEffect::GetVal2String() const String ret = "";
switch (effect)
{
- // TODO (Ben#1#): Effect code
+ case MAPE_ITEM:
+ if (const Item *i = pokemod->GetItem(val2))
+ ret = i->GetName();
+ break;
+ case MAPE_PC:
+ if (val2 <= PCT_END)
+ ret = PCTypeStr[val2];
+ break;
+ case MAPE_STRENGTH_BLOCK:
+ case MAPE_BUTTON:
+ if (val2 <= FV_END)
+ ret = FlagValueStr[val2];
+ break;
}
return ret;
}
@@ -368,6 +572,12 @@ bool PokeGen::PokeMod::MapEffect::GetIsTransparent() const return isTransparent;
}
+bool PokeGen::PokeMod::MapEffect::GetCanMove() const
+{
+ LogFetchVar("MapEffect", id, "canMove", canMove, name);
+ return canMove;
+}
+
unsigned PokeGen::PokeMod::MapEffect::GetDialog() const
{
LogFetchVar("MapEffect", id, "dialog", dialog, name);
@@ -377,7 +587,7 @@ unsigned PokeGen::PokeMod::MapEffect::GetDialog() const PokeGen::PokeMod::String PokeGen::PokeMod::MapEffect::GetDialogString() const
{
LogFetchVar("MapEffect", id, "dialog string", dialog, name);
- if (const Dialog *d = curPokeMod.GetDialog(dialog))
+ if (const Dialog *d = pokemod->GetDialog(dialog))
return d->GetDialog();
return "";
}
|
