Beispiel #1
0
function get_tribe_table(&$objUser)
{
    global $arrStats;
    include_once 'inc/functions/military.php';
    include_once 'inc/functions/races.php';
    include_once 'inc/functions/magic.php';
    include_once 'inc/functions/population.php';
    $arrBuild = $objUser->get_builds();
    $iAcres = $arrBuild[LAND];
    $iBarren = $objUser->get_barren();
    $arrStats = $objUser->get_stats();
    $arrGoods = $objUser->get_goods();
    $arrPopulation = getPopulation($objUser);
    $arrArmys = $objUser->get_armys();
    $iMageLevel = get_mage_level($objUser);
    $userid = $objUser->get_userid();
    $iStrength = $objUser->get_strength();
    $iRulerAge = getRulerAge($objUser);
    //     $iSpells        = getActiveSpells($objUser);
    $arrUnitVars = getUnitVariables($arrStats[RACE]);
    $arrUnitNames = $arrUnitVars['output'];
    $total_defence = getArmyDefence($objUser);
    $total_defence = $total_defence['raw'];
    $suicidal_offence = getArmyOffence($objUser);
    $suicidal_offence = $suicidal_offence['raw'];
    $offencePerAcre = ceil($suicidal_offence / $iAcres);
    $defencePerAcre = ceil($total_defence / $iAcres);
    $iMilitaryUnits = $arrArmys[UNIT1] + $arrArmys[UNIT2] + $arrArmys[UNIT3] + $arrArmys[UNIT4];
    //==========================================================================
    // Stop people from avoiding the tribe page so they dont get updated
    //==========================================================================
    include_once 'inc/functions/update_ranking.php';
    doUpdateRankings($objUser, 'yes');
    $strServerTime = date("H:i:s");
    $res = "<table class=\"medium\" cellpadding=\"0\" cellspacing=\"0\">" . "<tr class=\"header\">" . "<th colspan=\"5\">" . stripslashes($arrStats['tribe']) . " (#" . $arrStats['kingdom'] . ")" . "</th>" . "</tr>" . "<tr class=\"subheader\">" . "<th width=\"120px\">" . "Type" . "</th>" . "<td width=\"165px\">" . "Info" . "</td>" . "<td width=\"30px\">" . "&nbsp;" . "</td>" . "<th width=\"120px\">" . "Type" . "</th>" . "<td width=\"165px\">" . "Info" . "</td>" . "</tr>" . "<tr class=\"data\">" . "<th>" . "Ruler Age:" . "</th>" . "<td>" . $iRulerAge . " Years" . "</td>" . "<td>" . "&nbsp;" . "</td>" . "<th>" . "Fame:" . "</th>" . "<td>" . number_format($arrStats['fame']) . "</td>" . "</tr>" . "<tr class=\"data\">" . "<th>" . "Race:" . "</th>" . "<td>" . $arrStats['race'] . "</td>" . "<td>" . "&nbsp;" . "</td>" . "<th>" . "Strength:" . "</th>" . "<td>" . number_format($iStrength) . "</td>" . "</tr>" . "<tr class=\"data\">" . "<th>" . $arrUnitNames[1] . "s:" . "</th>" . "<td>" . number_format($arrPopulation['citizens']) . "</td>" . "<td>" . "&nbsp;" . "</td>" . "<th>" . "Military Units:" . "</th>" . "<td>" . number_format($iMilitaryUnits) . "</td>" . "</tr>" . "<tr class=\"data\">" . "<th>" . "Mage Level:" . "</th>" . "<td>" . $iMageLevel . "</td>" . "<td>" . "&nbsp;" . "</td>";
    if ($arrStats[RACE] == 'Templar') {
        $res .= "<th>" . "Mystics:" . "</th>";
    } else {
        $res .= "<th>" . "Thieves:" . "</th>";
    }
    $res .= "<td>" . number_format($arrArmys['unit5']) . "</td>" . "</tr>" . "<tr class=\"data\">" . "<th>" . "Raw Offence:" . "</th>" . "<td>" . $offencePerAcre . " OPA</td>" . "<td>" . "&nbsp;" . "</td>" . "<th>" . "Raw Defence:" . "</th>" . "<td>" . $defencePerAcre . " DPA</td>" . "</tr>" . "<tr class=\"data\">" . "<th>" . "Barren Land:" . "</th>" . "<td>" . number_format($iBarren) . "</td>" . "<td>" . "&nbsp;" . "</td>" . "<th>" . "Land:" . "</th>" . "<td>" . number_format($iAcres) . "</td>" . "</tr>" . "</table>" . '<div class="center" style="font-size: 0.8em">' . 'Server Time: ' . $strServerTime . '</div>';
    return $res;
}
Beispiel #2
0
function check_to_update($user)
{
    //==========================================================================
    //                                                     Martel, July 09, 2006
    // Use global src object if the source == the tribe triggering this update
    // (self update)
    //==========================================================================
    $objSrcUser =& $GLOBALS["objSrcUser"];
    if ($user != $objSrcUser->get_userid()) {
        $objUser = new clsUser($user);
    } else {
        $objUser =& $objSrcUser;
    }
    //==========================================================================
    // Calculate updates owed
    //==========================================================================
    $Last_update_hour = $objUser->get_user_info(LAST_UPDATE_HOUR);
    $Last_update_day = $objUser->get_user_info(LAST_UPDATE_DAY);
    //     $iTribeTick = $objUser->get_user_info(LAST_UPDATE_TICK);
    $day = date("d");
    $hour = date("H");
    $month = date("m");
    $year = date("y");
    $lmonth = $month - 1;
    if ($day < $Last_update_day) {
        if ($lmonth == 0) {
            $lmonth = 12;
        }
        if ($lmonth == 1 || $lmonth == 3 || $lmonth == 5 || $lmonth == 7 || $lmonth == 8 || $lmonth == 10 || $lmonth == 12) {
            $day = $day + 31;
        } elseif ($lmonth == 2) {
            if ($year % 4 == 0) {
                $day = $day + 29;
            } else {
                $day = $day + 28;
            }
        } elseif ($lmonth == 4 || $lmonth == 6 || $lmonth == 9 || $lmonth == 11) {
            $day = $day + 30;
        }
    }
    $iUpdatesOwed = ($day - $Last_update_day) * 24 + ($hour - $Last_update_hour);
    if ($iUpdatesOwed > 36) {
        $iUpdatesOwed = 36;
    }
    $objUser->set_user_info(LAST_UPDATE_DAY, date('d'));
    $objUser->set_user_info(LAST_UPDATE_HOUR, date('H'));
    //     $objUser->set_user_info(LAST_UPDATE_TICK, $iGameTick);
    // Preparing for new method to count owed updates
    include_once 'inc/classes/clsGame.php';
    $objGame = new clsGame();
    //     $iGameTick = $objGame->get_game_time(HOUR_COUNTER);
    //     $iUpdatesOwed = floor($iGameTick - $iTribeTick);
    //==========================================================================
    // FORGET UPDATES - setting updatesOwed to 0 is permanent and will be saved
    // Until the new update system is implemented this is the only feasible way.
    //==========================================================================
    if ($objGame->get_game_switch(GLOBAL_PAUSE) == ON) {
        $iUpdatesOwed = 0;
    }
    // Tribes who are either killed, waiting to be reset or paused
    $strReset = $objUser->get_stat(RESET_OPTION);
    $blnKilled = $objUser->get_stat(KILLED);
    $iPaused = $objUser->get_user_info(PAUSE_ACCOUNT);
    if ($strReset == 'yes' || $blnKilled == 1) {
        $iUpdatesOwed = 0;
    } elseif ($iPaused > 0) {
        // Counter to see how long tribe has left in "forced" protection
        // Expl: only after these updates a tribe can choose to un-pause
        $iPaused -= $iUpdatesOwed;
        if ($iPaused <= 1) {
            $iPaused = 1;
        }
        // Save the last update info
        $objUser->set_user_info(PAUSE_ACCOUNT, $iPaused);
    }
    //==========================================================================
    // Time to hand out updates...
    //==========================================================================
    if ($iUpdatesOwed > 0) {
        // 6 Week limit for Infinity ORKFiA                Martel, July 09, 2006
        $iHours = $objUser->get_user_info(HOURS);
        $objRace = $objUser->get_race();
        $intLifespan = $objRace->getLifespan();
        // M: Perform near-death updates until the tribe is dead
        if ($iHours + $iUpdatesOwed > $intLifespan) {
            include_once 'inc/functions/tribe.php';
            $blnReturn = FALSE;
            // Updates that should be used to determine chance of death
            $iMaxAfter100Owed = $iHours + $iUpdatesOwed - $intLifespan + $iUpdatesOwed;
            $iUpdatesAfter100Owed = min($iUpdatesOwed, $iMaxAfter100Owed);
            // Iterate through each update to see if it's time to die
            for ($i = 1; $i <= $iUpdatesAfter100Owed; $i++) {
                // Correct hour of news event
                $event = $iUpdatesAfter100Owed - $i;
                $event_time = date(TIMESTAMP_FORMAT, strtotime("-{$event} hours"));
                $iRand = rand(1, max(1, 24 - $iMaxAfter100Owed));
                if ($iRand == 1) {
                    // Give remaining updates to tribe
                    $iUpdatesOwedBeforeDeath = $i + ($iUpdatesOwed - $iUpdatesAfter100Owed);
                    call_update_script($iUpdatesOwedBeforeDeath, $objUser);
                    // For use in Alliance News
                    $iRulerAge = getRulerAge($objUser);
                    $strTribe = $objUser->get_stat(TRIBE);
                    // Code for death due to age
                    $objUser->set_stat(KILLED, 1);
                    obj_kill_user($objUser);
                    // Alliance News
                    $strAlliNews = "<b class=\"negative\">The ruler of " . $strTribe . " has died at an age of " . $iRulerAge . ".</b>";
                    $iShowAlli = $objUser->get_stat(ALLIANCE);
                    // Tribe News
                    $strTribeNews = "The death of the old and tired tribe ruler comes as " . "no surprise. Most citizens have left the lands, and " . "the leaderless military rampantly plundered what " . "they could. The citizens remaining wish to " . "contribute goods they hid to support your cause." . "<br /><br />" . $strAlliNews . "<br /><br />" . "Below are the news that your previous tribe recieved:";
                    $blnReturn = TRUE;
                } else {
                    $strAlliNews = '';
                    $iShowAlli = '';
                    $strTribeNews = 'Leader, your age is becoming a problem! The citizens ' . 'are preparing for the worst and your general openly ' . 'disobey you.';
                }
                $strSQL = 'INSERT INTO ' . "news" . ' SET ' . "time" . " = '{$event_time}', " . "type" . " = 'death', " . "duser" . " = {$user}, " . "result" . " = 1, " . "text" . " = '{$strTribeNews}', " . "kingdom_text" . " = '{$strAlliNews}', " . "kingdoma" . " = {$iShowAlli}";
                mysql_query($strSQL);
                if ($blnReturn) {
                    break;
                }
            }
        }
        // Vacation mode 48 hours (+6 hours enter-phase = 54 hours)
        if ($iPaused > 0 && $objUser->get_stat(KILLED) == 0) {
            // (Martel: paused accs will still age - "fair ranking" fix)
            $iNewHours = $objUser->get_user_info(HOURS) + $iUpdatesOwed;
            $objUser->set_user_info(HOURS, $iNewHours);
            // Only "forget" updates while in protection, not during enter-phase
            //                                  Bug-fix February 27, 2008 Martel
            if ($iPaused <= 48) {
                $iUpdatesOwed = 0;
            }
        }
        //======================================================================
        // Update Tribe
        // Martel: Moving this to a separate file            - February 27, 2008
        //======================================================================
        require_once 'inc/functions/update_script.php';
        generate_updates($objUser, $iUpdatesOwed);
    }
}