예제 #1
0
function move_tribe($id, $target){
    $objSrcUser = new clsUser($id);
    $local_stats = $objSrcUser->get_stats();
    if ($target == 1 && $local_stats[LEVEL] < 5)
        $target = 2;

    mysql_query("UPDATE stats SET kingdom = $target, type ='player', invested = 0, vote = 0 where id = $id");
    mysql_query("UPDATE rankings_personal SET alli_id = $target where id = $id");
    mysql_query("UPDATE goods SET credits = 0, market_money = 0, market_food = 0, market_soldiers = 0, market_wood = 0 WHERE id = $id");

}
예제 #2
0
function include_thievery2_text()
{
    global $op, $dplayer, $action, $amount, $amount_sent, $stop;
    include_once 'inc/functions/ops.php';
    include_once 'inc/functions/thievery.php';
    $objSrcUser =& $GLOBALS["objSrcUser"];
    if ($objSrcUser->get_stat(RACE) == 'Templar') {
        echo '<div id="textMedium"><p>' . 'Your proud Templar people will not lower themselves to thievery practices.' . '</p></div>';
        include_game_down();
        exit;
    }
    if (!$dplayer) {
        $objTrgUser = $objSrcUser;
    } else {
        $objTrgUser = new clsUser($dplayer);
    }
    $arrTrgStats = $objTrgUser->get_stats();
    if ($arrTrgStats[KILLED] == 0 && $arrTrgStats[RESET_OPTION] != 'yes' && !$objTrgUser->isPaused()) {
        set_op_vars();
        // Verify attacker's status
        obj_check_protection($objSrcUser, 'thievery');
        $op_level = get_op_level($objSrcUser);
        if ($op > $op_level) {
            echo "Please Do Not Edit Forms";
            // make something to notifiy the admin if this happens
            include_game_down();
            exit;
        }
        make_thievery($objSrcUser, $objTrgUser, $action[$op], $amount_sent, $amount, $stop);
        //======================================================================
        // Report: War effects
        //======================================================================
        require_once 'inc/functions/war.php';
        $objSrcAlliance = $objSrcUser->get_alliance();
        if (checkWarBetween($objSrcAlliance, $objTrgUser->get_stat(ALLIANCE))) {
            $objTrgAlliance = $objTrgUser->get_alliance();
            if ($arrGains = testWarVictory($objSrcAlliance, $objTrgAlliance)) {
                // Append war-win message
                require_once 'inc/pages/war_room2.inc.php';
                echo $strReport = '<div id="textMedium">' . '<p><strong class="positive">Your alliance has won the war!</strong></p>' . getVictoryReport($arrGains) . '</div>';
            }
        }
    } else {
        echo $strDiv = '<div id="textMedium"><p>' . 'This tribe is either dead or paused.' . '<br /><br />' . '<a href="main.php?cat=game&page=thievery">' . 'Return' . '</a>' . '</p></div>';
    }
}
예제 #3
0
function send_mail($from_id, $to_id, $subject, $message)
{
    $orkTime = $GLOBALS['orkTime'];
    $objSrcUser = new clsUser($from_id);
    $objTrgUser = new clsUser($to_id);
    $arrSrcStats = $objSrcUser->get_stats();
    $arrTrgStats = $objTrgUser->get_stats();
    // we should check for the blocking system around here
    if (is_blocked_mail($from_id, $to_id)) {
        echo "<br /><br />You cannot mail {$arrTrgStats['tribe']} because you have been blocked from doing so.";
        include_game_down();
        exit;
    }
    $subject = safeHTML($subject);
    $message = safeHTML($message);
    $message = "{$message}<br /><br /><i>~{$arrSrcStats['tribe']}(#{$arrSrcStats['kingdom']})";
    if (!$subject) {
        $subject = "No Subject";
    }
    mysql_query("INSERT INTO messages (for_user, from_user, date, subject, text, new, action) VALUES ('{$to_id}', '{$from_id}', '{$orkTime}', '{$subject}', '{$message}', 'new', 'received')");
    mysql_query("INSERT INTO messages (for_user, from_user, date, subject, text, new, action) VALUES ('{$to_id}', '{$from_id}', '{$orkTime}', '{$subject}', '{$message}', 'new', 'sent')");
    echo "<h3>Message sent to {$arrTrgStats['tribe']}(#{$arrTrgStats['kingdom']})</h3><br />";
    mysql_query("UPDATE preferences SET last_m ='{$orkTime}' WHERE id = {$to_id}");
}
예제 #4
0
function get_market_history_table(&$objAlliance)
{
    $strMarketHistoryTable = "<table cellspacing=\"0\" cellpadding=\"0\" class=\"medium\">" . "<tr class=\"header\">" . "<th colspan=\"5\">" . "Market History" . "</th>" . "</tr>" . "<tr class=\"subheader\">" . "<th>" . "Tribe" . "</th>" . "<td>" . "Money" . "</td>" . "<td>" . "Food" . "</td>" . "<td>" . "Wood" . "</td>" . "<td>" . "Soldiers" . "</td>" . "</tr>";
    $arrSum = array(MARKET_MONEY => 0, MARKET_FOOD => 0, MARKET_WOOD => 0, MARKET_SOLDIERS => 0);
    $objTmpUser = new clsUser(1);
    foreach ($objAlliance->get_userids() as $iUser) {
        $objTmpUser->set_userid($iUser);
        // This might speed it up a bit.. Reuse
        $arrTmpGoods = $objTmpUser->get_goods();
        $arrTmpStats = $objTmpUser->get_stats();
        $strMarketHistoryTable .= "<tr class=\"data\">" . "<th>" . stripslashes($arrTmpStats[TRIBE]) . "</th>" . "<td>" . number_format($arrTmpGoods[MARKET_MONEY]) . "</td>" . "<td>" . number_format($arrTmpGoods[MARKET_FOOD]) . "</td>" . "<td>" . number_format($arrTmpGoods[MARKET_WOOD]) . "</td>" . "<td>" . number_format($arrTmpGoods[MARKET_SOLDIERS]) . "</td>" . "</tr>";
        // M: Add to total for each resource type
        foreach ($arrSum as $str => $i) {
            $arrSum[$str] += $arrTmpGoods[$str];
        }
    }
    $arrAlli = $objAlliance->get_alliance_infos();
    $strMarketHistoryTable .= "<tr class=\"data\">" . "<th class=bsup>" . "Unaccounted For:" . "</th>" . "<td class=bsup>" . number_format($arrAlli[MONEY] - $arrSum[MARKET_MONEY]) . "</td>" . "<td class=bsup>" . number_format($arrAlli[FOOD] - $arrSum[MARKET_FOOD]) . "</td>" . "<td class=bsup>" . number_format($arrAlli[WOOD] - $arrSum[MARKET_WOOD]) . "</td>" . "<td class=bsup>" . number_format($arrAlli[SOLDIERS] - $arrSum[MARKET_SOLDIERS]) . "</td>" . "</tr>" . "</table>";
    return $strMarketHistoryTable;
}
예제 #5
0
function make_magic2(&$objSrcUser, $i_intTargetid, &$arrSpells, $i_strSpellName, $i_intSpelltimes, $i_blnStopOnSuccess, $i_blnMinHours, $i_minHours)
{
    $iUserID = $objSrcUser->get_userid();
    $damageModifier = 1;
    mt_srand((double) microtime() * 1000000);
    $objTrgUser = new clsUser($i_intTargetid);
    $arrSrcStats = $objSrcUser->get_stats();
    $arrTrgStats = $objTrgUser->get_stats();
    $arrTrgBuild = $objTrgUser->get_builds();
    $intCasterMageLevel = get_mage_level($objSrcUser);
    $intTargetMageLevel = get_mage_level($objTrgUser);
    if ($arrTrgStats[ALLIANCE] == "0") {
        echo "This Player Has Either Been Deleted Or Suspended";
        free_casting_now($iUserID);
        include_game_down();
        exit;
    }
    // war check
    include_once "inc/functions/war.php";
    // Gotland was here
    $warmodifier = war_alli($objTrgUser->get_stat(ALLIANCE), $objSrcUser->get_stat(ALLIANCE));
    if ($warmodifier > 1) {
        $res = mysql_query("SELECT defiance FROM spells WHERE id = {$iUserID}");
        $line = mysql_fetch_assoc($res);
        $damageModifier = $damageModifier * 1.1;
        if ($line["defiance"] > 0) {
            $damageModifier = $damageModifier * 1.1;
        }
    }
    $target = war_target($arrTrgStats[ALLIANCE]);
    if ($target != 0 && $damageModifier == 0) {
        //what is this supposed to do? right now it does nothing at all - AI
        $damageModifier = $damageModifier * 0.95;
    }
    $lastWar = mysql_query("SELECT last_target, last_end FROM war WHERE id = " . $arrSrcStats[ALLIANCE]);
    $lastWar = mysql_fetch_array($lastWar);
    $timeCounter = mysql_query("SELECT hour_counter FROM admin_global_time");
    $timeCounter = mysql_fetch_array($timeCounter);
    // Spell type = SPELL_SELF, SPELL_ALLIANCE, SPELL_ENEMY etc (integers)
    $strSpellType = $arrSpells[$i_strSpellName]['type'];
    // Spell Display = full name of spell
    $strSpellDisplay = $arrSpells[$i_strSpellName]['display'];
    if ($arrTrgStats[ALLIANCE] == $lastWar['last_target'] && $strSpellType == SPELL_ENEMY) {
        if ($timeCounter['hour_counter'] <= $lastWar['last_end'] + 12) {
            echo '<div class="center">The war is not even over for 12 hours. Give them some time to recover!</div>';
            free_casting_now($iUserID);
            include_game_down();
            exit;
        }
    }
    include_once 'inc/functions/update.php';
    check_to_update($objTrgUser->get_userid());
    // Include the code for the spell about to be cast
    require_once "inc/spells/" . $i_strSpellName . ".php";
    // Check for casting "harmful" spells on yourself
    if ($iUserID == $objTrgUser->get_userid() && ($strSpellType == SPELL_ENEMY || $strSpellType == SPELL_ALL || $strSpellType == SPELL_WAR)) {
        echo '<div class="center">' . "I'm sorry you cannot cast " . $strSpellDisplay . " upon yourself.\n";
        echo "<br /><br /><br /><a href=main.php?cat=game&page=mystic&magekd=" . $objSrcUser->get_stat(ALLIANCE) . ">Back to Mystics</a></div>";
        free_casting_now($iUserID);
        include_game_down();
        exit;
    }
    // Martel: Heal may only target alliance members
    // SPELL_ALLIANCE only on allimates
    $iSrcAlli = $objSrcUser->get_stat(ALLIANCE);
    $iTrgAlli = $objTrgUser->get_stat(ALLIANCE);
    if ($strSpellType == SPELL_ALLIANCE && $iTrgAlli != $iSrcAlli) {
        echo '<div class="center">' . "Sorry but you cannot cast " . $strSpellDisplay . " on non-allies.<br />";
        echo "<br /><br /><br /><a href=\"main.php?cat=game&page=mystic&magekd=" . $objTrgUser->get_stat(ALLIANCE) . "\">Back to Mystics</a></div>";
        free_casting_now($iUserID);
        include_game_down();
        exit;
    }
    // SPELL_ENEMY not on own alli
    if ($strSpellType == SPELL_ENEMY && $iTrgAlli == $iSrcAlli) {
        echo '<div class="center">' . "Sorry, but I refuse to do harm to our alliance members.<br />";
        echo "<br /><br /><br /><a href=\"main.php?cat=game&page=mystic&magekd=" . $objTrgUser->get_stat(ALLIANCE) . "\">Back to Mystics</a></div>";
        free_casting_now($iUserID);
        include_game_down();
        exit;
    }
    // Check for target protection period
    if ($objTrgUser->get_user_info(HOURS) < PROTECTION_HOURS) {
        // Removed code-reuse of the copy-paste variety            - AI 30/09/06
        if ($strSpellType != SPELL_SELF) {
            $iRemaining = PROTECTION_HOURS - $objTrgUser->get_user_info(HOURS);
            echo '<div id="textMedium"><p>' . 'It appears that the tribe you wish to target is still ' . 'materializing. Our Mage estimates that it will take another ' . $iRemaining . ' updates for the area to become a stable part of ' . 'our reality.' . "</p><p>" . '<a href="main.php?cat=game&page=mystic&amp;magekd=' . $objTrgUser->get_stat(ALLIANCE) . '">Back to Mystics</a>' . '</p>' . '</div>';
            free_casting_now($iUserID);
            include_game_down();
            exit;
        }
    }
    // Check for own protection period (this is also checked in mystic2.inc.php
    if ($objSrcUser->get_user_info(HOURS) < PROTECTION_HOURS) {
        if ($strSpellType != SPELL_SELF) {
            echo '<div id="textMedium"><p>' . 'You are still under protection.' . "</p><p>" . '<a href="main.php?cat=game&page=mystic&amp;magekd=' . $objSrcUser->get_stat(ALLIANCE) . '">Back to Mystics</a>' . '</p>' . '</div>';
            free_casting_now($iUserID);
            include_game_down();
            exit;
        }
    }
    // Check for visioning a spirit
    if ($objTrgUser->get_stat(RACE) == 'Spirit' && $i_strSpellName == 'vision') {
        echo '<div id="textMedium"><p>' . "Your mystics are confused, they can't see anything at all." . "</p><p>" . '<a href="main.php?cat=game&page=mystic&amp;magekd=' . $objSrcUser->get_stat(ALLIANCE) . '">Back to Mystics</a>' . '</p>' . '</div>';
        free_casting_now($iUserID);
        include_game_down();
        exit;
    }
    // Check for casting jura on a Templar - AI 11/02/2007
    if ($objTrgUser->get_stat(RACE) == 'Templar' && $i_strSpellName == "juranimosity") {
        echo "Sorry, but " . $objTrgUser->get_stat(TRIBE) . " does not have any thieves for me to disband.";
        echo "<br /><br /><br /><a href=\"main.php?cat=game&amp;page=mystic&amp;magekd=" . $objTrgUser->get_stat(ALLIANCE) . ">Back to Mystics</a>";
        free_casting_now($iUserID);
        include_game_down();
        exit;
    }
    // check the user has cast it at lest 1 time
    if ($i_intSpelltimes <= 0) {
        echo "Sorry but you must cast this spell at least 1 time.<br />";
        echo "<br /><br /><br /><a href=main.php?cat=game&page=mystic&magekd=" . $objTrgUser->get_stat(ALLIANCE) . ">Back to Mystics</a>";
        free_casting_now($iUserID);
        include_game_down();
        exit;
    }
    // Added by Genia4, checks that the user didnt ask to cast a self-spell until it succeeds for less than 1 hours.
    if ($i_blnMinHours && $i_minHours <= 0) {
        echo "Sorry but you must tell your mage for how much time you want the self spell.<br />";
        echo "<br /><br /><br /><a href=main.php?cat=game&page=mystic&magekd=" . $objTrgUser->get_stat(ALLIANCE) . ">Back to Mystics</a>";
        free_casting_now($iUserID);
        include_game_down();
        exit;
    }
    // check the user has cast it no more than X times
    if ($i_intSpelltimes > MAX_SPELL_CASTS) {
        echo "Sorry but you can't auto-cast more than " . MAX_SPELL_CASTS . " times in a row in the interests of reducing server lag.<br />";
        echo "<br /><br /><br /><a href=main.php?cat=game&page=mystic&magekd=" . $objTrgUser->get_stat(ALLIANCE) . ">Back to Mystics</a>";
        free_casting_now($iUserID);
        include_game_down();
        exit;
    }
    // check they aren't trying to cast a spell beyond their level, they must've modified the
    // form directly to do this....TSKTSK!
    $iMageLevel = get_mage_level($objSrcUser);
    // Martel: Added age 22 to implement high acreage spells
    // And removed again - AI 30/09/06
    //$arrSrcBuild = $objSrcUser->get_builds();
    //$iTotalAcres = $arrSrcBuild[LAND];
    if ($iMageLevel < $arrSpells[$i_strSpellName]['level']) {
        echo "I'm sorry, you cannot cast " . $strSpellDisplay . ".";
        echo "<br /><br /><br /><a href=main.php?cat=game&page=mystic&magekd=" . $objSrcUser->get_stat(ALLIANCE) . ">Back to Mystics</a>";
        free_casting_now($iUserID);
        include_game_down();
        exit;
    }
    if (!clsBlock::isOpAllowed($objSrcUser, $objTrgUser) && $strSpellType != SPELL_SELF) {
        echo '<div id="textMedium"><p>' . 'Someone else from the same IP has already opped this tribe during the last 8 hours.' . '</p><p>' . '<a href="main.php?cat=game&amp;page=mystic">Return</a>' . '</p></div>';
        clsBlock::reportOp($objSrcUser, $objTrgUser, 'Spell: ' . $i_strSpellName, false);
        free_casting_now($iUserID);
        include_game_down();
        exit;
    }
    $intOldPower = $objSrcUser->get_spell(POWER);
    //Check for Thwart
    $trgThwart = 1;
    if ($strSpellType != SPELL_SELF) {
        $arrTrgSpells = $objTrgUser->get_spells();
        if ($arrTrgSpells[THWART] > 0) {
            $trgThwart = 0.75;
        }
    }
    //Churches
    // Tragedy: april 20th 2002:
    // adding a cap of max 80% effectiveness on churches, ergo max 20% of land
    $church_percentage = min(0.2, $arrTrgBuild['churches'] / $arrTrgBuild['land']);
    //frost: added high elves church bonus
    if ($objTrgUser->get_stat(RACE) == 'High Elf') {
        $church_bonus = $church_percentage * 4;
    } else {
        $church_bonus = $church_percentage * 3.5;
    }
    // Skathen: May 10th 2002:
    // Stop churches affecting self spells
    // Stop selected target affecting self spells
    // Martel: version 2.0, same purpose
    if ($strSpellType == SPELL_SELF) {
        //next line a small hack to prevent possible future bugs
        $objTrgUser = $objSrcUser;
        $church_bonus = 0;
        $trgThwart = 1;
        $intTargetMageLevel = 12 - $intCasterMageLevel;
        if ($intTargetMageLevel <= 4) {
            $intTargetMageLevel = 4;
        }
        if ($objSrcUser->get_user_info(HOURS) < PROTECTION_HOURS) {
            $intTargetMageLevel = 3;
        }
    }
    $chance_to_cast = formulate_chance($intCasterMageLevel, $intTargetMageLevel, $arrSpells[$i_strSpellName]);
    //==========================================================================
    // Main block - calculates success-rates, calls the specific spell-function
    //==========================================================================
    //How many spells can we cast ?
    //since we don't have 'infinity', we'll use an arbitrarily large number
    $totalAvailable = $arrSpells[$i_strSpellName]['cost'] > 0 ? floor($intOldPower / $arrSpells[$i_strSpellName]['cost']) : 9999999999.0;
    if ($totalAvailable > $i_intSpelltimes) {
        $totalAvailable = $i_intSpelltimes;
    }
    /* check the tribe still has the power to cast one time*/
    if ($totalAvailable <= 0) {
        echo '<div class="center">' . "I'm sorry, you don't have enough Magic Power to cast that spell.";
        echo "<br /><br /><br /><a href=main.php?cat=game&page=mystic&amp;magekd=" . $objTrgUser->get_stat(ALLIANCE) . ">Back to Mystics</a></div>";
        free_casting_now($iUserID);
        include_game_down();
        exit;
    }
    /* check for casting on a Nazgul, but only if its not a self spell */
    if ($strSpellType != SPELL_SELF && $objTrgUser->get_stat(RACE) == "Nazgul") {
        $nazgulBonus = 0.2;
    } else {
        $nazgulBonus = 0;
    }
    // added nazgul casting failures
    if ($objSrcUser->get_stat(RACE) == "Nazgul") {
        $nazgulPenalty = 0.25;
    } else {
        $nazgulPenalty = 0;
    }
    /* check for casting on a Dragon, casting on dragon gives 50% less damage */
    if ($objTrgUser->get_stat(RACE) == "Dragon") {
        $damageModifier *= 0.5;
    }
    // Roar of the horde fireball
    if ($strSpellType == SPELL_ENEMY && ($objTrgUser->get_stat(RACE) == "Uruk Hai" || $objTrgUser->get_stat(RACE) == "Oleg Hai" || $objTrgUser->get_stat(RACE) == "Mori Hai")) {
        $id = $objTrgUser->get_userid();
        $seek = mysql_query("Select * from spells where id = {$id}");
        $seek = mysql_fetch_array($seek);
        if ($seek['roar'] > 0 && $seek['forest'] == 0) {
            $rothBonus = 1 / 7;
        } else {
            $rothBonus = 0;
        }
    } else {
        $rothBonus = 0;
    }
    //Formulate the independent failure-chances. ML=magelevel, CH=Church-protection, race=race-protection, etc...
    $P_ML = 1 - $trgThwart * min($chance_to_cast, 290) / 300;
    $P_CH = $church_bonus;
    //$P_race1 -- used to be dragon protection
    $P_race2 = $nazgulBonus;
    $P_race3 = $nazgulPenalty;
    $P_roth = $rothBonus;
    // Martel: Adding exceptions here (alliance spell)
    if ($strSpellType == SPELL_ALLIANCE) {
        $P_CH = 0;
        $P_roth = 0;
    }
    //Calculate total chance of success per spell
    $P_success = (1 - $P_ML) * (1 - $P_CH) * (1 - $P_race2) * (1 - $P_race3) * (1 - $P_roth);
    //Loop through the number of spells casted, randomly decide wether it succeeds or fails.
    //When it fails, randomly choose a reason based on the relative failure-rates of all possible failure-reasons
    //Note that Stop-On-Success will be dealt with later on, by the spell-include-function
    $cntSpellSuccess = 0;
    $cntSF_total = 0;
    $cntSF_ML = 0;
    $cntSF_CH = 0;
    $cntSF_race2 = 0;
    $cntSF_race3 = 0;
    $cntSF_roth = 0;
    //Don't worry too much about the math behind it. It's correct and assures a fair distribution over the various 'reasons for failure'
    $P_fail_Total = $P_ML + $P_CH + $P_race2 + $P_race3 + $P_roth;
    $P_fail_ML = $P_ML / $P_fail_Total;
    $P_fail_CH = $P_CH / $P_fail_Total;
    $P_fail_race2 = $P_race2 / $P_fail_Total;
    $P_fail_race3 = $P_race3 / $P_fail_Total;
    $P_fail_roth = $P_roth / $P_fail_Total;
    if ($i_blnStopOnSuccess && $i_blnMinHours && $strSpellType == SPELL_SELF) {
        $i_blnStopOnSuccess = FALSE;
    }
    if ($i_blnMinHours && $strSpellType != SPELL_SELF) {
        $i_blnStopOnSuccess = TRUE;
    }
    for ($x = 1; $x <= $totalAvailable; $x++) {
        $random = rand(1, 10000) / 10000;
        if ($random < $P_success) {
            $cntSpellSuccess++;
            //Stop-On-Success check
            if ($i_blnStopOnSuccess == 1) {
                $totalAvailable = $x;
                break;
            }
        } else {
            $cntSF_total++;
            //Why did the spell fail ? Default ML-difference, CHs, race-protection, roth-protection, etc...
            $random = rand(1, 10000) / 10000;
            if ($random <= $P_fail_ML) {
                $cntSF_ML++;
            }
            if ($random > $P_fail_ML && $random <= $P_fail_ML + $P_fail_CH) {
                $cntSF_CH++;
            }
            if ($random > $P_fail_ML + $P_fail_CH && $random <= $P_fail_ML + $P_fail_CH + $P_fail_race2) {
                $cntSF_race2++;
            }
            if ($random > $P_fail_ML + $P_fail_CH + $P_fail_race2 && $random <= $P_fail_ML + $P_fail_CH + $P_fail_race2 + $P_fail_race3) {
                $cntSF_race3++;
            }
            if ($random > $P_fail_ML + $P_fail_CH + $P_fail_race2 + $P_fail_race3) {
                $cntSF_roth++;
            }
        }
    }
    // Ok, now we're done with calcing how many spells will succeed and why they will fail, we proceed to actually casting the spells
    // Call with: SpellCaster-object, Target-object, Spellname, Times-to-cast, Minimum-hours
    if (!$i_blnMinHours) {
        $minHours = 0;
    } else {
        $minHours = $i_minHours;
    }
    if ($cntSpellSuccess > 0) {
        $spellResult = cast_spell($objSrcUser, $objTrgUser, $arrSpells[$i_strSpellName], $cntSpellSuccess, $minHours, $damageModifier);
    } else {
        // Gotland: initialize the spellresult to avoid error message in case all attempts failed
        $spellResult["casted"] = 0;
        $spellResult["damage"] = 0;
        $spellResult["text_news"] = "";
        $spellResult["text_screen"] = "";
    }
    // $spellResult structure: (it's an array)
    // ["damage"] = 'Damage' done, could be used to calculate fame, not used for that right now.
    // ["casted"] = Amount of spells casted
    // ["text_screen"] = Return-text for the spell, to be outputted on the screen
    // ["text_news"] = text for the tribenews of the victim
    // Spend the mana and save back to to the db
    $manaSpent = ($spellResult["casted"] + $cntSF_total) * $arrSpells[$i_strSpellName]['cost'];
    $objSrcUser->set_spell(POWER, $intOldPower - $manaSpent);
    $dtTimestamp = date(TIMESTAMP_FORMAT);
    // Print out spell-casting-report
    if ($cntSpellSuccess == 0) {
        $spellResult["casted"] = 0;
    }
    $strReport = "<p>" . "Your mage has casted the spell " . ($spellResult["casted"] + $cntSF_total) . " times.<br />" . "He succeeded " . $spellResult["casted"] . " times and failed " . $cntSF_total . " times.<br />";
    if ($cntSF_ML > 0) {
        $strReport .= $cntSF_ML . " failures he blames on lack of training.<br />";
    }
    if ($cntSF_CH > 0) {
        $strReport .= $cntSF_CH . " of his cast-attempts were stopped by the Gods.<br />";
    }
    if ($cntSF_race2 > 0) {
        $strReport .= $cntSF_race2 . " spells failed due to ancient Nazgul protection.<br />";
    }
    if ($cntSF_race3 > 0) {
        $strReport .= $cntSF_race3 . " times your mage was hindered by our Nazgul curse.<br />";
    }
    if ($cntSF_roth > 0) {
        // Roar of the Hoard "fireball bonus"
        // M: Updated to use objects. August 05, 2007
        $citizens = $objSrcUser->get_pop(CITIZENS);
        $totalKilled = 0;
        for ($x = 1; $x <= $cntSF_roth; $x++) {
            $killed = ceil($citizens * 0.05);
            if ($citizens - $killed < 2000) {
                $killed = rand(10, 45);
            }
            if ($citizens - $killed < 100) {
                $killed = rand(2, 4);
            }
            if ($citizens - $killed < 50) {
                $killed = 0;
            }
            $citizens -= $killed;
            $totalKilled += $killed;
        }
        $objSrcUser->set_pop(CITIZENS, $citizens);
        $strReport .= '</p><p>Those orks must be under the influence of some spell. ' . $cntSF_roth . ' spells were returned by them in the form of ' . 'fireballs! <strong class="negative">' . number_format($totalKilled) . '</strong> citizens were killed.</p><p>';
    }
    if ($cntSpellSuccess > 0) {
        $strReport .= "</p><p>Your mage reports the following results:<br />";
        $strReport .= $spellResult["text_screen"] . "<br />";
    }
    if ($spellResult["damage"] == 0) {
        $intFameWon = fame_win($objSrcUser, $objTrgUser, 0);
    } else {
        if ($i_strSpellName == "enforced") {
            $fame = floor($spellResult["damage"] * 0.1);
        } else {
            $fame = floor($spellResult["casted"] * $arrSpells[$i_strSpellName][FAME]);
        }
        $intFameWon = fame_win($objSrcUser, $objTrgUser, $fame);
        $strReport .= "</p><p>Your Mage gained a total of <strong class='positive'>" . number_format($intFameWon) . " fame</strong>.</p><p>";
    }
    // Add spell-message to target tribenews
    if (isset($spellResult["text_news"])) {
        if ($spellResult["text_news"] != "" && $spellResult["casted"] > 0) {
            // Insert upwards compatibility with spells that do allinews
            //                                              - AI 02/12/06
            $strAlliMsgTemp = "";
            if (isset($spellResult["alli_news"])) {
                $strAlliMsgTemp = $spellResult["alli_news"];
            }
            $strMsgTemp = $spellResult["text_news"];
            insert_news_item($i_strSpellName, $objTrgUser->get_userid(), $iUserID, 2, $strMsgTemp, $strAlliMsgTemp);
            //trigger news flag of defender
            $objTrgUser->set_user_info(LAST_NEWS, 1);
        }
    }
    // Add failed-spells message to target tribenews
    if ($strSpellType != SPELL_SELF && $i_strSpellName != "vision" && $cntSF_total > 0) {
        if ($cntSF_total > 1) {
            $plural = "s";
        } else {
            $plural = "";
        }
        $strMsgTemp = "Our Mage has detected {$cntSF_total} failed " . $strSpellDisplay . " spell{$plural} coming from " . $arrSrcStats[TRIBE] . "(#" . $arrSrcStats[ALLIANCE] . ").";
        $strAlliMsgTemp = "";
        insert_news_item($i_strSpellName, $objTrgUser->get_userid(), $iUserID, 2, $strMsgTemp, $strAlliMsgTemp);
        //trigger news flag of defender
        $objTrgUser->set_user_info(LAST_NEWS, 1);
    }
    // Check for kill-by-fireball.
    if ($spellResult["damage"] <= -100) {
        obj_test_for_kill($objTrgUser, $objSrcUser);
    }
    // AI's block system
    if ($strSpellType != SPELL_SELF) {
        clsBlock::logOp($objSrcUser, $objTrgUser, 'Spell: ' . $i_strSpellName);
    }
    $strReport .= "</p>" . "<p>" . "<a href=main.php?cat=game&page=mystic&magekd=" . $objTrgUser->get_stat(ALLIANCE) . ">Back to Mystics</a>" . "</p>";
    // Print out the Report
    echo '<div id="textBig">' . '<h2>' . "Mystics Report " . '</h2>' . $strReport . '</div>';
    // As requested... Show spells on success. Will people ever be satisfied? :p
    if ($spellResult["casted"] > 0 && $strSpellType == SPELL_SELF) {
        include_once 'inc/pages/advisors.inc.php';
        echo '<br/>' . get_effecting_spells_table($objSrcUser);
    }
    free_casting_now($iUserID);
    include_game_down();
    exit;
}
예제 #6
0
function include_mystic2_text()
{
    include_once "inc/functions/magic.php";
    include_once "inc/functions/spells.php";
    include_once "inc/functions/news.php";
    $strSpellName = strval($_POST["selSpellname"]);
    $intSpellTimes = intval($_POST["txtAmount"]);
    $iTrgUserid = intval($_POST["selTarget"]);
    $minHours = intval($_POST["minHours"]);
    $blnStopOnSuccess = FALSE;
    if (isset($_POST["chkStop"]) && $_POST["chkStop"] == "yes") {
        $blnStopOnSuccess = TRUE;
    }
    // Species5618 19-2-2004: added processing of Minimum hours checkbox
    $blnMinHours = FALSE;
    if (isset($_POST["chkMin"]) && $_POST["chkMin"] == "yes") {
        $blnMinHours = TRUE;
    }
    $objSrcUser =& $GLOBALS["objSrcUser"];
    $arrSrcStats = $objSrcUser->get_stats();
    $arrSpells = set_spell_vars($objSrcUser);
    $strSpellType = $arrSpells[$strSpellName]['type'];
    // Can't cast damaging spells in protection
    if ($arrSpells[$strSpellName]['fame'] > 0) {
        obj_check_protection($objSrcUser, "magic");
    }
    if (empty($iTrgUserid) || $iTrgUserid == $objSrcUser->get_userid()) {
        if ($strSpellType == SPELL_SELF || $strSpellType == SPELL_ALLIANCE) {
            $iTrgUserid = $objSrcUser->get_userid();
        } else {
            echo '<div class="center">Please select a target.</div>';
            include_game_down();
            exit;
        }
    }
    include_once 'inc/functions/update.php';
    check_to_update($iTrgUserid);
    $objTrgUser = new clsUser($iTrgUserid);
    $arrTrgStats = $objTrgUser->get_stats();
    include_once "inc/functions/war.php";
    $modifier = war_alli($arrSrcStats[ALLIANCE], $arrTrgStats[ALLIANCE]);
    if ($modifier < 1 && $strSpellType == SPELL_WAR) {
        echo '<div class="center">' . 'War only spell, you cannot cast it on this target!' . '</div>';
        include_game_down();
        exit;
    }
    // M: Allow self spells even if target is paused
    if (($arrTrgStats[KILLED] > 0 || $arrTrgStats[RESET_OPTION] == 'yes') && $strSpellType != SPELL_SELF) {
        echo $strDiv = '<div id="textMedium"><p>' . 'This tribe is dead or has reset.' . '<br /><br />' . '<a href="main.php?cat=game&amp;page=mystic">' . 'Try Again ?' . '</a>' . '</p></div>';
    } elseif ($objTrgUser->isPaused() && $strSpellType != SPELL_SELF) {
        echo $strDiv = '<div id="textMedium"><p>' . 'This tribe is paused.' . '<br /><br />' . '<a href="main.php?cat=game&amp;page=mystic">' . 'Try Again ?' . '</a>' . '</p></div>';
    } else {
        // Doubleclick-protection. Sets a field in the DB when the script loads,
        // field will be turned "off" when the thing is done.
        // Added by Species5618, 10-3-2004
        $magic_busy = $objSrcUser->get_spell(CASTING_NOW);
        if ($magic_busy == BUSY) {
            echo $strDiv = '<div class="center">' . "Spells are being processed at the moment, please don't " . "doubleclick the button, even though the server might not " . "respond immediately." . '<br /><br />' . '<a href="main.php?cat=game&amp;page=mystic">' . 'Try Again ?' . '</a>' . '</div>';
            include_game_down();
            exit;
        } else {
            $objSrcUser->set_spell(CASTING_NOW, BUSY);
            make_magic2($objSrcUser, $iTrgUserid, $arrSpells, $strSpellName, $intSpellTimes, $blnStopOnSuccess, $blnMinHours, $minHours);
            // frost: 'free' casting_now is in inc/functions/magic.php, because
            // here it's getting ignored
        }
    }
}
예제 #7
0
function include_invade2_text()
{
    global $ip;
    $objSrcUser =& $GLOBALS["objSrcUser"];
    $arrSrcUser = $objSrcUser->get_user_infos();
    $arrSrcStats = $objSrcUser->get_stats();
    //==========================================================================
    // Secure user input from the invasion form
    //==========================================================================
    if (isset($_POST['TrgPlayer']) && !empty($_POST['TrgPlayer']) && $_POST['TrgPlayer'] != 'spacer') {
        // Selected Target
        $iTrgUserId = abs(intval($_POST['TrgPlayer']));
    } else {
        echo $strDiv = '<div id="textMedium"><p>' . "Your army walk back to their homes, you should give them a " . "target next time!" . '</p><p>' . '<a href="main.php?cat=game&page=invade">' . "Try Again ?" . "</a>" . '</p></div>';
        include_game_down();
        exit;
    }
    $arrWhite = array('1', '2', '3', '4', '5');
    $arrWhite2 = array(1 => 'standard', 'raid', 'barren', 'hitnrun', 'bc');
    // Selected Target
    if (isset($_POST['invade_type']) && in_array($_POST['invade_type'], $arrWhite)) {
        $iAttack = intval($_POST['invade_type']);
    } else {
        echo $strDiv = '<div id="textMedium"><p>' . "Your army walk back to their homes, you should give them a " . "target next time!" . '</p><p>' . '<a href="main.php?cat=game&page=invade">' . "Try Again ?" . "</a>" . '</p></div>';
        include_game_down();
        exit;
    }
    // Army Sent
    $arrUnitVars = getUnitVariables($arrSrcStats[RACE]);
    $arrUnitOffence = $arrUnitVars['offence'];
    $arrUnitVar = $arrUnitVars['variables'];
    if (isset($_POST["arrArmySent"])) {
        $arrArmySent = $_POST["arrArmySent"];
        foreach ($arrUnitOffence as $i => $iUnitOffence) {
            if ($iUnitOffence > 0) {
                $arrArmySent[$arrUnitVar[$i]] = max(0, intval($arrArmySent[$arrUnitVar[$i]]));
            } else {
                $arrArmySent[$arrUnitVar[$i]] = 0;
            }
        }
    }
    //==========================================================================
    // Verify attacker's status
    //==========================================================================
    obj_check_protection($objSrcUser, "invade");
    $iTotalSentArmy = array_sum($arrArmySent);
    if ($iTotalSentArmy < 1) {
        echo $strDiv = '<div id="textMedium"><p>' . 'Sorry, but you did not send any units to battle.<br />' . 'This attack has been aborted.' . '</p><p>' . '<a href="main.php?cat=game&page=invade">' . "Try Again ?" . "</a>" . '</p></div>';
        include_game_down();
        exit;
    }
    if (verifyArmyAvailable($objSrcUser, $arrArmySent) == 1) {
        echo $strDiv = '<div id="textMedium"><p>' . 'Sorry, you do not have that many units to send.<br />' . 'This attack has been aborted.' . '</p><p>' . '<a href="main.php?cat=game&page=invade">' . "Try Again ?" . "</a>" . '</p></div>';
        include_game_down();
        exit;
    }
    if ($arrSrcStats[RACE] == "Oleg Hai" && verifyArmyAvailableOleg($objSrcUser, $arrArmySent) == 1) {
        $mercsTrainedThisHour = $objSrcUser->get_army_merc(MERC_T3);
        echo $strDiv = '<div id="textMedium"><p>' . "Sorry, but you did only train {$mercsTrainedThisHour} " . "mercs this update and that's the maximum you may use for an " . "attack.<br />" . "This attack has been aborted." . '</p><p>' . '<a href="main.php?cat=game&page=invade">' . "Try Again ?" . "</a>" . '</p></div>';
        include_game_down();
        exit;
    }
    if ($arrSrcUser[NEXT_ATTACK] > 0) {
        echo $strDiv = '<div id="textMedium"><p>' . 'Sorry, but you cannot attack for at least ' . $arrSrcUser[NEXT_ATTACK] . ' more updates.' . '</p><p>' . '<a href="main.php?cat=game&page=invade">' . 'Try Again ?' . '</a>' . '</p></div>';
        include_game_down();
        exit;
    }
    if ($arrSrcUser[HOURS] < PROTECTION_HOURS) {
        echo $strDiv = '<div id="textMedium"><p>' . 'You are not allowed to attack while in protection!' . '</p><p>' . '<a href="main.php?cat=game&page=invade">' . 'Try Again ?' . '</a>' . '</p></div>';
        include_game_down();
        exit;
    }
    //==========================================================================
    // Verify defender's status
    //==========================================================================
    include_once 'inc/functions/update.php';
    check_to_update($iTrgUserId);
    $objTrgUser = new clsUser($iTrgUserId);
    $arrTrgStats = $objTrgUser->get_stats();
    if ($arrTrgStats[ALLIANCE] == $objSrcUser->get_stat(ALLIANCE)) {
        echo $strDiv = '<div id="textMedium"><p>' . 'Sorry, honor before might. Do not attack into your own alliance.' . '</p><p>' . '<a href="main.php?cat=game&page=invade">' . 'Try Again ?' . '</a>' . '</p></div>';
        include_game_down();
        exit;
    } elseif ($objTrgUser->get_stat(ALLIANCE) < 11) {
        echo $strDiv = '<div id="textMedium"><p>' . 'I hope you did not think that you would get away with ' . 'attacking into a staff alliance, did you?' . '</p><p>' . '<a href="main.php?cat=game&page=invade">' . 'Try Again ?' . '</a>' . '</p></div>';
        include_game_down();
        exit;
    }
    // Frost: Added a global protection mode
    include_once 'inc/classes/clsGame.php';
    $objGame = new clsGame();
    if ($objGame->get_game_switch(GLOBAL_PROTECTION) == 'on') {
        echo $strDiv = '<div id="textMedium"><p>' . 'Because of a global event all tribes in ORKFiA are under ' . 'protection. Please check the community forum for an announcement.' . '</p><p>' . '<a href="main.php?cat=game&page=invade">' . 'Try Again ?' . '</a>' . '</p></div>';
        include_game_down();
        exit;
    }
    $iTrgHours = $objTrgUser->get_user_info(HOURS);
    if ($iTrgHours < PROTECTION_HOURS) {
        $iTrgHoursRemaining = PROTECTION_HOURS - $iTrgHours;
        echo $strDiv = '<div id="textMedium"><p>' . 'It appears that the tribe you wish to target is still ' . 'materializing. Our general estimates that it will ' . 'take another ' . $iTrgHoursRemaining . ' updates for the area ' . 'to become a stable part of reality.' . '</p><p>' . '<a href="main.php?cat=game&page=invade">' . 'Try Again ?' . '</a>' . '</p></div>';
        include_game_down();
        exit;
    }
    if ($objTrgUser->get_stat(ALLIANCE) == 0) {
        echo $strDiv = '<div id="textMedium"><p>' . 'This player has either been deleted or suspended.' . '</p><p>' . '<a href="main.php?cat=game&page=invade">' . 'Try Again ?' . '</a>' . '</p></div>';
        include_game_down();
        exit;
    }
    // Frost: added jan -04
    // Martel: updated July 08, 2006
    if ($objTrgUser->get_stat(KILLED) == 1 || $objTrgUser->get_stat(RESET_OPTION) == 'yes') {
        echo $strDiv = '<div id="textMedium"><p>' . 'This tribe is dead.' . '</p><p>' . '<a href="main.php?cat=game&amp;page=invade">' . 'Try Again ?' . '</a>' . '</p></div>';
        include_game_down();
        exit;
    }
    // Paused account                                      Martel, July 13, 2006
    if ($objTrgUser->isPaused()) {
        echo $strDiv = '<div id="textMedium"><p>' . 'This tribe is paused.' . '</p><p>' . '<a href="main.php?cat=game&amp;page=invade">' . 'Return' . '</a>' . '</p></div>';
        return;
    }
    // Blocking system                          - AI 11/02/2007
    if (!clsBlock::isOpAllowed($objSrcUser, $objTrgUser)) {
        echo '<div id="textMedium"><p>' . 'Someone else from the same IP has already opped this tribe during the last 8 hours.' . '</p><p>' . '<a href="main.php?cat=game&amp;page=invade">Return</a>' . '</p></div>';
        clsBlock::reportOp($objSrcUser, $objTrgUser, 'Attack: ' . $arrWhite2[$iAttack], false);
        return;
    }
    $iTrgLand = $objTrgUser->get_build(LAND);
    $iSrcLand = $objSrcUser->get_build(LAND);
    $breakoff = round($iSrcLand * 0.7);
    // Barren attack has 70% bottom feed limit if smaller than 2000 acres
    if ($iAttack == ATTACK_BARREN && $iTrgLand <= $breakoff && $iTrgLand < 2000) {
        echo $strDiv = '<div id="textMedium"><p>' . 'Sorry but you can not bash the small ones. Barren grabs are not ' . 'allowed against smaller tribes unless they are within 70% ' . 'of your own size.' . '</p><p>' . '<a href="main.php?cat=game&page=invade">' . 'Try Again ?' . '</a>' . '</p></div>';
        include_game_down();
        exit;
    }
    if ($iAttack == ATTACK_HNR && $iTrgLand < $iSrcLand) {
        echo $strDiv = '<div id="textMedium"><p>' . 'What kind of coward are you who try to make a Hit \'n\' Run ' . 'attack against a smaller tribe?' . '</p><p>' . 'Shame on you!' . '</p><p>' . '<a href="main.php?cat=game&page=invade">' . 'Return' . '</a>' . '</p></div>';
        include_game_down();
        exit;
    }
    $quick_check = mysql_query("Select * from user where id = 1");
    $quick_check = mysql_fetch_array($quick_check);
    if ($quick_check[STOPGAMETRIGGER] == 99) {
        echo $strDiv = '<div id="textMedium"><p>' . 'The game has been paused by staff, possibly due to technical ' . 'maintenance. Please look in the announcements ' . 'forum or the admin game message for more information.' . '</p><p>' . '<a href="main.php?cat=game&page=invade">' . 'Return' . '</a>' . '</p></div>';
        include_game_down();
        exit;
    } else {
        //======================================================================
        // Do Battle
        //======================================================================
        /* include the code for the attack about to be done */
        include_once "inc/attacks/" . $arrWhite2[$iAttack] . ".php";
        // Damadm00 19-03-2004, check here the result from the viking check
        // Martel: Notify thieves about attack only if not viking+25% luck
        if ($arrSrcStats[RACE] == 'Viking' && getVikingCheck() == 1) {
            $viking = 1;
        } else {
            $viking = 0;
            getMonitoringCheck($objSrcUser);
        }
        include_once 'inc/functions/military.php';
        $defence = getArmyDefence($objTrgUser, $iAttack);
        $defence = $defence['total_home'];
        $offence = getSentOffence($objSrcUser, $arrArmySent);
        //Attacking Templars kills mystics, not thieves - AI
        $thieves = 'thieves';
        if ($objTrgUser->get_stat(RACE) == 'Templar') {
            $thieves = 'mystics';
        }
        // Eagle 30% auto force retreat feature
        if ($objTrgUser->get_stat(RACE) == "Eagle" && getEagleCheck() == 1) {
            doRetreat($objSrcUser, $objTrgUser, $arrArmySent, 1, 0);
            return;
        } elseif ($offence < $defence && $iAttack != ATTACK_HNR) {
            doRetreat($objSrcUser, $objTrgUser, $arrArmySent, 0, $viking);
            return;
        } elseif ($offence < $defence && $iAttack == ATTACK_HNR) {
            if ($offence > 0.5 * $defence) {
                if ($defence == 0) {
                    $defence = 1;
                }
                $arrSrcArmyLost = getSrcLosses($objSrcUser, $arrArmySent, $offence / $defence, $arrWhite2[$iAttack]);
                $arrTrgArmyLost = getTrgLosses($objTrgUser, $objSrcUser, $offence / $defence, $arrWhite2[$iAttack]);
                $arrReport = doAttack($objSrcUser, $objTrgUser, $arrArmySent);
            } else {
                doRetreat($objSrcUser, $objTrgUser, $arrArmySent, 0, $viking);
                return;
            }
        } else {
            if ($defence == 0) {
                $defence = 1;
            }
            $arrSrcArmyLost = getSrcLosses($objSrcUser, $arrArmySent, $offence / $defence, $arrWhite2[$iAttack]);
            $arrTrgArmyLost = getTrgLosses($objTrgUser, $objSrcUser, $offence / $defence, $arrWhite2[$iAttack]);
            $arrReport = doAttack($objSrcUser, $objTrgUser, $arrArmySent);
        }
        // Spread Pestilence
        $arrSpreadPest = checkPestilence($objSrcUser, $objTrgUser);
        $pestSrc = $arrSpreadPest['attacker'];
        $pestTrg = $arrSpreadPest['defender'];
        //======================================================================
        // Begin creating the invade report
        //======================================================================
        $strTribe = stripslashes($objTrgUser->get_rankings_personal(TRIBE_NAME));
        $iAlliance = $arrTrgStats[ALLIANCE];
        $strReport = '<div id="textMedium">' . '<h2>' . "Invade Report" . '</h2>' . '<p>' . 'Your invasion of <strong>' . $strTribe . ' (#' . $iAlliance . ')</strong> was successful, ' . 'below follows a report from your general.' . '</p>';
        //======================================================================
        // Report: Gains
        //======================================================================
        // Acres
        if (isset($arrReport['gained_acres']) && $arrReport['gained_acres'] != 0) {
            $strReport .= '<p>' . "Our army has gained control over " . "<strong>" . $arrReport['gained_acres'] . " acres</strong>. ";
            // Explored Acres
            if (isset($arrReport['explored_acres']) && $arrReport['explored_acres'] != 0) {
                $strReport .= "Also <strong>" . $arrReport['explored_acres'] . " acres</strong> was " . "explored and can be used to build on now.";
            }
            $strReport .= '</p>';
        }
        // Citizens Killed (raid or hnr)
        if (isset($arrReport['killed_citizens']) && $arrReport['killed_citizens'] != 0) {
            $strReport .= '<p>' . "Our army storm into their lands, killing <strong>" . $arrReport['killed_citizens'] . "</strong> of their citizens." . '</p>';
        }
        // Money (raid)
        if (isset($arrReport['gained_crowns']) && $arrReport['gained_crowns'] != 0) {
            $strReport .= '<p>' . "The army report having stolen <strong class=\"indicator\">" . number_format($arrReport['gained_crowns']) . " crowns</strong>." . '</p>';
        }
        // Buildings Razed (blasphemy crusade)
        if (isset($arrReport['damaged_total']) && $arrReport['damaged_total'] != 0) {
            $strReport .= '<p>' . "Your loyal army charges into their lands, destroying <strong>" . $arrReport['damaged_total'] . " buildings</strong> of witchcraft " . "and deception. (";
            // Academies
            if (isset($arrReport['damaged_academies']) && $arrReport['damaged_academies'] != 0) {
                $strReport .= " <strong>" . $arrReport['damaged_academies'] . " academies</strong>";
            }
            // Guilds
            if (isset($arrReport['damaged_guilds']) && $arrReport['damaged_guilds'] != 0) {
                $strReport .= " <strong>" . $arrReport['damaged_guilds'] . " guilds</strong>";
            }
            // Hideouts
            if (isset($arrReport['damaged_hideouts']) && $arrReport['damaged_hideouts'] != 0) {
                $strReport .= " <strong>" . $arrReport['damaged_hideouts'] . " hideouts</strong>";
            }
            $strReport .= ').</p>';
        }
        // Thieves Killed (blasphemy crusade)
        if (isset($arrReport['killed_thieves']) && $arrReport['killed_thieves'] != 0) {
            $strReport .= '<p>' . "Your general reports having killed <strong>" . $arrReport['killed_thieves'] . " {$thieves} of the enemy</strong>." . '</p>';
        }
        // Fame Gained
        if (isset($arrReport['gained_fame']) && $arrReport['gained_fame'] != 0) {
            $strReport .= '<p>' . "This invasion gave our tribe <strong class=\"positive\">" . $arrReport['gained_fame'] . " fame</strong>." . '</p>';
        }
        //======================================================================
        // Begin enemy defence estimation (report)
        //======================================================================
        if ($offence > $defence * 2) {
            $strReport .= '<p>' . "Our army is more than double the power of the " . "defending army, causing the enemy to run in fear. (Victory " . "by more than 100%)" . '</p>';
        } elseif ($offence > $defence * 1.8) {
            $strReport .= '<p>' . "Our army is almost double the power of the defending " . "army. (Victory by more than 80%)" . '</p>';
        } elseif ($offence > $defence * 1.6) {
            $strReport .= '<p>' . "Our army has easily broken the enemies defences, " . "overpowering them by more than 3 to 2. (Victory by more " . "than 60%)" . '</p>';
        } elseif ($offence > $defence * 1.4) {
            $strReport .= '<p>' . "Our army has broken the enemies defences, overpowering " . "them by around 3 to 2. (Victory by more than 40%)" . '</p>';
        } elseif ($offence > $defence * 1.2) {
            $strReport .= '<p>' . "Our army has broken through the line of defence, but it was " . "a hard battle. (Victory by more than 20%)" . '</p>';
        } elseif ($offence > $defence * 1.1) {
            $strReport .= '<p>' . "Our army has broken through the line of defence, but it was " . "a very tough battle. (Victory by more than 10%)" . '</p>';
        } elseif ($offence >= $defence) {
            $strReport .= '<p>' . "Our army fought hard, winning only after a lengthy and very " . "difficult battle. (Victory by less than 10%)" . '</p>';
        }
        //======================================================================
        // Report: Army Losses
        //======================================================================
        $arrUnitVars = getUnitVariables($objSrcUser->get_stat(RACE));
        $arrUnitNames = $arrUnitVars['output'];
        $strPlural = 's';
        $strReport .= '<p>' . "The captains report that we have lost ";
        if ($arrSrcArmyLost[UNIT1] > 0) {
            $strReport .= $arrSrcArmyLost[UNIT1] . " " . $arrUnitNames[2] . $strPlural . ", ";
        }
        if ($arrSrcArmyLost[UNIT2] > 0) {
            if ($arrUnitNames[3] == 'Swordmen') {
                $strPlural = '';
            } elseif ($arrUnitNames[3] == 'Pikemen') {
                $strPlural = '';
            }
            $strReport .= $arrSrcArmyLost[UNIT2] . " " . $arrUnitNames[3] . $strPlural . ", ";
        }
        if ($arrSrcArmyLost[UNIT3] > 0) {
            if ($arrUnitNames[4] == 'Crossbowmen') {
                $strPlural = '';
            } elseif ($arrUnitNames[4] == 'Longbowmen') {
                $strPlural = '';
            } elseif ($arrUnitNames[4] == 'Mummy') {
                $arrUnitNames[4] = 'Mummie';
            }
            $strReport .= $arrSrcArmyLost[UNIT3] . " " . $arrUnitNames[4] . $strPlural . ", ";
        }
        if ($arrSrcArmyLost[UNIT4] > 0) {
            if ($arrUnitNames[5] == 'Priestess') {
                $strPlural = '';
            }
            $strReport .= $arrSrcArmyLost[UNIT4] . " " . $arrUnitNames[5] . $strPlural . ", ";
        }
        if ($arrSrcArmyLost[UNIT5] > 0) {
            if ($arrUnitNames[6] == 'Thief') {
                $arrUnitNames[6] = 'Thieve';
            }
            $strReport .= $arrSrcArmyLost[UNIT5] . " " . $arrUnitNames[6] . $strPlural . ", ";
        }
        if (array_sum($arrSrcArmyLost) < 1) {
            $strReport .= " no military at all, ";
        }
        $totalkilled = round(array_sum($arrTrgArmyLost), -2);
        if ($totalkilled > 0) {
            $strReport .= " and they estimate the enemy's losses to be {$totalkilled} units";
            if ($objSrcUser->get_stat(RACE) == "Undead") {
                $strReport .= ", who joined our cursed army as soldiers.";
            }
        } else {
            $strReport .= " and they estimate the enemy's losses to be near zero";
        }
        $strReport .= '.</p>';
        //======================================================================
        // Report: Army available again
        //======================================================================
        $wait = $objSrcUser->get_user_info(NEXT_ATTACK);
        $strReport .= '<p>' . "Our generals report our army will be able to attack again " . "in " . $wait . " updates. ";
        if ($wait > 4) {
            // Assuming that an attack with more than 4 hours is a BC or Hitnrun
            $wait -= 2;
            $strReport .= "However, our army will be home to defend our lands after " . $wait . " updates.";
        }
        $strReport .= '</p>';
        //======================================================================
        // Report: Pestilence
        //======================================================================
        if ($pestSrc == "yes") {
            $strReport .= '<p>' . "<strong class=\"negative\">During your invasion your military " . "got infected with pestilence.</strong>" . '</p>';
        }
        //======================================================================
        // frost: added suicide detection | modified for age 18. only one update
        // loss of 25% citizens
        //======================================================================
        $suicide = getSuicideCheck($objSrcUser, $arrArmySent);
        if ($arrSrcStats[RACE] != "Raven" && $suicide == 1) {
            $citz = $objSrcUser->get_pop(CITIZENS);
            $leavingCitz = floor($citz * 0.25);
            $strReport .= '<p>' . "<strong class=\"negative\">Your citizens are getting tired of " . "their tax money going to far-away military campaigns " . "instead of defending their homes. " . number_format($leavingCitz) . " citizens have left your lands.</strong>" . '</p>';
            $objSrcUser->set_pop(CITIZENS, $citz - $leavingCitz);
        }
        //======================================================================
        // Report: Viking Stealth Attack
        //======================================================================
        if ($viking == 1) {
            $strReport .= '<p>' . "<strong class=\"positive\">You got lucky. Your location " . "doesn't end up in the news.</strong>" . '</p>';
        }
        //======================================================================
        // Report: War effects
        //======================================================================
        require_once 'inc/functions/war.php';
        $objSrcAlliance = $objSrcUser->get_alliance();
        if (checkWarBetween($objSrcAlliance, $objTrgUser->get_stat(ALLIANCE))) {
            $objTrgAlliance = $objTrgUser->get_alliance();
            if ($arrGains = testWarVictory($objSrcAlliance, $objTrgAlliance)) {
                // Append war-win message
                require_once 'inc/pages/war_room2.inc.php';
                $strReport .= '<p><strong class="positive">Your alliance has won the war!</strong></p>' . getVictoryReport($arrGains);
            }
        }
        $strReport .= '<p>' . '<a href="main.php?cat=game&amp;page=tribe">Continue</a>' . '</p>' . '</div>';
        echo $strReport;
        //======================================================================
        // Defender tribe news (damage report)
        //======================================================================
        $srcDisplay = $arrSrcStats[TRIBE] . " (#" . $arrSrcStats[ALLIANCE] . ")";
        $trgDisplay = $arrTrgStats[TRIBE] . " (#" . $arrTrgStats[ALLIANCE] . ")";
        $strStrategy = $arrWhite2[$iAttack];
        switch ($strStrategy) {
            case "standard":
                if ($viking == 0) {
                    $strTrgTribe = "<span class=\"positive\">{$srcDisplay} has successfully marched into our lands and conquered " . $arrReport['gained_acres'] . " acres</span>";
                    $strTrgAlliance = "<span class=\"newsattack\">{$srcDisplay} has successfully marched into the lands of {$trgDisplay} and conquered " . $arrReport['gained_acres'] . " acres</span>";
                } else {
                    $strTrgTribe = "<span class=\"positive\">An unidentified tribe of vikings has successfully marched into our lands and conquered " . $arrReport['gained_acres'] . " acres</span>";
                    $strTrgAlliance = "<span class=\"newsattack\">An unidentified tribe of vikings has successfully marched into the lands of {$trgDisplay} and conquered " . $arrReport['gained_acres'] . " acres</span>";
                }
                break;
            case "raid":
                if ($viking == 0) {
                    $strTrgTribe = "<span class=\"positive\">{$srcDisplay} has successfully stormed into our lands and conquered " . $arrReport['gained_acres'] . " acres, stolen " . $arrReport['gained_crowns'] . " crowns and slaughtered " . $arrReport['killed_citizens'] . " citizens</span>";
                    $strTrgAlliance = "<span class=\"newsattack\">{$srcDisplay} has successfully stormed into the lands of {$trgDisplay} and conquered " . $arrReport['gained_acres'] . " acres, stolen " . $arrReport['gained_crowns'] . " crowns and slaughtered " . $arrReport['killed_citizens'] . " citizens</span>";
                } else {
                    $strTrgTribe = "<span class=\"positive\">An unidentified tribe of vikings has successfully stormed into our lands and conquered " . $arrReport['gained_acres'] . " acres, stolen " . $arrReport['gained_crowns'] . " crowns and slaughtered " . $arrReport['killed_citizens'] . " citizens</span>";
                    $strTrgAlliance = "<span class=\"newsattack\">An unidentified tribe of vikings has Successfully stormed into the lands of {$trgDisplay} and conquered " . $arrReport['gained_acres'] . " acres, stolen " . $arrReport['gained_crowns'] . " crowns and slaughtered " . $arrReport['killed_citizens'] . " citizens</span>";
                }
                break;
            case "barren":
                if ($viking == 0) {
                    $strTrgTribe = "<span class=\"newsattack\">{$srcDisplay} has successfully sneaked into our lands and claimed " . $arrReport['gained_acres'] . " acres</span>";
                    $strTrgAlliance = "<span class=\"newsattack\">{$srcDisplay} has successfully sneaked into the lands of {$trgDisplay} and claimed " . $arrReport['gained_acres'] . " acres</span>";
                } else {
                    $strTrgTribe = "<span class=\"newsattack\">An unidentified tribe of vikings has successfully sneaked into our lands and claimed " . $arrReport['gained_acres'] . " acres</span>";
                    $strTrgAlliance = "<span class=\"newsattack\">An unidentified tribe of vikings has successfully sneaked into the lands of {$trgDisplay} and claimed " . $arrReport['gained_acres'] . " acres</span>";
                }
                break;
            case "bc":
                if ($viking == 0) {
                    $strTrgTribe = "<span class=\"newsbc\">{$srcDisplay} has successfully charged into our lands and destroyed " . $arrReport['damaged_total'] . " buildings and killed " . $arrReport['killed_thieves'] . " {$thieves}. Our lands will be avaliable for building again after they have been cleared</span>";
                    $strTrgAlliance = "<span class=\"newsbc\">{$srcDisplay} has successfully charged into the lands of {$trgDisplay} and destroyed " . $arrReport['damaged_total'] . " buildings and slaughtered " . $arrReport['killed_thieves'] . " {$thieves}</span>";
                } else {
                    $strTrgTribe = "<span class=\"newsbc\">An unidentified tribe of vikings has successfully charged into our lands and destroyed " . $arrReport['damaged_total'] . " buildings and killed " . $arrReport['killed_thieves'] . " {$thieves}. Our lands will be avaliable for building again after they have been cleared</span>";
                    $strTrgAlliance = "<span class=\"newsbc\">An unidentified tribe of vikings has successfully charged into the lands of {$trgDisplay} and destroyed " . $arrReport['damaged_total'] . " buildings and killed " . $arrReport['killed_thieves'] . " {$thieves}</span>";
                }
                break;
            case "hitnrun":
                $strAdd = "";
                if ($offence >= $defence) {
                    $strAdd = " and " . $arrReport['killed_citizens'] . " citizens";
                }
                if ($viking == 0) {
                    $strTrgTribe = "<span class=\"newsattack\">{$srcDisplay} has cowardly ambushed our lands, killing many troops" . $strAdd . "</span>";
                    $strTrgAlliance = "<span class=\"newsattack\">{$srcDisplay} has cowardly attacked and rained arrows over {$trgDisplay}, killing many troops" . $strAdd . "</span>";
                } else {
                    $strTrgTribe = "<span class=\"newsattack\">An unidentified tribe of vikings has cowardly ambushed our lands, killing many troops" . $strAdd . "</span></span>";
                    $strTrgAlliance = "<span class=\"newsattack\">An unidentified tribe of vikings has cowardly attacked and rained arrows over {$trgDisplay}, killing many troops" . $strAdd . "</span>";
                }
                break;
        }
        $trgId = $objTrgUser->get_userid();
        $srcId = $objSrcUser->get_userid();
        $trgKd = $objTrgUser->get_stat(ALLIANCE);
        $srcKd = $objSrcUser->get_stat(ALLIANCE);
        if ($viking == 0) {
            $result = "INSERT INTO `news` VALUES ('', NOW(), '{$ip}', '{$strStrategy}', '{$trgId}', '{$srcId}', '1', " . quote_smart($strTrgTribe) . ", " . quote_smart($strTrgAlliance) . ",'{$trgKd}','{$srcKd}',1)";
        } else {
            $result = "INSERT INTO `news` VALUES ('', NOW(), '{$ip}', '{$strStrategy}', '{$trgId}', '{$srcId}', '1', " . quote_smart($strTrgTribe) . ", " . quote_smart($strTrgAlliance) . ",'{$trgKd}',0,1)";
        }
        mysql_query($result);
        $arrUnitVars = getUnitVariables($objTrgUser->get_stat(RACE));
        $arrUnitNames = $arrUnitVars['output'];
        $strPlural = 's';
        $strPlural2 = 's';
        $strPlural3 = 's';
        $strPlural4 = 's';
        $strPlural5 = 's';
        if ($arrUnitNames[3] == 'Swordmen') {
            $strPlural2 = '';
        } elseif ($arrUnitNames[3] == 'Pikemen') {
            $strPlural2 = '';
        }
        if ($arrUnitNames[4] == 'Crossbowmen') {
            $strPlural3 = '';
        } elseif ($arrUnitNames[4] == 'Longbowmen') {
            $strPlural3 = '';
        } elseif ($arrUnitNames[4] == 'Mummy') {
            $arrUnitNames[4] = 'Mummie';
        }
        if ($arrUnitNames[5] == 'Priestess') {
            $strPlural4 = 'es';
        }
        if ($arrUnitNames[6] == 'Thief') {
            $arrUnitNames[6] = 'Thieve';
        }
        $strTrgNews = "A report has been collected, our losses are listed as follows: " . "<br />" . $arrUnitNames[2] . $strPlural . " killed: " . "<span class=\"negative\">" . $arrTrgArmyLost[UNIT1] . "</span>," . "<br />" . $arrUnitNames[3] . $strPlural2 . " killed: " . "<span class=\"negative\">" . $arrTrgArmyLost[UNIT2] . "</span>," . "<br />" . $arrUnitNames[4] . $strPlural3 . " killed: " . "<span class=\"negative\">" . $arrTrgArmyLost[UNIT3] . "</span>," . "<br />" . $arrUnitNames[5] . $strPlural4 . " killed: " . "<span class=\"negative\">" . $arrTrgArmyLost[UNIT4] . "</span>.";
        //Add mystic losses for templars - AI 24/04/2007
        if ($arrTrgArmyLost[UNIT5] > 0) {
            $strTrgNews .= "<br />" . $arrUnitNames[6] . $strPlural5 . " killed: " . "<span class=\"negative\">" . $arrTrgArmyLost[UNIT5] . "</span>.";
        }
        if ($pestTrg == "yes") {
            $strTrgNews .= "<br />" . "<strong class=\"negative\">" . "During this invasion pestilence " . "was spread into our lands for 12 updates" . "</strong>.";
        }
        // create tribe news for attack
        mysql_query("INSERT INTO `news` (`id`, `time`, `ip`, `type`, `duser`, `ouser`, `result`, `text`, `kingdom_text`) VALUES ('', NOW(), '{$ip}', 'invade report', '{$arrTrgStats['id']}', '{$arrSrcStats['id']}', 1, '{$strTrgNews}', '')");
        $orkTime = date(TIMESTAMP_FORMAT);
        $objTrgUser->set_user_info(LAST_NEWS, $orkTime);
        // Update target rankings
        include_once 'inc/functions/update_ranking.php';
        doUpdateRankings($objTrgUser, 'yes');
        // Log the op for blocking system  - AI 11/02/2007
        clsBlock::logOp($objSrcUser, $objTrgUser, 'Attack: ' . $arrWhite2[$iAttack]);
    }
}
예제 #8
0
function include_vote_text()
{
    $objSrcUser =& $GLOBALS["objSrcUser"];
    $iSrcVote = $objSrcUser->get_stat(VOTE);
    $objSrcAlli = $objSrcUser->get_alliance();
    $arrUserIds = $objSrcAlli->get_userids();
    // M: Show advisor text
    $strAdvisorText = '<div id="textMedium" style="margin-top: 0;">' . '<p>' . "Please vote for whom you think should be the elder and control your alliance." . '</p>' . '</div><br />';
    echo $strAdvisorText;
    // M: Populate arrVotes - this array contains information about all voters
    $objTmpUser = new clsUser(1);
    foreach ($arrUserIds as $iUserId) {
        $objTmpUser->set_userid($iUserId);
        $arrVotes[$iUserId]["tribename"] = $objTmpUser->get_stat(TRIBE);
        $arrVotes[$iUserId]["playertype"] = $objTmpUser->get_stat(TYPE);
        $arrVotes[$iUserId]["votes"] = 0;
        $arrVotes[$iUserId]["votefor"] = '';
    }
    // M: Count their votes (also verify that they voted for an alliance member)
    $iValidVotes = 0;
    foreach ($arrUserIds as $iUserId) {
        $objTmpUser->set_userid($iUserId);
        $iTmpVote = $objTmpUser->get_stat(VOTE);
        if ($iTmpVote > 0 && in_array($iTmpVote, $arrUserIds)) {
            $iValidVotes++;
            $arrVotes[$iTmpVote]["votes"]++;
            $arrVotes[$iUserId]["votefor"] = stripslashes($arrVotes[$iTmpVote]["tribename"]);
        }
    }
    // M: Create table rows for each tribe
    $strTableRows = '';
    foreach ($arrUserIds as $iUserId) {
        $objTmpUser->set_userid($iUserId);
        $arrTmpStats = $objTmpUser->get_stats();
        $strTmpTribe = stripslashes($arrTmpStats[TRIBE]);
        // M: Fetch information about this tribe's votes
        $strVoted = stripslashes($arrVotes[$iUserId]["votefor"]);
        $strType = $arrVotes[$iUserId]["playertype"];
        $iVotes = $arrVotes[$iUserId]["votes"];
        if ($iSrcVote == $iUserId) {
            $strChecked = " checked";
        } else {
            $strChecked = "";
        }
        // M: Column for elder to elect co-elder
        $strCoelderTD = '';
        if ($objSrcUser->get_stat(TYPE) == 'elder') {
            if ($strType == "coelder") {
                $strChecked2 = " checked";
            } else {
                $strChecked2 = "";
            }
            $strCoelderTD = '<td>' . '<input type="checkbox" name="voteforcoelder[]" value="' . $iUserId . '"' . $strChecked2 . " />" . "</td>";
        }
        $strTableRows .= '<tr class="data">' . '<th>' . '<label>' . '<input type="radio" name="votefor" value="' . $iUserId . '"' . $strChecked . ' /> <span class="' . $strType . '">' . $strTmpTribe . '</span></label>' . '</th>' . '<td class="left">' . floor($iVotes / max(1, $iValidVotes) * 100) . '%' . '</td>' . '<td class="left">' . $strVoted . '</td>' . $strCoelderTD . "</tr>";
    }
    // M: Vote for donkey (default)
    if ($iSrcVote == '' || $iSrcVote == 0) {
        $strChecked = " checked";
    } else {
        $strChecked = '';
    }
    // M: Extra column for elder to elect co-elders
    if ($objSrcUser->get_stat(TYPE) == 'elder') {
        $iColumns = '4';
        $strThCoelder = "<th class=\"center\">" . "Co-elder" . "</td>";
    } else {
        $iColumns = '3';
        $strThCoelder = '';
    }
    // M: "Elect your elder"-table
    $strElderTable = "<form method=\"post\" action=\"main.php?cat=game&amp;page=vote2\" id=\"center\">" . "<table cellspacing=\"0\" cellpadding=\"0\" class=\"medium\">" . "<tr class=\"header\">" . "<th colspan=\"" . $iColumns . "\">" . "Elect Your Elder" . "</th>" . "</tr>" . "<tr class=\"subheader\">" . "<th>" . "Tribe" . "</th>" . "<th>" . "Votes" . "</th>" . "<th>" . "Voted For" . "</th>" . $strThCoelder . "</tr>" . $strTableRows . "<tr class=\"data\">" . '<th class="bsup" colspan="' . $iColumns . '">' . "<input type=\"radio\" name=\"votefor\" value=\"0\" id=\"0\"" . $strChecked . " /> " . "<label for=\"0\">" . "No Vote" . "</label>" . "</th>" . "</tr>" . "</table><br />" . "<input type=\"submit\" value=\"Vote\" />" . "</form>";
    echo $strElderTable;
}
예제 #9
0
function include_research_text()
{
    $objSrcUser =& $GLOBALS["objSrcUser"];
    $arrStats = $objSrcUser->get_stats();
    // M: Navigation links
    $strPurchase = '';
    if ($arrStats[TYPE] == "elder" || $arrStats[TYPE] == "coelder") {
        $strPurchase = "<a href='main.php?cat=game&amp;page=research&amp;action=buy'>Purchase</a> | ";
    }
    $topLinks = '<div class="center">' . '| <a href="main.php?cat=game&amp;page=research&amp;action=view">View/Invest</a> | ' . $strPurchase . '<a href="main.php?cat=game&amp;page=research&amp;action=history">History</a> |' . '</div>';
    echo $topLinks;
    // M: User Tables
    $arrGoods = $objSrcUser->get_goods();
    $arrUserInfos = $objSrcUser->get_user_infos();
    // M: Alliance Tables
    $objSrcAlli = $objSrcUser->get_alliance();
    $arrAlli = $objSrcAlli->get_alliance_infos();
    $arrSci = $objSrcAlli->get_alliance_sciences();
    // M: Get rounded %'s
    foreach ($arrSci as $str => $iBonus) {
        $arrSciMod[$str] = round($iBonus * 100, 2);
    }
    $do = '';
    if (isset($_GET['do']) && !empty($_GET['do'])) {
        $do = strval($_GET['do']);
    }
    $action = 'view';
    if (isset($_GET['action']) && !empty($_GET['action'])) {
        $action = strval($_GET['action']);
    }
    switch ($action) {
        case 'view':
            if ($do == "invest") {
                $invest = max(0, $arrGoods[RESEARCH]);
                if ($arrUserInfos[HOURS] < PROTECTION_HOURS) {
                    echo '<br /><div class="center">' . "Sorry, you can only invest research points once you have left protection.</div><br />";
                    return;
                } elseif ($invest == 0) {
                    echo '<br /><div class="center">' . "I'm sure you meant well, but investing 0 rps will do nothing for our research.</div><br />";
                    return;
                } else {
                    $arrStats[INVESTED] += $invest;
                    $arrAlli[RESEARCH] += $invest;
                    $objSrcUser->set_good(RESEARCH, 0);
                    $objSrcUser->set_stat(INVESTED, $arrStats[INVESTED]);
                    $objSrcAlli->set_alliance_info(RESEARCH, $arrAlli[RESEARCH]);
                    header('location:main.php?cat=game&page=research&action=view&do=thank');
                    exit;
                }
            }
            if ($arrGoods[RESEARCH] > 0) {
                $strMessage = "Our researchers have been working very hard." . "<br />" . "Would you like to invest their produced research points?" . "<form method=\"post\" action=\"main.php?cat=game&amp;page=research&amp;action=view&amp;do=invest\">" . '<label>Available: </label><strong><span class="indicator">' . $arrGoods[RESEARCH] . '</span> rps</strong> ' . "<input type=\"submit\" value=\"Invest\" name=\"invest\" />" . "</form>";
            } elseif ($do == 'thank') {
                $strMessage = "You have invested your research. Your alliance thanks you!";
            } else {
                $strMessage = "We have no research points for you to invest at this moment.";
            }
            $strAdvisorText = '<div id="textMedium">' . "<p>Good morning " . stripslashes($arrStats[NAME]) . "!<br />" . $strMessage . '</p>' . '</div><br />';
            echo $strAdvisorText;
            // M: Show alliance research (new function shared with spells)
            echo get_alliance_science_table($objSrcAlli);
            // M: Show guide link + advice
            include_once 'inc/pages/advisors.inc.php';
            echo get_guide_link($objSrcUser, 'research', 'textMedium');
            break;
        case "buy":
            // M: Restrict access to elders and co-elders
            if ($arrStats[TYPE] == "player") {
                echo "<div class=\"center\">Only your elected elder can purchase the research points you have invested.<br /><br />";
                echo "| <a  href=main.php?cat=game&amp;page=research&action=view style=\"text-decoration:none\">Return To Investing</a> |</div>";
                return;
            }
            // M: Handle POST action
            if ($do == "buy") {
                // M: Clean POST-data
                $invest_prod = max(0, floor(intval($_POST['invest_prod'])));
                $invest_eng = max(0, floor(intval($_POST['invest_eng'])));
                $invest_def = max(0, floor(intval($_POST['invest_def'])));
                $invest_off = max(0, floor(intval($_POST['invest_off'])));
                $iToPurchase = $invest_off + $invest_def + $invest_eng + $invest_prod;
                if ($iToPurchase == 0) {
                    echo "<div class=\"center\">I'm sure you meant well, but purchasing 0 rps will do nothing for our science.</div><br />";
                } elseif ($iToPurchase < 0 || $iToPurchase > 9999999 || $invest_eng < 0 || $invest_eng > 9999999 || $invest_prod < 0 || $invest_prod > 9999999 || $invest_def < 0 || $invest_def > 9999999 || $invest_off < 0 || $invest_off > 9999999) {
                    echo "<div class=\"center\">It's impossible to invest that amount.</div><br />";
                } elseif ($iToPurchase > $arrAlli[RESEARCH]) {
                    echo "<div class=\"center\">How can you purchase research points that you don't have?</div><br />";
                } else {
                    // M: New research
                    $iNewResearch = max(0, $arrAlli[RESEARCH] - $iToPurchase);
                    $arrNewAlliInfos = array(RESEARCH => $iNewResearch, HOME_BONUS => $arrAlli[HOME_BONUS] + $invest_eng, INCOME_BONUS => $arrAlli[INCOME_BONUS] + $invest_prod, DEFENCE_BONUS => $arrAlli[DEFENCE_BONUS] + $invest_def, OFFENCE_BONUS => $arrAlli[OFFENCE_BONUS] + $invest_off);
                    // M: Save to DB
                    $objSrcAlli->set_alliance_infos($arrNewAlliInfos);
                    // M: Show report
                    $strReport = '<div id="textMedium">' . '<h2>Purchase Report</h2>' . "<p>" . "Thank you " . stripslashes($arrStats[NAME]) . ", our research has been updated!" . "</p>" . "<p>" . "You had <strong>" . number_format($arrAlli[RESEARCH]) . " research points</strong> and you used up " . "<strong>" . number_format($iToPurchase) . "</strong>." . "</p>" . "<p>" . '<a href="main.php?cat=game&amp;page=research' . '&amp;action=buy">Return To Purchasing</a>' . '</p>' . '</div>';
                    echo $strReport;
                    include_game_down();
                    exit;
                }
            }
            // M: Show "advisor" text
            if ($arrAlli['research'] != 0) {
                $strMessage = "<br />Our alliance has been working very hard.<br />" . "In what branch of sciences would you like to purchase?";
            } else {
                $strMessage = "<br />We have no research points for you to " . "purchase at this moment.";
            }
            $strAdvisorText = '<div id="textMedium">' . '<p>Good morning ' . $arrStats[NAME] . '!' . $strMessage . '</p>' . '</div><br />';
            echo $strAdvisorText;
            // M: Show purchase interface
            $left = '<img src="' . HOST_PICS . 'bar_left.gif" alt="" />' . '<img src="' . HOST_PICS . 'bar_mid.gif" height="12" width="';
            $right = '%" alt="" /><img src="' . HOST_PICS . 'bar_right.gif" alt="" />';
            $researchPurchase = "<table cellspacing=\"0\" cellpadding=\"0\" class=\"medium\">" . "<form method=\"post\" action=\"main.php?cat=game&amp;page=research&amp;action=buy&amp;do=buy\">" . "<tr class=\"header\">" . "<th colspan=\"4\">Alliance Research</th>" . "</tr>" . "<tr class=\"subheader\">" . "<th width=\"33%\">" . "Type" . "</th>" . "<th>" . "Amount" . "</th>" . "<th width=\"10%\" class=\"center\">" . "%" . "</th>" . "<th width=\"20%\" class=\"right\">" . "Purchase" . "</th>" . "</tr>" . "<tr class=\"data\">" . "<th>" . "Production:" . "</th>" . "<td class=\"left\">" . $left . floor($arrSciMod['prod'] * 1.4) . $right . "</td>" . "<td class=\"center\">" . $arrSciMod['prod'] . "</td>" . "<td>" . "<input type=\"text\" name=\"invest_prod\" size=\"8\" maxlength=\"7\" value=\"0\" />" . "</td>" . "</tr>" . "<tr class=\"data\">" . "<th>" . "Engineering:" . "</th>" . "<td class=\"left\">" . $left . floor($arrSciMod['eng'] * 1.4) . $right . "</td>" . "<td class=\"center\">" . $arrSciMod['eng'] . "</td>" . "<td>" . "<input type=\"text\" name=\"invest_eng\" size=\"8\" maxlength=\"7\" value=\"0\" />" . "</td>" . "</tr>" . "<tr class=\"data\">" . "<th>" . "Defence Tactics:" . "</th>" . "<td class=\"left\">" . $left . floor($arrSciMod['def'] * 1.4) . $right . "</td>" . "<td class=\"center\">" . $arrSciMod['def'] . "</td>" . "<td>" . "<input type=\"text\" name=\"invest_def\" size=\"8\" maxlength=\"7\" value=\"0\" />" . "</td>" . "</tr>" . "<tr class=\"data\">" . "<th>" . "War Tactics:" . "</th>" . "<td class=\"left\">" . $left . floor($arrSciMod['war'] * 1.4) . $right . "</td>" . "<td class=\"center\">" . $arrSciMod['war'] . "</td>" . "<td>" . "<input type=\"text\" name=\"invest_off\" size=\"8\" maxlength=\"7\" value=\"0\" />" . "</td>" . "</tr>" . "<tr class=\"data\">" . "<th class=\"bsup\">" . "Available:" . "</th>" . "<td class=\"bsup left\" colspan=\"2\"><strong><span class=\"indicator\">" . number_format($arrAlli['research']) . "</span> rps</strong>" . "</td>" . "<td class=\"bsup\">" . "<input type=\"submit\" value=\"Purchase\" name=\"submit\" />" . "</td>" . "</tr>" . "</form>" . "</table>";
            echo $researchPurchase;
            break;
        case "history":
            echo '<br />';
            $arrUserids = $objSrcAlli->get_userids();
            $objTmpUser = new clsUser(0);
            $strTribesInvested = '';
            foreach ($arrUserids as $iTmpUserid) {
                // M: Clear temporary object (first time trying this method :))
                $objTmpUser->set_userid($iTmpUserid);
                $arrTmpStats = $objTmpUser->get_stats();
                $iTmpAcres = $objTmpUser->get_build(LAND);
                $strTribesInvested .= "<tr class=\"data\">" . "<th>" . stripslashes($arrTmpStats[TRIBE]) . "</th>" . "<td>" . round($arrTmpStats[INVESTED] / $iTmpAcres) . "</td>" . "<td>" . number_format($arrTmpStats[INVESTED]) . " rps</td>" . "</tr>";
            }
            $researchHistoryTable = '<table cellspacing="0" cellpadding="0" class="medium">' . "<tr class=\"header\">" . "<th colspan=\"4\">Investment History</th>" . "</tr>" . "<tr class=\"subheader\">" . "<th>" . "Tribe" . "</th>" . "<th class=\"right\">" . "RPA" . "</th>" . "<th class=\"right\">" . "Amount" . "</th>" . "</tr>" . $strTribesInvested . '</table>';
            echo $researchHistoryTable;
            echo '<div id="textMedium">' . '<h3>What does it mean?</h3>' . '<ul><li>RPA - Research Per Acre' . '</li>' . '<li>rps - research points' . '</li><ul>' . '</div>';
            break;
    }
}
예제 #10
0
function get_coloured_name($id, $type)
{
    $objTmpUser = new clsUser($id);
    $arrStats = $objTmpUser->get_stats();
    if ($arrStats[LEVEL] == 6) {
        $strSpan = '<span class="admin">' . $arrStats[NAME] . "</span>";
    } elseif ($arrStats[LEVEL] == 5) {
        $strSpan = '<span class="head">' . $arrStats[NAME] . "</span>";
    } elseif ($arrStats[LEVEL] > 2) {
        // && $arrStats[ALLIANCE] < 11)
        $strSpan = '<span class="staff">' . $arrStats[NAME] . "</span>";
    } elseif ($arrStats[LEVEL] > 1) {
        $strSpan = '<span class="mod">' . $arrStats[NAME] . "</span>";
    } else {
        $strSpan = '<span class="player">' . $arrStats[NAME] . "</span>";
    }
    if ($type == '0') {
        if ($arrStats[LEVEL] == 6) {
            $strSpan = '<span class="admin">' . $arrStats[NAME] . "</span>";
        } elseif ($arrStats[TYPE] == 'elder') {
            $strSpan = '<span class="elder">' . $arrStats[NAME] . '</span>';
        } elseif ($arrStats[TYPE] == 'coelder') {
            $strSpan = '<span class="coelder">' . $arrStats[NAME] . '</span>';
        } else {
            $strSpan = '<span class="player">' . $arrStats[NAME] . "</span>";
        }
    }
    return $strSpan;
}