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


PHP Shadowrun4::getNPCByAbbrev方法代码示例

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


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

示例1: execute

 public static function execute(SR_Player $player, array $args)
 {
     $bot = Shadowrap::instance($player);
     if (count($args) !== 2) {
         $bot->reply(Shadowhelp::getHelp($player, 'gmt'));
         return false;
     }
     $target = Shadowrun4::getPlayerByShortName($args[0]);
     if ($target === -1) {
         $player->message('The username is ambigious.');
         return false;
     }
     if ($target === false) {
         $player->message('The player is not in memory or unknown.');
         return false;
     }
     if (false === $target->isCreated()) {
         $bot->reply(sprintf('The player %s has not started a game yet.', $args[0]));
         return false;
     }
     # Check for valid enemies.
     $npcnames = explode(',', $args[1]);
     foreach ($npcnames as $i => $npcname) {
         if (false === ($npc = Shadowrun4::getNPCByAbbrev($player, $npcname))) {
             $bot->reply(sprintf('Unknown NPC: %s.', $npcname));
             return false;
         }
         $npcnames[$i] = $npc->getNPCClassName();
     }
     # Prepare for action cases
     $p = $target->getParty();
     $a = $p->getAction();
     $ep = NULL;
     switch ($a) {
         case SR_Party::ACTION_TALK:
             $p->getEnemyParty()->popAction(true);
             # we pop the enemies talking
         # we pop the enemies talking
         case SR_Party::ACTION_SLEEP:
             $p->popAction(false);
             # and pop our own fallthrough
             break;
         case SR_Party::ACTION_FIGHT:
             $ep = $p->getEnemyParty();
             # Stack and re-init the fight :)
             break;
             # Nothing todo here
         # Nothing todo here
         case SR_Party::ACTION_INSIDE:
         case SR_Party::ACTION_OUTSIDE:
         case SR_Party::ACTION_EXPLORE:
         case SR_Party::ACTION_GOTO:
         case SR_Party::ACTION_HUNT:
             break;
             # Impossibru
         # Impossibru
         case SR_Party::ACTION_HIJACK:
         case SR_Party::ACTION_TRAVEL:
         case SR_Party::ACTION_DELETE:
         default:
             $bot->reply('Cannot #gmt because target action is ' . $a . '!');
             return false;
     }
     # Generate NPCs
     if (false === ($ep2 = SR_NPC::createEnemyParty($npcnames))) {
         $bot->reply('cannot create party! check logs');
         return false;
     }
     # Merge?
     if ($ep === NULL) {
         $ep = $ep2;
     } else {
         $ep->mergeParty($ep2);
     }
     # Delegate new actions
     if ($p->isFighting()) {
         # Already fighting
         $p->popAction(false);
         $p->fight($ep, true);
     } elseif ($ep->getLeader() instanceof SR_TalkingNPC) {
         # Init a talk
         $p->talk($ep, true);
     } else {
         # Init a fight
         $p->fight($ep, true);
     }
     # That's it!
     return $bot->reply('The party now encountered some enemies!');
 }
开发者ID:sinfocol,项目名称:gwf3,代码行数:89,代码来源:gmt.php


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