curly4

3x test2

Dec 10th, 2021
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // Updates to engine state
  2. engine.onUpdate = function(prevState) {
  3. if (engine.gameState !== prevState.gameState) {
  4. switch (engine.gameState) {
  5. case 'STARTING':
  6. onStarting();
  7. break;
  8. case 'IN_PROGRESS':
  9. onStarted();
  10. break;
  11. case 'ENDED':
  12. onEnded();
  13. break;
  14. }
  15. }
  16. };
  17.  
  18. let bet = 1;
  19. let autoCashOut = 3;
  20. const accountChase = 3;
  21. const minWagered = 30;
  22. let variance = 0.3;
  23.  
  24. let playerIndex = 0;
  25. let totalWagered = 0;
  26. let betSize;
  27.  
  28. function onStarting() {
  29. if (engine.balance >= bet) {
  30. engine.placeBet(bet, autoCashOut).catch(console.error);
  31. }
  32. playerIndex = 0;
  33. totalWagered = 0;
  34. }
  35.  
  36. function onStarted() {
  37. console.log('Game started!');
  38. for (playerIndex = 0; playerIndex < engine.players.length; playerIndex++) {
  39. betSize = engine.players[playerIndex].bet;
  40. totalWagered += betSize;
  41. betSize = 0;
  42. }
  43. console.log("Total Wagered: " + totalWagered + " mETH");
  44. autoCashOut = 0;
  45. }
  46.  
  47. function onEnded() {
  48. console.log('Game crashed at ' + engine.multiplier);
  49. if (totalWagered >= minWagered) {
  50. bet = 1;
  51. autoCashOut = accountChase + (Math.floor(((Math.random() * variance) * 100)) / 100);
  52. } else {
  53. bet = 0;
  54. }
  55. }
Add Comment
Please, Sign In to add comment