当前位置: 首页>>代码示例>>PHP>>正文


PHP getFactors函数代码示例

本文整理汇总了PHP中getFactors函数的典型用法代码示例。如果您正苦于以下问题:PHP getFactors函数的具体用法?PHP getFactors怎么用?PHP getFactors使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了getFactors函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: TargetEvent

    function TargetEvent()
    {
        global $pricelist, $resource;
        $resourceIDs = array(901, 902, 903, 921);
        $debrisIDs = array(901, 902);
        $resQuery = array();
        $collectQuery = array();
        $collectedGoods = array();
        foreach ($debrisIDs as $debrisID) {
            $collectedGoods[$debrisID] = 0;
            $resQuery[] = 'der_' . $resource[$debrisID];
        }
        $sql = 'SELECT ' . implode(',', $resQuery) . ', (' . implode(' + ', $resQuery) . ') as total
		FROM %%PLANETS%% WHERE id = :planetId';
        $targetData = Database::get()->selectSingle($sql, array(':planetId' => $this->_fleet['fleet_end_id']));
        if (!empty($targetData['total'])) {
            $sql = 'SELECT * FROM %%USERS%% WHERE id = :userId;';
            $targetUser = Database::get()->selectSingle($sql, array(':userId' => $this->_fleet['fleet_owner']));
            $targetUserFactors = getFactors($targetUser);
            $shipStorageFactor = 1 + $targetUserFactors['ShipStorage'];
            // Get fleet capacity
            $fleetData = FleetFunctions::unserialize($this->_fleet['fleet_array']);
            $recyclerStorage = 0;
            $otherFleetStorage = 0;
            foreach ($fleetData as $shipId => $shipAmount) {
                if ($shipId == 209 || $shipId == 219) {
                    $recyclerStorage += $pricelist[$shipId]['capacity'] * $shipAmount;
                } else {
                    $otherFleetStorage += $pricelist[$shipId]['capacity'] * $shipAmount;
                }
            }
            $recyclerStorage *= $shipStorageFactor;
            $otherFleetStorage *= $shipStorageFactor;
            $incomingGoods = 0;
            foreach ($resourceIDs as $resourceID) {
                $incomingGoods += $this->_fleet['fleet_resource_' . $resource[$resourceID]];
            }
            $totalStorage = $recyclerStorage + min(0, $otherFleetStorage - $incomingGoods);
            $param = array(':planetId' => $this->_fleet['fleet_end_id']);
            // fast way
            $collectFactor = min(1, $totalStorage / $targetData['total']);
            foreach ($debrisIDs as $debrisID) {
                $fleetColName = 'fleet_resource_' . $resource[$debrisID];
                $debrisColName = 'der_' . $resource[$debrisID];
                $collectedGoods[$debrisID] = ceil($targetData[$debrisColName] * $collectFactor);
                $collectQuery[] = $debrisColName . ' = GREATEST(0, ' . $debrisColName . ' - :' . $resource[$debrisID] . ')';
                $param[':' . $resource[$debrisID]] = $collectedGoods[$debrisID];
                $this->UpdateFleet($fleetColName, $this->_fleet[$fleetColName] + $collectedGoods[$debrisID]);
            }
            $sql = 'UPDATE %%PLANETS%% SET ' . implode(',', $collectQuery) . ' WHERE id = :planetId;';
            Database::get()->update($sql, $param);
        }
        $LNG = $this->getLanguage(NULL, $this->_fleet['fleet_owner']);
        $Message = sprintf($LNG['sys_recy_gotten'], pretty_number($collectedGoods[901]), $LNG['tech'][901], pretty_number($collectedGoods[902]), $LNG['tech'][902]);
        PlayerUtil::sendMessage($this->_fleet['fleet_owner'], 0, $LNG['sys_mess_tower'], 5, $LNG['sys_recy_report'], $Message, $this->_fleet['fleet_start_time'], NULL, 1, $this->_fleet['fleet_universe']);
        $this->setState(FLEET_RETURN);
        $this->SaveFleet();
    }
开发者ID:bergi9,项目名称:2Moons,代码行数:58,代码来源:MissionCaseRecycling.class.php

示例2: TargetEvent

    function TargetEvent()
    {
        $senderUser = $GLOBALS['DATABASE']->getFirstRow("SELECT * FROM " . USERS . " WHERE id = " . $this->_fleet['fleet_owner'] . ";");
        $senderUser['factor'] = getFactors($senderUser, 'basic', $this->_fleet['fleet_start_time']);
        $fleetArray = fleetAmountToArray($this->_fleet['fleet_array']);
        $duration = $this->_fleet['fleet_start_time'] - $this->_fleet['start_time'];
        require_once 'includes/classes/class.FleetFunctions.php';
        $fleetMaxSpeed = FleetFunctions::GetFleetMaxSpeed($fleetArray, $senderUser);
        $SpeedFactor = FleetFunctions::GetGameSpeedFactor();
        $distance = FleetFunctions::GetTargetDistance(array($this->_fleet['fleet_start_galaxy'], $this->_fleet['fleet_start_system'], $this->_fleet['fleet_start_planet']), array($this->_fleet['fleet_end_galaxy'], $this->_fleet['fleet_end_system'], $this->_fleet['fleet_end_planet']));
        $consumption = FleetFunctions::GetFleetConsumption($fleetArray, $duration, $distance, $fleetMaxSpeed, $senderUser, $SpeedFactor);
        $this->UpdateFleet('fleet_resource_elyrium', $this->_fleet['fleet_resource_elyrium'] + $consumption / 2);
        $LNG = $this->getLanguage($senderUser['lang']);
        $TargetUserID = $this->_fleet['fleet_target_owner'];
        $TargetMessage = '<div style="text-align : justify;">
    	' . $LNG['fleet_deploy_9'] . ' :
    </div>

    <div class="citation">
        <div class="guillemet ouvrir">«</div>
        <div class="guillemet fermer">»</div>
        
                ' . $LNG['fleet_deploy_10'] . ' Base Alpha 5 [' . $this->_fleet['fleet_end_system'] . ':' . $this->_fleet['fleet_end_planet'] . '] ' . $LNG['fleet_deploy_11'] . '
                <br>
        <div style="padding-left : 20px; padding-top : 10px;">
            — ' . $LNG['fleet_deploy_12'] . ' ' . date('d/m/Y H:i:s', TIMESTAMP) . '<br>
            — ' . $LNG['fleet_deploy_13'] . ' : Home001 [' . $this->_fleet['fleet_start_system'] . ':' . $this->_fleet['fleet_start_planet'] . ']<br>
            — ' . $LNG['fleet_deploy_14'] . ' : Base Alpha 5 [' . $this->_fleet['fleet_end_system'] . ':' . $this->_fleet['fleet_end_planet'] . '] <br>
        </div>
    </div>
  
                       <h3>' . $LNG['fleet_deploy_7'] . ' :</h3>
            <div class="conteneur_item" style="margin-top : 5px;">
                    <div class="element_item">
                        <img src="/media/ingame/image/metal.jpg">
                        ' . $LNG['tech'][901] . ' : <span class="orange">' . pretty_number($this->_fleet['fleet_resource_metal']) . '</span> ' . $LNG['lm_achat_units'] . '
                    </div>    
					<div class="element_item">
                        <img src="/media/ingame/image/oro.jpg">
                        ' . $LNG['tech'][902] . ' : <span class="orange">' . pretty_number($this->_fleet['fleet_resource_crystal']) . '</span> ' . $LNG['lm_achat_units'] . '
                    </div> 
					<div class="element_item">
                        <img src="/media/ingame/image/crystal.jpg">
                        ' . $LNG['tech'][903] . ' : <span class="orange">' . pretty_number($this->_fleet['fleet_resource_deuterium']) . '</span> ' . $LNG['lm_achat_units'] . '
                    </div> 
					<div class="element_item">
                        <img src="/media/ingame/image/elyrium.jpg">
                        ' . $LNG['tech'][904] . ' : <span class="orange">' . pretty_number($this->_fleet['fleet_resource_elyrium']) . '</span> ' . $LNG['lm_achat_units'] . '
                    </div> 
                        </div>
                                                    
    <div class="explication_utilisateur">
        ' . $LNG['fleet_deploy_15'] . '
    </div>';
        SendSimpleMessage($TargetUserID, 0, $this->_fleet['fleet_start_time'], 7, $LNG['sys_mess_tower_deploy_good'], $LNG['sys_stat_mess_stay'], $TargetMessage);
        $this->RestoreFleet(false);
    }
开发者ID:fuding,项目名称:Antaris,代码行数:57,代码来源:MissionCaseStay.php

示例3: TargetEvent

 function TargetEvent()
 {
     global $resource;
     $iPlanetCount = $GLOBALS['DATABASE']->getFirstCell("SELECT COUNT(*) FROM " . PLANETS . " WHERE `id_owner` = '" . $this->_fleet['fleet_owner'] . "' AND `planet_type` = '1' AND `destruyed` = '0';");
     $iGalaxyPlace = $GLOBALS['DATABASE']->getFirstCell("SELECT COUNT(*) FROM " . PLANETS . " WHERE `id` = '" . $this->_fleet['fleet_end_id'] . "';");
     $senderUser = $GLOBALS['DATABASE']->getFirstRow("SELECT * FROM " . USERS . " WHERE `id` = '" . $this->_fleet['fleet_owner'] . "';");
     $senderPlanet = $GLOBALS['DATABASE']->getFirstRow("SELECT * FROM " . PLANETS . " WHERE `id` = '" . $this->_fleet['fleet_start_id'] . "';");
     $senderUser['factor'] = getFactors($senderUser, 'basic', $this->_fleet['fleet_start_time']);
     $LNG = $this->getLanguage($senderUser['lang']);
     $MaxPlanets = PlayerUtil::maxPlanetCount($senderUser);
     if ($iGalaxyPlace != 0) {
         $TheMessage = sprintf($LNG['sys_colo_notfree'], GetTargetAdressLink($this->_fleet, ''));
         $this->setState(FLEET_RETURN);
     } elseif ($iPlanetCount >= $MaxPlanets) {
         $TheMessage = sprintf($LNG['sys_colo_maxcolo'], GetTargetAdressLink($this->_fleet, ''), $MaxPlanets);
         $this->setState(FLEET_RETURN);
     } elseif (PlayerUtil::allowPlanetPosition($this->_fleet['fleet_end_planet'], $senderUser) == false) {
         $TheMessage = sprintf($LNG['sys_colo_notech'], GetTargetAdressLink($this->_fleet, ''), $MaxPlanets);
         $this->setState(FLEET_RETURN);
     } else {
         require_once 'includes/functions/CreateOnePlanetRecord.php';
         $NewOwnerPlanet = CreateOnePlanetRecord($this->_fleet['fleet_end_galaxy'], $this->_fleet['fleet_end_system'], $this->_fleet['fleet_end_planet'], $this->_fleet['fleet_universe'], $this->_fleet['fleet_owner'], $LNG['fcp_colony'], false, $senderUser['authlevel']);
         if ($NewOwnerPlanet === false) {
             $TheMessage = sprintf($LNG['sys_colo_badpos'], GetTargetAdressLink($this->_fleet, ''));
             $this->setState(FLEET_RETURN);
         } else {
             $this->_fleet['fleet_end_id'] = $NewOwnerPlanet;
             $TheMessage = sprintf($LNG['sys_colo_allisok'], GetTargetAdressLink($this->_fleet, ''));
             $this->StoreGoodsToPlanet();
             if ($this->_fleet['fleet_amount'] == 1) {
                 $this->KillFleet();
             } else {
                 $CurrentFleet = explode(";", $this->_fleet['fleet_array']);
                 $NewFleet = '';
                 foreach ($CurrentFleet as $Item => $Group) {
                     if (empty($Group)) {
                         continue;
                     }
                     $Class = explode(",", $Group);
                     if ($Class[0] == 208 && $Class[1] > 1) {
                         $NewFleet .= $Class[0] . "," . ($Class[1] - 1) . ";";
                     } elseif ($Class[0] != 208 && $Class[1] > 0) {
                         $NewFleet .= $Class[0] . "," . $Class[1] . ";";
                     }
                 }
                 $this->UpdateFleet('fleet_array', $NewFleet);
                 $this->UpdateFleet('fleet_amount', $this->_fleet['fleet_amount'] - 1);
                 $this->UpdateFleet('fleet_resource_metal', 0);
                 $this->UpdateFleet('fleet_resource_crystal', 0);
                 $this->UpdateFleet('fleet_resource_deuterium', 0);
                 $this->setState(FLEET_RETURN);
             }
         }
     }
     SendSimpleMessage($this->_fleet['fleet_owner'], 0, $this->_fleet['fleet_start_time'], 4, $LNG['sys_colo_mess_from'], $LNG['sys_colo_mess_report'], $TheMessage);
     $this->SaveFleet();
 }
开发者ID:Decoder1978,项目名称:Xterium,代码行数:57,代码来源:MissionCaseColonisation.php

示例4: TargetEvent

 function TargetEvent()
 {
     global $pricelist, $reslist, $resource;
     $resourceIDs = array(901, 902, 903, 921);
     $debrisIDs = array(901, 902);
     $resQuery = array();
     $collectQuery = array();
     $collectedGoods = array();
     foreach ($debrisIDs as $debrisID) {
         $collectedGoods[$debrisID] = 0;
         $resQuery[] = 'der_' . $resource[$debrisID];
     }
     $targetData = $GLOBALS['DATABASE']->getFirstRow("SELECT " . implode(',', $resQuery) . ", (" . implode(' + ', $resQuery) . ") as total FROM " . PLANETS . " WHERE id = " . $this->_fleet['fleet_end_id'] . ";");
     if (!empty($targetData['total'])) {
         $targetUser = $GLOBALS['DATABASE']->getFirstRow("SELECT * FROM " . USERS . " WHERE id = " . $this->_fleet['fleet_owner'] . ";");
         $targetUserFactors = getFactors($targetUser);
         $shipStorageFactor = 1 + $targetUserFactors['ShipStorage'];
         // Get fleet capacity
         $fleetData = explode(";", $this->_fleet['fleet_array']);
         $recyclerStorage = 0;
         $otherFleetStorage = 0;
         foreach ($fleetData as $fleetRow) {
             if (empty($fleetRow)) {
                 continue;
             }
             $temp = explode(",", $fleetRow);
             if ($temp[0] == 209 || $temp[0] == 219) {
                 $recyclerStorage += $pricelist[$temp[0]]['capacity'] * $temp[1];
             } else {
                 $otherFleetStorage += $pricelist[$temp[0]]['capacity'] * $temp[1];
             }
         }
         $recyclerStorage *= $shipStorageFactor;
         $otherFleetStorage *= $shipStorageFactor;
         unset($temp);
         $incomingGoods = 0;
         foreach ($resourceIDs as $resourceID) {
             $incomingGoods += $this->_fleet['fleet_resource_' . $resource[$resourceID]];
         }
         $totalStorage = $recyclerStorage + min(0, $otherFleetStorage - $incomingGoods);
         // fast way
         $collectFactor = min(1, $totalStorage / $targetData['total']);
         foreach ($debrisIDs as $debrisID) {
             $collectedGoods[$debrisID] = ceil($targetData['der_' . $resource[$debrisID]] * $collectFactor);
             $collectQuery[] = 'der_' . $resource[$debrisID] . ' = GREATEST(0, der_' . $resource[$debrisID] . ' - ' . $collectedGoods[$debrisID] . ')';
             $this->UpdateFleet('fleet_resource_' . $resource[$debrisID], $this->_fleet['fleet_resource_' . $resource[$debrisID]] + $collectedGoods[$debrisID]);
         }
         $GLOBALS['DATABASE']->query("UPDATE " . PLANETS . " SET " . implode(',', $collectQuery) . " WHERE id = " . $this->_fleet['fleet_end_id'] . ";");
     }
     $LNG = $this->getLanguage(NULL, $this->_fleet['fleet_owner']);
     $Message = sprintf($LNG['sys_recy_gotten'], pretty_number($collectedGoods[901]), $LNG['tech'][901], pretty_number($collectedGoods[902]), $LNG['tech'][902]);
     SendSimpleMessage($this->_fleet['fleet_owner'], 0, $this->_fleet['fleet_start_time'], 5, $LNG['sys_mess_tower'], $LNG['sys_recy_report'], $Message);
     $this->setState(FLEET_RETURN);
     $this->SaveFleet();
 }
开发者ID:Decoder1978,项目名称:Xterium,代码行数:55,代码来源:MissionCaseRecycling.php

示例5: TargetEvent

 function TargetEvent()
 {
     $sql = 'SELECT * FROM %%USERS%% WHERE id = :userId;';
     $senderUser = Database::get()->selectSingle($sql, array(':userId' => $this->_fleet['fleet_owner']));
     $senderUser['factor'] = getFactors($senderUser, 'basic', $this->_fleet['fleet_start_time']);
     $fleetArray = FleetFunctions::unserialize($this->_fleet['fleet_array']);
     $duration = $this->_fleet['fleet_start_time'] - $this->_fleet['start_time'];
     $SpeedFactor = FleetFunctions::GetGameSpeedFactor();
     $distance = FleetFunctions::GetTargetDistance(array($this->_fleet['fleet_start_galaxy'], $this->_fleet['fleet_start_system'], $this->_fleet['fleet_start_planet']), array($this->_fleet['fleet_end_galaxy'], $this->_fleet['fleet_end_system'], $this->_fleet['fleet_end_planet']));
     $consumption = FleetFunctions::GetFleetConsumption($fleetArray, $duration, $distance, $senderUser, $SpeedFactor);
     $this->UpdateFleet('fleet_resource_deuterium', $this->_fleet['fleet_resource_deuterium'] + $consumption / 2);
     $LNG = $this->getLanguage($senderUser['lang']);
     $TargetUserID = $this->_fleet['fleet_target_owner'];
     $TargetMessage = sprintf($LNG['sys_stat_mess'], GetTargetAddressLink($this->_fleet, ''), pretty_number($this->_fleet['fleet_resource_metal']), $LNG['tech'][901], pretty_number($this->_fleet['fleet_resource_crystal']), $LNG['tech'][902], pretty_number($this->_fleet['fleet_resource_deuterium']), $LNG['tech'][903]);
     PlayerUtil::sendMessage($TargetUserID, 0, $LNG['sys_mess_tower'], 5, $LNG['sys_stat_mess_stay'], $TargetMessage, $this->_fleet['fleet_start_time'], NULL, 1, $this->_fleet['fleet_universe']);
     $this->RestoreFleet(false);
 }
开发者ID:tatarysh,项目名称:2Moons,代码行数:17,代码来源:MissionCaseStay.class.php

示例6: TargetEvent

 function TargetEvent()
 {
     $senderUser = $GLOBALS['DATABASE']->getFirstRow("SELECT * FROM " . USERS . " WHERE id = " . $this->_fleet['fleet_owner'] . ";");
     $senderUser['factor'] = getFactors($senderUser, 'basic', $this->_fleet['fleet_start_time']);
     $fleetArray = fleetAmountToArray($this->_fleet['fleet_array']);
     $duration = $this->_fleet['fleet_start_time'] - $this->_fleet['start_time'];
     require_once 'includes/classes/class.FleetFunctions.php';
     $fleetMaxSpeed = FleetFunctions::GetFleetMaxSpeed($fleetArray, $senderUser);
     $SpeedFactor = FleetFunctions::GetGameSpeedFactor();
     $distance = FleetFunctions::GetTargetDistance(array($this->_fleet['fleet_start_galaxy'], $this->_fleet['fleet_start_system'], $this->_fleet['fleet_start_planet']), array($this->_fleet['fleet_end_galaxy'], $this->_fleet['fleet_end_system'], $this->_fleet['fleet_end_planet']));
     $consumption = FleetFunctions::GetFleetConsumption($fleetArray, $duration, $distance, $fleetMaxSpeed, $senderUser, $SpeedFactor);
     $this->UpdateFleet('fleet_resource_deuterium', $this->_fleet['fleet_resource_deuterium'] + $consumption / 2);
     $LNG = $this->getLanguage($senderUser['lang']);
     $TargetUserID = $this->_fleet['fleet_target_owner'];
     $TargetMessage = sprintf($LNG['sys_stat_mess'], GetTargetAdressLink($this->_fleet, ''), pretty_number($this->_fleet['fleet_resource_metal']), $LNG['tech'][901], pretty_number($this->_fleet['fleet_resource_crystal']), $LNG['tech'][902], pretty_number($this->_fleet['fleet_resource_deuterium']), $LNG['tech'][903]);
     SendSimpleMessage($TargetUserID, 0, $this->_fleet['fleet_start_time'], 5, $LNG['sys_mess_tower'], $LNG['sys_stat_mess_stay'], $TargetMessage);
     $this->RestoreFleet(false);
 }
开发者ID:Decoder1978,项目名称:Xterium,代码行数:18,代码来源:MissionCaseStay.php

示例7: TargetEvent

    function TargetEvent()
    {
        global $resource, $reslist;
        $db = Database::get();
        $fleetAttack = array();
        $fleetDefend = array();
        $userAttack = array();
        $userDefend = array();
        $incomingFleets = array();
        $stealResource = array(901 => 0, 902 => 0, 903 => 0);
        $debris = array();
        $planetDebris = array();
        $debrisResource = array(901, 902);
        $messageHTML = <<<HTML
<div class="raportMessage">
\t<table>
\t\t<tr>
\t\t\t<td colspan="2"><a href="game.php?page=raport&raport=%s" target="_blank"><span class="%s">%s %s (%s)</span></a></td>
\t\t</tr>
\t\t<tr>
\t\t\t<td>%s</td><td><span class="%s">%s: %s</span>&nbsp;<span class="%s">%s: %s</span></td>
\t\t</tr>
\t\t<tr>
\t\t\t<td>%s</td><td><span>%s:&nbsp;<span class="reportSteal element901">%s</span>&nbsp;</span><span>%s:&nbsp;<span class="reportSteal element902">%s</span>&nbsp;</span><span>%s:&nbsp;<span class="reportSteal element903">%s</span></span></td>
\t\t</tr>
\t\t<tr>
\t\t\t<td>%s</td><td><span>%s:&nbsp;<span class="reportDebris element901">%s</span>&nbsp;</span><span>%s:&nbsp;<span class="reportDebris element902">%s</span></span></td>
\t\t</tr>
\t</table>
</div>
HTML;
        //Minize HTML
        $messageHTML = str_replace(array("\n", "\t", "\r"), "", $messageHTML);
        $sql = "SELECT * FROM %%PLANETS%% WHERE id = :planetId;";
        $targetPlanet = $db->selectSingle($sql, array(':planetId' => $this->_fleet['fleet_end_id']));
        $sql = "SELECT * FROM %%USERS%% WHERE id = :userId;";
        $targetUser = $db->selectSingle($sql, array(':userId' => $targetPlanet['id_owner']));
        $targetUser['factor'] = getFactors($targetUser, 'basic', $this->_fleet['fleet_start_time']);
        $planetUpdater = new ResourceUpdate();
        list($targetUser, $targetPlanet) = $planetUpdater->CalcResource($targetUser, $targetPlanet, true, $this->_fleet['fleet_start_time']);
        if ($this->_fleet['fleet_group'] != 0) {
            $sql = "DELETE FROM %%AKS%% WHERE id = :acsId;";
            $db->delete($sql, array(':acsId' => $this->_fleet['fleet_group']));
            $sql = "SELECT * FROM %%FLEETS%% WHERE fleet_group = :acsId;";
            $incomingFleetsResult = $db->select($sql, array(':acsId' => $this->_fleet['fleet_group']));
            foreach ($incomingFleetsResult as $incomingFleetRow) {
                $incomingFleets[$incomingFleetRow['fleet_id']] = $incomingFleetRow;
            }
            unset($incomingFleetsResult);
        } else {
            $incomingFleets = array($this->_fleet['fleet_id'] => $this->_fleet);
        }
        foreach ($incomingFleets as $fleetID => $fleetDetail) {
            $sql = "SELECT * FROM %%USERS%% WHERE id = :userId;";
            $fleetAttack[$fleetID]['player'] = $db->selectSingle($sql, array(':userId' => $fleetDetail['fleet_owner']));
            $fleetAttack[$fleetID]['player']['factor'] = getFactors($fleetAttack[$fleetID]['player'], 'attack', $this->_fleet['fleet_start_time']);
            $fleetAttack[$fleetID]['fleetDetail'] = $fleetDetail;
            $fleetAttack[$fleetID]['unit'] = FleetFunctions::unserialize($fleetDetail['fleet_array']);
            $userAttack[$fleetAttack[$fleetID]['player']['id']] = $fleetAttack[$fleetID]['player']['username'];
        }
        $sql = "SELECT * FROM %%FLEETS%%\n\t\tWHERE fleet_mission\t\t= :mission\n\t\tAND fleet_end_id\t\t= :fleetEndId\n\t\tAND fleet_start_time \t<= :timeStamp\n\t\tAND fleet_end_stay \t\t>= :timeStamp;";
        $targetFleetsResult = $db->select($sql, array(':mission' => 5, ':fleetEndId' => $this->_fleet['fleet_end_id'], ':timeStamp' => TIMESTAMP));
        foreach ($targetFleetsResult as $fleetDetail) {
            $fleetID = $fleetDetail['fleet_id'];
            $sql = "SELECT * FROM %%USERS%% WHERE id = :userId;";
            $fleetDefend[$fleetID]['player'] = $db->selectSingle($sql, array(':userId' => $fleetDetail['fleet_owner']));
            $fleetDefend[$fleetID]['player']['factor'] = getFactors($fleetDefend[$fleetID]['player'], 'attack', $this->_fleet['fleet_start_time']);
            $fleetDefend[$fleetID]['fleetDetail'] = $fleetDetail;
            $fleetDefend[$fleetID]['unit'] = FleetFunctions::unserialize($fleetDetail['fleet_array']);
            $userDefend[$fleetDefend[$fleetID]['player']['id']] = $fleetDefend[$fleetID]['player']['username'];
        }
        unset($targetFleetsResult);
        $fleetDefend[0]['player'] = $targetUser;
        $fleetDefend[0]['player']['factor'] = getFactors($fleetDefend[0]['player'], 'attack', $this->_fleet['fleet_start_time']);
        $fleetDefend[0]['fleetDetail'] = array('fleet_start_galaxy' => $targetPlanet['galaxy'], 'fleet_start_system' => $targetPlanet['system'], 'fleet_start_planet' => $targetPlanet['planet'], 'fleet_start_type' => $targetPlanet['planet_type']);
        $fleetDefend[0]['unit'] = array();
        foreach (array_merge($reslist['fleet'], $reslist['defense']) as $elementID) {
            if (empty($targetPlanet[$resource[$elementID]])) {
                continue;
            }
            $fleetDefend[0]['unit'][$elementID] = $targetPlanet[$resource[$elementID]];
        }
        $userDefend[$fleetDefend[0]['player']['id']] = $fleetDefend[0]['player']['username'];
        require_once 'includes/classes/missions/functions/calculateAttack.php';
        $fleetIntoDebris = Config::get($this->_fleet['fleet_universe'])->Fleet_Cdr;
        $defIntoDebris = Config::get($this->_fleet['fleet_universe'])->Defs_Cdr;
        $combatResult = calculateAttack($fleetAttack, $fleetDefend, $fleetIntoDebris, $defIntoDebris);
        foreach ($fleetAttack as $fleetID => $fleetDetail) {
            $fleetArray = '';
            $totalCount = 0;
            $fleetDetail['unit'] = array_filter($fleetDetail['unit']);
            foreach ($fleetDetail['unit'] as $elementID => $amount) {
                $fleetArray .= $elementID . ',' . floattostring($amount) . ';';
                $totalCount += $amount;
            }
            if ($totalCount == 0) {
                if ($this->_fleet['fleet_id'] == $fleetID) {
                    $this->KillFleet();
                } else {
                    $sql = 'DELETE %%FLEETS%%, %%FLEETS_EVENT%%
//.........这里部分代码省略.........
开发者ID:sincilite,项目名称:Evermoon,代码行数:101,代码来源:MissionCaseDestruction.class.php

示例8: TargetEvent

    function TargetEvent()
    {
        global $resource, $reslist;
        $fleetAttack = array();
        $fleetDefend = array();
        $userAttack = array();
        $userDefend = array();
        $stealResource = array(901 => 0, 902 => 0, 903 => 0, 904 => 0);
        $debris = array();
        $planetDebris = array();
        $raportInfo = array();
        $TargetOwner = $this->_fleet['fleet_target_owner'];
        $StartOwner = $this->_fleet['fleet_owner'];
        $debrisRessource = array(901, 902, 903);
        $SelectCount = $GLOBALS['DATABASE']->getFirstCell("SELECT COUNT(*) FROM uni1_buddy WHERE (sender = " . $this->_fleet['fleet_target_owner'] . " AND owner = " . $this->_fleet['fleet_owner'] . " AND state = '1') OR (sender = " . $this->_fleet['fleet_owner'] . " AND owner = " . $this->_fleet['fleet_target_owner'] . " AND state = '1');");
        if ($SelectCount > 0) {
            $senderUser = $GLOBALS['DATABASE']->getFirstRow("SELECT * FROM " . USERS . " WHERE id = " . $this->_fleet['fleet_owner'] . ";");
            $LNG = $this->getLanguage($senderUser['lang']);
            $TheMessage = '<div style="text-align : justify;">
        ' . sprintf($LNG['ls_fts_colo_1'], $this->_fleet['fleet_end_system'], $this->_fleet['fleet_end_planet'], $LNG['type_missionbis'][$this->_fleet['fleet_mission']]) . '
    </div>
  
    <div class="citation">
        <div class="guillemet ouvrir">«</div>
        <div class="guillemet fermer">»</div>
        
        ' . $LNG['ls_fts_colo_2'] . ' :
        <ul style="text-align : left;">
            <li>' . $LNG['ls_fts_colo_3'] . '</li>
            <li>' . $LNG['ls_fts_colo_4'] . '</li>
            <li>' . $LNG['ls_fts_colo_5'] . '</li>
            <li>' . $LNG['ls_fts_colo_6'] . '</li>
            <li>' . $LNG['ls_fts_colo_7'] . '</li>
            <li>' . $LNG['ls_fts_colo_8'] . '</li>
        </ul>
    </div>
        
    <div class="explication_utilisateur">
        ' . $LNG['ls_fts_colo_9'] . '
    </div>';
            SendSimpleMessage($this->_fleet['fleet_owner'], 0, $this->_fleet['fleet_start_time'], 7, $LNG['sys_colo_mess_from_text1'], sprintf($LNG['sys_colo_mess_report1'], $this->_fleet['fleet_end_system'], $this->_fleet['fleet_end_planet']), $TheMessage);
            $this->setState(FLEET_RETURN);
        } else {
            $messageHTML = <<<HTML
<div class="raportMessage">
\t<table>
\t\t<tr>
\t\t\t<td colspan="2"><a href="CombatReport.php?raport=%s" target="_blank"><span class="%s">%s %s (%s)</span></a></td>
\t\t</tr>
\t\t<tr>
\t\t\t<td>%s</td><td><span class="%s">%s: %s</span>&nbsp;<span class="%s">%s: %s</span></td>
\t\t</tr>
\t\t<tr>
\t\t\t<td>%s</td><td><span>%s:&nbsp;<span class="raportSteal element901">%s</span>&nbsp;</span><span>%s:&nbsp;<span class="raportSteal element902">%s</span>&nbsp;</span><span>%s:&nbsp;<span class="raportSteal element903">%s</span><span>%s:&nbsp;<span class="raportSteal element904">%s</span></span></td>
\t\t</tr>
\t\t<tr>
\t\t\t<td>%s</td><td><span>%s:&nbsp;<span class="raportDebris element901">%s</span>&nbsp;</span><span>%s:&nbsp;<span class="raportDebris element902">%s</span><span>%s:&nbsp;<span class="raportDebris element903">%s</span></span></td>
\t\t</tr>
\t</table>
</div>
HTML;
            //Minize HTML
            $messageHTML = str_replace(array("\n", "\t", "\r"), "", $messageHTML);
            $targetPlanet = $GLOBALS['DATABASE']->getFirstRow("SELECT * FROM " . PLANETS . " WHERE id = '" . $this->_fleet['fleet_end_id'] . "';");
            $targetUser = $GLOBALS['DATABASE']->getFirstRow("SELECT * FROM " . USERS . " WHERE id = '" . $targetPlanet['id_owner'] . "';");
            $targetUser['factor'] = getFactors($targetUser, 'basic', $this->_fleet['fleet_start_time']);
            $planetUpdater = new ResourceUpdate();
            list($targetUser, $targetPlanet) = $planetUpdater->CalcResource($targetUser, $targetPlanet, true, $this->_fleet['fleet_start_time']);
            if ($this->_fleet['fleet_group'] != 0) {
                $GLOBALS['DATABASE']->query("DELETE FROM " . AKS . " WHERE id = '" . $this->_fleet['fleet_group'] . "';");
                $incomingFleetsResult = $GLOBALS['DATABASE']->query("SELECT * FROM " . FLEETS . " WHERE fleet_group = '" . $this->_fleet['fleet_group'] . "';");
                while ($incomingFleetsRow = $GLOBALS['DATABASE']->fetch_array($incomingFleetsResult)) {
                    $incomingFleets[$incomingFleetsRow['fleet_id']] = $incomingFleetsRow;
                }
                $GLOBALS['DATABASE']->free_result($incomingFleetsResult);
            } else {
                $incomingFleets = array($this->_fleet['fleet_id'] => $this->_fleet);
            }
            foreach ($incomingFleets as $fleetID => $fleetDetail) {
                $fleetAttack[$fleetID]['fleetDetail'] = $fleetDetail;
                $fleetAttack[$fleetID]['player'] = $GLOBALS['DATABASE']->getFirstRow("SELECT * FROM " . USERS . " WHERE id = '" . $fleetDetail['fleet_owner'] . "';");
                $fleetAttack[$fleetID]['player']['factor'] = getFactors($fleetAttack[$fleetID]['player'], 'attack', $this->_fleet['fleet_start_time']);
                $fleetAttack[$fleetID]['unit'] = fleetAmountToArray($fleetDetail['fleet_array'] . ';306,' . $fleetDetail['fleet_population_306'] . ';307,' . $fleetDetail['fleet_population_307']);
                $userAttack[$fleetAttack[$fleetID]['player']['id']] = $fleetAttack[$fleetID]['player']['username'];
            }
            $targetFleetsResult = $GLOBALS['DATABASE']->query("SELECT * FROM " . FLEETS . " WHERE fleet_mission = '5' AND fleet_end_id = '" . $this->_fleet['fleet_end_id'] . "' AND fleet_start_time <= '" . TIMESTAMP . "' AND fleet_end_stay >= '" . TIMESTAMP . "';");
            while ($fleetDetail = $GLOBALS['DATABASE']->fetch_array($targetFleetsResult)) {
                $fleetID = $fleetDetail['fleet_id'];
                $fleetDefend[$fleetID]['fleetDetail'] = $fleetDetail;
                $fleetDefend[$fleetID]['player'] = $GLOBALS['DATABASE']->getFirstRow("SELECT * FROM " . USERS . " WHERE id = '" . $fleetDetail['fleet_owner'] . "';");
                $fleetDefend[$fleetID]['player']['factor'] = getFactors($fleetDefend[$fleetID]['player'], 'attack', $this->_fleet['fleet_start_time']);
                $fleetDefend[$fleetID]['unit'] = fleetAmountToArray($fleetDetail['fleet_array']);
                $userDefend[$fleetDefend[$fleetID]['player']['id']] = $fleetDefend[$fleetID]['player']['username'];
            }
            $GLOBALS['DATABASE']->free_result($targetFleetsResult);
            $fleetDefend[0]['player'] = $targetUser;
            $fleetDefend[0]['player']['factor'] = getFactors($fleetDefend[0]['player'], 'attack', $this->_fleet['fleet_start_time']);
            $fleetDefend[0]['fleetDetail'] = array('fleet_start_galaxy' => $targetPlanet['galaxy'], 'fleet_start_system' => $targetPlanet['system'], 'fleet_start_planet' => $targetPlanet['planet'], 'fleet_start_type' => $targetPlanet['planet_type']);
            $fleetDefend[0]['unit'] = array();
            $avaible_fleets = array(202, 203, 209, 223, 219, 210, 204, 205, 206, 207, 211, 214, 215, 216);
//.........这里部分代码省略.........
开发者ID:fuding,项目名称:Antaris,代码行数:101,代码来源:MissionCaseAttack.php

示例9: getFactors

<?php

function getFactors($val)
{
    $ret = [];
    for ($i = 2; $i < $val; $i++) {
        if ((int) ((double) $val / (double) $i) == (double) $val / (double) $i) {
            $ret[] = $i;
        }
    }
    return $ret;
}
//print_r ( getFactors ( 28 ) );
$divA = [];
for ($i = 1; $i <= 30; $i++) {
    foreach (getFactors($i) as $fac) {
        $divA[] = $i . ' divided by ' . $fac . ' = ';
    }
}
shuffle($divA);
//print_r( $divA );
for ($i = 0; $i < count($divA); $i++) {
    echo $divA[$i] . "\n";
}
开发者ID:raxisau,项目名称:JackBooted,代码行数:24,代码来源:division.php

示例10: TargetEvent

    function TargetEvent()
    {
        global $pricelist, $reslist, $resource;
        $resourceIDs = array(901, 902, 903, 904, 921);
        $debrisIDs = array(901, 902, 903);
        $resQuery = array();
        $collectQuery = array();
        $collectedGoods = array();
        $senderUser = $GLOBALS['DATABASE']->getFirstRow("SELECT * FROM " . USERS . " WHERE id = " . $this->_fleet['fleet_owner'] . ";");
        foreach ($debrisIDs as $debrisID) {
            $collectedGoods[$debrisID] = 0;
            $resQuery[] = 'der_' . $resource[$debrisID];
        }
        $targetData = $GLOBALS['DATABASE']->getFirstRow("SELECT " . implode(',', $resQuery) . ", (" . implode(' + ', $resQuery) . ") as total FROM " . PLANETS . " WHERE id = " . $this->_fleet['fleet_end_id'] . ";");
        if (!empty($targetData['total'])) {
            $targetUser = $GLOBALS['DATABASE']->getFirstRow("SELECT * FROM " . USERS . " WHERE id = " . $this->_fleet['fleet_owner'] . ";");
            $targetUserFactors = getFactors($targetUser);
            $shipStorageFactor = 1 + $targetUserFactors['ShipStorage'];
            // Get fleet capacity
            $fleetData = explode(";", $this->_fleet['fleet_array']);
            $recyclerStorage = 0;
            $otherFleetStorage = 0;
            foreach ($fleetData as $fleetRow) {
                if (empty($fleetRow)) {
                    continue;
                }
                $temp = explode(",", $fleetRow);
                if ($temp[0] == 209 || $temp[0] == 219 || $temp[0] == 223) {
                    $recyclerStorage += $pricelist[$temp[0]]['capacity'] * $temp[1];
                } else {
                    $otherFleetStorage += $pricelist[$temp[0]]['capacity'] * $temp[1];
                }
            }
            $recyclerStorage *= $shipStorageFactor;
            $otherFleetStorage *= $shipStorageFactor;
            unset($temp);
            $incomingGoods = 0;
            foreach ($resourceIDs as $resourceID) {
                $incomingGoods += $this->_fleet['fleet_resource_' . $resource[$resourceID]];
            }
            $totalStorage = $recyclerStorage + min(0, $otherFleetStorage - $incomingGoods);
            // fast way
            $collectFactor = min(1, $totalStorage / $targetData['total']);
            foreach ($debrisIDs as $debrisID) {
                $collectedGoods[$debrisID] = ceil($targetData['der_' . $resource[$debrisID]] * $collectFactor);
                $collectQuery[] = 'der_' . $resource[$debrisID] . ' = GREATEST(0, der_' . $resource[$debrisID] . ' - ' . $collectedGoods[$debrisID] . ')';
                $this->UpdateFleet('fleet_resource_' . $resource[$debrisID], $this->_fleet['fleet_resource_' . $resource[$debrisID]] + $collectedGoods[$debrisID]);
            }
            $GLOBALS['DATABASE']->query("UPDATE " . PLANETS . " SET " . implode(',', $collectQuery) . " WHERE id = " . $this->_fleet['fleet_end_id'] . ";");
        }
        $LNG = $this->getLanguage($senderUser['lang']);
        $TargetOwner = $this->_fleet['fleet_target_owner'];
        $StartOwner = $this->_fleet['fleet_owner'];
        if ($collectedGoods[901] + $collectedGoods[902] + $collectedGoods[903] == 0) {
            $Message = ' <div style="text-align : justify;">
        ' . $LNG['fleet_recycle_3'] . ' planète Home001 [363:7]        
                    ' . $LNG['fleet_recycle_4'] . ' ' . $this->getUsername($StartOwner) . ' <span class="orange">[testt]</span>.
                ' . $LNG['fleet_recycle_5'] . '
    </div>

	<div class="citation" style="text-align : left;">
        <div class="guillemet ouvrir">«</div>
        <div class="guillemet fermer">»</div>
                
                    ' . $LNG['fleet_recycle_6'] . ' Home001 [363:7] ' . $LNG['fleet_recycle_7'] . '.
            
            </div>
        
            <div style="margin-top : 10px;" class="rouge">' . $LNG['fleet_recycle_8'] . '</div>
        
    <div class="explication_utilisateur">
        ' . $LNG['fleet_recycle_9'] . '
    </div>';
        } else {
            $Message = sprintf($LNG['sys_recy_gotten'], pretty_number($collectedGoods[901]), $LNG['tech'][901], pretty_number($collectedGoods[902]), $LNG['tech'][902], pretty_number($collectedGoods[903]), $LNG['tech'][903]);
        }
        SendSimpleMessage($this->_fleet['fleet_owner'], 0, $this->_fleet['fleet_start_time'], 5, $LNG['sys_mess_tower'], $LNG['sys_recy_report'], $Message);
        $this->setState(FLEET_RETURN);
        $this->SaveFleet();
    }
开发者ID:fuding,项目名称:Antaris,代码行数:80,代码来源:MissionCaseRecycling.php

示例11: __construct

 function __construct($Bot)
 {
     $this->USER = $Bot;
     $this->USER['factor'] = getFactors($this->USER);
     $this->COUNT = array('PLANETS' => 0, 'MOONS' => 0);
 }
开发者ID:joancefet,项目名称:Beta7,代码行数:6,代码来源:class.bot.php

示例12: EndStayEvent


//.........这里部分代码省略.........
<td>%s</td><td><span %s>%s: %s</span>&nbsp;<span %s>%s: %s</span></td>
</tr>
<tr>
\t\t\t<td>%s</td><td><span>%s:&nbsp;<span style="color:#a47d7a;">%s</span>&nbsp;</span><span>%s:&nbsp;<span style="color:#5ca6aa;">%s</span>&nbsp;</span><span>%s:&nbsp;<span style="color:#339966;">%s</span></span></td>
\t\t</tr>
<tr>
\t\t\t<td>%s</td><td><span>%s:&nbsp;<span style="color:#a47d7a;">%s</font>&nbsp;</span><span>%s:&nbsp;<span style="color:#5ca6aa;">%s</span></span></td>
\t\t</tr>
</table>
</div>
HTML;
                //Minize HTML
                $messageHTML = str_replace(array("\n", "\t", "\r"), "", $messageHTML);
                $FindSize = mt_rand(0, 100);
                $maxAttack = 0;
                if (10 < $FindSize) {
                    $Message = $LNG['sys_expe_attack_' . $Which . '_1_' . $Rand[0]];
                    $maxAttack = 0.3 + $Add + mt_rand($Points[0], abs($Points[0])) * 0.01;
                } elseif (0 < $FindSize && 10 >= $FindSize) {
                    $Message = $LNG['sys_expe_attack_' . $Which . '_2_' . $Rand[1]];
                    $maxAttack = 0.3 + $Add + mt_rand($Points[1], abs($Points[1])) * 0.01;
                } elseif (0 == $FindSize) {
                    $Message = $LNG['sys_expe_attack_' . $Which . '_3_' . $Rand[2]];
                    $maxAttack = 0.3 + $Add + mt_rand($Points[2], abs($Points[2])) * 0.01;
                }
                foreach ($fleetArray as $ID => $count) {
                    $DefenderFleetArray .= $ID . "," . round($count * $maxAttack) . ";";
                }
                $AttackerTechno = $GLOBALS['DATABASE']->getFirstRow("SELECT * FROM " . USERS . " WHERE id = " . $this->_fleet['fleet_owner'] . ";");
                $DefenderTechno = array('id' => 0, 'username' => $Name, 'military_tech' => min($AttackerTechno['military_tech'] + $Def, 0), 'defence_tech' => min($AttackerTechno['defence_tech'] + $Def, 0), 'shield_tech' => min($AttackerTechno['shield_tech'] + $Def, 0), 'laser_tech' => 0, 'ion_tech' => 0, 'plasma_tech' => 0, 'gravity_tech' => 0, 'rpg_amiral' => 0, 'dm_defensive' => 0, 'dm_attack' => 0, 'experience_combat_level' => min($AttackerTechno['experience_combat_level'], 0), 'academy_1101' => 0, 'academy_1102' => 0, 'academy_1301' => 0, 'academy_1302' => 0, 'academy_1103' => 0, 'academy_1108' => 0, 'academy_1109' => 0, 'academy_1110' => 0, 'academy_1111' => 0, 'academy_1303' => 0, 'academy_1311' => 0);
                $fleetID = $this->_fleet['fleet_id'];
                $fleetAttack[$fleetID]['fleetDetail'] = $this->_fleet;
                $fleetAttack[$fleetID]['player'] = $AttackerTechno;
                $fleetAttack[$fleetID]['player']['factor'] = getFactors($fleetAttack[$this->_fleet['fleet_id']]['player'], 'attack', $this->_fleet['fleet_start_time']);
                $fleetAttack[$fleetID]['unit'] = array();
                $temp = explode(';', $this->_fleet['fleet_array']);
                foreach ($temp as $temp2) {
                    $temp2 = explode(',', $temp2);
                    if ($temp2[0] < 100) {
                        continue;
                    }
                    if (!isset($fleetAttack[$fleetID]['unit'][$temp2[0]])) {
                        $fleetAttack[$fleetID]['unit'][$temp2[0]] = 0;
                    }
                    $fleetAttack[$fleetID]['unit'][$temp2[0]] += $temp2[1];
                }
                $fleetDefend = array();
                $defRowDef = explode(';', $DefenderFleetArray);
                foreach ($defRowDef as $Element) {
                    $Element = explode(',', $Element);
                    if ($Element[0] < 100) {
                        continue;
                    }
                    if (!isset($fleetDefend[0]['unit'][$Element[0]])) {
                        $fleetDefend[0]['unit'][$Element[0]] = 0;
                    }
                    $fleetDefend[0]['unit'][$Element[0]] += $Element[1];
                }
                $fleetDefend[0]['fleetDetail'] = array('fleet_start_galaxy' => $this->_fleet['fleet_end_galaxy'], 'fleet_start_system' => $this->_fleet['fleet_end_system'], 'fleet_start_planet' => $this->_fleet['fleet_end_planet'], 'fleet_start_type' => 1, 'fleet_end_galaxy' => $this->_fleet['fleet_end_galaxy'], 'fleet_end_system' => $this->_fleet['fleet_end_system'], 'fleet_end_planet' => $this->_fleet['fleet_end_planet'], 'fleet_end_type' => 1, 'fleet_resource_metal' => 0, 'fleet_resource_crystal' => 0, 'fleet_resource_deuterium' => 0);
                $fleetDefend[0]['player'] = $DefenderTechno;
                $fleetDefend[0]['player']['factor'] = 0;
                require_once 'calculateAttack.php';
                $fleetIntoDebris = $GLOBALS['CONFIG'][$this->_fleet['fleet_universe']]['Fleet_Cdr'];
                $defIntoDebris = $GLOBALS['CONFIG'][$this->_fleet['fleet_universe']]['Defs_Cdr'];
                $combatResult = calculateAttack($fleetAttack, $fleetDefend, $fleetIntoDebris, $defIntoDebris);
                $fleetArray = '';
开发者ID:joancefet,项目名称:Beta7,代码行数:67,代码来源:MissionCaseExpedition.php

示例13: TargetEvent

    function TargetEvent()
    {
        $db = Database::get();
        $sql = 'SELECT * FROM %%USERS%% WHERE `id` = :userId;';
        $senderUser = $db->selectSingle($sql, array(':userId' => $this->_fleet['fleet_owner']));
        $senderUser['factor'] = getFactors($senderUser, 'basic', $this->_fleet['fleet_start_time']);
        $LNG = $this->getLanguage($senderUser['lang']);
        $checkPosition = PlayerUtil::checkPosition($this->_fleet['fleet_universe'], $this->_fleet['fleet_end_galaxy'], $this->_fleet['fleet_end_system'], $this->_fleet['fleet_end_planet']);
        $isPositionFree = PlayerUtil::isPositionFree($this->_fleet['fleet_universe'], $this->_fleet['fleet_end_galaxy'], $this->_fleet['fleet_end_system'], $this->_fleet['fleet_end_planet']);
        if (!$isPositionFree || !$checkPosition) {
            $message = sprintf($LNG['sys_colo_notfree'], GetTargetAddressLink($this->_fleet, ''));
        } else {
            $allowPlanetPosition = PlayerUtil::allowPlanetPosition($this->_fleet['fleet_end_planet'], $senderUser);
            if (!$allowPlanetPosition) {
                $message = sprintf($LNG['sys_colo_notech'], GetTargetAddressLink($this->_fleet, ''));
            } else {
                $sql = 'SELECT COUNT(*) as state
				FROM %%PLANETS%%
				WHERE `id_owner`	= :userId
				AND `planet_type`	= :type
				AND `destruyed`		= :destroyed;';
                $currentPlanetCount = $db->selectSingle($sql, array(':userId' => $this->_fleet['fleet_owner'], ':type' => 1, ':destroyed' => 0), 'state');
                $maxPlanetCount = PlayerUtil::maxPlanetCount($senderUser);
                if ($currentPlanetCount >= $maxPlanetCount) {
                    $message = sprintf($LNG['sys_colo_maxcolo'], GetTargetAddressLink($this->_fleet, ''), $maxPlanetCount);
                } else {
                    $NewOwnerPlanet = PlayerUtil::createPlanet($this->_fleet['fleet_end_galaxy'], $this->_fleet['fleet_end_system'], $this->_fleet['fleet_end_planet'], $this->_fleet['fleet_universe'], $this->_fleet['fleet_owner'], $LNG['fcp_colony'], false, $senderUser['authlevel']);
                    if ($NewOwnerPlanet === false) {
                        $message = sprintf($LNG['sys_colo_badpos'], GetTargetAddressLink($this->_fleet, ''));
                        $this->setState(FLEET_RETURN);
                    } else {
                        $this->_fleet['fleet_end_id'] = $NewOwnerPlanet;
                        $message = sprintf($LNG['sys_colo_allisok'], GetTargetAddressLink($this->_fleet, ''));
                        $this->StoreGoodsToPlanet();
                        if ($this->_fleet['fleet_amount'] == 1) {
                            $this->KillFleet();
                        } else {
                            $CurrentFleet = explode(";", $this->_fleet['fleet_array']);
                            $NewFleet = '';
                            foreach ($CurrentFleet as $Group) {
                                if (empty($Group)) {
                                    continue;
                                }
                                $Class = explode(",", $Group);
                                if ($Class[0] == 208 && $Class[1] > 1) {
                                    $NewFleet .= $Class[0] . "," . ($Class[1] - 1) . ";";
                                } elseif ($Class[0] != 208 && $Class[1] > 0) {
                                    $NewFleet .= $Class[0] . "," . $Class[1] . ";";
                                }
                            }
                            $this->UpdateFleet('fleet_array', $NewFleet);
                            $this->UpdateFleet('fleet_amount', $this->_fleet['fleet_amount'] - 1);
                            $this->UpdateFleet('fleet_resource_metal', 0);
                            $this->UpdateFleet('fleet_resource_crystal', 0);
                            $this->UpdateFleet('fleet_resource_deuterium', 0);
                        }
                    }
                }
            }
        }
        PlayerUtil::sendMessage($this->_fleet['fleet_owner'], 0, $LNG['sys_colo_mess_from'], 4, $LNG['sys_colo_mess_report'], $message, $this->_fleet['fleet_start_time'], NULL, 1, $this->_fleet['fleet_universe']);
        $this->setState(FLEET_RETURN);
        $this->SaveFleet();
    }
开发者ID:tatarysh,项目名称:2Moons,代码行数:64,代码来源:MissionCaseColonisation.class.php

示例14: TargetEvent

    function TargetEvent()
    {
        global $resource, $reslist;
        $fleetAttack = array();
        $fleetDefend = array();
        $userAttack = array();
        $userDefend = array();
        $stealResource = array(901 => 0, 902 => 0, 903 => 0);
        $debris = array();
        $planetDebris = array();
        $raportInfo = array();
        $debrisRessource = array(901, 902);
        $messageHTML = <<<HTML
\t\t<div class="raportMessage">
\t<table>
\t\t<tr>
\t\t\t<td colspan="2"><a href="CombatReport.php?raport=%s" target="_blank"><span class="%s">%s %s (%s)</span></a></td>
\t\t</tr>
\t\t<tr>
\t\t\t<td>%s</td><td><span %s>%s: %s</span>&nbsp;<span %s>%s: %s</span></td>
\t\t</tr>
\t\t<tr>
\t\t\t<td>%s</td><td><span>%s:&nbsp;<span style="color:#a47d7a;">%s</span>&nbsp;</span><span>%s:&nbsp;<span style="color:#5ca6aa;">%s</span>&nbsp;</span><span>%s:&nbsp;<span style="color:#339966;">%s</span></span></td>
\t\t</tr>
\t\t<tr>
\t\t\t<td>%s</td><td><span>%s:&nbsp;<span style="color:#a47d7a;">%s</font>&nbsp;</span><span>%s:&nbsp;<span style="color:#5ca6aa;">%s</span></span></td>
\t\t</tr>
\t</table>
</div>
HTML;
        //Minize HTML
        $messageHTML = str_replace(array("\n", "\t", "\r"), "", $messageHTML);
        $targetPlanet = $GLOBALS['DATABASE']->getFirstRow("SELECT * FROM " . PLANETS . " WHERE id = '" . $this->_fleet['fleet_end_id'] . "';");
        $targetUser = $GLOBALS['DATABASE']->getFirstRow("SELECT * FROM " . USERS . " WHERE id = '" . $targetPlanet['id_owner'] . "';");
        $targetUser['factor'] = getFactors($targetUser, 'basic', $this->_fleet['fleet_start_time']);
        $planetUpdater = new ResourceUpdate();
        list($targetUser, $targetPlanet) = $planetUpdater->CalcResource($targetUser, $targetPlanet, true, $this->_fleet['fleet_start_time']);
        if ($this->_fleet['fleet_group'] != 0) {
            $GLOBALS['DATABASE']->query("DELETE FROM " . AKS . " WHERE id = '" . $this->_fleet['fleet_group'] . "';");
            $incomingFleetsResult = $GLOBALS['DATABASE']->query("SELECT * FROM " . FLEETS . " WHERE fleet_group = '" . $this->_fleet['fleet_group'] . "';");
            while ($incomingFleetsRow = $GLOBALS['DATABASE']->fetch_array($incomingFleetsResult)) {
                $incomingFleets[$incomingFleetsRow['fleet_id']] = $incomingFleetsRow;
            }
            $GLOBALS['DATABASE']->free_result($incomingFleetsResult);
        } else {
            $incomingFleets = array($this->_fleet['fleet_id'] => $this->_fleet);
        }
        foreach ($incomingFleets as $fleetID => $fleetDetail) {
            $fleetAttack[$fleetID]['fleetDetail'] = $fleetDetail;
            $fleetAttack[$fleetID]['player'] = $GLOBALS['DATABASE']->getFirstRow("SELECT * FROM " . USERS . " WHERE id = '" . $fleetDetail['fleet_owner'] . "';");
            $fleetAttack[$fleetID]['player']['factor'] = getFactors($fleetAttack[$fleetID]['player'], 'attack', $this->_fleet['fleet_start_time']);
            $fleetAttack[$fleetID]['unit'] = fleetAmountToArray($fleetDetail['fleet_array']);
            $userAttack[$fleetAttack[$fleetID]['player']['id']] = $fleetAttack[$fleetID]['player']['username'];
        }
        $targetFleetsResult = $GLOBALS['DATABASE']->query("SELECT * FROM " . FLEETS . " WHERE fleet_mission = '5' AND fleet_end_id = '" . $this->_fleet['fleet_end_id'] . "' AND fleet_start_time <= '" . TIMESTAMP . "' AND fleet_end_stay >= '" . TIMESTAMP . "';");
        while ($fleetDetail = $GLOBALS['DATABASE']->fetch_array($targetFleetsResult)) {
            $fleetID = $fleetDetail['fleet_id'];
            $fleetDefend[$fleetID]['fleetDetail'] = $fleetDetail;
            $fleetDefend[$fleetID]['player'] = $GLOBALS['DATABASE']->getFirstRow("SELECT * FROM " . USERS . " WHERE id = '" . $fleetDetail['fleet_owner'] . "';");
            $fleetDefend[$fleetID]['player']['factor'] = getFactors($fleetDefend[$fleetID]['player'], 'attack', $this->_fleet['fleet_start_time']);
            $fleetDefend[$fleetID]['unit'] = fleetAmountToArray($fleetDetail['fleet_array']);
            $userDefend[$fleetDefend[$fleetID]['player']['id']] = $fleetDefend[$fleetID]['player']['username'];
        }
        $GLOBALS['DATABASE']->free_result($targetFleetsResult);
        $fleetDefend[0]['player'] = $targetUser;
        $fleetDefend[0]['player']['factor'] = getFactors($fleetDefend[0]['player'], 'attack', $this->_fleet['fleet_start_time']);
        $fleetDefend[0]['fleetDetail'] = array('fleet_start_galaxy' => $targetPlanet['galaxy'], 'fleet_start_system' => $targetPlanet['system'], 'fleet_start_planet' => $targetPlanet['planet'], 'fleet_start_type' => $targetPlanet['planet_type']);
        $fleetDefend[0]['unit'] = array();
        foreach (array_merge($reslist['fleet'], $reslist['defense']) as $elementID) {
            if (empty($targetPlanet[$resource[$elementID]])) {
                continue;
            }
            $fleetDefend[0]['unit'][$elementID] = $targetPlanet[$resource[$elementID]];
        }
        $userDefend[$fleetDefend[0]['player']['id']] = $fleetDefend[0]['player']['username'];
        require_once 'calculateAttack.php';
        $fleetIntoDebris = $GLOBALS['CONFIG'][$this->_fleet['fleet_universe']]['Fleet_Cdr'];
        $defIntoDebris = $GLOBALS['CONFIG'][$this->_fleet['fleet_universe']]['Defs_Cdr'];
        $combatResult = calculateAttack($fleetAttack, $fleetDefend, $fleetIntoDebris, $defIntoDebris);
        $sqlQuery = "";
        foreach ($fleetAttack as $fleetID => $fleetDetail) {
            $fleetArray = '';
            $totalCount = 0;
            $fleetDetail['unit'] = array_filter($fleetDetail['unit']);
            foreach ($fleetDetail['unit'] as $elementID => $amount) {
                $fleetArray .= $elementID . ',' . floattostring($amount) . ';';
                $totalCount += $amount;
            }
            if ($totalCount == 0) {
                if ($this->_fleet['fleet_id'] == $fleetID) {
                    $this->KillFleet();
                } else {
                    $sqlQuery .= "DELETE FROM " . FLEETS . " WHERE fleet_id = " . $fleetID . ";";
                    $sqlQuery .= "DELETE FROM " . FLEETS_EVENT . " WHERE fleetID = " . $fleetID . ";";
                }
                $sqlQuery .= "UPDATE " . LOG_FLEETS . " SET fleet_state = 2 WHERE fleet_id = '" . $fleetID . "';";
            } elseif ($totalCount > 0) {
                $sqlQuery .= "UPDATE " . FLEETS . " SET fleet_array = '" . substr($fleetArray, 0, -1) . "', fleet_amount = '" . $totalCount . "' WHERE fleet_id = '" . $fleetID . "';";
                $sqlQuery .= "UPDATE " . LOG_FLEETS . " SET fleet_array = '" . substr($fleetArray, 0, -1) . "', fleet_amount = '" . $totalCount . "', fleet_state = 1 WHERE fleet_id = '" . $fleetID . "';";
            } else {
//.........这里部分代码省略.........
开发者ID:Decoder1978,项目名称:Xterium,代码行数:101,代码来源:MissionCaseDestruction.php

示例15: TargetEvent

    function TargetEvent()
    {
        global $resource, $reslist;
        $fleetAttack = array();
        $fleetDefend = array();
        $userAttack = array();
        $userDefend = array();
        $stealResource = array(901 => 0, 902 => 0, 903 => 0);
        $debris = array();
        $planetDebris = array();
        $raportInfo = array();
        $debrisRessource = array(901, 902);
        $messageHTML = <<<HTML
\t\t<div class="raportMessage">
\t<table>
\t\t<tr>
\t\t\t<td colspan="2"><a href="CombatReport.php?raport=%s" onclick="starttraining20()" target="_blank"><span %s>%s %s (%s)</span></a></td>
\t\t</tr>
\t\t<tr>
\t\t\t<td>%s</td><td><span %s>%s: %s</span>&nbsp;<span %s>%s: %s</span></td>
\t\t</tr>
\t\t<tr>
\t\t\t<td>%s</td><td><span>%s:&nbsp;<span style="color:#a47d7a;">%s</span>&nbsp;</span><span>%s:&nbsp;<span style="color:#5ca6aa;">%s</span>&nbsp;</span><span>%s:&nbsp;<span style="color:#339966;">%s</span></span></td>
\t\t</tr>
\t\t<tr>
\t\t\t<td>%s</td><td><span>%s:&nbsp;<span style="color:#a47d7a;">%s</font>&nbsp;</span><span>%s:&nbsp;<span style="color:#5ca6aa;">%s</span></span></td>
\t\t</tr>
\t</table>
</div>
HTML;
        //Minize HTML
        $messageHTML = str_replace(array("\n", "\t", "\r"), "", $messageHTML);
        $targetPlanet = $GLOBALS['DATABASE']->getFirstRow("SELECT * FROM " . PLANETS . " WHERE id = '" . $this->_fleet['fleet_end_id'] . "';");
        $targetUser = $GLOBALS['DATABASE']->getFirstRow("SELECT * FROM " . USERS . " WHERE id = '" . $targetPlanet['id_owner'] . "';");
        $targetUser['factor'] = getFactors($targetUser, 'basic', $this->_fleet['fleet_start_time']);
        $planetUpdater = new ResourceUpdate();
        list($targetUser, $targetPlanet) = $planetUpdater->CalcResource($targetUser, $targetPlanet, true, $this->_fleet['fleet_start_time']);
        if ($this->_fleet['fleet_group'] != 0) {
            $GLOBALS['DATABASE']->query("DELETE FROM " . AKS . " WHERE id = '" . $this->_fleet['fleet_group'] . "';");
            $incomingFleetsResult = $GLOBALS['DATABASE']->query("SELECT * FROM " . FLEETS . " WHERE fleet_group = '" . $this->_fleet['fleet_group'] . "';");
            while ($incomingFleetsRow = $GLOBALS['DATABASE']->fetch_array($incomingFleetsResult)) {
                $incomingFleets[$incomingFleetsRow['fleet_id']] = $incomingFleetsRow;
            }
            $GLOBALS['DATABASE']->free_result($incomingFleetsResult);
        } else {
            $incomingFleets = array($this->_fleet['fleet_id'] => $this->_fleet);
        }
        foreach ($incomingFleets as $fleetID => $fleetDetail) {
            $fleetAttack[$fleetID]['fleetDetail'] = $fleetDetail;
            $fleetAttack[$fleetID]['player'] = $GLOBALS['DATABASE']->getFirstRow("SELECT * FROM " . USERS . " WHERE id = '" . $fleetDetail['fleet_owner'] . "';");
            $fleetAttack[$fleetID]['player']['factor'] = getFactors($fleetAttack[$fleetID]['player'], 'attack', $this->_fleet['fleet_start_time']);
            $fleetAttack[$fleetID]['unit'] = fleetAmountToArray($fleetDetail['fleet_array']);
            $userAttack[$fleetAttack[$fleetID]['player']['id']] = $fleetAttack[$fleetID]['player']['username'];
        }
        $targetFleetsResult = $GLOBALS['DATABASE']->query("SELECT * FROM " . FLEETS . " WHERE fleet_mission = '5' AND fleet_end_id = '" . $this->_fleet['fleet_end_id'] . "' AND fleet_start_time <= '" . TIMESTAMP . "' AND fleet_end_stay >= '" . TIMESTAMP . "';");
        while ($fleetDetail = $GLOBALS['DATABASE']->fetch_array($targetFleetsResult)) {
            $fleetID = $fleetDetail['fleet_id'];
            $fleetDefend[$fleetID]['fleetDetail'] = $fleetDetail;
            $fleetDefend[$fleetID]['player'] = $GLOBALS['DATABASE']->getFirstRow("SELECT * FROM " . USERS . " WHERE id = '" . $fleetDetail['fleet_owner'] . "';");
            $fleetDefend[$fleetID]['player']['factor'] = getFactors($fleetDefend[$fleetID]['player'], 'attack', $this->_fleet['fleet_start_time']);
            $fleetDefend[$fleetID]['unit'] = fleetAmountToArray($fleetDetail['fleet_array']);
            $userDefend[$fleetDefend[$fleetID]['player']['id']] = $fleetDefend[$fleetID]['player']['username'];
        }
        $GLOBALS['DATABASE']->free_result($targetFleetsResult);
        $fleetDefend[0]['player'] = $targetUser;
        $fleetDefend[0]['player']['factor'] = getFactors($fleetDefend[0]['player'], 'attack', $this->_fleet['fleet_start_time']);
        $fleetDefend[0]['fleetDetail'] = array('fleet_start_galaxy' => $targetPlanet['galaxy'], 'fleet_start_system' => $targetPlanet['system'], 'fleet_start_planet' => $targetPlanet['planet'], 'fleet_start_type' => $targetPlanet['planet_type']);
        $fleetDefend[0]['unit'] = array();
        foreach (array_merge($reslist['fleet'], $reslist['defense']) as $elementID) {
            if (empty($targetPlanet[$resource[$elementID]])) {
                continue;
            }
            $fleetDefend[0]['unit'][$elementID] = $targetPlanet[$resource[$elementID]];
        }
        $userDefend[$fleetDefend[0]['player']['id']] = $fleetDefend[0]['player']['username'];
        require_once 'calculateAttack.php';
        $fleetIntoDebris = $GLOBALS['CONFIG'][$this->_fleet['fleet_universe']]['Fleet_Cdr'];
        $defIntoDebris = $GLOBALS['CONFIG'][$this->_fleet['fleet_universe']]['Defs_Cdr'];
        $combatResult = calculateAttack($fleetAttack, $fleetDefend, $fleetIntoDebris, $defIntoDebris);
        /*ob_start();
        		print_r($fleetAttack);
        		print_r($fleetDefend);
        		print_r($fleetIntoDebris);
        		print_r($defIntoDebris);
        
        		$content = ob_get_contents();
        		ob_end_clean();
        
        		$f = fopen("file.txt", "w");
        		fwrite($f, $content);
        		fclose($f);*/
        $sqlQuery = "";
        foreach ($fleetAttack as $fleetID => $fleetDetail) {
            $fleetArray = '';
            $totalCount = 0;
            $fleetDetail['unit'] = array_filter($fleetDetail['unit']);
            foreach ($fleetDetail['unit'] as $elementID => $amount) {
                $fleetArray .= $elementID . ',' . floattostring($amount) . ';';
                $totalCount += $amount;
            }
//.........这里部分代码省略.........
开发者ID:joancefet,项目名称:Beta7,代码行数:101,代码来源:MissionCaseAttack.php


注:本文中的getFactors函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。