mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-11-26 09:33:49 +01:00
Merge pull request #2760 from jamie-mac/fix/slots
Fixes issue with incorrect result in slots, and corrects the direction of the reel spin
This commit is contained in:
commit
4a1e3e75ec
@ -159,18 +159,18 @@ export function SlotMachine(props: IProps): React.ReactElement {
|
|||||||
const copy = index.slice();
|
const copy = index.slice();
|
||||||
for (let i = 0; i < copy.length; i++) {
|
for (let i = 0; i < copy.length; i++) {
|
||||||
if (copy[i] === locks[i] && !stoppedOne) continue;
|
if (copy[i] === locks[i] && !stoppedOne) continue;
|
||||||
copy[i] = (copy[i] + 1) % symbols.length;
|
copy[i] = (copy[i] - 1 >= 0) ? copy[i] - 1 : symbols.length - 1;
|
||||||
stoppedOne = true;
|
stoppedOne = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
setIndex(copy);
|
setIndex(copy);
|
||||||
|
|
||||||
if (stoppedOne && copy.every((e, i) => e === locks[i])) {
|
if (stoppedOne && copy.every((e, i) => e === locks[i])) {
|
||||||
checkWinnings();
|
checkWinnings(getTable(copy, symbols));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function getTable(): string[][] {
|
function getTable(index:number[], symbols:string[]): string[][] {
|
||||||
return [
|
return [
|
||||||
[
|
[
|
||||||
symbols[(index[0] + symbols.length - 1) % symbols.length],
|
symbols[(index[0] + symbols.length - 1) % symbols.length],
|
||||||
@ -209,8 +209,7 @@ export function SlotMachine(props: IProps): React.ReactElement {
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
function checkWinnings(): void {
|
function checkWinnings(t:string[][]): void {
|
||||||
const t = getTable();
|
|
||||||
const getPaylineData = function (payline: number[][]): string[] {
|
const getPaylineData = function (payline: number[][]): string[] {
|
||||||
const data = [];
|
const data = [];
|
||||||
for (const point of payline) {
|
for (const point of payline) {
|
||||||
@ -267,7 +266,7 @@ export function SlotMachine(props: IProps): React.ReactElement {
|
|||||||
setInvestment(investment);
|
setInvestment(investment);
|
||||||
}
|
}
|
||||||
|
|
||||||
const t = getTable();
|
const t = getTable(index, symbols);
|
||||||
// prettier-ignore
|
// prettier-ignore
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
@ -288,7 +287,7 @@ export function SlotMachine(props: IProps): React.ReactElement {
|
|||||||
disabled={!canPlay}
|
disabled={!canPlay}
|
||||||
>Spin!</Button>)}}
|
>Spin!</Button>)}}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<Typography variant="h4">{status}</Typography>
|
<Typography variant="h4">{status}</Typography>
|
||||||
<Typography>Pay lines</Typography>
|
<Typography>Pay lines</Typography>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user