MAPG-235 basic gameflow works
This commit is contained in:
1 parent
5daed10036
commit
93f8fc3f34
10 files changed
+209
-55
No files matched your search
@@ -4,9 +4,9 @@ use MapGuesser\Util\Geo\Position;
|
||||
|
||||
class Guess extends Model
|
||||
{
|
||||
protected static string $table = 'guess';
|
||||
protected static string $table = 'guesses';
|
||||
|
||||
protected static array $fields = ['user_id', 'place_in_challenge_id', 'lat', 'lng', 'time_spent'];
|
||||
protected static array $fields = ['user_id', 'place_in_challenge_id', 'lat', 'lng', 'score', 'distance', 'time_spent'];
|
||||
|
||||
protected static array $relations = ['user' => User::class, 'place_in_challenge' => PlaceInChallenge::class];
|
||||
|
||||
@@ -20,7 +20,16 @@ class Guess extends Model
|
||||
|
||||
private Position $position;
|
||||
|
||||
private int $timeSpent;
|
||||
private int $score = 0;
|
||||
|
||||
private int $distance = 0;
|
||||
|
||||
private int $timeSpent = 0;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->position = new Position(0.0, 0.0);
|
||||
}
|
||||
|
||||
public function setUser(User $user): void
|
||||
{
|
||||
@@ -57,6 +66,16 @@ class Guess extends Model
|
||||
$this->position->setLng($lng);
|
||||
}
|
||||
|
||||
public function setScore(int $score): void
|
||||
{
|
||||
$this->score = $score;
|
||||
}
|
||||
|
||||
public function setDistance(int $distance): void
|
||||
{
|
||||
$this->distance = $distance;
|
||||
}
|
||||
|
||||
public function setTimeSpent(int $timeSpent): void
|
||||
{
|
||||
$this->timeSpent = $timeSpent;
|
||||
@@ -97,6 +116,16 @@ class Guess extends Model
|
||||
return $this->position->getLng();
|
||||
}
|
||||
|
||||
public function getScore(): int
|
||||
{
|
||||
return $this->score;
|
||||
}
|
||||
|
||||
public function getDistance(): int
|
||||
{
|
||||
return $this->distance;
|
||||
}
|
||||
|
||||
public function getTimeSpent(): ?int
|
||||
{
|
||||
return $this->timeSpent;
|
||||
|
||||
@@ -4,7 +4,7 @@ class UserInChallenge extends Model
|
||||
{
|
||||
protected static string $table = 'user_in_challenge';
|
||||
|
||||
protected static array $fields = ['user_id', 'challenge_id', 'round', 'score', 'time_left', 'is_owner'];
|
||||
protected static array $fields = ['user_id', 'challenge_id', 'round', 'time_left', 'is_owner'];
|
||||
|
||||
protected static array $relations = ['user' => User::class, 'challenge' => Challenge::class];
|
||||
|
||||
@@ -18,8 +18,6 @@ class UserInChallenge extends Model
|
||||
|
||||
private int $round = 0;
|
||||
|
||||
private int $score = 0;
|
||||
|
||||
private ?int $timeLeft = null;
|
||||
|
||||
private bool $isOwner = false;
|
||||
@@ -49,11 +47,6 @@ class UserInChallenge extends Model
|
||||
$this->round = $round;
|
||||
}
|
||||
|
||||
public function setScore(int $score): void
|
||||
{
|
||||
$this->score = $score;
|
||||
}
|
||||
|
||||
public function setTimeLeft(?int $timeLeft): void
|
||||
{
|
||||
if(isset($timeLeft)) {
|
||||
@@ -91,11 +84,6 @@ class UserInChallenge extends Model
|
||||
return $this->round;
|
||||
}
|
||||
|
||||
public function getScore(): int
|
||||
{
|
||||
return $this->score;
|
||||
}
|
||||
|
||||
public function getTimeLeft(): ?int
|
||||
{
|
||||
return $this->timeLeft;
|
||||
|
||||
Reference in new issue
Block a user