Ejemplo n.º 1
0
 protected function eat()
 {
     $client = $this->getApplication()->getErpkClient();
     $management = new ManagementModule($client);
     $status = $management->getEnergyStatus();
     if ($status['energy'] < $status['max_energy'] && $status['food_recoverable_energy'] > 0) {
         $result = $management->eat();
         return 'Health: ' . $result['health'];
     } else {
         return 'Energy already maximum or no food in inventory';
     }
 }
Ejemplo n.º 2
0
 protected function updateStorageStatus()
 {
     $output = $this->output;
     $now = time();
     $needsUpdate = $this->storageLastUpdate === null || $this->storageUpdateInterval <= $now - $this->storageLastUpdate;
     if ($needsUpdate === false) {
         return;
     }
     $output->writeln('<comment>Updating the storage...</comment>' . "\r");
     $this->toBuy = $this->amountToRefill;
     $inventory = $this->managementModule->getInventory();
     $this->storageLastUpdate = $now;
     if (!isset($inventory['items'][$this->industry->getId()][$this->quality])) {
         $inStorage = 0;
     } else {
         $inStorage = (int) $inventory['items'][$this->industry->getId()][$this->quality];
     }
     $this->toBuy -= $inStorage;
     if ($this->toBuy > 0) {
         $output->writeln('<comment>You already have ' . $inStorage . ' of ' . $this->industry->getName() . ' in storage,' . ' so you need to buy only: ' . $this->toBuy . '.</comment>');
         $availableSlots = $inventory['storage']['maximum'] - $inventory['storage']['current'];
         if ($this->toBuy > $availableSlots) {
             $this->toBuy = $availableSlots;
             $output->writeln('<comment>Unfortunately, you have only ' . $availableSlots . ' slots available in storage.</comment>');
             $output->writeln('<comment>You can buy maximum ' . $this->toBuy . ' of products.</comment>');
         }
     } else {
         $this->toBuy = 0;
         $output->writeln('<comment>You already have ' . $inStorage . ' of ' . $this->industry->getName() . ' in storage.</comment>');
         $output->writeln('<comment>Waiting ' . $this->storageUpdateInterval . ' seconds until next storage update.</comment>');
         sleep($this->storageUpdateInterval);
     }
 }
Ejemplo n.º 3
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $client = $this->getApplication()->getErpkClient();
     $mgmt = new ManagementModule($client);
     $output->write('Working... ');
     $result = $mgmt->workAsEmployee();
     $output->writeln($result['status'] ? 'OK' : 'error (' . $result['message'] . ')');
     sleep(5);
     $output->write('Training... ');
     $result = $mgmt->train(true, $input->getOption('train2'), $input->getOption('train3'), $input->getOption('train4'));
     $output->writeln($result['status'] ? 'OK' : 'error (' . $result['message'] . ')');
     sleep(5);
     $output->write('Getting daily rewards... ');
     $result = $mgmt->getDailyTasksReward();
     $output->writeln($result['message']);
 }