cyphesis/tests/PlantTest.cpp
Erik Ogenvik cd33df2d75 Use camel casing for tests.
This makes it much easier to find them in various editors.
2016-01-20 15:34:49 +01:00

201 lines
4.5 KiB
C++

// Cyphesis Online RPG Server and AI Engine
// Copyright (C) 2003 Alistair Riddoch
//
// 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 2 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, write to the Free Software Foundation,
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
#ifdef NDEBUG
#undef NDEBUG
#endif
#ifndef DEBUG
#define DEBUG
#endif
#include "IGEntityExerciser.h"
#include "allOperations.h"
#include "rulesets/Plant.h"
#include "rulesets/AtlasProperties.h"
#include "rulesets/AreaProperty.h"
#include "rulesets/BBoxProperty.h"
#include "rulesets/Domain.h"
#include "rulesets/Script.h"
#include "rulesets/StatusProperty.h"
#include "common/id.h"
#include "common/log.h"
#include "common/Property_impl.h"
#include "common/TypeNode.h"
#include "stubs/common/stubCustom.h"
#include "stubs/common/stubRouter.h"
#include "stubs/common/stubTypeNode.h"
#include "stubs/modules/stubLocation.h"
#include "stubs/rulesets/stubThing.h"
#include "stubs/rulesets/stubEntity.h"
#include "stubs/rulesets/stubLocatedEntity.h"
#include "stubs/rulesets/stubIdProperty.h"
#include "stubs/common/stubProperty.h"
#include "stubs/rulesets/stubSoftProperty.h"
#include "stubs/rulesets/stubContainsProperty.h"
#include "stubs/rulesets/stubStatusProperty.h"
#include "stubs/rulesets/stubBBoxProperty.h"
#include "stubs/rulesets/stubAreaProperty.h"
#include "stubs/rulesets/stubTerrainEffectorProperty.h"
#include "stubs/rulesets/stubDomain.h"
#include <cstdlib>
#include <cassert>
using Atlas::Message::Element;
using Atlas::Message::ListType;
using Atlas::Message::MapType;
using Atlas::Objects::Entity::RootEntity;
int main()
{
Plant e("1", 1);
TypeNode type("plant");
e.setType(&type);
IGEntityExerciser ee(e);
// Throw an op of every type at the entity
ee.runOperations();
// Subscribe the entity to every class of op
std::set<std::string> opNames;
ee.addAllOperations(opNames);
// Throw an op of every type at the entity again now it is subscribed
ee.runOperations();
return 0;
}
// stubs
void TestWorld::message(const Operation & op, LocatedEntity & ent)
{
}
LocatedEntity * TestWorld::addNewEntity(const std::string &,
const Atlas::Objects::Entity::RootEntity &)
{
return 0;
}
void addToEntity(const Point3D & p, std::vector<double> & vd)
{
vd.resize(3);
vd[0] = p[0];
vd[1] = p[1];
vd[2] = p[2];
}
BaseWorld * BaseWorld::m_instance = 0;
BaseWorld::BaseWorld(LocatedEntity & gw) : m_gameWorld(gw)
{
m_instance = this;
}
BaseWorld::~BaseWorld()
{
m_instance = 0;
}
LocatedEntity * BaseWorld::getEntity(const std::string & id) const
{
long intId = integerId(id);
EntityDict::const_iterator I = m_eobjects.find(intId);
if (I != m_eobjects.end()) {
assert(I->second != 0);
return I->second;
} else {
return 0;
}
}
LocatedEntity * BaseWorld::getEntity(long id) const
{
EntityDict::const_iterator I = m_eobjects.find(id);
if (I != m_eobjects.end()) {
assert(I->second != 0);
return I->second;
} else {
return 0;
}
}
Script::Script()
{
}
/// \brief Script destructor
Script::~Script()
{
}
bool Script::operation(const std::string & opname,
const Atlas::Objects::Operation::RootOperation & op,
OpVector & res)
{
return false;
}
void Script::hook(const std::string & function, LocatedEntity * entity)
{
}
PropertyManager * PropertyManager::m_instance = 0;
PropertyManager::PropertyManager()
{
assert(m_instance == 0);
m_instance = this;
}
PropertyManager::~PropertyManager()
{
m_instance = 0;
}
int PropertyManager::installFactory(const std::string & type_name,
const Atlas::Objects::Root & type_desc,
PropertyKit * factory)
{
return 0;
}
void log(LogLevel lvl, const std::string & msg)
{
}
long integerId(const std::string & id)
{
long intId = strtol(id.c_str(), 0, 10);
if (intId == 0 && id != "0") {
intId = -1L;
}
return intId;
}