KlassischeKeplerKriege/game/state/commands.cpp

22 lines
623 B
C++

#include "commands.hpp"
namespace game {
void ShootCommand::apply(Player *player, State *state) const
{
(void) state;
// TODO spawn missile if alive and enough energy
//std::cout<<"apply command " << name() << std::endl;
player->energy -= m_speed;
player->missiles.push_back(new Missile(player->id, player->ship->position, m_angle, m_speed));
}
bool ShootCommand::allowed(const Player *player, const State *state) const
{
(void) state;
// TODO
return player->alive && player->energy >= m_speed;
//return player->alive;
}
}