示例#1
0
function getResearchProduction(&$objUser)
{
    $production = array();
    $arrBuilds = $objUser->get_builds();
    $iLand = $arrBuilds[LAND];
    $iLabs = $arrBuilds[LABS];
    $research = 1;
    $raw = $iLabs * $research;
    // Research produced (incl. >30% penalty)
    $labs_percentage = floor($iLabs / $iLand * 100);
    $research = 1 - max(($labs_percentage - 30) / 200, 0);
    $labs_produce = floor($iLabs * $research);
    // Research Bonus = 25%                    Age 9, September 25, 2007, Martel
    // New code                                         January 09, 2008, Martel
    $arrResearch = getResearchBonuses($objUser->get_alliance());
    $research_bonus = round($raw * $arrResearch['research']);
    // War Penalty on Resarch
    $iHours = $objUser->get_user_info(HOURS);
    include_once "inc/functions/war.php";
    if (war_target($objUser->get_stat(ALLIANCE)) != 0 && $iHours > PROTECTION_HOURS) {
        $war_loss = round($labs_produce * 0.5);
    } else {
        $war_loss = 0;
    }
    $total = $labs_produce + $research_bonus - $war_loss;
    // research penalty (>30% labs)
    $penalty = floor($iLabs - $labs_produce);
    $production['per_each'] = $research;
    $production['raw'] = $raw;
    $production['research_bonus'] = $research_bonus;
    $production['penalty'] = $penalty;
    $production['war_loss'] = $war_loss;
    $production['total'] = $total;
    return $production;
}
示例#2
0
function doAttack(&$objSrcUser, &$objTrgUser, $arrSentArmy)
{
    $srcKd = $objSrcUser->get_stat(KINGDOM);
    $trgKd = $objTrgUser->get_stat(KINGDOM);
    $arrTrgBuilds = $objTrgUser->get_builds();
    $iSrcLand = $objSrcUser->get_build(LAND);
    $strSrcRace = $objSrcUser->get_stat(RACE);
    $arrTrgArmys = $objTrgUser->get_armys();
    $arrTrgMilRet = $objTrgUser->get_milreturns();
    //==========================================================================
    // Blasphemy Crusade Attack: Destroy T/M Buildings and gain Fame
    //==========================================================================
    $destroyed = 0.04;
    $modifier = war_alli($srcKd, $trgKd);
    if ($modifier == 2) {
        $destroyed *= 1.5;
    } elseif ($modifier == 0 && war_target($trgKd) != 0) {
        $destroyed *= 0.95;
    }
    // Demolish x % Guilds
    $iDamaged_Guilds = $arrTrgBuilds[GUILDS];
    if ($iDamaged_Guilds > $arrTrgBuilds[LAND] * $destroyed) {
        $iDamaged_Guilds = round($arrTrgBuilds[LAND] * $destroyed);
    }
    // Demolish x % Academies
    $iDamaged_Academies = $arrTrgBuilds[ACADEMIES];
    if ($iDamaged_Academies > $arrTrgBuilds[LAND] * $destroyed) {
        $iDamaged_Academies = round($arrTrgBuilds[LAND] * $destroyed);
    }
    // Demolish x % Hideouts
    $iDamaged_Hideouts = $arrTrgBuilds[HIDEOUTS];
    if ($iDamaged_Hideouts > $arrTrgBuilds[LAND] * $destroyed) {
        $iDamaged_Hideouts = round($arrTrgBuilds[LAND] * $destroyed);
    }
    // Kill x % Thieves
    $iThieves_killed = round(($arrTrgArmys[UNIT5] - ($arrTrgMilRet[UNIT5_T1] + $arrTrgMilRet[UNIT5_T2] + $arrTrgMilRet[UNIT5_T3] + $arrTrgMilRet[UNIT5_T4])) * ($destroyed * 1.25));
    // Total # Buildings destroyed (to calc fame)
    $iDamaged_Total = $iDamaged_Academies + $iDamaged_Guilds + $iDamaged_Hideouts;
    // Ravens do 1/3 Damage
    if ($strSrcRace == "Raven") {
        $iThieves_killed = round(0.333 * $iThieves_killed);
        $iDamaged_Total = round(0.333 * $iDamaged_Total);
        $iDamaged_Academies = round(0.333 * $iDamaged_Academies);
        $iDamaged_Guilds = round(0.333 * $iDamaged_Guilds);
        $iDamaged_Hideouts = round(0.333 * $iDamaged_Hideouts);
    }
    $arrBuilds = array(GUILDS => $arrTrgBuilds[GUILDS] - $iDamaged_Guilds, HIDEOUTS => $arrTrgBuilds[HIDEOUTS] - $iDamaged_Hideouts, ACADEMIES => $arrTrgBuilds[ACADEMIES] - $iDamaged_Academies, LAND => $arrTrgBuilds[LAND] - $iDamaged_Total, LAND_T2 => $arrTrgBuilds[LAND_T2] + $iDamaged_Total);
    // Save new stats to DB
    $objTrgUser->set_builds($arrBuilds);
    $objTrgUser->set_army(UNIT5, $arrTrgArmys[UNIT5] - $iThieves_killed);
    //==========================================================================
    // Return time
    //==========================================================================
    $wait = 6;
    if ($strSrcRace == "Raven") {
        $wait = 1;
    } elseif ($strSrcRace == "Mori Hai" || $strSrcRace == "Dragon") {
        $wait = 5;
    } elseif ($strSrcRace == "Viking") {
        $wait = 4;
    }
    $objSrcUser->set_user_info(NEXT_ATTACK, $wait);
    //==========================================================================
    // Calculate Fame Gains
    //==========================================================================
    $fame_win = 0;
    // Fame only if target and source is in war
    if ($modifier == 2) {
        $ratio = min(1, $arrTrgBuilds[LAND] / $iSrcLand);
        $fame_win = round($ratio * $iDamaged_Total);
        // fame bonus from being in war
        $fame_win *= 1.2;
    }
    // Cannot take more fame than what the target has
    $fame_win = round($fame_win);
    $target_fame = $objTrgUser->get_stat(FAME);
    if ($fame_win > $target_fame) {
        $fame_win = $target_fame;
    }
    $fame1 = $objSrcUser->get_stat(FAME) + $fame_win;
    $fame2 = $target_fame - $fame_win;
    $objSrcUser->set_stat(FAME, $fame1);
    $objTrgUser->set_stat(FAME, $fame2);
    //==========================================================================
    $arrResults['gained_fame'] = $fame_win;
    $arrResults['killed_thieves'] = $iThieves_killed;
    $arrResults['damaged_academies'] = $iDamaged_Academies;
    $arrResults['damaged_guilds'] = $iDamaged_Guilds;
    $arrResults['damaged_hideouts'] = $iDamaged_Hideouts;
    $arrResults['damaged_total'] = $iDamaged_Total;
    return $arrResults;
}
示例#3
0
function doAttack(&$objSrcUser, &$objTrgUser, $arrSentArmy)
{
    $srcId = $objSrcUser->get_userid();
    $trgId = $objTrgUser->get_userid();
    $srcKd = $objSrcUser->get_stat(KINGDOM);
    $trgKd = $objTrgUser->get_stat(KINGDOM);
    $arrTrgBuilds = $objTrgUser->get_builds();
    $iSrcLand = $objSrcUser->get_build(LAND);
    //==========================================================================
    // Standard Attack: Acres and Fame
    //==========================================================================
    $gains = pow($arrTrgBuilds[LAND] / $iSrcLand, 2) + $arrTrgBuilds[LAND] / ($iSrcLand * 3);
    $gains = min($gains, 1);
    $standard_gains = 0.115 * $gains;
    // Oleg Hai bonus
    $strSrcRace = $objSrcUser->get_stat(RACE);
    if ($strSrcRace == "Oleg Hai") {
        $standard_gains *= 1.3;
    }
    if ($standard_gains * $arrTrgBuilds[LAND] > $iSrcLand * 1.3 * $standard_gains) {
        $standard_gains *= $iSrcLand * 1.3 / $arrTrgBuilds[LAND];
    }
    if ($arrTrgBuilds[LAND] > $iSrcLand * 3) {
        $standard_gains /= 2;
    }
    //==========================================================================
    // War effects on gains
    //==========================================================================
    include_once "inc/functions/war.php";
    $modifier = war_alli($srcKd, $trgKd);
    if ($modifier == 2) {
        $standard_gains *= 1.2;
    }
    $target = war_target($trgKd);
    if ($target != 0 && $modifier == 0) {
        $standard_gains *= 0.95;
    }
    //==========================================================================
    // Spell effects on gains
    //==========================================================================
    if ($objTrgUser->get_spell(FOREST) > 0) {
        $standard_gains *= 0.8;
    }
    if ($objSrcUser->get_spell(MORTALITY) > 0) {
        $standard_gains += 0.01;
    }
    //==========================================================================
    // Bottom feed penalty on gains
    //==========================================================================
    if ($arrTrgBuilds[LAND] / $iSrcLand < 0.8 && $arrTrgBuilds[LAND] < 1500) {
        $bottom_feeder_difference = $arrTrgBuilds[LAND] / $iSrcLand;
        $bottom_feeder_penalty = (0.8 - $bottom_feeder_difference) / 10;
        $standard_gains -= 5 * $bottom_feeder_penalty;
    } elseif ($arrTrgBuilds[LAND] / $iSrcLand < 0.8 && $arrTrgBuilds[LAND] > 1499) {
        $bottom_feeder_difference = $arrTrgBuilds[LAND] / $iSrcLand;
        $bottom_feeder_penalty = (0.85 - $bottom_feeder_difference) / 10;
        $standard_gains -= 5 * $bottom_feeder_penalty;
    }
    //==========================================================================
    // Minimum Gains limit
    //==========================================================================
    if ($standard_gains < 0.01) {
        $standard_gains = 0.01;
    }
    //==========================================================================
    // Calculate Acre Gains
    //==========================================================================
    include_once 'inc/functions/build.php';
    $arrBuildVars = getBuildingVariables($objTrgUser->get_stat(RACE));
    $arrBuildVars = $arrBuildVars['variables'];
    $max_build = $objTrgUser->get_number_build_types();
    $total_grab = 0;
    // Built
    for ($i = 1; $i <= $max_build; $i++) {
        $strVar = trim($arrBuildVars[$i]);
        $acres_won[$strVar] = round($arrTrgBuilds[$strVar] * $standard_gains);
        $buildings = $objTrgUser->get_build($strVar);
        $land = $objTrgUser->get_build(LAND);
        $arrBuilds = array($strVar => $buildings - $acres_won[$strVar], LAND => $land - $acres_won[$strVar]);
        $objTrgUser->set_builds($arrBuilds);
        $total_grab += $acres_won[$strVar];
    }
    // 1 hour
    for ($i = 1; $i <= $max_build; $i++) {
        $strVar = trim($arrBuildVars[$i]);
        $strVar = $strVar . "_t1";
        $acres_won[$strVar] = round($arrTrgBuilds[$strVar] * $standard_gains);
        $buildings = $objTrgUser->get_build($strVar);
        $land = $objTrgUser->get_build(LAND);
        $arrBuilds = array($strVar => $buildings - $acres_won[$strVar], LAND => $land - $acres_won[$strVar]);
        $objTrgUser->set_builds($arrBuilds);
        $total_grab += $acres_won[$strVar];
    }
    // 2 hours
    for ($i = 1; $i <= $max_build; $i++) {
        $strVar = trim($arrBuildVars[$i]);
        $strVar = $strVar . "_t2";
        $acres_won[$strVar] = round($arrTrgBuilds[$strVar] * $standard_gains);
        $buildings = $objTrgUser->get_build($strVar);
        $land = $objTrgUser->get_build(LAND);
        $arrBuilds = array($strVar => $buildings - $acres_won[$strVar], LAND => $land - $acres_won[$strVar]);
        $objTrgUser->set_builds($arrBuilds);
        $total_grab += $acres_won[$strVar];
    }
    // 3 hours
    for ($i = 1; $i <= $max_build; $i++) {
        $strVar = trim($arrBuildVars[$i]);
        $strVar = $strVar . "_t3";
        $acres_won[$strVar] = round($arrTrgBuilds[$strVar] * $standard_gains);
        $buildings = $objTrgUser->get_build($strVar);
        $land = $objTrgUser->get_build(LAND);
        $arrBuilds = array($strVar => $buildings - $acres_won[$strVar], LAND => $land - $acres_won[$strVar]);
        $objTrgUser->set_builds($arrBuilds);
        $total_grab += $acres_won[$strVar];
    }
    // 4 hours
    for ($i = 1; $i <= $max_build; $i++) {
        $strVar = trim($arrBuildVars[$i]);
        $strVar = $strVar . "_t4";
        $acres_won[$strVar] = round($arrTrgBuilds[$strVar] * $standard_gains);
        $buildings = $objTrgUser->get_build($strVar);
        $land = $objTrgUser->get_build(LAND);
        $arrBuilds = array($strVar => $buildings - $acres_won[$strVar], LAND => $land - $acres_won[$strVar]);
        $objTrgUser->set_builds($arrBuilds);
        $total_grab += $acres_won[$strVar];
    }
    // Explored
    $explore_gains = 0.2;
    $acres_explored = round($total_grab * $explore_gains);
    $land = $objSrcUser->get_build(LAND);
    $objSrcUser->set_build(LAND, $land + $acres_explored);
    //==========================================================================
    // Record
    //==========================================================================
    $fetch_record = mysql_query("Select * from records where id = 1");
    $fetch_record = @mysql_fetch_array($fetch_record);
    if ($total_grab > $fetch_record['grab']) {
        $id = $objSrcUser->get_userid();
        $update = mysql_query("Update records set grab = {$total_grab}, grab_id = {$id} where id = 1");
    }
    //==========================================================================
    // Return time
    //==========================================================================
    $wait = 4;
    // 4 hour attack time
    if ($strSrcRace == "Raven") {
        $wait = 1;
    } elseif ($strSrcRace == "Mori Hai" || $strSrcRace == "Dragon") {
        $wait = 3;
    }
    $landtime = 'land_t' . $wait;
    $objSrcUser->set_user_info(NEXT_ATTACK, $wait);
    //==========================================================================
    // Add land to incoming
    //==========================================================================
    if ($total_grab > 0) {
        $old_land = $objSrcUser->get_build($landtime);
        $objSrcUser->set_build($landtime, $total_grab + $old_land);
    }
    //==========================================================================
    // Calculate Fame Gains
    //==========================================================================
    $fame_win = max(0, $total_grab * 2);
    // War effects
    include_once 'inc/functions/war.php';
    $objSrcAlliance = $objSrcUser->get_alliance();
    if (checkWarBetween($objSrcAlliance, $trgKd)) {
        // Update land counter in new war system           March 06, 2008 Martel
        $iNeeded = $objSrcAlliance->get_war('land_needed');
        $objSrcAlliance->set_war('land_needed', max(0, $iNeeded - $total_grab));
        // War effects on fame
        $fame_win *= 1.2;
    }
    // Cannot take more fame than what the target has
    $fame_win = round($fame_win);
    $target_fame = $objTrgUser->get_stat(FAME);
    if ($fame_win > $target_fame) {
        $fame_win = $target_fame;
    }
    $fame1 = $objSrcUser->get_stat(FAME) + $fame_win;
    $fame2 = $target_fame - $fame_win;
    $objSrcUser->set_stat(FAME, $fame1);
    $objTrgUser->set_stat(FAME, $fame2);
    //==========================================================================
    $arrResults['gained_acres'] = $total_grab;
    $arrResults['explored_acres'] = $acres_explored;
    $arrResults['gained_fame'] = $fame_win;
    return $arrResults;
}
示例#4
0
function call_mergers_text()
{
    global $userid, $task, $mergerid, $checker, $listtribeid, $changedname, $declinereason, $local_stats, $tool;
    include_once 'inc/functions/resort_tools.php';
    // we're abstracting the actual moving out to there
    include_once 'inc/staff/move.inc.php';
    //if (! user_has_access($tool))
    //{
    //    echo "Sorry, this page is restricted to ORKFiA Staff";
    //    include_game_down();
    //    exit;
    //}
    check_access($tool);
    $orkTime = date('YmdHis');
    echo "<h2>Select task:</h2><br />|  <a href='main.php?cat=game&page=resort_tools&tool=mergers&task=pending'>View Pending Mergers</a>  |  <a href='main.php?cat=game&page=resort_tools&tool=mergers&task=done'>View Done Mergers</a>  |  <a href='main.php?cat=game&page=resort_tools&tool=mergers&task=rejected'>View Declined Mergers</a>  |  <a href='main.php?cat=game&page=resort_tools&tool=mergers&task=requested'>View Requested Mergers</a>  |<br /><br />";
    if ($task == "changename") {
        // loads a form where you can change the requested name of a tribe
        $seek = mysql_query("SELECT newname FROM mergers WHERE id = {$mergerid}");
        $seek = mysql_fetch_array($seek);
        echo "<form method=\"post\" action=\"main.php?cat=game&page=resort_tools&tool=mergers&task=changed&mergerid={$mergerid}\">";
        echo "<br /><br /><table border=0 cellspacing=0 cellpadding=0 class='small'>";
        echo "<tr class='header'><th colspan=2> Change Requested Name </th></tr>";
        echo "<tr class='subheader'><th> Current Requested Name </th><td> New Name </td></tr>";
        echo "<tr class='data'><th> {$seek['newname']} </th><td> <input type='text' name='changedname' maxLength='30'></td> </tr>";
        echo "<tr class='data'><td colspan='2'><input type=submit value='Change requested name'></td></tr>";
        echo "</table>";
        echo "</form>";
    }
    if ($task == "changed") {
        // the queries part for changing the requested name of a tribe
        //check if someone else already has that name first
        $changedname = quote_smart(strip_tags(trim($changedname)));
        $check = mysql_query("SELECT * FROM stats WHERE tribe = {$changedname} AND id != {$mergerid}");
        if (mysql_num_rows($check) != 0) {
            echo "<br /><br />Some tribe is already using that name<br /><br />";
        } else {
            $update = mysql_query("UPDATE mergers SET newname = {$changedname} WHERE id = {$mergerid}");
            echo "<br /><br />The Requested tribe name is changed<br /><br />";
            $task = "pending";
        }
    }
    if ($task == "decline") {
        // loads a form where you can give a reason for not merging a tribe
        echo "<form method=\"post\" action=\"main.php?cat=game&page=resort_tools&tool=mergers&task=delete&mergerid={$mergerid}\">";
        echo "<br /><br /><table border=0 cellspacing=0 cellpadding=0 class='small'>";
        echo "<tr class='header'><th colspan=2> Decline Merge </th></tr>";
        echo "<tr class='subheader'><th>Decline Reason</th></tr>";
        echo "<tr class='data'><td><input type='text' name='declinereason' maxLength='100'></td></tr>";
        echo "<tr class='data'><td><input type=submit value='Decline Merge'></td></tr>";
        echo "</table>";
        echo "</form>";
    }
    if ($task == "delete") {
        // the queries part for the decline option
        $seek = mysql_query("SELECT * FROM mergers WHERE id = {$mergerid}");
        $seek = mysql_fetch_array($seek);
        $message1 = "Your merge request to {$seek['target']} has been declined.<br />The reason for this is: {$declinereason} .<br />";
        $message2 = "The merge from {$seek['oldname']}(#{$seek['origin']}) has been declined.<br />The reason for this is: {$declinereason} .<br />";
        $bleh2 = mysql_query("SELECT id FROM stats WHERE type='elder' AND kingdom='{$seek['target']}'");
        $bleh2 = mysql_fetch_array($bleh2);
        $sendmessage1 = mysql_query("INSERT INTO messages (id, for_user, from_user, date, subject, text, new, action) VALUES ('', '{$seek['tribe']}', '0', '" . $orkTime . "', 'Merge Request Declined', '" . $message1 . "', 'new', 'received')");
        $sendmessage2 = mysql_query("INSERT INTO messages (id, for_user, from_user, date, subject, text, new, action) VALUES ('', '{$bleh2['id']}', '0', '" . $orkTime . "', 'Merge Request Declined', '" . $message2 . "', 'new', 'received')");
        $update = mysql_query("UPDATE mergers SET request_status = 'declined', declined_reason = '{$declinereason}', mod_id = {$local_stats['id']} WHERE id = {$mergerid}");
        $task = "pending";
    }
    if ($task == "accept") {
        // doing the merge itself
        $fetch = mysql_query("Select * from mergers where id = {$mergerid}");
        $fetch = mysql_fetch_array($fetch);
        $search = mysql_query("Select * from stats where id = {$fetch['tribe']}");
        $search = mysql_fetch_array($search);
        $newname = "'" . $fetch['newname'] . "'";
        //$update = mysql_query("UPDATE goods SET credits = 0, market_money = 0, market_food = 0, market_soldiers = 0, market_wood = 0 WHERE id = {$fetch['tribe']}");
        //$update = mysql_query("UPDATE stats set kingdom = {$fetch['target']}, type = 'player', vote = 0, invested = 0, tribe = $newname where id = {$fetch['tribe']}");
        //$update = mysql_query("UPDATE rankings_personal set alli_id = {$fetch['target']} where id = {$fetch['tribe']}");
        mysql_query("UPDATE stats SET tribe = {$newname} where id = {$fetch['tribe']}");
        move_tribe($fetch['tribe'], $fetch['target']);
        $update = mysql_query("UPDATE mergers set request_status = 'done', merge_time = '{$orkTime}', mod_id = '{$local_stats['id']}' where id = {$fetch['id']}");
        $strSQL = mysql_query("INSERT INTO news (id, time, ip, type, duser, ouser, result, text, kingdom_text, kingdoma, kingdomb) VALUES ('', '{$orkTime}', '---', 'Mod Move', '0', '0', '1', '', '<font class = \"positive\">{$search['tribe']}(#{$fetch['origin']}) has been merged into {$newname}(#{$fetch['target']})! </font>', '{$fetch['origin']}', '{$fetch['target']}')");
        echo "<br /><br />Merge was done =D<br /><br />";
        $task = "pending";
    } elseif ($task == "done") {
        // show list with all done mergers
        $fetch = mysql_query("SELECT * FROM mergers WHERE request_status = 'done' order by merge_time desc");
        $mergers = array();
        while ($arrmergers = mysql_fetch_array($fetch, MYSQL_ASSOC)) {
            $mergers[$arrmergers["id"]] = $arrmergers;
        }
        echo "<br /><br /><table border=0 cellspacing=0 cellpadding=0 class='big'>";
        echo "<tr class='header'><th colspan='5'> Done Mergers </th></tr>";
        echo "<tr class='subheader'><th> Merge Time </td><td> Tribe ID </td><td> Old Location </td><td> New Location </td><td> Staff </td></tr>";
        foreach ($mergers as $strKey => $value) {
            $mod = mysql_query("SELECT name FROM stats WHERE id={$value['mod_id']}");
            $mod = mysql_fetch_array($mod);
            echo "<tr class='data'><th> {$value['merge_time']} </th><td> {$value['tribe']} </td><td> {$value['oldname']}(#{$value['origin']}) </td><td> {$value['newname']}(#{$value['target']}) </td><td> {$mod['name']} </td></tr>";
        }
        echo "</table>";
    } elseif ($task == "rejected") {
        // show list with all rejected mergers and the reason to reject it
        $fetch = mysql_query("SELECT * FROM mergers WHERE request_status = 'declined' order by merge_time desc");
        $mergers = array();
        while ($arrmergers = mysql_fetch_array($fetch, MYSQL_ASSOC)) {
            $mergers[$arrmergers["id"]] = $arrmergers;
        }
        echo "<br /><br /><table border=0 cellspacing=0 cellpadding=0 class='big'>";
        echo "<tr class='header'><th colspan=5> Declined Mergers </th></tr>";
        echo "<tr class='subheader'><th> Merge Time </th><td> Tribe ID </td><td> Location </td><td> Staff </td><td> Reason </td></tr>";
        foreach ($mergers as $strKey => $value) {
            $mod = mysql_query("SELECT name FROM stats WHERE id={$value['mod_id']}");
            $mod = mysql_fetch_array($mod);
            echo "<tr class='data'><th> {$value['merge_time']} </th><td> {$value['tribe']} </td><td> {$value['oldname']}(#{$value['origin']}) </td><td> {$mod['name']} </td><td>{$value['declined_reason']}</td></tr>";
        }
        echo "</table>";
    } elseif ($task == "requested") {
        // show list with all mergers not accepted by the elder yet
        $fetch = mysql_query("SELECT * FROM mergers WHERE request_status = 'not ready' order by merge_time desc");
        $mergers = array();
        while ($arrmergers = mysql_fetch_array($fetch, MYSQL_ASSOC)) {
            $mergers[$arrmergers["id"]] = $arrmergers;
        }
        echo "<br /><br /><table border=0 cellspacing=0 cellpadding=0 class='big'>";
        echo "<tr class='header'><th colspan=4> Requested Mergers </th></tr>";
        echo "<tr class='subheader'><th> Merge Time </th><td> Tribe ID </td><td> Current Location </td><td> Wanted Location </td></tr>";
        foreach ($mergers as $strKey => $value) {
            echo "<tr class='data'><th> {$value['merge_time']} </th><td> {$value['tribe']} </td><td> {$value['oldname']}(#{$value['origin']}) </td><td>{$value['newname']}(#{$value['target']})</td></tr>";
        }
        echo "</table>";
    } elseif ($task == "pending") {
        // show list of all tribes ready to get merged
        $fetch = mysql_query("SELECT * FROM mergers WHERE request_status = 'ready' order by merge_time desc");
        $mergers = array();
        while ($arrmergers = mysql_fetch_array($fetch, MYSQL_ASSOC)) {
            $mergers[$arrmergers["id"]] = $arrmergers;
        }
        echo "<br /><br />" . '<table border="0" cellspacing="0" cellpadding="0" class="big">' . '<tr class="header">' . '<th colspan="8">New Mergers</th>' . '</tr>' . '<tr class="subheader">' . '<th> Merge Time </th>' . '<td> Tribe ID </td>' . '<td> Old Location </td>' . '<td> New Location </td>' . '<td class="center"> §1 </td>' . '<td class="center"> Ruler<br />Age </td>' . '<td> War </td>' . '<td> Actions </td>' . '</tr>';
        foreach ($mergers as $strKey => $value) {
            //             $age = mysql_query("SELECT land FROM build WHERE id = $value[tribe]");
            //             $age = mysql_fetch_array($land);
            //             $ltxt = $land['land'];
            $bExists = TRUE;
            $strSQL = "SELECT id FROM " . TBL_USER . " WHERE id = {$value['tribe']}";
            $resSQL = mysql_query($strSQL);
            if (mysql_num_rows($resSQL) == 1) {
                $objTmpUser = new clsUser($value['tribe']);
            } else {
                $bExists = FALSE;
            }
            // 21 YEARS OLD ====================================================
            if ($bExists) {
                $iHours = $objTmpUser->get_user_info(HOURS);
            } else {
                $iHours = 11808;
            }
            if (($iYears = ceil(($iHours + 192) / 12)) > 21) {
                $strTmpYears = '<span class="negative">' . $iYears . '</span>';
            } else {
                $strTmpYears = '<span class="positive">' . $iYears . '</span>';
            }
            // WEEKS JOINED < 6 ================================================
            if ($bExists) {
                $strDate = $objTmpUser->get_gamestat(SIGNUP_TIME);
            } else {
                $strDate = '0000-00-00 00:00:00';
            }
            if (ceil((strtotime($strDate) - strtotime('-6 weeks')) / 86400) < 0) {
                $strTmpSignup = '<span class="negative">Veteran</span>';
            } else {
                $strTmpSignup = '<span class="positive">Novice</span>';
            }
            include_once "inc/functions/war.php";
            $seek1['war_target'] = war_target($value['origin']);
            $seek2['war_target'] = war_target($value['target']);
            $seek4 = mysql_query("Select count(id) as bleh from stats where kingdom = {$value['target']}");
            $seek4 = mysql_fetch_array($seek4);
            if ($seek1['war_target'] > 0 || $seek2['war_target'] > 0) {
                $war = '<font class="negative">At War</font>';
            } else {
                $war = '<font class="positive">Ok!</font>';
            }
            if ($seek1['war_target'] > 0 || $seek2['war_target'] > 0 || $seek4['bleh'] >= MAX_ALLIANCE_SIZE) {
                $accept = "<font class=\"negative\">No Merging *</font>";
                $show = true;
            } else {
                $accept = "<a href='main.php?cat=game&page=resort_tools&tool=mergers&amp;task=accept&amp;mergerid={$value['id']}'>Accept</a>";
            }
            echo "<tr class='data'>\n                    <th class='bsdown'> {$value['merge_time']} </th>\n                    <td class='bsdown'> {$value['tribe']} </td>\n                    <td class='bsdown'> {$value['oldname']}(#{$value['origin']}) </td>\n                    <td class='bsdown'> {$value['newname']}(#{$value['target']}) </td>\n                    <td class='bsdown center'> " . $strTmpSignup . " </td>\n                    <td class='bsdown center'> " . $strTmpYears . " </td>\n                    <td class='bsdown'> {$war} </td>\n                    <td class='bsdown'> <a href='main.php?cat=game&page=resort_tools&tool=mergers&task=changename&mergerid={$value['id']}'>Change Name</a><br />\n                         {$accept}<br />\n                         <a href='main.php?cat=game&page=resort_tools&tool=mergers&task=decline&mergerid={$value['id']}'>Decline</a>\n                    </td>\n                </tr>";
        }
        echo "</table>";
        if (isset($show)) {
            echo "* = The no merging means that his alliance or the alliance he want to go to is at war, or that the alliance he want to merge to is already at " . MAX_ALLIANCE_SIZE . " tribes.<br />";
        }
    }
}
示例#5
0
function make_magic2(&$objSrcUser, $i_intTargetid, &$arrSpells, $i_strSpellName, $i_intSpelltimes, $i_blnStopOnSuccess, $i_blnMinHours, $i_minHours)
{
    $iUserID = $objSrcUser->get_userid();
    $damageModifier = 1;
    mt_srand((double) microtime() * 1000000);
    $objTrgUser = new clsUser($i_intTargetid);
    $arrSrcStats = $objSrcUser->get_stats();
    $arrTrgStats = $objTrgUser->get_stats();
    $arrTrgBuild = $objTrgUser->get_builds();
    $intCasterMageLevel = get_mage_level($objSrcUser);
    $intTargetMageLevel = get_mage_level($objTrgUser);
    if ($arrTrgStats[ALLIANCE] == "0") {
        echo "This Player Has Either Been Deleted Or Suspended";
        free_casting_now($iUserID);
        include_game_down();
        exit;
    }
    // war check
    include_once "inc/functions/war.php";
    // Gotland was here
    $warmodifier = war_alli($objTrgUser->get_stat(ALLIANCE), $objSrcUser->get_stat(ALLIANCE));
    if ($warmodifier > 1) {
        $res = mysql_query("SELECT defiance FROM spells WHERE id = {$iUserID}");
        $line = mysql_fetch_assoc($res);
        $damageModifier = $damageModifier * 1.1;
        if ($line["defiance"] > 0) {
            $damageModifier = $damageModifier * 1.1;
        }
    }
    $target = war_target($arrTrgStats[ALLIANCE]);
    if ($target != 0 && $damageModifier == 0) {
        //what is this supposed to do? right now it does nothing at all - AI
        $damageModifier = $damageModifier * 0.95;
    }
    $lastWar = mysql_query("SELECT last_target, last_end FROM war WHERE id = " . $arrSrcStats[ALLIANCE]);
    $lastWar = mysql_fetch_array($lastWar);
    $timeCounter = mysql_query("SELECT hour_counter FROM admin_global_time");
    $timeCounter = mysql_fetch_array($timeCounter);
    // Spell type = SPELL_SELF, SPELL_ALLIANCE, SPELL_ENEMY etc (integers)
    $strSpellType = $arrSpells[$i_strSpellName]['type'];
    // Spell Display = full name of spell
    $strSpellDisplay = $arrSpells[$i_strSpellName]['display'];
    if ($arrTrgStats[ALLIANCE] == $lastWar['last_target'] && $strSpellType == SPELL_ENEMY) {
        if ($timeCounter['hour_counter'] <= $lastWar['last_end'] + 12) {
            echo '<div class="center">The war is not even over for 12 hours. Give them some time to recover!</div>';
            free_casting_now($iUserID);
            include_game_down();
            exit;
        }
    }
    include_once 'inc/functions/update.php';
    check_to_update($objTrgUser->get_userid());
    // Include the code for the spell about to be cast
    require_once "inc/spells/" . $i_strSpellName . ".php";
    // Check for casting "harmful" spells on yourself
    if ($iUserID == $objTrgUser->get_userid() && ($strSpellType == SPELL_ENEMY || $strSpellType == SPELL_ALL || $strSpellType == SPELL_WAR)) {
        echo '<div class="center">' . "I'm sorry you cannot cast " . $strSpellDisplay . " upon yourself.\n";
        echo "<br /><br /><br /><a href=main.php?cat=game&page=mystic&magekd=" . $objSrcUser->get_stat(ALLIANCE) . ">Back to Mystics</a></div>";
        free_casting_now($iUserID);
        include_game_down();
        exit;
    }
    // Martel: Heal may only target alliance members
    // SPELL_ALLIANCE only on allimates
    $iSrcAlli = $objSrcUser->get_stat(ALLIANCE);
    $iTrgAlli = $objTrgUser->get_stat(ALLIANCE);
    if ($strSpellType == SPELL_ALLIANCE && $iTrgAlli != $iSrcAlli) {
        echo '<div class="center">' . "Sorry but you cannot cast " . $strSpellDisplay . " on non-allies.<br />";
        echo "<br /><br /><br /><a href=\"main.php?cat=game&page=mystic&magekd=" . $objTrgUser->get_stat(ALLIANCE) . "\">Back to Mystics</a></div>";
        free_casting_now($iUserID);
        include_game_down();
        exit;
    }
    // SPELL_ENEMY not on own alli
    if ($strSpellType == SPELL_ENEMY && $iTrgAlli == $iSrcAlli) {
        echo '<div class="center">' . "Sorry, but I refuse to do harm to our alliance members.<br />";
        echo "<br /><br /><br /><a href=\"main.php?cat=game&page=mystic&magekd=" . $objTrgUser->get_stat(ALLIANCE) . "\">Back to Mystics</a></div>";
        free_casting_now($iUserID);
        include_game_down();
        exit;
    }
    // Check for target protection period
    if ($objTrgUser->get_user_info(HOURS) < PROTECTION_HOURS) {
        // Removed code-reuse of the copy-paste variety            - AI 30/09/06
        if ($strSpellType != SPELL_SELF) {
            $iRemaining = PROTECTION_HOURS - $objTrgUser->get_user_info(HOURS);
            echo '<div id="textMedium"><p>' . 'It appears that the tribe you wish to target is still ' . 'materializing. Our Mage estimates that it will take another ' . $iRemaining . ' updates for the area to become a stable part of ' . 'our reality.' . "</p><p>" . '<a href="main.php?cat=game&page=mystic&amp;magekd=' . $objTrgUser->get_stat(ALLIANCE) . '">Back to Mystics</a>' . '</p>' . '</div>';
            free_casting_now($iUserID);
            include_game_down();
            exit;
        }
    }
    // Check for own protection period (this is also checked in mystic2.inc.php
    if ($objSrcUser->get_user_info(HOURS) < PROTECTION_HOURS) {
        if ($strSpellType != SPELL_SELF) {
            echo '<div id="textMedium"><p>' . 'You are still under protection.' . "</p><p>" . '<a href="main.php?cat=game&page=mystic&amp;magekd=' . $objSrcUser->get_stat(ALLIANCE) . '">Back to Mystics</a>' . '</p>' . '</div>';
            free_casting_now($iUserID);
            include_game_down();
            exit;
        }
    }
    // Check for visioning a spirit
    if ($objTrgUser->get_stat(RACE) == 'Spirit' && $i_strSpellName == 'vision') {
        echo '<div id="textMedium"><p>' . "Your mystics are confused, they can't see anything at all." . "</p><p>" . '<a href="main.php?cat=game&page=mystic&amp;magekd=' . $objSrcUser->get_stat(ALLIANCE) . '">Back to Mystics</a>' . '</p>' . '</div>';
        free_casting_now($iUserID);
        include_game_down();
        exit;
    }
    // Check for casting jura on a Templar - AI 11/02/2007
    if ($objTrgUser->get_stat(RACE) == 'Templar' && $i_strSpellName == "juranimosity") {
        echo "Sorry, but " . $objTrgUser->get_stat(TRIBE) . " does not have any thieves for me to disband.";
        echo "<br /><br /><br /><a href=\"main.php?cat=game&amp;page=mystic&amp;magekd=" . $objTrgUser->get_stat(ALLIANCE) . ">Back to Mystics</a>";
        free_casting_now($iUserID);
        include_game_down();
        exit;
    }
    // check the user has cast it at lest 1 time
    if ($i_intSpelltimes <= 0) {
        echo "Sorry but you must cast this spell at least 1 time.<br />";
        echo "<br /><br /><br /><a href=main.php?cat=game&page=mystic&magekd=" . $objTrgUser->get_stat(ALLIANCE) . ">Back to Mystics</a>";
        free_casting_now($iUserID);
        include_game_down();
        exit;
    }
    // Added by Genia4, checks that the user didnt ask to cast a self-spell until it succeeds for less than 1 hours.
    if ($i_blnMinHours && $i_minHours <= 0) {
        echo "Sorry but you must tell your mage for how much time you want the self spell.<br />";
        echo "<br /><br /><br /><a href=main.php?cat=game&page=mystic&magekd=" . $objTrgUser->get_stat(ALLIANCE) . ">Back to Mystics</a>";
        free_casting_now($iUserID);
        include_game_down();
        exit;
    }
    // check the user has cast it no more than X times
    if ($i_intSpelltimes > MAX_SPELL_CASTS) {
        echo "Sorry but you can't auto-cast more than " . MAX_SPELL_CASTS . " times in a row in the interests of reducing server lag.<br />";
        echo "<br /><br /><br /><a href=main.php?cat=game&page=mystic&magekd=" . $objTrgUser->get_stat(ALLIANCE) . ">Back to Mystics</a>";
        free_casting_now($iUserID);
        include_game_down();
        exit;
    }
    // check they aren't trying to cast a spell beyond their level, they must've modified the
    // form directly to do this....TSKTSK!
    $iMageLevel = get_mage_level($objSrcUser);
    // Martel: Added age 22 to implement high acreage spells
    // And removed again - AI 30/09/06
    //$arrSrcBuild = $objSrcUser->get_builds();
    //$iTotalAcres = $arrSrcBuild[LAND];
    if ($iMageLevel < $arrSpells[$i_strSpellName]['level']) {
        echo "I'm sorry, you cannot cast " . $strSpellDisplay . ".";
        echo "<br /><br /><br /><a href=main.php?cat=game&page=mystic&magekd=" . $objSrcUser->get_stat(ALLIANCE) . ">Back to Mystics</a>";
        free_casting_now($iUserID);
        include_game_down();
        exit;
    }
    if (!clsBlock::isOpAllowed($objSrcUser, $objTrgUser) && $strSpellType != SPELL_SELF) {
        echo '<div id="textMedium"><p>' . 'Someone else from the same IP has already opped this tribe during the last 8 hours.' . '</p><p>' . '<a href="main.php?cat=game&amp;page=mystic">Return</a>' . '</p></div>';
        clsBlock::reportOp($objSrcUser, $objTrgUser, 'Spell: ' . $i_strSpellName, false);
        free_casting_now($iUserID);
        include_game_down();
        exit;
    }
    $intOldPower = $objSrcUser->get_spell(POWER);
    //Check for Thwart
    $trgThwart = 1;
    if ($strSpellType != SPELL_SELF) {
        $arrTrgSpells = $objTrgUser->get_spells();
        if ($arrTrgSpells[THWART] > 0) {
            $trgThwart = 0.75;
        }
    }
    //Churches
    // Tragedy: april 20th 2002:
    // adding a cap of max 80% effectiveness on churches, ergo max 20% of land
    $church_percentage = min(0.2, $arrTrgBuild['churches'] / $arrTrgBuild['land']);
    //frost: added high elves church bonus
    if ($objTrgUser->get_stat(RACE) == 'High Elf') {
        $church_bonus = $church_percentage * 4;
    } else {
        $church_bonus = $church_percentage * 3.5;
    }
    // Skathen: May 10th 2002:
    // Stop churches affecting self spells
    // Stop selected target affecting self spells
    // Martel: version 2.0, same purpose
    if ($strSpellType == SPELL_SELF) {
        //next line a small hack to prevent possible future bugs
        $objTrgUser = $objSrcUser;
        $church_bonus = 0;
        $trgThwart = 1;
        $intTargetMageLevel = 12 - $intCasterMageLevel;
        if ($intTargetMageLevel <= 4) {
            $intTargetMageLevel = 4;
        }
        if ($objSrcUser->get_user_info(HOURS) < PROTECTION_HOURS) {
            $intTargetMageLevel = 3;
        }
    }
    $chance_to_cast = formulate_chance($intCasterMageLevel, $intTargetMageLevel, $arrSpells[$i_strSpellName]);
    //==========================================================================
    // Main block - calculates success-rates, calls the specific spell-function
    //==========================================================================
    //How many spells can we cast ?
    //since we don't have 'infinity', we'll use an arbitrarily large number
    $totalAvailable = $arrSpells[$i_strSpellName]['cost'] > 0 ? floor($intOldPower / $arrSpells[$i_strSpellName]['cost']) : 9999999999.0;
    if ($totalAvailable > $i_intSpelltimes) {
        $totalAvailable = $i_intSpelltimes;
    }
    /* check the tribe still has the power to cast one time*/
    if ($totalAvailable <= 0) {
        echo '<div class="center">' . "I'm sorry, you don't have enough Magic Power to cast that spell.";
        echo "<br /><br /><br /><a href=main.php?cat=game&page=mystic&amp;magekd=" . $objTrgUser->get_stat(ALLIANCE) . ">Back to Mystics</a></div>";
        free_casting_now($iUserID);
        include_game_down();
        exit;
    }
    /* check for casting on a Nazgul, but only if its not a self spell */
    if ($strSpellType != SPELL_SELF && $objTrgUser->get_stat(RACE) == "Nazgul") {
        $nazgulBonus = 0.2;
    } else {
        $nazgulBonus = 0;
    }
    // added nazgul casting failures
    if ($objSrcUser->get_stat(RACE) == "Nazgul") {
        $nazgulPenalty = 0.25;
    } else {
        $nazgulPenalty = 0;
    }
    /* check for casting on a Dragon, casting on dragon gives 50% less damage */
    if ($objTrgUser->get_stat(RACE) == "Dragon") {
        $damageModifier *= 0.5;
    }
    // Roar of the horde fireball
    if ($strSpellType == SPELL_ENEMY && ($objTrgUser->get_stat(RACE) == "Uruk Hai" || $objTrgUser->get_stat(RACE) == "Oleg Hai" || $objTrgUser->get_stat(RACE) == "Mori Hai")) {
        $id = $objTrgUser->get_userid();
        $seek = mysql_query("Select * from spells where id = {$id}");
        $seek = mysql_fetch_array($seek);
        if ($seek['roar'] > 0 && $seek['forest'] == 0) {
            $rothBonus = 1 / 7;
        } else {
            $rothBonus = 0;
        }
    } else {
        $rothBonus = 0;
    }
    //Formulate the independent failure-chances. ML=magelevel, CH=Church-protection, race=race-protection, etc...
    $P_ML = 1 - $trgThwart * min($chance_to_cast, 290) / 300;
    $P_CH = $church_bonus;
    //$P_race1 -- used to be dragon protection
    $P_race2 = $nazgulBonus;
    $P_race3 = $nazgulPenalty;
    $P_roth = $rothBonus;
    // Martel: Adding exceptions here (alliance spell)
    if ($strSpellType == SPELL_ALLIANCE) {
        $P_CH = 0;
        $P_roth = 0;
    }
    //Calculate total chance of success per spell
    $P_success = (1 - $P_ML) * (1 - $P_CH) * (1 - $P_race2) * (1 - $P_race3) * (1 - $P_roth);
    //Loop through the number of spells casted, randomly decide wether it succeeds or fails.
    //When it fails, randomly choose a reason based on the relative failure-rates of all possible failure-reasons
    //Note that Stop-On-Success will be dealt with later on, by the spell-include-function
    $cntSpellSuccess = 0;
    $cntSF_total = 0;
    $cntSF_ML = 0;
    $cntSF_CH = 0;
    $cntSF_race2 = 0;
    $cntSF_race3 = 0;
    $cntSF_roth = 0;
    //Don't worry too much about the math behind it. It's correct and assures a fair distribution over the various 'reasons for failure'
    $P_fail_Total = $P_ML + $P_CH + $P_race2 + $P_race3 + $P_roth;
    $P_fail_ML = $P_ML / $P_fail_Total;
    $P_fail_CH = $P_CH / $P_fail_Total;
    $P_fail_race2 = $P_race2 / $P_fail_Total;
    $P_fail_race3 = $P_race3 / $P_fail_Total;
    $P_fail_roth = $P_roth / $P_fail_Total;
    if ($i_blnStopOnSuccess && $i_blnMinHours && $strSpellType == SPELL_SELF) {
        $i_blnStopOnSuccess = FALSE;
    }
    if ($i_blnMinHours && $strSpellType != SPELL_SELF) {
        $i_blnStopOnSuccess = TRUE;
    }
    for ($x = 1; $x <= $totalAvailable; $x++) {
        $random = rand(1, 10000) / 10000;
        if ($random < $P_success) {
            $cntSpellSuccess++;
            //Stop-On-Success check
            if ($i_blnStopOnSuccess == 1) {
                $totalAvailable = $x;
                break;
            }
        } else {
            $cntSF_total++;
            //Why did the spell fail ? Default ML-difference, CHs, race-protection, roth-protection, etc...
            $random = rand(1, 10000) / 10000;
            if ($random <= $P_fail_ML) {
                $cntSF_ML++;
            }
            if ($random > $P_fail_ML && $random <= $P_fail_ML + $P_fail_CH) {
                $cntSF_CH++;
            }
            if ($random > $P_fail_ML + $P_fail_CH && $random <= $P_fail_ML + $P_fail_CH + $P_fail_race2) {
                $cntSF_race2++;
            }
            if ($random > $P_fail_ML + $P_fail_CH + $P_fail_race2 && $random <= $P_fail_ML + $P_fail_CH + $P_fail_race2 + $P_fail_race3) {
                $cntSF_race3++;
            }
            if ($random > $P_fail_ML + $P_fail_CH + $P_fail_race2 + $P_fail_race3) {
                $cntSF_roth++;
            }
        }
    }
    // Ok, now we're done with calcing how many spells will succeed and why they will fail, we proceed to actually casting the spells
    // Call with: SpellCaster-object, Target-object, Spellname, Times-to-cast, Minimum-hours
    if (!$i_blnMinHours) {
        $minHours = 0;
    } else {
        $minHours = $i_minHours;
    }
    if ($cntSpellSuccess > 0) {
        $spellResult = cast_spell($objSrcUser, $objTrgUser, $arrSpells[$i_strSpellName], $cntSpellSuccess, $minHours, $damageModifier);
    } else {
        // Gotland: initialize the spellresult to avoid error message in case all attempts failed
        $spellResult["casted"] = 0;
        $spellResult["damage"] = 0;
        $spellResult["text_news"] = "";
        $spellResult["text_screen"] = "";
    }
    // $spellResult structure: (it's an array)
    // ["damage"] = 'Damage' done, could be used to calculate fame, not used for that right now.
    // ["casted"] = Amount of spells casted
    // ["text_screen"] = Return-text for the spell, to be outputted on the screen
    // ["text_news"] = text for the tribenews of the victim
    // Spend the mana and save back to to the db
    $manaSpent = ($spellResult["casted"] + $cntSF_total) * $arrSpells[$i_strSpellName]['cost'];
    $objSrcUser->set_spell(POWER, $intOldPower - $manaSpent);
    $dtTimestamp = date(TIMESTAMP_FORMAT);
    // Print out spell-casting-report
    if ($cntSpellSuccess == 0) {
        $spellResult["casted"] = 0;
    }
    $strReport = "<p>" . "Your mage has casted the spell " . ($spellResult["casted"] + $cntSF_total) . " times.<br />" . "He succeeded " . $spellResult["casted"] . " times and failed " . $cntSF_total . " times.<br />";
    if ($cntSF_ML > 0) {
        $strReport .= $cntSF_ML . " failures he blames on lack of training.<br />";
    }
    if ($cntSF_CH > 0) {
        $strReport .= $cntSF_CH . " of his cast-attempts were stopped by the Gods.<br />";
    }
    if ($cntSF_race2 > 0) {
        $strReport .= $cntSF_race2 . " spells failed due to ancient Nazgul protection.<br />";
    }
    if ($cntSF_race3 > 0) {
        $strReport .= $cntSF_race3 . " times your mage was hindered by our Nazgul curse.<br />";
    }
    if ($cntSF_roth > 0) {
        // Roar of the Hoard "fireball bonus"
        // M: Updated to use objects. August 05, 2007
        $citizens = $objSrcUser->get_pop(CITIZENS);
        $totalKilled = 0;
        for ($x = 1; $x <= $cntSF_roth; $x++) {
            $killed = ceil($citizens * 0.05);
            if ($citizens - $killed < 2000) {
                $killed = rand(10, 45);
            }
            if ($citizens - $killed < 100) {
                $killed = rand(2, 4);
            }
            if ($citizens - $killed < 50) {
                $killed = 0;
            }
            $citizens -= $killed;
            $totalKilled += $killed;
        }
        $objSrcUser->set_pop(CITIZENS, $citizens);
        $strReport .= '</p><p>Those orks must be under the influence of some spell. ' . $cntSF_roth . ' spells were returned by them in the form of ' . 'fireballs! <strong class="negative">' . number_format($totalKilled) . '</strong> citizens were killed.</p><p>';
    }
    if ($cntSpellSuccess > 0) {
        $strReport .= "</p><p>Your mage reports the following results:<br />";
        $strReport .= $spellResult["text_screen"] . "<br />";
    }
    if ($spellResult["damage"] == 0) {
        $intFameWon = fame_win($objSrcUser, $objTrgUser, 0);
    } else {
        if ($i_strSpellName == "enforced") {
            $fame = floor($spellResult["damage"] * 0.1);
        } else {
            $fame = floor($spellResult["casted"] * $arrSpells[$i_strSpellName][FAME]);
        }
        $intFameWon = fame_win($objSrcUser, $objTrgUser, $fame);
        $strReport .= "</p><p>Your Mage gained a total of <strong class='positive'>" . number_format($intFameWon) . " fame</strong>.</p><p>";
    }
    // Add spell-message to target tribenews
    if (isset($spellResult["text_news"])) {
        if ($spellResult["text_news"] != "" && $spellResult["casted"] > 0) {
            // Insert upwards compatibility with spells that do allinews
            //                                              - AI 02/12/06
            $strAlliMsgTemp = "";
            if (isset($spellResult["alli_news"])) {
                $strAlliMsgTemp = $spellResult["alli_news"];
            }
            $strMsgTemp = $spellResult["text_news"];
            insert_news_item($i_strSpellName, $objTrgUser->get_userid(), $iUserID, 2, $strMsgTemp, $strAlliMsgTemp);
            //trigger news flag of defender
            $objTrgUser->set_user_info(LAST_NEWS, 1);
        }
    }
    // Add failed-spells message to target tribenews
    if ($strSpellType != SPELL_SELF && $i_strSpellName != "vision" && $cntSF_total > 0) {
        if ($cntSF_total > 1) {
            $plural = "s";
        } else {
            $plural = "";
        }
        $strMsgTemp = "Our Mage has detected {$cntSF_total} failed " . $strSpellDisplay . " spell{$plural} coming from " . $arrSrcStats[TRIBE] . "(#" . $arrSrcStats[ALLIANCE] . ").";
        $strAlliMsgTemp = "";
        insert_news_item($i_strSpellName, $objTrgUser->get_userid(), $iUserID, 2, $strMsgTemp, $strAlliMsgTemp);
        //trigger news flag of defender
        $objTrgUser->set_user_info(LAST_NEWS, 1);
    }
    // Check for kill-by-fireball.
    if ($spellResult["damage"] <= -100) {
        obj_test_for_kill($objTrgUser, $objSrcUser);
    }
    // AI's block system
    if ($strSpellType != SPELL_SELF) {
        clsBlock::logOp($objSrcUser, $objTrgUser, 'Spell: ' . $i_strSpellName);
    }
    $strReport .= "</p>" . "<p>" . "<a href=main.php?cat=game&page=mystic&magekd=" . $objTrgUser->get_stat(ALLIANCE) . ">Back to Mystics</a>" . "</p>";
    // Print out the Report
    echo '<div id="textBig">' . '<h2>' . "Mystics Report " . '</h2>' . $strReport . '</div>';
    // As requested... Show spells on success. Will people ever be satisfied? :p
    if ($spellResult["casted"] > 0 && $strSpellType == SPELL_SELF) {
        include_once 'inc/pages/advisors.inc.php';
        echo '<br/>' . get_effecting_spells_table($objSrcUser);
    }
    free_casting_now($iUserID);
    include_game_down();
    exit;
}
示例#6
0
function call_target_find($landMin,$landMax,$strMin,$strMax,$fameMin,$fameMax,$races,$sort,$sortType)
{
    // ---One hell of an sql query start---

    $sql="SELECT tribe_name,alli_id,land,nw,fame,race,id FROM rankings_personal WHERE hours >= " . PROTECTION_HOURS . " AND alli_id > 10 AND ";
    $criteria=0; //this var is needed to check whether to put ADD in the query (the user may only want to search by 1 criteria)
    if(is_numeric($landMin))
    {
        $sql.="land>=$landMin ";
        $criteria=1;
    }
    if(is_numeric($landMax))
    {
        if($criteria>0)
        {
            $sql.="AND ";
        }

        $sql.="land<=$landMax ";
        $criteria=1;
    }
    if(is_numeric($strMin))
    {
        if($criteria>0)
        {
            $sql.="AND ";
        }

        $sql.="nw>=$strMin ";
        $criteria=1;
    }
    if(is_numeric($strMax))
    {
        if($criteria>0)
        {
            $sql.="AND ";
        }

        $sql.="nw<=$strMax ";
        $criteria=1;
    }
    if(is_numeric($fameMin))
    {
        if($criteria>0)
        {
            $sql.="AND ";
        }

        $sql.="fame>=$fameMin ";
        $criteria=1;
    }
    if(is_numeric($fameMax))
    {
        if($criteria>0)
        {
            $sql.="AND ";
        }

        $sql.="fame<=$fameMax ";
        $criteria=1;
    }
    $sql.="AND race IN (";

    $racesAmount=count($races);
    for($i=0;$i<$racesAmount;$i++)
    {
        $sql.="'$races[$i]'";

        if($i!=$racesAmount-1)
        {
            $sql.=",";
        }
    }

    $sql.=") ORDER BY $sort $sortType LIMIT 100";

    // ---One hell of an sql query end---

    $results=mysql_query($sql) or die(mysql_error());

if ($races[0] != "") {
?>
<table cellspacing="0" cellpadding="0" class="big" id="results">
    <tr class="header">
        <th colspan="7">Your Search Results</th>
    </tr>
    <tr class="subheader">
        <th>Tribe name</th>
        <th class="right">#</th>
        <th class="center">War</th>
        <th class="center">Race</th>
        <th class="right">Land</th>
        <th class="right">Strength</th>
        <th class="right">Fame</th>
    </tr>
<?
    include_once("inc/functions/war.php");

    while($arrTrgFind = mysql_fetch_array($results))
    {
        $warTarget = war_target($arrTrgFind['alli_id']);

        echo "<tr class=\"data\">";
        echo "<th><a href=\"main.php?cat=game&amp;page=external_affairs&amp;tribe=$arrTrgFind[id]&amp;aid=$arrTrgFind[alli_id]\">$arrTrgFind[tribe_name]</th>";
        echo "<td><a href=\"main.php?cat=game&amp;page=alliance&amp;aid=$arrTrgFind[alli_id]\">$arrTrgFind[alli_id]</td>";
        if ($warTarget == 0)
            echo "<td>&nbsp;</td>";
        else
            echo "<td class=\"negative center\">*WAR*</td>";
        echo "<td class=\"center\">$arrTrgFind[race]</td>";
        echo "<td>$arrTrgFind[land]</td>";
        echo "<td>$arrTrgFind[nw]</td>";
        echo "<td>$arrTrgFind[fame]</td>";
        echo "</tr>";
   }
?>
    </tbody>
</table>
<div class="center"><? echo mysql_num_rows($results); ?> Targets Found.</div>
<?
}
}
示例#7
0
function include_preferences_text()
{
    global $orkTime;
    include_once 'inc/classes/clsGame.php';
    $objSrcUser =& $GLOBALS["objSrcUser"];
    $arrSrcUserInfos = $objSrcUser->get_user_infos();
    $arrSrcStats = $objSrcUser->get_stats();
    $iUserId = $objSrcUser->get_userid();
    $objGame = new clsGame();
    // Navigational Links
    if ($arrSrcStats[TYPE] == 'elder' || $arrSrcStats[TYPE] == 'coelder') {
        echo $topLinks = '<div class="center">| <b>Options</b> ' . '| <a href="main.php?cat=game&page=elder">Elder Options</a> ' . '|' . '</div>';
    }
    echo '<div id="textBig">';
    echo '<h2>Account Settings</h2>' . '<p>' . '<a href="main.php?cat=game&amp;page=preferences&amp;task=layout">Interface Settings</a> :: ' . '<a href="main.php?cat=game&amp;page=preferences&amp;task=profile">Profile Settings</a> :: ' . '<a href="main.php?cat=game&amp;page=preferences&amp;task=request_name">Request Name Change</a>' . '</p>';
    echo '<h2>Account Options</h2>' . '<p>' . '<a href="main.php?cat=game&amp;page=preferences&amp;task=request_merge">Request Merge</a> :: ' . '<a href="main.php?cat=game&amp;page=preferences&amp;task=pause_account">Pause Account</a> :: ' . '<a href="main.php?cat=game&amp;page=preferences&amp;task=reset_account">Reset Account</a> :: ' . '<a href="main.php?cat=game&amp;page=preferences&amp;task=delete_account">Delete Account</a>' . '</p>';
    if ($arrSrcStats[LEVEL] > 1) {
        echo "<h2>Staff Options</h2>" . '<p>' . '<a href="main.php?cat=game&amp;page=resort_tools">Resort Tools</a>' . '</p>';
    }
    echo '</div>';
    //==========================================================================
    // Below you will find the options for people to manage their accounts
    //==========================================================================
    echo '<div id="textBig">';
    $task = '';
    if (isset($_GET['task'])) {
        $task = $_GET['task'];
    }
    switch ($task) {
        case "layout":
            ?>
            <h2>Interface Settings</h2>

<?php 
            // XSS secure May 21, 2006 -Martel & Damadm00
            $widths = array(1 => 750, 1060);
            $alignments = array(1 => 'left', 'center');
            //             $designs    = array( 1 => 'blue', 'ice', 'red');
            $designs = array(1 => 'forest_v1', 'black_v2', 'ork_v2');
            //             $output     = array( 1 => 'Trade Winds', 'Castle Walls', 'Uruk Hatred');
            $output = array(1 => 'Forest Greens', 'Cursed Nights', 'Old Orkfia');
            // Handle POST Requests
            if (isset($_POST['width']) && isset($_POST['alignment']) && isset($_POST['design'])) {
                if (in_array($_POST['width'], $widths) && in_array($_POST['alignment'], $alignments) && in_array($_POST['design'], $designs)) {
                    $arrSrcDesignSafe[WIDTH] = $_POST['width'];
                    $arrSrcDesignSafe[ALIGNMENT] = $_POST['alignment'];
                    $arrSrcDesignSafe[COLOR] = $_POST['design'];
                    $objSrcUser->set_designs($arrSrcDesignSafe);
                    // A gift to you Damadm00 ^^ -Martel
                    header("Location: main.php?cat=game&page=preferences&task=layout");
                }
            } elseif (isset($_POST['guide_links'])) {
                if (isset($_POST['check'])) {
                    echo '<p><strong>Saved!</strong> Guide links will now show.</p>';
                    $objSrcUser->set_preference(GUIDE_LINKS, ON);
                } else {
                    echo '<p><strong>Saved!</strong> Guide links will no longer show.</p>';
                    $objSrcUser->set_preference(GUIDE_LINKS, OFF);
                }
            }
            // GUIDE LINKS OPTION
            $strChecked = '';
            if ($objSrcUser->get_preference(GUIDE_LINKS) == ON) {
                $strChecked = ' CHECKED';
            }
            // INTERFACE OPTIONS
            $arrSrcDesign = $objSrcUser->get_designs();
            ?>
            <h3>Interface Control</h3>

            <form method="post" action="main.php?cat=game&amp;page=preferences&amp;task=layout">

                <label for="skin">Skin:</label><br />
                <select name="design" id="skin">
<?php 
            foreach ($designs as $key => $color) {
                if ($color == $arrSrcDesign['color']) {
                    echo "<option value=\"" . $color . "\" selected=\"selected\">" . $output[$key] . "</option>";
                } else {
                    echo "<option value=\"" . $color . "\">" . $output[$key] . "</option>";
                }
            }
            ?>
                </select><br /><br />

                <label for="screen width">Width:</label><br />
                <select name="width" id="screen width">
<?php 
            foreach ($widths as $width) {
                if ($width == $arrSrcDesign['width']) {
                    echo "<option value=\"" . $width . "\" selected=\"selected\">" . $width . "</option>";
                } else {
                    echo "<option value=\"" . $width . "\">" . $width . "</option>";
                }
            }
            ?>
                </select><br /><br />

                <label for="layout alignment">Alignment:</label><br />
                <select name="alignment" id = "layout alignment">
<?php 
            foreach ($alignments as $alignment) {
                if ($alignment == $arrSrcDesign['alignment']) {
                    echo "<option value=\"" . $alignment . "\" selected=\"selected\">" . $alignment . "</option>";
                } else {
                    echo "<option value=\"" . $alignment . "\">" . $alignment . "</option>";
                }
            }
            ?>
                </select>

                <input type="submit" value="Update interface" />
            </form>

            <h3>Ingame Help System</h3>

            <form method="post" action="main.php?cat=game&amp;page=preferences&amp;task=layout">
                <label for="1">Show Guide Links: </label>
                <input type="checkbox" id="1" name="check" <?php 
            echo $strChecked;
            ?>
>
                <input type="hidden" name="guide_links" />
                <input type="submit" value="Update interface" />
            </form>
<?php 
            break;
        case "profile":
            //==================================================================
            // Action handler part of Profile            October 28, 2007 Martel
            //==================================================================
            if (isset($_POST['realname']) && !empty($_POST['realname'])) {
                // Enforce maxlength in form
                $strSafe = substr($_POST['realname'], 0, 24);
                // Same as in registration, important to keep the order right
                $strSafe = addslashes(strip_tags(trim($strSafe)));
                if (!empty($strSafe)) {
                    $objSrcUser->set_user_info(REALNAME, $strSafe);
                    echo '<p>Thank you, your name has been updated.</p>';
                }
            } elseif (isset($_POST['name']) && !empty($_POST['name'])) {
                // Enforce maxlength in form
                $strSafe = substr($_POST['name'], 0, 16);
                // Same as in registration, important to keep the order right
                $strSafe = addslashes(strip_tags(trim($strSafe)));
                $resSQL = mysql_query("SELECT * FROM stats WHERE name = '{$strSafe}'");
                $arrSQL = mysql_fetch_array($resSQL);
                if ($arrSQL) {
                    echo "<p>Sorry, that leader name is taken.</p>";
                    $strSafe = '';
                }
                if (!empty($strSafe)) {
                    $objSrcUser->set_stat(NAME, $strSafe);
                    echo '<p>Thank you, your name has been updated.</p>';
                }
            } elseif (isset($_POST['password1']) && !empty($_POST['password1'])) {
                $password1 = $_POST['password1'];
                $password2 = $_POST['password2'];
                $password = $_POST['password'];
                $check = mysql_query("SELECT * FROM user WHERE password = sha1('{$password}') AND id = {$iUserId}") or die("Error Retrieving Password From DB.");
                if (mysql_num_rows($check) == 1 && $password1 == $password2) {
                    $strPw1Safe = sha1($password1);
                    $objSrcUser->set_user_info(PASSWORD, $strPw1Safe);
                    echo "<p>Your password has been changed.</p>";
                    $email = stripslashes($objSrcUser->get_preference(EMAIL));
                    $username = stripslashes($arrSrcUserInfos[USERNAME]);
                    mail("{$email}", "ORKFiA New Password", "Hello, \nYour password has been updated with the one you requested =) \n\nUsername: {$username} \nPassword: {$password1}" . SIGNED_ORKFIA, "From: ORKFiA <" . EMAIL_REGISTRATION . ">\r\nX-Mailer: PHP/" . phpversion() . "\r\nX-Priority: Normal");
                } else {
                    echo "<p>Either you entered the wrong current password, or your new password wasn't matching in both entries.</p>";
                }
            } elseif (isset($_POST['email']) && !empty($_POST['email'])) {
                $strEmailSafe = $_POST['email'];
                // This check is used on the registration and verification pages
                if (!ereg('^[-!#$%&\'*+\\./0-9=?A-Z^_`a-z{|}~]+' . '@' . '[-!#$%&\'*+\\/0-9=?A-Z^_`a-z{|}~]+\\.' . '[-!#$%&\'*+\\./0-9=?A-Z^_`a-z{|}~]+$', $strEmailSafe)) {
                    echo "<p>Sorry, invalid e-mail address.</p>";
                } else {
                    $pref_search = mysql_query("SELECT * FROM preferences WHERE email = " . quote_smart($strEmailSafe));
                    $pref_search = mysql_fetch_array($pref_search);
                    if ($pref_search) {
                        echo "<p>Sorry, that email is in use.</p>";
                    } else {
                        $strCode = '';
                        for ($i = 0; $i < 12; $i++) {
                            $strCode .= substr("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", rand(0, 61), 1);
                        }
                        // Activation email sent to all new players
                        mail($strEmailSafe, "ORKFiA Verification", "Thank you for updating your profile =) \n\nHere is your new verification code: {$strCode} \n\nWe hope you enjoy your stay in ORKFiA =)" . SIGNED_ORKFIA, "From: ORKFiA <" . EMAIL_REGISTRATION . ">\r\nX-Mailer: PHP/" . phpversion() . "\r\nX-Priority: Normal");
                        $arrNewPrefs = array(EMAIL_ACTIVATION => $strCode, EMAIL => $strEmailSafe);
                        $objSrcUser->set_preferences($arrNewPrefs);
                        echo '<p>Thank you, your e-mail has been updated and ' . 'a new verification code has been sent to it.</p>';
                    }
                }
            }
            $arrUsers = $objSrcUser->get_user_infos();
            $arrStats = $objSrcUser->get_stats();
            $arrUsers[REALNAME] = stripslashes($arrUsers[REALNAME]);
            $arrStats[NAME] = stripslashes($arrStats[NAME]);
            $strEmail = stripslashes($objSrcUser->get_preference(EMAIL));
            //==================================================================
            // Output part of Profile                    October 28, 2007 Martel
            //==================================================================
            echo '<h2>Profile Settings</h2>';
            $strRealName = '<h3>Real Name</h3>' . '<p>About your privacy: Only admins and Law & Order ' . 'can see your real name, and only when enforcing the Code ' . 'of Conduct (to help judge that you are a unique individual). ' . 'We believe it is your right to remain anonymous, and you may ' . 'rest assured this will never be shown to anybody else.</p>' . '<form method="post" action="main.php?cat=game&amp;page=preferences&amp;task=profile">' . '<label for="real_name">Your Real Name:</label>' . '<br />' . '<input type="text" name="realname" id="real_name" value="' . $arrUsers[REALNAME] . '" maxlength="24" size="24" /> ' . '<input type="submit" value="Update my profile" />' . "</form>" . '<blockquote>"You also agree that by creating your account, ' . 'all details you have supplied are correct, persons who ' . 'create accounts with false information may be removed from ' . 'ORKFiA."</blockquote>';
            echo $strRealName;
            $strLeaderName = '<h3>Leader Name</h3>' . '<p>Your current nick name with us is <em>' . $arrStats[NAME] . '</em>. This is used in the forums, when sending mail using ' . 'the Orkfia Mail and in various alliance contexts. If someone ' . 'called out "<em>Hey ' . $arrStats[NAME] . '!</em>" in the ' . 'street, would you react to it and think it must be another ' . 'ORKFiAN?</p>' . '<form method="post" action="main.php?cat=game&amp;page=preferences&amp;task=profile">' . '<label for="new_leader_name">Your Leader Name:</label><br />' . '<input type="text" name="name" id="new_leader_name" value="' . $arrStats[NAME] . '" maxlength="16" size="16" /> ' . "<input type=\"submit\" value=\"Update my profile\" />" . "</form>";
            echo $strLeaderName;
            $strPassword = '******' . '<p>For your own safety, make sure your password consists of ' . 'minimum 8 characters including numbers and capital letters.' . '</p>' . '<form method="post" action="main.php?cat=game&amp;page=preferences&amp;task=profile">' . '<label for="current_pw">Current Password:</label><br />' . '<input type="password" name="password" id="current_pw" />' . '<br /><br />' . '<label for="new_pw">New Password:</label><br />' . '<input type="password" name="password1" id="new_pw" ' . 'maxlength="30" />' . '<br /><br />' . '<label for="repeat_pw">Confirm Password:</label><br />' . '<input type="password" name="password2" id="repeat_pw" ' . 'maxlength="30" /> ' . '<input type="submit" value="Update my profile" />' . "</form>";
            echo $strPassword;
            $strEmail = '<h3>E-mail</h3>' . '<p>It is important that you get this right, if you would ' . 'forget your password or if our ORKFiA Staff Team need to ' . 'contact you this e-mail will be used. We will never share ' . 'this with anyone else, privacy is a major concern to us.</p>' . '<form method="post" action="main.php?cat=game&amp;page=preferences&amp;task=profile">' . '<label for="new_email">' . "Your e-mail:" . '</label><br />' . '<input type="text" name="email" id="new_email" value="' . $strEmail . '" maxlength="30" size="30" />' . ' <input type="submit" value="Update my profile" />' . "</form>";
            echo $strEmail;
            break;
        case "request_name":
            $strSwitch = $objGame->get_game_switch(NAME_CHANGE_PROGRAM);
            if ($strSwitch == 'on') {
                echo "<h2> Request Name Change </h2>";
                echo "<p>Here you may request that the ORKFiA Staff Team " . "changes your tribe name. Normally you would only change " . "your tribe name if you reset your account, or if " . "your tribe dies.</p>";
                if (isset($_POST['action']) && $_POST['action'] == "yes") {
                    if (!empty($_POST['newtribename']) && !empty($_POST['reason'])) {
                        $strTribe = $_POST['newtribename'];
                        $strTribe = quote_smart(strip_tags(trim($strTribe)));
                        $reason = quote_smart(str_replace("'", "", strip_tags(trim($_POST['reason']))));
                        $check = mysql_query("SELECT * FROM stats WHERE tribe = {$strTribe}");
                        if (mysql_num_rows($check) != 0) {
                            echo "<p>Sorry, someone is already using that tribe name.</p>";
                        } else {
                            echo "<p>Thank you, your request has been sent to staff. You will soon recieve a confirmation note.</p>";
                            mysql_query("INSERT INTO namechanges (id, tribe, requestedname, reason, mod_id, reason_declined, request_status, oldname) VALUES ( '', '{$arrSrcStats['id']}', {$strTribe}, {$reason}, '0', '0', 'ready', '{$arrSrcStats['tribe']}')");
                        }
                    } else {
                        echo '<p>' . "You need to fill in a new tribe name and a reason." . '</p><p>' . '<a href="main.php?cat=game&amp;page=preferences&amp;task=request_name">Return</a>' . '</p>';
                    }
                } elseif (isset($_POST['action']) && $_POST['action'] == "cancel") {
                    echo "<p>Your request to change your tribe name has been deleted.</p>";
                    mysql_query("UPDATE namechanges SET request_status = 'cancelled' WHERE tribe = {$arrSrcStats['id']} AND request_status = 'ready' ");
                } else {
                    $strSQL = "SELECT requestedname FROM namechanges WHERE tribe = {$arrSrcStats['id']} AND request_status = 'ready'";
                    $result2 = mysql_query($strSQL);
                    if ($result = mysql_fetch_array($result2)) {
                        echo "<p>You have a pending name request.<br /> Your requested name is: " . stripslashes($result['requestedname']) . ".</p><p>If you wish to cancel your name request you may use the button below.</p>" . "<form method=\"post\" action=\"main.php?cat=game&amp;page=preferences&amp;task=request_name\">" . "<input type=hidden value='cancel' name='action'>" . "<input type=submit value='Cancel Request'>" . "</form>";
                    } else {
                        ?>
            <form method="post" action="main.php?cat=game&amp;page=preferences&amp;task=request_name">

                <label for="new tribe name">New Tribe Name:</label><br />
                <input type="text" size="30" name="newtribename"
                maxlength="30" id="new tribe name"
                value="<?php 
                        echo stripslashes($arrSrcStats[TRIBE]);
                        ?>
" /><br /><br />

                <label for="reason">Reason For Changing:</label><br />
                <input type="text" size="48" name="reason" maxlength="100" id="reason" />
                <input type="hidden" name="action" value="yes" />

                <input type="submit" value="Send request to Operations staff" />
            </form>
<?php 
                    }
                }
            } else {
                echo '<p class="positive">Currently name changes are closed. ' . 'It is not possible to request any more name changes.</p>';
            }
            break;
        case "request_merge":
            echo '<h2>Request Merge</h2>';
            $mergeswitch = $objGame->get_game_switch(MERGER_PROGRAM);
            if ($mergeswitch == "on") {
                if (isset($_POST['do']) && $_POST['do'] == "cancel") {
                    $bleh = mysql_query("SELECT * FROM mergers WHERE tribe = {$arrSrcStats['id']} AND ( request_status = 'not ready' OR request_status = 'ready')");
                    $bleh = mysql_fetch_array($bleh);
                    $bleh2 = mysql_query("SELECT * FROM stats WHERE type='elder' AND kingdom='{$bleh['target']}'");
                    $bleh2 = mysql_fetch_array($bleh2);
                    $message = "The merge request done by " . $arrSrcStats[TRIBE] . " (#" . $arrSrcStats[ALLIANCE] . ") has been cancelled by the player.";
                    mysql_query("INSERT INTO messages (id, for_user, from_user, date, subject, text, new, action) VALUES ('', {$bleh2['id']}, 0, {$orkTime}, 'Merge Request Cancelled', " . quote_smart($message) . ", 'new', 'received')");
                    mysql_query("DELETE FROM mergers WHERE tribe = {$arrSrcStats['id']} AND ( request_status = 'not ready' OR request_status = 'ready')");
                    echo "<p>Your merge request has been deleted.</p>";
                    echo '</div>';
                    return;
                }
                $result2 = mysql_query("SELECT * FROM mergers WHERE tribe = {$arrSrcStats['id']} AND ( request_status = 'not ready' OR request_status = 'ready')");
                $result2 = mysql_fetch_array($result2);
                if (isset($result2['target'])) {
                    echo "<p>You have a pending merge request to alliance (#" . $result2['target'] . ").<br />If you want to cancel this " . "merge request click on the button below.</p>";
                    echo $strCancelForm = '<form method="post" action="main.php?cat=game&amp;page=preferences&amp;task=request_merge">' . '<input type="hidden" name="do" value="cancel" />' . '<input type="submit" value="Cancel merge request" />' . '</form>';
                    echo '</div>';
                    return;
                }
                // Action on sent confirmation from target elder (by PM link)
                if (isset($_GET['checker']) && $_GET['checker'] > 0) {
                    $checker = intval($_GET['checker']);
                    $mergerid = intval($_GET['mergerid']);
                    $result = mysql_query("SELECT * FROM mergers WHERE tribe = {$mergerid} ORDER BY id DESC LIMIT 1");
                    if (mysql_num_rows($result) > 0) {
                        $result = mysql_fetch_array($result);
                        if ($checker == 1 && $result['target'] == $arrSrcStats[ALLIANCE]) {
                            mysql_query("UPDATE mergers SET auth = 1, request_status = 'ready' WHERE tribe = {$mergerid} AND request_status = 'not ready'") or die("<p>Error while accepting tribe.</p>");
                            $message = "Your request to merge to alliance {$result['target']} has been accepted by their elder.<br /><br />A member of the Operations Resort will merge you as soon as possible =)";
                            $sqlquery = "INSERT INTO messages (id, for_user, from_user, date, subject, text, new, action) VALUES ('', {$result['tribe']}, 0, {$orkTime}, 'Merge Request Accepted', " . quote_smart($message) . ", 'new', 'received')";
                            mysql_query($sqlquery);
                            echo "<p>Thank you, we have now accepted a new member to the alliance.</p>";
                        } elseif ($checker == 2 && $result['target'] == $arrSrcStats[ALLIANCE]) {
                            mysql_query("DELETE FROM mergers WHERE tribe = {$result['tribe']} AND ( request_status = 'not ready' OR request_status = 'ready') ") or die("<br />Error while rejecting tribe.<br />");
                            $message = "Your request to merge to alliance {$result['target']} has been rejected by their elder.<br /><br />";
                            $sqlquery = "INSERT INTO messages (id, for_user, from_user, date, subject, text, new, action) VALUES ('', {$result['tribe']}, 0, {$orkTime}, 'Merge Request Rejected', " . quote_smart($message) . ", 'new', 'received')";
                            mysql_query($sqlquery);
                            echo "<p>Thank you for answering the request.</p>";
                        } else {
                            echo "<p>This tribe is no longer applying for a merge into your alliance.</p>";
                        }
                    } else {
                        echo "<p>The merge request no longer exists.</p>";
                    }
                } elseif (isset($_POST['do']) && $_POST['do'] == "yes") {
                    $iTargetAlli = intval($_POST['target']);
                    if (empty($iTargetAlli)) {
                        echo "<p>You have to fill in an alliance number that " . "you wish to merge into. Please try again. </p>";
                        unset($_POST['do']);
                        echo '</div>';
                        return;
                    } elseif ($iTargetAlli == $arrSrcStats[ALLIANCE]) {
                        echo "<p>You can not merge into your own alliance. " . "Please fill in another alliance number.</p>";
                        echo '</div>';
                        return;
                    } elseif ($iTargetAlli <= 10) {
                        echo "<p>You can not request to merge into a staff " . "alliance. Please fill in another alliance " . "number.</p>";
                        echo '</div>';
                        return;
                    }
                    $strSQL = "SELECT * FROM " . TBL_ALLIANCE . " WHERE id = " . $iTargetAlli;
                    if (mysql_num_rows(mysql_query($strSQL)) != 1) {
                        echo "<p>We're sorry, this alliance does not exist.</p>";
                        echo '</div>';
                        return;
                    }
                    $objTrgAlliance = new clsAlliance($iTargetAlli);
                    $arrUserids = $objTrgAlliance->get_userids();
                    if (count($arrUserids) >= MAX_ALLIANCE_SIZE) {
                        echo "<p>We're sorry, this alliance is full.</p>";
                        echo '</div>';
                        return;
                    } else {
                        // Default: no name change requested along with merger
                        $newtribename = $arrSrcStats[TRIBE];
                        $safetribename = quote_smart(stripslashes($newtribename));
                        if (isset($_POST['newtribename']) && !empty($_POST['newtribename'])) {
                            $safetribename = quote_smart(strip_tags(trim($_POST['newtribename'])));
                            $id = $objSrcUser->get_userid();
                            $check = mysql_query("SELECT * FROM stats WHERE tribe = {$safetribename} AND id != {$id}");
                            if (mysql_num_rows($check) != 0) {
                                echo "<p>Someone is already using that tribename.</p>";
                                echo '</div>';
                                return;
                            }
                            $message = "You have an awaiting merge request.<br /><br />" . $arrSrcStats[TRIBE] . " (#" . $arrSrcStats[ALLIANCE] . ") wishes to join your alliance.<br />They did also request a new name.<br /><br />Do you <a href= \"main.php?cat=game&amp;page=preferences&amp;task=request_merge&amp;checker=1&amp;mergerid=" . $arrSrcStats['id'] . "\">accept their request</a> or <a href= \"main.php?cat=game&amp;page=preferences&amp;task=request_merge&amp;checker=2&amp;mergerid=" . $arrSrcStats['id'] . "\">deny their request</a>?<br />";
                        } else {
                            $message = "You have an awaiting merge request.<br /><br />" . $arrSrcStats[TRIBE] . " (#" . $arrSrcStats[ALLIANCE] . ") wishes to join your alliance.<br /><br />Do you <a href=\"main.php?cat=game&amp;page=preferences&amp;task=request_merge&amp;checker=1&amp;mergerid=" . $arrSrcStats['id'] . "\">accept</a> or <a href=\"main.php?cat=game&amp;page=preferences&amp;task=request_merge&amp;checker=2&amp;mergerid=" . $arrSrcStats['id'] . "\">deny</a> their request?";
                        }
                        $iElderId = mysql_query("SELECT id FROM stats WHERE type = 'elder' AND " . ALLIANCE . " = {$iTargetAlli}");
                        $iElderId = mysql_fetch_array($iElderId);
                        $iElderId = $iElderId['id'];
                        if (!empty($iElderId)) {
                            mysql_query("INSERT INTO messages (id, for_user, from_user, date, subject, text, new, action) VALUES ('', {$iElderId}, 0, {$orkTime}, 'Merge Request', " . quote_smart($message) . ", 'new', 'received')");
                        } else {
                            echo "<p>There's no elder in this alliance!</p>";
                            echo '</div>';
                            return;
                        }
                        // Insert into mergers
                        mysql_query("INSERT INTO mergers (id, tribe, target, origin, auth, tribe_status, request_status, mtype, merge_time, newname, oldname, mod_id, declined_reason) VALUES ('', {$id}, {$iTargetAlli}, {$arrSrcStats[ALLIANCE]}, 0, " . quote_smart($arrSrcStats[TYPE]) . ", 'not ready', 1, {$orkTime}, {$safetribename}, " . quote_smart($arrSrcStats[TRIBE]) . ", '0', '0')") or die("Merger error");
                        echo "<p>The request was sent to the elder of (#" . $iTargetAlli . ")!</p>";
                    }
                } else {
                    include_once "inc/functions/war.php";
                    $warTarget = war_target($arrSrcStats[ALLIANCE]);
                    $strDate = $objSrcUser->get_gamestat(SIGNUP_TIME);
                    $iHours = $objSrcUser->get_user_info(HOURS);
                    $bAllow = TRUE;
                    if ($warTarget != 0) {
                        echo "<p>The option to merge is not available during war.</p>";
                        $bAllow = FALSE;
                    } elseif (strtotime("-6 weeks") < strtotime($strDate)) {
                        echo '<p>You may merge for another ' . ceil((strtotime($strDate) - strtotime("-6 weeks")) / 86400) . ' days.</p>';
                        $bAllow = TRUE;
                    } elseif ($iHours < 72) {
                        echo '<p>You may merge for another ' . ceil(abs(($iHours - 72) / 12)) . ' orkfian years';
                        $bAllow = TRUE;
                    }
                    if ($bAllow) {
                        echo $strForm = '<h3>Merging into another alliance</h3>' . '<form method="post" action="main.php?cat=game&amp;page=preferences&amp;task=request_merge">' . 'Alliance # you wish to request a merge with: ' . '<input type="text" size="4" name="target" maxlength="4" />' . '<br />' . 'New tribe name you want: ' . '<input type="text" size="16" name="newtribename" maxlength="30" /> (optional)' . '<br /><br />' . '<input type="hidden" name="do" value="yes" />' . '<input type="submit" value="Send merge request" />' . '</form>';
                    } elseif (strtotime("-6 weeks") > strtotime($strDate)) {
                        echo '<p>Currently your ruler is too old to merge.</p>';
                    }
                }
                echo $strRules = '<h3>Merger Rules</h3>' . '<ol>' . '<li>You may request a merge ' . 'anywhere, at any time, within 6 weeks after you ' . 'sign up</li>' . '<li>Veteran players may only merge before their ' . 'ruler age is 22 (within 3 days after restarting)' . '<li>Exception to rule #2: If you were <em>defected' . '</em> you may request a merges at any ruler age, but ' . 'only <em>after</em> 1 week</li>' . '<li>No one may merge during wars</li>' . '</ol>';
            } else {
                echo "<p>Currently merging is closed. You can not request/accept any more mergers.</p>";
            }
            break;
        case "delete_account":
            echo '<h2>Delete Account</h2>';
            include_once "inc/functions/war.php";
            $warTarget = war_target($arrSrcStats[ALLIANCE]);
            if ($warTarget > 0) {
                echo "<p>You are not allowed to delete during war.</p>";
                echo '</div>';
                return;
            }
            $arrSrcArmysOut = $objSrcUser->get_armys_out();
            if (array_sum($arrSrcArmysOut) > 0) {
                echo "<p>Sorry, you can not delete with troops out.</p>";
                echo '</div>';
                return;
            }
            if (isset($_GET['do']) && $_GET['do'] == "yes" && isset($_POST['checker'])) {
                echo "<p>It's so sad to see you go.</p>";
                //include_once("inc/functions/research.php");
                //delete_my_rps($iUserId);
                // no more - AI 07/05/07
                $objSrcUser->set_stat(NAME, 'deleted');
                $objSrcUser->set_stat(ALLIANCE, 0);
                mysql_query("DELETE FROM rankings_personal WHERE id = {$iUserId}");
                setcookie("userid", "");
                echo "<p>...Thank you for playing ORKFiA...</p>";
                // Alliance News
                $iAlliance = $objSrcUser->get_stat(ALLIANCE);
                $orkTime = date("YmdHis");
                $strSQL = "INSERT INTO news (id, time, ip, type, duser, ouser, result, text, kingdom_text, kingdoma, kingdomb) VALUES ('','{$orkTime}', '', 'Selfdeletion', 0, 0, 1, 'tribe deleted', '" . $arrSrcStats[TRIBE] . " deleted their tribe.', " . $iAlliance . ", {$iAlliance})";
                mysql_query($strSQL);
                echo '</div>';
                return;
            } else {
                $strForm = '<form method="post" action="main.php?cat=game&amp;page=preferences&amp;task=delete_account&amp;do=yes">' . 'Are you absolutely sure you want to <em>delete</em> your account? ' . '<input type="checkbox" name="checker" id="y1"> ' . '<label for="y1">(yes)</label>' . '<br /><br />' . 'This action is permanent and cannot be undone.' . '<br /><br />' . '<input type="submit" value="Delete my account">' . '</form>';
                echo $strForm;
            }
            break;
        case "reset_account":
            echo '<h2>Reset Account</h2>';
            include_once "inc/functions/war.php";
            $warTarget = war_target($arrSrcStats[ALLIANCE]);
            if ($warTarget > 0) {
                echo '<p>Sorry, you are not allowed to reset during war.</p>';
                echo '</div>';
                return;
            }
            $arrSrcArmysOut = $objSrcUser->get_armys_out();
            if (array_sum($arrSrcArmysOut) > 0) {
                echo '<p>Sorry, you cannot reset while you have troops out.</p>';
                echo '</div>';
                return;
            }
            if (isset($_GET['do']) && $_GET['do'] == "yes" && isset($_POST['checker'])) {
                // Mark tribe for resetting
                $objSrcUser->set_stat(RESET_OPTION, "'yes'");
                // Force update of rankings
                include_once 'inc/functions/update_ranking.php';
                doUpdateRankings($objSrcUser, 'yes');
                $strP = '<p>' . 'Your account has been reset!' . '</p><p>' . '<a href="main.php?cat=game&amp;page=tribe">' . 'Continue' . '</a>' . '</p>';
                echo $strP;
            } else {
                $strForm = '<form method="post" action="main.php?cat=game&amp;page=preferences&amp;task=reset_account&amp;do=yes">' . 'Are you absolutely sure you want to <em>reset</em> your account? ' . '<input type="checkbox" name="checker" id="1"> ' . '<label for="1">(yes)</label>' . '<br /><br />' . 'This action is permanent and cannot be undone.' . '<br /><br />' . '<input type="submit" value="Reset my account">' . '</form>';
                echo $strForm;
            }
            break;
        case "pause_account":
            echo '<h2>Pause Account</h2>';
            $PauseModeActive = $objGame->get_game_switch(PAUSE_MODE_ACTIVE);
            if ($PauseModeActive != 'on') {
                echo "<p><span class=positive>We're sorry, currently you may " . "not pause your account due to a global event.</span></p>";
                echo '</div>';
                return;
            }
            $arrSrcUserInfos = $objSrcUser->get_user_infos();
            if ($arrSrcUserInfos[PAUSE_ACCOUNT] == 0 && ($arrSrcUserInfos[NEXT_ATTACK] > 0 && $arrSrcUserInfos[HOURS] > 0)) {
                echo "<p>" . $arrSrcUserInfos[NEXT_ATTACK] . " hour(s) left before your troops are home.</p>";
                echo '</div>';
                return;
            }
            $arrSrcBuilds = $objSrcUser->get_builds();
            if ($arrSrcUserInfos[PAUSE_ACCOUNT] == 0 && ($arrSrcBuilds[LAND_T1] > 0 || $arrSrcBuilds[LAND_T2] > 0 || $arrSrcBuilds[LAND_T3] > 0 || $arrSrcBuilds[LAND_T4] > 0)) {
                echo "<p>You can't pause while land is incoming.</p>";
                echo '</div>';
                return;
            }
            if ($arrSrcUserInfos[PAUSE_ACCOUNT] > 49) {
                echo "<p>Your account will be paused in " . ($arrSrcUserInfos[PAUSE_ACCOUNT] - 49) . " updates, you will be able to unpause it in " . ($arrSrcUserInfos[PAUSE_ACCOUNT] - 1) . "</p>";
                echo '</div>';
                return;
            }
            if ($arrSrcUserInfos[PAUSE_ACCOUNT] > 1) {
                echo "<p>" . ($arrSrcUserInfos[PAUSE_ACCOUNT] - 1) . " updates left " . "until you may un-pause your account and play again.</p>";
                echo '</div>';
                return;
            }
            //             if($arrSrcUserInfos[PAUSE_ACCOUNT] == 1 && war_target($arrSrcStats[ALLIANCE]) > 0 )
            //             {
            //                 echo "<p>You cannot unpause during war.</p>";
            //                 echo '</div>';
            //                 return;
            //             }
            if (isset($_POST['do']) && $_POST['do'] == "yes") {
                // Pause Account Routines. Martel July 13, 2006
                $arrSrcUser = $objSrcUser->get_user_infos();
                if ($arrSrcUser[NEXT_ATTACK] <= 1) {
                    $arrSrcUser[NEXT_ATTACK] = 1;
                }
                $arrNewSrcUser = array(NEXT_ATTACK => $arrSrcUser[NEXT_ATTACK], PAUSE_ACCOUNT => 55);
                $objSrcUser->set_user_infos($arrNewSrcUser);
                // Empty Magic and Thievery Points
                $objSrcUser->set_spell(POWER, 0);
                $objSrcUser->set_thievery(CREDITS, 0);
                // Forced Ranking Update
                include_once 'inc/functions/update_ranking.php';
                doUpdateRankings($objSrcUser, 'yes');
                // M: Alliance news (March 07, 2008)
                $objSrcAlliance = $objSrcUser->get_alliance();
                $iWarTarget = $objSrcAlliance->get_war('target');
                // 0=default
                $iAllianceid = $objSrcAlliance->get_allianceid();
                mysql_query("INSERT INTO news (id, time, ip, type, duser, ouser, result, text, kingdom_text, kingdoma, kingdomb) VALUES ('', '{$orkTime}', '---', 'vacation', 0, 0, 1, '', '{$arrSrcStats['tribe']} (#{$iAllianceid}) is entering vacation mode', {$iAllianceid}, {$iWarTarget})");
                echo "<p>Your account has been paused, see you back in 2 or more days =)</p>";
                echo '</div>';
                return;
            } elseif (isset($_POST['do']) && $_POST['do'] == "no") {
                // Un-Pause Account Routines. Martel July 13, 2006
                $arrNewSrcUser = array(NEXT_ATTACK => 0, PAUSE_ACCOUNT => 0);
                $objSrcUser->set_user_infos($arrNewSrcUser);
                // M: Alliance news (March 07, 2008)
                $objSrcAlliance = $objSrcUser->get_alliance();
                $iWarTarget = $objSrcAlliance->get_war('target');
                // 0=default
                $iAllianceid = $objSrcAlliance->get_allianceid();
                mysql_query("INSERT INTO news (id, time, ip, type, duser, ouser, result, text, kingdom_text, kingdoma, kingdomb) VALUES ('', '{$orkTime}', '---', 'vacation', 0, 0, 1, '', '{$arrSrcStats['tribe']} (#{$iAllianceid}) is now back from vacation mode', {$iAllianceid}, {$iWarTarget})");
                echo "<p>Your account has been un-paused, we're glad to see you back =)</p>";
            } else {
                if ($arrSrcUserInfos[PAUSE_ACCOUNT] > 0) {
                    ?>
                <p>You are now allowed to un-pause your account.</p>
                <form method="post" action="main.php?cat=game&amp;page=preferences&amp;task=pause_account">
                    <input type="hidden" name="do" value="no">
                    <input type="submit" value="Leave Vacation Mode">
                </form>
<?php 
                } else {
                    ?>
                <h3>Vacation Mode Rules</h3>
                <ul>
                    <li>Entering Vacation Mode will take 6 hours</li>
                    <li>You <i>may</i> enter Vacation Mode during war</li>
                    <li>You may not enter Vacation Mode if you currently have
                    military out on an attack or if you have incoming acres</li>
                    <li>Your ruler will still age, but your account will be
                    protected during Vacation Mode</li>
                </ul>

                <form method="post" action="main.php?cat=game&amp;page=preferences&amp;task=pause_account">
                    <input type="hidden" name="do" value="yes">
                    <input type="submit" value="Enter vacation mode">
                </form>

                <p>Vacation Mode runs for 48 hours minimum. If you cannot enter
                VM with your account due to circumstances beyond your control,
                you may message a staff member in Law & Order requesting your
                account being suspended and a valid reason why you can't pause
                it yourself.</p>
<?php 
                }
            }
            break;
    }
    echo '</div>';
}
示例#8
0
function make_thievery(&$objSrcUser, &$objTrgUser, $local_action, $amount_sent, $amount_ops, $stop_on_success)
{
    global $HTTP_SERVER_VARS, $connection;
    check_to_update($objTrgUser->get_userid());
    if ($objTrgUser->get_stat(ALLIANCE) == 0) {
        echo "This player has been either deleted or suspended";
        include_game_down();
        exit;
    }
    //frost: global protection routine
    $global_protection = mysql_query("SELECT global_protection FROM admin_switches");
    $global_protection = mysql_fetch_array($global_protection);
    if ($global_protection['global_protection'] == "on") {
        echo "<br /><br /><br />Because of a global event all tribes in ORKFiA are under protection.<br />Please read the announcement in the forum.";
        include_game_down();
        exit;
    }
    mt_srand((double) microtime() * 1000000);
    $amount_sent = floor($amount_sent);
    if (!file_exists("inc/ops/" . $local_action . ".php")) {
        echo "Missing file: inc/ops/{$local_action}.php";
        include_game_down();
        exit;
    }
    $fn = "inc/ops/" . $local_action . ".php";
    include $fn;
    $kingdom = $objTrgUser->get_stat(ALLIANCE);
    if ($amount_sent <= 0) {
        echo "Not sending ANY thieves on a thievery mission doesn't accomplish much<br /><br />";
        echo "<a href=main.php?cat=game&page=thievery&kd={$kingdom}>Try again</a>";
        include_game_down();
        exit;
    }
    if ($objSrcUser->get_userid() == $objTrgUser->get_userid() && get_op_type() == "aggressive") {
        echo "You must choose an appropriate target.<br /><br />";
        echo "<a href=main.php?cat=game&page=thievery&kd={$kingdom}>Try again ?</a>";
        include_game_down();
        exit;
    }
    if ($objTrgUser->get_user_info(hours) < PROTECTION_HOURS && get_op_type() != "self") {
        $iRemaining = PROTECTION_HOURS - $objTrgUser->get_user_info(HOURS);
        $strProtectionMsg = '<div id="textMedium"><p>' . 'It appears that the tribe you wish to target is still ' . 'materializing. The head of our thieves estimates that it will ' . 'take another ' . $iRemaining . ' updates for the area to become ' . 'a stable part of reality.';
        echo $strProtectionMsg . "</p><p>";
        echo "<a href=main.php?cat=game&page=thievery&kd={$kingdom}>Try again ?</a>" . '</p></div>';
        include_game_down();
        exit;
    }
    if ($amount_ops <= 0) {
        echo '<div id="textMedium"><p>' . "You didn't do anything..." . "<p><a href=main.php?cat=game&page=thievery&kd={$kingdom}>Try again</a>" . '</p></div>';
        include_game_down();
        exit;
    }
    $credits = $objSrcUser->get_thievery(CREDITS);
    $op_cost = get_op_cost($local_action, $objSrcUser->get_build(LAND));
    if ($credits < $op_cost) {
        echo '<div id="textMedium"><p>' . "Sorry, every aggressive thievery operation " . "requires thievery points and you don't have enough to perform this type of operation.</p>" . "<p><a href=main.php?cat=game&page=thievery&kd={$kingdom}>Try again</a>" . '</p></div>';
        include_game_down();
        exit;
    }
    // Tried to send more operations than have op-credits
    if ($credits < $amount_ops * $op_cost) {
        $amount_ops = floor($credits / $op_cost);
    }
    if ($amount_sent > $objSrcUser->get_army_home(UNIT5)) {
        echo '<div id="textMedium"><p>' . "We don't have enough thieves to send even 1 operation in the way you've requested, please specify a different amount.</p>" . "<p><a href=main.php?cat=game&page=thievery&kd={$kingdom}>Try again</a>" . '</p></div>';
        include_game_down();
        exit;
    }
    if (!clsBlock::isOpAllowed($objSrcUser, $objTrgUser) && get_op_type() != "self") {
        echo '<div id="textMedium"><p>' . 'Someone else from the same IP has already opped this tribe during the last 8 hours.' . '</p><p>' . '<a href="main.php?cat=game&amp;page=thievery">Return</a>' . '</p></div>';
        clsBlock::reportOp($objSrcUser, $objTrgUser, 'Thief op: ' . $local_action, false);
        free_casting_now($iUserID);
        include_game_down();
        exit;
    }
    // Dragon 50% damage reduction. For war-bonusses change this modifier as well, instead of directly editing the ops-files.
    // -Martel wuz here- (50% reduction works now)
    include_once 'inc/functions/get.php';
    if ($objTrgUser->get_stat(RACE) == 'Dragon') {
        $modifier = 0.5;
    } else {
        $modifier = 1;
    }
    // War-check
    include_once "inc/functions/war.php";
    $warmodifier = war_alli($objTrgUser->get_stat(ALLIANCE), $objSrcUser->get_stat(ALLIANCE));
    if ($warmodifier > 1) {
        $modifier *= 1.1;
        if ($objSrcUser->get_spell(DEFIANCE) > 0) {
            $modifier *= 1.1;
        }
    }
    $target = war_target($objTrgUser->get_stat(ALLIANCE));
    if ($target != 0 && $warmodifier == 0) {
        $modifier *= 0.95;
    }
    $total_sent = $amount_ops * $amount_sent;
    // Ugly way of doing it... but here the div for the report starts. Timesaver.
    echo '<div id="textBig">' . '<h2>' . 'Thievery Report' . '</h2>' . '<p>';
    if ($total_sent > $objSrcUser->get_army_home(UNIT5)) {
        $amount_ops = floor($objSrcUser->get_army_home(UNIT5) / $amount_sent);
        echo "We don't have enough thieves to send that many operations, we've sent less instead.<br /><br />";
    }
    // GUARDHOUSES
    // Tragedy: april 20th 2002:
    // adding a cap of max 80% effectiveness on guardhouses, ergo max 20% of land
    $guard_percentage = min(0.2, $objTrgUser->get_build(GUARDHOUSES) / $objTrgUser->get_build(LAND));
    if (get_op_type() != "self") {
        $P_guard = $guard_percentage * 3.5;
    } else {
        $P_guard = 0;
    }
    //THIEVES TRAP
    //Species 5618: 17-01-2005
    //special self-op provides 15% thievery protection
    if ($objTrgUser->get_thievery(TRAP) > 0 && get_op_type() != "self") {
        $P_trap = 0.15;
    } else {
        $P_trap = 0;
    }
    $defthiefs = $objTrgUser->get_army_home(UNIT5);
    if ($defthiefs < 10) {
        $defthiefs = 10;
    }
    $d_user_tpa = $defthiefs / $objTrgUser->get_build(LAND);
    //Templars don't have thieves - AI 10/02/2007
    if ($objTrgUser->get_stat(RACE) == 'Templar') {
        $d_user_tpa = 0;
    }
    $off_thieves = $objSrcUser->get_army_home(UNIT5);
    $thieves_lost = 0;
    $cntOpSuccess = 0;
    $cntOF_total = 0;
    $cntOF_tpa = 0;
    $cntOF_gh = 0;
    $cntOF_trap = 0;
    $d_land = $objTrgUser->get_build(LAND);
    $o_land = $objSrcUser->get_build(LAND);
    for ($x = 1; $x <= $amount_ops; $x++) {
        if (get_op_type() == "aggressive") {
            $o_user_tpa = $off_thieves / $o_land;
            if ($d_user_tpa > 0.25) {
                $tpa_vs_tpa = $o_user_tpa / $d_user_tpa / 1.5;
            } else {
                $tpa_vs_tpa = 1;
            }
            $tpa_vs_tpa = min(max($tpa_vs_tpa, 0.05), 1);
            $chance = get_op_chance() / 100 * $tpa_vs_tpa;
            if ($o_land < 0.5 * $d_land || $o_land > 2 * $d_land) {
                $chance /= 2;
            }
            $P_tpa = 1 - $chance;
        } else {
            $P_tpa = 1 - get_op_chance() / 100;
        }
        $P_success = (1 - $P_tpa) * (1 - $P_guard) * (1 - $P_trap);
        //Randomly decide wether the op succeeds or fails.
        //When it fails, randomly choose a reason based on the relative failure-rates of all possible failure-reasons
        //Don't worry too much about the math behind it. It's correct and assures a fair distribution over the various 'reasons for failure'
        $P_fail_Total = $P_tpa + $P_guard + $P_trap;
        $P_fail_tpa = $P_tpa / $P_fail_Total;
        $P_fail_guard = $P_guard / $P_fail_Total;
        $P_fail_trap = $P_trap / $P_fail_Total;
        $random = rand(1, 10000) / 10000;
        if ($random < $P_success) {
            $cntOpSuccess++;
            //Stop-On-Success check
            if ($stop_on_success == "yes") {
                $amount_ops = $x;
                break;
            }
        } else {
            $cntOF_total++;
            //Why did the op fail ? TPA-diff or GH failure or Thieves Trap?
            $random = rand(1, 10000) / 10000;
            if ($random <= $P_fail_trap) {
                $cntOF_trap++;
                $thieves_lost += ceil($amount_sent * 0.05 * 1.3);
            } elseif ($random <= $P_fail_trap + $P_fail_guard) {
                $cntOF_gh++;
                $thieves_lost += ceil($amount_sent * (rand(5, 15) / 100));
            } else {
                $cntOF_tpa++;
                $thieves_lost += ceil($amount_sent * 0.05);
            }
        }
        //Lower amount of thieves so chances are correctly recalculated during the next iteration.
        $off_thieves -= $amount_sent;
    }
    if (get_op_type() == "self" && $local_action != "trap") {
        $thieves_lost = 0;
    }
    //Now call the actual op.
    //The $opResult return-value is an array consisting of 3 values:
    //- $opResult["fame"], fame gained/lost
    //- $opResult["text_screen"], text to be shown on screen
    //- $opResult["text_news"], text to be shown in enemy tribenews
    if ($local_action == "ambush" && $cntOpSuccess > 0) {
        $cntOpSuccess = 1;
    }
    if ($cntOpSuccess > 0) {
        $opResult = do_op($objSrcUser, $objTrgUser, $cntOpSuccess, $amount_sent, $modifier);
    } else {
        $opResult["fame"] = 0;
    }
    $total_sent = $amount_ops * $amount_sent;
    if ($thieves_lost > $total_sent) {
        $thieves_lost = $total_sent;
    }
    $plural1 = "";
    $plural2 = "was";
    if ($amount_ops > 1) {
        $plural1 = "s";
        $plural2 = "were";
    }
    $plural3 = "thief";
    if ($total_sent > 1) {
        $plural3 = "thieves";
    }
    echo "{$amount_ops} operation{$plural1}, a total of {$total_sent} {$plural3}, {$plural2} sent on its way.<br />";
    if ($cntOpSuccess == 1) {
        $plural = "";
        $plural3 = "was";
    } else {
        $plural = "s";
        $plural3 = "were";
    }
    if ($cntOF_total == 1) {
        $plural2 = "has";
    } else {
        $plural2 = "have";
    }
    echo "{$cntOpSuccess} operation{$plural} {$plural3} reported to be successful, {$cntOF_total} {$plural2} failed.<br /><br />";
    if ($cntOF_tpa == 1) {
        $plural = "";
        $plural2 = "has";
    } else {
        $plural = "s";
        $plural2 = "have";
    }
    if ($cntOF_tpa > 0 && get_op_type() == "aggressive" && $d_user_tpa != 0) {
        echo "{$cntOF_tpa} operation{$plural} {$plural2} failed because the enemy thieves intercepted ours.<br />";
    } elseif ($cntOF_tpa > 0 && get_op_type() == "aggressive" && $d_user_tpa == 0) {
        echo "{$cntOF_tpa} operation{$plural} {$plural2} failed because our thieves got spotted by enemy military.<br />";
    }
    if ($cntOF_gh == 1) {
        $plural = "";
        $plural2 = "has";
    } else {
        $plural = "s";
        $plural2 = "have";
    }
    if ($cntOF_gh > 0) {
        echo "Enemy guardstations caused {$cntOF_gh} operation{$plural} to fail<br />";
    }
    if ($cntOF_trap == 1) {
        $plural = "";
        $plural2 = "was";
    } else {
        $plural = "s";
        $plural2 = "were";
    }
    if ($cntOF_trap > 0) {
        echo "{$cntOF_trap} of our operations were caught by traps the enemy had set for us<br />";
    }
    if ($opResult["fame"] != 0) {
        $trgFame = $objTrgUser->get_stat(FAME);
        if ($opResult["fame"] > $trgFame) {
            $opResult["fame"] = $trgFame;
        }
        $newDFame = $trgFame - $opResult["fame"];
        $objTrgUser->set_stat(FAME, $newDFame);
        $newFame = $objSrcUser->get_stat(FAME) + $opResult["fame"];
        $objSrcUser->set_stat(FAME, $newFame);
    }
    if ($amount_ops != 1) {
        $plural = "these";
        $plural2 = "s";
    } else {
        $plural = "this";
        $plural2 = "";
    }
    if ($thieves_lost == 1) {
        $plural3 = 'f';
    } else {
        $plural3 = 'ves';
    }
    echo "With {$plural} operation{$plural2} we have gained <b class=positive>" . $opResult["fame"] . " fame</b> and lost " . number_format($thieves_lost) . " thie" . $plural3 . ".<br /><br />";
    $dplayer = $objTrgUser->get_userid();
    $userid = $objSrcUser->get_userid();
    $tribe = stripslashes($objSrcUser->get_stat(TRIBE));
    $iSrcAid = $objSrcUser->get_stat(ALLIANCE);
    if ($cntOF_total > 0 && get_op_type() == "aggressive") {
        if ($cntOF_total > 1) {
            $plural = 's';
        } else {
            $plural = '';
        }
        $timestamp = date(TIMESTAMP_FORMAT);
        $ip = $HTTP_SERVER_VARS["REMOTE_ADDR"];
        $create['event'] = "INSERT INTO `news` (`id`, `time`, `ip`, `type`, `duser`, `ouser`, `result`, `text`, `kingdom_text`)\n                          VALUES ('', '{$timestamp}', '{$ip}', '{$local_action}', '{$dplayer}', '{$userid}', 'fail',\n                          'We have caught {$cntOF_total} operation{$plural} of enemy thieves from {$tribe} (#{$iSrcAid}) tresspassing on our land.','') ";
        $created['event'] = mysql_query($create['event'], $connection);
        //trigger news flag of defender
        $objTrgUser->set_user_info(LAST_NEWS, $timestamp);
    }
    if ($cntOpSuccess > 0) {
        if (get_op_type() == "aggressive") {
            // echo name and alli
            $strTrgTribe = stripslashes($objTrgUser->get_stat(TRIBE));
            $iTrgAlliance = $objTrgUser->get_stat(ALLIANCE);
            echo "As your thieves return from {$strTrgTribe} (#{$iTrgAlliance}) the foreman reports the following result:" . '</p>';
        } else {
            echo "The foreman of our thieves reports the following result:" . '</p>';
        }
        echo '<div style="padding: 0 15px">' . $opResult["text_screen"] . '</div>' . '<p>';
        if ($opResult["text_news"] != "") {
            $timestamp = date(TIMESTAMP_FORMAT);
            $ip = $HTTP_SERVER_VARS["REMOTE_ADDR"];
            $create['event'] = "INSERT INTO `news` (`id`, `time`, `ip`, `type`, `duser`, `ouser`, `result`, `text`, `kingdom_text`)\n                              VALUES ('', '{$timestamp}', '{$ip}', '{$local_action}', '{$dplayer}', '{$userid}', '1',\n                              '{$opResult['text_news']}','') ";
            $created['event'] = mysql_query($create['event'], $connection);
            //trigger news flag of defender
            $objTrgUser->set_user_info(LAST_NEWS, $timestamp);
        }
    }
    if (get_op_type() == "aggressive" || get_op_name() == "Thieves Trap (SELF)") {
        $total_cost = $amount_ops * $op_cost;
        $credits = $objSrcUser->get_thievery(CREDITS) - $total_cost;
        $objSrcUser->set_thievery(CREDITS, $credits);
    }
    $returning = $total_sent - $thieves_lost;
    $returnTime = 3;
    if ($objSrcUser->get_stat(RACE) == 'Spirit') {
        $returnTime = 2;
    }
    $col = UNIT5 . "_t" . $returnTime;
    $thievesout = $objSrcUser->get_milreturn($col);
    $objSrcUser->set_milreturn($col, $thievesout + $returning);
    $thievesleft = $objSrcUser->get_army(UNIT5) - $thieves_lost;
    $objSrcUser->set_army(UNIT5, $thievesleft);
    obj_test_for_kill($objTrgUser, $objSrcUser);
    if (get_op_type() != "self") {
        clsBlock::logOp($objSrcUser, $objTrgUser, 'Thief op: ' . $local_action);
    }
    echo '</p>' . '<p>' . '<a href="main.php?cat=game&amp;page=thievery&amp;kd=' . $kingdom . '">Return</a>' . '</p>' . '</div>';
}