예제 #1
0
function obj_test_for_kill(&$objTrgUser, &$objSrcUser)
{
    global $ip;
    // Minimize multi-kills - Martel December 30, 2007
    //  #1 Query DB for kill status (Don't use cached data) #2 Check citz
    $strSQL = 'SELECT killed FROM stats WHERE id = ' . $objTrgUser->get_userid();
    $arrRow = mysql_fetch_row(mysql_query($strSQL));
    if ($arrRow[0] == 0 && $objTrgUser->get_pop(CITIZENS) <= 0) {
        // Separate a reset tribe from a killed (1=age, 2=pk)
        $objTrgUser->set_stat(KILLED, 2);
        // Show kill message
        $arrTrgStats = $objTrgUser->get_stats();
        echo $strDiv = '<div id="textMedium">' . '<p>' . "Congratulations! You watch on as the last citizen of " . '<strong class="negative">' . stripslashes($arrTrgStats[TRIBE]) . ' (#' . $arrTrgStats[ALLIANCE] . ")</strong> dies and their empire crumbles in front of you." . '</p>' . '</div>' . '<br />';
        // Update SrcUser with +1 Kill
        $arrSrcStats = $objSrcUser->get_stats();
        $iKilled = $arrSrcStats[KILLS] + 1;
        $objSrcUser->set_stat(KILLS, $iKilled);
        // Record: Largest Kill
        require_once 'inc/classes/clsGame.php';
        $objGame = new clsGame();
        $arrRecords = $objGame->get_game_records();
        $arrTrgBuilds = $objTrgUser->get_builds();
        if ($arrTrgBuilds[LAND] > $arrRecords[KILLED]) {
            $arrRecords = array(KILLED => $arrTrgBuilds[LAND], KILLED_ID => $objSrcUser->get_userid());
            $objGame->set_game_records($arrRecords);
        }
        // War effects
        require_once "inc/functions/war.php";
        $objSrcAlliance = $objSrcUser->get_alliance();
        if (checkWarBetween($objSrcAlliance, $arrTrgStats[ALLIANCE])) {
            $objTrgAlliance = $objTrgUser->get_alliance();
            // 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 - $arrTrgBuilds[LAND]));
            // Wait with adding this until it is 100% sure no multi kills exist
            //             if (($arrGains = testWarVictory($objSrcAlliance, $objTrgAlliance)))
            //             {
            //                 require_once('inc/pages/war_room2.inc.php');
            //                 $strGains = getVictoryReport($arrGains);
            //                 // Show war-win message
            //                 echo $strDiv =
            //                 '<div id="textMedium">' .
            //                     '<p><strong class="positive">Your alliance have won the war!</strong></p>' .
            //                     $strGains .
            //                 '</div>' .
            //                 '<br />';
            //             }
            // Add war-kill to global news
            $strGlobalNews = '<strong class="negative">Alliance #' . $arrSrcStats[ALLIANCE] . " has laid the final blow in " . $arrTrgStats[TRIBE] . "\\'s ORKFiA career during their war.</strong>";
            mysql_query("INSERT INTO news (id, time, ip, type, duser, ouser, " . "result, text, kingdom_text, kingdoma, kingdomb) " . "VALUES ('', NOW(), '---', 'global', 0, 0, 1, '', " . "'{$strGlobalNews}', 0, '')");
            // War events if a killed tribe is in the biggest half of the alli
            $iLand = $arrTrgBuilds[LAND];
            $arrRow1 = mysql_fetch_row(mysql_query("SELECT COUNT(id) FROM rankings_personal WHERE land > {$iLand} AND alli_id = " . $arrTrgStats[ALLIANCE]));
            $arrRow2 = mysql_fetch_row(mysql_query("SELECT COUNT(id) FROM rankings_personal WHERE alli_id = " . $arrTrgStats[ALLIANCE]));
            if ($arrRow1[0] * 2 < $arrRow2[0]) {
                require_once "inc/functions/update.php";
                //==============================================================
                // Bonus for the killing alliance: MP+TP gain, army
                // moved 1 hours closer to home
                //==============================================================
                // Since we don't seem to want a max to the mps/tps here,
                //  why not just add obj_mage_power_growth twice, same for
                //  thieves ofc                              - AI 25/11/2006
                //==============================================================
                $arrUserId = $objSrcAlliance->get_userids();
                foreach ($arrUserId as $iUserid) {
                    check_to_update($iUserid);
                    $objTmpUser = new clsUser($iUserid);
                    $build = $objTmpUser->get_builds();
                    // Bonus to Thievery Credits
                    require_once "inc/functions/ops.php";
                    $bonus1 = 2 * obj_thief_op_growth($objTmpUser);
                    $iNewCredits = $objTmpUser->get_thievery(CREDITS);
                    $iNewCredits += $bonus1;
                    // Bonus to Spell Power
                    require_once "inc/functions/spells.php";
                    $bonus2 = 2 * obj_mage_power_growth($objTmpUser);
                    $iNewPower = $objTmpUser->get_spell(POWER);
                    $iNewPower += $bonus2;
                    // Update User
                    $objTmpUser->set_thievery(CREDITS, $iNewCredits);
                    $objTmpUser->set_spell(POWER, $iNewPower);
                    // Update Military Training 1x time (Mori thieves)
                    $arrTmpStats = $objTmpUser->get_stats();
                    if ($arrTmpStats[RACE] == "Mori Hai") {
                        $arrMercs = $objTmpUser->get_army_mercs();
                        $arrNewMercs = array(MERC_T0 => $arrMercs[MERC_T1], MERC_T1 => $arrMercs[MERC_T2], MERC_T2 => $arrMercs[MERC_T3], MERC_T3 => 0);
                        $objTmpUser->set_army_mercs($arrNewMercs);
                    }
                    // Update Military Training 1x time (Everybody)
                    $arrRets = $objTmpUser->get_milreturns();
                    $arrNewRets = array(UNIT1_T1 => $arrRets[UNIT1_T2], UNIT1_T2 => $arrRets[UNIT1_T3], UNIT1_T3 => $arrRets[UNIT1_T4], UNIT1_T4 => 0, UNIT2_T1 => $arrRets[UNIT2_T2], UNIT2_T2 => $arrRets[UNIT2_T3], UNIT2_T3 => $arrRets[UNIT2_T4], UNIT2_T4 => 0, UNIT3_T1 => $arrRets[UNIT3_T2], UNIT3_T2 => $arrRets[UNIT3_T3], UNIT3_T3 => $arrRets[UNIT3_T4], UNIT3_T4 => 0, UNIT4_T1 => $arrRets[UNIT4_T2], UNIT4_T2 => $arrRets[UNIT4_T3], UNIT4_T3 => $arrRets[UNIT4_T4], UNIT4_T4 => 0, UNIT5_T1 => $arrRets[UNIT5_T2], UNIT5_T2 => $arrRets[UNIT5_T3], UNIT5_T3 => $arrRets[UNIT5_T4], UNIT5_T4 => 0, UNIT6_T1 => $arrRets[UNIT6_T2], UNIT6_T2 => $arrRets[UNIT6_T3], UNIT6_T3 => $arrRets[UNIT6_T4], UNIT6_T4 => 0);
                    $objTmpUser->set_milreturns($arrNewRets);
                    // Update Tribe News
                    $strNews = "The death of one of our enemies has given our " . "troops courage! Armies are returning more quickly, " . "thieves are more willing to risk their lives for the " . "tribe and your mage feels extra powerful.";
                    mysql_query("INSERT INTO news (time, ip, type, duser, " . "ouser, result, text, kingdom_text) VALUES " . "(NOW(), '---', 'local_news', {$iUserid}, '', " . "1, '{$strNews}','')");
                    $objTmpUser->set_user_info(LAST_NEWS, 1);
                }
                // Defiance for the losing alliance, gives bonuses to off/tm-dmg
                $arrUserId = $objTrgAlliance->get_userids();
                foreach ($arrUserId as $iUserid) {
                    check_to_update($iUserid);
                    $objTmpUser = new clsUser($iUserid);
                    $objTmpUser->set_spell(DEFIANCE, 4);
                    $strNews = "The death of one of our big tribes has filled the " . "hearts of our people with anger! For 4 more months " . "we will strike hard at our enemies!";
                    mysql_query("INSERT INTO news (time, ip, type, duser, " . "ouser, result, text, kingdom_text) VALUES " . "(NOW(), '---', 'local_news', {$iUserid}, '', " . "1, '{$strNews}','')");
                    $objTmpUser->set_user_info(LAST_NEWS, 1);
                }
            }
            //top half
        }
        //war
        // Create News
        $timestamp = date(TIMESTAMP_FORMAT);
        $d_news = '<strong class="negative">' . $arrSrcStats[TRIBE] . " (#" . $arrSrcStats[ALLIANCE] . ") has laid the final blow in " . $arrTrgStats[TRIBE] . "\\'s ORKFiA career.</strong>";
        $o_news = '<strong class="positive">Our ' . $arrSrcStats[TRIBE] . " has laid the final blow in " . $arrTrgStats[TRIBE] . " (#" . $arrTrgStats[ALLIANCE] . ")\\'s ORKFiA career.</strong>";
        $strNews = "I am sorry leader, upon your return to your tribe your alliance " . "has sent this message forth to you." . "<br /><br />" . $d_news . "<br /><br />" . "They have also sent us supplies and some citizens to restart " . "our tribe." . "<br /><br />" . "Below this line is news our previous tribe had recieved:";
        $strSQL = "INSERT INTO news (time, ip, type, duser, ouser, result, " . "text, kingdom_text, kingdoma, kingdomb) VALUES ('{$timestamp}', " . "'{$ip}', 'killed', {$arrTrgStats[ID]}, 0, 1, '{$strNews}', " . "'{$d_news}', '{$arrTrgStats[ALLIANCE]}', '')";
        mysql_query($strSQL);
        $strSQL = "INSERT INTO news (time, ip, type, duser, ouser, result, text, " . "kingdom_text, kingdoma, kingdomb) VALUES ('{$timestamp}', '{$ip}', " . "'killed', 0, 0, 1, '', '{$o_news}', '{$arrSrcStats[ALLIANCE]}', '')";
        mysql_query($strSQL);
        //======================================================================
        // Kill the tribe
        //======================================================================
        require_once 'inc/staff/delete.inc.php';
        doBackupTribe($objTrgUser->get_userid(), 'kill');
        obj_kill_user($objTrgUser);
    } else {
        return;
    }
}
예제 #2
0
function include_orkfiastats_text()
{
    global $orkTime;
    include_once 'inc/classes/clsGame.php';
    $objGame = new clsGame();
    $arrRecords = $objGame->get_game_records();
    $orkTime = date(TIMESTAMP_FORMAT);
    $old = $orkTime - 300;
    $result = mysql_query("SELECT id FROM online WHERE time > {$old}");
    $online = mysql_num_rows($result);
    $maxonline = max($online, $arrRecords[ONLINE]);
    //  $update = mysql_query("Update records set online = $maxonline where id = 1");
    $objGame->set_game_record(ONLINE, $maxonline);
    if ($arrRecords[AGESTART] < time()) {
        $age_time = time_since($arrRecords[AGESTART]);
    } else {
        $age_time = "Yet to start";
    }
    //  echo $age25 = mktime (0,0,0,04,13,2006); //hours,mins,secs,month,day,year
    $fetch1 = mysql_query("SELECT id FROM spells WHERE pest > 0");
    $fetch1 = mysql_num_rows($fetch1);
    $fetch2 = mysql_query("SELECT id FROM stats");
    $fetch2 = mysql_num_rows($fetch2);
    $fetch3 = mysql_query("Select alli_id,alli_name from rankings_personal,rankings_alliance where rankings_personal.id = {$arrRecords['grab_id']} and alli_id = rankings_alliance.id");
    $fetch3 = @mysql_fetch_array($fetch3);
    $fetch4 = mysql_query("Select alli_id,alli_name from rankings_personal,rankings_alliance where rankings_personal.id = {$arrRecords['arson_id']} and alli_id = rankings_alliance.id");
    $fetch4 = @mysql_fetch_array($fetch4);
    $fetch5 = mysql_query("Select alli_id,alli_name from rankings_personal,rankings_alliance where rankings_personal.id = {$arrRecords['killed_id']} and alli_id = rankings_alliance.id");
    $fetch5 = @mysql_fetch_array($fetch5);
    $fetch6 = mysql_query("Select alli_id,alli_name from rankings_personal,rankings_alliance where rankings_personal.id = {$arrRecords['fireball_id']} and alli_id = rankings_alliance.id");
    $fetch6 = @mysql_fetch_array($fetch6);
    $cursed = floor($fetch1 / $fetch2 * 10000);
    $cursed2 = $cursed / 100;
    $infected = $arrRecords[PEST] / 100;
    if ($cursed > $arrRecords[PEST]) {
        //      mysql_query("UPDATE records SET pest = $cursed WHERE id = 1");
        $objGame->set_game_record(PEST, $cursed);
        $infected = $cursed / 100;
    }
    $fetch3['alli_name'] = stripslashes($fetch3['alli_name']);
    $fetch4['alli_name'] = stripslashes($fetch4['alli_name']);
    $fetch5['alli_name'] = stripslashes($fetch5['alli_name']);
    $fetch6['alli_name'] = stripslashes($fetch6['alli_name']);
    // Empty results get their numbers so the game doesn't scream error at us ;)
    if (!isset($fetch3['alli_id'])) {
        $fetch3['alli_id'] = 0;
    }
    if (!isset($fetch4['alli_id'])) {
        $fetch4['alli_id'] = 0;
    }
    if (!isset($fetch5['alli_id'])) {
        $fetch5['alli_id'] = 0;
    }
    if (!isset($fetch6['alli_id'])) {
        $fetch6['alli_id'] = 0;
    }
    if ($online == "1") {
        $plural1 = "was";
        $plural2 = "";
    } else {
        $plural1 = "were";
        $plural2 = "s";
    }
    $check = mysql_query("Select * from build where id = {$arrRecords['grab_id']}");
    $check = @mysql_fetch_array($check);
    if ($check['land_t1'] == $arrRecords['grab'] || $check['land_t2'] == $arrRecords['grab'] || $check['land_t3'] == $arrRecords['grab'] || $check['land_t4'] == $arrRecords['grab']) {
        $fetch3['alli_name'] = "Hidden for now";
        $fetch3['alli_id'] = 0;
    }
    $orkStats = "<table cellspacing=\"0\" cellpadding=\"0\" class=\"medium\">" . "<tr class=\"header\">" . "<th>" . "Stats Running Time" . "</th>" . "</tr>" . "<tr class=\"data\">" . "<td class=\"center\">" . $age_time . "</td>" . "</tr>" . "</table>" . "<br />" . "<table cellspacing=\"0\" cellpadding=\"0\" class=\"medium\">" . "<tr class=\"header\">" . "<th colspan=\"2\">" . "Players Online" . "</th>" . "</tr>" . "<tr class=\"data\">" . "<td class=\"center\" colspan=\"2\">" . "There " . $plural1 . " " . $online . " player" . $plural2 . " online in the last 3 minutes.<br /><br />" . "</td>" . "</tr>" . "<tr class=\"data\">" . "<th>" . "Most online at one time:" . "</th>" . "<td>" . $maxonline . " Players" . "</td>" . "</tr>" . "</table>" . "<br />" . "<table cellspacing=\"0\" cellpadding=\"0\" class=\"medium\">" . "<tr class=\"header\">" . "<th colspan=\"2\">" . "Pestilence" . "</th>" . "</tr>" . "<tr class=\"data\">" . "<th>" . "Percentage Currently Infected:" . "</th>" . "<td>" . $cursed2 . "%" . "</td>" . "</tr>" . "<tr class=\"data\">" . "<th>" . "Highest Percentage Infected:" . "</th>" . "<td>" . $infected . "%" . "</td>" . "</tr>" . "</table>" . "<br />" . "<table cellspacing=\"0\" cellpadding=\"0\" class=\"medium\">" . "<tr class=\"header\">" . "<th colspan=\"2\">" . "Fireball" . "</th>" . "</tr>" . "<tr class=\"data\">" . "<th>" . "Most Damaging Fireball:" . "</th>" . "<td>" . $arrRecords[FIREBALL] . " Citizens" . "</td>" . "</tr>" . "<tr class=\"data\">" . "<th>" . "By Alliance:" . "</th>" . "<td>" . $fetch6['alli_name'] . "(#" . $fetch6['alli_id'] . ")" . "</td>" . "</tr>" . "</table>" . "<br />" . "<table cellspacing=\"0\" cellpadding=\"0\" class=\"medium\">" . "<tr class=\"header\">" . "<th colspan=\"2\">" . "Standard Attack" . "</th>" . "</tr>" . "<tr class=\"data\">" . "<th>" . "Most Acres Taken:" . "</th>" . "<td>" . $arrRecords[GRAB] . " Acres" . "</td>" . "</tr>" . "<tr class=\"data\">" . "<th>" . "By Alliance:" . "</th>" . "<td>" . $fetch3['alli_name'] . "(#" . $fetch3['alli_id'] . ")" . "</td>" . "</tr>" . "</table>" . "<br />" . "<table cellspacing=\"0\" cellpadding=\"0\" class=\"medium\">" . "<tr class=\"header\">" . "<th colspan=\"2\">" . "Arson" . "</th>" . "</tr>" . "<tr class=\"data\">" . "<th>" . "Most Damaging Arson:" . "</th>" . "<td>" . $arrRecords[ARSON] . " Homes" . "</td>" . "</tr>" . "<tr class=\"data\">" . "<th>" . "By Alliance:" . "</th>" . "<td>" . $fetch4['alli_name'] . "(#" . $fetch4['alli_id'] . ")" . "</td>" . "</tr>" . "</table>" . "<br />" . "<table cellspacing=\"0\" cellpadding=\"0\" class=\"medium\">" . "<tr class=\"header\">" . "<th colspan=\"2\">" . "Largest Kill" . "</th>" . "</tr>" . "<tr class=\"data\">" . "<th>" . "Largest Tribe Killed:" . "</th>" . "<td>" . $arrRecords[KILLED] . " Acres" . "</td>" . "</tr>" . "<tr class=\"data\">" . "<th>" . "By Alliance:" . "</th>" . "<td>" . $fetch5['alli_name'] . "(#" . $fetch5['alli_id'] . ")" . "</td>" . "</tr>" . "</table>";
    echo $orkStats;
}