99 lines
2.0 KiB
PHP
99 lines
2.0 KiB
PHP
<?php namespace MapGuesser\PersistentData\Model;
|
|
|
|
use SokoWeb\PersistentData\Model\Model;
|
|
|
|
class UserInChallenge extends Model
|
|
{
|
|
protected static string $table = 'user_in_challenge';
|
|
|
|
protected static array $fields = ['user_id', 'challenge_id', 'current_round', 'time_left', 'is_owner'];
|
|
|
|
protected static array $relations = ['user' => User::class, 'challenge' => Challenge::class];
|
|
|
|
private ?User $user = null;
|
|
|
|
private ?int $userId = null;
|
|
|
|
private ?Challenge $challenge = null;
|
|
|
|
private ?int $challengeId = null;
|
|
|
|
private int $currentRound = 0;
|
|
|
|
private ?int $timeLeft = null;
|
|
|
|
private bool $isOwner = false;
|
|
|
|
public function setUser(User $user): void
|
|
{
|
|
$this->user = $user;
|
|
}
|
|
|
|
public function setUserId(int $userId): void
|
|
{
|
|
$this->userId = $userId;
|
|
}
|
|
|
|
public function setChallenge(Challenge $challenge): void
|
|
{
|
|
$this->challenge = $challenge;
|
|
}
|
|
|
|
public function setChallengeId(int $challengeId): void
|
|
{
|
|
$this->challengeId = $challengeId;
|
|
}
|
|
|
|
public function setCurrentRound(int $currentRound): void
|
|
{
|
|
$this->currentRound = $currentRound;
|
|
}
|
|
|
|
public function setTimeLeft(?int $timeLeft): void
|
|
{
|
|
if (isset($timeLeft)) {
|
|
$this->timeLeft = max(0, $timeLeft);
|
|
}
|
|
}
|
|
|
|
public function setIsOwner(bool $isOwner): void
|
|
{
|
|
$this->isOwner = $isOwner;
|
|
}
|
|
|
|
public function getUser(): ?User
|
|
{
|
|
return $this->user;
|
|
}
|
|
|
|
public function getUserId(): ?int
|
|
{
|
|
return $this->userId;
|
|
}
|
|
|
|
public function getChallenge(): ?Challenge
|
|
{
|
|
return $this->challenge;
|
|
}
|
|
|
|
public function getChallengeId(): ?int
|
|
{
|
|
return $this->challengeId;
|
|
}
|
|
|
|
public function getCurrentRound(): int
|
|
{
|
|
return $this->currentRound;
|
|
}
|
|
|
|
public function getTimeLeft(): ?int
|
|
{
|
|
return $this->timeLeft;
|
|
}
|
|
|
|
public function getIsOwner(): bool
|
|
{
|
|
return $this->isOwner;
|
|
}
|
|
}
|