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 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121
|
/****************************************************************
**
** Attal : Lords of Doom
**
** genericFightMap.h
** generic class for managing (not graphical) fightMap
**
** Version : $Id: genericFightMap.h,v 1.8 2004/08/01 11:30:19 audoux Exp $
**
** Author(s) : Pascal Audoux - Cyrille Verrier
**
** Date : 02/08/2000
**
** Licence :
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation; either version 2, or (at your option)
** any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
****************************************************************/
#ifndef GENERICFIGHTMAP_H
#define GENERICFIGHTMAP_H
// generic include files
// include files for QT
#include <qptrlist.h>
#include <qptrstack.h>
// application specific include
#include "libCommon/genericFightCell.h"
class PathFightFinder;
class GenericFightUnit;
/* ------------------------------
* GenericFightMap
* ------------------------------ */
/** generic class for managing (not graphical) cells */
class GenericFightMap
{
public:
/** Constructor */
GenericFightMap();
/** Destructor */
virtual ~GenericFightMap();
/** Return cell of the fightMap */
GenericFightCell * at( int i, int j )
{ return _genericFightCells[i][j]; }
/** Create new fight map */
virtual void newFightMap( int h, int w, bool horizontalDraw = false );
virtual void reinit();
virtual void initPath( GenericFightUnit * unit );
void printPath();
virtual void clearPath();
QPtrStack<GenericFightCell> computePath( GenericFightUnit * unit, GenericFightCell * cell );
GenericFightCell * getNeighbour1( GenericFightCell * cell );
GenericFightCell * getNeighbour2( GenericFightCell * cell );
GenericFightCell * getNeighbour3( GenericFightCell * cell );
GenericFightCell * getNeighbour4( GenericFightCell * cell );
GenericFightCell * getNeighbour5( GenericFightCell * cell );
GenericFightCell * getNeighbour6( GenericFightCell * cell );
bool areNeighbours( GenericFightCell * cell1, GenericFightCell * cell2 );
int getHeight () { return _height; }
int getWidth () { return _width; }
protected:
GenericFightCell * giveNeighbourOnPath( GenericFightCell * cell, int dist );
int _height, _width;
PathFightFinder * _path;
bool _horizontalDraw;
GenericFightCell *** _genericFightCells;
};
/** pseudo-pile of GenericFightCell (in fact, a list..) */
class FightPile : public QPtrList<GenericFightCell>
{
public:
/** Constrcutor */
FightPile( GenericFightMap * map, int limit, GenericFightUnit* unit );
/** \return Returns the 'smallest' cell */
GenericFightCell * takeSmallest();
/** Appends neighbours of a cell */
void appendNeighbours( GenericFightCell * cell );
private:
void handleNeighbour( GenericFightCell * neighbour, int dist );
bool testHeadFree( GenericFightCell * cell );
GenericFightMap * _map;
int _limit;
GenericFightUnit * _unit;
};
#endif // GENERICFIGHTMAP_H
|