Beispiel #1
0
function call_tour_move_text()
{
    global $local_stats, $id, $confirm, $target, $tool;
    include_once 'inc/functions/resort_tools.php';
    check_access($tool);
    $alli_id = '';
    if (isset($_POST['alli_id'])) {
        $alli_id = intval($_POST['alli_id']);
    }
    echo '<h2>ORKFiA Tour!</h2>';
    $strForm = "<form method=\"post\" action=\"" . $_SERVER['REQUEST_URI'] . "\">" . '<label>Where is our touring tribe? Alliance #</label> ' . '<input name="alli_id" size="3" value="' . $alli_id . '"/><br /><br />';
    if (isset($_POST['alli_id']) && !empty($_POST['alli_id'])) {
        $iAlliance = intval($_POST['alli_id']);
        include 'inc/functions/vote.php';
        // select everyone in this alliance
        $strSQL = "SELECT * " . "  FROM stats " . " WHERE kingdom = " . $iAlliance . " ORDER BY tribe ASC";
        $result = mysql_query($strSQL) or die("Elder Defect:" . mysql_error());
        $strForm .= "<label>Select the lucky tribe</label>: " . '<select name="id" size="1">' . render_option_list($result, TRIBE, ID, 0) . '</select><br /><br />' . '<label>Where will they apparate to? Alliance #</label>: ' . '<input name="target" size="5" /><br /><br />' . '<input type="submit" value="Move Tourer" name="confirm">';
    } else {
        $strForm .= '<input type="submit" value="Choose Alliance" name="confirm">';
    }
    $strForm .= "</form>";
    echo $strForm;
    if (isset($_POST['confirm']) && isset($_POST['id']) && !empty($_POST['id']) && isset($_POST['target']) && !empty($_POST['target'])) {
        $id = intval($_POST['id']);
        $target = intval($_POST['target']);
        $trgTmpUser = new clsUser($id);
        $strTribeName = ucwords(stripslashes($trgTmpUser->get_stat(TRIBE)));
        if ($trgTmpUser->get_build(LAND) != 1) {
            echo '<p>"W-T-F mate?" That was not a tourer tribe.</p></div>';
            include_game_down();
            exit;
        } elseif ($target < 11) {
            echo '<p>"W-T-F mate?" No apparating into staff alliances.</p></div>';
            include_game_down();
            exit;
        }
        echo "<p>Leader! The tribe of " . $strTribeName . " has now apparated to alliance #<strong>{$target}</strong>. Let us hope that neither of their citizens got splinched.</p>";
        $orkTime = date(TIMESTAMP_FORMAT);
        $search = mysql_query("SELECT * FROM stats WHERE id = {$id}");
        $search = mysql_fetch_array($search);
        //mysql_query("UPDATE stats SET kingdom = $target, type ='player', invested = 0 where id = $id");
        //mysql_query("UPDATE rankings_personal SET alli_id = $target where id = $id");
        //mysql_query("UPDATE stats SET vote = 0, invested = 0 WHERE vote = $id");
        //mysql_query("UPDATE goods SET credits = 0, market_money = 0, market_food = 0, market_soldiers = 0, market_wood = 0 WHERE id = $id");
        include_once 'inc/staff/move.inc.php';
        move_tribe($id, $target);
        mysql_query("INSERT INTO news (id, time, ip, type, duser, ouser, result, text, kingdom_text, kingdoma, kingdomb) VALUES ('', '{$orkTime}', '---', 'Tour Move', '0', '0', '1', '', '<span class=\"indicator\">{$search['tribe']} has joined our alliance. Long live Orkfia! Long live the tour!</span>', '', '{$target}')");
    }
}
Beispiel #2
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;
    }
}