Example #1
0
function building_names()
{
    global $build_cost, $building_output, $building_variables, $building_count, $objSrcUser;
    // Bad... but better... replace with above asap. globals are not nice
    $arrTemp = getBuildingVariables($objSrcUser->get_stat(RACE));
    $building_variables = $arrTemp['variables'];
    $building_output = $arrTemp['output'];
    $building_count = count($building_variables);
}
Example #2
0
function getStartValues($strRace, $iLand = STARTING_LAND)
{
    // Race housing effeciency
    include_once 'inc/functions/build.php';
    $arrBuildVariables = getBuildingVariables($strRace);
    $iCitzPerHome = $arrBuildVariables['housing'][1];
    // Units
    $arrInit[UNIT1] = floor($iLand * 0.8);
    $arrInit[UNIT2] = floor($iLand * 0.04);
    $arrInit[UNIT3] = floor($iLand * 0.04);
    $arrInit[UNIT4] = floor($iLand * 0.04);
    $arrInit[UNIT5] = floor($iLand * 0.4);
    //     $arrInit[UNIT6] = 0; // Mystic units
    // Buildings
    $arrInit[LAND] = $iLand;
    $arrInit[HOMES] = floor($iLand * 0.3);
    $arrInit[FARMS] = floor($iLand * 0.075);
    $arrInit[MARKETS] = floor($iLand * 0.07000000000000001);
    $arrInit[YARDS] = floor(1 + $iLand / 1000) * 40;
    $arrInit[GUILDS] = 10;
    $arrInit[HIDEOUTS] = 10;
    // Goods
    $arrInit[MONEY] = round(960 / PROTECTION_HOURS * $iCitzPerHome * $iLand);
    $arrInit[FOOD] = round(320 / PROTECTION_HOURS * $iCitzPerHome);
    $arrInit[WOOD] = round(200 / PROTECTION_HOURS * $iLand);
    $arrInit[RESEARCH] = 5000;
    // Citizens
    $arrInit[CITIZENS] = round(960 / PROTECTION_HOURS * $iCitzPerHome);
    // Fame
    $arrInit[FAME] = 5000;
    // Spells
    $arrInit[POPULATION] = round(PROTECTION_HOURS * 0.375);
    $arrInit[GROWTH] = round(PROTECTION_HOURS * 0.375);
    $arrInit['matawaska'] = round(PROTECTION_HOURS * 0.375);
    // actual name= food
    $arrInit[INCOME] = round(PROTECTION_HOURS * 0.375);
    // Classic exceptions
    if ($_SERVER['SERVER_NAME'] == DINAH_SERVER_NAME) {
        $arrInit[MONEY] = 300000;
        $arrInit[FOOD] = 5000;
        $arrInit[WOOD] = 25000;
        $arrInit[CITIZENS] = 5000;
    }
    // Race Exceptions
    if ($strRace == 'Spirit') {
        $arrInit['farms'] = 0;
    } elseif ($strRace == 'Templar') {
        $arrInit['hideouts'] = 0;
        //         $arrInit[UNIT5] = 0;
        //         $arrInit[UNIT6] = floor($iLand * .4);
    }
    return $arrInit;
}
Example #3
0
function get_construction_table(&$objUser)
{
    include_once 'inc/functions/build.php';
    $arrVars = getBuildingVariables($objUser->get_stat(RACE));
    $arrBuilds = $objUser->get_builds();
    $iBarren = $objUser->get_barren();
    $iTotal = $arrBuilds[LAND] - $iBarren;
    $strTd = '';
    for ($i = 1; $i <= 4; $i++) {
        $current = LAND . '_t' . $i;
        $strTd .= '<td';
        if ($arrBuilds[$current] > 0) {
            $strTd .= ' class="incoming"';
        }
        $strTd .= '>' . $arrBuilds[$current] . '</td>';
    }
    // Incoming Acres Table
    $strTable1 = "<table class=\"medium\" cellpadding=\"0\" cellspacing=\"0\">" . "<tr class=\"header\">" . "<th colspan=\"7\">" . "Incoming Acres" . "</th>" . "</tr>" . "<tr class=\"subheader\">" . "<th width=\"30%\">" . "Type" . "</th>" . "<td width=\"20%\" colspan=\"2\">" . "Ready" . "</td>" . "<td>" . "In 1" . "</td>" . "<td>" . "In 2" . "</td>" . "<td>" . "In 3" . "</td>" . "<td>" . "In 4" . "</td>" . "</tr>" . "<tr class=\"data\">" . "<th>" . "Barren Land:" . "</th>" . "<td>" . $iBarren . "</td>" . "<td>" . "(" . getBuildInPercent($objUser, $iBarren, 'yes') . "%)" . "</td>" . $strTd . "</tr>" . "</table><br />";
    // Under Construction Table (+ explore table)
    $strTable2 = $strTable1 . "<table class=\"medium\" cellpadding=\"0\" cellspacing=\"0\">" . "<tr class=\"header\">" . "<th colspan=\"7\">" . "Under Construction" . "</th>" . "</tr>" . "<tr class=\"subheader\">" . "<th width=\"30%\">" . "Type" . "</th>" . "<td width=\"20%\" colspan=\"2\">" . "Constructed" . "</td>" . "<td>" . "In 1" . "</td>" . "<td>" . "In 2" . "</td>" . "<td>" . "In 3" . "</td>" . "<td>" . "In 4" . "</td>" . "</tr>";
    for ($i = 1; $i <= count($arrVars['variables']); $i++) {
        $current = $arrVars['variables'][$i];
        $strTable2 .= "<tr class=\"data\">" . "<th>" . $arrVars['output'][$i] . ":" . "</th>" . "<td>" . number_format($arrBuilds[$current]) . "</td>" . "<td>" . "(" . getBuildInPercent($objUser, $arrBuilds[$current], 'yes') . "%)" . "</td>";
        for ($j = 1; $j <= 4; $j++) {
            $current2 = $current . '_t' . $j;
            $strTable2 .= '<td';
            if ($arrBuilds[$current2] > 0) {
                $strTable2 .= ' class="incoming"';
            }
            $strTable2 .= '>' . $arrBuilds[$current2] . '</td>';
        }
        $strTable2 .= "</tr>";
    }
    $strTable2 .= "<tr class=\"data\">" . "<th class=\"bsup\">" . "Constructed Land:" . "</th>" . "<td class=\"bsup\">" . $iTotal . "</td>" . "<td class=\"bsup\">" . "(" . getBuildInPercent($objUser, $iTotal, 'yes') . "%)" . "</td>" . "<td class=\"bsup\" colspan=\"4\">" . "&nbsp;" . "</td>" . "</tr>" . "</table>";
    return $strTable2;
}
Example #4
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;
}
function include_reset_account_text()
{
    global $Host;
    $objSrcUser =& $GLOBALS["objSrcUser"];
    $arrStats = $objSrcUser->get_stats();
    $iUserid = $objSrcUser->get_userid();
    $arrRaces = getActiveRaces();
    if ($arrStats[RESET_OPTION] == 'yes' || $arrStats[KILLED] > 0) {
        if (isset($_POST['submit'])) {
            $tribe = $_POST['tribe'];
            $tribe = addslashes(strip_tags(trim($tribe)));
            $race = $_POST['race'];
            // Leader should only be submitted 1 time, right after signing up
            if (isset($_POST['alias']) && !empty($_POST['alias'])) {
                $alias = $_POST['name'];
                $alias = addslashes(strip_tags(trim($alias)));
            } else {
                $alias = $arrStats[NAME];
            }
            // Validate form input
            if (!empty($tribe) && !empty($race) && in_array($race, $arrRaces)) {
                // Check that the new tribe name isn't already taken
                $check = mysql_query("SELECT * FROM " . TBL_STAT . " WHERE tribe = '{$tribe}' AND id != {$iUserid}");
                $check = mysql_fetch_array($check);
                $stat_search2 = mysql_query("SELECT * FROM " . TBL_STAT . " WHERE name = '{$alias}' AND id != {$iUserid}");
                $stat_search2 = mysql_fetch_array($stat_search2);
                if (isset($check[TRIBE])) {
                    $strDiv = '<div id="textSmall">' . '<p>' . 'Sorry, but that tribe name is already taken.' . '<br /><br />' . '<a href="main.php?cat=game&amp;page=reset_account">' . 'Try Again?' . '</a>' . '</p>' . '</div>';
                    echo $strDiv;
                } elseif (isset($stat_search2[NAME])) {
                    $strDiv = '<div id="textSmall">' . '<p>' . 'Sorry, but that leader name is already taken.' . '<br /><br />' . '<a href="main.php?cat=game&amp;page=reset_account">' . 'Try Again?' . '</a>' . '</p>' . '</div>';
                    echo $strDiv;
                } else {
                    //==========================================================
                    //                       Recoded November 07, 2007 by Martel
                    // Infinity: bonus on age death, Classic: bonus if killed
                    // Cause of death, 2=killed, 1=age, 0=reset
                    //==========================================================
                    $bBonus = FALSE;
                    if ($_SERVER['SERVER_NAME'] != DINAH_SERVER_NAME && $arrStats[KILLED] == 1) {
                        $bBonus = TRUE;
                    } elseif ($_SERVER['SERVER_NAME'] == DINAH_SERVER_NAME && $arrStats[KILLED] == 2) {
                        $bBonus = TRUE;
                    }
                    // Race housing effeciency
                    $arrBuildVariables = getBuildingVariables($race);
                    $homes_hold = $arrBuildVariables['housing'][1];
                    $ratio = 1;
                    // Death Bonus "Heritage"          Martel, November 07, 2007
                    if ($bBonus && $objSrcUser->get_kill(LAND) > STARTING_LAND) {
                        $arrKill = $objSrcUser->get_kills();
                        $ratio = $homes_hold / $arrKill[POP];
                        $iLand = $arrKill[LAND];
                        $arrCost = getUnitVariables($race);
                        $arrCost = $arrCost['gold'];
                        // New Heritage     (Age9) AI+Martel, September 25, 2007
                        $iLand = round(pow(max(0, $iLand - STARTING_LAND), 0.80459611995) + STARTING_LAND);
                        if ($iLand > 2000) {
                            $iLand = 2000;
                        } elseif ($iLand < STARTING_LAND) {
                            $iLand = $iLand;
                        }
                        // Buildings
                        $arrBonusValues[LAND] = $iLand;
                        // Goods
                        $arrBonusValues[RESEARCH] = 0;
                        //round(($arrKill[RESEARCH] / $arrKill[LAND]) * $land);
                        // Citizens
                        $arrBonusValues[CITIZENS] = round($iLand * 15 * $ratio);
                        // Fame
                        $arrBonusValues[FAME] = round($arrKill[FAME] * 0.04);
                        // Market Goods
                        $arrBonusValues[MONEY] = round($arrKill[CASH] * $ratio);
                        $arrBonusValues[UNIT1] = round($arrKill[BASICS] * $ratio);
                        $arrBonusValues[CREDITS] = round(2 * $arrBonusValues[MONEY] + (2 * $arrCost[2] + 15) * $arrBonusValues[UNIT1]);
                    } else {
                        $arrBonusValues[LAND] = 0;
                        $arrBonusValues[RESEARCH] = 0;
                        $arrBonusValues[CITIZENS] = 0;
                        $arrBonusValues[FAME] = 0;
                    }
                    //==========================================================
                    // Reset Tables (excluded from this reset is TBL_USER,
                    // TBL_STATS and TBL_PREFERENCES)
                    //==========================================================
                    $iNewLand = STARTING_LAND + $arrBonusValues[LAND];
                    include_once 'inc/functions/reset_account.php';
                    $arrStartValues = getStartValues($race, $iNewLand);
                    // User table (save old but set updates to start now)
                    $arrUsers = $objSrcUser->get_user_infos();
                    $arrNewUsers = array(HOURS => 0, LAST_LOGIN => date('Y-m-d H:i:s'), LAST_UPDATE_HOUR => date('H'), LAST_UPDATE_DAY => date('d'));
                    $objSrcUser->set_user_infos($arrNewUsers);
                    // Build Table
                    mysql_query("DELETE FROM build WHERE id = {$iUserid}") or die("build1");
                    mysql_query("INSERT INTO build SET id = {$iUserid}") or die("build2");
                    // add land + buildings (overrides hardcoded DB defaults)
                    $arrBuildsNew = array(LAND => $arrStartValues[LAND], HOMES => $arrStartValues[HOMES], FARMS => $arrStartValues[FARMS], MARKETS => $arrStartValues[MARKETS], YARDS => $arrStartValues[YARDS], GUILDS => $arrStartValues[GUILDS], HIDEOUTS => $arrStartValues[HIDEOUTS]);
                    $objSrcUser->set_builds($arrBuildsNew);
                    // Army Table
                    mysql_query("DELETE FROM army WHERE id = {$iUserid}") or die("army");
                    mysql_query("INSERT INTO army SET id = {$iUserid}") or die("army2");
                    // add military units (overrides hardcoded DB defaults)
                    $arrArmysNew = array(UNIT1 => $arrStartValues[UNIT1], UNIT2 => $arrStartValues[UNIT2], UNIT3 => $arrStartValues[UNIT3], UNIT4 => $arrStartValues[UNIT4], UNIT5 => $arrStartValues[UNIT5]);
                    $objSrcUser->set_armys($arrArmysNew);
                    // ArmyMercs Table
                    mysql_query("DELETE FROM army_mercs WHERE id = {$iUserid}") or die("army");
                    if ($race == "Oleg Hai" || $race == "Mori Hai") {
                        mysql_query("INSERT INTO army_mercs SET id = {$iUserid}") or die("army2");
                        if ($race == "Oleg Hai") {
                            mysql_query("UPDATE army SET unit4 = 0 WHERE id = {$iUserid}");
                        }
                    }
                    // Milreturn Table
                    mysql_query("DELETE FROM milreturn WHERE id = {$iUserid}") or die("milreturn");
                    mysql_query("INSERT INTO milreturn SET id = {$iUserid}") or die("milreturn2");
                    // Population Table
                    $iNewCitz = $arrStartValues[CITIZENS] + $arrBonusValues[CITIZENS];
                    $objSrcUser->set_pop(CITIZENS, $iNewCitz);
                    // Personal Rankings
                    mysql_query("DELETE FROM rankings_personal WHERE id = {$iUserid}") or die("milreturn");
                    mysql_query("INSERT INTO rankings_personal SET id = {$iUserid}") or die("milreturn2");
                    // Goods Table
                    mysql_query("DELETE FROM goods WHERE id = {$iUserid}") or die("goods");
                    mysql_query("INSERT INTO goods SET id = {$iUserid}") or die("goods2");
                    // Add modified starting values to Goods
                    $arrGoodsNew = array(MONEY => $arrStartValues[MONEY], FOOD => $arrStartValues[FOOD], WOOD => $arrStartValues[WOOD], RESEARCH => $arrStartValues[RESEARCH] + $arrBonusValues[RESEARCH]);
                    $objSrcUser->set_goods($arrGoodsNew);
                    // Spells Table
                    mysql_query("DELETE FROM spells WHERE id = {$iUserid}") or die("spells");
                    mysql_query("INSERT INTO spells SET id = {$iUserid}") or die("spells2");
                    // add basic self spells (overrides hardcoded DB defaults)
                    $arrSpellsNew = array(POPULATION => $arrStartValues[POPULATION], GROWTH => $arrStartValues[GROWTH], FOOD => $arrStartValues['matawaska'], INCOME => $arrStartValues[INCOME]);
                    $objSrcUser->set_spells($arrSpellsNew);
                    // Thievery Table
                    mysql_query("DELETE FROM thievery WHERE id = {$iUserid}") or die("thievery");
                    mysql_query("INSERT INTO thievery SET id = {$iUserid}") or die("thievery2");
                    // Kill Table
                    mysql_query("DELETE FROM kills WHERE id = {$iUserid}");
                    mysql_query("INSERT INTO kills SET id = {$iUserid}");
                    // Stats table (save old but update new tribe name & race)
                    $arrStats = $objSrcUser->get_stats();
                    $arrStatsNew = array(KILLED => 0, TRIBE => $tribe, RACE => $race, FAME => $arrStartValues[FAME] + $arrBonusValues[FAME], RESET_OPTION => "no", INVESTED => 0, KILLS => 0, TWG_VOTE => 0);
                    $objSrcUser->set_stats($arrStatsNew);
                    //==========================================================
                    // Add bonus to build, tribe goods & alliance market
                    //==========================================================
                    if ($bBonus) {
                        // add kill bonus to market credits
                        $arrGoodsNew = array(MARKET_MONEY => $arrBonusValues[MONEY], MARKET_SOLDIERS => $arrBonusValues[UNIT1], CREDITS => $arrBonusValues[CREDITS]);
                        $objSrcUser->set_goods($arrGoodsNew);
                        // alliance object
                        include_once 'inc/classes/clsAlliance.php';
                        $iAllianceId = $objSrcUser->get_stat(ALLIANCE);
                        $objSrcAlliance = new clsAlliance($iAllianceId);
                        // add bonus to alliance market
                        $arrAllianceInfos = $objSrcAlliance->get_alliance_infos();
                        $arrNewAllianceInfos = array(MONEY => $arrAllianceInfos[MONEY] + $arrBonusValues[MONEY], SOLDIERS => $arrAllianceInfos[SOLDIERS] + $arrBonusValues[UNIT1]);
                        $objSrcAlliance->set_alliance_infos($arrNewAllianceInfos);
                    }
                    // Update rankings (forced = yes)
                    include_once 'inc/functions/update_ranking.php';
                    doUpdateRankings($objSrcUser, 'yes');
                    $strDiv = '<div id="textSmall">' . '<p>' . 'Account updated =)' . '<br /><br />' . '<a href="main.php?cat=game&amp;page=tribe">' . 'Continue' . '</a>' . '</p>' . '</div>';
                    echo $strDiv;
                }
            } else {
                $strDiv = '<div id="textSmall">' . '<p>' . 'You forgot to enter a new tribe name and/or forgot to ' . 'choose a race.' . '<br /><br />' . '<a href="main.php?cat=game&amp;page=reset_account">' . 'Try Again?' . '</a>' . '</p>' . '</div>';
                echo $strDiv;
            }
        } else {
            $picture = 'defeat';
            if ($arrStats[KILLED] == 2) {
                $strMessage = '<p>' . stripslashes($arrStats[NAME]) . ', it seems that <strong class="negative">your last ' . 'citizens have left your tribe</strong>. ' . 'With them the last of your power is gone and so is your physical presence in the lands of Orkfia. But, within ' . PROTECTION_HOURS . ' ' . 'months you could once again do battle with your allies. ' . '</p>';
                $picture = 'defeat';
            } elseif ($arrStats[KILLED] == 0) {
                $strMessage = '<p>' . stripslashes($arrStats[NAME]) . ', it seems that <strong class="negative">you have ' . 'decided to reset</strong>. ' . 'The last of your power is gone and so is your physical presence in the lands of Orkfia. But, within ' . PROTECTION_HOURS . ' ' . 'months you could once again do battle with your allies. ' . '</p>';
                $picture = 'defeat';
            } elseif ($arrStats[KILLED] == 1) {
                $strMessage = '<p>' . stripslashes($arrStats[NAME]) . ', it seems that <strong class="positive">the leader ' . 'of your tribe has died due to age</strong>. ' . 'The last of your power is gone and so is your physical presence in the lands of Orkfia. But, within ' . PROTECTION_HOURS . ' ' . 'months you could once again do battle with your allies. ' . '</p>';
                $picture = 'victory';
            } elseif ($arrStats[KILLED] == 3) {
                $strMessage = '<p>' . 'Welcome! It seems that <strong class="positive">you are ' . 'about to create your first tribe in Orkfia</strong>. ' . 'Currently you have no physical presence in these lands. But, within ' . PROTECTION_HOURS . ' ' . 'months you could do battle together with your allies. ' . '</p>' . '<p>' . '<label for="1">' . 'Leader Name: ' . '</label>' . '<input id="1" name="name" size="20" maxLength="20">' . '</p>';
                $picture = 'victory';
            }
            $strForm = '<form method="POST" ' . 'action="main.php?cat=game&amp;page=reset_account">' . '<div id="textMedium">' . '<p style="text-align: center">' . '<img src="' . $Host . $picture . '_small.gif">' . '</p>' . $strMessage . '<p>' . 'Your account is now paused, time will start running once you submit the information below.' . '</p>' . '<p>' . '<label for="2">' . 'New Tribe Name: ' . '</label>' . '<input id="2" name="tribe" size="20" maxLength="20" value="' . stripslashes($arrStats[TRIBE]) . '">' . '</p>' . '<p>' . '<label for="3">' . 'Select Race: ' . '</label>' . '<select id="3" size="1" name="race">';
            foreach ($arrRaces as $strCurRace) {
                $strAdd = '';
                if ($arrStats[RACE] == $strCurRace) {
                    $strAdd = ' selected';
                }
                $strForm .= "<option value=\"{$strCurRace}\"{$strAdd}>" . $strCurRace . "</option>";
            }
            $strForm .= '</select> ' . '<a href="http://guide.orkfia.org/races.php?chapter=4" class="newWindowLink" target="_blank" style="cursor: help">Races</a>' . '</p>' . '<p>' . '<input type="submit" name="submit" value="Return to Orkfia!">' . '</p>' . '</div>' . '</form>';
            echo $strForm;
        }
    } else {
        // Kick someone in the butt for finding this page through address field
        include_once "inc/pages/logout.inc.php";
        include_logout_text();
    }
}
Example #6
0
function obj_kill_user(&$objUser)
{
    // Tag tribe to be restarted
    $objUser->set_stat(RESET_OPTION, 'yes');
    // Remove invested research
    //require_once("inc/functions/research.php");
    //delete_my_rps($objUser->get_userid());
    // no more - AI 07/05/07
    // Mail user to tell them they have been killed
    $strMail = "Unfortunately your tribe in ORKFiA has died. It is now ready " . "to be restarted." . "\n\n" . HOST . SIGNED_ORKFIA;
    $strEmail = stripslashes($objUser->get_preference(EMAIL));
    mail($strEmail, "Your tribe is no more =(", $strMail, "From: ORKFiA <" . EMAIL_REPORTER . ">\r\nX-Mailer: PHP/" . phpversion() . "\r\nX-Priority: Normal");
    // Calculate Re-starting Bonus
    // Species5618 (7-6-04): Setting a flag that marks the tribe as dead, so
    // that they do receive their age-death-bonus ("heritage") when they login
    if ($objUser->get_stat(KILLED) == 1 || $_SERVER['SERVER_NAME'] == DINAH_SERVER_NAME) {
        require_once 'inc/functions/population.php';
        $arrPopulation = getPopulation($objUser);
        require_once 'inc/functions/races.php';
        $strRace = $objUser->get_stat(RACE);
        $arrUnitVars = getUnitVariables($strRace);
        $arrUnitCost = $arrUnitVars['gold'];
        // Calculate the killed army's worth
        $total_value = $arrPopulation['basics'] * $arrUnitCost[2];
        $total_value += $arrPopulation['off_specs'] * $arrUnitCost[3];
        $total_value += $arrPopulation['def_specs'] * $arrUnitCost[4];
        $total_value += $arrPopulation['elites'] * $arrUnitCost[5];
        $total_value += $arrPopulation['thieves'] * $arrUnitCost[6];
        $total_value = round($total_value * 0.02);
        // Calculate the killed army in basics
        $total_troops = round($arrPopulation['total_army'] / 40);
        // Base Housing Capacities
        require_once 'inc/functions/build.php';
        $arrBuildVariables = getBuildingVariables($strRace);
        $homes_hold = $arrBuildVariables['housing'][1];
        // Add kill-bonus
        $iLand = $objUser->get_build(LAND);
        $fame = $objUser->get_stat(FAME);
        //Removed - AI 08/05/07
        //$research = $objUser->get_stat(INVESTED);
        $arrKills = array(LAND => $iLand, CASH => $total_value, BASICS => $total_troops, POP => $homes_hold, FAME => $fame);
        $objUser->set_kills($arrKills);
    }
    // Reset Tribe Rankings
    $arrRankingsPersonal = array(STRENGTH => 3000, LAND => STARTING_LAND, FAME => 5000, HOURS => 0);
    $objUser->set_rankings_personals($arrRankingsPersonal);
    // Update Alliance Rankings
    $objAlliance = $objUser->get_alliance();
    $objAlliance->do_update_ranking();
    // Set total land to what would be inherited (fix a science bug),
    //  we're using a hardcoded value here which just happens to be the same
    //  as the one used in inc/pages/reset_account.inc.php,
    //  this is a BAD THING                                      - AI 11/01/2006
    // Age changes coding - new heritage formula
    // Martel, September 16, 2007 (Plus also using constant and not '400')
    $iLand = $objUser->get_build(LAND);
    $iNewFormulaHeritage = round(pow(max(0, $iLand - STARTING_LAND), 0.80459611995) + STARTING_LAND);
    if (($objUser->get_stat(KILLED) == 1 || $_SERVER['SERVER_NAME'] == DINAH_SERVER_NAME) && $iNewFormulaHeritage > STARTING_LAND) {
        $iLand = $iNewFormulaHeritage;
    }
    if ($iLand > 2000) {
        $iLand = 2000;
    } elseif ($iLand < STARTING_LAND) {
        $iLand = STARTING_LAND;
    }
    // Save new land (to fix a science bug)
    $objUser->set_build(LAND, $iLand);
    // Reset other stuff too, so the tribe can be defected         - AI 02/12/06
    $objUser->set_user_info(PAUSE_ACCOUNT, 0);
}
Example #7
0
function include_build_text()
{
    global  $Host, $build_cost, $local_goods, $max_build,
            $local_build,
            $wood_cost, $output_building_percent, $building_percent,
            $buildings_due, $current, $sub_current1, $sub_current2,
            $sub_current3, $userid, $local_pop;

    $objSrcUser = &$GLOBALS["objSrcUser"];

    include_once('inc/functions/build.php');
//     mysql_grab($userid, 'local', 'goods', 'build', 'pop'); 1 1 down...
    $local_goods = $objSrcUser->get_goods();
    $local_build = $objSrcUser->get_builds();
    $local_pop = $objSrcUser->get_pops();
    build_cost();
    building_names();
    general_build();

    // New object oriented code

    $arrBuildingVariables = getBuildingVariables($objSrcUser->get_stat(RACE));

    $arrBuildVar     = $arrBuildingVariables['variables'];
    $arrBuildOutput  = $arrBuildingVariables['output'];
    $arrBuildTooltip = $arrBuildingVariables['tooltips'];
    $iBuildings      = count($arrBuildVar);
    $iBarren         = $objSrcUser->get_barren();

    //==========================================================================
    // Stop people from avoiding the tribe page so they dont get updated
    //==========================================================================
    include_once('inc/functions/update_ranking.php');
    doUpdateRankings($objSrcUser);

    $arrSrcStats = $objSrcUser->get_stats();
    $arrBuild = $objSrcUser->get_builds();

    echo $topLinks =
        '<div class="center">' .
            '<b>Construction</b> | ' .
            '<a href="main.php?cat=game&amp;page=army">Military Training</a> | ' .
            '<a href="main.php?cat=game&amp;page=explore">Exploration</a>' .
        '</div>';

    $advisorText =
        '<div id="textBig">' .
        '<p>' .
            "<b>Your tribe architect</b> greets you: <br />" .
            "To let your civilization grow and prosper, you must build your land. " .
            "How you build your land is completely up to you, " .
            "but some buildings are necessary for your people to survive." .
        "</p>" .
        "<p>" .
            "It will cost you <b>" . number_format($build_cost) . " crowns</b>" .
            " and <b>" . number_format($wood_cost) . " logs</b> to build on " .
            "<b>1 barren acre</b>." .
        '</p>' .
        '<p align="center">' .
            "You have <b><span class=\"indicator\">$iBarren</span> barren " .
            "acre(s)</b> and you can afford to " .
            "build on <b class=\"indicator\">$max_build</b>" .
            " of them." .
        "</p>" .
        "</div>";
    echo $advisorText;

    $advisorLinks =
        '<br />' .
        '<div class="tableLinkBig">' .
            '<a href="main.php?cat=game&amp;page=advisors&amp;show=build">Tribe Architect</a>' .
            ' :: ' .
            '<a href="main.php?cat=game&amp;page=raze_build">Demolish Buildings</a>' .
        '</div>';
    echo $advisorLinks;

    $buildTable =
        '<form id="center" action="main.php?cat=game&amp;page=build2" method="post" style="margin-top: 0pt;">' .
        '<table class="big" cellpadding="0" cellspacing="0">' .
            '<tr class="header">' .
                '<th colspan="9">' .'Order Construction' . '</th>' .
            '</tr>' .
            '<tr class="subheader">' .
                '<th>' . 'Type' . '</th>' .
                '<th class="right">' . 'Owned' . '</th>' .
                '<th class="right">' . '%' . '</th>' .
                '<th class="right">' . 'Build' . '</th>' .
                '<th class="right">' . '&nbsp;' . '</th>' .
                '<th>' . 'Type' . '</th>' .
                '<th class="right">' . 'Owned' . '</th>' .
                '<th class="right">' . '%' . '</th>' .
                '<th class="right">' . 'Build' . '</th>' .
            '</tr>';

    for ($i = 1; $i <= $iBuildings; $i++)
    {
        $current = $arrBuildVar[$i];
        $i2 = $i + 1;
        $current2 = $arrBuildVar[$i2];

        $buildTable .=
            '<tr class="data">' .
                '<th width="20%"><label for="' . $i . '" title="' . $arrBuildTooltip[$i] . '">' . $arrBuildOutput[$i] . '</label></th>' .
                '<td width="12%">';

        if ($buildings_due[$arrBuildVar[$i]] > 0)
        {
            $buildTable .=
                '<span style="font-size: 0.8em;">(' .
                $buildings_due[$arrBuildVar[$i]] .
                ')</span>';
        }

        $buildTable .=
                ' <strong>' . $local_build[$current] . '</strong></td>' .
                '<td width="7%">' .
                getBuildInPercent($objSrcUser, $local_build[$current], 'yes') .
                "</td>" .
                "<td width=\"7%\"><input id=\"$i\" size=\"3\" maxlength=\"4\" name=\"built[$current]\" /></td>" .
                "<td>&nbsp;</td>" .
                '<th width=\"20%\"><label for="' . $i2 . '" title="' . $arrBuildTooltip[$i2] . '">' . $arrBuildOutput[$i2] . '</label></th>' .
                "<td width=\"12%\" class=\"right\">";

        if ($buildings_due[$arrBuildVar[$i2]] > 0)
        {
            $buildTable .=
                '<span style="font-size: 0.8em;">(' .
                $buildings_due[$arrBuildVar[$i2]] . ")</span>";
        }

        $buildTable .=
                "<strong> $local_build[$current2]</strong>" . "</td>" .
                "<td width=\"7%\" class=\"right\">" .
                getBuildInPercent($objSrcUser, $local_build[$current2], 'yes') .
                "</td>" .
                "<td width=\"7%\" class=\"right\">" .
                "<input id=\"$i2\" size=\"3\" maxlength=\"4\" name=\"built[$current2]\" />" . "</td>" .
            "</tr>";
        $i++;
    }

    $buildTable .=
        "</table>";
    echo $buildTable;

?>
        <span style="font-size: 0.8em;">Total <b><?=$local_build[LAND]; ?></b> acres.</span>
        <br /><br />
        <input type="submit" value="Order Construction" />
    </form>
<?

}
Example #8
0
function doAttack(&$objSrcUser, &$objTrgUser, $arrSentArmy)
{
    $srcKd = $objSrcUser->get_stat(ALLIANCE);
    $trgKd = $objTrgUser->get_stat(ALLIANCE);
    $strSrcRace = $objSrcUser->get_stat(RACE);
    $iSrcLand = $objSrcUser->get_build(LAND);
    $arrTrgBuilds = $objTrgUser->get_builds();
    $gains = pow($arrTrgBuilds[LAND] / $iSrcLand, 2) + $arrTrgBuilds[LAND] / ($iSrcLand * 3);
    $gains = min($gains, 1);
    $quick_gains = 0.01 * $gains;
    // 1% Land Gain
    if ($strSrcRace == "Oleg Hai") {
        $quick_gains = $quick_gains * 1.3;
    }
    //==========================================================================
    // 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;
    for ($i = 1; $i <= $max_build; $i++) {
        $strVar = trim($arrBuildVars[$i]);
        $acres_won[$strVar] = round($arrTrgBuilds[$strVar] * $quick_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 = $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);
    //==========================================================================
    // Calculate Citizens Killed
    //==========================================================================
    $trgCits = $objTrgUser->get_pop(CITIZENS);
    $max_kill = $trgCits * 0.2;
    $trgRace = $objTrgUser->get_stat(RACE);
    if ($max_kill < $arrTrgBuilds[LAND] * 3 && $trgRace != "Dragon") {
        $max_kill = $arrTrgBuilds[LAND] * 3;
    } elseif ($max_kill < $arrTrgBuilds[LAND] * 2 && $trgRace == "Dragon") {
        $max_kill = $arrTrgBuilds[LAND] * 2;
    }
    // War effects on max kill
    include_once "inc/functions/war.php";
    $modifier = war_alli($srcKd, $trgKd);
    if ($modifier == 2) {
        $max_kill = $max_kill * 1.2;
    }
    // Martel: small bug fixed, $arrTrgBuilds not $arrTrgBuild
    $wallsPercent = $arrTrgBuilds[WALLS] * 100 / $arrTrgBuilds[LAND];
    if ($wallsPercent > 20) {
        $wallsPercent = 20;
    }
    // frost: age 18, each % walls shelters 2% citizen
    for ($y = 1; $y <= $wallsPercent; $y++) {
        $max_kill *= 0.98;
    }
    // Max citizens to kill == citizens available
    $max_kill = round($max_kill);
    if ($max_kill > $trgCits) {
        $max_kill = $trgCits;
    }
    if ($max_kill > 0) {
        $intCitizens_alive = $trgCits - $max_kill;
        $objTrgUser->set_pop(CITIZENS, $intCitizens_alive);
    } else {
        $max_kill = 0;
    }
    // Let's see if we killed the tribe
    include_once 'inc/functions/generic.php';
    obj_test_for_kill($objTrgUser, $objSrcUser);
    //==========================================================================
    // Calculate Cash Gains and Fame
    //==========================================================================
    $trgMoney = $objTrgUser->get_good(MONEY);
    $mod = 1;
    $stolen_crowns = round($trgMoney * 0.04);
    if ($arrTrgBuilds[LAND] > $iSrcLand) {
        $fame_win = round($total_grab * 1.0);
    } elseif ($arrTrgBuilds[LAND] < $iSrcLand * 0.7) {
        $fame_win = round(-$total_grab * 1.0);
        $mod = $arrTrgBuilds[LAND] * 1.3 / $iSrcLand;
    } else {
        $fame_win = round($total_grab * 1.2);
    }
    if ($mod < 0.7) {
        $mod = 0.7;
    }
    $max_crowns = round($arrTrgBuilds[LAND] * 500);
    $stolen_crowns = min(round($stolen_crowns * $mod), round($max_crowns));
    $objTrgUser->set_good(MONEY, $trgMoney - $stolen_crowns);
    $money = $objSrcUser->get_good(MONEY);
    $objSrcUser->set_good(MONEY, $money + $stolen_crowns);
    //==========================================================================
    // 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
    //==========================================================================
    // War effects
    $objSrcAlliance = $objSrcUser->get_alliance();
    require_once 'inc/functions/war.php';
    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;
    $arrResults['gained_crowns'] = $stolen_crowns;
    $arrResults['killed_citizens'] = $max_kill;
    return $arrResults;
}
Example #9
0
function getMaxPopulation(&$objUser)
{
    $population = array();
    $iAllianceId = $objUser->get_stat(KINGDOM);
    $strRace = $objUser->get_stat(RACE);
    $arrBuilds = $objUser->get_builds();
    // Base Housing Capacities
    include_once 'inc/functions/build.php';
    $arrBuildVars = getBuildingVariables($strRace);
    $homes_hold = $arrBuildVars['housing'][1];
    $extra_hold = $arrBuildVars['housing'][2];
    $hideouts_hold = $arrBuildVars['housing'][12];
    // Maximum number of homes that will house population
    if ($strRace != "Mori Hai") {
        $max_homes = floor($arrBuilds[LAND] * 0.3);
    } else {
        $max_homes = floor($arrBuilds[LAND] * 0.45);
    }
    if ($arrBuilds[HOMES] >= $max_homes) {
        $arrBuilds[HOMES] = $max_homes;
    }
    // Various other buildings house population too
    $other_buildings = $arrBuilds[FARMS] + $arrBuilds[WALLS] + $arrBuilds[WEAPONRIES] + $arrBuilds[GUILDS] + $arrBuilds[MINES] + $arrBuilds[MARKETS] + $arrBuilds[LABS] + $arrBuilds[CHURCHES] + $arrBuilds[GUARDHOUSES] + $arrBuilds[BANKS] + $arrBuilds[ACADEMIES] + $arrBuilds[YARDS];
    // Hideouts (is the same as other for most races)
    $hideouts = $arrBuilds[HIDEOUTS];
    // Raw Housing Capacity of Buildings
    $homes = $arrBuilds[HOMES] * $homes_hold;
    $hideouts *= $hideouts_hold;
    $other_buildings *= $extra_hold;
    $other_buildings += $hideouts;
    $total_room = $homes + $other_buildings;
    // Population Spell Bonus (Elendian)
    $spellBonuses = getSpellBonuses($objUser);
    $spell_bonus = round($total_room * $spellBonuses['population'], 0);
    // Research Bonus - New code                        January 09, 2008, Martel
    $arrResearch = getResearchBonuses($objUser->get_alliance());
    $research_bonus = round($total_room * $arrResearch['population']);
    // Population Fame bonus
    $arrFameBonuses = getFameBonuses($objUser);
    $fame_bonus = round($total_room * $arrFameBonuses['population']);
    // Total Population
    $total = floor($homes + $fame_bonus + $spell_bonus + $research_bonus + $other_buildings);
    // Max Citizens
    $arrPopulation = getPopulation($objUser);
    $max_citizens = floor($total - $arrPopulation['total_army']);
    // Total Citizens (How many citzizens there can be after update)
    $total_citizens = $arrPopulation['citizens'];
    // Get Growthrate
    $growthrate = getGrowthRate($objUser);
    $total_citizens = floor($total_citizens * $growthrate);
    if ($total_citizens > $max_citizens) {
        $total_citizens = $max_citizens;
    }
    if ($total_citizens < 200) {
        $total_citizens = 200;
    }
    $population['homes'] = $homes;
    // raw capacity of homes
    $population['extra_homes'] = $other_buildings;
    // raw of other buildings
    $population['total_raw'] = $total_room;
    $population['fame_bonus'] = $fame_bonus;
    $population['spell_bonus'] = $spell_bonus;
    $population['research_bonus'] = $research_bonus;
    $population['max_citizens'] = $max_citizens;
    $population['growth_rate'] = $growthrate;
    $population['total_citizens'] = $total_citizens;
    $population['total'] = $total;
    // total max population
    return $population;
}