diff --git a/README.md b/README.md index ef3e904..0358210 100644 --- a/README.md +++ b/README.md @@ -19,4 +19,7 @@ This is a Symfony 3 project w/ React JS in standalone mode and w/ WebSocket. 2.) React JS WebPack watch generator w/ babel presets: es2015, react - $ webpack --progress --colors --watch + $ webpack --progress --colors --watch -d + + -d --> Debugger; If you write this line somewhere: debugger; + The browser will stop the code here!!! diff --git a/app/config/security.yml b/app/config/security.yml index 698018c..b8b611e 100644 --- a/app/config/security.yml +++ b/app/config/security.yml @@ -26,4 +26,4 @@ security: - { path: ^/register, role: IS_AUTHENTICATED_ANONYMOUSLY } - { path: ^/resetting, role: IS_AUTHENTICATED_ANONYMOUSLY } - { path: ^/admin, role: ROLE_SUPER_ADMIN } -# - { path: ^/, role: ROLE_SUPER_ADMIN } + - { path: ^/, role: ROLE_SUPER_ADMIN } diff --git a/src/Mine/SeekerBundle/Controller/GameController.php b/src/Mine/SeekerBundle/Controller/GameController.php index e9d635d..9ef5fd2 100644 --- a/src/Mine/SeekerBundle/Controller/GameController.php +++ b/src/Mine/SeekerBundle/Controller/GameController.php @@ -6,8 +6,20 @@ use Symfony\Bundle\FrameworkBundle\Controller\Controller; class GameController extends Controller { + public function indexAction() + { + return $this->render('MineSeekerBundle:Game:index.html.twig'); + } + public function playAction() { - return $this->render('MineSeekerBundle:Game:play.html.twig'); + return $this->render('MineSeekerBundle:Game:play.html.twig', array( + 'env' => $this->container->getParameter('kernel.environment') + )); + } + + public function listAction() + { + return $this->render('MineSeekerBundle:Game:list.html.twig'); } } diff --git a/src/Mine/SeekerBundle/Entity/Grid.php b/src/Mine/SeekerBundle/Entity/Grid.php index 2f1ac0f..ec78618 100644 --- a/src/Mine/SeekerBundle/Entity/Grid.php +++ b/src/Mine/SeekerBundle/Entity/Grid.php @@ -22,701 +22,37 @@ class Grid */ private $id; - /** - * @var GridCol - * - * @ORM\OneToMany(targetEntity="Mine\SeekerBundle\Entity\GridCol", mappedBy="gridRow") - */ - private $gridRow0; - - /** - * @var GridCol - * - * @ORM\OneToMany(targetEntity="Mine\SeekerBundle\Entity\GridCol", mappedBy="gridRow") - */ - private $gridRow1; - - /** - * @var GridCol - * - * @ORM\OneToMany(targetEntity="Mine\SeekerBundle\Entity\GridCol", mappedBy="gridRow") - */ - private $gridRow2; - - /** - * @var GridCol - * - * @ORM\OneToMany(targetEntity="Mine\SeekerBundle\Entity\GridCol", mappedBy="gridRow") - */ - private $gridRow3; - - /** - * @var GridCol - * - * @ORM\OneToMany(targetEntity="Mine\SeekerBundle\Entity\GridCol", mappedBy="gridRow") - */ - private $gridRow4; - - /** - * @var GridCol - * - * @ORM\OneToMany(targetEntity="Mine\SeekerBundle\Entity\GridCol", mappedBy="gridRow") - */ - private $gridRow5; - - /** - * @var GridCol - * - * @ORM\OneToMany(targetEntity="Mine\SeekerBundle\Entity\GridCol", mappedBy="gridRow") - */ - private $gridRow6; - - /** - * @var GridCol - * - * @ORM\OneToMany(targetEntity="Mine\SeekerBundle\Entity\GridCol", mappedBy="gridRow") - */ - private $gridRow7; - - /** - * @var GridCol - * - * @ORM\OneToMany(targetEntity="Mine\SeekerBundle\Entity\GridCol", mappedBy="gridRow") - */ - private $gridRow8; - - /** - * @var GridCol - * - * @ORM\OneToMany(targetEntity="Mine\SeekerBundle\Entity\GridCol", mappedBy="gridRow") - */ - private $gridRow9; - - /** - * @var GridCol - * - * @ORM\OneToMany(targetEntity="Mine\SeekerBundle\Entity\GridCol", mappedBy="gridRow") - */ - private $gridRow10; - - /** - * @var GridCol - * - * @ORM\OneToMany(targetEntity="Mine\SeekerBundle\Entity\GridCol", mappedBy="gridRow") - */ - private $gridRow11; - - /** - * @var GridCol - * - * @ORM\OneToMany(targetEntity="Mine\SeekerBundle\Entity\GridCol", mappedBy="gridRow") - */ - private $gridRow12; - - /** - * @var GridCol - * - * @ORM\OneToMany(targetEntity="Mine\SeekerBundle\Entity\GridCol", mappedBy="gridRow") - */ - private $gridRow13; - - /** - * @var GridCol - * - * @ORM\OneToMany(targetEntity="Mine\SeekerBundle\Entity\GridCol", mappedBy="gridRow") - */ - private $gridRow14; - - /** - * @var GridCol - * - * @ORM\OneToMany(targetEntity="Mine\SeekerBundle\Entity\GridCol", mappedBy="gridRow") - */ - private $gridRow15; - /** * @var PlayedGame * - * @ORM\OneToOne(targetEntity="Mine\SeekerBundle\Entity\PlayedGame", inversedBy="grid") - * @ORM\JoinColumn(name="played_game", referencedColumnName="id") + * @ORM\OneToOne(targetEntity="Mine\SeekerBundle\Entity\PlayedGame", inversedBy="grid", cascade={"persist"}) */ private $playedGame; - /** - * Get id + * @var GridCol * - * @return int + * @ORM\OneToMany(targetEntity="Mine\SeekerBundle\Entity\GridRow", mappedBy="grid", cascade={"persist"}) + * @ORM\JoinColumn(name="grid_row", referencedColumnName="id", onDelete="CASCADE") */ - public function getId() - { - return $this->id; - } + private $gridRow; + /** * Constructor */ public function __construct() { - $this->gridRow0 = new ArrayCollection(); - $this->gridRow1 = new ArrayCollection(); - $this->gridRow2 = new ArrayCollection(); - $this->gridRow3 = new ArrayCollection(); - $this->gridRow4 = new ArrayCollection(); - $this->gridRow5 = new ArrayCollection(); - $this->gridRow6 = new ArrayCollection(); - $this->gridRow7 = new ArrayCollection(); - $this->gridRow8 = new ArrayCollection(); - $this->gridRow9 = new ArrayCollection(); - $this->gridRow10 = new ArrayCollection(); - $this->gridRow11 = new ArrayCollection(); - $this->gridRow12 = new ArrayCollection(); - $this->gridRow13 = new ArrayCollection(); - $this->gridRow14 = new ArrayCollection(); - $this->gridRow15 = new ArrayCollection(); + $this->gridRow = new ArrayCollection(); } /** - * Add gridRow0 + * Get id * - * @param GridCol $gridRow0 - * - * @return Grid + * @return integer */ - public function addGridRow0(GridCol $gridRow0) + public function getId() { - $this->gridRow0[] = $gridRow0; - - return $this; - } - - /** - * Remove gridRow0 - * - * @param GridCol $gridRow0 - */ - public function removeGridRow0(GridCol $gridRow0) - { - $this->gridRow0->removeElement($gridRow0); - } - - /** - * Get gridRow0 - * - * @return \Doctrine\Common\Collections\Collection - */ - public function getGridRow0() - { - return $this->gridRow0; - } - - /** - * Add gridRow1 - * - * @param GridCol $gridRow1 - * - * @return Grid - */ - public function addGridRow1(GridCol $gridRow1) - { - $this->gridRow1[] = $gridRow1; - - return $this; - } - - /** - * Remove gridRow1 - * - * @param GridCol $gridRow1 - */ - public function removeGridRow1(GridCol $gridRow1) - { - $this->gridRow1->removeElement($gridRow1); - } - - /** - * Get gridRow1 - * - * @return \Doctrine\Common\Collections\Collection - */ - public function getGridRow1() - { - return $this->gridRow1; - } - - /** - * Add gridRow2 - * - * @param GridCol $gridRow2 - * - * @return Grid - */ - public function addGridRow2(GridCol $gridRow2) - { - $this->gridRow2[] = $gridRow2; - - return $this; - } - - /** - * Remove gridRow2 - * - * @param GridCol $gridRow2 - */ - public function removeGridRow2(GridCol $gridRow2) - { - $this->gridRow2->removeElement($gridRow2); - } - - /** - * Get gridRow2 - * - * @return \Doctrine\Common\Collections\Collection - */ - public function getGridRow2() - { - return $this->gridRow2; - } - - /** - * Add gridRow3 - * - * @param GridCol $gridRow3 - * - * @return Grid - */ - public function addGridRow3(GridCol $gridRow3) - { - $this->gridRow3[] = $gridRow3; - - return $this; - } - - /** - * Remove gridRow3 - * - * @param GridCol $gridRow3 - */ - public function removeGridRow3(GridCol $gridRow3) - { - $this->gridRow3->removeElement($gridRow3); - } - - /** - * Get gridRow3 - * - * @return \Doctrine\Common\Collections\Collection - */ - public function getGridRow3() - { - return $this->gridRow3; - } - - /** - * Add gridRow4 - * - * @param GridCol $gridRow4 - * - * @return Grid - */ - public function addGridRow4(GridCol $gridRow4) - { - $this->gridRow4[] = $gridRow4; - - return $this; - } - - /** - * Remove gridRow4 - * - * @param GridCol $gridRow4 - */ - public function removeGridRow4(GridCol $gridRow4) - { - $this->gridRow4->removeElement($gridRow4); - } - - /** - * Get gridRow4 - * - * @return \Doctrine\Common\Collections\Collection - */ - public function getGridRow4() - { - return $this->gridRow4; - } - - /** - * Add gridRow5 - * - * @param GridCol $gridRow5 - * - * @return Grid - */ - public function addGridRow5(GridCol $gridRow5) - { - $this->gridRow5[] = $gridRow5; - - return $this; - } - - /** - * Remove gridRow5 - * - * @param GridCol $gridRow5 - */ - public function removeGridRow5(GridCol $gridRow5) - { - $this->gridRow5->removeElement($gridRow5); - } - - /** - * Get gridRow5 - * - * @return \Doctrine\Common\Collections\Collection - */ - public function getGridRow5() - { - return $this->gridRow5; - } - - /** - * Add gridRow6 - * - * @param GridCol $gridRow6 - * - * @return Grid - */ - public function addGridRow6(GridCol $gridRow6) - { - $this->gridRow6[] = $gridRow6; - - return $this; - } - - /** - * Remove gridRow6 - * - * @param GridCol $gridRow6 - */ - public function removeGridRow6(GridCol $gridRow6) - { - $this->gridRow6->removeElement($gridRow6); - } - - /** - * Get gridRow6 - * - * @return \Doctrine\Common\Collections\Collection - */ - public function getGridRow6() - { - return $this->gridRow6; - } - - /** - * Add gridRow7 - * - * @param GridCol $gridRow7 - * - * @return Grid - */ - public function addGridRow7(GridCol $gridRow7) - { - $this->gridRow7[] = $gridRow7; - - return $this; - } - - /** - * Remove gridRow7 - * - * @param GridCol $gridRow7 - */ - public function removeGridRow7(GridCol $gridRow7) - { - $this->gridRow7->removeElement($gridRow7); - } - - /** - * Get gridRow7 - * - * @return \Doctrine\Common\Collections\Collection - */ - public function getGridRow7() - { - return $this->gridRow7; - } - - /** - * Add gridRow8 - * - * @param GridCol $gridRow8 - * - * @return Grid - */ - public function addGridRow8(GridCol $gridRow8) - { - $this->gridRow8[] = $gridRow8; - - return $this; - } - - /** - * Remove gridRow8 - * - * @param GridCol $gridRow8 - */ - public function removeGridRow8(GridCol $gridRow8) - { - $this->gridRow8->removeElement($gridRow8); - } - - /** - * Get gridRow8 - * - * @return \Doctrine\Common\Collections\Collection - */ - public function getGridRow8() - { - return $this->gridRow8; - } - - /** - * Add gridRow9 - * - * @param GridCol $gridRow9 - * - * @return Grid - */ - public function addGridRow9(GridCol $gridRow9) - { - $this->gridRow9[] = $gridRow9; - - return $this; - } - - /** - * Remove gridRow9 - * - * @param GridCol $gridRow9 - */ - public function removeGridRow9(GridCol $gridRow9) - { - $this->gridRow9->removeElement($gridRow9); - } - - /** - * Get gridRow9 - * - * @return \Doctrine\Common\Collections\Collection - */ - public function getGridRow9() - { - return $this->gridRow9; - } - - /** - * Add gridRow10 - * - * @param GridCol $gridRow10 - * - * @return Grid - */ - public function addGridRow10(GridCol $gridRow10) - { - $this->gridRow10[] = $gridRow10; - - return $this; - } - - /** - * Remove gridRow10 - * - * @param GridCol $gridRow10 - */ - public function removeGridRow10(GridCol $gridRow10) - { - $this->gridRow10->removeElement($gridRow10); - } - - /** - * Get gridRow10 - * - * @return \Doctrine\Common\Collections\Collection - */ - public function getGridRow10() - { - return $this->gridRow10; - } - - /** - * Add gridRow11 - * - * @param GridCol $gridRow11 - * - * @return Grid - */ - public function addGridRow11(GridCol $gridRow11) - { - $this->gridRow11[] = $gridRow11; - - return $this; - } - - /** - * Remove gridRow11 - * - * @param GridCol $gridRow11 - */ - public function removeGridRow11(GridCol $gridRow11) - { - $this->gridRow11->removeElement($gridRow11); - } - - /** - * Get gridRow11 - * - * @return \Doctrine\Common\Collections\Collection - */ - public function getGridRow11() - { - return $this->gridRow11; - } - - /** - * Add gridRow12 - * - * @param GridCol $gridRow12 - * - * @return Grid - */ - public function addGridRow12(GridCol $gridRow12) - { - $this->gridRow12[] = $gridRow12; - - return $this; - } - - /** - * Remove gridRow12 - * - * @param GridCol $gridRow12 - */ - public function removeGridRow12(GridCol $gridRow12) - { - $this->gridRow12->removeElement($gridRow12); - } - - /** - * Get gridRow12 - * - * @return \Doctrine\Common\Collections\Collection - */ - public function getGridRow12() - { - return $this->gridRow12; - } - - /** - * Add gridRow13 - * - * @param GridCol $gridRow13 - * - * @return Grid - */ - public function addGridRow13(GridCol $gridRow13) - { - $this->gridRow13[] = $gridRow13; - - return $this; - } - - /** - * Remove gridRow13 - * - * @param GridCol $gridRow13 - */ - public function removeGridRow13(GridCol $gridRow13) - { - $this->gridRow13->removeElement($gridRow13); - } - - /** - * Get gridRow13 - * - * @return \Doctrine\Common\Collections\Collection - */ - public function getGridRow13() - { - return $this->gridRow13; - } - - /** - * Add gridRow14 - * - * @param GridCol $gridRow14 - * - * @return Grid - */ - public function addGridRow14(GridCol $gridRow14) - { - $this->gridRow14[] = $gridRow14; - - return $this; - } - - /** - * Remove gridRow14 - * - * @param GridCol $gridRow14 - */ - public function removeGridRow14(GridCol $gridRow14) - { - $this->gridRow14->removeElement($gridRow14); - } - - /** - * Get gridRow14 - * - * @return \Doctrine\Common\Collections\Collection - */ - public function getGridRow14() - { - return $this->gridRow14; - } - - /** - * Add gridRow15 - * - * @param GridCol $gridRow15 - * - * @return Grid - */ - public function addGridRow15(GridCol $gridRow15) - { - $this->gridRow15[] = $gridRow15; - - return $this; - } - - /** - * Remove gridRow15 - * - * @param GridCol $gridRow15 - */ - public function removeGridRow15(GridCol $gridRow15) - { - $this->gridRow15->removeElement($gridRow15); - } - - /** - * Get gridRow15 - * - * @return \Doctrine\Common\Collections\Collection - */ - public function getGridRow15() - { - return $this->gridRow15; + return $this->id; } /** @@ -742,4 +78,38 @@ class Grid { return $this->playedGame; } + + /** + * Add gridRow + * + * @param GridCol $gridRow + * + * @return Grid + */ + public function addGridRow(GridCol $gridRow) + { + $this->gridRow[] = $gridRow; + + return $this; + } + + /** + * Remove gridRow + * + * @param GridCol $gridRow + */ + public function removeGridRow(GridCol $gridRow) + { + $this->gridRow->removeElement($gridRow); + } + + /** + * Get gridRow + * + * @return \Doctrine\Common\Collections\Collection + */ + public function getGridRow() + { + return $this->gridRow; + } } diff --git a/src/Mine/SeekerBundle/Entity/Grid.php~ b/src/Mine/SeekerBundle/Entity/Grid.php~ index 2f1ac0f..ec78618 100644 --- a/src/Mine/SeekerBundle/Entity/Grid.php~ +++ b/src/Mine/SeekerBundle/Entity/Grid.php~ @@ -22,701 +22,37 @@ class Grid */ private $id; - /** - * @var GridCol - * - * @ORM\OneToMany(targetEntity="Mine\SeekerBundle\Entity\GridCol", mappedBy="gridRow") - */ - private $gridRow0; - - /** - * @var GridCol - * - * @ORM\OneToMany(targetEntity="Mine\SeekerBundle\Entity\GridCol", mappedBy="gridRow") - */ - private $gridRow1; - - /** - * @var GridCol - * - * @ORM\OneToMany(targetEntity="Mine\SeekerBundle\Entity\GridCol", mappedBy="gridRow") - */ - private $gridRow2; - - /** - * @var GridCol - * - * @ORM\OneToMany(targetEntity="Mine\SeekerBundle\Entity\GridCol", mappedBy="gridRow") - */ - private $gridRow3; - - /** - * @var GridCol - * - * @ORM\OneToMany(targetEntity="Mine\SeekerBundle\Entity\GridCol", mappedBy="gridRow") - */ - private $gridRow4; - - /** - * @var GridCol - * - * @ORM\OneToMany(targetEntity="Mine\SeekerBundle\Entity\GridCol", mappedBy="gridRow") - */ - private $gridRow5; - - /** - * @var GridCol - * - * @ORM\OneToMany(targetEntity="Mine\SeekerBundle\Entity\GridCol", mappedBy="gridRow") - */ - private $gridRow6; - - /** - * @var GridCol - * - * @ORM\OneToMany(targetEntity="Mine\SeekerBundle\Entity\GridCol", mappedBy="gridRow") - */ - private $gridRow7; - - /** - * @var GridCol - * - * @ORM\OneToMany(targetEntity="Mine\SeekerBundle\Entity\GridCol", mappedBy="gridRow") - */ - private $gridRow8; - - /** - * @var GridCol - * - * @ORM\OneToMany(targetEntity="Mine\SeekerBundle\Entity\GridCol", mappedBy="gridRow") - */ - private $gridRow9; - - /** - * @var GridCol - * - * @ORM\OneToMany(targetEntity="Mine\SeekerBundle\Entity\GridCol", mappedBy="gridRow") - */ - private $gridRow10; - - /** - * @var GridCol - * - * @ORM\OneToMany(targetEntity="Mine\SeekerBundle\Entity\GridCol", mappedBy="gridRow") - */ - private $gridRow11; - - /** - * @var GridCol - * - * @ORM\OneToMany(targetEntity="Mine\SeekerBundle\Entity\GridCol", mappedBy="gridRow") - */ - private $gridRow12; - - /** - * @var GridCol - * - * @ORM\OneToMany(targetEntity="Mine\SeekerBundle\Entity\GridCol", mappedBy="gridRow") - */ - private $gridRow13; - - /** - * @var GridCol - * - * @ORM\OneToMany(targetEntity="Mine\SeekerBundle\Entity\GridCol", mappedBy="gridRow") - */ - private $gridRow14; - - /** - * @var GridCol - * - * @ORM\OneToMany(targetEntity="Mine\SeekerBundle\Entity\GridCol", mappedBy="gridRow") - */ - private $gridRow15; - /** * @var PlayedGame * - * @ORM\OneToOne(targetEntity="Mine\SeekerBundle\Entity\PlayedGame", inversedBy="grid") - * @ORM\JoinColumn(name="played_game", referencedColumnName="id") + * @ORM\OneToOne(targetEntity="Mine\SeekerBundle\Entity\PlayedGame", inversedBy="grid", cascade={"persist"}) */ private $playedGame; - /** - * Get id + * @var GridCol * - * @return int + * @ORM\OneToMany(targetEntity="Mine\SeekerBundle\Entity\GridRow", mappedBy="grid", cascade={"persist"}) + * @ORM\JoinColumn(name="grid_row", referencedColumnName="id", onDelete="CASCADE") */ - public function getId() - { - return $this->id; - } + private $gridRow; + /** * Constructor */ public function __construct() { - $this->gridRow0 = new ArrayCollection(); - $this->gridRow1 = new ArrayCollection(); - $this->gridRow2 = new ArrayCollection(); - $this->gridRow3 = new ArrayCollection(); - $this->gridRow4 = new ArrayCollection(); - $this->gridRow5 = new ArrayCollection(); - $this->gridRow6 = new ArrayCollection(); - $this->gridRow7 = new ArrayCollection(); - $this->gridRow8 = new ArrayCollection(); - $this->gridRow9 = new ArrayCollection(); - $this->gridRow10 = new ArrayCollection(); - $this->gridRow11 = new ArrayCollection(); - $this->gridRow12 = new ArrayCollection(); - $this->gridRow13 = new ArrayCollection(); - $this->gridRow14 = new ArrayCollection(); - $this->gridRow15 = new ArrayCollection(); + $this->gridRow = new ArrayCollection(); } /** - * Add gridRow0 + * Get id * - * @param GridCol $gridRow0 - * - * @return Grid + * @return integer */ - public function addGridRow0(GridCol $gridRow0) + public function getId() { - $this->gridRow0[] = $gridRow0; - - return $this; - } - - /** - * Remove gridRow0 - * - * @param GridCol $gridRow0 - */ - public function removeGridRow0(GridCol $gridRow0) - { - $this->gridRow0->removeElement($gridRow0); - } - - /** - * Get gridRow0 - * - * @return \Doctrine\Common\Collections\Collection - */ - public function getGridRow0() - { - return $this->gridRow0; - } - - /** - * Add gridRow1 - * - * @param GridCol $gridRow1 - * - * @return Grid - */ - public function addGridRow1(GridCol $gridRow1) - { - $this->gridRow1[] = $gridRow1; - - return $this; - } - - /** - * Remove gridRow1 - * - * @param GridCol $gridRow1 - */ - public function removeGridRow1(GridCol $gridRow1) - { - $this->gridRow1->removeElement($gridRow1); - } - - /** - * Get gridRow1 - * - * @return \Doctrine\Common\Collections\Collection - */ - public function getGridRow1() - { - return $this->gridRow1; - } - - /** - * Add gridRow2 - * - * @param GridCol $gridRow2 - * - * @return Grid - */ - public function addGridRow2(GridCol $gridRow2) - { - $this->gridRow2[] = $gridRow2; - - return $this; - } - - /** - * Remove gridRow2 - * - * @param GridCol $gridRow2 - */ - public function removeGridRow2(GridCol $gridRow2) - { - $this->gridRow2->removeElement($gridRow2); - } - - /** - * Get gridRow2 - * - * @return \Doctrine\Common\Collections\Collection - */ - public function getGridRow2() - { - return $this->gridRow2; - } - - /** - * Add gridRow3 - * - * @param GridCol $gridRow3 - * - * @return Grid - */ - public function addGridRow3(GridCol $gridRow3) - { - $this->gridRow3[] = $gridRow3; - - return $this; - } - - /** - * Remove gridRow3 - * - * @param GridCol $gridRow3 - */ - public function removeGridRow3(GridCol $gridRow3) - { - $this->gridRow3->removeElement($gridRow3); - } - - /** - * Get gridRow3 - * - * @return \Doctrine\Common\Collections\Collection - */ - public function getGridRow3() - { - return $this->gridRow3; - } - - /** - * Add gridRow4 - * - * @param GridCol $gridRow4 - * - * @return Grid - */ - public function addGridRow4(GridCol $gridRow4) - { - $this->gridRow4[] = $gridRow4; - - return $this; - } - - /** - * Remove gridRow4 - * - * @param GridCol $gridRow4 - */ - public function removeGridRow4(GridCol $gridRow4) - { - $this->gridRow4->removeElement($gridRow4); - } - - /** - * Get gridRow4 - * - * @return \Doctrine\Common\Collections\Collection - */ - public function getGridRow4() - { - return $this->gridRow4; - } - - /** - * Add gridRow5 - * - * @param GridCol $gridRow5 - * - * @return Grid - */ - public function addGridRow5(GridCol $gridRow5) - { - $this->gridRow5[] = $gridRow5; - - return $this; - } - - /** - * Remove gridRow5 - * - * @param GridCol $gridRow5 - */ - public function removeGridRow5(GridCol $gridRow5) - { - $this->gridRow5->removeElement($gridRow5); - } - - /** - * Get gridRow5 - * - * @return \Doctrine\Common\Collections\Collection - */ - public function getGridRow5() - { - return $this->gridRow5; - } - - /** - * Add gridRow6 - * - * @param GridCol $gridRow6 - * - * @return Grid - */ - public function addGridRow6(GridCol $gridRow6) - { - $this->gridRow6[] = $gridRow6; - - return $this; - } - - /** - * Remove gridRow6 - * - * @param GridCol $gridRow6 - */ - public function removeGridRow6(GridCol $gridRow6) - { - $this->gridRow6->removeElement($gridRow6); - } - - /** - * Get gridRow6 - * - * @return \Doctrine\Common\Collections\Collection - */ - public function getGridRow6() - { - return $this->gridRow6; - } - - /** - * Add gridRow7 - * - * @param GridCol $gridRow7 - * - * @return Grid - */ - public function addGridRow7(GridCol $gridRow7) - { - $this->gridRow7[] = $gridRow7; - - return $this; - } - - /** - * Remove gridRow7 - * - * @param GridCol $gridRow7 - */ - public function removeGridRow7(GridCol $gridRow7) - { - $this->gridRow7->removeElement($gridRow7); - } - - /** - * Get gridRow7 - * - * @return \Doctrine\Common\Collections\Collection - */ - public function getGridRow7() - { - return $this->gridRow7; - } - - /** - * Add gridRow8 - * - * @param GridCol $gridRow8 - * - * @return Grid - */ - public function addGridRow8(GridCol $gridRow8) - { - $this->gridRow8[] = $gridRow8; - - return $this; - } - - /** - * Remove gridRow8 - * - * @param GridCol $gridRow8 - */ - public function removeGridRow8(GridCol $gridRow8) - { - $this->gridRow8->removeElement($gridRow8); - } - - /** - * Get gridRow8 - * - * @return \Doctrine\Common\Collections\Collection - */ - public function getGridRow8() - { - return $this->gridRow8; - } - - /** - * Add gridRow9 - * - * @param GridCol $gridRow9 - * - * @return Grid - */ - public function addGridRow9(GridCol $gridRow9) - { - $this->gridRow9[] = $gridRow9; - - return $this; - } - - /** - * Remove gridRow9 - * - * @param GridCol $gridRow9 - */ - public function removeGridRow9(GridCol $gridRow9) - { - $this->gridRow9->removeElement($gridRow9); - } - - /** - * Get gridRow9 - * - * @return \Doctrine\Common\Collections\Collection - */ - public function getGridRow9() - { - return $this->gridRow9; - } - - /** - * Add gridRow10 - * - * @param GridCol $gridRow10 - * - * @return Grid - */ - public function addGridRow10(GridCol $gridRow10) - { - $this->gridRow10[] = $gridRow10; - - return $this; - } - - /** - * Remove gridRow10 - * - * @param GridCol $gridRow10 - */ - public function removeGridRow10(GridCol $gridRow10) - { - $this->gridRow10->removeElement($gridRow10); - } - - /** - * Get gridRow10 - * - * @return \Doctrine\Common\Collections\Collection - */ - public function getGridRow10() - { - return $this->gridRow10; - } - - /** - * Add gridRow11 - * - * @param GridCol $gridRow11 - * - * @return Grid - */ - public function addGridRow11(GridCol $gridRow11) - { - $this->gridRow11[] = $gridRow11; - - return $this; - } - - /** - * Remove gridRow11 - * - * @param GridCol $gridRow11 - */ - public function removeGridRow11(GridCol $gridRow11) - { - $this->gridRow11->removeElement($gridRow11); - } - - /** - * Get gridRow11 - * - * @return \Doctrine\Common\Collections\Collection - */ - public function getGridRow11() - { - return $this->gridRow11; - } - - /** - * Add gridRow12 - * - * @param GridCol $gridRow12 - * - * @return Grid - */ - public function addGridRow12(GridCol $gridRow12) - { - $this->gridRow12[] = $gridRow12; - - return $this; - } - - /** - * Remove gridRow12 - * - * @param GridCol $gridRow12 - */ - public function removeGridRow12(GridCol $gridRow12) - { - $this->gridRow12->removeElement($gridRow12); - } - - /** - * Get gridRow12 - * - * @return \Doctrine\Common\Collections\Collection - */ - public function getGridRow12() - { - return $this->gridRow12; - } - - /** - * Add gridRow13 - * - * @param GridCol $gridRow13 - * - * @return Grid - */ - public function addGridRow13(GridCol $gridRow13) - { - $this->gridRow13[] = $gridRow13; - - return $this; - } - - /** - * Remove gridRow13 - * - * @param GridCol $gridRow13 - */ - public function removeGridRow13(GridCol $gridRow13) - { - $this->gridRow13->removeElement($gridRow13); - } - - /** - * Get gridRow13 - * - * @return \Doctrine\Common\Collections\Collection - */ - public function getGridRow13() - { - return $this->gridRow13; - } - - /** - * Add gridRow14 - * - * @param GridCol $gridRow14 - * - * @return Grid - */ - public function addGridRow14(GridCol $gridRow14) - { - $this->gridRow14[] = $gridRow14; - - return $this; - } - - /** - * Remove gridRow14 - * - * @param GridCol $gridRow14 - */ - public function removeGridRow14(GridCol $gridRow14) - { - $this->gridRow14->removeElement($gridRow14); - } - - /** - * Get gridRow14 - * - * @return \Doctrine\Common\Collections\Collection - */ - public function getGridRow14() - { - return $this->gridRow14; - } - - /** - * Add gridRow15 - * - * @param GridCol $gridRow15 - * - * @return Grid - */ - public function addGridRow15(GridCol $gridRow15) - { - $this->gridRow15[] = $gridRow15; - - return $this; - } - - /** - * Remove gridRow15 - * - * @param GridCol $gridRow15 - */ - public function removeGridRow15(GridCol $gridRow15) - { - $this->gridRow15->removeElement($gridRow15); - } - - /** - * Get gridRow15 - * - * @return \Doctrine\Common\Collections\Collection - */ - public function getGridRow15() - { - return $this->gridRow15; + return $this->id; } /** @@ -742,4 +78,38 @@ class Grid { return $this->playedGame; } + + /** + * Add gridRow + * + * @param GridCol $gridRow + * + * @return Grid + */ + public function addGridRow(GridCol $gridRow) + { + $this->gridRow[] = $gridRow; + + return $this; + } + + /** + * Remove gridRow + * + * @param GridCol $gridRow + */ + public function removeGridRow(GridCol $gridRow) + { + $this->gridRow->removeElement($gridRow); + } + + /** + * Get gridRow + * + * @return \Doctrine\Common\Collections\Collection + */ + public function getGridRow() + { + return $this->gridRow; + } } diff --git a/src/Mine/SeekerBundle/Entity/GridCol.php b/src/Mine/SeekerBundle/Entity/GridCol.php index c88fbf5..0f052a7 100644 --- a/src/Mine/SeekerBundle/Entity/GridCol.php +++ b/src/Mine/SeekerBundle/Entity/GridCol.php @@ -5,10 +5,10 @@ namespace Mine\SeekerBundle\Entity; use Doctrine\ORM\Mapping as ORM; /** - * GridRow + * GridCol * - * @ORM\Table(name="grid_row") - * @ORM\Entity(repositoryClass="Mine\SeekerBundle\Repository\GridRowRepository") + * @ORM\Table(name="grid_col") + * @ORM\Entity(repositoryClass="Mine\SeekerBundle\Repository\GridColRepository") */ class GridCol { @@ -22,129 +22,24 @@ class GridCol private $id; /** - * @var int + * @var string * - * @ORM\Column(name="col0", type="integer", nullable=true) + * @ORM\Column(name="col", type="string", length=1, nullable=false) */ - private $col0; + private $col; /** - * @var int + * @var GridRow * - * @ORM\Column(name="col1", type="integer", nullable=true) + * @ORM\ManyToOne(targetEntity="Mine\SeekerBundle\Entity\GridRow", inversedBy="gridCol", cascade={"persist"}) + * @ORM\JoinColumn(name="grid_col", referencedColumnName="id", onDelete="CASCADE") */ - private $col1; - - /** - * @var int - * - * @ORM\Column(name="col2", type="integer", nullable=true) - */ - private $col2; - - /** - * @var int - * - * @ORM\Column(name="col3", type="integer", nullable=true) - */ - private $col3; - - /** - * @var int - * - * @ORM\Column(name="col4", type="integer", nullable=true) - */ - private $col4; - - /** - * @var int - * - * @ORM\Column(name="col5", type="integer", nullable=true) - */ - private $col5; - - /** - * @var int - * - * @ORM\Column(name="col6", type="integer", nullable=true) - */ - private $col6; - - /** - * @var int - * - * @ORM\Column(name="col7", type="integer", nullable=true) - */ - private $col7; - - /** - * @var int - * - * @ORM\Column(name="col8", type="integer", nullable=true) - */ - private $col8; - - /** - * @var int - * - * @ORM\Column(name="col9", type="integer", nullable=true) - */ - private $col9; - - /** - * @var int - * - * @ORM\Column(name="col10", type="integer", nullable=true) - */ - private $col10; - - /** - * @var int - * - * @ORM\Column(name="col11", type="integer", nullable=true) - */ - private $col11; - - /** - * @var int - * - * @ORM\Column(name="col12", type="integer", nullable=true) - */ - private $col12; - - /** - * @var int - * - * @ORM\Column(name="col13", type="integer", nullable=true) - */ - private $col13; - - /** - * @var int - * - * @ORM\Column(name="col14", type="integer", nullable=true) - */ - private $col14; - - /** - * @var int - * - * @ORM\Column(name="col15", type="integer", nullable=true) - */ - private $col15; - - /** - * @var Grid - * - * @ORM\ManyToOne(targetEntity="Mine\SeekerBundle\Entity\Grid", inversedBy="gridRow") - */ - private $gridRow; - + private $gridCol; /** * Get id * - * @return int + * @return integer */ public function getId() { @@ -152,410 +47,50 @@ class GridCol } /** - * Set col0 + * Set col * - * @param integer $col0 + * @param integer $col * * @return GridCol */ - public function setCol0($col0) + public function setCol($col) { - $this->col0 = $col0; + $this->col = $col; return $this; } /** - * Get col0 + * Get col * * @return integer */ - public function getCol0() + public function getCol() { - return $this->col0; + return $this->col; } /** - * Set col1 + * Set gridCol * - * @param integer $col1 + * @param GridRow $gridCol * * @return GridCol */ - public function setCol1($col1) + public function setGridCol(GridRow $gridCol = null) { - $this->col1 = $col1; + $this->gridCol = $gridCol; return $this; } /** - * Get col1 + * Get gridCol * - * @return integer + * @return GridRow */ - public function getCol1() + public function getGridCol() { - return $this->col1; - } - - /** - * Set col2 - * - * @param integer $col2 - * - * @return GridCol - */ - public function setCol2($col2) - { - $this->col2 = $col2; - - return $this; - } - - /** - * Get col2 - * - * @return integer - */ - public function getCol2() - { - return $this->col2; - } - - /** - * Set col3 - * - * @param integer $col3 - * - * @return GridCol - */ - public function setCol3($col3) - { - $this->col3 = $col3; - - return $this; - } - - /** - * Get col3 - * - * @return integer - */ - public function getCol3() - { - return $this->col3; - } - - /** - * Set col4 - * - * @param integer $col4 - * - * @return GridCol - */ - public function setCol4($col4) - { - $this->col4 = $col4; - - return $this; - } - - /** - * Get col4 - * - * @return integer - */ - public function getCol4() - { - return $this->col4; - } - - /** - * Set col5 - * - * @param integer $col5 - * - * @return GridCol - */ - public function setCol5($col5) - { - $this->col5 = $col5; - - return $this; - } - - /** - * Get col5 - * - * @return integer - */ - public function getCol5() - { - return $this->col5; - } - - /** - * Set col6 - * - * @param integer $col6 - * - * @return GridCol - */ - public function setCol6($col6) - { - $this->col6 = $col6; - - return $this; - } - - /** - * Get col6 - * - * @return integer - */ - public function getCol6() - { - return $this->col6; - } - - /** - * Set col7 - * - * @param integer $col7 - * - * @return GridCol - */ - public function setCol7($col7) - { - $this->col7 = $col7; - - return $this; - } - - /** - * Get col7 - * - * @return integer - */ - public function getCol7() - { - return $this->col7; - } - - /** - * Set col8 - * - * @param integer $col8 - * - * @return GridCol - */ - public function setCol8($col8) - { - $this->col8 = $col8; - - return $this; - } - - /** - * Get col8 - * - * @return integer - */ - public function getCol8() - { - return $this->col8; - } - - /** - * Set col9 - * - * @param integer $col9 - * - * @return GridCol - */ - public function setCol9($col9) - { - $this->col9 = $col9; - - return $this; - } - - /** - * Get col9 - * - * @return integer - */ - public function getCol9() - { - return $this->col9; - } - - /** - * Set col10 - * - * @param integer $col10 - * - * @return GridCol - */ - public function setCol10($col10) - { - $this->col10 = $col10; - - return $this; - } - - /** - * Get col10 - * - * @return integer - */ - public function getCol10() - { - return $this->col10; - } - - /** - * Set col11 - * - * @param integer $col11 - * - * @return GridCol - */ - public function setCol11($col11) - { - $this->col11 = $col11; - - return $this; - } - - /** - * Get col11 - * - * @return integer - */ - public function getCol11() - { - return $this->col11; - } - - /** - * Set col12 - * - * @param integer $col12 - * - * @return GridCol - */ - public function setCol12($col12) - { - $this->col12 = $col12; - - return $this; - } - - /** - * Get col12 - * - * @return integer - */ - public function getCol12() - { - return $this->col12; - } - - /** - * Set col13 - * - * @param integer $col13 - * - * @return GridCol - */ - public function setCol13($col13) - { - $this->col13 = $col13; - - return $this; - } - - /** - * Get col13 - * - * @return integer - */ - public function getCol13() - { - return $this->col13; - } - - /** - * Set col14 - * - * @param integer $col14 - * - * @return GridCol - */ - public function setCol14($col14) - { - $this->col14 = $col14; - - return $this; - } - - /** - * Get col14 - * - * @return integer - */ - public function getCol14() - { - return $this->col14; - } - - /** - * Set col15 - * - * @param integer $col15 - * - * @return GridCol - */ - public function setCol15($col15) - { - $this->col15 = $col15; - - return $this; - } - - /** - * Get col15 - * - * @return integer - */ - public function getCol15() - { - return $this->col15; - } - - /** - * Set gridRow - * - * @param Grid $gridRow - * - * @return GridCol - */ - public function setGridRow(Grid $gridRow = null) - { - $this->gridRow = $gridRow; - - return $this; - } - - /** - * Get gridRow - * - * @return Grid - */ - public function getGridRow() - { - return $this->gridRow; + return $this->gridCol; } } diff --git a/src/Mine/SeekerBundle/Entity/GridCol.php~ b/src/Mine/SeekerBundle/Entity/GridCol.php~ index c88fbf5..0f052a7 100644 --- a/src/Mine/SeekerBundle/Entity/GridCol.php~ +++ b/src/Mine/SeekerBundle/Entity/GridCol.php~ @@ -5,10 +5,10 @@ namespace Mine\SeekerBundle\Entity; use Doctrine\ORM\Mapping as ORM; /** - * GridRow + * GridCol * - * @ORM\Table(name="grid_row") - * @ORM\Entity(repositoryClass="Mine\SeekerBundle\Repository\GridRowRepository") + * @ORM\Table(name="grid_col") + * @ORM\Entity(repositoryClass="Mine\SeekerBundle\Repository\GridColRepository") */ class GridCol { @@ -22,129 +22,24 @@ class GridCol private $id; /** - * @var int + * @var string * - * @ORM\Column(name="col0", type="integer", nullable=true) + * @ORM\Column(name="col", type="string", length=1, nullable=false) */ - private $col0; + private $col; /** - * @var int + * @var GridRow * - * @ORM\Column(name="col1", type="integer", nullable=true) + * @ORM\ManyToOne(targetEntity="Mine\SeekerBundle\Entity\GridRow", inversedBy="gridCol", cascade={"persist"}) + * @ORM\JoinColumn(name="grid_col", referencedColumnName="id", onDelete="CASCADE") */ - private $col1; - - /** - * @var int - * - * @ORM\Column(name="col2", type="integer", nullable=true) - */ - private $col2; - - /** - * @var int - * - * @ORM\Column(name="col3", type="integer", nullable=true) - */ - private $col3; - - /** - * @var int - * - * @ORM\Column(name="col4", type="integer", nullable=true) - */ - private $col4; - - /** - * @var int - * - * @ORM\Column(name="col5", type="integer", nullable=true) - */ - private $col5; - - /** - * @var int - * - * @ORM\Column(name="col6", type="integer", nullable=true) - */ - private $col6; - - /** - * @var int - * - * @ORM\Column(name="col7", type="integer", nullable=true) - */ - private $col7; - - /** - * @var int - * - * @ORM\Column(name="col8", type="integer", nullable=true) - */ - private $col8; - - /** - * @var int - * - * @ORM\Column(name="col9", type="integer", nullable=true) - */ - private $col9; - - /** - * @var int - * - * @ORM\Column(name="col10", type="integer", nullable=true) - */ - private $col10; - - /** - * @var int - * - * @ORM\Column(name="col11", type="integer", nullable=true) - */ - private $col11; - - /** - * @var int - * - * @ORM\Column(name="col12", type="integer", nullable=true) - */ - private $col12; - - /** - * @var int - * - * @ORM\Column(name="col13", type="integer", nullable=true) - */ - private $col13; - - /** - * @var int - * - * @ORM\Column(name="col14", type="integer", nullable=true) - */ - private $col14; - - /** - * @var int - * - * @ORM\Column(name="col15", type="integer", nullable=true) - */ - private $col15; - - /** - * @var Grid - * - * @ORM\ManyToOne(targetEntity="Mine\SeekerBundle\Entity\Grid", inversedBy="gridRow") - */ - private $gridRow; - + private $gridCol; /** * Get id * - * @return int + * @return integer */ public function getId() { @@ -152,410 +47,50 @@ class GridCol } /** - * Set col0 + * Set col * - * @param integer $col0 + * @param integer $col * * @return GridCol */ - public function setCol0($col0) + public function setCol($col) { - $this->col0 = $col0; + $this->col = $col; return $this; } /** - * Get col0 + * Get col * * @return integer */ - public function getCol0() + public function getCol() { - return $this->col0; + return $this->col; } /** - * Set col1 + * Set gridCol * - * @param integer $col1 + * @param GridRow $gridCol * * @return GridCol */ - public function setCol1($col1) + public function setGridCol(GridRow $gridCol = null) { - $this->col1 = $col1; + $this->gridCol = $gridCol; return $this; } /** - * Get col1 + * Get gridCol * - * @return integer + * @return GridRow */ - public function getCol1() + public function getGridCol() { - return $this->col1; - } - - /** - * Set col2 - * - * @param integer $col2 - * - * @return GridCol - */ - public function setCol2($col2) - { - $this->col2 = $col2; - - return $this; - } - - /** - * Get col2 - * - * @return integer - */ - public function getCol2() - { - return $this->col2; - } - - /** - * Set col3 - * - * @param integer $col3 - * - * @return GridCol - */ - public function setCol3($col3) - { - $this->col3 = $col3; - - return $this; - } - - /** - * Get col3 - * - * @return integer - */ - public function getCol3() - { - return $this->col3; - } - - /** - * Set col4 - * - * @param integer $col4 - * - * @return GridCol - */ - public function setCol4($col4) - { - $this->col4 = $col4; - - return $this; - } - - /** - * Get col4 - * - * @return integer - */ - public function getCol4() - { - return $this->col4; - } - - /** - * Set col5 - * - * @param integer $col5 - * - * @return GridCol - */ - public function setCol5($col5) - { - $this->col5 = $col5; - - return $this; - } - - /** - * Get col5 - * - * @return integer - */ - public function getCol5() - { - return $this->col5; - } - - /** - * Set col6 - * - * @param integer $col6 - * - * @return GridCol - */ - public function setCol6($col6) - { - $this->col6 = $col6; - - return $this; - } - - /** - * Get col6 - * - * @return integer - */ - public function getCol6() - { - return $this->col6; - } - - /** - * Set col7 - * - * @param integer $col7 - * - * @return GridCol - */ - public function setCol7($col7) - { - $this->col7 = $col7; - - return $this; - } - - /** - * Get col7 - * - * @return integer - */ - public function getCol7() - { - return $this->col7; - } - - /** - * Set col8 - * - * @param integer $col8 - * - * @return GridCol - */ - public function setCol8($col8) - { - $this->col8 = $col8; - - return $this; - } - - /** - * Get col8 - * - * @return integer - */ - public function getCol8() - { - return $this->col8; - } - - /** - * Set col9 - * - * @param integer $col9 - * - * @return GridCol - */ - public function setCol9($col9) - { - $this->col9 = $col9; - - return $this; - } - - /** - * Get col9 - * - * @return integer - */ - public function getCol9() - { - return $this->col9; - } - - /** - * Set col10 - * - * @param integer $col10 - * - * @return GridCol - */ - public function setCol10($col10) - { - $this->col10 = $col10; - - return $this; - } - - /** - * Get col10 - * - * @return integer - */ - public function getCol10() - { - return $this->col10; - } - - /** - * Set col11 - * - * @param integer $col11 - * - * @return GridCol - */ - public function setCol11($col11) - { - $this->col11 = $col11; - - return $this; - } - - /** - * Get col11 - * - * @return integer - */ - public function getCol11() - { - return $this->col11; - } - - /** - * Set col12 - * - * @param integer $col12 - * - * @return GridCol - */ - public function setCol12($col12) - { - $this->col12 = $col12; - - return $this; - } - - /** - * Get col12 - * - * @return integer - */ - public function getCol12() - { - return $this->col12; - } - - /** - * Set col13 - * - * @param integer $col13 - * - * @return GridCol - */ - public function setCol13($col13) - { - $this->col13 = $col13; - - return $this; - } - - /** - * Get col13 - * - * @return integer - */ - public function getCol13() - { - return $this->col13; - } - - /** - * Set col14 - * - * @param integer $col14 - * - * @return GridCol - */ - public function setCol14($col14) - { - $this->col14 = $col14; - - return $this; - } - - /** - * Get col14 - * - * @return integer - */ - public function getCol14() - { - return $this->col14; - } - - /** - * Set col15 - * - * @param integer $col15 - * - * @return GridCol - */ - public function setCol15($col15) - { - $this->col15 = $col15; - - return $this; - } - - /** - * Get col15 - * - * @return integer - */ - public function getCol15() - { - return $this->col15; - } - - /** - * Set gridRow - * - * @param Grid $gridRow - * - * @return GridCol - */ - public function setGridRow(Grid $gridRow = null) - { - $this->gridRow = $gridRow; - - return $this; - } - - /** - * Get gridRow - * - * @return Grid - */ - public function getGridRow() - { - return $this->gridRow; + return $this->gridCol; } } diff --git a/src/Mine/SeekerBundle/Entity/GridRow.php b/src/Mine/SeekerBundle/Entity/GridRow.php new file mode 100644 index 0000000..651036a --- /dev/null +++ b/src/Mine/SeekerBundle/Entity/GridRow.php @@ -0,0 +1,116 @@ +gridCol = new ArrayCollection(); + } + + /** + * Get id + * + * @return integer + */ + public function getId() + { + return $this->id; + } + + /** + * Add gridCol + * + * @param GridCol $gridCol + * + * @return GridRow + */ + public function addGridCol(GridCol $gridCol) + { + $this->gridCol[] = $gridCol; + + return $this; + } + + /** + * Remove gridCol + * + * @param GridCol $gridCol + */ + public function removeGridCol(GridCol $gridCol) + { + $this->gridCol->removeElement($gridCol); + } + + /** + * Get gridCol + * + * @return \Doctrine\Common\Collections\Collection + */ + public function getGridCol() + { + return $this->gridCol; + } + + /** + * Set grid + * + * @param Grid $grid + * + * @return GridRow + */ + public function setGrid(Grid $grid = null) + { + $this->grid = $grid; + + return $this; + } + + /** + * Get grid + * + * @return Grid + */ + public function getGrid() + { + return $this->grid; + } +} diff --git a/src/Mine/SeekerBundle/Entity/GridRow.php~ b/src/Mine/SeekerBundle/Entity/GridRow.php~ new file mode 100644 index 0000000..651036a --- /dev/null +++ b/src/Mine/SeekerBundle/Entity/GridRow.php~ @@ -0,0 +1,116 @@ +gridCol = new ArrayCollection(); + } + + /** + * Get id + * + * @return integer + */ + public function getId() + { + return $this->id; + } + + /** + * Add gridCol + * + * @param GridCol $gridCol + * + * @return GridRow + */ + public function addGridCol(GridCol $gridCol) + { + $this->gridCol[] = $gridCol; + + return $this; + } + + /** + * Remove gridCol + * + * @param GridCol $gridCol + */ + public function removeGridCol(GridCol $gridCol) + { + $this->gridCol->removeElement($gridCol); + } + + /** + * Get gridCol + * + * @return \Doctrine\Common\Collections\Collection + */ + public function getGridCol() + { + return $this->gridCol; + } + + /** + * Set grid + * + * @param Grid $grid + * + * @return GridRow + */ + public function setGrid(Grid $grid = null) + { + $this->grid = $grid; + + return $this; + } + + /** + * Get grid + * + * @return Grid + */ + public function getGrid() + { + return $this->grid; + } +} diff --git a/src/Mine/SeekerBundle/Entity/PlayedGame.php b/src/Mine/SeekerBundle/Entity/PlayedGame.php index 4805f89..95ad7b0 100644 --- a/src/Mine/SeekerBundle/Entity/PlayedGame.php +++ b/src/Mine/SeekerBundle/Entity/PlayedGame.php @@ -3,6 +3,7 @@ namespace Mine\SeekerBundle\Entity; use Doctrine\Common\Collections\ArrayCollection; +use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping as ORM; use Jotunheimr\UserBundle\Entity\User; @@ -23,10 +24,17 @@ class PlayedGame */ private $id; + /** + * @var string + * + * @ORM\Column(name="game_assoc", type="string", length=50, nullable=false) + */ + private $gameAssoc; + /** * @var Grid * - * @ORM\OneToOne(targetEntity="Mine\SeekerBundle\Entity\Grid", mappedBy="playedGame") + * @ORM\OneToOne(targetEntity="Mine\SeekerBundle\Entity\Grid", mappedBy="playedGame", cascade={"persist"}) */ private $grid; @@ -94,19 +102,11 @@ class PlayedGame * @var Step * * @ORM\OneToMany(targetEntity="Mine\SeekerBundle\Entity\Step", mappedBy="playedGame") + * @ORM\JoinColumn(name="step", referencedColumnName="id", nullable=true) */ private $step; - /** - * Get id - * - * @return int - */ - public function getId() - { - return $this->id; - } /** * Constructor */ @@ -115,6 +115,16 @@ class PlayedGame $this->step = new ArrayCollection(); } + /** + * Get id + * + * @return integer + */ + public function getId() + { + return $this->id; + } + /** * Set redPoints * @@ -259,64 +269,6 @@ class PlayedGame return $this->red; } - /** - * Set blue - * - * @param User $blue - * - * @return PlayedGame - */ - public function setBlue(User $blue = null) - { - $this->blue = $blue; - - return $this; - } - - /** - * Get blue - * - * @return User - */ - public function getBlue() - { - return $this->blue; - } - - /** - * Add step - * - * @param \Mine\SeekerBundle\Entity\Step $step - * - * @return PlayedGame - */ - public function addStep(\Mine\SeekerBundle\Entity\Step $step) - { - $this->step[] = $step; - - return $this; - } - - /** - * Remove step - * - * @param \Mine\SeekerBundle\Entity\Step $step - */ - public function removeStep(\Mine\SeekerBundle\Entity\Step $step) - { - $this->step->removeElement($step); - } - - /** - * Get step - * - * @return \Doctrine\Common\Collections\Collection - */ - public function getStep() - { - return $this->step; - } - /** * Set redAnon * @@ -341,6 +293,30 @@ class PlayedGame return $this->redAnon; } + /** + * Set blue + * + * @param User $blue + * + * @return PlayedGame + */ + public function setBlue(User $blue = null) + { + $this->blue = $blue; + + return $this; + } + + /** + * Get blue + * + * @return User + */ + public function getBlue() + { + return $this->blue; + } + /** * Set blueAnon * @@ -364,4 +340,62 @@ class PlayedGame { return $this->blueAnon; } + + /** + * Add step + * + * @param Step $step + * + * @return PlayedGame + */ + public function addStep(Step $step) + { + $this->step[] = $step; + + return $this; + } + + /** + * Remove step + * + * @param Step $step + */ + public function removeStep(Step $step) + { + $this->step->removeElement($step); + } + + /** + * Get step + * + * @return Collection + */ + public function getStep() + { + return $this->step; + } + + /** + * Set gameAssoc + * + * @param string $gameAssoc + * + * @return PlayedGame + */ + public function setGameAssoc($gameAssoc) + { + $this->gameAssoc = $gameAssoc; + + return $this; + } + + /** + * Get gameAssoc + * + * @return string + */ + public function getGameAssoc() + { + return $this->gameAssoc; + } } diff --git a/src/Mine/SeekerBundle/Entity/PlayedGame.php~ b/src/Mine/SeekerBundle/Entity/PlayedGame.php~ index d102286..95ad7b0 100644 --- a/src/Mine/SeekerBundle/Entity/PlayedGame.php~ +++ b/src/Mine/SeekerBundle/Entity/PlayedGame.php~ @@ -3,7 +3,9 @@ namespace Mine\SeekerBundle\Entity; use Doctrine\Common\Collections\ArrayCollection; +use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping as ORM; +use Jotunheimr\UserBundle\Entity\User; /** * PlayedGame @@ -22,15 +24,22 @@ class PlayedGame */ private $id; + /** + * @var string + * + * @ORM\Column(name="game_assoc", type="string", length=50, nullable=false) + */ + private $gameAssoc; + /** * @var Grid * - * @ORM\OneToOne(targetEntity="Mine\SeekerBundle\Entity\Grid", mappedBy="playedGame") + * @ORM\OneToOne(targetEntity="Mine\SeekerBundle\Entity\Grid", mappedBy="playedGame", cascade={"persist"}) */ private $grid; /** - * @var \Jotunheimr\UserBundle\Entity\User + * @var User * * @ORM\ManyToOne(targetEntity="Jotunheimr\UserBundle\Entity\User") * @ORM\JoinColumn(name="red_id", referencedColumnName="id", nullable=true) @@ -46,7 +55,7 @@ class PlayedGame private $redAnon; /** - * @var \Jotunheimr\UserBundle\Entity\User + * @var User * * @ORM\ManyToOne(targetEntity="Jotunheimr\UserBundle\Entity\User") * @ORM\JoinColumn(name="blue_id", referencedColumnName="id", nullable=true) @@ -93,19 +102,11 @@ class PlayedGame * @var Step * * @ORM\OneToMany(targetEntity="Mine\SeekerBundle\Entity\Step", mappedBy="playedGame") + * @ORM\JoinColumn(name="step", referencedColumnName="id", nullable=true) */ private $step; - /** - * Get id - * - * @return int - */ - public function getId() - { - return $this->id; - } /** * Constructor */ @@ -114,6 +115,16 @@ class PlayedGame $this->step = new ArrayCollection(); } + /** + * Get id + * + * @return integer + */ + public function getId() + { + return $this->id; + } + /** * Set redPoints * @@ -213,11 +224,11 @@ class PlayedGame /** * Set grid * - * @param \Mine\SeekerBundle\Entity\Grid $grid + * @param Grid $grid * * @return PlayedGame */ - public function setGrid(\Mine\SeekerBundle\Entity\Grid $grid = null) + public function setGrid(Grid $grid = null) { $this->grid = $grid; @@ -227,7 +238,7 @@ class PlayedGame /** * Get grid * - * @return \Mine\SeekerBundle\Entity\Grid + * @return Grid */ public function getGrid() { @@ -237,11 +248,11 @@ class PlayedGame /** * Set red * - * @param \Jotunheimr\UserBundle\Entity\User $red + * @param User $red * * @return PlayedGame */ - public function setRed(\Jotunheimr\UserBundle\Entity\User $red = null) + public function setRed(User $red = null) { $this->red = $red; @@ -251,7 +262,7 @@ class PlayedGame /** * Get red * - * @return \Jotunheimr\UserBundle\Entity\User + * @return User */ public function getRed() { @@ -259,13 +270,37 @@ class PlayedGame } /** - * Set blue + * Set redAnon * - * @param \Jotunheimr\UserBundle\Entity\User $blue + * @param Gamer $redAnon * * @return PlayedGame */ - public function setBlue(\Jotunheimr\UserBundle\Entity\User $blue = null) + public function setRedAnon(Gamer $redAnon = null) + { + $this->redAnon = $redAnon; + + return $this; + } + + /** + * Get redAnon + * + * @return Gamer + */ + public function getRedAnon() + { + return $this->redAnon; + } + + /** + * Set blue + * + * @param User $blue + * + * @return PlayedGame + */ + public function setBlue(User $blue = null) { $this->blue = $blue; @@ -275,7 +310,7 @@ class PlayedGame /** * Get blue * - * @return \Jotunheimr\UserBundle\Entity\User + * @return User */ public function getBlue() { @@ -283,13 +318,37 @@ class PlayedGame } /** - * Add step + * Set blueAnon * - * @param \Mine\SeekerBundle\Entity\Step $step + * @param Gamer $blueAnon * * @return PlayedGame */ - public function addStep(\Mine\SeekerBundle\Entity\Step $step) + public function setBlueAnon(Gamer $blueAnon = null) + { + $this->blueAnon = $blueAnon; + + return $this; + } + + /** + * Get blueAnon + * + * @return Gamer + */ + public function getBlueAnon() + { + return $this->blueAnon; + } + + /** + * Add step + * + * @param Step $step + * + * @return PlayedGame + */ + public function addStep(Step $step) { $this->step[] = $step; @@ -299,9 +358,9 @@ class PlayedGame /** * Remove step * - * @param \Mine\SeekerBundle\Entity\Step $step + * @param Step $step */ - public function removeStep(\Mine\SeekerBundle\Entity\Step $step) + public function removeStep(Step $step) { $this->step->removeElement($step); } @@ -309,10 +368,34 @@ class PlayedGame /** * Get step * - * @return \Doctrine\Common\Collections\Collection + * @return Collection */ public function getStep() { return $this->step; } + + /** + * Set gameAssoc + * + * @param string $gameAssoc + * + * @return PlayedGame + */ + public function setGameAssoc($gameAssoc) + { + $this->gameAssoc = $gameAssoc; + + return $this; + } + + /** + * Get gameAssoc + * + * @return string + */ + public function getGameAssoc() + { + return $this->gameAssoc; + } } diff --git a/src/Mine/SeekerBundle/Repository/GridColRepository.php b/src/Mine/SeekerBundle/Repository/GridColRepository.php index 5c88b8b..a529c8c 100644 --- a/src/Mine/SeekerBundle/Repository/GridColRepository.php +++ b/src/Mine/SeekerBundle/Repository/GridColRepository.php @@ -3,7 +3,7 @@ namespace Mine\SeekerBundle\Repository; /** - * GridRepository + * GridColRepository * * This class was generated by the Doctrine ORM. Add your own custom * repository methods below. diff --git a/src/Mine/SeekerBundle/Repository/GridRowRepository.php b/src/Mine/SeekerBundle/Repository/GridRowRepository.php index c17bedf..aecadfb 100644 --- a/src/Mine/SeekerBundle/Repository/GridRowRepository.php +++ b/src/Mine/SeekerBundle/Repository/GridRowRepository.php @@ -1,6 +1,7 @@ , + , document.getElementById('mine-wrapper') ); diff --git a/src/Mine/SeekerBundle/Resources/public/js/mine-seeker/app.js b/src/Mine/SeekerBundle/Resources/public/js/mine-seeker/app.js index 727f4b5..0a752ca 100644 --- a/src/Mine/SeekerBundle/Resources/public/js/mine-seeker/app.js +++ b/src/Mine/SeekerBundle/Resources/public/js/mine-seeker/app.js @@ -1,55 +1,157 @@ import React from 'react'; +import Grid from './grid/grid'; import GridControl from './grid/grid-control'; +import Logging from './system/logging'; class MineSeeker extends React.Component { + constructor(props) { + super(props); + + var gameAssoc = props.gameId !== '' ? props.gameId : this.makeGameAssoc(50); + var channel = "acme/channel/" + gameAssoc; + var log = new Logging(); + log.state.logging = props.env === 'dev'; + + var grid = new Grid(); + + this.state = { + gameInherited: props.gameId !== '', + gameAssoc: gameAssoc, + log: log, + websocket: null, + channel: channel, + createGrid: false, + grid: grid.state.grid + } + } + + makeGameAssoc(len) { + var text = ""; + var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; + for (var i = 0; i < len; i++) { + text += possible.charAt(Math.floor(Math.random() * possible.length)); + } + return text; + } + + topicProcess(payload, grid) { + var log = this.state.log; + + /** It is a PUBLISH */ + if (typeof payload.data !== 'undefined') { + log.i([payload.user + " has been stepped to coords: " + payload.data.coords[0] + ', ' + payload.data.coords[0], payload]); + + /** because the activePlayer has been changed before the data come */ + if (this.refs.gridControl.state.webPlayer !== payload.data.player) { + this.refs.gridControl.stepEvent(payload.data.coords, true); + } + } else { + /** It is a SUBSCRIBE */ + log.i(["Something happened on the channel!", payload]); + + if (this.refs.gridControl.state.webPlayer === null) { + if (payload.userCnt === 1) { + this.refs.gridControl.state.webPlayer = 'red'; + } + + if (payload.userCnt === 2) { + this.refs.gridControl.state.webPlayer = 'blue'; + this.refs.gridControl.state.grid = JSON.parse(grid); + } + } + } + } + /** after rendering */ componentDidMount() { - var websocket = WS.connect("ws://mine.dev:6450"); + this.state.websocket = WS.connect("ws://mine.dev:6450"); - /** session is an Autobahn JS WAMP session. */ - websocket.on("socket/connect", function (session) { - console.info("Successfully Connected!"); + var log = this.state.log; - session.subscribe("acme/channel", function(uri, payload){ - console.log("Received message", payload.msg); - }); + /** + * Connect + * Session is an Autobahn JS WAMP session. + */ + this.state.websocket.on("socket/connect", (session) => { + log.i("Successfully connected to the Server!"); - session.call("sample/sum", [2, 5]).then( - function (result) { - console.log("RPC Valid!", result); - }, - function (error, desc) { - console.log("RPC Error", error, desc); - } - ); + /** + * Connect + * Send grid information to the server + */ + session + .call( + this.state.gameInherited ? "sample/connectGame" : "sample/startGame", + [this.state.grid, this.state.gameAssoc] + ) + .then( + (grid) => { + log.l(["Grid has been created! Return w/ gameAssoc."]); - session.publish("acme/channel", {msg: "This is a message!"}); + /** Connect */ + session.subscribe( + this.state.channel, + (uri, payload, log) => { - // session.publish("acme/channel", {msg: "I'm leaving, I will not see the next message"}); - // - // session.unsubscribe("acme/channel"); - // - // session.publish("acme/channel", {msg: "I won't see this"}); - // - // session.subscribe("acme/channel", function (uri, payload) { - // console.log("Received message", payload.msg); - // }); - // - // session.publish("acme/channel", {msg: "I'm back!"}); + /** Create GridControl class */ + if (this.state.createGrid) { + this.topicProcess(payload, grid); + } else { + this.setState({createGrid: true}, () => { + /** Start GridControl tag */ + this.refs.gridControl.setState({grid: this.state.grid}, () => { + this.refs.gridControl.state.session = session; + this.refs.gridControl.state.channel = this.state.channel; + + this.topicProcess(payload, grid); + }); + }); + } + } + ); + }, + (error, desc) => log.e(["RPC Error", error, desc]) + ); }); - /** error provides us with some insight into the disconnection: error.reason and error.code */ - websocket.on("socket/disconnect", function (error) { - console.info("Disconnected for " + error.reason + " with code " + error.code); + /** + * Connect + * Error provides us with some insight into the disconnection: error.reason and error.code + */ + this.state.websocket.on("socket/disconnect", function (error) { + log.w("Disconnected for " + error.reason + " with code " + error.code); }); } + createGrid() { + return this.state.createGrid + ? + : ''; + } + + /** FOR DEVELOPMENT */ + createLink() { + return this.state.gameAssoc + ? Play w/ me! + : ''; + } + render() { return ( -
- // +
+
+ {this.createLink()} +
+ {this.createGrid()} + {/**/} +
); } } export default MineSeeker; + diff --git a/src/Mine/SeekerBundle/Resources/public/js/mine-seeker/grid/grid-control.js b/src/Mine/SeekerBundle/Resources/public/js/mine-seeker/grid/grid-control.js index 360a1c8..8773bea 100644 --- a/src/Mine/SeekerBundle/Resources/public/js/mine-seeker/grid/grid-control.js +++ b/src/Mine/SeekerBundle/Resources/public/js/mine-seeker/grid/grid-control.js @@ -1,21 +1,24 @@ import React from 'react'; import Sound from 'react-sound'; -import Grid from './grid'; import GridField from './grid-field'; import UserControl from '../user/user-control'; class GridControl extends React.Component { - constructor() { - super(); - - var grid = new Grid(); + constructor(props) { + super(props); this.state = { - grid: grid.state.grid, + env: props.env, + log: props.log, + session: null, + channel: null, + webPlayer: null, + grid: null, updatedFieldCache: [], bombFieldCache: [], foundUserMineCache: 0, playBomb: false, + sound: null, lastClicked: { red: null, blue: null @@ -191,6 +194,8 @@ class GridControl extends React.Component { this.state.foundUserMineCache++; if (!justOnFirstIteration) { + this.playingSound('mine'); + /** set last clicked field w/ color */ this.state.lastClicked[activePlayer] = [x, y]; } @@ -201,7 +206,9 @@ class GridControl extends React.Component { }); } else { if (!justOnFirstIteration) { - /** set ACTIVE player */ + this.playingSound('click'); + + /** set __ACTIVE__ player in the UserControl !!!! */ userControl.setState({ activePlayer: userControl.state.activePlayer ? 0 : 1 }); @@ -245,19 +252,20 @@ class GridControl extends React.Component { } } - /** - * Most important event!! - * @param coords - */ - onClick(coords) { + stepEvent(coords, isOpponentStepped) { var activePlayer = this.refs.userControl.state.activePlayer ? 'blue' : 'red'; - this.state.foundUserMineCache = 0; + this.state.foundUserMineCache = 0; this.state.playBomb = true; - console.log( - this.state.playBomb - ); + /** Step automatically when not this user stepped */ + if (!isOpponentStepped) { + this.state.session + .publish(this.state.channel, { + 'coords': coords, + 'player': activePlayer + }); + } if (this.refs.userControl.state.bombSelected) { var radius = this.getBombRadius(coords[0], coords[1]); @@ -296,7 +304,7 @@ class GridControl extends React.Component { } if (this.state.foundUserMineCache) { - /** remove ONE mine from global */ + /** remove the found mines from global */ this.refs.userControl.setState({ mines: this.refs.userControl.state.mines - this.state.foundUserMineCache, foundMines: true @@ -306,7 +314,7 @@ class GridControl extends React.Component { this.refs.userControl.setState({foundMines: false}) }.bind(this), 500); - /** add ONE mine to active Player */ + /** add the found mines to the active Player */ this.refs.userControl.refs[activePlayer].setState({ mines: this.refs.userControl.refs[activePlayer].state.mines + this.state.foundUserMineCache }); @@ -321,6 +329,19 @@ class GridControl extends React.Component { } } + /** + * Most important event!! + * Click only when the active player is the current client. + * @param coords + */ + onClick(coords) { + var activePlayer = this.refs.userControl.state.activePlayer ? 'blue' : 'red'; + + if (activePlayer === this.state.webPlayer) { + this.stepEvent(coords, false); + } + } + /** * On Hover when you want to drop BOMB * @param coords @@ -335,34 +356,50 @@ class GridControl extends React.Component { } } - playingBomb() { - return this.state.playBomb - ? Sound.status.PLAYING - : Sound.status.STOPPED; + /** + * Play sound effets + * @param type + * @returns {*} + */ + playingSound(type) { + this.state.log.i('Sound playing type: ' + type); + + return type !== null + ? + : ''; } + /** after rendering */ componentDidMount() { - soundManager.setup({debugMode: false}); + /** disable console of soundmanager */ + soundManager.setup({ + debugMode: this.state.env, + useConsole: this.state.env + }); } renderGridFields() { - var grid = []; + /** If the app.js filled the this.state.grid var, START the grid render */ + if (this.state.grid) { + var grid = []; - for (var i = 0, j = this.state.grid.length; i < j; i++) { - for (var k = 0, l = this.state.grid[i].length; k < l; k++) { - grid.push( - - ); + for (var i = 0, j = this.state.grid.length; i < j; i++) { + for (var k = 0, l = this.state.grid[i].length; k < l; k++) { + grid.push( + + ); + } } + + return grid; } - return grid; + return ""; } render() { @@ -375,11 +412,7 @@ class GridControl extends React.Component {
{this.renderGridFields()}
- - {/**/} - {/**/} - {/**/} - {/**/} + {this.playingSound(this.state.sound)} ); } diff --git a/src/Mine/SeekerBundle/Resources/public/js/mine-seeker/grid/grid-field.js b/src/Mine/SeekerBundle/Resources/public/js/mine-seeker/grid/grid-field.js index cdc957a..69ab29e 100644 --- a/src/Mine/SeekerBundle/Resources/public/js/mine-seeker/grid/grid-field.js +++ b/src/Mine/SeekerBundle/Resources/public/js/mine-seeker/grid/grid-field.js @@ -12,7 +12,7 @@ class GridField extends React.Component { lastClickedBlue: false, bombTargetArea: null, icons: { - root: 'bundles/mineseeker/images/', + root: '/bundles/mineseeker/images/', water: { 1: 'bg-wave-1-outbg.png', 2: 'bg-wave-1-outbg.png', @@ -35,6 +35,8 @@ class GridField extends React.Component { componentWillMount() { var wave = Math.floor(Math.random() * 3) + 1; + console.log('mounted'); + this.setState({ currentImage: this.state.icons.root + this.state.icons.water[wave] }); diff --git a/src/Mine/SeekerBundle/Resources/public/js/mine-seeker/system/logging.js b/src/Mine/SeekerBundle/Resources/public/js/mine-seeker/system/logging.js new file mode 100644 index 0000000..93c25be --- /dev/null +++ b/src/Mine/SeekerBundle/Resources/public/js/mine-seeker/system/logging.js @@ -0,0 +1,41 @@ +class Logging { + constructor() { + this.state = { + logging: null + }; + } + + output(data, method) { + if (this.state.logging) { + if (typeof data === 'object') { + console.log('-------'); + data.forEach((item) => console[method](item)); + console.log('\n'); + } else { + console[method](data); + } + } + } + + i(data) { + this.output(data, 'info'); + } + + w(data) { + this.output(data, 'warn'); + } + + t(data) { + this.output(data, 'table'); + } + + e(data) { + this.output(data, 'error'); + } + + l(data) { + this.output(data, 'log'); + } +} + +export default Logging; diff --git a/src/Mine/SeekerBundle/Resources/public/js/mine-seeker/user/user.js b/src/Mine/SeekerBundle/Resources/public/js/mine-seeker/user/user.js index 7ae8f4c..e37ccfc 100644 --- a/src/Mine/SeekerBundle/Resources/public/js/mine-seeker/user/user.js +++ b/src/Mine/SeekerBundle/Resources/public/js/mine-seeker/user/user.js @@ -9,6 +9,7 @@ class User extends React.Component { active: props.active, color: props.color === 'blue' ? 1 : 0, mines: 0, + srcRoot: '/bundles/mineseeker/images/', haveBomb: true, enabledBomb: true }; @@ -19,27 +20,27 @@ class User extends React.Component { } getSrc(color) { - return 'bundles/mineseeker/images/bg-flag-' + color + '-outbg.png'; + return this.state.srcRoot + 'bg-flag-' + color + '-outbg.png'; } getBomb() { if (this.state.haveBomb) { if (this.state.enabledBomb && this.state.active) { - return 'bundles/mineseeker/images/bg-bomb-outbg.png'; + return this.state.srcRoot + 'bg-bomb-outbg.png'; } else { - return 'bundles/mineseeker/images/bg-bomb-disabled-outbg.png'; + return this.state.srcRoot + 'bg-bomb-disabled-outbg.png'; } } else { - return 'bundles/mineseeker/images/bg-bomb-exploded-outbg.png'; + return this.state.srcRoot + 'bg-bomb-exploded-outbg.png'; } } getFigure(color) { - return 'bundles/mineseeker/images/bg-figure-' + color + '-outbg.png'; + return this.state.srcRoot + 'bg-figure-' + color + '-outbg.png'; } getCursor(state, color) { - var cursorImg = 'bundles/mineseeker/images/bg-cursor-' + color + '-outbg.png'; + var cursorImg = this.state.srcRoot + 'bg-cursor-' + color + '-outbg.png'; return state ? cursor diff --git a/src/Mine/SeekerBundle/Resources/views/Game/index.html.twig b/src/Mine/SeekerBundle/Resources/views/Game/index.html.twig new file mode 100644 index 0000000..7b2f1e8 --- /dev/null +++ b/src/Mine/SeekerBundle/Resources/views/Game/index.html.twig @@ -0,0 +1 @@ +Bazmeg index. \ No newline at end of file diff --git a/src/Mine/SeekerBundle/Resources/views/Game/list.html.twig b/src/Mine/SeekerBundle/Resources/views/Game/list.html.twig new file mode 100644 index 0000000..e69de29 diff --git a/src/Mine/SeekerBundle/Resources/views/Game/play.html.twig b/src/Mine/SeekerBundle/Resources/views/Game/play.html.twig index 35e0a51..1794139 100644 --- a/src/Mine/SeekerBundle/Resources/views/Game/play.html.twig +++ b/src/Mine/SeekerBundle/Resources/views/Game/play.html.twig @@ -8,7 +8,10 @@ {% endblock %} {% block body %} -
+
+
{% endblock %} {% block javascripts %} diff --git a/src/Mine/SeekerBundle/Rpc/AcmeRpc.php b/src/Mine/SeekerBundle/Rpc/AcmeRpc.php index 2c02cc8..50ae164 100644 --- a/src/Mine/SeekerBundle/Rpc/AcmeRpc.php +++ b/src/Mine/SeekerBundle/Rpc/AcmeRpc.php @@ -2,6 +2,11 @@ namespace Mine\SeekerBundle\Rpc; +use Doctrine\ORM\EntityManager; +use Mine\SeekerBundle\Entity\Grid; +use Mine\SeekerBundle\Entity\GridCol; +use Mine\SeekerBundle\Entity\GridRow; +use Mine\SeekerBundle\Entity\PlayedGame; use Ratchet\ConnectionInterface; use Gos\Bundle\WebSocketBundle\RPC\RpcInterface; use Gos\Bundle\WebSocketBundle\Router\WampRequest; @@ -9,29 +14,19 @@ use Gos\Bundle\WebSocketBundle\Router\WampRequest; class AcmeRpc implements RpcInterface { /** - * Adds the params together - * - * Note: $conn isnt used here, but contains the connection of the person making this request. - * - * @param ConnectionInterface $connection - * @param WampRequest $request - * @param array $params - * @return array + * @var EntityManager */ - public function addFunc(ConnectionInterface $connection, WampRequest $request, $params) - { - return array("result" => array_sum($params)); - } + protected $entityManager; + + protected $grid; /** - * @param ConnectionInterface $connection - * @param WampRequest $request - * @param $params - * @return number + * AcmeRpc constructor. + * @param EntityManager $entityManager */ - public function sum(ConnectionInterface $connection, WampRequest $request, $params) + public function __construct(EntityManager $entityManager) { - return array_sum($params); + $this->entityManager = $entityManager; } /** @@ -43,4 +38,95 @@ class AcmeRpc implements RpcInterface { return 'acme.rpc'; } + + /** + * @param ConnectionInterface $connection + * @param WampRequest $request + * @param array $params + * @return Grid + */ + public function startGame(ConnectionInterface $connection, WampRequest $request, array $params) + { + return $this->saveGrid($params); + } + + /** + * @param ConnectionInterface $connection + * @param WampRequest $request + * @param array $params + * @return string Json string for frontend. + */ + public function connectGame(ConnectionInterface $connection, WampRequest $request, array $params) + { + return json_encode($this->getGrid($params[1]), JSON_NUMERIC_CHECK); + } + + /** + * @param $gameAssoc + * @return array + */ + private function getGrid($gameAssoc) + { + $getsee = array(); + + $this->entityManager->clear(); + + $grid = $this->entityManager + ->getRepository('MineSeekerBundle:PlayedGame') + ->findOneByGameAssoc($gameAssoc) + ->getGrid(); + + foreach ($grid->getGridRow()->toArray() as $row) { + $bazmeg = array(); + + foreach ($row->getGridCol()->toArray() as $col) { + $bazmeg[] = $col->getCol(); + } + + $getsee[] = $bazmeg; + } + + return $getsee; + } + + /** + * @param $data + * @return Grid + */ + private function saveGrid($data) + { + $playedGame = new PlayedGame(); + $grid = new Grid(); + + foreach ($data[0] as $row) { + $gridRow = new GridRow(); + + foreach ($row as $col) { + $gridCol = new GridCol(); + + $gridCol->setCol($col); + + /** Save Col */ + $gridCol->setGridCol($gridRow); + $this->entityManager->persist($gridCol); + } + + /** Save Row */ + $gridRow->setGrid($grid); + $this->entityManager->persist($gridRow); + } + + /** Save Grid */ + $grid->setPlayedGame($playedGame); + $this->entityManager->persist($grid); + + /** Save PlayedGame */ + $playedGame->setGameAssoc($data[1]); + $playedGame->setGrid($grid); + $this->entityManager->persist($playedGame); + + $this->entityManager->flush(); + + return $data[1]; + } } diff --git a/src/Mine/SeekerBundle/Topic/AcmeTopic.php b/src/Mine/SeekerBundle/Topic/AcmeTopic.php index 11d3844..388466e 100644 --- a/src/Mine/SeekerBundle/Topic/AcmeTopic.php +++ b/src/Mine/SeekerBundle/Topic/AcmeTopic.php @@ -2,6 +2,7 @@ namespace Mine\SeekerBundle\Topic; +use Doctrine\ORM\EntityManager; use Gos\Bundle\WebSocketBundle\Client\ClientManipulatorInterface; use Gos\Bundle\WebSocketBundle\Topic\TopicInterface; use Gos\Bundle\WebSocketBundle\Router\WampRequest; @@ -13,14 +14,23 @@ class AcmeTopic implements TopicInterface /** @var ClientManipulatorInterface */ protected $clientManipulator; + /** @var EntityManager */ + protected $entityManager; + + protected $red; + + protected $blue; + /** * AcmeTopic constructor. * * @param $clientManipulator ClientManipulatorInterface + * @param EntityManager $entityManager */ - public function __construct(ClientManipulatorInterface $clientManipulator) + public function __construct(ClientManipulatorInterface $clientManipulator, EntityManager $entityManager) { $this->clientManipulator = $clientManipulator; + $this->entityManager = $entityManager; } /** @@ -35,10 +45,24 @@ class AcmeTopic implements TopicInterface { /** this will broadcast the message to ALL subscribers of this topic. */ $user = $this->clientManipulator->getClient($connection); - dump($user); + $userName = is_string($user) ? $user : $user->getUsername(); + + if ($topic->count() === 1) { + $this->red = $userName; + } + + if ($topic->count() === 2) { + $this->blue = $userName; + } + $topic->broadcast([ - 'msg' => $connection->resourceId . " has joined " . $topic->getId(), - 'user' => $this->getName() + 'userTopicId' => $connection->resourceId, + 'channel' => $topic->getId(), + 'user' => $userName, + 'color' => $userName === $this->red ? 'red' : 'blue', + 'red' => $this->red, + 'blue' => $this->blue, + 'userCnt' => $topic->count() ]); } @@ -53,8 +77,6 @@ class AcmeTopic implements TopicInterface public function onUnSubscribe(ConnectionInterface $connection, Topic $topic, WampRequest $request) { /** this will broadcast the message to ALL subscribers of this topic. */ - $user = $this->clientManipulator->getClient($connection); - dump($user); $topic->broadcast(['msg' => $connection->resourceId . " has left " . $topic->getId()]); } @@ -73,13 +95,18 @@ class AcmeTopic implements TopicInterface */ public function onPublish(ConnectionInterface $connection, Topic $topic, WampRequest $request, $event, array $exclude, array $eligible) { - /* - $topic->getId() will contain the FULL requested uri, so you can proceed based on that - if ($topic->getId() == "acme/channel/shout") - //shout something to all subs. - */ + $user = $this->clientManipulator->getClient($connection); + $userName = is_string($user) ? $user : $user->getUsername(); + $topic->broadcast([ - 'msg' => $event + 'userTopicId' => $connection->resourceId, + 'channel' => $topic->getId(), + 'user' => $userName, + 'color' => $userName === $this->red ? 'red' : 'blue', + 'red' => $this->red, + 'blue' => $this->blue, + 'userCnt' => $topic->count(), + 'data' => $event ]); }