Пример #1
0
function getArmyDefence(&$objUser, $attack_type = '')
{
    $arrUnitInfo = getUnitVariables($objUser->get_stat(RACE));
    $arrUnitDefence = $arrUnitInfo['defence'];
    // Raw deffence
    $arrArmy = $objUser->get_armys();
    $raw_defence = $arrArmy[UNIT1] * $arrUnitDefence[2] + $arrArmy[UNIT2] * $arrUnitDefence[3] + $arrArmy[UNIT3] * $arrUnitDefence[4] + $arrArmy[UNIT4] * $arrUnitDefence[5] + $arrArmy[UNIT5] * $arrUnitDefence[6];
    // Bonus From Walls
    $arrBuildBonus = getBuildBonuses($objUser);
    $wall_bonus = floor($raw_defence * $arrBuildBonus['defence']);
    // Bonus From Science
    $arrSci = getSciences($objUser->get_stat(ALLIANCE));
    $research_bonus = floor($raw_defence * $arrSci['def']);
    // Bonus From Spells
    $arrSpellBonus = getSpellBonuses($objUser);
    $spell_bonus = floor($raw_defence * $arrSpellBonus['defence']);
    // Total
    $total = $raw_defence + $wall_bonus + $research_bonus + $spell_bonus;
    // Total Home
    $arrArmyHome = $objUser->get_armys_home();
    $raw_defence_home = $arrArmyHome[UNIT1] * $arrUnitDefence[2] + $arrArmyHome[UNIT2] * $arrUnitDefence[3] + $arrArmyHome[UNIT3] * $arrUnitDefence[4] + $arrArmyHome[UNIT4] * $arrUnitDefence[5] + $arrArmyHome[UNIT5] * $arrUnitDefence[6];
    // this'll add 15% to raw, fixed now - AI 16/11/06
    //if ($attack_type == ATTACK_RAID)
    //    $raw_defence_home *= 1.15;
    $home_raid = 0;
    if ($attack_type == ATTACK_RAID) {
        $home_raid = floor($raw_defence_home * 0.15);
    }
    $home_spell = floor($raw_defence_home * $arrSpellBonus['defence']);
    $home_research = floor($raw_defence_home * $arrSci['def']);
    $home_walls = floor($raw_defence_home * $arrBuildBonus['defence']);
    $total_home = $raw_defence_home + $home_spell + $home_research + $home_walls + $home_raid;
    $defence['raw'] = $raw_defence;
    $defence['building_bonus'] = $wall_bonus;
    $defence['research_bonus'] = $research_bonus;
    $defence['spell_bonus'] = $spell_bonus;
    $defence['total'] = $total;
    $defence['total_home'] = $total_home;
    return $defence;
}
Пример #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 getFoodProduction(&$objUser)
{
    $production = array();
    $strRace = $objUser->get_stat(RACE);
    $iOldFood = $objUser->get_good(FOOD);
    $iFarms = $objUser->get_build(FARMS);
    $food = 250;
    if ($strRace == "Dragon") {
        $food = 62.5;
    }
    $raw = $iFarms * $food;
    // Self Spell Bonus
    $update_spells = getSpellBonuses($objUser);
    $spell_bonus = round($raw * $update_spells['food']);
    // Research Bonus - New code                        January 09, 2008, Martel
    $arrResearch = getResearchBonuses($objUser->get_alliance());
    $research_bonus = round($raw * $arrResearch['food']);
    // Food Eaten
    $population = getPopulation($objUser);
    $used = $population['total_pop'] * 0.15;
    // Race Exceptions
    if ($strRace == 'Brittonian') {
        $used *= 0.5;
    } elseif ($strRace == 'Mori Hai') {
        $used *= 0.75;
    } elseif ($strRace == 'Spirit') {
        $used = 0;
    }
    //  0% for spirit
    // Food Rotten
    $decayed = floor($iOldFood * 0.0002);
    // Food Produced
    $total = $raw + $research_bonus + $spell_bonus - $used - $decayed;
    $production['per_each'] = $food;
    $production['raw'] = $raw;
    $production['research_bonus'] = $research_bonus;
    $production['spell_bonus'] = $spell_bonus;
    $production['used'] = $used;
    $production['decayed'] = $decayed;
    $production['total'] = $total;
    return $production;
}
Пример #4
0
function getCitizenIncome(&$objUser)
{
    $taxes = array();
    $strRace = $objUser->get_stat(RACE);
    $population = getPopulation($objUser);
    $citizens = $population['citizens'];
    $citizen_income = $citizens * 2;
    // Starvation = 50% Income
    $starvation = 0;
    $arrGoods = $objUser->get_goods();
    $production = getFoodProduction($objUser);
    if ($arrGoods[FOOD] + $production['total'] < 0 && $strRace != "Spirit") {
        $starvation = round($citizen_income * 0.5);
    }
    // Spell Bonus
    $update_spells = getSpellBonuses($objUser);
    $quanta_bonus = $update_spells['income'];
    $spell_income_bonus = round(($citizen_income - $starvation) * $quanta_bonus);
    // Total
    $total_income = $citizen_income - $starvation + $spell_income_bonus;
    $taxes['raw'] = $citizen_income;
    $taxes['starvation'] = $starvation;
    $taxes['spell_bonus'] = $spell_income_bonus;
    $taxes['total'] = $total_income;
    return $taxes;
}