summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrederik Schwarzer <[email protected]>2016-05-14 01:05:50 +0200
committerFrederik Schwarzer <[email protected]>2016-05-14 01:05:50 +0200
commitf88dd6ae2ec2c273ebba0ceca49a90fb3894b838 (patch)
treeab09d99c6064bc794709f73cdf0dc7c20df3bb81
parent194fc542cdbc9398a311d31539a85551f9395362 (diff)
Refactor members.
-rw-r--r--src/move.cpp23
-rw-r--r--src/move.h3
2 files changed, 11 insertions, 15 deletions
diff --git a/src/move.cpp b/src/move.cpp
index c86e84c..5227c8a 100644
--- a/src/move.cpp
+++ b/src/move.cpp
@@ -22,10 +22,8 @@
namespace KShisen
{
Move::Move(TilePos const & tilePos1, TilePos const & tilePos2, int tile1, int tile2)
- : m_x1(tilePos1.x())
- , m_y1(tilePos1.y())
- , m_x2(tilePos2.x())
- , m_y2(tilePos2.y())
+ : m_tilePos1(tilePos1)
+ , m_tilePos2(tilePos2)
, m_tile1(tile1)
, m_tile2(tile2)
, m_hasSlide(false)
@@ -37,10 +35,8 @@ Move::Move(TilePos const & tilePos1, TilePos const & tilePos2, int tile1, int ti
}
Move::Move(TilePos const & tilePos1, TilePos const & tilePos2, int tile1, int tile2, int slideX1, int slideY1, int slideX2, int slideY2)
- : m_x1(tilePos1.x())
- , m_y1(tilePos1.y())
- , m_x2(tilePos2.x())
- , m_y2(tilePos2.y())
+ : m_tilePos1(tilePos1)
+ , m_tilePos2(tilePos2)
, m_tile1(tile1)
, m_tile2(tile2)
, m_hasSlide(true)
@@ -53,22 +49,22 @@ Move::Move(TilePos const & tilePos1, TilePos const & tilePos2, int tile1, int ti
int Move::x1() const
{
- return m_x1;
+ return m_tilePos1.x();
}
int Move::y1() const
{
- return m_y1;
+ return m_tilePos1.y();
}
int Move::x2() const
{
- return m_x2;
+ return m_tilePos2.x();
}
int Move::y2() const
{
- return m_y2;
+ return m_tilePos2.y();
}
int Move::tile1() const
@@ -108,8 +104,7 @@ int Move::slideY2() const
void Move::swapTiles()
{
- std::swap(m_x1, m_x2);
- std::swap(m_y1, m_y2);
+ std::swap(m_tilePos1, m_tilePos2);
std::swap(m_tile1, m_tile2);
}
}
diff --git a/src/move.h b/src/move.h
index 8f663bd..0eacc04 100644
--- a/src/move.h
+++ b/src/move.h
@@ -54,7 +54,8 @@ public:
void swapTiles();
private:
- int m_x1, m_y1, m_x2, m_y2; ///< coordinates of the two tiles that matched
+ TilePos m_tilePos1; ///< coordinates of the first tile that matched
+ TilePos m_tilePos2; ///< coordinates of the second tile that matched
int m_tile1; ///< type of tile at first set of coordinates
int m_tile2; ///< type of tile at second set of coordinates
bool m_hasSlide; ///< if we performed a slide during the move