mirror of
https://github.com/worldforge/cyphesis
synced 2026-08-13 12:26:04 -04:00
It is completely reasonable to require that a fectory has a pointer to a TypeNode, so these tests always set one up now. Upgrade to using the framework while we're doing it.
646 lines
11 KiB
C++
646 lines
11 KiB
C++
// Cyphesis Online RPG Server and AI Engine
|
|
// Copyright (C) 2009 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
|
|
|
|
// $Id$
|
|
|
|
#ifdef NDEBUG
|
|
#undef NDEBUG
|
|
#endif
|
|
#ifndef DEBUG
|
|
#define DEBUG
|
|
#endif
|
|
|
|
#include "TestBase.h"
|
|
|
|
#include "server/EntityFactory.h"
|
|
|
|
#include "rulesets/Creator.h"
|
|
#include "rulesets/Plant.h"
|
|
#include "rulesets/Stackable.h"
|
|
#include "rulesets/World.h"
|
|
|
|
#include "common/ScriptKit.h"
|
|
#include "common/TypeNode.h"
|
|
|
|
#include <cassert>
|
|
|
|
class TestScriptFactory : public ScriptKit<LocatedEntity> {
|
|
protected:
|
|
std::string m_package;
|
|
public:
|
|
virtual const std::string & package() const {
|
|
return m_package;
|
|
}
|
|
|
|
virtual int addScript(LocatedEntity * entity) const {
|
|
return 0;
|
|
}
|
|
|
|
virtual int refreshClass() {
|
|
return 0;
|
|
}
|
|
};
|
|
|
|
class EntityFactorytest : public Cyphesis::TestBase
|
|
{
|
|
private:
|
|
EntityKit * m_ek;
|
|
public:
|
|
EntityFactorytest();
|
|
|
|
void setup();
|
|
void teardown();
|
|
|
|
void test_newEntity();
|
|
void test_destructor();
|
|
void test_updateProperties();
|
|
};
|
|
|
|
EntityFactorytest::EntityFactorytest()
|
|
{
|
|
ADD_TEST(EntityFactorytest::test_newEntity);
|
|
ADD_TEST(EntityFactorytest::test_destructor);
|
|
ADD_TEST(EntityFactorytest::test_updateProperties);
|
|
}
|
|
|
|
void EntityFactorytest::setup()
|
|
{
|
|
m_ek = new EntityFactory<Thing>;
|
|
m_ek->m_type = new TypeNode("foo");
|
|
}
|
|
|
|
void EntityFactorytest::teardown()
|
|
{
|
|
delete m_ek->m_type;
|
|
delete m_ek;
|
|
}
|
|
|
|
void EntityFactorytest::test_newEntity()
|
|
{
|
|
LocatedEntity * e = m_ek->newEntity("1", 1);
|
|
|
|
ASSERT_NOT_NULL(e);
|
|
}
|
|
|
|
void EntityFactorytest::test_destructor()
|
|
{
|
|
m_ek->m_scriptFactory = new TestScriptFactory;
|
|
}
|
|
|
|
void EntityFactorytest::test_updateProperties()
|
|
{
|
|
m_ek->updateProperties();
|
|
}
|
|
|
|
int main()
|
|
{
|
|
EntityFactorytest t;
|
|
|
|
return t.run();
|
|
}
|
|
|
|
// stubs
|
|
|
|
Stackable::Stackable(const std::string & id, long intId) :
|
|
Thing(id, intId), m_num(1)
|
|
{
|
|
// m_properties["num"] = new Property<int>(m_num, 0);
|
|
}
|
|
|
|
Stackable::~Stackable()
|
|
{
|
|
}
|
|
|
|
void Stackable::CombineOperation(const Operation & op, OpVector & res)
|
|
{
|
|
}
|
|
|
|
void Stackable::DivideOperation(const Operation & op, OpVector & res)
|
|
{
|
|
}
|
|
|
|
Plant::Plant(const std::string & id, long intId) :
|
|
Thing(id, intId), m_nourishment(0)
|
|
{
|
|
}
|
|
|
|
Plant::~Plant()
|
|
{
|
|
}
|
|
|
|
void Plant::NourishOperation(const Operation & op, OpVector & res)
|
|
{
|
|
}
|
|
|
|
void Plant::TickOperation(const Operation & op, OpVector & res)
|
|
{
|
|
}
|
|
|
|
void Plant::TouchOperation(const Operation & op, OpVector & res)
|
|
{
|
|
}
|
|
|
|
Creator::Creator(const std::string & id, long intId) :
|
|
Character(id, intId)
|
|
{
|
|
}
|
|
|
|
Creator::~Creator()
|
|
{
|
|
}
|
|
|
|
void Creator::operation(const Operation & op, OpVector & res)
|
|
{
|
|
}
|
|
|
|
void Creator::externalOperation(const Operation & op, Link &)
|
|
{
|
|
}
|
|
|
|
void Creator::mindLookOperation(const Operation & op, OpVector & res)
|
|
{
|
|
}
|
|
|
|
Character::Character(const std::string & id, long intId) :
|
|
Thing(id, intId),
|
|
m_movement(*(Movement*)0),
|
|
m_mind(0), m_externalMind(0)
|
|
{
|
|
}
|
|
|
|
Character::~Character()
|
|
{
|
|
}
|
|
|
|
void Character::operation(const Operation & op, OpVector &)
|
|
{
|
|
}
|
|
|
|
void Character::externalOperation(const Operation & op, Link &)
|
|
{
|
|
}
|
|
|
|
|
|
void Character::ImaginaryOperation(const Operation & op, OpVector &)
|
|
{
|
|
}
|
|
|
|
void Character::InfoOperation(const Operation & op, OpVector &)
|
|
{
|
|
}
|
|
|
|
void Character::TickOperation(const Operation & op, OpVector &)
|
|
{
|
|
}
|
|
|
|
void Character::TalkOperation(const Operation & op, OpVector &)
|
|
{
|
|
}
|
|
|
|
void Character::NourishOperation(const Operation & op, OpVector &)
|
|
{
|
|
}
|
|
|
|
void Character::UseOperation(const Operation & op, OpVector &)
|
|
{
|
|
}
|
|
|
|
void Character::WieldOperation(const Operation & op, OpVector &)
|
|
{
|
|
}
|
|
|
|
void Character::AttackOperation(const Operation & op, OpVector &)
|
|
{
|
|
}
|
|
|
|
void Character::ActuateOperation(const Operation & op, OpVector &)
|
|
{
|
|
}
|
|
|
|
void Character::mindActuateOperation(const Operation &, OpVector &)
|
|
{
|
|
}
|
|
|
|
void Character::mindAttackOperation(const Operation &, OpVector &)
|
|
{
|
|
}
|
|
|
|
void Character::mindCombineOperation(const Operation &, OpVector &)
|
|
{
|
|
}
|
|
|
|
void Character::mindCreateOperation(const Operation &, OpVector &)
|
|
{
|
|
}
|
|
|
|
void Character::mindDeleteOperation(const Operation &, OpVector &)
|
|
{
|
|
}
|
|
|
|
void Character::mindDivideOperation(const Operation &, OpVector &)
|
|
{
|
|
}
|
|
|
|
void Character::mindEatOperation(const Operation &, OpVector &)
|
|
{
|
|
}
|
|
|
|
void Character::mindGoalInfoOperation(const Operation &, OpVector &)
|
|
{
|
|
}
|
|
|
|
void Character::mindImaginaryOperation(const Operation &, OpVector &)
|
|
{
|
|
}
|
|
|
|
void Character::mindLookOperation(const Operation &, OpVector &)
|
|
{
|
|
}
|
|
|
|
void Character::mindMoveOperation(const Operation &, OpVector &)
|
|
{
|
|
}
|
|
|
|
void Character::mindSetOperation(const Operation &, OpVector &)
|
|
{
|
|
}
|
|
|
|
void Character::mindSetupOperation(const Operation &, OpVector &)
|
|
{
|
|
}
|
|
|
|
void Character::mindTalkOperation(const Operation &, OpVector &)
|
|
{
|
|
}
|
|
|
|
void Character::mindThoughtOperation(const Operation &, OpVector &)
|
|
{
|
|
}
|
|
|
|
void Character::mindTickOperation(const Operation &, OpVector &)
|
|
{
|
|
}
|
|
|
|
void Character::mindTouchOperation(const Operation &, OpVector &)
|
|
{
|
|
}
|
|
|
|
void Character::mindUpdateOperation(const Operation &, OpVector &)
|
|
{
|
|
}
|
|
|
|
void Character::mindUseOperation(const Operation &, OpVector &)
|
|
{
|
|
}
|
|
|
|
void Character::mindWieldOperation(const Operation &, OpVector &)
|
|
{
|
|
}
|
|
|
|
void Character::mindOtherOperation(const Operation &, OpVector &)
|
|
{
|
|
}
|
|
|
|
|
|
Thing::Thing(const std::string & id, long intId) :
|
|
Entity(id, intId)
|
|
{
|
|
}
|
|
|
|
Thing::~Thing()
|
|
{
|
|
}
|
|
|
|
void Thing::DeleteOperation(const Operation & op, OpVector & res)
|
|
{
|
|
}
|
|
|
|
void Thing::MoveOperation(const Operation & op, OpVector & res)
|
|
{
|
|
}
|
|
|
|
void Thing::SetOperation(const Operation & op, OpVector & res)
|
|
{
|
|
}
|
|
|
|
void Thing::LookOperation(const Operation & op, OpVector & res)
|
|
{
|
|
}
|
|
|
|
void Thing::CreateOperation(const Operation & op, OpVector & res)
|
|
{
|
|
}
|
|
|
|
void Thing::UpdateOperation(const Operation & op, OpVector & res)
|
|
{
|
|
}
|
|
|
|
Entity::Entity(const std::string & id, long intId) :
|
|
LocatedEntity(id, intId), m_motion(0)
|
|
{
|
|
}
|
|
|
|
Entity::~Entity()
|
|
{
|
|
}
|
|
|
|
void Entity::destroy()
|
|
{
|
|
destroyed.emit();
|
|
}
|
|
|
|
void Entity::ActuateOperation(const Operation &, OpVector &)
|
|
{
|
|
}
|
|
|
|
void Entity::AppearanceOperation(const Operation &, OpVector &)
|
|
{
|
|
}
|
|
|
|
void Entity::AttackOperation(const Operation &, OpVector &)
|
|
{
|
|
}
|
|
|
|
void Entity::CombineOperation(const Operation &, OpVector &)
|
|
{
|
|
}
|
|
|
|
void Entity::CreateOperation(const Operation &, OpVector &)
|
|
{
|
|
}
|
|
|
|
void Entity::DeleteOperation(const Operation &, OpVector &)
|
|
{
|
|
}
|
|
|
|
void Entity::DisappearanceOperation(const Operation &, OpVector &)
|
|
{
|
|
}
|
|
|
|
void Entity::DivideOperation(const Operation &, OpVector &)
|
|
{
|
|
}
|
|
|
|
void Entity::EatOperation(const Operation &, OpVector &)
|
|
{
|
|
}
|
|
|
|
void Entity::GetOperation(const Operation &, OpVector &)
|
|
{
|
|
}
|
|
|
|
void Entity::InfoOperation(const Operation &, OpVector &)
|
|
{
|
|
}
|
|
|
|
void Entity::ImaginaryOperation(const Operation &, OpVector &)
|
|
{
|
|
}
|
|
|
|
void Entity::LookOperation(const Operation &, OpVector &)
|
|
{
|
|
}
|
|
|
|
void Entity::MoveOperation(const Operation &, OpVector &)
|
|
{
|
|
}
|
|
|
|
void Entity::NourishOperation(const Operation &, OpVector &)
|
|
{
|
|
}
|
|
|
|
void Entity::SetOperation(const Operation &, OpVector &)
|
|
{
|
|
}
|
|
|
|
void Entity::SightOperation(const Operation &, OpVector &)
|
|
{
|
|
}
|
|
|
|
void Entity::SoundOperation(const Operation &, OpVector &)
|
|
{
|
|
}
|
|
|
|
void Entity::TalkOperation(const Operation &, OpVector &)
|
|
{
|
|
}
|
|
|
|
void Entity::TickOperation(const Operation &, OpVector &)
|
|
{
|
|
}
|
|
|
|
void Entity::TouchOperation(const Operation &, OpVector &)
|
|
{
|
|
}
|
|
|
|
void Entity::UpdateOperation(const Operation &, OpVector &)
|
|
{
|
|
}
|
|
|
|
void Entity::UseOperation(const Operation &, OpVector &)
|
|
{
|
|
}
|
|
|
|
void Entity::WieldOperation(const Operation &, OpVector &)
|
|
{
|
|
}
|
|
|
|
void Entity::externalOperation(const Operation & op, Link &)
|
|
{
|
|
}
|
|
|
|
void Entity::operation(const Operation & op, OpVector & res)
|
|
{
|
|
}
|
|
|
|
void Entity::addToMessage(Atlas::Message::MapType & omap) const
|
|
{
|
|
}
|
|
|
|
void Entity::addToEntity(const Atlas::Objects::Entity::RootEntity & ent) const
|
|
{
|
|
}
|
|
|
|
PropertyBase * Entity::setAttr(const std::string & name,
|
|
const Atlas::Message::Element & attr)
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
const PropertyBase * Entity::getProperty(const std::string & name) const
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
PropertyBase * Entity::setProperty(const std::string & name,
|
|
PropertyBase * prop)
|
|
{
|
|
return m_properties[name] = prop;
|
|
}
|
|
|
|
PropertyBase * Entity::modProperty(const std::string & name)
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
void Entity::installDelegate(int class_no, const std::string & delegate)
|
|
{
|
|
}
|
|
|
|
Domain * Entity::getMovementDomain()
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
void Entity::sendWorld(const Operation & op)
|
|
{
|
|
}
|
|
|
|
void Entity::onContainered()
|
|
{
|
|
}
|
|
|
|
void Entity::onUpdated()
|
|
{
|
|
}
|
|
|
|
LocatedEntity::LocatedEntity(const std::string & id, long intId) :
|
|
Router(id, intId),
|
|
m_refCount(0), m_seq(0),
|
|
m_script(0), m_type(0), m_flags(0), m_contains(0)
|
|
{
|
|
}
|
|
|
|
LocatedEntity::~LocatedEntity()
|
|
{
|
|
}
|
|
|
|
bool LocatedEntity::hasAttr(const std::string & name) const
|
|
{
|
|
return false;
|
|
}
|
|
|
|
int LocatedEntity::getAttr(const std::string & name,
|
|
Atlas::Message::Element & attr) const
|
|
{
|
|
return -1;
|
|
}
|
|
|
|
int LocatedEntity::getAttrType(const std::string & name,
|
|
Atlas::Message::Element & attr,
|
|
int type) const
|
|
{
|
|
return -1;
|
|
}
|
|
|
|
PropertyBase * LocatedEntity::setAttr(const std::string & name,
|
|
const Atlas::Message::Element & attr)
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
const PropertyBase * LocatedEntity::getProperty(const std::string & name) const
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
PropertyBase * LocatedEntity::modProperty(const std::string & name)
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
PropertyBase * LocatedEntity::setProperty(const std::string & name,
|
|
PropertyBase * prop)
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
void LocatedEntity::installDelegate(int, const std::string &)
|
|
{
|
|
}
|
|
|
|
void LocatedEntity::destroy()
|
|
{
|
|
}
|
|
|
|
Domain * LocatedEntity::getMovementDomain()
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
void LocatedEntity::sendWorld(const Operation & op)
|
|
{
|
|
}
|
|
|
|
void LocatedEntity::onContainered()
|
|
{
|
|
}
|
|
|
|
void LocatedEntity::onUpdated()
|
|
{
|
|
}
|
|
|
|
Router::Router(const std::string & id, long intId) : m_id(id),
|
|
m_intId(intId)
|
|
{
|
|
}
|
|
|
|
Router::~Router()
|
|
{
|
|
}
|
|
|
|
void Router::addToMessage(Atlas::Message::MapType & omap) const
|
|
{
|
|
}
|
|
|
|
void Router::addToEntity(const Atlas::Objects::Entity::RootEntity & ent) const
|
|
{
|
|
}
|
|
|
|
void Router::error(const Operation & op,
|
|
const std::string & errstring,
|
|
OpVector & res,
|
|
const std::string & to) const
|
|
{
|
|
}
|
|
|
|
void Router::clientError(const Operation & op,
|
|
const std::string & errstring,
|
|
OpVector & res,
|
|
const std::string & to) const
|
|
{
|
|
}
|
|
|
|
Location::Location() : m_loc(0)
|
|
{
|
|
}
|
|
|
|
TypeNode::TypeNode(const std::string & name) : m_name(name), m_parent(0)
|
|
{
|
|
}
|
|
|
|
TypeNode::~TypeNode()
|
|
{
|
|
}
|
|
|
|
void TypeNode::addProperties(const Atlas::Message::MapType &)
|
|
{
|
|
}
|
|
|
|
void TypeNode::updateProperties(const Atlas::Message::MapType &)
|
|
{
|
|
}
|