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


PHP Shadowfunc::randomData方法代码示例

本文整理汇总了PHP中Shadowfunc::randomData方法的典型用法代码示例。如果您正苦于以下问题:PHP Shadowfunc::randomData方法的具体用法?PHP Shadowfunc::randomData怎么用?PHP Shadowfunc::randomData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Shadowfunc的用法示例。


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

示例1: decideCombat

 public static function decideCombat(SR_Player $player, array $args)
 {
     $args = SR_AIDecision::filterDecisions($args);
     $total = 0;
     $data = array();
     foreach ($args as $decision) {
         $decision instanceof SR_AIDecision;
         $chance = (int) ($decision->getPreference() * 1000);
         $total += $chance;
         $data[] = array($decision, $chance);
     }
     $rand = Shadowfunc::randomData($data, $total);
     return $rand === false ? NULL : $rand;
 }
开发者ID:sinfocol,项目名称:gwf3,代码行数:14,代码来源:dice.php

示例2: enemyContact

 private function enemyContact(SR_Party $party, $friendly = false)
 {
     $dice = $friendly ? 18 : 8;
     if (rand(1, $dice) !== 1) {
         return false;
     }
     $mc = $party->getMemberCount();
     $level = $party->getMax('level', true);
     $possible = array();
     $total = 0;
     foreach ($this->npcs as $npc) {
         $npc instanceof SR_NPC;
         if ($npc->getNPCLevel() <= $level && $npc->isNPCFriendly($party) === $friendly && $npc->canNPCMeet($party)) {
             $multi = $friendly === true ? 1 : 1;
             $percent = round($npc->getNPCMeetPercent($party) * $multi * 100);
             $total += $percent;
             $possible[] = array($npc->getNPCClassName(), $percent);
         }
     }
     $npcs = array();
     $x = 200;
     // 200% chance nothing
     do {
         $contact = false;
         if (false !== ($npc = Shadowfunc::randomData($possible, $total, $x * 100))) {
             $contact = true;
             $npcs[] = $npc;
             $x += 120 - Common::clamp($mc * 10, 0, 50);
         }
         if (count($npcs) >= $this->maxEnemies($party)) {
             break;
         }
     } while ($contact === true);
     if (count($npcs) === 0) {
         return false;
     }
     $ep = SR_NPC::createEnemyParty($npcs);
     if ($friendly === true) {
         $party->talk($ep, true);
     } else {
         $party->fight($ep, true);
     }
     return true;
 }
开发者ID:sinfocol,项目名称:gwf3,代码行数:44,代码来源:SR_City.php

示例3: randModifier

 public static function randModifier(SR_Player $player, $level)
 {
     $luck = $player->get('luck');
     $total = 0;
     $possible = array();
     $level = intval($level + $luck * 2);
     foreach (self::getRuneData() as $data) {
         $minlvl = $data[self::RUNE_MIN_LEVEL];
         if ($level < $minlvl) {
             continue;
         }
         $maxlvl = $data[self::RUNE_MAX_LEVEL];
         $range = $maxlvl - $minlvl;
         # Percent of level
         $level = Common::clamp($level, 0, $maxlvl);
         $l = $level - $minlvl;
         $l = $l / $range;
         $dc = round($data[self::RUNE_DROP_CHANCE] * $l * 100);
         if ($dc < 1) {
             continue;
         }
         $possible[] = array($data, $dc);
         $total += $dc;
     }
     if (count($possible) === 0) {
         return false;
     }
     if (false === ($data = Shadowfunc::randomData($possible, $total, 0))) {
         return false;
     }
     $minlvl = $data[self::RUNE_MIN_LEVEL];
     $maxlvl = $data[self::RUNE_MAX_LEVEL];
     $range = $maxlvl - $minlvl;
     $l = $level - $minlvl;
     $l = $l / $range;
     $min = $data[self::RUNE_MIN_MODIFIER];
     $max = $data[self::RUNE_MAX_MODIFIER];
     $r = $max - $min;
     $max = $r * $l;
     $power = Shadowfunc::diceFloat($min, $min + $max, 2) * SR_Player::RUNE_MULTIPLIER;
     if ($power < 0.1) {
         return false;
     }
     //		echo "RUNE POWER $min - $max: $power\n";
     return array($data[self::RUNE_MODIFIER] => $power);
 }
开发者ID:sinfocol,项目名称:gwf3,代码行数:46,代码来源:SR_Rune.php


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