$result = db_query($sql); $row = db_fetch_assoc($result); $user =& $session['user']; if ($row['turns'] > $user['turns']) { output('`2%s`2 sizes you up, then decides that separating you from your %s`2 right now would be too exhausting an experience for you.', $shopkeep, $row['name']); output('The sale is off!`0`n`n'); } elseif ($row['attack'] >= $user['attack'] || $row['defense'] >= $user['defense'] || $row['hitpoints'] >= $user['maxhitpoints'] || $row['charm'] > $user['charm'] || $row['favor'] > $user['deathpower']) { output('`2%s`2 sizes you up, then decides that separating you from your %s`2 right now would be too painful for you.', $shopkeep, $row['name']); output('The sale is off!`0`n`n'); } else { $gold = $row['gold']; $gems = $row['gems']; $gem = translate_inline('gem'); $gem_pl = translate_inline('gems'); require_once './modules/mysticalshop/lib.php'; mysticalshop_applydiscount($gold, $gems, $disnum); $sellgold = round($gold * 0.75, 0); $sellgems = round($gems * 0.25, 0); $rare = $row['rare']; $itemname = $row['name']; output("`2You have chosen to sell your %s`2.", $itemname); output(' `2%s `2hands you your `^%s gold `2and `%%s %s `2and bids you a good day.`n`n', $shopkeep, $sellgold, $sellgems, abs($sellgems) != 1 ? $gem_pl : $gem); output("`3Any magic enchantments %s`3 provided have now been removed.", $itemname); output_notl('`0`n`n'); debuglog('sold ' . $itemname . ' for ' . $sellgold . ' gold and ' . $sellgems . ' gems.'); //The hook is up here to catch the ID of the item before it's reset modulehook("mysticalshop-sell", array("itemid" => $id)); $rare = FALSE; if ($row['rare']) { $rare = $id; }
$id = httpget('id'); if (is_numeric($id)) { $sql = "SELECT dk,name,gold,gems,rare,rarenum FROM " . db_prefix("magicitems") . " WHERE id={$id}"; $result = db_query($sql); $row = db_fetch_assoc($result); $dk = $row['dk']; $name = $row['name']; $gold = $row['gold']; $gems = $row['gems']; $gem = translate_inline('gem'); $gem_pl = translate_inline('gems'); //run some checks first to see if the player can afford the item in question output("`2The cost of `3%s `2is `^%s gold `2and `%%s %s`2.`0", $name, $gold, $gems, abs($gems) != 1 ? $gem_pl : $gem); require_once './modules/mysticalshop/lib.php'; if (mysticalshop_applydiscount($gold, $gems)) { output('`&However, after some haggling, you convince %s`& to lower the price to `^%s gold `&and `%%s %s`&!`0', $shopkeep, $gold, $gems, abs($gems) != 1 ? $gem_pl : $gem); } if ($row['rare'] == 1 && $row['rarenum'] < 1) { output('`$Too bad you can\'t buy any because they are all sold out!`0'); } elseif ($session['user']['gold'] < $gold && $session['user']['gems'] < $gems) { output("`n`n`2Sorry, but you have neither enough gold nor gems to purchase `6%s `2as a gift.`0", $name); } else { if ($session['user']['gold'] < $gold) { output("`n`n`2Sorry, you don't have enough gold to purchase `^%s `2as a gift.`0", $name); } else { if ($session['user']['gems'] < $gems) { output("`n`n`2Sorry, you don't have enough gems to purchase `^%s `2as a gift.`0", $name); } else { //if the player can afford to, let's allow them to search output("`n`n`i`3You have chosen to give `^%s `3as a gift to another player.`0`i", $name);
<?php $playerid = httpget('playerid'); $id = httpget('id'); if (is_numeric($id) && is_numeric($playerid)) { $giftid = get_module_pref("giftid"); $sql = 'SELECT name,gold,gems FROM ' . db_prefix('magicitems') . ' WHERE id=' . $id . ' LIMIT 1'; $result = db_query($sql); $row = db_fetch_assoc($result); $gifteditem = $row['name']; $giftgold = $row['gold']; $giftgems = $row['gems']; require_once './modules/mysticalshop/lib.php'; mysticalshop_applydiscount($giftgold, $giftgems); //We've bought the player the gift, let's subtract the cost now. $session['user']['gold'] -= $giftgold; $session['user']['gems'] -= $giftgems; //now, let's set their item data up $sql = "SELECT acctid,name,sex FROM " . db_prefix("accounts") . " WHERE acctid={$playerid} LIMIT 1"; $result = db_query($sql); $row = db_fetch_assoc($result); $pname = $row['name']; $gifteeid = $row['acctid']; $usersex = translate_inline($row['sex'] ? "She" : "He"); output("`2You have bought `^%s`2 as a gift for `6%s`2!", $gifteditem, $pname); output(" %s will receive mail with details on how to pick it up.`0`n`n", $usersex); set_module_pref("gifted", 1, "mysticalshop", $gifteeid); set_module_pref("giftid", $id, "mysticalshop", $gifteeid); set_module_pref("giftcat", $cat, "mysticalshop", $gifteeid); //send a mail with name of item, shop, and location (for the clueless) $subject = translate_inline("Someone bought you a magical item!");
$favor = $row['favor']; if ($row['rare'] > 0) { output("`&This item is rare and only a limited amount exists.`n"); } if ($attack != 0) { output("`&This item's enchantments will alter attack by `^%s `&%s.`n", $attack, abs($attack) != 1 ? $points : $point); } if ($defense != 0) { output("`&This item's enchantments will alter defense by `^%s `&%s.`n", $defense, abs($defense) != 1 ? $points : $point); } if ($charm != 0) { output("`&This item's enchantments will alter charm by `^%s `&%s.`n", $charm, abs($charm) != 1 ? $points : $point); } if ($row['hitpoints'] != 0) { output("`&This item's enchantments will alter maximum hit points by `^%s`&.`n", $row['hitpoints']); } if ($row['turns'] != 0) { output("`&This item's enchantments will alter turns by `^%s`&.`n", $row['turns']); } if ($favor != 0) { output('`&This item\'s enchantments will alter favor with %s`& by `^%s `&%s.`n', getsetting('deathoverlord', '`$Ramius'), $favor, abs($favor) != 1 ? $points : $point); } output_notl('`0'); require_once './modules/mysticalshop/lib.php'; mysticalshop_applydiscount($gold, $gems, NULL, 'show_table'); output('`nWould you like to <a href="' . htmlentities($fromeditor . 'edit&id=' . $id . '&cat=') . $cat . '">[ Edit ]</a> this item?', true); addnav('', $fromeditor . 'edit&id=' . $id . '&cat=' . $cat); } else { output('Nothing to preview.`n'); } output("`n`3Click `iRefresh List`i to return to the category you were just viewing.`0`n`n");