diff options
| author | Ben Boeckel <MathStuf@gmail.com> | 2008-03-31 01:17:59 +0000 |
|---|---|---|
| committer | Ben Boeckel <MathStuf@gmail.com> | 2008-03-31 01:17:59 +0000 |
| commit | 9a65bc6bb7c8da1dfa5b101579e52845c75848ef (patch) | |
| tree | 258900f882a6998ac6fa525bd247e302028a8911 /pokemod/MapEffect.cpp | |
| parent | 8e1ec2aec50999bae30625303f2c96e5b3b7f318 (diff) | |
| download | sigen-9a65bc6bb7c8da1dfa5b101579e52845c75848ef.tar.gz sigen-9a65bc6bb7c8da1dfa5b101579e52845c75848ef.tar.xz sigen-9a65bc6bb7c8da1dfa5b101579e52845c75848ef.zip | |
[FIX] Member variables now use m_ prefix
[FIX] Lots of minor fixes
git-svn-id: https://pokegen.svn.sourceforge.net/svnroot/pokegen/trunk@95 6ecfd1a5-f3ed-3746-8530-beee90d26b22
Diffstat (limited to 'pokemod/MapEffect.cpp')
| -rw-r--r-- | pokemod/MapEffect.cpp | 345 |
1 files changed, 161 insertions, 184 deletions
diff --git a/pokemod/MapEffect.cpp b/pokemod/MapEffect.cpp index 484e304f..f18c54e5 100644 --- a/pokemod/MapEffect.cpp +++ b/pokemod/MapEffect.cpp @@ -1,343 +1,320 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: pokemod/MapEffect.cpp -// Purpose: Define an effect for a map -// Author: Ben Boeckel -// Modified by: Ben Boeckel -// Created: Fri June 1 2007 20:23:15 -// Copyright: ©2007-2008 Ben Boeckel and Nerdy Productions -// Licence: -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License along -// with this program. If not, see <http://www.gnu.org/licenses/>. -///////////////////////////////////////////////////////////////////////////// - +/* + * Copyright 2007-2008 Ben Boeckel <MathStuf@gmail.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +// Pokemod includes #include "Pokemod.h" #include "Dialog.h" + +// Header include #include "MapEffect.h" const QStringList MapEffect::MapEffectStr = QStringList() << "Item" << "PC" << "Strength Block" << "Button" << "Slot Machine" << "Card Flip Game"; const QStringList MapEffect::PCTypeStr = QStringList() << "Item" << "Pokémon" << "PokéDex" << "Hall of Fame" << "All"; -MapEffect::MapEffect(const Pokemod* par, const int _id) : - Object("MapEffect", par, _id), - name(""), - coordinate(0, 0), - existFlag(0, 0), - skin(""), - effect(-1), - val1(-1), - val2(-1), - direction(-1), - isGhost(false), - canMove(false), - dialog(-1) +MapEffect::MapEffect(const Pokemod* pokemod, const int id) : + Object("MapEffect", pokemod, id), + m_name(""), + m_coordinate(0, 0), + m_existFlag(0, 0), + m_skin(""), + m_effect(INT_MAX), + m_value1(INT_MAX), + m_value2(INT_MAX), + m_direction(INT_MAX), + m_isGhost(false), + m_canMove(false), + m_dialog(INT_MAX) { } -MapEffect::MapEffect(const Pokemod* par, const MapEffect& e, const int _id) : - Object("MapEffect", par, _id) +MapEffect::MapEffect(const Pokemod* pokemod, const MapEffect& effect, const int id) : + Object("MapEffect", pokemod, id) { - *this = e; + *this = effect; } -MapEffect::MapEffect(const Pokemod* par, const QString& fname, const int _id) : - Object("MapEffect", par, _id) +MapEffect::MapEffect(const Pokemod* pokemod, const QString& fileName, const int id) : + Object("MapEffect", pokemod, id) { - load(fname, _id); + load(fileName, id); } bool MapEffect::validate() const { bool valid = true; - pokemod->validationMsg(QString("------Effect \"%1\" with id %2---").arg(name).arg(id), Pokemod::V_Msg); - if (name == "") + pokemod()->validationMsg(QString("------Effect \"%1\" with id %2---").arg(m_name).arg(id()), Pokemod::V_Msg); + if (m_name == "") { - pokemod->validationMsg("Name is not defined"); + pokemod()->validationMsg("Name is not defined"); valid = false; } - if (Flag::End <= existFlag.getStatus()) + if (Flag::End <= m_existFlag.status()) { - pokemod->validationMsg("Invalid existence flag status"); + pokemod()->validationMsg("Invalid existence flag status"); valid = false; } - if (!QFile::exists(getSkin())) + if (!QFile::exists(skin())) { - pokemod->validationMsg(QString("Skin not found")); + pokemod()->validationMsg(QString("Skin not found")); valid = false; } - if (effect < E_End) + if (m_effect < E_End) { bool ok = true; - switch (effect) + switch (m_effect) { case E_Item: - if (pokemod->getItemIndex(val2) == -1) + if (pokemod()->itemIndex(m_value2) == INT_MAX) ok = false; break; case E_PC: - if (PC_End <= val2) + if (PC_End <= m_value2) ok = false; break; case E_StrengthBlock: case E_Button: - if (Flag::End <= val2) + if (Flag::End <= m_value2) ok = false; break; } if (!ok) { - pokemod->validationMsg("Invalid val2"); + pokemod()->validationMsg("Invalid val2"); valid = false; } } else { - pokemod->validationMsg("Invalid effect"); + pokemod()->validationMsg("Invalid effect"); valid = false; } - if (Pokemod::D_End_None <= direction) + if (Pokemod::D_End_None <= m_direction) { - pokemod->validationMsg("Invalid driection"); + pokemod()->validationMsg("Invalid driection"); valid = false; } - if (pokemod->getDialogIndex(dialog) == -1) + if (pokemod()->dialogIndex(m_dialog) == INT_MAX) { - pokemod->validationMsg("Invalid dialog"); + pokemod()->validationMsg("Invalid dialog"); valid = false; } return valid; } -void MapEffect::load(const QString& fname, const int _id) throw(Exception) +void MapEffect::load(const QString& fileName, int id) throw(Exception) { - Ini ini(fname); - if (_id == -1) + Ini ini(fileName); + if (id == INT_MAX) ini.getValue("id", id); - else - id = _id; + setId(id); int i; int j; - ini.getValue("name", name); + ini.getValue("name", m_name); ini.getValue("coordinate-x", i, 0); ini.getValue("coordinate-y", j, 0); - coordinate.set(i, j); + m_coordinate.set(i, j); ini.getValue("existFlag-f", i, 0); ini.getValue("existFlag-s", j, 0); - existFlag.set(i, j); - ini.getValue("skin", skin); - ini.getValue("effect", effect); - ini.getValue("val1", val1); - ini.getValue("val2", val2); - ini.getValue("direction", direction); - ini.getValue("isGhost", isGhost); - ini.getValue("canMove", canMove); - ini.getValue("dialog", dialog); + m_existFlag.set(i, j); + ini.getValue("skin", m_skin); + ini.getValue("effect", m_effect); + ini.getValue("val1", m_value1); + ini.getValue("val2", m_value2); + ini.getValue("direction", m_direction); + ini.getValue("isGhost", m_isGhost); + ini.getValue("canMove", m_canMove); + ini.getValue("dialog", m_dialog); } void MapEffect::save(const QString& map) const throw(Exception) { Ini ini; - ini.addField("id", id); - ini.addField("name", name); - ini.addField("coordinate-x", coordinate.getX()); - ini.addField("coordinate-y", coordinate.getY()); - ini.addField("existFlag-f", existFlag.getFlag()); - ini.addField("existFlag-s", existFlag.getStatus()); - ini.addField("skin", skin); - ini.addField("effect", effect); - ini.addField("val1", val1); - ini.addField("val2", val2); - ini.addField("direction", direction); - ini.addField("isGhost", isGhost); - ini.addField("canMove", canMove); - ini.addField("dialog", dialog); - ini.save(QString("%1/map/%2/effect/%3.pini").arg(pokemod->getPath()).arg(map).arg(name)); + ini.addField("id", id()); + ini.addField("name", m_name); + ini.addField("coordinate-x", m_coordinate.x()); + ini.addField("coordinate-y", m_coordinate.y()); + ini.addField("existFlag-f", m_existFlag.flag()); + ini.addField("existFlag-s", m_existFlag.status()); + ini.addField("skin", m_skin); + ini.addField("effect", m_effect); + ini.addField("val1", m_value1); + ini.addField("val2", m_value2); + ini.addField("direction", m_direction); + ini.addField("isGhost", m_isGhost); + ini.addField("canMove", m_canMove); + ini.addField("dialog", m_dialog); + ini.save(QString("%1/map/%2/effect/%3.pini").arg(pokemod()->path()).arg(map).arg(m_name)); } -void MapEffect::setName(const QString& n) +void MapEffect::setName(const QString& name) { - name = n; + m_name = name; } void MapEffect::setCoordinate(const int x, const int y) { - coordinate.set(x, y); + m_coordinate.set(x, y); } -void MapEffect::setCoordinateX(const int x) +void MapEffect::setExistFlag(const int flag, const int status) { - coordinate.setX(x); + m_existFlag.set(flag, status); } -void MapEffect::setCoordinateY(const int y) +void MapEffect::setSkin(const QString& skin) throw(Exception) { - coordinate.setY(y); + if (!QFile::exists(QString("%1/image/skin/%2.png").arg(pokemod()->path()).arg(skin))) + throw(Exception(className(), "skin does not exist")); + m_skin = skin; } -void MapEffect::setExistFlag(const int f, const int s) +void MapEffect::setEffect(const int effect) throw(BoundsException) { - existFlag.set(f, s); + if (E_End <= effect) + throw(BoundsException(className(), "effect")); + m_effect = effect; + m_value1 = INT_MAX; + m_value2 = INT_MAX; } -void MapEffect::setExistFlagFlag(const int f) +void MapEffect::setValue1(const int value1) throw(UnusedException) { - existFlag.setFlag(f); + if ((m_effect != E_StrengthBlock) && (m_effect != E_Button)) + throw(UnusedException(className(), "val1")); + m_value1 = value1; } -void MapEffect::setExistFlagStatus(const int s) +void MapEffect::setValue2(const int value2) throw(Exception) { - existFlag.setStatus(s); -} - -void MapEffect::setSkin(const QString& s) throw(Exception) -{ - if (!QFile::exists(QString("%1/image/skin/%2.png").arg(pokemod->getPath()).arg(s))) - throw(Exception(className, "skin does not exist")); - skin = s; -} - -void MapEffect::setEffect(const int e) throw(BoundsException) -{ - if (E_End <= e) - throw(BoundsException(className, "effect")); - effect = e; - val1 = -1; - val2 = -1; -} - -void MapEffect::setVal1(const int v1) throw(UnusedException) -{ - if ((effect != E_StrengthBlock) && (effect != E_Button)) - throw(UnusedException(className, "val1")); - val1 = v1; -} - -void MapEffect::setVal2(const int v2) throw(Exception) -{ - switch (effect) + switch (m_effect) { case E_Item: - if (pokemod->getItemIndex(val2) == -1) - throw(BoundsException(className, "val2")); + if (pokemod()->itemIndex(value2) == INT_MAX) + throw(BoundsException(className(), "val2")); break; case E_PC: - if (PC_End <= val2) - throw(BoundsException(className, "val2")); + if (PC_End <= value2) + throw(BoundsException(className(), "val2")); break; case E_StrengthBlock: case E_Button: - if (Flag::End <= val2) - throw(BoundsException(className, "val2")); + if (Flag::End <= value2) + throw(BoundsException(className(), "val2")); break; default: - throw(UnusedException(className, "val2")); + throw(UnusedException(className(), "val2")); break; } - val2 = v2; + m_value2 = value2; } -void MapEffect::setDirection(const int d) throw(BoundsException) +void MapEffect::setDirection(const int direction) throw(BoundsException) { - if (Pokemod::D_End_None <= d) - throw(BoundsException(className, "direction")); - direction = d; + if (Pokemod::D_End_None <= direction) + throw(BoundsException(className(), "direction")); + m_direction = direction; } -void MapEffect::setIsGhost(const bool i) +void MapEffect::setIsGhost(const bool isGhost) { - isGhost = i; + m_isGhost = isGhost; } -void MapEffect::setCanMove(const bool c) +void MapEffect::setCanMove(const bool canMove) { - canMove = c; + m_canMove = canMove; } -void MapEffect::setDialog(const int d) throw(BoundsException) +void MapEffect::setDialog(const int dialog) throw(BoundsException) { - if (pokemod->getDialogIndex(d) == -1) - throw(BoundsException(className, "dialog")); - dialog = d; + if (pokemod()->dialogIndex(dialog) == INT_MAX) + throw(BoundsException(className(), "dialog")); + m_dialog = dialog; } -QString MapEffect::getName() const +QString MapEffect::name() const { - return name; + return m_name; } -Point MapEffect::getCoordinate() const +Point MapEffect::coordinate() const { - return coordinate; + return m_coordinate; } -Flag MapEffect::getExistFlag() const +Flag MapEffect::existFlag() const { - return existFlag; + return m_existFlag; } -QString MapEffect::getSkin() const +QString MapEffect::skin() const { - return QString("%1/image/skin/%2.png").arg(pokemod->getPath()).arg(skin); + return QString("%1/image/skin/%2.png").arg(pokemod()->path()).arg(m_skin); } -int MapEffect::getEffect() const +int MapEffect::effect() const { - return effect; + return m_effect; } -int MapEffect::getVal1() const +int MapEffect::value1() const { - return val1; + return m_value1; } -int MapEffect::getVal2() const +int MapEffect::value2() const { - return val2; + return m_value2; } -int MapEffect::getDirection() const +int MapEffect::direction() const { - return direction; + return m_direction; } -bool MapEffect::getIsGhost() const +bool MapEffect::isGhost() const { - return isGhost; + return m_isGhost; } -bool MapEffect::getCanMove() const +bool MapEffect::canMove() const { - return canMove; + return m_canMove; } -int MapEffect::getDialog() const +int MapEffect::dialog() const { - return dialog; + return m_dialog; } MapEffect& MapEffect::operator=(const MapEffect& rhs) { if (this == &rhs) return *this; - name = rhs.name; - coordinate = rhs.coordinate; - existFlag = rhs.existFlag; - skin = rhs.skin; - effect = rhs.effect; - val1 = rhs.val1; - val2 = rhs.val2; - direction = rhs.direction; - isGhost = rhs.isGhost; - canMove = rhs.canMove; - dialog = rhs.dialog; + m_name = rhs.m_name; + m_coordinate = rhs.m_coordinate; + m_existFlag = rhs.m_existFlag; + m_skin = rhs.m_skin; + m_effect = rhs.m_effect; + m_value1 = rhs.m_value1; + m_value2 = rhs.m_value2; + m_direction = rhs.m_direction; + m_isGhost = rhs.m_isGhost; + m_canMove = rhs.m_canMove; + m_dialog = rhs.m_dialog; return *this; } |
