ARGINT -------------------------------------------
// Validarea si atomicitatea sunt in HeroItems::exchange*(); aici doar
// afisam rezultatul si tinem sesiunea sincronizata cu noul sold de aur.
if (($_POST['t4action'] === 'g2s' || $_POST['t4action'] === 's2g') && isset($_POST['amount'])) {
$t4Items = new HeroItems();
$t4Amount = (int) $_POST['amount'];
$t4Ex = ($_POST['t4action'] === 'g2s')
? $t4Items->exchangeGoldToSilver($session->uid, $t4Amount)
: $t4Items->exchangeSilverToGold($session->uid, $t4Amount);
if ($t4Ex === HeroItems::EXCHANGE_OK) {
$t4Msg = defined('HERO_EXCHANGE_OK') ? HERO_EXCHANGE_OK : 'Exchange completed.';
// soldul de aur din sesiune trebuie reimprospatat, altfel pagina ar
// arata vechea valoare pana la expirarea cache-ului de utilizator
$t4NewGold = (int) $database->getUserField($session->uid, 'gold', 0);
$session->gold = $t4NewGold;
$_SESSION['gold'] = $t4NewGold;
unset($_SESSION['cache_user_' . (isset($_SESSION['username']) ? $_SESSION['username'] : '')]);
} elseif ($t4Ex === HeroItems::EXCHANGE_NOT_ENOUGH) {
$t4Msg = defined('HERO_EXCHANGE_NOTENOUGH') ? HERO_EXCHANGE_NOTENOUGH : 'You do not have enough for this exchange.';
} elseif ($t4Ex === HeroItems::EXCHANGE_NO_HERO) {
$t4Msg = defined('HERO_LOCKED_NOHERO') ? HERO_LOCKED_NOHERO : 'You have no hero yet.';
} else {
$t4Msg = defined('HERO_EXCHANGE_FAIL') ? HERO_EXCHANGE_FAIL : 'The exchange could not be completed.';
}
}
if ($_POST['t4action'] === 'bid' && isset($_POST['aucid'], $_POST['maxbid'])) {
$t4Result = $t4Auction->placeBid($session->uid, (int) $_POST['aucid'], (int) $_POST['maxbid']);
if ($t4Result === HeroAuction::BID_OK) {
$t4Msg = HERO_AUC_BID_OK;
} elseif ($t4Result === HeroAuction::BID_OUTBID) {
$t4Msg = HERO_AUC_BID_OUTBID;
} elseif ($t4Result === HeroAuction::BID_NO_SILVER) {
$t4Msg = HERO_AUC_BID_NOSILVER;
} else {
$t4Msg = HERO_AUC_BID_FAIL;
}
} elseif ($_POST['t4action'] === 'sell'
&& isset($_POST['rowid'], $_POST['qty'], $_POST['price'], $_POST['duration'])) {
$t4Result = $t4Auction->createAuction(
$session->uid, (int) $_POST['rowid'],
(int) $_POST['qty'], (int) $_POST['price'], (int) $_POST['duration']
);
$t4Msg = ($t4Result > 0) ? HERO_AUC_SELL_OK : HERO_AUC_SELL_FAIL;
}
}
$t4Open = $t4Auction->getOpenAuctions(50, $session->uid);
$t4MyBids = $t4Auction->getMyBids($session->uid);
$t4MySales = $t4Auction->getMySales($session->uid);
$t4Now = time();
// Unequipped items sellable from the inventory.
$t4Sellable = array();
foreach ($t4HeroItems->getInventory($session->uid) as $t4Row) {
if ($t4Row['equipped'] == 0 && !$t4Row['orphan']) {
$t4Sellable[] = $t4Row;
}
}
?>
getSilver($session->uid);
$t4Gold = (int) $session->gold;
$t4RateG2S = HeroItems::silverPerGold();
$t4RateS2G = HeroItems::silverForOneGold();
?>
|
|
:
:
|
|
|
|
|
|
|
|
|
()
|
|
|
getTimeFormat(max(0, $t4A['time_end'] - $t4Now)); ?> |
uid) { ?>
-
|
|
|
| (x) |
: |
: |
getTimeFormat(max(0, $t4A['time_end'] - $t4Now)); ?> |
|
| (x) |
: |
getTimeFormat(max(0, $t4A['time_end'] - $t4Now)); ?> |