/
Bet.php
40 lines (35 loc) · 1.12 KB
/
Bet.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<?php
namespace ApostaAiApi\Models;
use ApostaAiApi\Models\Base\Bet as BaseBet;
/**
* Skeleton subclass for representing a row from the 'bet' table.
*
*
*
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*
*/
class Bet extends BaseBet
{
const GOLD_MEDAL_VALUE = 10;
const SILVER_MEDAL_VALUE = 5;
const BRONZE_MEDAL_VALUE = 1;
public function submitResult($participantId, $result) {
// Got the participant right
if ($this->getChosenParticipantId() === $participantId) {
// Got the result right
if ($this->getChosenResult() === $result) {
$this->setMedal("gold");
$this->getUser()->addScore(self::GOLD_MEDAL_VALUE);
} else {
$this->setMedal("silver");
$this->getUser()->addScore(self::SILVER_MEDAL_VALUE);
}
} else {
$this->setMedal("bronze");
$this->getUser()->addScore(self::BRONZE_MEDAL_VALUE);
}
}
}