Creen un archivo por comando con .h y .cpp
Closed this issue · 0 comments
mateocapon commented
TPWorms/server_src/game_src/game_command.h
Lines 17 to 54 in d5432b1
class GameCommand { | |
protected: | |
// Make this private and add a getter | |
char id_worm = -1; | |
int direction; | |
public: | |
GameCommand(char id = -1, int direction = 0): id_worm(id), direction(direction) {}; | |
~GameCommand() = default; | |
void virtual execute(Game& game) { return; }; | |
static std::shared_ptr<GameCommand> createCommand(int id, MoveCommandAttributes move , ShootCommandAttributes shoot , int type); | |
}; | |
class MoveCommand: public GameCommand { | |
public: | |
int get_direction() { return direction; } | |
MoveCommand(char id, int direction): GameCommand(id, direction) {} | |
~MoveCommand() {} | |
void execute(Game& game) override { game.move_player(id_worm, direction); } | |
}; | |
class JumpCommand: public GameCommand { | |
public: | |
JumpCommand(char id, int direction): GameCommand(id, direction) {} | |
~JumpCommand() {} | |
void execute(Game& game) override { game.jump_player(id_worm, direction); } | |
}; | |
class ExitCommand: public GameCommand { | |
public: | |
ExitCommand(char id) : GameCommand(id) {} | |
~ExitCommand() {} | |
void execute(Game& game) override { game.remove_player(id_worm); } | |
}; |