new: usr: add mineseeker game to the symfony 4 project #3
This commit is contained in:
163
src/Entity/Gamer.php
Normal file
163
src/Entity/Gamer.php
Normal file
@@ -0,0 +1,163 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity;
|
||||
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
/**
|
||||
* @ORM\Entity(repositoryClass="App\Repository\GamerRepository")
|
||||
*/
|
||||
class Gamer
|
||||
{
|
||||
/**
|
||||
* @ORM\Id()
|
||||
* @ORM\GeneratedValue()
|
||||
* @ORM\Column(type="integer")
|
||||
*/
|
||||
private $id;
|
||||
|
||||
/**
|
||||
* @var string|null
|
||||
*
|
||||
* @ORM\Column(name="user_name", type="string", length=100, nullable=false)
|
||||
*/
|
||||
private $userName;
|
||||
|
||||
/**
|
||||
* @var string|null
|
||||
*
|
||||
* @ORM\Column(name="ip", type="string", length=20, nullable=true)
|
||||
*/
|
||||
private $ip;
|
||||
|
||||
/**
|
||||
* TODO
|
||||
* $ip='0.0.0.0';
|
||||
* $ip=$_SERVER['REMOTE_ADDR'];
|
||||
* $clientDetails = json_decode(file_get_contents("http://ipinfo.io/$ip/json"));
|
||||
* echo "You're logged in from: <b>" . $clientDetails->country . "</b>";
|
||||
*
|
||||
* function GetIP()
|
||||
* {
|
||||
* if ( getenv("HTTP_CLIENT_IP") ) {
|
||||
* $ip = getenv("HTTP_CLIENT_IP");
|
||||
* } elseif ( getenv("HTTP_X_FORWARDED_FOR") ) {
|
||||
* $ip = getenv("HTTP_X_FORWARDED_FOR");
|
||||
* if ( strstr($ip, ',') ) {
|
||||
* $tmp = explode(',', $ip);
|
||||
* $ip = trim($tmp[0]);
|
||||
* }
|
||||
* } else {
|
||||
* $ip = getenv("REMOTE_ADDR");
|
||||
* }
|
||||
* return $ip;
|
||||
* }
|
||||
*/
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*
|
||||
* @ORM\Column(name="country", type="string", length=100, nullable=true)
|
||||
*/
|
||||
private $country;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
* @see http://symfony.com/doc/current/components/http_foundation.html
|
||||
*
|
||||
* @ORM\Column(name="user_agent", type="string", length=255, nullable=true)
|
||||
*/
|
||||
private $userAgent;
|
||||
|
||||
/**
|
||||
* @var \DateTime
|
||||
*
|
||||
* @ORM\Column(name="conn_timestamp", type="datetime", nullable=false)
|
||||
*/
|
||||
private $connTimestamp;
|
||||
|
||||
public function getId(): ?int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string|null
|
||||
*/
|
||||
public function getUserName(): ?string
|
||||
{
|
||||
return $this->userName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string|null $userName
|
||||
*/
|
||||
public function setUserName(?string $userName): void
|
||||
{
|
||||
$this->userName = $userName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string|null
|
||||
*/
|
||||
public function getIp(): ?string
|
||||
{
|
||||
return $this->ip;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string|null $ip
|
||||
*/
|
||||
public function setIp(?string $ip): void
|
||||
{
|
||||
$this->ip = $ip;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getCountry(): string
|
||||
{
|
||||
return $this->country;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $country
|
||||
*/
|
||||
public function setCountry(string $country): void
|
||||
{
|
||||
$this->country = $country;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getUserAgent(): string
|
||||
{
|
||||
return $this->userAgent;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $userAgent
|
||||
*/
|
||||
public function setUserAgent(string $userAgent): void
|
||||
{
|
||||
$this->userAgent = $userAgent;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \DateTime
|
||||
*/
|
||||
public function getConnTimestamp(): \DateTime
|
||||
{
|
||||
return $this->connTimestamp;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \DateTime $connTimestamp
|
||||
*/
|
||||
public function setConnTimestamp(\DateTime $connTimestamp): void
|
||||
{
|
||||
$this->connTimestamp = $connTimestamp;
|
||||
}
|
||||
}
|
||||
70
src/Entity/Grid.php
Normal file
70
src/Entity/Grid.php
Normal file
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity;
|
||||
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
/**
|
||||
* @ORM\Entity(repositoryClass="App\Repository\GridRepository")
|
||||
*/
|
||||
class Grid
|
||||
{
|
||||
/**
|
||||
* @ORM\Id()
|
||||
* @ORM\GeneratedValue()
|
||||
* @ORM\Column(type="integer")
|
||||
*/
|
||||
private $id;
|
||||
|
||||
/**
|
||||
* @var PlayedGame|null
|
||||
*
|
||||
* @ORM\OneToOne(targetEntity="App\Entity\PlayedGame", inversedBy="grid", cascade={"persist"})
|
||||
*/
|
||||
private $playedGame;
|
||||
|
||||
/**
|
||||
* @var GridRow|null
|
||||
*
|
||||
* @ORM\OneToMany(targetEntity="App\Entity\GridRow", mappedBy="grid", cascade={"persist"})
|
||||
* @ORM\JoinColumn(name="grid_row", referencedColumnName="id", onDelete="CASCADE")
|
||||
*/
|
||||
private $gridRow;
|
||||
|
||||
public function getId(): ?int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return PlayedGame|null
|
||||
*/
|
||||
public function getPlayedGame()
|
||||
{
|
||||
return $this->playedGame;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param PlayedGame|null $playedGame
|
||||
*/
|
||||
public function setPlayedGame( $playedGame): void
|
||||
{
|
||||
$this->playedGame = $playedGame;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return GridRow|null
|
||||
*/
|
||||
public function getGridRow()
|
||||
{
|
||||
return $this->gridRow;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param GridRow|null $gridRow
|
||||
*/
|
||||
public function setGridRow( $gridRow): void
|
||||
{
|
||||
$this->gridRow = $gridRow;
|
||||
}
|
||||
}
|
||||
70
src/Entity/GridRow.php
Normal file
70
src/Entity/GridRow.php
Normal file
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity;
|
||||
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
/**
|
||||
* @ORM\Entity(repositoryClass="App\Repository\GridRowRepository")
|
||||
*/
|
||||
class GridRow
|
||||
{
|
||||
/**
|
||||
* @ORM\Id()
|
||||
* @ORM\GeneratedValue()
|
||||
* @ORM\Column(type="integer")
|
||||
*/
|
||||
private $id;
|
||||
|
||||
/**
|
||||
* @var Grid|null
|
||||
*
|
||||
* @ORM\ManyToOne(targetEntity="App\Entity\Grid", inversedBy="gridRow", cascade={"persist"})
|
||||
* @ORM\JoinColumn(name="grid", referencedColumnName="id", onDelete="CASCADE")
|
||||
*/
|
||||
private $grid;
|
||||
|
||||
/**
|
||||
* @var array|null
|
||||
*
|
||||
* @ORM\Column(name="grid_col", type="json_array", nullable=false)
|
||||
*/
|
||||
private $gridCol;
|
||||
|
||||
public function getId(): ?int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Grid|null
|
||||
*/
|
||||
public function getGrid()
|
||||
{
|
||||
return $this->grid;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Grid|null $grid
|
||||
*/
|
||||
public function setGrid( $grid): void
|
||||
{
|
||||
$this->grid = $grid;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array|null
|
||||
*/
|
||||
public function getGridCol()
|
||||
{
|
||||
return $this->gridCol;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array|null $gridCol
|
||||
*/
|
||||
public function setGridCol($gridCol): void
|
||||
{
|
||||
$this->gridCol = $gridCol;
|
||||
}
|
||||
}
|
||||
351
src/Entity/PlayedGame.php
Normal file
351
src/Entity/PlayedGame.php
Normal file
@@ -0,0 +1,351 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity;
|
||||
|
||||
use App\Application\Sonata\UserBundle\Entity\User;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
/**
|
||||
* @ORM\Entity(repositoryClass="App\Repository\PlayedGameRepository")
|
||||
*/
|
||||
class PlayedGame
|
||||
{
|
||||
/**
|
||||
* @ORM\Id()
|
||||
* @ORM\GeneratedValue()
|
||||
* @ORM\Column(type="integer")
|
||||
*/
|
||||
private $id;
|
||||
|
||||
/**
|
||||
* @var string|null
|
||||
*
|
||||
* @ORM\Column(name="game_assoc", type="string", length=50, nullable=false)
|
||||
*/
|
||||
private $gameAssoc;
|
||||
|
||||
/**
|
||||
* @var Grid|null
|
||||
*
|
||||
* @ORM\OneToOne(targetEntity="App\Entity\Grid", mappedBy="playedGame", cascade={"persist"})
|
||||
*/
|
||||
private $grid;
|
||||
|
||||
/**
|
||||
* @var User|null
|
||||
*
|
||||
* @ORM\ManyToOne(targetEntity="App\Application\Sonata\UserBundle\Entity\User")
|
||||
* @ORM\JoinColumn(name="red_id", referencedColumnName="id", nullable=true)
|
||||
*/
|
||||
private $red;
|
||||
|
||||
/**
|
||||
* @var Gamer|null
|
||||
*
|
||||
* @ORM\ManyToOne(targetEntity="App\Entity\Gamer")
|
||||
* @ORM\JoinColumn(name="red_anon", referencedColumnName="id", nullable=true)
|
||||
*/
|
||||
private $redAnon;
|
||||
|
||||
/**
|
||||
* @var User|null
|
||||
*
|
||||
* @ORM\ManyToOne(targetEntity="App\Application\Sonata\UserBundle\Entity\User")
|
||||
* @ORM\JoinColumn(name="blue_id", referencedColumnName="id", nullable=true)
|
||||
*/
|
||||
private $blue;
|
||||
|
||||
/**
|
||||
* @var Gamer|null
|
||||
*
|
||||
* @ORM\ManyToOne(targetEntity="App\Entity\Gamer")
|
||||
* @ORM\JoinColumn(name="blue_anon", referencedColumnName="id", nullable=true)
|
||||
*/
|
||||
private $blueAnon;
|
||||
|
||||
/**
|
||||
* @var int|null
|
||||
*
|
||||
* @ORM\Column(name="red_points", type="integer", length=5, nullable=true)
|
||||
*/
|
||||
private $redPoints;
|
||||
|
||||
/**
|
||||
* @var int|null
|
||||
*
|
||||
* @ORM\Column(name="blue_points", type="integer", length=5, nullable=true)
|
||||
*/
|
||||
private $bluePoints;
|
||||
|
||||
/**
|
||||
* @var boolean|null
|
||||
*
|
||||
* @ORM\Column(name="red_exploded_bomb", type="boolean", nullable=true)
|
||||
*/
|
||||
private $redExplodedBomb;
|
||||
|
||||
/**
|
||||
* @var boolean|null
|
||||
*
|
||||
* @ORM\Column(name="blue_exploded_bomb", type="boolean", nullable=true)
|
||||
*/
|
||||
private $blueExplodedBomb;
|
||||
|
||||
/**
|
||||
* @var string|null
|
||||
*
|
||||
* @ORM\Column(name="resign", type="string", length=7, nullable=true)
|
||||
*/
|
||||
private $resign;
|
||||
|
||||
/**
|
||||
* @var \DateTime|null
|
||||
*
|
||||
* @ORM\Column(name="created", type="datetime", nullable=true)
|
||||
*/
|
||||
private $created;
|
||||
|
||||
/**
|
||||
* @var \DateTime|null
|
||||
*
|
||||
* @ORM\Column(name="updated", type="datetime", nullable=true)
|
||||
*/
|
||||
private $updated;
|
||||
|
||||
/**
|
||||
* @var Step|null
|
||||
*
|
||||
* @ORM\OneToMany(targetEntity="App\Entity\Step", mappedBy="playedGame")
|
||||
* @ORM\JoinColumn(name="step", referencedColumnName="id", nullable=true)
|
||||
*/
|
||||
private $step;
|
||||
|
||||
public function getId(): ?int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string|null
|
||||
*/
|
||||
public function getGameAssoc(): ?string
|
||||
{
|
||||
return $this->gameAssoc;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string|null $gameAssoc
|
||||
*/
|
||||
public function setGameAssoc(?string $gameAssoc): void
|
||||
{
|
||||
$this->gameAssoc = $gameAssoc;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Grid|null
|
||||
*/
|
||||
public function getGrid()
|
||||
{
|
||||
return $this->grid;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Grid|null $grid
|
||||
*/
|
||||
public function setGrid( $grid): void
|
||||
{
|
||||
$this->grid = $grid;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return User|null
|
||||
*/
|
||||
public function getRed()
|
||||
{
|
||||
return $this->red;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param User|null $red
|
||||
*/
|
||||
public function setRed( $red): void
|
||||
{
|
||||
$this->red = $red;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Gamer|null
|
||||
*/
|
||||
public function getRedAnon()
|
||||
{
|
||||
return $this->redAnon;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Gamer|null $redAnon
|
||||
*/
|
||||
public function setRedAnon( $redAnon): void
|
||||
{
|
||||
$this->redAnon = $redAnon;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return User|null
|
||||
*/
|
||||
public function getBlue()
|
||||
{
|
||||
return $this->blue;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param User|null $blue
|
||||
*/
|
||||
public function setBlue( $blue): void
|
||||
{
|
||||
$this->blue = $blue;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Gamer|null
|
||||
*/
|
||||
public function getBlueAnon()
|
||||
{
|
||||
return $this->blueAnon;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Gamer|null $blueAnon
|
||||
*/
|
||||
public function setBlueAnon( $blueAnon): void
|
||||
{
|
||||
$this->blueAnon = $blueAnon;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int|null
|
||||
*/
|
||||
public function getRedPoints(): ?int
|
||||
{
|
||||
return $this->redPoints;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int|null $redPoints
|
||||
*/
|
||||
public function setRedPoints(?int $redPoints): void
|
||||
{
|
||||
$this->redPoints = $redPoints;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int|null
|
||||
*/
|
||||
public function getBluePoints(): ?int
|
||||
{
|
||||
return $this->bluePoints;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int|null $bluePoints
|
||||
*/
|
||||
public function setBluePoints(?int $bluePoints): void
|
||||
{
|
||||
$this->bluePoints = $bluePoints;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool|null
|
||||
*/
|
||||
public function getRedExplodedBomb(): ?bool
|
||||
{
|
||||
return $this->redExplodedBomb;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool|null $redExplodedBomb
|
||||
*/
|
||||
public function setRedExplodedBomb(?bool $redExplodedBomb): void
|
||||
{
|
||||
$this->redExplodedBomb = $redExplodedBomb;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool|null
|
||||
*/
|
||||
public function getBlueExplodedBomb(): ?bool
|
||||
{
|
||||
return $this->blueExplodedBomb;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool|null $blueExplodedBomb
|
||||
*/
|
||||
public function setBlueExplodedBomb(?bool $blueExplodedBomb): void
|
||||
{
|
||||
$this->blueExplodedBomb = $blueExplodedBomb;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string|null
|
||||
*/
|
||||
public function getResign(): ?string
|
||||
{
|
||||
return $this->resign;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string|null $resign
|
||||
*/
|
||||
public function setResign(?string $resign): void
|
||||
{
|
||||
$this->resign = $resign;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \DateTime|null
|
||||
*/
|
||||
public function getCreated(): ?\DateTime
|
||||
{
|
||||
return $this->created;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \DateTime|null $created
|
||||
*/
|
||||
public function setCreated(?\DateTime $created): void
|
||||
{
|
||||
$this->created = $created;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \DateTime|null
|
||||
*/
|
||||
public function getUpdated(): ?\DateTime
|
||||
{
|
||||
return $this->updated;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \DateTime|null $updated
|
||||
*/
|
||||
public function setUpdated(?\DateTime $updated): void
|
||||
{
|
||||
$this->updated = $updated;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Step|null
|
||||
*/
|
||||
public function getStep()
|
||||
{
|
||||
return $this->step;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Step|null $step
|
||||
*/
|
||||
public function setStep( $step): void
|
||||
{
|
||||
$this->step = $step;
|
||||
}
|
||||
}
|
||||
138
src/Entity/Step.php
Normal file
138
src/Entity/Step.php
Normal file
@@ -0,0 +1,138 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity;
|
||||
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
/**
|
||||
* @ORM\Entity(repositoryClass="App\Repository\StepRepository")
|
||||
*/
|
||||
class Step
|
||||
{
|
||||
/**
|
||||
* @ORM\Id()
|
||||
* @ORM\GeneratedValue()
|
||||
* @ORM\Column(type="integer")
|
||||
*/
|
||||
private $id;
|
||||
|
||||
/**
|
||||
* @var int|null
|
||||
*
|
||||
* @ORM\Column(name="row", length=3, type="integer", nullable=false)
|
||||
*/
|
||||
private $row;
|
||||
|
||||
/**
|
||||
* @var int|null
|
||||
*
|
||||
* @ORM\Column(name="col", length=3, type="integer", nullable=false)
|
||||
*/
|
||||
private $col;
|
||||
|
||||
/**
|
||||
* @var boolean|null
|
||||
*
|
||||
* @ORM\Column(name="wbomb", type="boolean", nullable=true)
|
||||
*/
|
||||
private $wBomb;
|
||||
|
||||
/**
|
||||
* @var PlayedGame|null
|
||||
*
|
||||
* @ORM\ManyToOne(targetEntity="App\Entity\PlayedGame", inversedBy="step")
|
||||
*/
|
||||
private $playedGame;
|
||||
|
||||
/**
|
||||
* @var \DateTime|null
|
||||
*
|
||||
* @ORM\Column(name="created", type="datetime", nullable=true)
|
||||
*/
|
||||
private $created;
|
||||
|
||||
public function getId(): ?int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int|null
|
||||
*/
|
||||
public function getRow(): ?int
|
||||
{
|
||||
return $this->row;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int|null $row
|
||||
*/
|
||||
public function setRow(?int $row): void
|
||||
{
|
||||
$this->row = $row;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int|null
|
||||
*/
|
||||
public function getCol(): ?int
|
||||
{
|
||||
return $this->col;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int|null $col
|
||||
*/
|
||||
public function setCol(?int $col): void
|
||||
{
|
||||
$this->col = $col;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool|null
|
||||
*/
|
||||
public function getWBomb(): ?bool
|
||||
{
|
||||
return $this->wBomb;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool|null $wBomb
|
||||
*/
|
||||
public function setWBomb(?bool $wBomb): void
|
||||
{
|
||||
$this->wBomb = $wBomb;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return PlayedGame|null
|
||||
*/
|
||||
public function getPlayedGame(): ?PlayedGame
|
||||
{
|
||||
return $this->playedGame;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param PlayedGame|null $playedGame
|
||||
*/
|
||||
public function setPlayedGame(?PlayedGame $playedGame): void
|
||||
{
|
||||
$this->playedGame = $playedGame;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \DateTime|null
|
||||
*/
|
||||
public function getCreated(): ?\DateTime
|
||||
{
|
||||
return $this->created;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \DateTime|null $created
|
||||
*/
|
||||
public function setCreated(?\DateTime $created): void
|
||||
{
|
||||
$this->created = $created;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user