Esempio n. 1
0
	/**
	 * Sets the stat modifier type.
	 * <br>This is the list of each modifier type:
	 * <ul>
	 * <li>= : Sets the stat to the given value. This mod is applied first.</li>
	 * <li>* : Multiplies the stat by the given value. This mod is applied second.</li>
	 * <li>+ : Adds the given value directly onto the stat, this value can be negative. This mod is applied third.</li>
	 * </ul>
	 *
	 * @param string type The new type for this modifier.
	 * @returns am.stat_modifier This
	 */
	int StatModifier_type(lua_State *lua)
	{
		StatModifier *mod = castUData<StatModifier>(lua, 1);
		if (mod)
		{
			if (lua_gettop(lua) == 1)
			{
				lua_pushstring(lua, StatModifier::getModifierTypeString(mod->getType()));
				return 1;
			}
			else if (lua_isstr(lua, 2))
			{
				StatModifierType type = getStatModifier(lua, 2);
				if (type != MOD_MAX_LENGTH)
				{
					mod->setType(type);
				}
				else
				{
					std::stringstream ss;
					ss << "Invalid stat modifier type (";
					LuaState::printTypeValue(lua, 2, ss);
					ss << ')';
					LuaState::warning(lua, ss.str().c_str());
				}
				lua_first(lua);
			}
			return LuaState::expectedArgs(lua, "type", "string type");
		}
		return LuaState::expectedContext(lua, "type", "am.stat_modifier");
	}
Esempio n. 2
0
void Champion::addStatModifier(StatModifier &statModifier)
{
    ModifierType modType = statModifier.getType();
    if (modType == ModifierType::FLAT) {
        _flatModifiers[statModifier.getStatID()].push_back(&statModifier);
    } else if (modType == ModifierType::ADDATIVE) {
        _addativeModifiers[statModifier.getStatID()].push_back(&statModifier);
    } else if (modType == ModifierType::MULTIPLICATIVE) {
        
    } else {
        std::cout << "Unrecognised StatModifer type";
    }
}