/**
  * Display the initial listing of skills for self-use
  *
  * @return Array
  */
 public function index()
 {
     $skillsListObj = new Skill();
     $player = $this->player;
     $starting_turns = $player->turns();
     $starting_ki = $player->ki();
     $status_list = get_status_list();
     $no_skills = true;
     $stealth = $skillsListObj->hasSkill('Stealth');
     if ($stealth) {
         $no_skills = false;
     }
     $stealth_turn_cost = $skillsListObj->getTurnCost('Stealth');
     $unstealth_turn_cost = $skillsListObj->getTurnCost('Unstealth');
     $chi = $skillsListObj->hasSkill('Chi');
     $speed = $skillsListObj->hasSkill('speed');
     $hidden_resurrect = $skillsListObj->hasSkill('hidden resurrect');
     $midnight_heal = $skillsListObj->hasSkill('midnight heal');
     $kampo_turn_cost = $skillsListObj->getTurnCost('Kampo');
     $kampo = $skillsListObj->hasSkill('kampo');
     $heal = $skillsListObj->hasSkill('heal');
     $heal_turn_cost = $skillsListObj->getTurnCost('heal');
     $clone_kill = $skillsListObj->hasSkill('clone kill');
     $clone_kill_turn_cost = $skillsListObj->getTurnCost('clone kill');
     $wrath = $skillsListObj->hasSkill('wrath');
     $can_harmonize = $starting_ki;
     $parts = ['status_list' => $status_list, 'player' => $player, 'no_skills' => $no_skills, 'starting_turns' => $starting_turns, 'starting_ki' => $starting_ki, 'stealth' => $stealth, 'stealth_turn_cost' => $stealth_turn_cost, 'unstealth_turn_cost' => $unstealth_turn_cost, 'chi' => $chi, 'speed' => $speed, 'hidden_resurrect' => $hidden_resurrect, 'midnight_heal' => $midnight_heal, 'kampo_turn_cost' => $kampo_turn_cost, 'kampo' => $kampo, 'heal' => $heal, 'heal_turn_cost' => $heal_turn_cost, 'clone_kill' => $clone_kill, 'clone_kill_turn_cost' => $clone_kill_turn_cost, 'wrath' => $wrath, 'can_harmonize' => $can_harmonize];
     return ['title' => 'Your Skills', 'template' => 'skills.tpl', 'parts' => $parts, 'options' => ['quickstat' => 'player']];
 }
Beispiel #2
0
function render_status_section($target = null)
{
    $res = '';
    $statuses = get_status_list($target);
    if (!empty($statuses)) {
        $res .= "<span class='player-status ninja-notice " . implode(" ", $statuses) . "'>" . implode(", ", $statuses) . "</span>";
    }
    return $res;
}
Beispiel #3
0
/**
 * status_id=0 : 超级管理员
 * status_id=1 : 学校管理员
 * status_id=2 : 班级管理员
 * status_id=3 : 教师
 * status_id=4 : 家长
 */
function get_status($status_id)
{
    $statuss = get_status_list();
    foreach ($statuss as $k => $v) {
        if ($v["status_id"] == $status_id) {
            return $v["status_name"];
        }
    }
    return "未知";
}
Beispiel #4
0
    assign_query_info();
    $smarty->display('order_list.htm');
} else {
    if ($_REQUEST['act'] == 'order_query') {
        /* 检查权限 */
        admin_priv('order_view');
        /* 载入配送方式 */
        $smarty->assign('shipping_list', shipping_list());
        /* 载入支付方式 */
        $smarty->assign('pay_list', payment_list());
        /* 载入国家 */
        $smarty->assign('country_list', get_regions());
        /* 载入订单状态、付款状态、发货状态 */
        $smarty->assign('os_list', get_status_list('order'));
        $smarty->assign('ps_list', get_status_list('payment'));
        $smarty->assign('ss_list', get_status_list('shipping'));
        /* 模板赋值 */
        $smarty->assign('ur_here', $_LANG['03_order_query']);
        $smarty->assign('action_link', array('href' => 'order.php?act=list', 'text' => $_LANG['02_order_list']));
        /* 显示模板 */
        assign_query_info();
        $smarty->display('order_query.htm');
    } elseif ($_REQUEST['act'] == 'query') {
        /* 检查权限 */
        admin_priv('order_view');
        $order_list = order_list();
        $smarty->assign('order_list', $order_list['orders']);
        $smarty->assign('filter', $order_list['filter']);
        $smarty->assign('record_count', $order_list['record_count']);
        $smarty->assign('page_count', $order_list['page_count']);
        $sort_flag = sort_flag($order_list['filter']);
Beispiel #5
0
function add_data_to_player_row($player_data, $kill_password = true)
{
    if ($kill_password) {
        unset($player_data['pname']);
    }
    $player_data['max_health'] = max_health_by_level($player_data['level']);
    $player_data['hp_percent'] = min(100, round($player_data['health'] / $player_data['max_health'] * 100));
    $player_data['max_turns'] = 100;
    $player_data['turns_percent'] = min(100, round($player_data['turns'] / $player_data['max_turns'] * 100));
    $player_data['next_level'] = required_kills_to_level($player_data['level']);
    $player_data['exp_percent'] = min(100, round($player_data['kills'] / $player_data['next_level'] * 100));
    $player_data['status_list'] = implode(', ', get_status_list($player_data['player_id']));
    $player_data['hash'] = md5(implode($player_data));
    return $player_data;
}
 public function index()
 {
     $target = $player = first_value(in('ninja'), in('player'), in('find'), in('target'));
     $target_id = first_value(in('target_id'), in('player_id'), get_char_id($target));
     // Find target_id if possible.
     $target_player_obj = Player::find($target_id);
     $viewed_name_for_title = null;
     if ($target_player_obj !== null) {
         $viewed_name_for_title = $target_player_obj->name();
     }
     if ($target_player_obj === null) {
         $template = 'no-player.tpl';
         $parts = array();
     } else {
         $player_info = $target_player_obj->as_array();
         // Pull the info out of the object.
         if (!$player_info) {
             $template = 'no-player.tpl';
             $parts = array();
         } else {
             $viewing_player_obj = Player::find(self_char_id());
             $self = self_char_id() && self_char_id() == $player_info['player_id'];
             // Record whether this is a self-viewing.
             if ($viewing_player_obj !== null) {
                 $char_info = $viewing_player_obj->dataWithClan();
                 $char_id = $viewing_player_obj->id();
                 $username = $viewing_player_obj->name();
             } else {
                 $char_info = [];
             }
             $player = $target = $player_info['uname'];
             // reset the target and target_id vars.
             $target_id = $player_info['player_id'];
             // Get the player's kills for this date.
             $kills_today = query_item('select sum(killpoints) from levelling_log where _player_id = :player_id and killsdate = CURRENT_DATE and killpoints > 0', array(':player_id' => $target_id));
             $viewers_clan = $viewing_player_obj !== null ? ClanFactory::clanOfMember($viewing_player_obj) : null;
             // Attack Legal section
             $params = array('required_turns' => 0, 'ignores_stealth' => true);
             // 0 for unstealth.
             $attack_error = 'You must become a ninja first.';
             $attack_allowed = false;
             if (null !== $viewing_player_obj) {
                 $AttackLegal = new AttackLegal($viewing_player_obj, $target_player_obj, $params);
                 $attack_allowed = $AttackLegal->check(false);
                 $attack_error = $AttackLegal->getError();
             }
             $sel_rank_spot = "SELECT rank_id FROM rankings WHERE player_id = :char_id limit 1";
             $rank_spot = query_item($sel_rank_spot, array(':char_id' => $player_info['player_id']));
             // Display the player info.
             $status_list = get_status_list($player);
             $gurl = $gravatar_url = $target_player_obj->avatarUrl();
             if ($viewing_player_obj !== null && !$attack_error && !$self) {
                 // They're not dead or otherwise unattackable.
                 // Attack or Duel
                 $skillDAO = new SkillDAO();
                 $is_admin = false;
                 if ($viewing_player_obj) {
                     $is_admin = $viewing_player_obj->isAdmin();
                 }
                 if (!$is_admin) {
                     $combat_skills = $skillDAO->getSkillsByTypeAndClass($viewing_player_obj->_class_id, 'combat', $viewing_player_obj->level);
                     $targeted_skills = $skillDAO->getSkillsByTypeAndClass($viewing_player_obj->_class_id, 'targeted', $viewing_player_obj->level);
                 } else {
                     $combat_skills = $skillDAO->all('combat');
                     $targeted_skills = $skillDAO->all('targeted');
                 }
                 // Pull the items and some necessary data about them.
                 $items = inventory_counts($char_id);
                 $valid_items = rco($items);
                 // row count
             }
             // End of the there-was-no-attack-error section
             $set_bounty_section = '';
             $communication_section = '';
             $player_clan_section = '';
             $clan = ClanFactory::clanOfMember($player_info['player_id']);
             $same_clan = false;
             // Player clan and clan members
             if ($clan) {
                 $viewer_clan = $viewing_player_obj ? ClanFactory::clanOfMember($viewing_player_obj) : null;
                 $clan_id = $clan->getID();
                 $clan_name = $clan->getName();
                 if ($viewer_clan) {
                     $same_clan = $clan->getID() == $viewer_clan->getID();
                     $display_clan_options = $viewing_player_obj && !$self && $same_clan && $viewing_player_obj->isClanLeader();
                 } else {
                     $same_clan = $display_clan_options = false;
                 }
             }
             // Send the info to the template.
             $template = 'player.tpl';
             $parts = get_certain_vars(get_defined_vars(), array('char_info', 'viewing_player_obj', 'target_player_obj', 'combat_skills', 'targeted_skills', 'player_info', 'self', 'rank_spot', 'kills_today', 'gravatar_url', 'status_list', 'clan', 'items'));
         }
     }
     return ['template' => $template, 'title' => 'Ninja' . ($viewed_name_for_title ? ": {$viewed_name_for_title}" : ' Profile'), 'parts' => $parts, 'options' => ['quickstat' => 'player']];
 }
Beispiel #7
0
                     if ($attacker_level <= 50) {
                         // No bounty after this level?
                         $added_bounty = floor($attacker_level / 3 * $bounty_mod);
                         addBounty($char_id, $added_bounty);
                     }
                 }
                 // *** End of if > 5 ***
             }
         }
         $is_rewarded = (bool) $reward_gold || (bool) count($received_display_items);
         if ($status_effect) {
             // Only add the status effect
             $player->addStatus($status_effect);
             // Get the statuses and status classes for display.
             $display_statuses = implode(', ', get_status_list());
             $display_status_classes = implode(' ', get_status_list());
             // TODO: Take healthy out of the list since it's redundant.
             //$display_statuses = $display_statuses_classes = string_status($status_effect); // Get the string of a status.
         }
     }
     // Settings to display results.
     $npc_template = 'npc.abstract.tpl';
     $combat_data = array('victim' => $victim, 'display_name' => $display_name, 'attack_damage' => $npco->damage(), 'percent_damage' => $percent_damage, 'status_effect' => $status_effect, 'display_statuses' => $display_statuses, 'display_statuses_classes' => $display_statuses_classes, 'received_gold' => $received_gold, 'received_display_items' => $received_display_items, 'is_rewarded' => $is_rewarded, 'victory' => $victory, 'survive_fight' => $survive_fight, 'kill_npc' => $kill_npc, 'image_path' => $image_path, 'npc_stats' => $npc_stats, 'is_quick' => $is_quick, 'added_bounty' => $added_bounty, 'is_villager' => $is_villager, 'race' => $npco->race(), 'is_weaker' => $is_weaker, 'is_stronger' => $is_stronger);
     // ******************** START of logic for specific npcs ************************
 } else {
     if ($victim == 'peasant') {
         // *** PEASANT, was VILLAGER ***
         $villager_attack = rand(0, 10);
         // *** Villager Damage ***
         $just_villager = rand(0, 20);
         $added_bounty = 0;
Beispiel #8
0
 /**
  * Pull the data of the player obj as an array.
  *
  * @note
  * This function lazy loads the data only once per instance
  */
 public function data($specific = null)
 {
     if (!$this->data) {
         $this->data = $this->as_array();
         $this->data['next_level'] = $this->killsRequiredForNextLevel();
         $this->data['max_health'] = $this->getMaxHealth();
         $this->data['hp_percent'] = $this->health_percent();
         $this->data['max_turns'] = 100;
         $this->data['turns_percent'] = min(100, round($this->data['turns'] / $this->data['max_turns'] * 100));
         $this->data['exp_percent'] = min(100, round($this->data['kills'] / $this->data['next_level'] * 100));
         $this->data['status_list'] = implode(', ', get_status_list($this->id()));
         $this->data['hash'] = md5(implode($this->data));
         unset($this->data['pname']);
     }
     if ($specific) {
         return $this->data[$specific];
     } else {
         return $this->data;
     }
 }
Beispiel #9
0
    	}*/
    $changed = PlayerDAO::saveDetails($char);
    redirect('/stats.php?changed=' . (int) $changed . ($profile_changed ? '&profile_changed=1' : ''));
}
/*
if(false && DEBUG){
	$description = 'This is a description here and all';
	$goals = 'Kill ninja of the ramen clan';
	$beliefs = 'I believe in a one true ninja god';
	$instincts = 'When I hear whistling, I duck';
	$traits = 'Hardy, nervous, meaty, silent';
}
*/
$player = self_info();
//$player['created_date']=$player['created_date']? date("c", strtotime($player['created_date'])) : null;
$class_theme = class_theme($char->class_identity());
$level_category = level_category($player['level']);
$status_list = get_status_list();
$gravatar_url = generate_gravatar_url($player['player_id']);
$gurl = $gravatar_url;
$rank_display = get_rank($char_id);
// rank display.
$profile_editable = $player['messages'];
$parts = get_certain_vars(get_defined_vars(), ['player', 'level_category', 'status_list', 'description', 'goals', 'beliefs', 'instincts', 'traits', 'dev', 'changed']);
// Set the parts array's player clan if any is found.
if ($parts['player_clan'] = get_clan_by_player_id($char_id)) {
    // Set the char clan name and id for later usage.
    $parts['clan_name'] = $parts['player_clan']->getName();
    $parts['clan_id'] = $parts['player_clan']->getID();
}
display_page('stats.tpl', 'Ninja Stats', $parts, array('quickstat' => 'player'));
Beispiel #10
0
function get_json_str()
{
    $saved_status_names = get_saved_status_names();
    $all_status_names = get_status_list();
    return get_html_str($saved_status_names, $all_status_names);
}
Beispiel #11
0
 /**
  * Display the default stats page
  */
 public function index()
 {
     $char = new Player(self_char_id());
     $parts = ['char' => $char, 'clan' => ClanFactory::clanOfMember($char), 'status_list' => get_status_list(), 'rank_display' => $this->getRank($char->id()), 'profile_max_length' => self::PROFILE_MAX_LENGTH, 'error' => in('error'), 'successMessage' => '', 'profile_changed' => (bool) in('profile_changed'), 'changed' => (bool) in('changed')];
     return $this->render($parts);
 }
Beispiel #12
0
 /**
  * Handle Standard Abstract Npcs
  *
  * @param String $victim
  * @param Player $player
  * @param Array $npcs
  * @return array [$npc_template, $combat_data]
  */
 private function attackAbstractNpc($victim, Player $player, $npcs)
 {
     $npc_stats = $npcs[$victim];
     // Pull an npcs individual stats with generic fallbacks.
     $npco = new Npc($npc_stats);
     // Construct the npc object.
     $display_name = first_value(isset($npc_stats['name']) ? $npc_stats['name'] : null, ucfirst($victim));
     $status_effect = isset($npc_stats['status']) ? $npc_stats['status'] : null;
     // TODO: Calculate and display damage verbs
     $reward_item = isset($npc_stats['item']) && $npc_stats['item'] ? $npc_stats['item'] : null;
     $is_quick = (bool) ($npco->speed() > $player->speed());
     // Beyond basic speed and they see you coming, so show that message.
     $bounty_mod = isset($npc_stats['bounty']) ? $npc_stats['bounty'] : null;
     $is_weaker = $npco->strength() * 3 < $player->strength();
     // Npc much weaker?
     $is_stronger = $npco->strength() > $player->strength() * 3;
     // Npc More than twice as strong?
     $image = isset($npc_stats['img']) ? $npc_stats['img'] : null;
     // Assume defeat...
     $victory = false;
     $received_gold = null;
     $received_display_items = null;
     $added_bounty = null;
     $is_rewarded = null;
     // Gets items or gold.
     $display_statuses = $display_statuses_classes = null;
     $image_path = null;
     // If the image exists, set the path to it for use on the page.
     if ($image && file_exists(SERVER_ROOT . 'www/images/characters/' . $image)) {
         $image_path = IMAGE_ROOT . 'characters/' . $image;
     }
     // ******* FIGHT Logic ***********
     $npc_damage = $npco->damage();
     $survive_fight = $player->harm($npc_damage);
     $kill_npc = $npco->health() < $player->damage();
     if ($survive_fight > 0) {
         // The ninja survived, they get any gold the npc has.
         $received_gold = $this->calcReceivedGold($npco, (bool) $reward_item);
         $player->set_gold($player->gold() + $received_gold);
         $received_display_items = array();
         if ($kill_npc) {
             $victory = true;
             // Victory occurred, reward the poor sap.
             if ($npco->inventory()) {
                 foreach (array_keys($npco->inventory()) as $l_item) {
                     $item_info = item_info_from_identity($l_item);
                     $received_display_items[] = $item_info['item_display_name'];
                     add_item($player->id(), $item_info['item_internal_name'], 1);
                 }
             }
             // Add bounty where applicable.
             if ((bool) $bounty_mod && $player->level > self::MIN_LEVEL_FOR_BOUNTY && $player->level <= self::MAX_LEVEL_FOR_BOUNTY) {
                 $added_bounty = floor($player->level / 3 * $bounty_mod);
                 $player->set_bounty($player->bounty() + $added_bounty);
             }
         }
         $is_rewarded = (bool) $received_gold || (bool) count($received_display_items);
         if (isset($npc_stats['status']) && null !== $npc_stats['status']) {
             $player->addStatus($npc_stats['status']);
             // Get the statuses and status classes for display.
             $display_statuses = implode(', ', get_status_list());
             $display_statuses_classes = implode(' ', get_status_list());
             // TODO: Take healthy out of the list since it's redundant.
         }
     }
     $player->save();
     return ['npc.abstract.tpl', ['victim' => $victim, 'display_name' => $display_name, 'attack_damage' => $npc_damage, 'status_effect' => $status_effect, 'display_statuses' => $display_statuses, 'display_statuses_classes' => $display_statuses_classes, 'received_gold' => $received_gold, 'received_display_items' => $received_display_items, 'is_rewarded' => $is_rewarded, 'victory' => $victory, 'survive_fight' => $survive_fight, 'kill_npc' => $kill_npc, 'image_path' => $image_path, 'npc_stats' => $npc_stats, 'is_quick' => $is_quick, 'added_bounty' => $added_bounty, 'is_villager' => $npco->has_trait('villager'), 'race' => $npco->race(), 'is_weaker' => $is_weaker, 'is_stronger' => $is_stronger]];
 }
Beispiel #13
0
     send_message($char_id, $target_id, $message);
     // "message sent" notice will be displayed by the template itself.
 }
 // Get the player's kills for this date.
 $kills_today = query_item('select sum(killpoints) from levelling_log where _player_id = :player_id and killsdate = CURRENT_DATE and killpoints > 0', array(':player_id' => $target_id));
 $viewers_clan = $viewing_player_obj instanceof Player && $viewing_player_obj->vo ? get_clan_by_player_id($viewing_player_obj->vo->player_id) : null;
 // Attack Legal section
 $params = array('required_turns' => 0, 'ignores_stealth' => true);
 // 0 for unstealth.
 $AttackLegal = new AttackLegal($username, $target, $params);
 $attack_allowed = $AttackLegal->check(false);
 $attack_error = $AttackLegal->getError();
 $sel_rank_spot = "SELECT rank_id FROM rankings WHERE player_id = :char_id limit 1";
 $rank_spot = query_item($sel_rank_spot, array(':char_id' => $player_info['player_id']));
 // Display the player info.
 $status_list = get_status_list($player);
 $level_category = level_category($player_info['level']);
 $gurl = $gravatar_url = generate_gravatar_url($target_player_obj);
 if ($char_id && !$attack_error && !$self) {
     // They're not dead or otherwise unattackable.
     // Attack or Duel
     $skillDAO = new SkillDAO();
     $combat_skills = $skillDAO->getSkillsByTypeAndClass($viewing_player_obj->vo->_class_id, 'combat', $viewing_player_obj->vo->level)->fetchAll();
     $targeted_skills = $skillDAO->getSkillsByTypeAndClass($viewing_player_obj->vo->_class_id, 'targeted', $viewing_player_obj->vo->level)->fetchAll();
     // *** todo When Smarty3 is released, remove fetch all and change template to new foreach-as syntax ***
     // Check all the combat toggles to see if they should be checked on the profile page.
     foreach ($combat_skills as &$skill) {
         $skill['checked'] = 0;
         if (isset($combat_toggles[$skill['skill_internal_name']]) && $combat_toggles[$skill['skill_internal_name']]) {
             $skill['checked'] = 1;
             // Save the setting associatively back to the original array.