示例#1
0
function max_market_buy(&$objSrcUser)
{
    $arrSrcStats = $objSrcUser->get_stats();
    $arrSrcGoods = $objSrcUser->get_goods();
    $objSrcAlliance = $objSrcUser->get_alliance();
    // M: Update just to ensure decays have affected the goods
    doUpdateMarket($objSrcAlliance);
    $arrSrcAlliance = $objSrcAlliance->get_alliance_infos();
    // M: New functions connected to the object-oriented update routines
    include_once 'inc/functions/population.php';
    $iArmy = getPopulation($objSrcUser);
    $iArmy = $iArmy['total_army'];
    $iRoom = getMaxPopulation($objSrcUser);
    $iRoom = $iRoom['total'];
    $iLeft = floor($iRoom - $iArmy) - 800;
    // 800 so we do not kill ourselves
    if ($iLeft < 0) {
        $iLeft = 0;
    }
    // M: Fetch the prices for each goods
    $arrMarketCost = getPriceArray($objSrcUser);
    // M: Besides looking up what we can afford, let's not allow someone to die
    $arrMaxMarketBuy[UNIT1] = min(floor($arrSrcGoods[CREDITS] / $arrMarketCost[UNIT1]), $iLeft);
    if ($arrMaxMarketBuy[UNIT1] >= $arrSrcAlliance[SOLDIERS]) {
        $arrMaxMarketBuy[UNIT1] = $arrSrcAlliance[SOLDIERS];
    }
    $arrMaxMarketBuy[MONEY] = floor($arrSrcGoods[CREDITS] / $arrMarketCost[MONEY]);
    if ($arrMaxMarketBuy[MONEY] >= $arrSrcAlliance[MONEY]) {
        $arrMaxMarketBuy[MONEY] = $arrSrcAlliance[MONEY];
    }
    $arrMaxMarketBuy[WOOD] = floor($arrSrcGoods[CREDITS] / $arrMarketCost[WOOD]);
    if ($arrMaxMarketBuy[WOOD] >= $arrSrcAlliance[WOOD]) {
        $arrMaxMarketBuy[WOOD] = $arrSrcAlliance[WOOD];
    }
    $arrMaxMarketBuy[FOOD] = floor($arrSrcGoods[CREDITS] / $arrMarketCost[FOOD]);
    if ($arrMaxMarketBuy[FOOD] >= $arrSrcAlliance[FOOD]) {
        $arrMaxMarketBuy[FOOD] = $arrSrcAlliance[FOOD];
    }
    return $arrMaxMarketBuy;
}
示例#2
0
function get_market_table(&$objAlli)
{
    include_once 'inc/functions/market.php';
    doUpdateMarket($objAlli);
    $arrAlliance = $objAlli->get_alliance_infos();
    $alliancePool = "<table cellspacing=\"0\" cellpadding=\"0\" class=\"medium\">" . "<tr class=\"header\">" . "<th colspan=\"2\">Alliance Market - " . stripslashes($arrAlliance['name']) . " (#" . $arrAlliance[ID] . ")</th>" . "</tr>" . "<tr class=\"subheader\">" . "<th>" . "Type" . "</th>" . "<td>" . "Amount" . "</td>" . "</tr>" . "<tr class=\"data\">" . "<th>" . "Money:" . "</th>" . "<td>" . number_format($arrAlliance['money']) . " cr" . "</td>" . "</tr>" . "<tr class=\"data\">" . "<th>" . "Food:" . "</th>" . "<td>" . number_format($arrAlliance['food']) . " kgs" . "</td>" . "</tr>" . "<tr class=\"data\">" . "<th>" . "Wood:" . "</th>" . "<td>" . number_format($arrAlliance['wood']) . " logs" . "</td>" . "</tr>" . "<tr class=\"data\">" . "<th>" . "Soldiers: " . "</th>" . "<td>" . number_format($arrAlliance['soldiers']) . " units" . "</td>" . "</tr>" . "</table>";
    return $alliancePool;
}