$stmt = $dbh->prepare("SELECT collections.id,owner,gameinstance,collectors.name,collectors.id as coid from collections inner join collectors on collectors.id = owner where gameinstance = ?"); $stmt->bindParam(1, $_GET['gameid']); $stmt->execute(); while ($row = $stmt->fetch()) { if ($row['coid'] == $FCN_SUPERUSER) { continue; } // Specify the name of the user collection table and create it. In retrospect, I'm skeptical that this // is the best way to keep track of who owns what. It made sense (maybe) when we thought we'd be having // multiple game instances running simultaneously, but I'd prefer just having an owner field in the // main works table now. $userTable = $row['coid'] . "_" . $_GET['gameid'] . "_coll"; $substat = $dbh->prepare("CREATE TABLE " . $userTable . " ( work INT )"); $substat->execute(); // Give each player 200 points adjustPoints($row['coid'], 200); // Select n random works into the user table echo "<h3>" . $row['name'] . "</h3>"; $subs = $dbh->prepare("SELECT * FROM " . $tempTableName . " WHERE id > -1 ORDER BY RAND() LIMIT " . $initialSize); $subs->execute(); while ($subrow = $subs->fetch()) { // Show game admin who got what, and then delete the selected works from this temporary table. echo "<img src=\"../img.php?img=" . $subrow['id'] . "\" style=\"width:100px;\"/>\n"; $deletion = $dbh->prepare("DELETE FROM " . $tempTableName . " WHERE id = ?"); $deletion->bindParam(1, $subrow['id']); $deletion->execute(); // For purposes of provenance, record this as a "trade" from origin -1 $insertion = $dbh->prepare("INSERT INTO trades(origin, destination, gameinstance, work_from_origin, work_from_destination, accepted) VALUES(?,?,?,?,?,?)"); $insertion->bindValue(1, -1); $insertion->bindValue(2, $row['owner']); $insertion->bindValue(3, $_GET['gameid']);
$substmt->bindParam(2, $origin); $substmt->bindParam(3, $gameinstance); $substmt->bindParam(4, $tradeMessage); $substmt->bindValue(5, 0); $substmt->execute(); $mailNotification = "<a href=\"" . $FCN_ROOT . "mail.php\">" . getUsername($uuid) . " sent you a message about your recent trade.</a>"; createNotification($origin, $E_MESSAGE_RECEIVED, $mailNotification); } // If money was included, adjust points accordingly... if ($offered > 0) { adjustPoints($origin, -$offered); adjustPoints($uuid, $offered); } if ($requested > 0) { adjustPoints($origin, $requested); adjustPoints($uuid, -$requested); } } // FIXME this is nuts -- verbatim repetition of above if ($approved == "0") { $headline = getUsername($destination) . " rejected " . getUsername($origin) . "'s trade proposal"; $stmt = $dbh->prepare("UPDATE events SET type = ?, headline = ? WHERE xref = ? AND type = ?"); $stmt->bindValue(1, $E_TRADE_REJECTED); $stmt->bindValue(2, $headline); $stmt->bindValue(3, $tid); $stmt->bindValue(4, $E_TRADE_PROPOSED); $stmt->execute(); createNotification($origin, $E_TRADE_REJECTED, getUsername($destination) . " rejected your trade proposal."); if ($tradeMessage != "") { $substmt = $dbh->prepare("INSERT INTO msgs(uidf,uidt,gid,string,rr) VALUES( ?, ?, ?, ?, ? )"); $substmt->bindParam(1, $uuid);
/** * 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); }
$stmt = $dbh->prepare("UPDATE tombstones SET approved = ? WHERE id = ?"); $stmt->bindParam(1, $approvalAction); $stmt->bindParam(2, $challengeId); $stmt->execute(); if ($action === "approve") { adjustPoints($player, 10); createNotification($player, $E_ACHIEVEMENT, "Your tombstone for " . getTombstone($work, true) . " was approved by the game administrator! You receive " . $CURRENCY_SYMBOL . "10."); } else { createNotification($player, $E_ACHIEVEMENT, "Your tombstone for " . getTombstone($work, true) . " was rejected by the game administrator! You can create a new tombstone to try again."); $stmt = $dbh->prepare("DELETE FROM tombstones WHERE id = ?"); $stmt->bindParam(1, $challengeId); $stmt->execute(); } } else { if ($mode === "d") { $approvalAction = $action === "approve" ? 1 : 0; $stmt = $dbh->prepare("UPDATE work_descriptions SET approved = ? WHERE id = ?"); $stmt->bindParam(1, $approvalAction); $stmt->bindParam(2, $challengeId); $stmt->execute(); if ($action === "approve") { adjustPoints($player, 10); createNotification($player, $E_ACHIEVEMENT, "Your description for " . (workHasTombstone($work) ? getTombstone($work, true) : "a work") . " was approved! You receive " . $CURRENCY_SYMBOL . "10."); } else { createNotification($player, $E_ACHIEVEMENT, "Your description for " . (workHasTombstone($work) ? getTombstone($work, true) : "a work") . " was rejected! You can modify the description and try again."); } } } ?>
$approver = $_GET['uuid']; $action = $_GET['action']; $player = $_GET['player']; $work = $_GET['work']; // APPROVED column in these tables: 0 = rejected; 1 = accepted; 2 = pending. // These values really need to be global variables. Magic numbers abound. FIXME $approvalAction = $action === "approve" ? 1 : 0; $stmt = $dbh->prepare("UPDATE tombstones SET approved = ? WHERE id = ?"); $stmt->bindParam(1, $approvalAction); $stmt->bindParam(2, $challengeId); $stmt->execute(); if ($action === "approve") { // Award the player who submitted the tombstone 10 FCGs and notify them. adjustPoints($player, 10); createNotification($player, $E_ACHIEVEMENT, "Your tombstone for " . getTombstone($work, true) . " was approved by " . getUserName($approver) . "! You receive " . $CURRENCY_SYMBOL . "10."); } else { // ...or tell them they got it wrong. createNotification($player, $E_ACHIEVEMENT, "Your tombstone for " . getTombstone($work, true) . " was rejected by " . getUserName($approver) . "! You can create a new tombstone to try again."); // Delete the tombstone attempt. There's a mismatch here between the way we use // approval flags (0/1) and the fact that we just drop rejected attempts from the // table altogether, but fixing the problem will require rewriting some utility // functions in functions.php. $stmt = $dbh->prepare("DELETE FROM tombstones WHERE id = ?"); $stmt->bindParam(1, $challengeId); $stmt->execute(); } // Finally, award the approver 10 points. adjustPoints($approver, 10); ?>
<?php /** * award.php: do the work that allows the game admin to arbitrarily award (or penalize) players by * adjusting their points. */ ob_start(); require '../functions.php'; require '../db.php'; ob_end_clean(); $player = $_GET['collector']; $message = $_GET['desc']; $points = $_GET['points']; createNotification($player, $E_HAZARD, $message); adjustPoints($player, $points); echo "Divine intervention complete."; ?>