Example #1
0
void enemyTurn(Hero& hero, ArmoredEnemy& enemy)
{
	std::this_thread::sleep_for(std::chrono::milliseconds(500));
	hero.setHealth(hero.getBool() ? hero.getHealth() < static_cast<unsigned short>(enemy.getAttack() * 0.1) ? 0 : hero.getHealth() - static_cast<unsigned short>(enemy.getAttack() * 0.1) : hero.getHealth() < enemy.getAttack() ? 0 : hero.getHealth() - enemy.getAttack()); // If the hero is blocking only do 1/10th damage
	if(enemy.getBool())
		enemy.setBool(false); // Resetting blocking bool
	if(rand() % 10 + 1 == 10)
		enemy.setBool(true);
}
Example #2
0
int main()
{
//	cout<<"Starting game"<<endl;
//    Dungeon* dung = new Dungeon("map.txt");
//    vector<Entity> entities;
//    entities.push_back(Orc("fsdfsd", 100, 1.2));
//    Hero* hero = new Hero("Huko", "The programmer", 100);
//    Orc* orc = new Orc("Orketo", 50, 1.2);
//    dung->spawn("hero", hero);
//    dung->printMap();
//    dung->spawn("orc", orc);
//    dung->printMap();
    Hero* hero = new Hero("Niki", 100);
    cout<<hero->getHealth()<<endl;
    hero->takeDamage(20);
    cout<<hero->getHealth()<<endl;

    Weapon* weapon = new Weapon("axe", 50);
    hero->equipWeapon(weapon);
    cout<<hero->getWeapon()->getType()<<endl;
    return 0;
}
Example #3
0
void enemyTurn(Hero& hero, StrongEnemy& enemy)
{
	if(rand() % 10 + 1 == 10)
		enemy.setBool(true);
	unsigned short currentAttack = enemy.getAttack() + enemy.getStrength();
	if(enemy.getBool())
	{
		currentAttack += enemy.getStrength();
		enemy.setBool(false); // Resetting doubledamage bool
	}
	std::this_thread::sleep_for(std::chrono::milliseconds(500));
	hero.setHealth(hero.getBool() ? hero.getHealth() < static_cast<unsigned short>(currentAttack * 0.1) ? 0 : hero.getHealth() - static_cast<unsigned short>(currentAttack * 0.1) : hero.getHealth() < currentAttack ? 0 : hero.getHealth() - currentAttack); // If the hero is blocking only do 1/10th damage
}
Example #4
0
/**
 * Draw the overlay and processes button events.
 */
void Overlay::draw(float dt)
{
    // update the current turn label

    Level::turn t = level->getCurrentTurn();

    bool herot = (t == Level::HERO_TURN);
    bool haggist = (t == Level::HAGGIS_TURN);
    bool actiont = (t == Level::ACTION_TURN);

    heroturn->setEnabled(herot);
    haggisturn->setEnabled(haggist);
    actionturn->setEnabled(actiont);

    // update the progress bars

    Hero *h = level->getHero();
    bars[0]->setProgress((float) h->getHealth() / (float) h->getMaxStat());
    bars[1]->setProgress((float) h->getEnergy() / (float) h->getMaxStat());
    bars[2]->setProgress((float) h->getAmmo() / (float) h->getMaxStat());

    // update the action buttons

    actions[0]->setEnabled(WaitAction::canWait(h));
    actions[1]->setEnabled(WalkAction::canWalk(h));
    actions[2]->setEnabled(JumpAction::canJump(h));
    actions[3]->setEnabled(GrenadeAction::canThrow(h));
    actions[4]->setEnabled(PsychicAction::canPsychic(h));

    // do something depending on the state
    // check for action button presses
    // if it is the haggis' turn, do nothing
    if(!haggist)
    {
        for (int i=0; i<(int)actions.size(); i++)
        {
            if (actions[i]->isPressed())
            {
                actions[i]->reset();  //set pressed = false
                //only handle button if in right state
                if(state == NORMAL)
                {
                    handleButton(i);
                }
                else if(action == i)
                {
                    action = -1;
                    handleCellSelection(); //to return state to normal
                }
            }
        }
    }

    if ((state == WAITING_FOR_CELL) && maze)
    {
        // check if a cell has been selected
        if (maze->getSelection())
        {
            handleCellSelection();
        }
    }
}
Example #5
0
void enemyTurn(Hero& hero, Character& boss)
{
	std::this_thread::sleep_for(std::chrono::milliseconds(500));
	hero.setHealth(hero.getBool() ? hero.getHealth() < static_cast<unsigned short>(boss.getAttack() * 0.1) ? 0 : hero.getHealth() - static_cast<unsigned short>(boss.getAttack() * 0.1) : hero.getHealth() < boss.getAttack() ? 0 : hero.getHealth() - boss.getAttack());
}