1/**********************************************************************************
2 This file is part of the game 'KTron'
3
4 Copyright (C) 1998-2000 by Matthias Kiefer <matthias.kiefer@gmx.de>
5 Copyright (C) 2005 Benjamin C. Meyer <ben at meyerhome dot net>
6 Copyright (C) 2008-2009 Stas Verberkt <legolas at legolasweb dot nl>
7
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
12
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21
22 *******************************************************************************/
23
24#ifndef PLAYER_H
25#define PLAYER_H
26
27#include "snakepart.h"
28#include "playfield.h"
29
30#include <QObject>
31#include <QQueue>
32
33namespace PlayerDirections
34{
35 enum Direction {
36 None,
37 Up,
38 Down,
39 Left,
40 Right
41 };
42}
43
44/**
45* @short This class represents a player with current position and several flags
46*/
47class Player : public QObject
48{
49 Q_OBJECT
50
51 public:
52 Player(PlayField &pf, int playerNr);
53 int getPlayerNumber();
54 void reset();
55 void setCoordinates(int x, int y);
56 bool isComputer();
57 void setComputer(bool computer);
58 void setStartPosition();
59 void movePlayer();
60 bool crashed(int x, int y);
61 int getX();
62 int getY();
63 int getScore();
64 void addScore(int increment);
65 void resetScore();
66 void setEnlargement(int enlargement);
67 PlayerDirections::Direction getDirection();
68 void setDirection(PlayerDirections::Direction direction);
69 bool isAlive();
70 void die();
71 bool isAccelerated();
72 void setAccelerated(bool value);
73 bool hasKeyPressed();
74 void setKeyPressed(bool value);
75 QString getName();
76 void setName(QString name);
77
78 private:
79 int m_playerNumber;
80 QQueue<SnakePart> m_snakeParts;
81 PlayField *m_playField;
82 int m_score;
83 int m_enlarge;
84 PlayerDirections::Direction m_dir;
85 bool m_alive;
86 bool m_computer;
87 bool m_accelerated;
88 bool m_keyPressed;
89 QString m_name;
90 bool m_blockSwitchDir;
91
92 signals:
93 void fetchedItem(int playerNumber, int x, int y);
94};
95
96#endif //PLAYER_H
97
98