File indexing completed on 2024-04-21 04:04:03

0001 /*
0002     KShisen - A japanese game similar to Mahjongg
0003     SPDX-FileCopyrightText: 2016 Frederik Schwarzer <schwarzer@kde.org>
0004 
0005     SPDX-License-Identifier: GPL-2.0-or-later
0006 */
0007 
0008 #include "types.h"
0009 
0010 #ifndef KSHISEN_MOVE_H
0011 #define KSHISEN_MOVE_H
0012 
0013 namespace KShisen
0014 {
0015 /**
0016  * @brief Class holding a move on the board made by the player
0017  *
0018  * Contains all the information needed to undo or redo a move.
0019  */
0020 class Move
0021 {
0022 public:
0023     Move(TilePos tilePos1, TilePos tilePos2, int tile1, int tile2);
0024     Move(TilePos tilePos1, TilePos tilePos2, int tile1, int tile2, Slide const & slide);
0025 
0026     int x1() const;
0027     int y1() const;
0028     int x2() const;
0029     int y2() const;
0030     int tile1() const;
0031     int tile2() const;
0032     bool hasSlide() const;
0033     Slide slide() const;
0034     int slideX1() const;
0035     int slideY1() const;
0036     int slideX2() const;
0037     int slideY2() const;
0038 
0039     /**
0040      * @brief Swaps the two tiles involved in a move.
0041      *
0042      * This is needed for undoing a move in case both tiles are in the same column.
0043      */
0044     void swapTiles();
0045 
0046 private:
0047     TilePos m_tilePos1; ///< coordinates of the first tile that matched
0048     TilePos m_tilePos2; ///< coordinates of the second tile that matched
0049     int m_tile1; ///< type of tile at first set of coordinates
0050     int m_tile2; ///< type of tile at second set of coordinates
0051     bool m_hasSlide; ///< if we performed a slide during the move
0052     Slide m_slide; ///< original x coordinate of the last slided tile
0053 };
0054 } // namespace KShisen
0055 
0056 #endif // KSHISEN_MOVE_H
0057 
0058 // vim: expandtab:tabstop=4:shiftwidth=4
0059 // kate: space-indent on; indent-width 4