本文整理汇总了PHP中Common::isNumeric方法的典型用法代码示例。如果您正苦于以下问题:PHP Common::isNumeric方法的具体用法?PHP Common::isNumeric怎么用?PHP Common::isNumeric使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Common
的用法示例。
在下文中一共展示了Common::isNumeric方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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, 'gmloot'));
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;
}
if (Common::isNumeric($args[1])) {
$target->giveItems(Shadowfunc::randLoot($target, $args[1]), 'gmloot');
} else {
}
return true;
}
示例2: execute
/**
* Called like
* #quests SmithHammer
* #quests Lovers
* #quests open 1
* #quests open
* #quests done 1
* @param SR_Player $player
* @param array $args
*/
public static function execute(SR_Player $player, array $args)
{
if (count($args) === 0) {
$args = array('open');
}
$quests = SR_Quest::getAllQuests($player);
switch ($args[0]) {
case 'miss':
case 'missing':
return self::displayMissing($player, $quests, $args);
case 'open':
case 'deny':
case 'done':
case 'fail':
case 'abort':
return self::displaySection($player, $quests, $args[0], $args);
case 'stats':
case 's':
return self::displayStats($player, $quests);
case 'citystats':
case 'cstats':
case 'cs':
return self::displayCityStats($player);
default:
if (Common::isNumeric($args[0])) {
return self::onDisplayQuestByNum($player, $quests, $args);
}
return self::onSearchQuests($player, $quests, $args);
}
}
示例3: execute
public static function execute(SR_Player $player, array $args)
{
if (count($args) === 0) {
$args = array(1);
}
if (count($args) === 1 && Common::isNumeric($args[0])) {
return self::displaySets($player, (int) $args[0]);
} elseif (count($args) === 1) {
return self::displaySet($player, $args[0]);
}
}
示例4: generate
public static function generate(array $extensions_data)
{
$extensions = array();
foreach ($extensions_data as $extension_name => $data) {
if (Common::isNumeric($extension_name)) {
$extension_name = $data;
$data = null;
}
$extensions[] = self::createExtension($extension_name, $data);
}
usort($extensions, array(__CLASS__, 'sort_priority_asc'));
return $extensions;
}
示例5: merge_use_mapping
function merge_use_mapping(GDO_Database $db_from, GDO_Database $db_to, $classname, $colname, array $map, $numerical = true)
{
GDO::setCurrentDB($db_from);
$table = GDO::table($classname);
foreach ($map as $from => $to) {
if (Common::isNumeric($from)) {
if (false === $table->update("`{$colname}` = 0x40000000|{$to}", "`{$colname}` = {$from}")) {
return false;
}
}
}
return $table->update("`{$colname}` = `{$colname}` - 0x40000000", "`{$colname}` >= 0x40000000");
}
示例6: onDisplay
private function onDisplay($message = '')
{
if ($message === '') {
return $this->displayQuote(Dog_Quote::getRandomID());
}
if (Common::isNumeric($message)) {
return $this->displayQuote(intval($message));
}
$ids = Dog_Quote::searchQuotes($message);
if (count($ids) === 0) {
return sprintf('No quote found with search term "%s"', $message);
}
if (count($ids) === 1) {
return $this->displayQuote($ids[0]);
}
return sprintf('Matching IDs: %s.', implode(', ', $ids));
}
示例7: getRecipe
public function getRecipe(SR_Player $player, $arg)
{
$recipes = $this->getRecipesB($player);
if (Common::isNumeric($arg)) {
if ($arg > 0 && $arg <= count($recipes)) {
return $recipes[$arg - 1];
}
} else {
$arg = strtolower($arg);
foreach ($recipes as $recipe) {
if (strcasecmp($recipe[0], $arg) === 0) {
return $recipe;
}
}
}
return false;
}
示例8: getFieldData
private function getFieldData(SR_Player $player, $arg)
{
$fields = $this->getFields($player);
if (Common::isNumeric($arg)) {
if ($arg < 1 || $arg > count($fields)) {
return false;
}
$back = array_slice($fields, $arg - 1, 1);
return $back[0];
}
foreach ($fields as $data) {
if ($arg === $data[0]) {
return $data;
}
}
return false;
}
示例9: execute
public static function execute(SR_Player $player, array $args)
{
$bot = Shadowrap::instance($player);
if (count($args) < 2 || count($args) > 3) {
$bot->reply(Shadowhelp::getHelp($player, 'gmsp'));
return false;
}
if (false === ($spell = SR_Spell::getSpell($args[1]))) {
$bot->reply("The spell {$args[1]} is unknown.");
return false;
}
$server = $player->getUser()->getServer();
if (false === ($user = Dog::getUserByArg($args[0]))) {
$bot->reply(sprintf('The user %s is unknown.', $args[0]));
return false;
}
if (false === ($target = Shadowrun4::getPlayerByUID($user->getID()))) {
$bot->reply(sprintf('The player %s is unknown.', $user->getName()));
return false;
}
if (false === $target->isCreated()) {
$bot->reply(sprintf('The player %s has not started a game yet.', $args[0]));
return false;
}
$by = 1;
if (count($args) === 3) {
if (!Common::isNumeric($args[2])) {
$bot->reply(Shadowhelp::getHelp($player, 'gmsp'));
return false;
}
if (false === ($base = $player->getSpellBaseLevel($args[1]))) {
$bot->reply(Shadowhelp::getHelp($player, 'gmsp'));
return false;
}
$by = $args[2] - $base;
}
$target->levelupSpell($spell->getName(), $by);
$target->modify();
$base = $target->getSpellBaseLevel($args[1]);
return $bot->reply(sprintf('The target got changed spells!'));
}
示例10: execute
public static function execute(SR_Player $player, array $args)
{
$bot = Shadowrap::instance($player);
# Own info
if (count($args) === 0) {
return self::showClanInfo($player, $player);
}
# 1 Numeric == clan history.
if (count($args) === 1 && Common::isNumeric($args[0])) {
if ($args[0] < 1) {
$bot->reply(Shadowhelp::getHelp($player, 'clan'));
return false;
}
return self::showHistoryPage($player, (int) $args[0]);
}
# !members shows your clan members.
if (count($args) === 1 || count($args) === 2) {
if ($args[0] === '!m' || $args[0] === '!members') {
$page = isset($args[1]) ? (int) $args[1] : 1;
return self::showMembers($player, $page);
}
}
# Show another player.
if (count($args) !== 1) {
$bot->reply(Shadowhelp::getHelp($player, 'clan'));
return false;
}
if (false === ($target = Shadowrun4::getPlayerByShortName($args[0]))) {
self::rply($player, '1017');
// $bot->reply('This player is unknown or not in memory.');
return false;
} else {
if ($target === -1) {
self::rply($player, '1018');
// $bot->reply('This playername is ambigous.');
return false;
}
}
return self::showClanInfo($player, $target);
}
示例11: humanToSeconds
/**
* Convert a human duration to seconds.
* Input may be like 3d5h8i 7s.
* Also possible is 1 month 3 days or 1year2sec.
* Note that 'i' is used for minutes and 'm' for months.
* No unit means default unit, which is seconds.
* Supported units are:
* s, sec, second, seconds,
* i, min, minute, minutes,
* h, hour, hours,
* d, day, days,
* w, week, weeks,
* m, month, months,
* y, year, years.
* @param $duration string is the duration in human format.
* @return int duration as seconds
* */
public static function humanToSeconds($duration)
{
if (is_int($duration)) {
return $duration;
}
if (!is_string($duration)) {
return 0;
}
if (Common::isNumeric($duration)) {
return (int) $duration;
}
$duration = trim(strtolower($duration));
if (!preg_match('/^(?:(?:[0-9 ]+[sihdwmy])+)$/', $duration)) {
return 0;
}
$multis = array('s' => 1, 'i' => 60, 'h' => 3600, 'd' => 86400, 'w' => 604800, 'm' => 2592000, 'y' => 31536000);
$replace = array('seconds' => 's', 'second' => 's', 'sec' => 's', 'minutes' => 'i', 'minute' => 'i', 'min' => 'i', 'hours' => 'h', 'hour' => 'h', 'days' => 'd', 'day' => 'd', 'weeks' => 'w', 'week' => 'w', 'months' => 'm', 'month' => 'm', 'mon' => 'm', 'years' => 'y', 'year' => 'y');
$negative = 1;
$duration = strtolower(trim($duration));
if ($duration[0] == '-') {
$negative = -1;
}
$duration = trim($duration, '-');
$duration = str_replace(array_keys($replace), array_values($replace), $duration);
// $duration = preg_replace('/[^sihdwmy0-9]/', '', $duration);
$duration = preg_replace('/([sihdwmy])/', '$1 ', $duration);
$duration = explode(' ', trim($duration));
$back = 0;
foreach ($duration as $d) {
$unit = substr($d, -1);
if (is_numeric($unit)) {
$unit = 's';
} else {
$d = substr($d, 0, -1);
}
$d = intval($d);
$back += $multis[$unit] * $d;
}
return $negative * $back;
}
示例12: array
<?php
$lang = array('en' => array('help' => 'Usage: %CMD% [<cocktail>] [<nickname>]. Virtually get someone a cock or list them.', 'cock' => 'hands %s a nice %s.', 'list' => 'Available cocktails: %s.'));
$cocktails = array('Woo Woo', 'Piña Colada', 'Blue Lagoon', 'Sex on the Beach', 'Caipirinha', 'Tequila Sunrise', 'Cosmopolitan');
$plugin = Dog::getPlugin();
$argv = $plugin->argv();
$argc = count($argv);
$showlist = false;
if ($argc === 0) {
$showlist = true;
} elseif ($argc <= 2) {
if (Common::isNumeric($argv[0])) {
$target = isset($argv[1]) ? $argv[1] : Dog::getUser()->getName();
$coknum = (int) $argv[0] - 1;
if (isset($cocktails[$coknum])) {
$plugin->rplyAction('cock', array($target, $cocktails[$coknum]));
} else {
$showlist = true;
}
} else {
$plugin->showHelp();
}
} else {
$plugin->showHelp();
}
if ($showlist) {
$i = 1;
$out = '';
foreach ($cocktails as $cock) {
$out .= ', ' . $i++ . '-' . $cock;
}
示例13: onAddWTB
private function onAddWTB(SR_Player $player, array $args)
{
$have = $this->getWTBSlots($player);
$used = SR_BazarWTB::getItemcountForPlayer($player);
if ($used >= $have) {
return Dog::reply($player->lang('1191'));
}
$price = round($args[1]);
if ($price < self::MIN_PRICE) {
return Dog::reply($player->lang('1109', array(self::MIN_PRICE)));
}
if ($price > 10000000) {
return Dog::reply($player->lang('1110'));
}
$amt = $args[2];
if (!Common::isNumeric($amt) || $amt < 1) {
return Dog::reply($player->lang('1038'));
}
if (false === ($item = SR_Item::createByName($args[0], $amt, false))) {
return Dog::reply($player->lang('1192'));
}
if ($item->isItemStatted()) {
return Dog::reply($player->lang('1193'));
}
if (false === SR_BazarWTB::insertEntry($player, $item, $price)) {
return Dog::reply('Database Error 1b');
}
}
示例14: array
<?php
$lang = array('en' => array('help' => 'Usage: %CMD% <integer>. Predict the next sequential integer polled from rand(). $100 won by noother!', 'good' => 'Well done!', 'wrong' => 'You predicted %s but the outcome was %s.'));
$plugin = Dog::getPlugin();
$argv = $plugin->argv();
if (count($argv) !== 1 || !Common::isNumeric($argv[0])) {
return $plugin->showHelp();
}
$predicted = (int) $argv[0];
$rand = rand(0, getrandmax());
if ($rand === $predicted) {
$plugin->rply('good');
} else {
$plugin->rply('wrong', array($predicted, $rand));
}
示例15: isValid
public static function isValid($type, $value)
{
switch ($type) {
case 'b':
return $value === '0' || $value === '1';
case 'i':
return Common::isNumeric($value, false);
case 'f':
return Common::isNumeric($value, true);
case 's':
case 'v':
return true;
default:
return false;
}
}