当前位置: 首页>>代码示例>>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;未经允许,请勿转载。