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


PHP Shadowfunc::dicePercent方法代码示例

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


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

示例1: onEventWallet

 public function onEventWallet(SR_Party $party)
 {
     foreach ($party->getMembers() as $member) {
         $member instanceof SR_Player;
         if ($member->isHuman()) {
             $percent = 0.05;
             $luck = $member->get('luck');
             $percent += $luck / 200;
             if (Shadowfunc::dicePercent($percent)) {
                 $nuyen = rand(100, 1000);
                 $member->message(sprintf('You found a wallet with %s in it.', Shadowfunc::displayNuyen($nuyen)));
                 $member->giveNuyen($nuyen);
             }
         }
     }
 }
开发者ID:sinfocol,项目名称:gwf3,代码行数:16,代码来源:Vegas.php

示例2: onEventMushroom

 private function onEventMushroom(SR_Party $party)
 {
     foreach ($party->getMembers() as $member) {
         $member instanceof SR_Player;
         if ($member->isHuman()) {
             $percent = 0.05;
             $luck = $member->get('luck');
             $percent += $luck / 200;
             if (Shadowfunc::dicePercent($percent)) {
                 $amt = rand(2, 4);
                 $member->giveItems(array(SR_Item::createByName('Bolete', $amt)));
                 $member->message($this->lang($member, 'mushrooms', array($amt)));
             }
         }
     }
 }
开发者ID:sinfocol,项目名称:gwf3,代码行数:16,代码来源:Forest.php

示例3: onUpgradeB


//.........这里部分代码省略.........
     if (!$rune instanceof SR_Rune) {
         $bot->rply('1160');
         // 			$bot->reply('The second item is not a rune.');
         return false;
     }
     $modsRune = $rune->getModifiers();
     if ($modsRune === NULL || count($modsRune) === 0) {
         $bot->reply('The rune has no modifiers. Somethings wrong! (BUG)');
         return false;
     }
     if (!$this->checkCombination($player, $item, $rune)) {
         // 			$bot->rply('1161');
         // 			$bot->reply('This item can not get this rune applied to it.');
         return false;
     }
     # Check if equipped mount is loaded with items. (thx tehron)
     if ($item instanceof SR_Mount) {
         if ($item->isEquipped($player)) {
             if (count($player->getMountInvSorted()) !== 0) {
                 $bot->rply('1164');
                 // 					$bot->reply("Please '#mount clean' before you '#upgrade' it.");
                 return false;
             }
         }
     }
     if (false === SR_Item::canMergeModifiersLength($item, $rune)) {
         $bot->rply('1165');
         // 			$bot->reply('The item string would get too long with another modifier.');
         return false;
     }
     $mods = SR_Item::mergeModifiers($item->getItemModifiersB(), $rune->getItemModifiersB());
     $luck = $player->get('luck');
     $luck = Common::clamp($luck, 0, 30);
     $luckmod = 0.35;
     $luckmod -= $luck * 0.005;
     $fail = SR_Rune::calcFailChance($mods) * $luckmod * $this->getUpgradeFailModifier();
     $break = SR_Rune::calcBreakChance($mods) * $luckmod * $this->getUpgradeBreakModifier();
     $price_u = $this->calcUpgradePrice($player, $rune->getItemPriceStatted());
     $dpu = Shadowfunc::displayNuyen($price_u);
     $fail = round(Common::clamp($fail, 5, 85), 2);
     $break = round(Common::clamp($break, 1, 50), 2);
     if ($safe) {
         $fail -= 5;
         $break = 0;
     }
     ## Confirm
     $msg = implode(' ', $args);
     if ($msg !== $old_msg) {
         self::$UPGRADE_CONFIRM[$pid . $safebit] = $msg;
         return $player->msg('5211', array(Shadowfunc::displayNuyen($price_u), $item->displayFullName($player), $rune->displayFullName($player), $fail, $break));
         // 			return $player->message(sprintf(
         // 				'The smith examines your items ... "It would cost you %s to upgrade your %s with %s. The fail chance is %.02f%% and the break chance is %.02f%%. Please retype to confirm.',
         // 				Shadowfunc::displayNuyen($price_u), $item->getItemName(), $rune->getItemName(), $fail, $break
         // 			));
     }
     if (!$player->hasNuyen($price_u)) {
         $bot->rply('1063', array($dpu, $player->displayNuyen()));
         // 			$bot->reply(sprintf('The smith says: "I am sorry chummer, the upgrade would cost you %s."', $dpu));
         return false;
     }
     # Safe mode
     if ($safe) {
         $break = 0;
         if (false === ($oil = $player->getInvItemByName('MagicOil'))) {
             $bot->rply('1187', array(Shadowlang::displayItemNameS('MagicOil')));
             return false;
         }
         if (!$oil->useAmount($player, 1)) {
             $bot->reply('DB Error 19');
             return false;
         }
     }
     $player->msg('5212');
     // 		$player->message('The smith takes your items and goes to work...');
     $player->removeItem($rune);
     $rune->delete();
     if (Shadowfunc::dicePercent($fail)) {
         if (Shadowfunc::dicePercent($break)) {
             $player->removeItem($item);
             $item->delete();
             $bot->rply('5213', array($item->displayFullName($player), $rune->displayFullName($player)));
             // 				$bot->reply(sprintf('The upgrade horrible failed and the item and the rune is lost. The smith is very sorry and you don`t need to pay any money.'));
         } else {
             $price_f = $this->calcUpgradePrice($player, 0);
             $player->pay($price_f);
             $dpf = Shadowfunc::displayNuyen($price_f);
             $bot->rply('5214', array($dpf, $rune->displayFullName($player)));
             // 				$bot->reply(sprintf('The upgrade failed and the rune is lost. You only need to pay %s for the work.', $dpf));
         }
     } else {
         $player->pay($price_u);
         $old_name = $item->displayFullName($player);
         $item->addModifiers($rune->getItemModifiersB(), true);
         $item->addModifiers($rune->getItemModifiersA($player), true);
         $bot->rply('5215', array($dpu, $item->displayFullName($player), $old_name, $rune->displayFullName($player)));
         // 			$bot->reply(sprintf('The upgrade succeeded. You pay %s and the smith presents you a fine %s.', $dpu, $item->getItemName()));
     }
     $player->modify();
     return true;
 }
开发者ID:sinfocol,项目名称:gwf3,代码行数:101,代码来源:SR_Blacksmith.php

示例4: getStoreItemsB

 /**
  * Filter Store Items through availability.
  * @param SR_Player $player
  */
 public function getStoreItemsB(SR_Player $player)
 {
     $key = $this->getStoreItemsKey();
     if ($player->hasTemp($key)) {
         return $player->getTemp($key);
     }
     $rep = Common::clamp($player->get('reputation'), 0, 25) * 0.5;
     $items = $this->getStoreItems($player);
     if (!is_array($items)) {
         return array();
     }
     $back = array();
     $unique = false;
     foreach ($items as $i => $data) {
         $avail = isset($data[1]) ? $data[1] : 100.0;
         $avail += $rep;
         if (Shadowfunc::dicePercent($avail)) {
             $back[] = $data;
         } else {
             $unique = true;
         }
     }
     if ($unique === true) {
         $player->setTemp($key, $back);
     }
     return $back;
 }
开发者ID:sinfocol,项目名称:gwf3,代码行数:31,代码来源:SR_Store.php

示例5: diceLocate

 public function diceLocate()
 {
     return Shadowfunc::dicePercent($this->getFoundPercentage());
 }
开发者ID:sinfocol,项目名称:gwf3,代码行数:4,代码来源:SR_Location.php


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