So i found this JS 21 dice game on github, it just rolls 2 dice, and checks for a double roll.
If the plater gets 3 doubles in a roll, they will recieve a message to go to jail ( i want to change this to either a reward of some sort or a 5 minute time out).
also it needs to work as a per user roll process.. i have no experience with JS.
[code]
var dice = {
doubles: 0,
roll : function() {
var x = Math.floor(Math.random() * ((6 - 1) + 1) + 1);
var y = Math.floor(Math.random() * ((6 - 1) + 1) + 1);
var dicetotal = x + y;
$('.dice1').attr('id', "dice" + x);
$('.dice2').attr('id', "dice" + y);
if (x == y) { //<----checking if there is a double
this.doubles++;
//<---increment double count
if(this.doubles%3==0) $('.out').attr('id', "jail");
Now reroll the dice, but if you hit 3 doubles in a row, you get 5 minute TIME OUT!.
this.roll();
}
};
[/code]
A guy with little JS suggested this code should use -
var user1 = new dice();
var user2 = new dice();
...
user1.roll();
user2.roll();
Any help appreciated, ThankYou.
remember i have 0 experience with JS.