-
Notifications
You must be signed in to change notification settings - Fork 0
/
soldier.h
77 lines (58 loc) · 1.99 KB
/
soldier.h
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#ifndef __SOLDIER_H__
#define __SOLDIER_H__
#include "piece.h"
class soldier : public piece
{
public:
/* name: constructor */
/* desc: sets the rank */
/* params: rank */
/* return: n/a */
soldier(int team, int rank, image * h, image * r);
/* name: attack */
/* desc: handles an attack */
/* params: piece * enemy */
/* return: int - return 1 if this object wins */
/* return 0 if tie */
/* return -1 if this object loses */
/* 0) if enemy is a flag, return 1 */
/* 1) if enemy is a bomb, return -1 */
/* 2) if enemy's rank is less than this object's, return -1 */
/* 3) if enemy's rank is equal to this object's, return 0 */
/* 4) return 1 */
int attack(piece * enemy);
/* name: possible moves */
/* desc: checks left, right, up and down. */
/* if the move is on on the board and ( empty or an enemy ) */
/* then it is added to moves object. */
/* params: board * b, moves * m, */
/* return: void */
void possible_moves( board *b, moves *m );
/* name: valid_move */
/* desc: checks to see if the given x,y work */
/* on the board, and then if it make sense for the peice */
/* params: int checkx, int checky */
/* return: int - true if it makes sense */
/* 1) call the board's check method for checkx, and checky, */
/* if it returns false, return false */
/* 2) if the cehckx, and checky are to the left, right, up */
/* or down of the current position, return true */
/* 3) return false */
int valid_move(int checkx, int checky, board * b);
/* name: move */
/* desc: changes the object's x,y to the newx, newy */
/* params: int newx, int newy */
/* return: void */
void move(int newx, int newy)
{
_x = newx;
_y = newy;
}
/* name: is_soldier */
/* return true */
int is_soldier() { return 1; }
int get_rank() { return _rank; }
protected:
int _rank;
};
#endif