src/proto2/GameState.hh
author terom
Mon, 03 Nov 2008 23:24:21 +0000
changeset 6 faa4e777cc6e
parent 5 617813994ab1
child 8 2de58a6d0395
permissions -rw-r--r--
fiddle with cmake, fix some compile errors
3
5a209a8585c9 proto p2
terom
parents:
diff changeset
     1
#ifndef GAMESTATE_HH
5a209a8585c9 proto p2
terom
parents:
diff changeset
     2
#define GAMESTATE_HH
5a209a8585c9 proto p2
terom
parents:
diff changeset
     3
4
e28b28b8817c Drawer lis?tty. Pari metodia gamestateen ja dimensioniin.
ekku
parents: 3
diff changeset
     4
#include "Dimension.hh"
e28b28b8817c Drawer lis?tty. Pari metodia gamestateen ja dimensioniin.
ekku
parents: 3
diff changeset
     5
5
617813994ab1 move proto/p2 -> src/proto2
terom
parents: 4
diff changeset
     6
#include <list>
617813994ab1 move proto/p2 -> src/proto2
terom
parents: 4
diff changeset
     7
3
5a209a8585c9 proto p2
terom
parents:
diff changeset
     8
enum PlayerType {
6
faa4e777cc6e fiddle with cmake, fix some compile errors
terom
parents: 5
diff changeset
     9
	PLAYER_LOCAL = 0x01,
faa4e777cc6e fiddle with cmake, fix some compile errors
terom
parents: 5
diff changeset
    10
	PLAYER_REMOTE = 0x02
3
5a209a8585c9 proto p2
terom
parents:
diff changeset
    11
};
5a209a8585c9 proto p2
terom
parents:
diff changeset
    12
5a209a8585c9 proto p2
terom
parents:
diff changeset
    13
class Player {
6
faa4e777cc6e fiddle with cmake, fix some compile errors
terom
parents: 5
diff changeset
    14
	protected:
3
5a209a8585c9 proto p2
terom
parents:
diff changeset
    15
		Coordinate position;
5a209a8585c9 proto p2
terom
parents:
diff changeset
    16
5a209a8585c9 proto p2
terom
parents:
diff changeset
    17
	public:
4
e28b28b8817c Drawer lis?tty. Pari metodia gamestateen ja dimensioniin.
ekku
parents: 3
diff changeset
    18
6
faa4e777cc6e fiddle with cmake, fix some compile errors
terom
parents: 5
diff changeset
    19
		Player(Coordinate c) : position(c), dimensions(10, 10) {}
4
e28b28b8817c Drawer lis?tty. Pari metodia gamestateen ja dimensioniin.
ekku
parents: 3
diff changeset
    20
3
5a209a8585c9 proto p2
terom
parents:
diff changeset
    21
		PlayerType type;
6
faa4e777cc6e fiddle with cmake, fix some compile errors
terom
parents: 5
diff changeset
    22
		Dimension dimensions;
3
5a209a8585c9 proto p2
terom
parents:
diff changeset
    23
4
e28b28b8817c Drawer lis?tty. Pari metodia gamestateen ja dimensioniin.
ekku
parents: 3
diff changeset
    24
		Coordinate getPosition (void) const {
3
5a209a8585c9 proto p2
terom
parents:
diff changeset
    25
			return this->position;
5a209a8585c9 proto p2
terom
parents:
diff changeset
    26
		}
5a209a8585c9 proto p2
terom
parents:
diff changeset
    27
};
5a209a8585c9 proto p2
terom
parents:
diff changeset
    28
5a209a8585c9 proto p2
terom
parents:
diff changeset
    29
class LocalPlayer : public Player {
5a209a8585c9 proto p2
terom
parents:
diff changeset
    30
	public:
5a209a8585c9 proto p2
terom
parents:
diff changeset
    31
		void doMovement (PositionDelta d) {
5a209a8585c9 proto p2
terom
parents:
diff changeset
    32
			this->position += d;
5a209a8585c9 proto p2
terom
parents:
diff changeset
    33
5a209a8585c9 proto p2
terom
parents:
diff changeset
    34
			// XXX: notify server
5a209a8585c9 proto p2
terom
parents:
diff changeset
    35
		}
5a209a8585c9 proto p2
terom
parents:
diff changeset
    36
};
5a209a8585c9 proto p2
terom
parents:
diff changeset
    37
5a209a8585c9 proto p2
terom
parents:
diff changeset
    38
class RemotePlayer : public Player {
5a209a8585c9 proto p2
terom
parents:
diff changeset
    39
	public:
6
faa4e777cc6e fiddle with cmake, fix some compile errors
terom
parents: 5
diff changeset
    40
		void updatePosition (Coordinate p) {
3
5a209a8585c9 proto p2
terom
parents:
diff changeset
    41
			this->position = p;
5a209a8585c9 proto p2
terom
parents:
diff changeset
    42
		}
6
faa4e777cc6e fiddle with cmake, fix some compile errors
terom
parents: 5
diff changeset
    43
};
faa4e777cc6e fiddle with cmake, fix some compile errors
terom
parents: 5
diff changeset
    44
faa4e777cc6e fiddle with cmake, fix some compile errors
terom
parents: 5
diff changeset
    45
class GameState {
faa4e777cc6e fiddle with cmake, fix some compile errors
terom
parents: 5
diff changeset
    46
	public:
faa4e777cc6e fiddle with cmake, fix some compile errors
terom
parents: 5
diff changeset
    47
		Dimension map_dimensions;
faa4e777cc6e fiddle with cmake, fix some compile errors
terom
parents: 5
diff changeset
    48
		std::list<Player> player_list;
faa4e777cc6e fiddle with cmake, fix some compile errors
terom
parents: 5
diff changeset
    49
faa4e777cc6e fiddle with cmake, fix some compile errors
terom
parents: 5
diff changeset
    50
		LocalPlayer &getLocalPlayer (void) {
faa4e777cc6e fiddle with cmake, fix some compile errors
terom
parents: 5
diff changeset
    51
			// XXX: jotain
faa4e777cc6e fiddle with cmake, fix some compile errors
terom
parents: 5
diff changeset
    52
		}
faa4e777cc6e fiddle with cmake, fix some compile errors
terom
parents: 5
diff changeset
    53
};
faa4e777cc6e fiddle with cmake, fix some compile errors
terom
parents: 5
diff changeset
    54
3
5a209a8585c9 proto p2
terom
parents:
diff changeset
    55
5a209a8585c9 proto p2
terom
parents:
diff changeset
    56
#endif