1 /***************************************************************************
2                           cavalrysprite.h  -  description
3                              -------------------
4     begin                :
5     copyright            : (C) 2003-2007 by Gael de Chalendar
6     email                : kleag@free.fr
7  ***************************************************************************/
8 
9 /***************************************************************************
10  *                                                                         *
11  *   This program is free software; you can redistribute it and/or modify  *
12  *   it under the terms of the GNU General Public License as published by  *
13  *   the Free Software Foundation; either either version 2
14    of the License, or (at your option) any later version.of the License, or     *
15  *   (at your option) any later version.                                   *
16  *                                                                         *
17  *   You should have received a copy of the GNU General Public License
18  *   along with this program; if not, write to the Free Software
19  *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
20  *   02110-1301, USA
21  ***************************************************************************/
22 
23 
24 #ifndef KSIRKCAVALRYSPRITE_H
25 #define KSIRKCAVALRYSPRITE_H
26 
27 #include "armysprite.h"
28 
29 namespace Ksirk {
30 
31 namespace GameLogic
32 {
33   class Country;
34 }
35 
36 /**
37   * A CavalrySpritei is an army sprite that represents 5 armies
38   * @author Gaël de Chalendar
39   */
40 class CavalrySprite : public ArmySprite
41 {
42 public:
43   /**
44     * This simplified constructor allows to create a new @ref CavalrySprite with
45     * default values for svg pool id and skin elements names
46     * @param zoom The current zoom factor
47     * @param aBackGnd The background giving info about the world geometry and
48     * access to the underlying QGraphicsScene
49     * @param visibility Measures how much this sprite is visible. It gives its
50     * Z value on the graphics scene.
51     */
52   CavalrySprite(double zoom,
53                 BackGnd* aBackGnd,
54                 unsigned int visibility = 200);
55 
56   /**
57     * This constructor allows to create a new @ref AnimSprite whose images are
58     * taken from the given file name with the given number of frames and
59     * number of look directions
60     * @param svgid The id of the SVG element from which to load images
61     * @param aBackGnd The background giving info about the world geometry and
62     * access to the underlying QGraphicsScene
63     * @param nbFrames The number of different frames in this sprite animation,
64     * thus the number of columns in the sprite image
65     * @param nbDirs The number of different views on the sprite,
66     * thus the number of rows in the sprite image
67     * @param visibility Measures how much this sprite is visible. It gives its
68     * Z value on the graphics scene.
69     */
70   CavalrySprite(const QString &svgid,
71                  unsigned int width,
72                  unsigned int height,
73                  unsigned int nbFrames,
74                  unsigned int nbDirs,
75                  double zoom,
76                  BackGnd* aBackGnd,
77                  unsigned int visibility=200);
78 
79   /** The default destructor */
~CavalrySprite()80     ~CavalrySprite() override {}
81 
82 /**
83   * This function chooses the approach mode of a cavalry sprite towards its
84   * destination:
85   * if the distance between the origin and the destination is higher than half
86   * the size of the map and if the origin and destination countries comunicate,
87   * then the sprite should choose an approach by left or right, through the
88   * edge of the map.
89   */
90   void setupTravel(GameLogic::Country* src, GameLogic::Country* dest, const QPointF* dpcav=0) override;
91 
92   /**
93     * Gets the number of armies represented by a cavalry: 5
94     * @return the number of armies represented by a cavalry: 5
95     */
nbArmies()96   inline unsigned int nbArmies() const override {return m_nbArmies;}
97 
98 private:
99     static const unsigned int m_nbArmies = 5;
100 };
101 
102 }
103 
104 #endif
105