Example #1
0
/**
   Handle game over event
*/
static void _gameOver(NinjaState *state) {
  bool win = (state->p1Score == 2);

  if (win) {
    setAllLeds(0, 255, 0);
  } else {
    setAllLeds(255, 0, 0);
  }

  int16_t xp = 0;

  char buffer[32];

  if (win) {
    xp += 15;
    int16_t bonus = 6 * (state->p2Level - ANXGetLevel());
    if (bonus < 0) bonus = 0;
    xp += bonus;
    sprintf(buffer, "Victory!\n%d XP", xp);
  } else {
    xp += state->p1Score * 5;
    sprintf(buffer, "Fail :(\n%d XP", xp);
  }

  //Give them credit
  xp = max(0, xp);
  addExperience(xp);

  statusDialog(buffer);
  safeDisplay();
  safeWaitForButton();

  ledsOff();
}
void ComponentLevelExp::onMessage(const Message& message)
{
    switch (message.type)
    {
    case Message::ADD_EXPERIENCE:
        addExperience(message.value);
        break;
    }
}
Example #3
0
int characterShell::addExperience(lua_State* pLua)
{
	int _iAddExperience = lua_tointeger(pLua, 1);
	auto pCharacter = worldShell::CWorldSingleton::instance()->getPlayer()->getCharacter();

	if(pCharacter != nullptr)
		pCharacter->addExperience(_iAddExperience);

	return 1;
}
Example #4
0
void Monster::adjust(int buffswitch) {
    int     buff=0, crthp=0;
    long    xpmod=0;

    if(buffswitch == -1)
        buff = mrand(1,3)-1;
    else
        buff = MAX(0, MIN(buffswitch, 2));


    /*          Web Editor
     *           _   _  ____ _______ ______
     *          | \ | |/ __ \__   __|  ____|
     *          |  \| | |  | | | |  | |__
     *          | . ` | |  | | | |  |  __|
     *          | |\  | |__| | | |  | |____
     *          |_| \_|\____/  |_|  |______|
     *
     *      If you change anything here, make sure the changes are reflected in the web
     *      editor! Either edit the PHP yourself or tell Dominus to make the changes.
     */
    if(!flagIsSet(M_CUSTOM)) {
        if(level >= 1 && level <= MAXALVL) {
            setArmor(balancedStats[level].armor);
            weaponSkill = (level-1)*10;
            defenseSkill = (level-1)*10;
            setExperience(balancedStats[level].experience);
            damage.setNumber(balancedStats[level].ndice);
            damage.setSides(balancedStats[level].sdice);
            damage.setPlus(balancedStats[level].pdice);
        } else {
            setArmor(100);
            weaponSkill = 1;
            defenseSkill = 1;
            setExperience(6);
            damage.setNumber(1);
            damage.setSides(4);
            damage.setPlus(0);
        }


        if(cClass == CreatureClass::NONE)
            hp.setInitial(level * monType::getHitdice(type));
        else {
            crthp = class_stats[(int) cClass].hpstart + (level*class_stats[(int) cClass].hp);
            hp.setInitial(MAX(crthp, (level * monType::getHitdice(type))));
        }

        hp.restore();

        xpmod = experience / 10;
        xpmod *= monType::getHitdice(type) - monType::getHitdice(HUMANOID);

        if(xpmod > 0)
            addExperience(xpmod);
        else
            subExperience(xpmod*-1);
    }


    switch(buff) {
    case 1:         // Mob is weak.
        hp.setInitial( hp.getMax() - hp.getMax()/5);
        hp.restore();
        coins.set(coins[GOLD] * 4 / 5, GOLD);

        subExperience(experience / 5);
        setArmor(armor - 100);
        damage.setNumber(damage.getNumber() * 9 / 10);
        damage.setPlus(damage.getPlus() * 9 / 10);
        break;
    case 2:         // Mob is stronger
        hp.setInitial( hp.getMax() + hp.getMax()/5);
        hp.restore();
        coins.set(coins[GOLD] * 6 / 5, GOLD);

        addExperience(experience / 5);
        defenseSkill += 5;
        weaponSkill += 5;
        setArmor(armor + 100);

        damage.setNumber(damage.getNumber() * 11 / 10);
        damage.setPlus(damage.getPlus() * 11 / 10);
        break;
    default:
        break;
    }

    armor = MAX<unsigned int>(MIN(armor, MAX_ARMOR), 0);

    if(level >= 7)
        setFlag(M_BLOCK_EXIT);

}