Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[High Roller] Add function to return dice rolls #22

Open
Alonski opened this issue Sep 5, 2019 · 0 comments
Open

[High Roller] Add function to return dice rolls #22

Alonski opened this issue Sep 5, 2019 · 0 comments
Assignees
Labels
bug Something isn't working 📦 DappHighRoller

Comments

@Alonski
Copy link
Member

Alonski commented Sep 5, 2019

Currently the highRoller() function is returning 2 numbers as playerFirstTotal and playerSecondTotal.
We should create an intermediate function that returns 2 number[2] arrays
This creates weird UI where all rolls seem to resolve to double dice rolls:

getDieNumbers(totalSum: number): [number, number] {
  // Choose result for each die.
  if (totalSum === 12) {
    return [6, 6];
  }

  if (totalSum > 2 && totalSum < 12) {
    return [Math.floor(totalSum / 2), Math.ceil(totalSum / 2)];
  }

  if (totalSum > 2 && totalSum % 2 === 0) {
    return [Math.floor(totalSum / 2) - 1, Math.ceil(totalSum / 2) + 1];
  }

  return [totalSum / 2, totalSum / 2];
}

So a roll of 6 on the contract will always show [3,3] even if it was [6,0]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working 📦 DappHighRoller
Projects
None yet
1 participant