public static function execute(SR_Player $player, array $args) { $p = $player->getParty(); if (false !== ($city = $p->getCityClass())) { if ($city->isDungeon()) { self::rply($player, '1035'); return false; // Shadowrap::instance($player)->reply('In dungeons you don\'t have mounts.'); } } // $i = 1; $format = $player->lang('fmt_sumlist'); $out = ''; $total = 0.0; $total_max = 0.0; foreach ($p->getMembers() as $member) { $member instanceof SR_Player; $mount = $member->getMount(); $we = $mount->calcMountWeight(); $max = $mount->getMountWeightB(); $total += $we; $total_max += $max; if ('' !== ($weight = $mount->displayWeight())) { // $weight = "({$weight})"; } $out .= sprintf($format, $member->getEnum(), $mount->getName(), $weight); // $out .= sprintf(", \x02%s\x02-%s%s", $member->getEnum(), $mount->getName(), $weight); } return self::rply($player, '5083', array(Shadowfunc::displayWeight($total), Shadowfunc::displayWeight($total_max), ltrim($out, ',; '))); // $message = sprintf('Party Mounts(%s/%s): %s.', Shadowfunc::displayWeight($total), Shadowfunc::displayWeight($total_max), substr($out, 2)); return Shadowrap::instance($player)->reply($message); }
public static function execute(SR_Player $player, array $args) { // $bot = Shadowrap::instance($player); // $party = $player->getParty(); // $members = $party->getMembers(); $total = 0; $back = ''; $format = $player->lang('fmt_sumlist'); foreach ($player->getParty()->getMembers() as $member) { $member instanceof SR_Player; $we = $member->get('weight'); $mw = $member->get('max_weight'); $b = $we > $mw ? chr(2) : ''; $total += $we; $summand = sprintf('%s/%s', $b . Shadowfunc::displayWeight($we) . $b, Shadowfunc::displayWeight($mw)); $back .= sprintf($format, $member->getEnum(), $b . $member->getName() . $b, $summand); // $back .= sprintf(', %s(%s/%s)', $b.$member->getName().$b, $b.Shadowfunc::displayWeight($we).$b, Shadowfunc::displayWeight($mw)); } return self::rply($player, '5064', array(Shadowfunc::displayWeight($total), ltrim($back, ',; '))); // $bot->reply(sprintf('Your party carries %s: %s.', Shadowfunc::displayWeight($total), substr($back, 2))); // return true; }
public function on_push(SR_Player $player, array $args) { if (false === ($clan = SR_Clan::getByPlayer($player))) { $player->msg('1019'); // $player->message('You are not in a clan.'); return false; } if (count($args) !== 1 && count($args) !== 2) { $player->message(Shadowhelp::getHelp($player, 'clan_push')); return false; } $fee = self::COST_PUSHI; $dfee = Shadowfunc::displayNuyen($fee); if (false === $player->hasNuyen($fee)) { $player->msg('1063', array($dfee, $player->displayNuyen())); // $player->message(sprintf('The fee to push items in the bank is %s, but you only have %s.', $dfee, $player->displayNuyen())); return false; } $amt = isset($args[1]) ? (int) $args[1] : 1; if ($amt <= 0) { $player->message('1038'); // $player->message('Please push a positive amount of items.'); return false; } if (false === ($item = $player->getInvItem($args[0]))) { $player->message('1029'); // $player->message("You don't have that item in your inventory."); return false; } $itemname = $item->getItemName(); if ($item->isItemStackable()) { if ($item->getAmount() < $amt) { $player->msg('1040', array($itemname)); // $player->message(sprintf('You try to push %s %s but you only have %s.', $amt, $itemname, $item->getAmount())); return false; } $weight = $item->getItemWeight() * $amt; if (false === $clan->canHoldMore($weight)) { $player->msg('1132', array(Shadowfunc::displayWeight($weight), $clan->displayStorage(), $clan->displayMaxStorage())); // $player->message(sprintf('You try to push another %s into the clan bank, but it already holds %s/%s.', // Shadowfunc::displayWeight($weight), $clan->displayStorage(), $clan->displayMaxStorage() // )); return false; } if (false === $item->useAmount($player, $amt)) { $player->message('DB ERROR 1'); return false; } if (false === $this->putIntoBank($player, $clan, $itemname, $amt, $weight)) { $player->message('DB ERROR 2'); return false; } } else { $items = $player->getInvItems($itemname, $amt); if (count($items) !== $amt) { $player->msg('1040', array($itemname)); // $player->message(sprintf('You try to push %s %s but you only have %s.', $amt, $itemname, count($items))); return false; } $weight = $item->getItemWeight() * $amt; if (false === $clan->canHoldMore($weight)) { $player->msg('1132', array(Shadowfunc::displayWeight($weight), $clan->displayStorage(), $clan->displayMaxStorage())); // $player->message(sprintf( // 'You try to push another %s into the clan bank, but it already holds %s/%s.', // Shadowfunc::displayWeight($weight), $clan->displayStorage(), $clan->displayMaxStorage() // )); return false; } $weight2 = $item->getItemWeight(); foreach ($items as $item2) { $item2 instanceof SR_Item; if (false === $this->putIntoBank($player, $clan, $itemname, 1, $weight)) { $player->message('DB ERROR 3'); } elseif (false === $item2->deleteItem($player)) { $player->message('DB ERROR 33'); } } } if (false === $player->giveNuyen(-$fee)) { $player->message('DB ERROR 44'); } $player->msg('5173', array($dfee, "{$amt}x{$itemname}", $clan->displayStorage(), $clan->displayMaxStorage())); // $message = sprintf( // 'You pay the fee of %s and put %s of your %s into the clan bank, which now holds %s/%s.', // $dfee, $amt, $itemname, $clan->displayStorage(), $clan->displayMaxStorage()); // $player->message($message); return SR_ClanHistory::onPushi($clan, $player, $itemname, $amt); }
/** * Push an item to your mount. * @param SR_Player $player * @param array $args * @return boolean */ private static function on_push(SR_Player $player, array $args) { if (self::inCombatOrDungeon($player)) { return false; } $bot = Shadowrap::instance($player); $mount = $player->getMount(); array_shift($args); # Item $itemname = array_shift($args); if (false === ($item = $player->getInvItem($itemname))) { self::rply($player, '1029'); // $bot->reply('You don\'t have that item.'); return false; } $itemname = $item->getItemName(); $ditemname = $item->displayFullName($player); # Is Storage Mount? if (0 >= ($max = $mount->getMountWeightB())) { self::rply($player, '1037'); // $bot->reply(sprintf('You cannot store items in your %s.', $mount->getName())); return false; } # Amt $amt = isset($args[0]) ? intval(array_shift($args)) : 1; if ($amt < 1) { self::rply($player, '1038'); // $bot->reply('Please store a positive amount of items.'); return false; } # Is mount in mount? if ($item instanceof SR_Mount) { self::rply($player, '1039', array($mount->getName())); // $bot->reply(sprintf('You cannot put mounts in your %s.', $mount->getName())); return false; } # Make sure we have enough items in invemtory. # N.B.: $have_amt/$items2 is used later on! if ($item->isItemStackable()) { $have_amt = $item->getAmount(); if ($amt > $have_amt) { self::rply($player, '1040', array($item->displayFullName($player))); // $bot->reply(sprintf('You have not that much %s.', $item->getItemName())); return false; } } else { $items2 = $player->getInvItems($item->getItemName(), $amt); if (count($items2) < $amt) { self::rply($player, '1040', array($item->displayFullName($player))); // $bot->reply(sprintf('You have not that much %s.', $item->getItemName())); return false; } } # Is room in mount? $iw = $item->getItemWeight() * $amt; $we = $mount->calcMountWeight(); if ($iw + $we > $max) { self::rply($player, '1041', array($mount->displayName($player), Shadowfunc::displayWeight($we), Shadowfunc::displayWeight($max), $amt, $item->displayName($player), Shadowfunc::displayWeight($iw))); // $bot->reply(sprintf('Your %s(%s/%s) has no room for %d of your %s (%s).', $mount->getName(), Shadowfunc::displayWeight($we), Shadowfunc::displayWeight($max), $amt, $item->getName(), Shadowfunc::displayWeight($iw))); return false; } # A stackable? if ($item->isItemStackable()) { $item->useAmount($player, $amt); $player->putInMountInv(SR_Item::createByName($item->getItemName(), $amt, true)); $stored = $amt; } else { // $items2 = $player->getInvItems($item->getItemName(), $amt); $stored = 0; foreach ($items2 as $item2) { if ($player->removeFromInventory($item2)) { if ($player->putInMountInv($item2)) { $stored++; } } } } $player->modify(); return self::rply($player, '5080', array($stored, $ditemname, $mount->getName())); // $message = sprintf('You stored %d of your %s in your %s.', $stored, $itemname, $mount->getName()); // return $player->message($message); }
/** * Pop items from your bank. * @param SR_Player $player * @param array $args * @return boolean */ public function on_pop(SR_Player $player, array $args) { $bot = Shadowrap::instance($player); # Errors if (count($args) === 0 || count($args) > 2) { $bot->reply(Shadowhelp::getHelp($player, 'popi')); return false; } if (false === $this->checkAfford($player)) { return false; } if (false === ($item = $player->getBankItem($args[0]))) { $bot->rply('1101'); // $bot->reply('You don`t have that item in your bank.'); return false; } $itemname = $args[0]; # Whole stack or single if (count($args) === 1) { if (!$player->removeFromBank($item)) { $bot->rply('1101'); // $bot->reply('You don`t have that item in your bank.'); return false; } if (!$player->giveItems(array($item))) { $bot->reply(sprintf('Database error in %s line %s.', __FILE__, __LINE__)); return false; } $collected = $item->getAmount(); } else { # Args $amt = (int) $args[1]; if ($amt <= 0) { $bot->rply('1038'); // $bot->reply('Please pop a positve amount of items.'); return false; } # Limits if ($item->isItemStackable()) { $have_amt = $item->getAmount(); } else { $items2 = $player->getBankItemsByItemName($item->getItemName()); $have_amt = count($items2); } if ($amt > $have_amt) { $bot->rply('1102', array($item->getItemName())); // $bot->reply(sprintf('You do not have that much %s in your bank.', $item->getItemName())); return false; } # Split Stack if ($item->isItemStackable()) { if (false === $item->useAmount($player, $amt)) { $bot->reply(sprintf('Database error in %s line %s.', __FILE__, __LINE__)); return false; } if (false === ($item2 = SR_Item::createByName($item->getItemName(), $amt, true))) { $bot->reply(sprintf('Database error in %s line %s.', __FILE__, __LINE__)); return false; } if (false === $player->giveItem($item2)) { $bot->reply(sprintf('Database error in %s line %s.', __FILE__, __LINE__)); return false; } $collected = $amt; } else { $collected = 0; foreach ($items2 as $item2) { if (false === $player->removeFromBank($item2)) { $bot->reply(sprintf('Database error in %s line %s.', __FILE__, __LINE__)); } elseif (false === $player->giveItem($item2)) { $bot->reply(sprintf('Database error in %s line %s.', __FILE__, __LINE__)); } else { $collected++; if ($collected >= $amt) { break; } } } } } $player->modify(); // $player->updateInventory(); if (false === $this->pay($player)) { return false; } return $bot->rply('5145', array($collected, $item->displayFullName($player), Shadowfunc::displayWeight($player->get('weight')), Shadowfunc::displayWeight($player->get('max_weight')))); // if ('' === ($paymsg = $this->pay($player))) { // $paymsg .= 'You '; // } // $paymsg .= sprintf('remove %d %s from your bank account and put it into your inventory. You now carry %s/%s.', // $collected, $item->getItemName(), // Shadowfunc::displayWeight($player->get('weight')), Shadowfunc::displayWeight($player->get('max_weight')) // ); // $bot->reply($paymsg); // return true; }
public function getItemDescription() { 'A bag allows you to carry ' . Shadowfunc::displayWeight(self::BAG_WEIGHT) . ' more weight.'; }
public function displayMaxWeight() { return Shadowfunc::displayWeight($this->get('max_weight')); }
public static function displayASL(SR_Player $player) { $b = chr(2); if (0 >= ($age = $player->getBase('age'))) { return Shadowrun4::lang('none'); } return Shadowrun4::langPlayer($player, 'fmt_asl', array($age, $player->getBase('height'), Shadowfunc::displayWeight($player->getBase('bmi')))); // return sprintf("{$b}Age{$b}:%d, %dcm %s", $age, $player->getBase('height'), Shadowfunc::displayWeight($player->getBase('bmi'))); }
public function displayWeight() { // $weight = $this->getItemWeightStacked(); $weight = $this->getItemWeight(); if ($weight <= 0) { return ''; } $amount = $this->getAmount(); $w = Shadowfunc::displayWeight($weight); if ($amount > 1) { return $amount . 'x' . $w; } return $w; }
public function getItemDescription() { 'A backpack allows you to walk a bit faster and carry ' . Shadowfunc::displayWeight(self::BACKPACK_WEIGHT); }
?> </td> <td><?php echo $player->getBase('xp'); ?> </td> <td><?php echo $player->getBase('karma'); ?> </td> <td><?php echo Shadowfunc::displayWeight($player->get('weight')); ?> </td> <td><?php echo Shadowfunc::displayWeight($player->get('max_weight')); ?> </td> </tr> <tr><?php foreach (SR_Player::$ATTRIBUTE as $short => $long) { echo sprintf('<td>%s</td>', $short); } ?> </tr> <tr> <?php foreach (SR_Player::$ATTRIBUTE as $short => $long) { $base = $player->getBase($long); $curr = $player->get($long); $curr = $curr == $base ? '' : "({$curr})";
public function displayMaxStorage() { return Shadowfunc::displayWeight($this->getMaxStorage()); }
/** * Get text message for an event. * @param int $time * @param string $pname * @param int $action * @param string $iname * @param int $amt * @return string */ public static function getHistMessage(SR_Player $player, $time, $pname, $action, $iname, $amt) { $key = 'ch_' . $action; switch ($action) { case self::CREATE: $args = array($pname, $iname); break; case self::REQUEST: case self::JOIN: case self::PART: $args = array($pname, $amt); break; case self::MSG: $args = array($pname, $iname); break; case self::PUSHY: case self::POPY: $args = array($pname, Shadowfunc::displayNuyen($amt)); break; case self::PUSHI: case self::POPI: $args = array($pname, $amt, $iname); break; case self::ADD_MEMBERS: $args = array($pname, $amt); break; case self::ADD_WEALTH: $args = array($pname, Shadowfunc::displayNuyen($amt)); break; case self::ADD_STORAGE: $args = array($pname, Shadowfunc::displayWeight($amt)); break; // case self::CREATE: return sprintf('%s created the clan %s.', $pname, $iname); // case self::REQUEST: return sprintf('%s requested to join your clan as member #%s.', $pname, $amt); // case self::JOIN: return sprintf('%s has joined your clan as member #%s.', $pname, $amt); // case self::PART: return sprintf('%s has left your clan and it now holds %s members.', $pname, $amt); // case self::MSG: return sprintf("\X02%s\X02: \"%s\"", $pname, $iname); // case self::PUSHY: return sprintf('%s has pushed %s into the clanbank.', $pname, Shadowfunc::displayNuyen($amt)); // case self::POPY: return sprintf('%s has taken %s out of the clanbank.', $pname, Shadowfunc::displayNuyen($amt)); // case self::PUSHI: return sprintf('%s has put %s %s into the clanbank.', $pname, $amt, $iname); // case self::POPI: return sprintf('%s has taken %s %s out of the clanbank.', $pname, $amt, $iname); // case self::ADD_MEMBERS: return sprintf('%s has purchased more member slots and the clan can now hold up to %s.', $pname, $amt); // case self::ADD_WEALTH: return sprintf('%s has purchased more nuyen capacity and the clan can now hold up to %s.', $pname, Shadowfunc::displayNuyen($amt)); // case self::ADD_STORAGE: return sprintf('%s has purchased more storage room and the clan can now hold up to %s.', $pname, Shadowfunc::displayWeight($amt)); // case self::CREATE: return sprintf('%s created the clan %s.', $pname, $iname); // case self::REQUEST: return sprintf('%s requested to join your clan as member #%s.', $pname, $amt); // case self::JOIN: return sprintf('%s has joined your clan as member #%s.', $pname, $amt); // case self::PART: return sprintf('%s has left your clan and it now holds %s members.', $pname, $amt); // case self::MSG: return sprintf("\X02%s\X02: \"%s\"", $pname, $iname); // case self::PUSHY: return sprintf('%s has pushed %s into the clanbank.', $pname, Shadowfunc::displayNuyen($amt)); // case self::POPY: return sprintf('%s has taken %s out of the clanbank.', $pname, Shadowfunc::displayNuyen($amt)); // case self::PUSHI: return sprintf('%s has put %s %s into the clanbank.', $pname, $amt, $iname); // case self::POPI: return sprintf('%s has taken %s %s out of the clanbank.', $pname, $amt, $iname); // case self::ADD_MEMBERS: return sprintf('%s has purchased more member slots and the clan can now hold up to %s.', $pname, $amt); // case self::ADD_WEALTH: return sprintf('%s has purchased more nuyen capacity and the clan can now hold up to %s.', $pname, Shadowfunc::displayNuyen($amt)); // case self::ADD_STORAGE: return sprintf('%s has purchased more storage room and the clan can now hold up to %s.', $pname, Shadowfunc::displayWeight($amt)); default: return 'ERR ACTION: ' . $action; } return $player->lang($key, $args); }
public function on_sell(SR_Player $player, array $args) { $bot = Shadowrap::instance($player); $argc = count($args); if ($argc < 1 || $argc > 2) { $bot->reply(Shadowhelp::getHelp($player, 'sell')); return false; } // Multisell if (preg_match('/^\\d*-\\d*$/', $args[0]) && $argc === 1) { return $this->on_sellall($player, $args); } # Item $itemname = array_shift($args); if (false === ($item = $player->getInvItem($itemname))) { $bot->rply('1029'); // $bot->reply('You don\'t have that item.'); return false; } $itemname = $item->getItemName(); if (!$item->isItemSellable()) { $bot->rply('1151', array($item->getItemName())); // $bot->reply(sprintf('I don\'t want your %s.', $item->getItemName())); return false; } # Price $price = $item->getItemPrice(); # / $item->getItemDefaultAmount(); $total = 0.0; # Amount $amt = isset($args[0]) ? array_shift($args) : 1; if (!Common::isNumeric($amt)) { $bot->rply('1040', array($item->getItemName())); return false; } if ($amt < 1) { $bot->rply('1038', array($item->getItemName())); return false; } # A stackable? if ($item->isItemStackable()) { $have_amt = $item->getAmount(); # Split item if ($amt > $have_amt) { $bot->rply('1040', array($item->getItemName())); // $bot->reply(sprintf('You have not that much %s.', $item->getItemName())); return false; } if (!$item->useAmount($player, $amt)) { $bot->reply('Database Error R2 D2.'); return false; } } else { $items2 = $player->getInvItems($item->getItemName(), $amt); if (count($items2) < $amt) { $bot->rply('1040', array($item->getItemName())); // $bot->reply(sprintf('You have not that much %s.', $item->getItemName())); return false; } $stored = 0; foreach ($items2 as $item2) { $item2 instanceof SR_Item; if (!$item2->useAmount($player, 1)) { $bot->reply('Database Error R3 D3.'); return false; } } } $total = $this->calcSellPrice($player, $item, $amt); $player->giveNuyen($total); return $bot->rply('5191', array($amt, $item->displayFullName($player), Shadowfunc::displayNuyen($total), Shadowfunc::displayWeight($player->get('weight')), Shadowfunc::displayWeight($player->get('max_weight')))); // $bot->reply(sprintf('You sold %d of your %s for %s. You now carry %s/%s.', // $amt, $item->getItemName(), Shadowfunc::displayNuyen($total), // Shadowfunc::displayWeight($player->get('weight')), Shadowfunc::displayWeight($player->get('max_weight')) // )); // return true; }
private static function validateBMI(SR_Player $player, $mass, $height) { if ($mass <= 0) { return ' Your own body weight could not get parsed. Try 70kg.'; } $bmi = self::calcBMI($mass, $height); if ($bmi < 0.5 || $bmi > 1.5) { echo "BMI:{$bmi}}n"; return sprintf(' Your height (%dcm), compared with your weight(%s) does not match nicely.', $height, Shadowfunc::displayWeight($mass)); } $offp = 0.5; $offn = 0.2; $b = $player->getRaceBaseVar('bmi') * 1000; $min = round($b * (1 - $offn)); $max = round($b * (1 + $offp)); if ($mass < $min || $mass > $max) { return sprintf(' The body mass for a(n) %s should be between %s and %s.', $player->getRace(), Shadowfunc::displayWeight($min), Shadowfunc::displayWeight($max)); } return ''; }
public static function onASLShowPartyB(SR_Player $player, $field) { $out = ''; $sum = 0; $format = Shadowrun4::lang('fmt_sumlist'); foreach ($player->getParty()->getMembers() as $member) { $member instanceof SR_Player; $val = Common::clamp(intval($member->getBase($field)), 0); $sum += $val; switch ($field) { case 'age': $out2 = "{$val}y"; break; case 'bmi': $out2 = Shadowfunc::displayWeight($val); break; case 'height': $out2 = Shadowfunc::displayDistance($val, 2); break; default: self::reply($player, 'Error unknown field in onASLShowPartyB()'); return false; } $out .= sprintf($format, $member->getEnum(), $member->getName(), $out2); } switch ($field) { case 'age': $sumtxt = "{$sum}y"; break; case 'bmi': $sumtxt = Shadowfunc::displayWeight($sum); break; case 'height': $sumtxt = Shadowfunc::displayDistance($sum, 2); break; default: self::reply($player, 'Error unknown field2 in onASLShowPartyB()'); return false; } self::rply($player, '', array(Shadowrun4::lang('sum_' . $field), $sumtxt, ltrim($out, ',; '))); return true; }