Skip to content

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

@Alonski

Description

@Alonski

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]

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions