function render_recent_attackers() { $recent_attackers_section = ''; $recent_attackers = get_recent_attackers(); if (!empty($recent_attackers)) { $recent_attackers_section .= "<h3>You were recently attacked by</h3>\n\t\t\t<ul id='recent-attackers'>"; foreach ($recent_attackers as $l_attacker) { $status_class = ''; if ($l_attacker['health'] < 1) { $status_class = 'status-dead'; } $recent_attackers_section .= "<li class='recent-attacker {$status_class}'><a href='player.php?player_id={$l_attacker['send_from']}'>{$l_attacker['uname']}</a></li>"; } $recent_attackers_section .= '</ul>'; } return $recent_attackers_section; }
$match_string = in('enemy_match', null, 'no filter'); $add_enemy = in('add_enemy', null, 'toInt'); $remove_enemy = in('remove_enemy', null, 'toInt'); $enemy_limit = 20; $max_enemies = false; $enemy_list = null; if ($match_string) { $found_enemies = get_enemy_matches($match_string); } else { $found_enemies = null; } if (is_numeric($remove_enemy) && $remove_enemy != 0) { remove_enemy($remove_enemy); } if (is_numeric($add_enemy) && $add_enemy != 0) { add_enemy($add_enemy); } if (count($enemy_list) > $enemy_limit - 1) { $max_enemies = true; } $enemy_list = get_current_enemies(); $enemyCount = $enemy_list->rowCount(); $enemy_list = $enemy_list->fetchAll(); $recent_attackers = get_recent_attackers($char)->fetchAll(); // Add enemies at the bottom of the fight page. // Array that simulates database display information for switching out for an npc database solution. $npcs = array(array('name' => 'Peasant', 'identity' => 'peasant', 'image' => 'fighter.png'), array('name' => 'Thief', 'identity' => 'thief', 'image' => 'thief.png'), array('name' => 'Merchant', 'identity' => 'merchant', 'image' => 'merchant.png'), array('name' => "Guard", 'identity' => 'guard', 'image' => 'guard.png'), array('name' => 'Samurai', 'identity' => 'samurai', 'image' => 'samurai.png')); // Generic/abstracted npcs $other_npcs = NpcFactory::npcsData(); display_page('enemies.tpl', 'Fight', get_certain_vars(get_defined_vars(), array('char_name', 'npcs', 'other_npcs', 'char_info', 'found_enemies', 'active_ninjas', 'recent_attackers', 'enemy_list', 'peers')), array('quickstat' => false)); }