本文整理汇总了PHP中Shadowfunc::randomListItem方法的典型用法代码示例。如果您正苦于以下问题:PHP Shadowfunc::randomListItem方法的具体用法?PHP Shadowfunc::randomListItem怎么用?PHP Shadowfunc::randomListItem使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Shadowfunc
的用法示例。
在下文中一共展示了Shadowfunc::randomListItem方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: onSparkleItem
private function onSparkleItem(SR_Player $player)
{
$items = array('Ring', 'Amulet', 'Earring', 'LO_Ring', 'Knife', 'Stiletto', 'TinfoilCap', 'TinfoilBelt', 'TinfoilSandals');
$iname = Shadowfunc::randomListItem($items);
if (false === ($item = SR_Item::createByName($iname))) {
$player->message('DB Error 4');
return false;
}
return $player->giveItems(array($item), $this->lang($player, 'from_lake'));
}
示例2: onNPCTalk
public function onNPCTalk(SR_Player $player, $word, array $args)
{
$b = chr(2);
switch ($word) {
case 'shadowrun':
return $this->rply($word);
// return $this->reply("You are looking for a job? You could ask my brother in the Trolls\' Inn. He has some urgent need for spiritouses.");
// return $this->reply("You are looking for a job? You could ask my brother in the Trolls\' Inn. He has some urgent need for spiritouses.");
case 'cyberware':
return $this->rply($word);
// return $this->reply('Nobody wants to be a complete robot. When your essence is 0 you are screwed.');
// return $this->reply('Nobody wants to be a complete robot. When your essence is 0 you are screwed.');
case 'magic':
return $this->rply($word);
// return $this->reply('I don\'t trust those psychos. ');
// return $this->reply('I don\'t trust those psychos. ');
case 'biker':
case 'bikers':
return $this->rply('bikers');
// return $this->reply('Most of my guests are hardcore bikers. They protect my pub and in exchange they can have cheap parties here. They do not annoy the other guests, so all are fine with that.');
// return $this->reply('Most of my guests are hardcore bikers. They protect my pub and in exchange they can have cheap parties here. They do not annoy the other guests, so all are fine with that.');
case 'punk':
case 'punks':
return $this->rply('punks');
// return $this->reply("The punks and the bikers are in kinda clanwar. Better don`t mention them when you like to talk with the {$b}bikers{$b}.");
// return $this->reply("The punks and the bikers are in kinda clanwar. Better don`t mention them when you like to talk with the {$b}bikers{$b}.");
case 'ork':
case 'orks':
return $this->rply('orks');
// return $this->reply('We have not much trouble with orks here. The bikers protect us.');
// return $this->reply('We have not much trouble with orks here. The bikers protect us.');
case 'beer':
return $this->rply($word);
// return $this->reply('One beer. Ok!');
// return $this->reply('One beer. Ok!');
case 'hello':
$this->rply($word);
$player->giveKnowledge('words', 'Punks');
return true;
// return $this->reply("Hello chummer. Better don`t annoy the bikers. They are pissed because of the {$b}punks{$b}");
// return $this->reply("Hello chummer. Better don`t annoy the bikers. They are pissed because of the {$b}punks{$b}");
default:
$msg = array('def1', 'def2', 'def3');
$msg = Shadowfunc::randomListItem($msg);
$msg = $this->langNPC($msg);
return $this->rply('default', array($msg));
// $msg = array('anything new?', 'the usual stuff?', 'how can I serve you?');
// return $this->reply('Hello chummer, '.Shadowfunc::randomListItem($msg));
}
return false;
}
示例3: onRandomCombat
private function onRandomCombat(SR_Player $player)
{
$party = $player->getParty();
$mc = $party->getMemberCount();
$this->partyMessage($player, 'dig1', array($player->getName()));
$amt = rand($mc + 1, $mc + 3);
$amt = Common::clamp($amt, 1, SR_Party::MAX_MEMBERS);
$possible = array('Forest_Skeleton', 'Forest_Ghoul', 'Forest_Werewolf', 'Forest_ArchElve');
$enemies = array();
for ($i = 0; $i < $amt; $i++) {
$enemies[] = Shadowfunc::randomListItem($possible);
}
$party->fight(SR_NPC::createEnemyParty($enemies));
}
示例4: getRandomGender
public static function getRandomGender()
{
return Shadowfunc::randomListItem('male', 'female');
}
示例5: getTarget
public static function getTarget(array $players, $arg, $enum = true, $shortcuts = true)
{
if ($arg === '') {
return Shadowfunc::randomListItem($players);
}
# enum
if ($enum && is_numeric($arg)) {
foreach ($players as $player) {
$player instanceof SR_Player;
if ($player->getEnum() == $arg) {
return $player;
}
}
}
if (strlen($arg) < 3) {
$shortcuts = false;
}
$arg = strtolower($arg);
$n = self::toShortname($arg);
$candidates = array();
foreach ($players as $target) {
$name = strtolower($target->getName());
# Exact match
if ($name === $arg) {
return $target;
}
# Partial match
if (strtolower($target->getShortName()) === $n || $shortcuts && strpos($name, $arg) !== false) {
if (strpos($name, $n) !== false) {
$candidates[] = $target;
}
}
}
switch (count($candidates)) {
case 0:
return false;
case 1:
return $candidates[0];
default:
return false;
}
}
示例6: spawn
/**
* Spawn a copy of this NPC.
* @return SR_NPC
*/
public function spawn(SR_Party $party, SR_Party $attackers = NULL)
{
if (false === ($npc = self::createNPC($this->getNPCClassName(), $party, $attackers))) {
Dog_Log::error(sprintf('SR_NPC::spawn() failed for NPC class: %s.', $this->getNPCClassName()));
return false;
}
foreach ($this->getNPCEquipment() as $field => $itemname) {
if (is_array($itemname)) {
$itemname = Shadowfunc::randomListItem($itemname);
}
if (!in_array($field, SR_Player::$EQUIPMENT, true)) {
Dog_Log::error(sprintf('NPC %s has invalid equipment type: %s.', $this->getNPCPlayerName(), $field));
$npc->deletePlayer();
return false;
}
if (false === ($item = SR_Item::createByName($itemname))) {
Dog_Log::error(sprintf('NPC %s has invalid %s: %s.', $this->getNPCPlayerName(), $field, $itemname));
$npc->deletePlayer();
return false;
}
$item->changeOwnerAndPosition($npc->getID(), $field);
$npc->setEquipment($field, $item);
}
foreach ($this->getNPCCyberware() as $itemname) {
$npc->addCyberware(SR_Item::createByName($itemname));
}
foreach ($this->getNPCMountInventory() as $itemname) {
$npc->putInMountInv(SR_Item::createByName($itemname));
}
$inv = array();
foreach ($this->getNPCInventory() as $itemname) {
if (false === ($item = SR_Item::createByName($itemname))) {
Dog_Log::error(sprintf('NPC %s has invalid inventory item: %s.', $this->getNPCPlayerName(), $itemname));
$npc->deletePlayer();
return false;
}
$inv[] = $item;
}
$npc->giveItems($inv);
$npc->saveSpellData($this->getNPCSpells());
$npc->modify();
$npc->healHP(10000);
$npc->healMP(10000);
return $npc;
}