Exemplo n.º 1
0
 private function checkExistsAndGetResourceStorage($island, $resourceType)
 {
     $resourceStorage = $this->em->getRepository('AppBundle:Player\\ResourceStorage')->findOneBy(['island' => $island->getId(), 'resourceType' => $resourceType->getId()]);
     if (!$resourceStorage) {
         echo "Creating new storage for " . $resourceType->getName() . "\n";
         $resourceStorage = new ResourceStorage();
         $resourceStorage->setIsland($island);
         $resourceStorage->setResourceType($resourceType);
         $resourceStorage->setCount(0);
         $this->em->persist($resourceStorage);
     }
     return $resourceStorage;
 }
Exemplo n.º 2
0
 public function load(ObjectManager $manager)
 {
     $player1OrganicRaw = new ResourceStorage();
     $player1OrganicRaw->setCount(100);
     $player1OrganicRaw->setResourceType($this->getReference('organic-resource'));
     $player1OrganicRaw->setIsland($this->getReference('island1'));
     $player1CrystalRaw = new ResourceStorage();
     $player1CrystalRaw->setCount(100);
     $player1CrystalRaw->setResourceType($this->getReference('crystal-resource'));
     $player1CrystalRaw->setIsland($this->getReference('island1'));
     $player1PowerRaw = new ResourceStorage();
     $player1PowerRaw->setCount(100);
     $player1PowerRaw->setResourceType($this->getReference('power-resource'));
     $player1PowerRaw->setIsland($this->getReference('island1'));
     $player1MetalRaw = new ResourceStorage();
     $player1MetalRaw->setCount(100);
     $player1MetalRaw->setResourceType($this->getReference('metals-resource'));
     $player1MetalRaw->setIsland($this->getReference('island1'));
     $player2OrganicRaw = new ResourceStorage();
     $player2OrganicRaw->setCount(100);
     $player2OrganicRaw->setResourceType($this->getReference('organic-resource'));
     $player2OrganicRaw->setIsland($this->getReference('island2'));
     $player2CrystalRaw = new ResourceStorage();
     $player2CrystalRaw->setCount(100);
     $player2CrystalRaw->setResourceType($this->getReference('crystal-resource'));
     $player2CrystalRaw->setIsland($this->getReference('island2'));
     $player2PowerRaw = new ResourceStorage();
     $player2PowerRaw->setCount(100);
     $player2PowerRaw->setResourceType($this->getReference('power-resource'));
     $player2PowerRaw->setIsland($this->getReference('island2'));
     $player2MetalRaw = new ResourceStorage();
     $player2MetalRaw->setCount(100);
     $player2MetalRaw->setResourceType($this->getReference('metals-resource'));
     $player2MetalRaw->setIsland($this->getReference('island2'));
     $player3OrganicRaw = new ResourceStorage();
     $player3OrganicRaw->setCount(100);
     $player3OrganicRaw->setResourceType($this->getReference('organic-resource'));
     $player3OrganicRaw->setIsland($this->getReference('island3'));
     $player3CrystalRaw = new ResourceStorage();
     $player3CrystalRaw->setCount(100);
     $player3CrystalRaw->setResourceType($this->getReference('crystal-resource'));
     $player3CrystalRaw->setIsland($this->getReference('island3'));
     $player3PowerRaw = new ResourceStorage();
     $player3PowerRaw->setCount(100);
     $player3PowerRaw->setResourceType($this->getReference('power-resource'));
     $player3PowerRaw->setIsland($this->getReference('island3'));
     $player3MetalRaw = new ResourceStorage();
     $player3MetalRaw->setCount(100);
     $player3MetalRaw->setResourceType($this->getReference('metals-resource'));
     $player3MetalRaw->setIsland($this->getReference('island3'));
     $manager->persist($player1OrganicRaw);
     $manager->persist($player1CrystalRaw);
     $manager->persist($player1PowerRaw);
     $manager->persist($player1MetalRaw);
     $manager->persist($player2OrganicRaw);
     $manager->persist($player2CrystalRaw);
     $manager->persist($player2PowerRaw);
     $manager->persist($player2MetalRaw);
     $manager->persist($player3OrganicRaw);
     $manager->persist($player3CrystalRaw);
     $manager->persist($player3PowerRaw);
     $manager->persist($player3MetalRaw);
     $manager->flush();
 }