Files
deepMiner/include/BaseRobot.h
T
fegger 42876c1a93 Add HP and SmartBot; refactor bots and World
Introduce health (hp) and damage handling to Robot/BaseRobot
interfaces. Add SmartBot implementation. Refactor bot mining and
movement to use new World APIs (mine, mineAllPositive,
sortPositiveValues). Simplify RandomBot, DigDeepBot, and SortBot
logic, rename/overhaul World rearrange/display, and fix several
indexing/logic bugs and minor cleanups.
2026-04-26 20:41:36 +02:00

33 lines
960 B
C++

#pragma once
#include "Robot.h"
#include <string>
/* Base robot implementation shared by all concrete robot types. */
class BaseRobot : public Robot {
public:
BaseRobot(std::string name, int startX, int startY);
~BaseRobot() override = default;
void move(int direction, const World& world) override;
int decideNextMove(const World& world) const override;
void setPosition(int x, int y) override;
int getScore() const override { return score_; }
void addScore(int points) override { score_ += points; }
int getX() const override { return x_; }
int getY() const override { return y_; }
std::string getName() const override { return name_; }
int getHp() const override { return hp_;}
bool isAlive() const override { return hp_ > 0; }
void takeDamage( int damage ) override;
protected:
int x_;
int y_;
int score_;
std::string name_;
int hp_;
static constexpr int MaxHp = 100;
};