Skip to content

Commit 7da4b4b

Browse files
committed
merged from backup
falling pieces still strike
1 parent b0170cd commit 7da4b4b

File tree

2 files changed

+13
-11
lines changed

2 files changed

+13
-11
lines changed

model/JewelStrike.cpp

+11-9
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ JewelStrike::JewelStrike(Board &board, BoardCallback * callback)
1515

1616

1717

18-
bool JewelStrike::findMatch(BoardPos newPos, Jewel::COLOR newColor, BoardPos ignorePos) const
18+
int JewelStrike::findMatch(BoardPos newPos, Jewel::COLOR newColor, BoardPos ignorePos) const
1919
{
20+
int strikeLen = 0;
2021
//@bug remove when jewels falling implemented
2122
if (newColor == Jewel::NO_COLOR)
2223
return false;
23-
bool match = false;
2424
//newJewel will be at posIndex
2525
//Jewel &newJewel = m_board.getJewel(m_positions[ 1 - posIndex]);
2626
//Jewel &otherJewel = m_board.getJewel(m_positions[ posIndex]);
@@ -53,17 +53,19 @@ bool JewelStrike::findMatch(BoardPos newPos, Jewel::COLOR newColor, BoardPos ign
5353
}
5454
if (len[0] + len[1] >= MIN_LEN)
5555
{
56-
if (m_callback)
57-
{
5856
cur += directions[d];
5957
for (short l = 0; l < len[0] + len[1]; l++)
6058
{
61-
m_callback->kill(cur);
59+
{
60+
if (m_callback)
61+
m_callback->kill(cur);
62+
strikeLen++;
63+
64+
}
6265
cur += directions[d];
6366
}
64-
}
65-
match = true;
67+
6668
}
67-
}
68-
return match;
69+
} //directions
70+
return strikeLen;
6971
}

model/JewelStrike.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ class JewelStrike
3737
* @param newColor
3838
* @param ignorePos in case of a swap, don't check the position color, as for sure it does
3939
* not match. If invalid, argument is not taken into account
40-
* @return whether any strike is created
40+
* @return the sum of the lengths of the strike scored
4141
*/
42-
bool findMatch(BoardPos newPos, Jewel::COLOR newColor, BoardPos ignorePos = BoardPos()) const;
42+
int findMatch(BoardPos newPos, Jewel::COLOR newColor, BoardPos ignorePos = BoardPos()) const;
4343

4444
private:
4545
Board& m_board;

0 commit comments

Comments
 (0)