user7184660
user7184660

Reputation:

Javascript betting game issue, how to code gaming logic

http://codepen.io/hokaien/pen/jVgeGQ

Example: https://csgo500.com

if ( options[index] === wantTo ) 
    {
          var el = document.getElementById('number');
          var res = originalNumber+=(amountBet*wantTo);
          el.textContent= res;
    }  
}

I have this wheel betting game. User types in Wager and Number to bet on. The wheel spins. Wager is subtracted from balance. If user bets on '2' and lands on 2, User gets Wager*2.

How do I code a 'wager now on 2', 'wager now on 3', 'wager now on 5' button such that only when the user clicks it he enters the next round with the wager on that number?

Current Problems: 1. User can type wager with no number to bet on and his credits will be subtracted. ( solved )

var test2 =Number(document.getElementById("wantTo").value)
  var test3 = Number(document.getElementById("wantTo"))

  if ( test2 < 1, test3 != options) {
  }
    else {
  var el = document.getElementById('number');
        var res = originalNumber-=amountBet;
        el.textContent= res; 
}
  1. User can't bet on multiple numbers.
  2. User enters every round.
  3. User can change wager and number while wheel is spinning ( solved )

Upvotes: 0

Views: 589

Answers (1)

404answernotfound
404answernotfound

Reputation: 771

1) make a conditional that check the input for a value, if there is no value avoid taking credit from the user

2) again, additional logic required, probably to check an array of values against the wheel returned value

3) additional logic that probably needs a mechanism activated by the user so he can play, maybe when the value is inserted in the inputs, solving the problems before this one

4) you can disable the input when the wheel event starts with javascript like:

document.getElementById('yourElementId').disabled = true;

Upvotes: 1

Related Questions