Exemple #1
0
 public static function insert(Dolumar_Underworld_Models_Mission $mission, Dolumar_Underworld_Models_Battle $battle)
 {
     $data = $battle->getData();
     $db = Neuron_DB_Database::getInstance();
     $f = $battle->getAttacker()->getLocation();
     $t = $battle->getDefender()->getLocation();
     $fx = $f->x();
     $fy = $f->y();
     $tx = $t->x();
     $ty = $t->y();
     $as = $battle->getAttacker()->getSide()->getId();
     $ds = $battle->getDefender()->getSide()->getId();
     $id = $db->query("\n\t\t\tINSERT INTO\n\t\t\t\tunderworld_log_battles\n\t\t\tSET\n\t\t\t\tuat_attacker = {$data['uat_attacker']},\n\t\t\t\tuat_defender = {$data['uat_defender']},\n\t\t\t\tuat_startdate = FROM_UNIXTIME({$data['startdate']}),\n\t\t\t\tuat_enddate = FROM_UNIXTIME({$data['enddate']}),\n\t\t\t\tuat_fightlog = '{$db->escape($data['uat_fightlog'])}',\n\t\t\t\tuat_from_x = {$fx},\n\t\t\t\tuat_from_y = {$fy},\n\t\t\t\tuat_to_x = {$tx},\n\t\t\t\tuat_to_y = {$ty},\n\t\t\t\tum_id = {$mission->getId()},\n\t\t\t\tuat_attacker_side = {$as},\n\t\t\t\tuat_defender_side = {$ds}\n\t\t");
     $battle->setId($id);
 }
Exemple #2
0
 public static function fight(Dolumar_Underworld_Models_Army $attacker, Dolumar_Underworld_Models_Army $target)
 {
     $dummy = new Dolumar_Players_DummyVillage();
     $slots = $target->getSlots();
     $attUnits = $attacker->getUnits($slots);
     $defUnits = $target->getUnits($slots);
     $logger = new Dolumar_Battle_Logger();
     $fight = new Dolumar_Battle_Fight($dummy, $dummy, $attUnits, $defUnits, $slots, array(), $logger);
     $fight->getResult();
     $report = Dolumar_Underworld_Models_Report::getFromLogger($logger);
     // No need to duplicate the report anymore
     //$report = Dolumar_Battle_Report::unserialize ($report->serialize ());
     // Create battle
     $battle = new Dolumar_Underworld_Models_Battle(null);
     $battle->setReport($report);
     $battle->setAttacker($attacker);
     $battle->setDefender($target);
     $battle->setStartdate(NOW);
     $battle->setEnddate(NOW + $report->getDuration());
     // Kill kill kill kill kill the units
     $fight->killUnits($fight);
     return $battle;
 }
Exemple #3
0
 /**
  *	Prc fight
  */
 private function prcFight(Dolumar_Underworld_Models_Army $target)
 {
     $battle = Dolumar_Underworld_Models_Battle::fight($this, $target);
     Dolumar_Underworld_Mappers_BattleMapper::insert($this->getMap()->getMission(), $battle);
     // Kill the appropriate units
     // We do not do that yet
     // Check who won and remove the loser
     if ($battle->isWinner($this)) {
         $target->destroy();
         $this->execMove($target->getUnderworldLocation());
     } else {
         $this->destroy();
     }
     return $battle;
 }
Exemple #4
0
 public static function addAttackLog(Dolumar_Underworld_Models_Mission $mission, Neuron_GameServer_Player $player, Dolumar_Underworld_Models_Army $attacker, Dolumar_Underworld_Models_Army $defender, Neuron_GameServer_Map_Location $location, Neuron_GameServer_Map_Path $path, Dolumar_Underworld_Models_Battle $battle)
 {
     $db = Neuron_DB_Database::getInstance();
     $missionId = self::getMissionId($mission);
     $armyId = self::getArmyId($mission, $attacker);
     $armyId2 = self::getArmyId($mission, $defender);
     $pathtxt = $path->serialize();
     $sql = "\n\t\t\tINSERT INTO\n\t\t\t\tunderworld_log_event\n\t\t\tSET\n\t\t\t\tul_m_id = '{$missionId}',\n\t\t\t\tplid = '{$player->getId()}',\n\t\t\t\tul_a_vid = '{$armyId}',\n\t\t\t\tul_e_action = 'ATTACK',\n\t\t\t\tul_e_x = '{$location->x()}',\n\t\t\t\tul_e_y = '{$location->y()}',\n\t\t\t\tul_a2_vid = '{$armyId2}',\n\t\t\t\tul_e_extra = '{$db->escape($pathtxt)}',\n\t\t\t\tuat_id = {$battle->getId()},\n\t\t\t\tul_e_date = NOW()\n\t\t";
     $db->query($sql);
 }