File "HeadTail.php"

Full Path: /home/trinadezambia/public_html/gambling/app/Games/HeadTail.php
File size: 824 bytes
MIME-type: text/x-php
Charset: utf-8

<?php

namespace App\Games;

use App\Constants\Status;

class HeadTail extends Game
{
    protected $alias = 'head_tail';
    protected $resultShowOnStart = true;
    protected $extraValidationRule = [
        'choose' => 'required|in:head,tail'
    ];

    protected function gameResult()
    {
        $probableWin = $this->demoPlay
            ? $this->game->probable_win_demo
            : $this->game->probable_win;
    
        $random = mt_rand(0, 100);

        if ($random <= $probableWin) {
            $winLossData['win_status'] = Status::WIN;
            $winLossData['result'] = $this->request->choose;
        } else {
            $winLossData['win_status'] = Status::LOSS;
            $winLossData['result'] = $this->request->choose == 'head' ? 'tail' : 'head';
        }
        return $winLossData;
    }
}