Example #1
0
 public function getNPCMeetPercent(SR_Party $party)
 {
     foreach ($party->getMembers() as $player) {
         $quest = SR_Quest::getQuest($player, 'Seattle_Ranger');
         if ($quest->getAmount() > 0) {
             return 90;
         }
     }
     return 0;
 }
Example #2
0
 public static function displayBadKarmaParty(SR_Party $party)
 {
     $back = '';
     foreach ($party->getMembers() as $member) {
         $member instanceof SR_Player;
         $bk = $member->getBase('bad_karma');
         if ($bk > 0) {
             $back .= Shadowrun4::lang('info_bk', array($member->getName(), $bk));
             // 				$back .= sprintf(', %s has %d bad_karma', $member->getName(), $bk);
         }
     }
     return $back === '' ? '' : sprintf(' %s.', substr($back, 2));
 }
Example #3
0
 public static function displayBountyParty(SR_Party $party)
 {
     $back = '';
     $format = Shadowrun4::lang('fmt_sumlist');
     foreach ($party->getMembers() as $member) {
         $member instanceof SR_Player;
         $bounty = $member->getBase('bounty');
         if ($bounty > 0) {
             $back .= sprintf($format, $member->getEnum(), $member->getName(), Shadowfunc::displayNuyen($bounty));
             // 				$back .= sprintf(", {$b}%s{$b}-%s(%s)", $i++, $member->getName(), Shadowfunc::displayNuyen($bounty));
         }
     }
     return $back === '' ? '' : Shadowrun4::lang('meet_bounty', array(ltrim($back, ',; ')));
     // 		return $back === '' ? '' : sprintf(" There is a {$b}bounty{$b} on %s.", substr($back, 2));
 }
Example #4
0
 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);
             }
         }
     }
 }
Example #5
0
 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)));
             }
         }
     }
 }
Example #6
0
 public function onLeaveLocation(SR_Party $party)
 {
     foreach ($party->getMembers() as $member) {
         $member instanceof SR_Player;
         # The heat is on?
         if (!$member->hasConst(self::KEY)) {
             continue;
         }
         if (false !== ($milk = $member->getInvItemByName('Milk', false, false))) {
             $amt = $milk->getAmount();
             if (false !== $member->deleteFromInventory($milk)) {
                 $member->message($this->lang($member, 'sour'));
                 $member->giveItems(array(SR_Item::createByName('SourMilk', $amt)));
             }
         }
     }
 }
Example #7
0
 public function onLeaveLocation(SR_Party $party)
 {
     $errors = '';
     foreach ($party->getMembers() as $member) {
         $member instanceof SR_Player;
         if (false === ($item = $member->getInvItemByName('ID4Card'))) {
             $errors .= sprintf(', %s', $member->getName());
         } else {
             $member->message($this->lang($member, 'usecard', array($item->getAmount())));
             // 				$member->message(sprintf('You use one of your %d ID4 cards...', $item->getAmount()));
             $item->useAmount($member, 1);
         }
     }
     if ($errors !== '') {
         $this->partyMessage($party->getLeader(), 'nocard', array(substr($errors, 2)));
         // 			$party->notice(sprintf('%s do(es) not have an ID4Card... You hear the alarm sound!', substr($errors, 2)));
         if (false !== ($city = $this->getCityClass())) {
             $city->setAlert($party, GWF_Time::ONE_HOUR * 2);
         }
     }
 }
Example #8
0
 /**
  * Check if the party can move. Return false on success and string on error.
  * @param SR_Player $player
  * @return false|string
  */
 public static function checkMove(SR_Party $party)
 {
     $b = chr(2);
     $back = '';
     foreach ($party->getMembers() as $member) {
         $member instanceof SR_Player;
         if ($member->isDead()) {
             $party->ntice('1080', array($member->getName()));
             return false;
             // 				$back .= sprintf(', %s is dead', $member->getName());
         } elseif ($member->isOverloadedFull()) {
             $party->ntice('1081', array($member->getName()));
             return false;
             // 				$back .= sprintf(', %s is overloaded', $member->getName());
         }
         // 			elseif ($member->getBase('age') <= 0)
         // 			{
         // 				$party->ntice('1082', array($member->getName(), self::translate('aslset'));
         // 				return false;
         // // 				$back .= sprintf(", %s has no {$b}#asl{$b}", $member->getName());
         // 			}
     }
     return true;
     // 		if ($back === '')
     // 		{
     // 			return true;
     // 		}
     // 		$party->ntice('', array(substr($back, 2)));
     // 		return false;
     // 		return $back === '' ? false : 'You cannot move because '.substr($back, 2).'.';
 }
Example #9
0
 /**
  * Remove a party from memory.
  * @param SR_Party $party
  */
 public static function removeParty(SR_Party $party)
 {
     $partyid = $party->getID();
     foreach ($party->getMembers() as $member) {
         self::removePlayer($member);
     }
     unset(self::$parties[$partyid]);
 }
Example #10
0
 public function setElevatorFlagsParty(SR_Party $party, $floors = self::ALL_BITS, $bool = false)
 {
     foreach ($party->getMembers() as $member) {
         if (false === $this->setElevatorFlags($member, $floors, $bool)) {
             return false;
         }
     }
     return true;
 }
Example #11
0
 /**
  * Check if the party sum levels match nicely.
  * @param SR_Party $attackers
  * @param SR_Party $defenders
  * @param boolean $verbose
  * @return true|false
  */
 public static function isKillProtectedPartyLevel(SR_Party $attackers, SR_Party $defenders, SR_Player $player, $verbose = true)
 {
     # NPC
     if (!$defenders->isHuman()) {
         return false;
     }
     # A member has bounty or bad karma
     foreach ($defenders->getMembers() as $defender) {
         $defender instanceof SR_Player;
         if ($defender->getBase('bounty') > 0) {
             return false;
         }
         if ($defender->getBase('bad_karma')) {
             return false;
         }
     }
     # Check party sums for effective level.
     $al = $attackers->getSum('level', false);
     $dl = $defenders->getSum('level', false);
     # Clamp to the level where game gets hard.
     $clamp = self::MAX_LEVEL_DIFF + self::DISABLE_LEVEL_DIFF;
     $al = Common::clamp($al, 0, $clamp);
     $dl = Common::clamp($dl, 0, $clamp);
     $dif = $al - $dl;
     if ($dif > self::MAX_LEVEL_DIFF) {
         if ($verbose) {
             $player->msg('1015', array($al, $dl, self::MAX_LEVEL_DIFF));
             // 				$player->message(sprintf('Your party (level sum %d) cannot attack a party with level sum %d because the level difference is larger than %d.', $al, $dl, self::MAX_LEVEL_DIFF));
         }
         # Protected by level
         return true;
     }
     # No protection
     return false;
 }
Example #12
0
 public function onEnterLocation(SR_Party $party)
 {
     foreach ($party->getMembers() as $player) {
         $pid = $player->getID();
         unset(self::$UPGRADE_CONFIRM[$pid . 'X']);
         unset(self::$UPGRADE_CONFIRM[$pid . 'Y']);
         unset(self::$SPLIT_CONFIRM[$pid]);
         unset(self::$BREAK_CONFIRM[$pid]);
     }
 }
Example #13
0
 private function onCrackLockInit(SR_Party $party)
 {
     $crackers = array();
     foreach ($party->getMembers() as $member) {
         if (!$this->isLockClosedPlayer($member)) {
             $crackers[] = $member;
             $this->onSetLockPlayer($member, 0);
         }
     }
     shuffle($crackers);
     return $crackers;
 }
Example #14
0
 private function initNPCc(SR_Party $p, SR_Party $ep)
 {
     foreach ($p->getMembers() as $member) {
         $member instanceof SR_NPC;
         $member->onInitNPC($ep);
     }
 }
Example #15
0
 public function isExitAllowedParty(SR_Party $party)
 {
     foreach ($party->getMembers() as $m) {
         if (!$this->isExitAllowed($m)) {
             return false;
         }
     }
     return true;
 }
Example #16
0
 public function onReset(SR_Party $party)
 {
     echo "Resetting\n";
     foreach ($party->getMembers() as $player) {
         $this->onResetPlayer($player);
     }
 }