Show winning top with three same values in slot machine.
This commit is contained in:
parent
5f932a8828
commit
59b4c5dad9
1 changed files with 9 additions and 4 deletions
|
@ -47,21 +47,24 @@ const auto &kEmoji = ::Stickers::DicePacks::kSlotString;
|
||||||
return kShifts[partIndex] + inPartIndex;
|
return kShifts[partIndex] + inPartIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[[nodiscard]] int ComputePartValue(int value, int partIndex) {
|
||||||
|
return ((value - 1) >> (partIndex * 2)) & 0x03; // 0..3
|
||||||
|
}
|
||||||
|
|
||||||
[[nodiscard]] int ComputeComplexIndex(int value, int partIndex) {
|
[[nodiscard]] int ComputeComplexIndex(int value, int partIndex) {
|
||||||
Expects(value > 0 && value <= 64);
|
Expects(value > 0 && value <= 64);
|
||||||
|
|
||||||
if (value == kWinValue) {
|
if (value == kWinValue) {
|
||||||
return ComplexIndex(partIndex, kSevenWinIndex);
|
return ComplexIndex(partIndex, kSevenWinIndex);
|
||||||
}
|
}
|
||||||
const auto bits = ((value - 1) >> (partIndex * 2)) & 0x03; // 0..3
|
|
||||||
return ComplexIndex(partIndex, [&] {
|
return ComplexIndex(partIndex, [&] {
|
||||||
switch (bits) {
|
switch (ComputePartValue(value, partIndex)) {
|
||||||
case 0: return kBarIndex;
|
case 0: return kBarIndex;
|
||||||
case 1: return kBerriesIndex;
|
case 1: return kBerriesIndex;
|
||||||
case 2: return kLemonIndex;
|
case 2: return kLemonIndex;
|
||||||
case 3: return kSevenIndex;
|
case 3: return kSevenIndex;
|
||||||
}
|
}
|
||||||
Unexpected("Bits value in ComputeComplexIndex.");
|
Unexpected("Part value value in ComputeComplexIndex.");
|
||||||
}());
|
}());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -115,7 +118,9 @@ void SlotMachine::resolveEnds(int value) {
|
||||||
if (value <= 0 || value > 64) {
|
if (value <= 0 || value > 64) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (value == kWinValue) {
|
const auto firstPartValue = ComputePartValue(value, 0);
|
||||||
|
if (ComputePartValue(value, 1) == firstPartValue
|
||||||
|
&& ComputePartValue(value, 2) == firstPartValue) { // Three in a row.
|
||||||
resolve(_end[0], kWinBackIndex, kWinBackIndex, true);
|
resolve(_end[0], kWinBackIndex, kWinBackIndex, true);
|
||||||
}
|
}
|
||||||
for (auto i = 0; i != 3; ++i) {
|
for (auto i = 0; i != 3; ++i) {
|
||||||
|
|
Loading…
Reference in a new issue