/** * endAuctionBIN: end an auction that resulted in a buy it now purchase. * * @param auctionId The auction id (primary key of auctions table) * @param user User ID of the player placing this bid * @param bidAmt The amount of the BIN purchase * @param gameinstance deprecated, but here so that other moving parts move correctly. */ function endAuctionBIN($auctionId, $user, $bidAmt, $gameinstance) { global $dbh; // Place a bid using the normal bidding function, but then... placeBidFixedEnd($auctionId, $user, $bidAmt, $gameinstance); // ... drop the scheduled events created by that function, since the auction is // ending now. $query = $dbh->prepare("DROP EVENT IF EXISTS auctionEnd" . $auctionId); $query->execute(); $query = $dbh->prepare("DROP EVENT IF EXISTS notifyWinner" . $auctionId); $query->execute(); $query = $dbh->prepare("DROP EVENT IF EXISTS notifySeller" . $auctionId); $query->execute(); // Set the auction end time to NOW(). $query = $dbh->prepare("UPDATE auctions SET end = NOW() WHERE id = ?"); $query->bindParam(1, $auctionId); $query->execute(); // Find the work ID associated with this auction... $query = $dbh->prepare("SELECT wid FROM auctions WHERE id = ? LIMIT 1"); $query->bindParam(1, $auctionId); $query->execute(); $workid = -1; while ($row = $query->fetch()) { $workid = $row['wid']; } // Give the high bidder the work... $subq = $dbh->prepare("INSERT INTO " . $user . "_" . $gameinstance . "_coll VALUES(?)"); $subq->bindValue(1, $workid); $subq->execute(); // ...and take it from the seller. $subs = $dbh->prepare("DELETE FROM " . getSellerIdForAuction($auctionId) . "_" . $gameinstance . "_coll WHERE work=?"); $subs->bindValue(1, $workid); $subs->execute(); // Remove the work from any other pending transactions. clearWorkFromOtherTransactions($workid); // Assess a final value fee of 10% (roughly) the sale price and transfer bidder's FCGs to // seller. $finalVal = floor($bidAmt * 0.1); adjustPoints(getSellerIdForAuction($auctionId), $bidAmt); adjustPoints(getSellerIdForAuction($auctionId), -$finalVal); adjustPoints($user, -$bidAmt); }
$query->execute( ); echo( "You have placed an absentee bid of " . $CURRENCY_SYMBOL . $bidAmt . "."); exit; } */ // Series of sanity checks: did the user enter a positive integer as his/her bid? if (!is_numeric($bidAmt) || $bidAmt < 1) { echo $bidAmt . " isn't an acceptable bid. Please bid only positive integers."; // Is the auction still active? And is the user bidding an acceptable minimum? (Current high bid + 5 FCG) } elseif (isAuctionStillActiveFixedEnd($auctionId) && $bidAmt < getHighBidAmountForAuction($auctionId) + 5) { echo "Please bid at least " . $CURRENCY_SYMBOL . (getHighBidAmountForAuction($auctionId) + 5) . "."; echo "<p/><button id=\"dismiss\" class=\"ui-widget ui-button ui-state-default ui-corner-all ui-button-text-only\" style=\"width:100px;height:40px;\" onClick=\"window.parent.Shadowbox.close( );\">Okay</button>"; // Is the attempted bid less than the minimum bid for the auction? } elseif (isAuctionStillActiveFixedEnd($auctionId) && $bidAmt < getMinimumBidForAuction($auctionId)) { echo "Sorry, but the minimum bid for this auction is " . getMinimumBidForAuction($auctionId) . "."; echo "<p/><button id=\"dismiss\" class=\"ui-widget ui-button ui-state-default ui-corner-all ui-button-text-only\" style=\"width:100px;height:40px;\" onClick=\"window.parent.Shadowbox.close( );\">Okay</button>"; // Does the user have enough money to place this bid? If so, place it. } elseif (isAuctionStillActiveFixedEnd($auctionId) && $bidAmt <= getPoints($uuid)) { placeBidFixedEnd($auctionId, $uuid, $bidAmt, $gameinstance); echo "You have bid " . $CURRENCY_SYMBOL . $bidAmt . " on this work."; echo "<p/><button id=\"dismiss\" class=\"ui-widget ui-button ui-state-default ui-corner-all ui-button-text-only\" style=\"width:100px;height:40px;\" onClick=\"window.parent.Shadowbox.close( );\">Okay</button>"; // Logically, this should come first so we don't call the function 3 times in a row for other checks... FIXME } elseif (!isAuctionStillActiveFixedEnd($auctionId)) { echo "The auction has already ended!"; echo "<p/><button id=\"dismiss\" class=\"ui-widget ui-button ui-state-default ui-corner-all ui-button-text-only\" style=\"width:100px;height:40px;\" onClick=\"window.parent.Shadowbox.close( );\">Okay</button>"; } else { // Almost certainly due to a lack of points -- "place bid" button disappears when the auction ends. // Still, we should be a little more nuanced with the error state here. echo "You don't have " . $CURRENCY_SYMBOL . $bidAmt . "!"; echo "<p/><button id=\"dismiss\" class=\"ui-widget ui-button ui-state-default ui-corner-all ui-button-text-only\" style=\"width:100px;height:40px;\" onClick=\"window.parent.Shadowbox.close( );\">Okay</button>"; }