blob: 1de568790d07051de0248b9d8b282a249b5906e5 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
/**
* Copyright (C) David Wolfe, 1999. All rights reserved.
* Ported to Qt and adapted for TDDD86, 2015.
*/
#ifndef UNIT_H
#define UNIT_H
#include "utilities.h"
/* Root class for all pieces on the board.
* Subclasses are Robot, Hero and Junk.
*/
class Unit {
public:
Unit();
Unit(const Unit& u);
Unit(const Point& p);
/*
* Return Point representation of Unit
*/
Point asPoint() const;
/*
* Am I in the same square as u?
*/
bool at(const Unit& u) const;
/*
* Can I catch u in one move?
*/
bool attacks(const Unit& u) const;
/*
* Take one step closer to u
*/
void moveTowards(const Unit& u);
/*
* Teleport. Does not check for collision
*/
void teleport();
/*
* Euclidean distance to u
*/
double distanceTo(const Unit& u) const;
private:
int x; // x position of this unit
int y; // y position of this unit
// private helpers
void checkBounds();
};
#endif // UNIT_H
|