KlassischeKeplerKriege/game/state/commands.hpp

57 lines
1.1 KiB
C++
Raw Normal View History

#pragma once
#include "state.hpp"
#include "player.hpp"
#include "ship.hpp"
#include "planet.hpp"
#include "missile.hpp"
#include <iostream>
namespace game {
class Command {
public:
Command()
{
}
virtual ~Command()
{
}
virtual bool allowed(const Player *player, const State *state) const
{
(void) player;
(void) state;
return true;
}
virtual void apply(Player *player, State *state) const
{
(void) state;
(void) player;
std::cout<<"Command '" << name() << "' not yet implemented!" << std::endl;
}
virtual std::string name() const { return "<unnamed>"; }
};
class ShootCommand : public Command {
public:
ShootCommand(float angle, float speed) : m_angle(angle), m_speed(speed)
{
}
std::string name() const { return "<shoot>"; }
void apply( Player *player, State *state) const;
bool allowed(const Player *player, const State *state) const;
private:
float m_angle;
float m_speed;
};
}