File indexing completed on 2024-04-14 04:01:49

0001 /***************************************************************************
0002                           cavalrysprite.h  -  description
0003                              -------------------
0004     begin                : 
0005     copyright            : (C) 2003-2007 by Gael de Chalendar
0006     email                : kleag@free.fr
0007  ***************************************************************************/
0008 
0009 /***************************************************************************
0010  *                                                                         *
0011  *   This program is free software; you can redistribute it and/or modify  *
0012  *   it under the terms of the GNU General Public License as published by  *
0013  *   the Free Software Foundation; either either version 2
0014    of the License, or (at your option) any later version.of the License, or     *
0015  *   (at your option) any later version.                                   *
0016  *                                                                         *
0017  *   You should have received a copy of the GNU General Public License
0018  *   along with this program; if not, write to the Free Software
0019  *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
0020  *   02110-1301, USA
0021  ***************************************************************************/
0022 
0023 
0024 #ifndef KSIRKCAVALRYSPRITE_H
0025 #define KSIRKCAVALRYSPRITE_H
0026 
0027 #include "armysprite.h"
0028 
0029 namespace Ksirk {
0030 
0031 namespace GameLogic
0032 {
0033   class Country;
0034 }
0035 
0036 /**
0037   * A CavalrySpritei is an army sprite that represents 5 armies
0038   * @author Gaƫl de Chalendar
0039   */
0040 class CavalrySprite : public ArmySprite
0041 {
0042 public:
0043   /**
0044     * This simplified constructor allows to create a new @ref CavalrySprite with
0045     * default values for svg pool id and skin elements names
0046     * @param zoom The current zoom factor
0047     * @param aBackGnd The background giving info about the world geometry and
0048     * access to the underlying QGraphicsScene
0049     * @param visibility Measures how much this sprite is visible. It gives its
0050     * Z value on the graphics scene.
0051     */
0052   CavalrySprite(double zoom,
0053                 BackGnd* aBackGnd,
0054                 unsigned int visibility = 200);
0055 
0056   /**
0057     * This constructor allows to create a new @ref AnimSprite whose images are
0058     * taken from the given file name with the given number of frames and
0059     * number of look directions
0060     * @param svgid The id of the SVG element from which to load images
0061     * @param aBackGnd The background giving info about the world geometry and
0062     * access to the underlying QGraphicsScene
0063     * @param nbFrames The number of different frames in this sprite animation, 
0064     * thus the number of columns in the sprite image
0065     * @param nbDirs The number of different views on the sprite, 
0066     * thus the number of rows in the sprite image
0067     * @param visibility Measures how much this sprite is visible. It gives its
0068     * Z value on the graphics scene.
0069     */
0070   CavalrySprite(const QString &svgid,
0071                  unsigned int width,
0072                  unsigned int height,
0073                  unsigned int nbFrames,
0074                  unsigned int nbDirs,
0075                  double zoom,
0076                  BackGnd* aBackGnd,
0077                  unsigned int visibility=200);
0078 
0079   /** The default destructor */
0080     ~CavalrySprite() override {}
0081 
0082 /**
0083   * This function chooses the approach mode of a cavalry sprite towards its
0084   * destination:
0085   * if the distance between the origin and the destination is higher than half
0086   * the size of the map and if the origin and destination countries comunicate,
0087   * then the sprite should choose an approach by left or right, through the
0088   * edge of the map.
0089   */
0090   void setupTravel(GameLogic::Country* src, GameLogic::Country* dest, const QPointF* dpcav=nullptr) override;
0091 
0092   /**
0093     * Gets the number of armies represented by a cavalry: 5
0094     * @return the number of armies represented by a cavalry: 5
0095     */
0096   inline unsigned int nbArmies() const override {return m_nbArmies;}
0097 
0098 private:
0099     static const unsigned int m_nbArmies = 5;
0100 };
0101 
0102 }
0103 
0104 #endif