Skip to content

Commit

Permalink
Add type hints
Browse files Browse the repository at this point in the history
  • Loading branch information
lulunac27a committed Apr 16, 2024
1 parent 976237c commit 3795986
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions dice-game-webapp/src/Main.hx
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@ import js.Browser;

class Main {
static function main() {
var appContent = cast(Browser.document.getElementById("app"), js.html.DivElement);
var rollButton = cast(Browser.document.getElementById("roll"), js.html.ButtonElement);
var diceInput = cast(Browser.document.getElementById("dice"), js.html.InputElement);
var appContent:js.html.DivElement = cast(Browser.document.getElementById("app"), js.html.DivElement);
var rollButton:js.html.ButtonElement = cast(Browser.document.getElementById("roll"), js.html.ButtonElement);
var diceInput:js.html.InputElement = cast(Browser.document.getElementById("dice"), js.html.InputElement);
rollButton.onclick = (event) -> {
var numberOfDice = Std.parseInt(diceInput.value);
var numberOfDice:Int = Std.parseInt(diceInput.value);
appContent.innerHTML = "";
var dice = [];
var dice:Array<Int> = [];
for (i in 0...numberOfDice) {
dice[i] = Std.random(6) + 1;
var newDice = js.Browser.document.createElement("div");
var newDice:js.html.DivElement = cast(js.Browser.document.createElement("div"), js.html.DivElement);
newDice.id = 'dice-${i + 1}';
newDice.textContent = 'Dice ${i + 1}: ${dice[i]}';
appContent.appendChild(newDice);
Expand Down

0 comments on commit 3795986

Please sign in to comment.