示例#1
1
 public function index()
 {
     $request = RequestWrapper::$request;
     $target = $request->get('player');
     $target_id = $request->get('player_id');
     if ($target_id) {
         $target_player_obj = Player::find($target_id);
     } else {
         $target_player_obj = Player::findByName($target);
     }
     if ($target_player_obj === null) {
         $template = 'no-player.tpl';
         $viewed_name_for_title = null;
         $parts = array();
     } else {
         $attack_error = 'You must become a ninja first.';
         $clan = Clan::findByMember($target_player_obj);
         $combat_skills = null;
         $display_clan_options = false;
         $items = null;
         $same_clan = false;
         $self = false;
         $targeted_skills = null;
         $template = 'player.tpl';
         $viewed_name_for_title = $target_player_obj->name();
         $viewing_player_obj = Player::find(SessionFactory::getSession()->get('player_id'));
         $kills_today = query_item('SELECT sum(killpoints) FROM levelling_log WHERE _player_id = :player_id AND killsdate = CURRENT_DATE AND killpoints > 0', [':player_id' => $target_player_obj->id()]);
         $rank_spot = query_item('SELECT rank_id FROM rankings WHERE player_id = :player_id limit 1', [':player_id' => $target_player_obj->id()]);
         if ($viewing_player_obj !== null) {
             $viewers_clan = Clan::findByMember($viewing_player_obj);
             $self = $viewing_player_obj->id() === $target_player_obj->id();
             $params = ['required_turns' => 0, 'ignores_stealth' => true];
             $AttackLegal = new AttackLegal($viewing_player_obj, $target_player_obj, $params);
             $AttackLegal->check(false);
             $attack_error = $AttackLegal->getError();
             if (!$attack_error && !$self) {
                 // They're not dead or otherwise unattackable.
                 // Pull the items and some necessary data about them.
                 $inventory = new Inventory($viewing_player_obj);
                 $items = $inventory->counts();
                 $skillDAO = new SkillDAO();
                 if (!$viewing_player_obj->isAdmin()) {
                     $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');
                 }
             }
             if ($clan && $viewers_clan) {
                 $same_clan = $clan->id == $viewers_clan->id;
                 $display_clan_options = !$self && $same_clan && $viewing_player_obj->isClanLeader();
             }
         }
         $parts = ['viewing_player_obj' => $viewing_player_obj, 'target_player_obj' => $target_player_obj, 'combat_skills' => $combat_skills, 'targeted_skills' => $targeted_skills, 'self' => $self, 'rank_spot' => $rank_spot, 'kills_today' => $kills_today, 'status_list' => Player::getStatusList($target_player_obj->id()), 'clan' => $clan, 'items' => $items, 'account' => Account::findByChar($target_player_obj), 'same_clan' => $same_clan, 'display_clan_options' => $display_clan_options, 'attack_error' => $attack_error];
     }
     $parts['authenticated'] = SessionFactory::getSession()->get('authenticated', false);
     $title = 'Ninja' . ($viewed_name_for_title ? ": {$viewed_name_for_title}" : ' Profile');
     return new StreamedViewResponse($title, $template, $parts, ['quickstat' => 'player']);
 }
示例#2
0
 /**
  * Display the initial listing of skills for self-use
  *
  * @return Array
  */
 public function index()
 {
     $error = RequestWrapper::getPostOrGet('error');
     $skillsListObj = new Skill();
     $player = $this->player;
     $starting_turns = $player->turns;
     $starting_ki = $player->ki;
     $status_list = Player::getStatusList();
     $no_skills = true;
     $stealth = $skillsListObj->hasSkill('Stealth', $player);
     if ($stealth) {
         $no_skills = false;
     }
     $stealth_turn_cost = $skillsListObj->getTurnCost('Stealth');
     $unstealth_turn_cost = $skillsListObj->getTurnCost('Unstealth');
     $stalk = $skillsListObj->hasSkill('Stalk', $player);
     $stalk_turn_cost = $skillsListObj->getTurnCost('Stalk');
     $chi = $skillsListObj->hasSkill('Chi', $player);
     $speed = $skillsListObj->hasSkill('speed', $player);
     $hidden_resurrect = $skillsListObj->hasSkill('hidden resurrect', $player);
     $midnight_heal = $skillsListObj->hasSkill('midnight heal', $player);
     $kampo_turn_cost = $skillsListObj->getTurnCost('Kampo');
     $kampo = $skillsListObj->hasSkill('kampo', $player);
     $heal = $skillsListObj->hasSkill('heal', $player);
     $heal_turn_cost = $skillsListObj->getTurnCost('heal');
     $clone_kill = $skillsListObj->hasSkill('clone kill', $player);
     $clone_kill_turn_cost = $skillsListObj->getTurnCost('clone kill');
     $wrath = $skillsListObj->hasSkill('wrath', $player);
     $can_harmonize = $starting_ki;
     $parts = ['error' => $error, '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, 'stalk' => $stalk, 'stalk_turn_cost' => $stalk_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 new StreamedViewResponse('Your Skills', 'skills.tpl', $parts, ['quickstat' => 'player']);
 }
示例#3
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 = isset($npc_stats['name']) ? $npc_stats['name'] : ucfirst($victim);
     $status_effect = isset($npc_stats['status']) ? $npc_stats['status'] : null;
     $reward_item = isset($npc_stats['item']) && $npc_stats['item'] ? $npc_stats['item'] : null;
     $is_quick = (bool) ($npco->getSpeed() > $player->getSpeed());
     // Beyond basic speed and they see you coming, so show that message.
     $is_weaker = $npco->getStrength() * 3 < $player->getStrength();
     // Npc much weaker?
     $is_stronger = $npco->getStrength() > $player->getStrength() * 3;
     // Npc More than twice as strong?
     $image = isset($npc_stats['img']) ? $npc_stats['img'] : null;
     // Assume defeat...
     $victory = false;
     $received_gold = null;
     $received_items = null;
     $added_bounty = '';
     $is_rewarded = null;
     // Gets items or gold.
     $statuses = null;
     $status_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->getHealth() < $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->setGold($player->gold + $received_gold);
         $received_items = array();
         if ($kill_npc) {
             $victory = true;
             // Victory occurred, reward the poor sap.
             if ($npco->inventory()) {
                 $inventory = new Inventory($player);
                 foreach (array_keys($npco->inventory()) as $l_item) {
                     $item = Item::findByIdentity($l_item);
                     $received_items[] = $item->getName();
                     $inventory->add($item->identity(), 1);
                 }
             }
             // Add bounty where applicable for npcs.
             if ($npco->bountyMod() > 0 && $player->level > self::MIN_LEVEL_FOR_BOUNTY && $player->level <= self::MAX_LEVEL_FOR_BOUNTY) {
                 $added_bounty = Combat::runBountyExchange($player, $npco, $npco->bountyMod());
             }
         }
         $is_rewarded = (bool) $received_gold || (bool) count($received_items);
         if (isset($npc_stats['status']) && null !== $npc_stats['status']) {
             $player->addStatus($npc_stats['status']);
             // Get the statuses and status classes for display.
             $statuses = implode(', ', Player::getStatusList());
             $status_classes = implode(' ', Player::getStatusList());
         }
     }
     $player->save();
     return ['npc.abstract.tpl', ['victim' => $victim, 'display_name' => $display_name, 'attack_damage' => $npc_damage, 'status_effect' => $status_effect, 'display_statuses' => $statuses, 'display_statuses_classes' => $status_classes, 'received_gold' => $received_gold, 'received_display_items' => $received_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->hasTrait('villager'), 'race' => $npco->race(), 'is_weaker' => $is_weaker, 'is_stronger' => $is_stronger]];
 }
示例#4
0
 /**
  * Display the default stats page
  *
  * @param Container
  */
 public function index(Container $p_dependencies)
 {
     $request = RequestWrapper::$request;
     $char = $p_dependencies['current_player'];
     $parts = ['char' => $char, 'clan' => Clan::findByMember($char), 'status_list' => Player::getStatusList(), 'rank_display' => $this->getRank($char->id()), 'profile_max_length' => self::PROFILE_MAX_LENGTH, 'error' => $request->get('error'), 'successMessage' => '', 'profile_changed' => (bool) $request->get('profile_changed'), 'changed' => (bool) $request->get('changed')];
     return $this->render($parts);
 }