Beispiel #1
0
 public function getDescription($data = array())
 {
     return parent::getDescription(array('bonus' => $this->getBonusFromLevel()));
 }
Beispiel #2
0
 public function __construct($bonus)
 {
     $this->bonus = $bonus;
     parent::__construct();
 }
Beispiel #3
0
 public function getDescription($data = array())
 {
     return parent::getDescription(array('hidden' => $this->hidden / 60));
 }
Beispiel #4
0
 public function getActiveBoosts($since = NOW, $now = NOW)
 {
     if ($now < $since) {
         $since = $now;
     }
     if (!isset($this->oBoosts[$now . '_' . $since])) {
         $this->oBoosts[$now . '_' . $since] = array();
         // Fetch all spells that were active
         $db = Neuron_Core_Database::__getInstance();
         $l = $db->getDataFromQuery($db->customQuery("\n\t\t\t\t\tSELECT\n\t\t\t\t\t\t*,\n\t\t\t\t\t\tSUBSTR( b_ba_id, (LOCATE( ':', b_ba_id )+1) ) AS level\n\t\t\t\t\tFROM\n\t\t\t\t\t\tboosts\n\t\t\t\t\tWHERE\n\t\t\t\t\t\tb_targetId = {$this->getId()}\n\t\t\t\t\t\tAND \n\t\t\t\t\t\t(\n\t\t\t\t\t\t\t(b_start <= {$now} AND b_end >= {$now}) \t/* All boosts that are active now */\n\t\t\t\t\t\t\tOR (b_start <= {$since} AND b_end >= {$since}) \t/* All boosts that have been active but ended */\n\t\t\t\t\t\t\tOR (b_start >= {$since} AND b_end <= {$now}) \t/* All boosts that are active and do not end yet */\n\t\t\t\t\t\t)\n\t\t\t\t\tORDER BY\n\t\t\t\t\t\tlevel DESC,\n\t\t\t\t\t\tb_start\n\t\t\t\t"));
         $unique = array();
         $timeDuration = $now - $since;
         $fkeyname = $now . '_' . $since;
         $setBoosts = array();
         foreach ($l as $v) {
             if (isset($setBoosts[$v['b_ba_id']])) {
                 continue;
             }
             $setBoosts[$v['b_ba_id']] = true;
             // Check the boost start & end dates
             $start = $v['b_start'];
             $end = $v['b_end'];
             //echo 'Current time: ('.$since . ' - ' . $now . ")\n";
             //echo 'Boost time:   ('.$start . ' - ' . $end . ")\n";
             if ($since == $now) {
                 $persistence = 1;
             } else {
                 if ($since <= $start && $now >= $end) {
                     $duration = $end - $since;
                 } elseif ($since <= $start && $now <= $end) {
                     $duration = $now - $start;
                 } elseif ($since >= $start && $now >= $end) {
                     $duration = $end - $since;
                 } else {
                     $duration = $now - $since;
                 }
                 // Persistence
                 $persistence = $duration / $timeDuration;
             }
             switch ($v['b_type']) {
                 case 'spell':
                     $obj = Dolumar_Effects_Boost::getFromId($v['b_ba_id']);
                     $classname = $obj->getClassName();
                     if ($obj && (!isset($this->oBoosts[$fkeyname][$classname]) || $this->oBoosts[$fkeyname][$classname]->getLevel() < $obj->getLevel())) {
                         $obj->setVillage($this);
                         $obj->setDates($v['b_start'], $v['b_end']);
                         $obj->setPersistence($persistence);
                         $actor = self::getFromId($v['b_fromId']);
                         $isPublic = intval($v['b_secret']) == 0;
                         $obj->setActor($actor, !$isPublic);
                         $obj->setBoostId($v['b_id']);
                         // Add to the array
                         $this->oBoosts[$fkeyname][$classname] = $obj;
                     }
                     break;
             }
         }
     }
     return array_merge(array_values($this->oBoosts[$now . '_' . $since]), $this->oEffects);
 }