Ejemplo n.º 1
0
 public function getDefenseSlots($amount = null)
 {
     $out = array();
     for ($i = 1; $i <= $amount; $i++) {
         $out[$i] = Dolumar_Battle_Slot_Grass::getRandomSlot($i, $this);
     }
     return $out;
 }
Ejemplo n.º 2
0
 public function getDefenseSlots($amount = null)
 {
     if (!isset($amount) || $amount < 1) {
         $runes = $this->objProfile->resources->getTotalRunes();
         $amount = 1 + ceil($runes / 75) * 2;
     }
     // Load the slots
     $db = Neuron_Core_Database::__getInstance();
     $l = $db->select('villages_slots', array('*'), "vs_vid = " . $this->objProfile->getId());
     $out = array();
     foreach ($l as $v) {
         $out[$v['vs_slot']] = Dolumar_Battle_Slot_Grass::getFromId($v['vs_slotId'], $v['vs_slot'], $this->objProfile);
     }
     if (count($out) < $amount) {
         for ($i = 1; $i <= $amount; $i++) {
             if (!isset($out[$i])) {
                 $out[$i] = Dolumar_Battle_Slot_Grass::getRandomSlot($i, $this->objProfile);
                 $db->insert('villages_slots', array('vs_vid' => $this->objProfile->getId(), 'vs_slot' => $i, 'vs_slotId' => $out[$i]->getSlotId()));
             }
         }
     }
     while (count($out) > $amount) {
         array_pop($out);
     }
     return $out;
 }