Пример #1
0
function getArmyOffence(&$objUser)
{
    $arrUnitInfo = getUnitVariables($objUser->get_stat(RACE));
    $arrUnitOffence = $arrUnitInfo['offence'];
    // Raw offence
    $arrArmy = $objUser->get_armys();
    $raw_offence = $arrArmy[UNIT1] * $arrUnitOffence[2] + $arrArmy[UNIT2] * $arrUnitOffence[3] + $arrArmy[UNIT3] * $arrUnitOffence[4] + $arrArmy[UNIT4] * $arrUnitOffence[5] + $arrArmy[UNIT5] * $arrUnitOffence[6];
    // Bonus From Weaponries
    $arrBuildBonus = getBuildBonuses($objUser);
    $weapon_bonus = floor($raw_offence * $arrBuildBonus['offence']);
    // Bonus From Science
    $arrSci = getSciences($objUser->get_stat(ALLIANCE));
    $research_bonus = floor($raw_offence * $arrSci['war']);
    // Bonus From Spells
    $arrSpellBonus = getSpellBonuses($objUser);
    $spell_bonus = floor($raw_offence * $arrSpellBonus['offence']);
    // Bonus From Fame                                Martel, September 25, 2007
    $arrFameBonus = getFameBonuses($objUser);
    $fame_bonus = floor($raw_offence * $arrFameBonus['offence']);
    // Total
    $total = $raw_offence + $weapon_bonus + $research_bonus + $spell_bonus + $fame_bonus;
    // Total Out
    $arrArmyOut = $objUser->get_armys_out();
    $raw_offence_out = $arrArmyOut[UNIT1] * $arrUnitOffence[2] + $arrArmyOut[UNIT2] * $arrUnitOffence[3] + $arrArmyOut[UNIT3] * $arrUnitOffence[4] + $arrArmyOut[UNIT4] * $arrUnitOffence[5] + $arrArmyOut[UNIT5] * $arrUnitOffence[6];
    $out_spell = floor($raw_offence_out * $arrSpellBonus['offence']);
    $out_research = floor($raw_offence_out * $arrSci['war']);
    $out_weaponries = floor($raw_offence_out * $arrBuildBonus['offence']);
    $out_fame = floor($raw_offence_out * $arrFameBonus['offence']);
    $total_out = $raw_offence_out + $out_spell + $out_research + $out_weaponries + $out_fame;
    $offence['raw'] = $raw_offence;
    $offence['building_bonus'] = $weapon_bonus;
    $offence['research_bonus'] = $research_bonus;
    $offence['spell_bonus'] = $spell_bonus;
    $offence['fame_bonus'] = $fame_bonus;
    $offence['total'] = $total;
    $offence['total_out'] = $total_out;
    return $offence;
}
Пример #2
0
function getSentOffence(&$objUser, $arrArmySent)
{
    $arrUnitInfo = getUnitVariables($objUser->get_stat(RACE));
    $arrUnitOffence = $arrUnitInfo['offence'];
    // Raw offence
    $raw_offence = $arrArmySent[UNIT1] * $arrUnitOffence[2] + $arrArmySent[UNIT2] * $arrUnitOffence[3] + $arrArmySent[UNIT3] * $arrUnitOffence[4] + $arrArmySent[UNIT4] * $arrUnitOffence[5] + $arrArmySent[UNIT5] * $arrUnitOffence[6];
    // Bonus From Weaponries
    $arrBuildBonus = getBuildBonuses($objUser);
    $weapon_bonus = floor($raw_offence * $arrBuildBonus['offence']);
    // Bonus From Science
    $arrSci = getSciences($objUser->get_stat(ALLIANCE));
    $research_bonus = floor($raw_offence * $arrSci['war']);
    // Bonus From Spells
    $arrSpellBonus = getSpellBonuses($objUser);
    $spell_bonus = floor($raw_offence * $arrSpellBonus['offence']);
    // Bonus From Fame                                Martel, September 25, 2007
    $arrFameBonus = getFameBonuses($objUser);
    $fame_bonus = floor($raw_offence * $arrFameBonus['offence']);
    // Total
    $total = $raw_offence + $weapon_bonus + $research_bonus + $spell_bonus + $fame_bonus;
    return $total;
}
Пример #3
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;
}