Beispiel #1
0
 /**
  * @param string $cityname
  * @param string $arg
  * @return SR_Location
  */
 public static function getLocationByAbbrev($cityname, $arg)
 {
     $player = Shadowrun4::getCurrentPlayer();
     if (false !== ($c = Common::substrUntil($arg, '_', false))) {
         $cityname = $c;
         $arg = Common::substrFrom($arg, '_', $arg);
     }
     if (false === ($city = Shadowrun4::getCityByAbbrev($cityname))) {
         self::reply($player, 'Unknown city: ' . $cityname);
         return false;
     }
     $city instanceof SR_City;
     return $city->getLocationByAbbrev($arg);
 }
Beispiel #2
0
 public static function displayItemNameS($itemname)
 {
     return self::displayItemnameFull(Shadowrun4::getCurrentPlayer(), SR_Item::createByName($itemname, 1, false));
 }
Beispiel #3
0
 public static function getItemPage($page, $indexedItems, $is_store, $ipp = 10)
 {
     $nItems = count($indexedItems);
     $page = (int) $page;
     $nPages = (int) (($nItems + $ipp - 1) / $ipp);
     if ($page < 1 || $page > $nPages) {
         return false;
     }
     $from = ($page - 1) * $ipp;
     $indexedItems = array_slice($indexedItems, $from, $ipp, true);
     $b = chr(2);
     $back = '';
     $price = '0';
     $dprice = '';
     $format = Shadowrun4::getCurrentPlayer()->lang('fmt_itemindex');
     foreach ($indexedItems as $idx => $data) {
         $itemname = $data[0];
         $count = $data[1];
         $dcount = $count > 1 ? "({$count})" : '';
         if ($is_store) {
             $price = $data[2];
             $dprice = sprintf("(%s)", Shadowfunc::displayNuyen($price));
         }
         $back .= sprintf($format, $idx + 1, $itemname, $dcount, $dprice, $count, $price);
         // 			$back .= sprintf(', %s%d%s-%s%s%s', $b, $idx+1, $b, $itemname, $count, $dprice);
     }
     return Shadowrun4::lang('page', array($page, $nPages, ltrim($back, ',; ')));
     // 		$back = sprintf('page %d/%d: %s.', $page, $nPages, $back);
     // 		return $back;
 }
Beispiel #4
0
 private static function getLocationTreeB($cityname)
 {
     if (false === ($city = Shadowrun4::getCity($cityname))) {
         echo 'Unknown City in get location tree: ' . $cityname . PHP_EOL;
         return array();
     }
     $player = Shadowrun4::getCurrentPlayer();
     $back = array();
     foreach ($city->getLocations() as $location) {
         $location instanceof SR_Location;
         if ($location->getFoundPercentage() <= 0) {
             continue;
         }
         $loc_name = $location->getName();
         if ($location instanceof SR_Entrance && $location->getExitLocation() !== false) {
             $exit_loc = $location->getExitCity();
             $back[$exit_loc] = sprintf('%s: %s', $loc_name, $location->getFoundText($player));
             $back[] = self::getLocationTreeB($exit_loc);
         } else {
             $back[$loc_name] = sprintf('%s: %s', $loc_name, $location->getFoundText($player));
         }
     }
     return $back;
 }
Beispiel #5
0
 public function isMixedRune()
 {
     $have_mount = false;
     $have_equip = false;
     $mods = array_merge($this->getItemModifiersA(Shadowrun4::getCurrentPlayer()), $this->getItemModifiersB());
     foreach ($mods as $k => $v) {
         if ($this->isMountModifier($k)) {
             $have_mount = true;
         } else {
             $have_equip = true;
         }
     }
     return $have_mount && $have_equip;
 }