當前位置: 首頁>>代碼示例>>PHP>>正文


PHP ArrayUtil::combineArrayWithSingleElement方法代碼示例

本文整理匯總了PHP中ArrayUtil::combineArrayWithSingleElement方法的典型用法代碼示例。如果您正苦於以下問題:PHP ArrayUtil::combineArrayWithSingleElement方法的具體用法?PHP ArrayUtil::combineArrayWithSingleElement怎麽用?PHP ArrayUtil::combineArrayWithSingleElement使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在ArrayUtil的用法示例。


在下文中一共展示了ArrayUtil::combineArrayWithSingleElement方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: getFactors

/**
 *  2Moons
 *  Copyright (C) 2012 Jan Kröpke
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * @package 2Moons
 * @author Jan Kröpke <info@2moons.cc>
 * @copyright 2012 Jan Kröpke <info@2moons.cc>
 * @license http://www.gnu.org/licenses/gpl.html GNU GPLv3 License
 * @version 1.7.2 (2013-03-18)
 * @info $Id$
 * @link http://2moons.cc/
 */
function getFactors($USER, $Type = 'basic', $TIME = NULL)
{
    global $resource, $pricelist, $reslist;
    if (empty($TIME)) {
        $TIME = TIMESTAMP;
    }
    $bonusList = BuildFunctions::getBonusList();
    $factor = ArrayUtil::combineArrayWithSingleElement($bonusList, 0);
    foreach ($reslist['bonus'] as $elementID) {
        $bonus = $pricelist[$elementID]['bonus'];
        if (isset($PLANET[$resource[$elementID]])) {
            $elementLevel = $PLANET[$resource[$elementID]];
        } elseif (isset($USER[$resource[$elementID]])) {
            $elementLevel = $USER[$resource[$elementID]];
        } else {
            continue;
        }
        if (in_array($elementID, $reslist['dmfunc'])) {
            if (DMExtra($elementLevel, $TIME, false, true)) {
                continue;
            }
            foreach ($bonusList as $bonusKey) {
                $factor[$bonusKey] += $bonus[$bonusKey][0];
            }
        } else {
            foreach ($bonusList as $bonusKey) {
                $factor[$bonusKey] += $elementLevel * $bonus[$bonusKey][0];
            }
        }
    }
    return $factor;
}
開發者ID:Hetachi,項目名稱:2Moons,代碼行數:57,代碼來源:GeneralFunctions.php

示例2: EndStayEvent


//.........這裏部分代碼省略.........
                    if (10 < $eventSize) {
                        $Message = $LNG['sys_expe_attack_1_1_5'];
                        $attackFactor = 40 + mt_rand(-4, 4) / 100;
                        $targetFleetData[204] = 5;
                    } elseif (0 < $eventSize && 10 >= $eventSize) {
                        $Message = $LNG['sys_expe_attack_1_3_3'];
                        $attackFactor = 60 + mt_rand(-6, 6) / 100;
                        $targetFleetData[215] = 3;
                    } else {
                        $Message = $LNG['sys_expe_attack_1_3_2'];
                        $attackFactor = 90 + mt_rand(-9, 9) / 100;
                        $targetFleetData[213] = 2;
                    }
                }
                foreach ($fleetArray as $shipId => $shipAmount) {
                    if (isset($targetFleetData[$shipId])) {
                        $targetFleetData[$shipId] = 0;
                    }
                    $targetFleetData[$shipId] = $roundFunction($shipAmount * $attackFactor);
                }
                $targetFleetData = array_filter($targetFleetData);
                $sql = 'SELECT * FROM %%USERS%% WHERE id = :userId;';
                $senderData = Database::get()->selectSingle($sql, array(':userId' => $this->_fleet['fleet_owner']));
                $targetData = array('id' => 0, 'username' => $targetName, 'military_tech' => min($senderData['military_tech'] + $techBonus, 0), 'defence_tech' => min($senderData['defence_tech'] + $techBonus, 0), 'shield_tech' => min($senderData['shield_tech'] + $techBonus, 0), 'rpg_amiral' => 0, 'dm_defensive' => 0, 'dm_attack' => 0);
                $fleetID = $this->_fleet['fleet_id'];
                $fleetAttack[$fleetID]['fleetDetail'] = $this->_fleet;
                $fleetAttack[$fleetID]['player'] = $senderData;
                $fleetAttack[$fleetID]['player']['factor'] = getFactors($fleetAttack[$this->_fleet['fleet_id']]['player'], 'attack', $this->_fleet['fleet_start_time']);
                $fleetAttack[$fleetID]['unit'] = $fleetArray;
                $fleetDefend = array();
                $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);
                $bonusList = BuildFunctions::getBonusList();
                $fleetDefend[0]['player'] = $targetData;
                $fleetDefend[0]['player']['factor'] = ArrayUtil::combineArrayWithSingleElement($bonusList, 0);
                $fleetDefend[0]['unit'] = $targetFleetData;
                require_once 'includes/classes/missions/functions/calculateAttack.php';
                $combatResult = calculateAttack($fleetAttack, $fleetDefend, $config->Fleet_Cdr, $config->Defs_Cdr);
                $fleetArray = '';
                $totalCount = 0;
                $fleetAttack[$fleetID]['unit'] = array_filter($fleetAttack[$fleetID]['unit']);
                foreach ($fleetAttack[$fleetID]['unit'] as $element => $amount) {
                    $fleetArray .= $element . ',' . $amount . ';';
                    $totalCount += $amount;
                }
                if ($totalCount <= 0) {
                    $this->KillFleet();
                } else {
                    $this->UpdateFleet('fleet_array', substr($fleetArray, 0, -1));
                    $this->UpdateFleet('fleet_amount', $totalCount);
                }
                require_once 'includes/classes/missions/functions/GenerateReport.php';
                $debrisResource = array(901, 902);
                $debris = array();
                foreach ($debrisResource as $elementID) {
                    $debris[$elementID] = 0;
                }
                $stealResource = array(901 => 0, 902 => 0, 903 => 0);
                $reportInfo = array('thisFleet' => $this->_fleet, 'debris' => $debris, 'stealResource' => $stealResource, 'moonChance' => 0, 'moonDestroy' => false, 'moonName' => NULL, 'moonDestroyChance' => NULL, 'moonDestroySuccess' => NULL, 'fleetDestroyChance' => NULL, 'fleetDestroySuccess' => NULL);
                $reportData = GenerateReport($combatResult, $reportInfo);
                $reportID = md5(uniqid('', true) . TIMESTAMP);
                $sql = "INSERT INTO %%RW%% SET\n\t\t\t\trid\t\t\t= :reportId,\n\t\t\t\traport\t\t= :reportData,\n\t\t\t\ttime\t\t= :time,\n\t\t\t\tattacker\t= :attacker;";
                Database::get()->insert($sql, array(':reportId' => $reportID, ':reportData' => serialize($reportData), ':time' => $this->_fleet['fleet_start_time'], ':attacker' => $this->_fleet['fleet_owner']));
                switch ($combatResult['won']) {
                    case "a":
                        $attackClass = 'raportWin';
                        $defendClass = 'raportLose';
開發者ID:Hilarious001,項目名稱:2Moons,代碼行數:67,代碼來源:MissionCaseExpedition.class.php


注:本文中的ArrayUtil::combineArrayWithSingleElement方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。