$playerinfo = $stmt->fetch(PDO::FETCH_ASSOC); $sql = "SELECT * FROM ::prefix::ships WHERE ship_id=:ship_id LIMIT 1"; $stmt = $pdo_db->prepare($sql); $stmt->bindParam(':ship_id', $ship_id); $stmt->execute(); $targetinfo = $stmt->fetch(PDO::FETCH_ASSOC); $playerscore = Tki\Score::updateScore($pdo_db, $playerinfo['ship_id'], $tkireg, $playerinfo); $targetscore = Tki\Score::updateScore($pdo_db, $targetinfo['ship_id'], $tkireg, $playerinfo); $playerscore = $playerscore * $playerscore; $targetscore = $targetscore * $targetscore; // Check to ensure target is in the same sector as player if ($targetinfo['sector'] != $playerinfo['sector'] || $targetinfo['on_planet'] == 'Y') { echo $langvars['l_att_notarg'] . '<br><br>'; } elseif ($playerinfo['turns'] < 1) { echo $langvars['l_att_noturn'] . '<br><br>'; } elseif (Tki\Team::sameTeam($playerinfo['team'], $targetinfo['team'])) { echo "<div style='color:#ff0;'>" . $langvars['l_team_noattack_members'] . "</div>\n"; } elseif ($_SESSION['in_combat'] !== null && $_SESSION['in_combat'] === true) { echo "<div style='color:#ff0;'>" . $langvars['l_team_already_combat'] . "</div>\n"; Tki\AdminLog::writeLog($pdo_db, 13371337, "{$playerinfo['ship_id']}|{$targetinfo['ship_id']}|Detected multi attack."); } else { // Set in combat flag $_SESSION['in_combat'] = (bool) true; // Determine percent chance of success in detecting target ship - based on player's sensors and opponent's cloak $success = (10 - $targetinfo['cloak'] + $playerinfo['sensors']) * 5; if ($success < 5) { $success = 5; } if ($success > 95) { $success = 95; }
// Database driven language entries $langvars = Tki\Translate::load($pdo_db, $lang, array('ship', 'planet', 'main', 'common', 'global_includes', 'global_funcs', 'footer', 'news')); echo "<h1>" . $title . "</h1>\n"; // PHP7 Null coalescing operator - if it is set, great, if not, set to null $ship_id = $ship_id ?? null; // Get playerinfo from database $sql = "SELECT team, ship_name, character_name, sector FROM ::prefix::ships WHERE email=:email LIMIT 1"; $stmt = $pdo_db->prepare($sql); $stmt->bindParam(':email', $_SESSION['username']); $stmt->execute(); $playerinfo = $stmt->fetch(PDO::FETCH_ASSOC); $sql = "SELECT team, ship_name, character_name, sector FROM ::prefix::ships WHERE ship_id=:ship_id"; $stmt = $pdo_db->prepare($sql); $stmt->bindParam(':ship_id', $ship_id); $stmt->execute(); $othership = $stmt->fetch(PDO::FETCH_ASSOC); if ($othership['sector'] != $playerinfo['sector']) { echo $langvars['l_ship_the'] . " <font color=white>" . $othership['ship_name'] . "</font> " . $langvars['l_ship_nolonger'] . " " . $playerinfo['sector'] . "<br>"; } else { $_SESSION['ship_selected'] = $ship_id; echo $langvars['l_ship_youc'] . " <font color=white>" . $othership['ship_name'] . "</font>, " . $langvars['l_ship_owned'] . " <font color=white>" . $othership['character_name'] . "</font>.<br><br>"; echo $langvars['l_ship_perform'] . "<br><br>"; echo "<a href=scan.php?ship_id={$ship_id}>" . $langvars['l_planet_scn_link'] . "</a><br>"; if (!Tki\Team::sameTeam($playerinfo['team'], $othership['team'])) { echo "<a href=attack.php?ship_id={$ship_id}>" . $langvars['l_planet_att_link'] . "</a><br>"; } echo "<a href=mailto.php?to={$ship_id}>" . $langvars['l_send_msg'] . "</a><br>"; } echo "<br>"; Tki\Text::gotomain($pdo_db, $lang); Tki\Footer::display($pdo_db, $lang, $tkireg, $template);