Пример #1
0
 public function getEffect($data)
 {
     if (!$data instanceof Dolumar_Effects_Effect) {
         $data = Dolumar_Effects_Effect::getFromId($data);
     }
     foreach ($this->getEffects() as $v) {
         if ($data->equals($v)) {
             return $v;
         }
         /*
         if (strtolower ($v->getClassName ()) == $sName || $v instanceof $sOrgName)
         {
         	return $v;
         }
         */
     }
     return false;
 }
Пример #2
0
 private function getEffectStats()
 {
     $effects = Dolumar_Effects_Effect::getEffects();
     $html = '<h2>Effects</h2>';
     $html .= '<div class="effect-report">';
     foreach ($effects as $v) {
         $html .= '<div class="effect fancybox">';
         $html .= '<h3>' . $v->getName() . '</h3>';
         for ($i = 1; $i <= 5; $i++) {
             $v->setLevel($i);
             $html .= '<div class="effect-level">';
             $html .= '<h4>Level ' . $i . ' ' . $v->getType_text() . '</h4>';
             $html .= '<p>' . $v->getDescription() . '</p>';
             $html .= '<p class="difficulty">Difficulty: ' . $v->getDifficulty() . '</p>';
             $html .= '</div>';
         }
         $html .= '</div>';
     }
     $html .= '</div>';
     return $html;
 }
Пример #3
0
 public function getFightReport($now = NOW, $logid = null, $showAll = false)
 {
     $text = Neuron_Core_Text::__getInstance();
     $this->loadData();
     $data = $this->data['battleLog'];
     // Check how much "report" can be seen
     $fightStart = $this->data['fightDate'];
     $out = array();
     $data = explode(';', $data);
     array_pop($data);
     $lastAction = null;
     $out[] = Neuron_Core_Tools::putIntoText($text->getRandomLine('introtext', 'battlereport', $this->id), array('attacker' => $this->getAttacker()->getName(), 'defender' => $this->getDefender()->getName()));
     $isDone = $showAll || $this->isDone();
     $slots = json_decode($this->data['slots'], true);
     if (isset($slots['attacking']) && isset($slots['defending'])) {
         // Create thze battle report
         $attacking = $this->parseUnitSlots($slots['attacking']);
         $defending = $this->parseUnitSlots($slots['defending']);
         $this->oBattlefield = new Dolumar_Battle_Battlefield($attacking, $defending);
     } else {
         $this->oBattlefield = new Dolumar_Battle_Battlefield(null, null);
     }
     $i = 0;
     foreach ($data as $v) {
         $facts = explode('|', $v);
         $orgfacts = $facts;
         if (count($facts) > 3) {
             // Fetch the date from the data
             $iDate = array_shift($facts);
             // Jump out of the loop if date is in the future
             if (!$isDone && $iDate + $fightStart > time()) {
                 break;
             }
             $iAction = intval(array_shift($facts));
             $iRandom = array_shift($facts);
             // $iTeam: attacker = 1, defender = 2.
             $iTeam = array_shift($facts);
             $isAttacker = $iTeam == 1;
             $date = Neuron_Core_Tools::getDuration($iDate);
             // Check for "empty" status report
             if ($lastAction === 0 && $iAction === 0) {
                 array_pop($out);
             }
             $lastAction = $iAction;
             // Check if we should push this log to the battlefield
             if ($logid != null && $logid == $i) {
                 $selected = true;
                 $usefield = true;
             } else {
                 $selected = false;
                 $usefield = $logid === null || $logid > $i;
             }
             switch ($iAction) {
                 // Status
                 case 0:
                     //$out[] = null;
                     $out[] = $text->getRandomLine('status_' . $facts[0], 'battlereport', $iRandom);
                     if ($usefield) {
                         $this->oBattlefield->nextround();
                     }
                     break;
                     // Move
                 // Move
                 case 1:
                     $unit = $this->getUnitData($facts[0]);
                     $out[] = Neuron_Core_Tools::putIntoText($text->getRandomLine('move', 'battlereport', $iRandom, $unit), array('unit' => (string) $unit, 'from' => $facts[1], 'to' => $facts[2]));
                     if ($usefield) {
                         $this->oBattlefield->move($isAttacker, $facts[1], $facts[2], $unit);
                     }
                     break;
                     // Stunned
                 // Stunned
                 case 2:
                     $unit = $this->getUnitData($facts[0]);
                     $slot = $this->getUnitSlot($facts[0]);
                     $out[] = Neuron_Core_Tools::putIntoText($text->getRandomLine('stunned', 'battlereport', $iRandom), array('unit' => (string) $unit));
                     if ($usefield) {
                         $this->oBattlefield->stunned(!$isAttacker, $slot, $unit);
                     }
                     break;
                     // Magic
                 // Magic
                 case 5:
                     /* 112|5|68|1|1:1|3|4:3:7::0:50|8 */
                     // unit | effect | probability
                     $unitData = explode(':', array_shift($facts));
                     $unit = Dolumar_SpecialUnits_SpecialUnits::getFromId($unitData[0]);
                     if ($unit) {
                         $unit->setLevel($unitData[1]);
                         $unit->setVillage($this->getAttacker());
                         $effectId = array_shift($facts);
                         $effect = Dolumar_Effects_Effect::getFromId($effectId);
                         $probability = array_shift($facts);
                         if ($effect && $effect instanceof Dolumar_Effects_Battle) {
                             $out[] = $effect->getBattleLog($this, $unit, $probability, $facts);
                             if ($usefield) {
                                 $this->oBattlefield->specialunit_action($isAttacker, $unit, $effect, true);
                             }
                         } else {
                             $out[] = 'Unidentified battle effect: ' . $effectId;
                         }
                     } else {
                         $out[] = 'Unidentified battle effect user: '******':', array_shift($facts));
                     $unit = Dolumar_SpecialUnits_SpecialUnits::getFromId($unitData[0]);
                     $unit->setLevel($unitData[1]);
                     $unit->setVillage($this->getAttacker());
                     $effectId = array_shift($facts);
                     $effect = Dolumar_Effects_Effect::getFromId($effectId);
                     $probability = array_shift($facts);
                     if ($effect && $effect instanceof Dolumar_Effects_Battle) {
                         $out[] = $effect->getFailedLog($this, $unit, $probability, $facts);
                         if ($usefield) {
                             $this->oBattlefield->specialunit_action($isAttacker, $unit, $effect, false);
                         }
                     }
                     break;
                     // Dead special units
                 // Dead special units
                 case 7:
                     /* 158|6|59|1|1:1|3 */
                     $unitData = explode(':', array_shift($facts));
                     $unit = Dolumar_SpecialUnits_SpecialUnits::getFromId($unitData[0]);
                     $unit->setLevel($unitData[1]);
                     $unit->setVillage($this->getAttacker());
                     $out[] = Neuron_Core_Tools::putIntoText($text->getRandomLine('specialunitdied', 'battlereport', $iRandom), array('unit' => $unit->getName(), 'level' => $unit->getLevel()));
                     if ($usefield) {
                         $this->oBattlefield->specialunit_dead($isAttacker, $effect, false);
                     }
                     break;
                     // whiped units
                 // whiped units
                 case 8:
                     $unit = $this->getUnitData($facts[0]);
                     $out[] = Neuron_Core_Tools::putIntoText($text->getRandomLine('whipe', 'battlereport', $iRandom), array('unit' => (string) $unit, 'date' => $date));
                     if ($usefield) {
                         $this->oBattlefield->whipe($isAttacker, $this->getUnitSlot($facts[0]), $unit);
                     }
                     break;
                 case 9:
                     $unit = $this->getUnitData($facts[0]);
                     $out[] = Neuron_Core_Tools::putIntoText($text->getRandomLine('flee', 'battlereport', $iRandom), array('unit' => (string) $unit, 'date' => $date));
                     if ($usefield) {
                         $this->oBattlefield->flee($isAttacker, $this->getUnitSlot($facts[0]), $unit);
                     }
                     break;
                     // Damage
                 // Damage
                 case 10:
                 case 11:
                 case 12:
                     switch ($iAction) {
                         case 11:
                             $damage = 'melee';
                             break;
                         case 12:
                             $damage = 'shooting';
                             break;
                         default:
                             $damage = 'error';
                             break;
                     }
                     $attacker = $this->getUnitData($facts[0]);
                     $defender = $this->getUnitData($facts[1]);
                     $out[] = Neuron_Core_Tools::putIntoText($text->getRandomLine('casualties_' . $damage, 'battlereport', $iRandom), array('attacker' => (string) $attacker, 'defender' => (string) $defender, 'amount' => $facts[2], 'date' => $date, 'frontage' => $this->getUnitFrontage($facts[0])));
                     if ($usefield) {
                         $this->oBattlefield->damage($isAttacker, $this->getUnitSlot($facts[0]), $this->getUnitSlot($facts[1]), $facts[2], $attacker, $defender);
                     }
                     break;
                     // Default
                 // Default
                 default:
                     $out[] = $date . ' Unknown log: ' . $iAction;
                     break;
             }
             $i = count($out);
         }
     }
     if (!$isDone) {
         $out[] = '...';
     }
     return $out;
 }
Пример #4
0
 public function getAvailableEffect($objSpell)
 {
     if (!$objSpell instanceof Dolumar_Effects_Effect) {
         $objSpell = Dolumar_Effects_Effect::getFromId($objSpell);
     }
     if ($objSpell) {
         foreach ($this->getAvailableEffects() as $v) {
             if ($v->equals($objSpell)) {
                 return $v;
             }
         }
     }
     return false;
 }