Ejemplo n.º 1
0
	bool TestCharacter::testEquipped()
	{
		Handle<Character> testChar(new Character());
		testChar->setName("TestChar");
		
		Stats *stats = testChar->getStats();
		stats->setBaseStat(Stat::STRENGTH, 10.0f);

		am_equalsDelta(10.0f, stats->getBaseStat(Stat::STRENGTH), 0.0001f);
		am_equalsDelta(10.0f, stats->getStat(Stat::STRENGTH), 0.0001f);

		BodyPart *part = new BodyPart("arm", BodyPartType::ARM);
		assert(testChar->addBodyPart(part));

		Handle<Item> sword(new Item());
		sword->getStatModifiers().addStatModifier(Stat::STRENGTH, StatModifier(5.0f, MOD_ADD));
		assert(testChar->equipItem(sword, "arm"));

		am_equalsDelta(10.0f, stats->getBaseStat(Stat::STRENGTH), 0.0001f);
		am_equalsDelta(15.0f, stats->getStat(Stat::STRENGTH), 0.0001f);

		assert(testChar->unequipItem("arm"));

		am_equalsDelta(10.0f, stats->getBaseStat(Stat::STRENGTH), 0.0001f);
		am_equalsDelta(10.0f, stats->getStat(Stat::STRENGTH), 0.0001f);

		return true;
	}
Ejemplo n.º 2
0
	bool TestCharacter::testSimple() {
		Handle<Character> testChar(new Character());
		testChar->setName("TestChar");
		am_equals("TestChar", testChar->getName().c_str());

		assert(testChar->getInventory());

		Stats *stats = testChar->getStats();
		stats->setBaseStat(Stat::STRENGTH, 10.0f);

		am_equalsDelta(10.0f, stats->getBaseStat(Stat::STRENGTH), 0.0001f);
		am_equalsDelta(10.0f, stats->getStat(Stat::STRENGTH), 0.0001f);

		Handle<Item> sword(new Item());
		StatModifiers &modifiers = sword->getStatModifiers();
		modifiers.addStatModifier(Stat::STRENGTH, StatModifier(5, MOD_ADD));

		stats->addModifiers(modifiers);

		am_equalsDelta(10.0f, stats->getBaseStat(Stat::STRENGTH), 0.0001f);
		am_equalsDelta(15.0f, stats->getStat(Stat::STRENGTH), 0.0001f);

		stats->removeModifiers(modifiers);

		modifiers.addStatModifier(Stat::STRENGTH, StatModifier(2.0f, MOD_MULTIPLY));

		stats->addModifiers(modifiers);

		am_equalsDelta(10.0f, stats->getBaseStat(Stat::STRENGTH), 0.0001f);
		am_equalsDelta(25.0f, stats->getStat(Stat::STRENGTH), 0.0001f);

		return true;
	}