Peter Muturi 1 年之前
父節點
當前提交
31a815be58
共有 2 個文件被更改,包括 17 次插入5 次删除
  1. 1 1
      resources/views/app/markup.blade.php
  2. 16 4
      resources/views/app/script.blade.php

+ 1 - 1
resources/views/app/markup.blade.php

@@ -3,7 +3,7 @@
     <h4 class="title">Craps <i class="fas fa-dice"></i></h4>
     <div class="row">
       <div class="col-1">
-        <button class="btn btn-danger shadow" @click="resetGame" :disabled="!game || rolled"><h5 class="m-0"><i class="fal fa-undo"></i></h5> Reset</button>
+        <button class="btn btn-danger shadow" @click="resetPassGame" :disabled="!game || rolled"><h5 class="m-0"><i class="fal fa-undo"></i></h5> Reset</button>
       </div>
       <div class="col-8">
         <div class="position-relative">

+ 16 - 4
resources/views/app/script.blade.php

@@ -44,7 +44,7 @@
                 if (self.passchips.indexOf(self.selectedChip) <= -1) {
                     self.passchips.push(self.selectedChip);
                 };
-                self.totalCounter();
+                self.total -= self.selectedChip;
             },
             onComeLine: function() {
                 var self = this;
@@ -55,7 +55,7 @@
                 if (self.currentComeChips.indexOf(self.selectedChip) <= -1) {
                     self.currentComeChips.push(self.selectedChip);
                 };
-                self.totalCounter();
+                self.total -= self.selectedChip;
             },
             onOddsLine: function() {
                 var self = this;
@@ -72,7 +72,7 @@
                         self.oddschips.push(self.selectedChip);
                     };
                 }
-                self.totalCounter();
+                self.total -= self.oddsChipCount;
             },
             resetGame: function() {
                 var self = this;
@@ -81,7 +81,6 @@
                 self.passPoint = 0;
                 self.oddschips = [];
                 self.oddsChipCount = 0;
-                self.total = 10000;
                 self.rolled = false;
                 setTimeout(function() {
                     if (self.comePoints.length == 0) {
@@ -89,6 +88,13 @@
                     };
                 }, 1)
             },
+            resetPassGame: function() {
+              var self = this;
+              self.total += self.passChipCount;
+              self.passChipCount = 0;
+              self.passchips = [];
+              self.game = false;
+            },
             resetComeGame: function() {
                 var self = this;
                 self.currentComeChips = [];
@@ -98,6 +104,7 @@
             },
             resetOddsGame: function () {
               var self = this;
+              self.total += self.oddsChipCount;
               self.oddsChipCount = 0;
               self.oddschips = [];
             },
@@ -148,6 +155,7 @@
                 var totalDice = self.dice1 + self.dice2;
                 if (totalDice == 7 || totalDice == 11) {
                     self.alert = 'Game Won! You rolled ' + totalDice;
+                    self.total += (self.passChipCount * 2);
                     self.resetGame();
                 } else if (totalDice == 2 || totalDice == 3 || totalDice == 12) {
                     self.alert = 'Game Lost! You rolled ' + totalDice;
@@ -163,6 +171,7 @@
                 if (self.passChipCount > 0) { //ensure pass game is ongoing
                     if (totalDice == self.passPoint) {
                         self.alert = 'Game Won! You rolled ' + totalDice;
+                        self.total += (self.passChipCount * 2);
                         if (self.oddsChipCount > 0) {
                             self.oddsGame();
                         }else {
@@ -184,6 +193,7 @@
                     for (var i = 0; i < self.comePoints.length; i++) {
                         if (totalDice == self.comePoints[i].move) {
                             multipleAlerts.push('Come Game Won! You rolled ' + totalDice);
+                            self.total += (self.comePoints[i].chipCount * 2);
                             self.comePoints.splice(i, 1);
                         } else if (totalDice == 7) {
                             multipleAlerts.push('Come Game Lost! You rolled ' + totalDice);
@@ -206,6 +216,7 @@
                 if (self.currentComeChips.length > 0) {
                     if (_totalDice == 7 || _totalDice == 11) {
                         self.comeAlert = 'Come Game Won! You rolled ' + _totalDice + '\n';
+                        self.total += (self.currentComeChips * 2);
                         if (self.comePoints.length == 0) {
                             self.resetComeGame();
                         }
@@ -231,6 +242,7 @@
                 var totalDice = self.dice1 + self.dice2;
                 if (totalDice == self.passPoint) {
                     self.oddsAlert = 'Odds Game Won! You rolled ' + totalDice;
+                    self.total += (self.oddsChipCount * 2);
                     self.resetGame();
                 } else if (totalDice == 7) {
                     self.oddsAlert = 'Odds Game Lost! You rolled ' + totalDice;