本文整理汇总了PHP中game::format_rank方法的典型用法代码示例。如果您正苦于以下问题:PHP game::format_rank方法的具体用法?PHP game::format_rank怎么用?PHP game::format_rank使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类game
的用法示例。
在下文中一共展示了game::format_rank方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_random_message
/**
* Hent ut en tilfeldig melding for en kriminalitet
*/
public function get_random_message($id, $success, $cash = null, $points = null)
{
$id = (int) $id;
$rank = $success ? game::format_rank($points, $this->up->rank) : null;
// hent en tilfeldig melding
$result = \Kofradia\DB::get()->query("\n\t\t\tSELECT text\n\t\t\tFROM kriminalitet_text\n\t\t\tWHERE krimid = {$id} AND outcome = " . ($success ? 1 : 2) . "\n\t\t\tORDER BY RAND()\n\t\t\tLIMIT 1");
// har melding?
$row = $result->fetch();
if ($row) {
if ($success) {
return str_replace(array("%cash", "%points", "%rank"), array(game::format_cash($cash), $points, $rank), $row['text']);
}
return $row['text'];
} else {
if ($success) {
return "Vellykket! Du skaffet deg {$points} poeng og " . game::format_cash($cash) . ".";
}
return "Mislykket! Du klarte det ikke...";
}
}
示例2: sykebil
/**
* Be som sykebil
*/
protected function sykebil()
{
// kan ikke bruke sykebil?
if ($this->up->data['up_b_id'] == $this->ff->data['br_b_id'] || $this->up->get_energy_percent() >= self::ENERGY_SYKEBIL_REQ) {
return;
}
// bekreftet?
if (isset($_POST['confirm']) && validate_sid()) {
// ikke bekreftet?
if (!isset($_POST['c'])) {
ess::$b->page->add_message("Du må bekrefte at du mister 25 % rank for å kunne benytte deg av alternativet.", "error");
} else {
if (!$this->form->validateHashOrAlert(null, "Sykehus")) {
return;
}
// sett ned ranken
$p = round($this->up->data['up_points'] * 0.25);
$this->up->increase_rank(-$p, false);
// flytt til korrekt bydel
\Kofradia\DB::get()->exec("UPDATE users_players SET up_b_id = {$this->ff->data['br_b_id']}, up_b_time = " . time() . " WHERE up_id = " . $this->up->id);
$this->up->data['up_b_id'] = $this->ff->data['br_b_id'];
unset($this->up->bydel);
// gi melding
ess::$b->page->add_message("Du ble hentet av en sykebil og ble fraktet til <b>" . htmlspecialchars($this->up->bydel['name']) . "</b>. Du kan nå kjøpe energi hos sykehuset. Du mistet " . game::format_num($p) . " poeng (" . game::format_rank($p) . " rank).");
putlog("DF", "%c4%bSYKEBIL:%b%c " . $this->up->data['up_name'] . " benyttet seg av sykebil og mistet " . game::format_number($p) . " rankpoeng. " . $this->up->generate_minside_url());
redirect::handle();
}
}
echo '
<div class="bg1_c xsmall">
<h1 class="bg1">Sykehus<span class="left2"></span><span class="right2"></span></h1>
<div class="bg1">
<boxes />
<p class="c"><a href="./?ff_id=' . $this->ff->id . '">Tilbake</a></p>
<p>Du har svært lite energi. Hvis du føler du står i fare for å dø og ikke har nok energi for å reise via bydeler, kan du få en sykebil til å hente deg.</p>
<p>Når du blir hentet av en sykebil, vil du bli fraktet til bydelen sykehuset befinner seg i uten å miste noe helse eller energi. Du vil deretter kunne utføre alternativene for å få energi.</p>
<p>Ved å benytte seg av dette alternativet <b>må du ofre 25 % av din totale rank</b>.</p>
<form action="" method="post">
<input type="hidden" name="sid" value="' . login::$info['ses_id'] . '" />
<input type="hidden" name="sykebil" />
' . $this->form->getHTMLInput() . '
<p class="c"><input type="checkbox" id="sykebil_c" name="c" /><label for="sykebil_c"> Jeg bekrefter at jeg mister 25 % av min rank</label></p>
<p class="c">' . show_sbutton("Be om sykebil", 'name="confirm"') . '</p>
</form>
<p class="c"><a href="./?ff_id=' . $this->ff->id . '">Tilbake</a></p>
</div>
</div>';
return true;
}
示例3: attack_log
/**
* Lagre logg over angrep
*/
protected function attack_log($ret, $attack_type, $vitner_log, player $up)
{
// sett opp vitner
$vitner = count($vitner_log) > 0 ? \Kofradia\DB::quote(serialize($vitner_log)) : 'NULL';
// sett opp liste over FF
$ff_defend = array();
$list = $this->get_ff_list();
foreach ($list as $row) {
if ($row['ff_is_crew'] != 0) {
continue;
}
$type = ff::$types[$row['ff_type']];
$ff_defend[] = array($row['ff_type'], $row['ff_id'], $type['refobj'], $row['ff_name'], $row['ffm_priority'], $type['priority'][$row['ffm_priority']], $row['ffm_status']);
}
$ff_defend = count($ff_defend) > 0 ? \Kofradia\DB::quote(serialize($ff_defend)) : 'NULL';
// sett opp liste over FF for angriper
$ff_attack = array();
$list = $up->get_ff_list();
foreach ($list as $row) {
if ($row['ff_is_crew'] != 0) {
continue;
}
$type = ff::$types[$row['ff_type']];
$ff_attack[] = array($row['ff_type'], $row['ff_id'], $type['refobj'], $row['ff_name'], $row['ffm_priority'], $type['priority'][$row['ffm_priority']], $row['ffm_status']);
}
$ff_attack = count($ff_attack) > 0 ? \Kofradia\DB::quote(serialize($ff_attack)) : 'NULL';
// legg til i loggen
$cash = isset($ret['penger']) ? $ret['penger'] : 0;
if (isset($ret['penger_bank'])) {
$cash = bcadd($cash, $ret['penger_bank']);
}
$hitlist = isset($ret['hitlist']) ? $ret['hitlist'] : 0;
\Kofradia\DB::get()->exec("INSERT INTO drapforsok SET df_attack_up_id = {$up->id}, df_defend_up_id = {$this->id}, df_time = " . time() . ", df_b_id = " . $up->data['up_b_id'] . ", df_outcome = " . ($ret['drept'] ? 1 : 0) . ", df_rankpoints = {$ret['rankpoeng']}, df_type = {$attack_type}, df_cash = {$cash}, df_hitlist = {$hitlist}, df_vitner = {$vitner}, df_attack_ff_list = {$ff_attack}, df_defend_ff_list = {$ff_defend}, df_bullets = {$ret['bullets']}");
if ($ret['drept']) {
// logg
if ($attack_type == self::ATTACK_TYPE_UTPRESSING) {
putlog("DF", "%c4UTPRESSING DREPT%c: {$up->data['up_name']} ({$up->rank['name']}) presset {$this->data['up_name']} ({$this->rank['name']}). " . $this->generate_minside_url());
} else {
putlog("DF", "ANGREP %c4DREPT%c: {$up->data['up_name']} ({$up->rank['name']}) angrep%c3 {$this->data['up_name']}%c ({$this->rank['name']}) med " . $up->weapon->data['name'] . " (" . game::format_number($up->data['up_weapon_training'] * 100, 2) . " % våpentrening) med " . fwords("%d kule", "%d kuler", $ret['bullets']) . ". " . $this->generate_minside_url());
putlog("DF", " - Angrepstyrke: " . game::format_number($ret['attack_skade'][0] * 100, 2) . ", beskyttelsestyrke: " . game::format_number($ret['attack_skade'][1] * 100, 2) . ", skadeprosent: " . game::format_number($ret['skadeprosent'] * 100, 2) . " % av " . weapon::MAX_ATTACK_HEALTH . " helsepoeng");
}
putlog("DF", " - Helse: Hadde " . game::format_number($this->get_health_percent(), 3) . " %");
putlog("DF", " - Energi: Hadde " . game::format_number($this->get_energy_percent(), 3) . " %");
if (!$this->protection->data) {
putlog("DF", " - Hadde ingen beskyttelse");
} else {
putlog("DF", " - Beskyttelse: Hadde {$this->protection->data['name']} med " . game::format_number($this->data['up_protection_state'] * 100, 2) . " % styrke");
}
putlog("DF", " - Rankpoeng: {$up->data['up_name']} fikk " . game::format_number($ret['rankpoeng']) . " rankpoeng (" . game::format_rank($ret['rankpoeng'], "all") . " % rank) " . $up->generate_minside_url());
if (count($ret['vitner']) == 0) {
putlog("DF", " - Ingen vitner");
} else {
foreach ($ret['vitner'] as $vitne) {
putlog("DF", " - Vitne: {$vitne['up']->data['up_name']} (" . ($vitne['visible'] ? 'ble oppdaget' : 'ble IKKE oppdaget') . ') ' . $vitne['up']->generate_minside_url());
}
}
putlog("DF", " - Penger fra hånda: " . game::format_cash($ret['penger']));
if (isset($ret['penger_bank'])) {
putlog("DF", " - Penger fra banken: " . game::format_cash($ret['penger_bank']));
}
putlog("DF", " - Penger fra hitlist: " . game::format_cash($ret['hitlist']));
foreach ($ret['ffm'] as $ffm) {
putlog("DF", " - Var " . $ffm->get_priority_name() . " i " . $ffm->ff->data['ff_name'] . " " . ess::$s['path'] . "/ff/?ff_id={$ffm->ff->id}");
}
} elseif ($attack_type == self::ATTACK_TYPE_KILL) {
// logg
putlog("DF", "ANGREP %c8SKADET%c: {$up->data['up_name']} ({$up->rank['name']}) angrep%c3 {$this->data['up_name']}%c ({$this->rank['name']}) med " . $up->weapon->data['name'] . " (" . game::format_number($up->data['up_weapon_training'] * 100, 2) . " % våpentrening) med " . fwords("%d kule", "%d kuler", $ret['bullets']) . ". " . $this->generate_minside_url());
putlog("DF", " - Angrepstyrke: " . game::format_number($ret['attack_skade'][0] * 100, 2) . ", beskyttelsestyrke: " . game::format_number($ret['attack_skade'][1] * 100, 2) . ", skadeprosent: " . game::format_number($ret['skadeprosent'] * 100, 2) . " % av " . weapon::MAX_ATTACK_HEALTH . " helsepoeng");
putlog("DF", " - Helse: Mistet " . game::format_number($ret['health_lost_p'] * 100, 3) . " % ({$ret['health_lost']}) og har nå%c4 " . game::format_number($ret['health_new_p'] * 100, 3) . " %");
putlog("DF", " - Energi: Mistet " . game::format_number($ret['energy_lost_p'] * 100, 3) . " % ({$ret['energy_lost']}) og har nå%c12 " . game::format_number($ret['energy_new_p'] * 100, 3) . " %");
if ($ret['protection_replaced']) {
putlog("DF", " - Beskyttelsen ble erstattet med " . $this->protection->data['name']);
} elseif ($ret['protection_lost_p'] == "") {
putlog("DF", " - Hadde ingen beskyttelse");
} else {
putlog("DF", " - Beskyttelse: Mistet " . game::format_number($ret['protection_lost_p'] * 100, 3) . " % og har nå " . game::format_number($ret['protection_new_p'] * 100, 3) . " %");
}
putlog("DF", " - Rankpoeng: {$up->data['up_name']} fikk " . game::format_num($ret['rankpoeng']) . " rankpoeng (offeret mistet " . game::format_num($ret['rankpoeng_lost']) . ") " . $up->generate_minside_url());
if (count($ret['vitner']) == 0) {
putlog("DF", " - Ingen vitner");
} else {
foreach ($ret['vitner'] as $vitne) {
putlog("DF", " - Vitne: {$vitne['up']->data['up_name']} (" . ($vitne['visible'] ? 'ble oppdaget' : 'ble IKKE oppdaget') . ') ' . $vitne['up']->generate_minside_url());
}
}
putlog("DF", " - Penger fra hånda: " . game::format_cash($ret['penger']));
putlog("DF", " - Penger fra hitlist: " . game::format_cash($ret['hitlist']));
}
}
示例4: page_default
/**
* Standard side - viser status for spilleren
*/
protected static function page_default()
{
// kan ikke se?
if (!page_min_side::$pstats) {
echo '
<p class="c">Du har ikke tilgang til å se denne siden.</p>';
return;
}
global $_game;
// rank
$rank_need = 0;
if (page_min_side::$active_player->rank['need_points'] == 0) {
$rank_prosent = 100;
} else {
$rank_prosent = (page_min_side::$active_player->data['up_points'] - page_min_side::$active_player->rank['points']) / page_min_side::$active_player->rank['need_points'] * 100;
$rank_need = page_min_side::$active_player->rank['need_points'] - page_min_side::$active_player->data['up_points'] + page_min_side::$active_player->rank['points'];
}
$rank_prosent_top = page_min_side::$active_player->data['up_points'] / game::$ranks['items_number'][count(game::$ranks['items_number'])]['points'] * 100;
// hvor mange rankprosent må vi til for å ta igjen neste person?
$result = \Kofradia\DB::get()->query("SELECT up_points FROM users_players WHERE up_access_level != 0 AND up_access_level < {$_game['access_noplay']} AND up_points > " . page_min_side::$active_player->data['up_points'] . " ORDER BY up_points LIMIT 1");
$rank_user_next = false;
$rank_user_prevnext = false;
if ($next = $result->fetch()) {
$points = $next['up_points'];
$to = game::rank_info($points);
if ($to['need_points'] == 0) {
// totalt for spillet
$percent = game::format_rank($points, "all");
$rank_user_next = '<p>Du må oppnå ' . game::format_num($points) . ' poeng (' . $percent . ' rank for spillet totalt) for å ta igjen neste rangert spiller.</p>';
// antall prosent vi trenger
$rank_user_next .= '<p>Du trenger ' . game::format_num($points - page_min_side::$active_player->data['up_points']) . ' poeng (' . game::format_rank($points - page_min_side::$active_player->data['up_points'], $to) . ' rank).</p>';
} else {
$percent = game::format_number(($points - $to['points']) / $to['need_points'] * 100, 3);
// samme rank?
$same = page_min_side::$active_player->rank['id'] == $to['id'];
$rank_user_next = '<p>Du må oppnå ' . game::format_num($points) . ' poeng (' . $percent . ' % ' . ($same ? 'på nåværende rank' : 'på ranken ' . $to['name']) . ') for å nå neste rangert spiller.</p>';
if ($same) {
$rank_user_next .= '<p>Du trenger ' . game::format_num($points - page_min_side::$active_player->data['up_points']) . ' poeng (' . game::format_rank($points - page_min_side::$active_player->data['up_points'], $to) . ' rank).</p>';
}
}
// finn ut hvor langt det er til forrige rankerte spiller
$result = \Kofradia\DB::get()->query("SELECT up_points FROM users_players WHERE up_access_level != 0 AND up_access_level < {$_game['access_noplay']} AND up_id != " . page_min_side::$active_player->id . " AND up_points <= " . page_min_side::$active_player->data['up_points'] . " ORDER BY up_points DESC LIMIT 1");
if ($row = $result->fetch()) {
$rank_user_prevnext = round((page_min_side::$active_player->data['up_points'] - $row['up_points']) / ($next['up_points'] - $row['up_points']) * 100, 4);
}
}
// finn ut tidspunkt for de forskjellige funksonene
$status = array("krim" => page_min_side::$active_player->status_kriminalitet(), "utpressing" => page_min_side::$active_player->status_utpressing(), "gta" => page_min_side::$active_player->status_gta(), "lotto" => page_min_side::$active_player->status_lotto());
// finn ut når vi kan gjøre forskjellige ting
$wait = array("kriminalitet" => $status['krim']['wait_time'], "utpressing" => $status['utpressing']['wait_time'], "biltyveri" => $status['gta']['wait_time'], "lotto" => $status['lotto']['wait_time'], "forum_topic" => 0, "forum_reply" => 0, "fengsel" => 0);
// forumene
$wait['forum_reply'] = max(0, page_min_side::$active_user->data['u_forum_reply_time'] + game::$settings['delay_forum_reply']['value'] - time());
$wait['forum_topic'] = max(0, page_min_side::$active_user->data['u_forum_topic_time'] + game::$settings['delay_forum_new']['value'] - time());
if (page_min_side::$active_player->data['up_weapon_id']) {
$wait['training'] = max(0, page_min_side::$active_player->data['up_weapon_training_next'] - time());
}
// for lav rank til å opprette forumtråder?
if (page_min_side::$active_player->rank['number'] < 4) {
$wait['forum_topic'] = -1;
}
// fengsel og bomberom
$wait['fengsel'] = max(0, page_min_side::$active_player->data['up_fengsel_time'] - time());
$wait['bomberom'] = max(0, page_min_side::$active_player->data['up_brom_expire'] - time());
$wait['lock'] = max($wait['fengsel'], $wait['bomberom']);
// sammendrag
$status = array(array("Kriminalitet", max($wait['kriminalitet'], $wait['lock']), "kriminalitet"), array("Utpressing", max($wait['utpressing'], $wait['lock']), "utpressing"), array("Biltyveri", max($wait['biltyveri'], $wait['lock']), "gta/biltyveri"), array("Lotto", max($wait['lotto'], $wait['lock']), "lotto"), array("Forumemne", $wait['forum_topic'], "forum/"), array("Forumsvar", $wait['forum_reply'], "forum/"), array("Fengsel", $wait['lock'], "fengsel"));
if (page_min_side::$active_player->data['up_weapon_id']) {
$status[] = array("Våpentrening", max($wait['training'], $wait['lock']), "angrip");
}
// javascript funksjoner for status
ess::$b->page->add_js_domready('
var min_side_data = ' . js_encode($status) . ';
var elm, c;
for (var i = 0; i < min_side_data.length; i++)
{
elm = $("min_side_"+i);
if (!elm) continue;
c = new Countdown($("min_side_"+i));
c.timesize = "partial",
c.complete = function()
{
this.element.set("text", "Klar!");
this.element.removeClass("status_venter").addClass("status_ny");
};
}');
// css
ess::$b->page->add_css('
.ms_space { margin-top: 2px }
.ms_space_bt { margin-bottom: 1em }
.status dd { text-align: right }
.status dd a { text-decoration: none; color: #CCFF00 }
a.status_ny { font-weight: bold }
a.status_klar:hover, a.status_ny:hover { color: #AAFF00; text-decoration: underline }
.status_venter { color: #888888 !important }
a.status_venter:hover { }
.split { height: 1px; background-color: #222222; overflow: hidden }');
//.........这里部分代码省略.........