Exemple #1
0
 public static function Roll($chance)
 {
     $coinCode = Input::get('coinCode');
     $betSize = Input::get('betsize');
     $profit = Input::get('profit');
     $payout = Input::get('payout');
     $roll = rand(1, 100);
     if ($roll < $chance) {
         $result = 'Win';
     } else {
         $result = 'Lose';
     }
     $wallet_balance = strtolower($coinCode) . "_wallet_balance";
     if (Auth::user()->{$wallet_balance} >= $betSize) {
         if ($result == 'Win') {
             $balance = Coin::Give($coinCode, $profit);
         } else {
             $balance = Coin::Take($coinCode, $betSize);
         }
         History::Add($betSize, $payout, $profit, $coinCode);
     } else {
         $result = "No Funds";
         $balance = Auth::user()->{$wallet_balance};
     }
     return json_encode(['result' => $result, 'profit' => $balance]);
 }