本文整理汇总了PHP中Queue::addUserLeaderBoard方法的典型用法代码示例。如果您正苦于以下问题:PHP Queue::addUserLeaderBoard方法的具体用法?PHP Queue::addUserLeaderBoard怎么用?PHP Queue::addUserLeaderBoard使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Queue
的用法示例。
在下文中一共展示了Queue::addUserLeaderBoard方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getFacebookGiftRequest
public static function getFacebookGiftRequest($user, $requestIds)
{
if (!empty($user) && !empty($requestIds)) {
$day = intval(GameConstantUtil::getConstant(FacebookRequestUtils::$CONSTANT_REQUEST_GIFT_TIME));
if ($day <= 0) {
$day = 7;
}
$coin = intval(GameConstantUtil::getConstant(FacebookRequestUtils::$CONSTANT_REQUEST_GIFT_COIN));
if ($day <= 0) {
$day = FacebookRequestUtils::$CONSTANT_REQUEST_GIFT_COIN_DEFAULT;
}
$SQL = "SELECT * FROM " . TBL_GAME_FB_REQUEST . " WHERE `to`='" . DBUtils::mysql_escape($user->facebookId) . "' AND used=0 AND type='" . FacebookRequestUtils::$CONSTANT_REQUEST_TYPE_GIFT . "' AND requestId IN (" . $requestIds . ") ORDER BY `time` DESC";
$fbRequests = GameFbRequest::findBySql(DBUtils::getConnection(), $SQL);
$userArray = array();
if (!empty($fbRequests) && sizeof($fbRequests) > 0) {
for ($i = sizeof($fbRequests) - 1; $i >= 0; $i--) {
$req = $fbRequests[$i];
$req->coin = $coin;
if (!empty($req)) {
$usrArr = $userArray[$req->userId];
if (empty($usrArr)) {
$usrArr = array();
array_push($usrArr, $req);
} else {
$last = $usrArr[sizeof($usrArr) - 1];
if (intval(date("Ymd", $req->time)) - intval(date("Ymd", $last->time)) >= 7) {
array_push($usrArr, $req);
} else {
GameFbRequest::useRequest($req->getId(), 2);
}
}
$userArray[$req->userId] = $usrArr;
}
}
}
unset($fbRequests);
$result = array();
foreach ($userArray as $userReq) {
if (!empty($userReq) && sizeof($userReq) > 0) {
try {
$coin = 0;
$obj = new stdClass();
$tmp = GameUsers::findById(DBUtils::getConnection(), $userReq[0]->userId);
if (!empty($tmp)) {
$obj->user = new stdClass();
$obj->user->userId = $tmp->userId;
$obj->user->userName = $tmp->userName;
$obj->user->userFirstname = $tmp->userFirstname;
$obj->user->userLastname = $tmp->userLastname;
$obj->user->facebookId = $tmp->facebookId;
$obj->user->userXP = $tmp->userXP;
$obj->user->userLevelNumber = $tmp->userLevelNumber;
$obj->user->coins = $tmp->coins;
$ids = "";
foreach ($userReq as $req) {
if (!empty($req)) {
GameFbRequest::useRequest($req->getId());
$coin = $coin + intval($req->coin);
if (!empty($ids)) {
$ids = $ids . "," . $req->requestId;
} else {
$ids = $ids . "" . $req->requestId;
}
}
}
$obj->coin = $coin;
$obj->ids = $ids;
$obj->type = FacebookRequestUtils::$CONSTANT_REQUEST_TYPE_GIFT;
array_push($result, $obj);
}
} catch (Exception $exc) {
error_log($exc->getTraceAsString());
}
}
}
unset($userArray);
foreach ($result as $value) {
if (!empty($value)) {
$time = time();
$user->setCoins($user->getCoins() + $value->coin);
$user->updateToDatabase(DBUtils::getConnection());
$userCoinLog = new GameUserCoinLog();
$userCoinLog->setUserId($user->userId);
$userCoinLog->setCoin($user->getCoins());
$userCoinLog->setDifCoin($value->coin);
$userCoinLog->setTime($time);
$userCoinLog->setType(FacebookRequestUtils::$CONSTANT_REQUEST_TYPE_GIFT);
$userCoinLog->setAdd(1);
$userCoinLog->setResult(FacebookRequestUtils::$CONSTANT_REQUEST_TYPE_GIFT . "->" . $value->user->userId . "->" . $value->ids);
$userCoinLog->setOpponentId($value->user->userId);
$userCoinLog->setUserLevel($user->userLevelNumber);
//$userCoinLog->setUserSpentCoin($user->opponentId);
try {
$userCoinLog->insertIntoDatabase(DBUtils::getConnection());
} catch (Exception $exc) {
error_log($exc->getTraceAsString());
}
Queue::addUserLeaderBoard($user->userId, $value->coin, $time);
}
}
//.........这里部分代码省略.........
示例2: getDailyBonusPrice
public static function getDailyBonusPrice($user)
{
if (!empty($user) && !empty($user->userId)) {
$start = strtotime(date("Y-m-d") . " 00:00:00");
$end = strtotime(date("Y-m-d") . " 00:00:00 +1 day");
$SQL = "SELECT * FROM " . TBL_GAME_USER_COIN_LOG . " WHERE userId=" . DBUtils::mysql_escape($user->userId, 1) . " AND type='" . GameUserXpLog::$CONSTANT_LOG_TYPE_DAILYBONUS . "' AND time<" . $end . " AND time>" . $start;
$coinLog = null;
try {
$coinLog = GameUserCoinLog::findBySql(DBUtils::getConnection(), $SQL);
} catch (Exception $exc) {
error_log($exc->getTraceAsString());
}
if (empty($coinLog) || sizeof($coinLog) < 1) {
$gain = 0;
$order = 0;
$bonuses = BonusUtils::getUserDailyBonus($user->userId);
if (!empty($bonuses) && sizeof($bonuses) > 0) {
for ($i = 0; $i < sizeof($bonuses); $i++) {
$bonus = $bonuses[$i];
if (!empty($bonus) && !empty($bonus->coin)) {
if ($gain < $bonus->coin && !empty($bonus->active)) {
$gain = $bonus->coin;
$order = $bonus->order;
}
}
}
}
if ($gain > 0) {
$time = time();
$user->setCoins($user->getCoins() + $gain);
$user->updateToDatabase(DBUtils::getConnection());
$userCoinLog = new GameUserCoinLog();
$userCoinLog->setUserId($user->userId);
$userCoinLog->setCoin($user->getCoins());
$userCoinLog->setDifCoin($gain);
$userCoinLog->setTime($time);
$userCoinLog->setType(GameUserXpLog::$CONSTANT_LOG_TYPE_DAILYBONUS);
$userCoinLog->setAdd(1);
$userCoinLog->setResult(GameUserXpLog::$CONSTANT_LOG_TYPE_DAILYBONUS . "->" . $order);
$userCoinLog->setUserLevel($user->userLevelNumber);
//$userCoinLog->setUserSpentCoin($user->opponentId);
try {
$userCoinLog->insertIntoDatabase(DBUtils::getConnection());
} catch (Exception $exc) {
error_log($exc->getTraceAsString());
}
Queue::addUserLeaderBoard($user->userId, $gain, $time);
return true;
}
}
}
return false;
}
示例3: buyItem
public static function buyItem($user, $toUser, $item, $gameId = null, $time = null)
{
if (empty($time)) {
$time = time();
}
$result = new FunctionResult();
$result->success = false;
if (!empty($user)) {
if (!empty($toUser)) {
if (!empty($item)) {
if ($user->coins >= $item->coin) {
Queue::addUserCoinLog($user->userId, $item->coin, $item->coin, $time, GameUserXpLog::$CONSTANT_LOG_TYPE_BUY_ITEM, 0, $gameId, $item->id . "_" . $item->coin . "_" . $item->itemCode, $toUser->userId);
Queue::addUserLeaderBoard($user->userId, -1 * $item->coin, $time);
$coin = $user->coins - $item->coin;
$user->setCoins($coin);
$user->updateToDatabase(DBUtils::getConnection());
$userItemLog = new GameUserItemLog();
$userItemLog->setItemId($item->id);
$userItemLog->setGameId($gameId);
$userItemLog->setTo($toUser->userId);
$userItemLog->setTime($time);
$userItemLog->setUserId($user->userId);
$userItemLog->setCoin($item->coin);
$userItemLog->setQuantity($item->quantity);
$userItemLog->setType(GameUserItemLog::$CONSTANT_ITEM_LOG_TYPE_BUY);
$userItemLog->setUserLevel($user->userLevelNumber);
$userItemLog->setUserCoin($user->coins);
//$userItemLog->setUserSpentCoin(GameUserItemLog::$CONSTANT_ITEM_LOG_TYPE_BUY);
try {
$userItemLog->insertIntoDatabase(DBUtils::getConnection());
} catch (Exception $exc) {
error_log($exc->getMessage());
error_log($exc->getTraceAsString());
}
$userItem = ItemUtils::getUserItem($toUser->userId, $item->itemCode);
if (empty($userItem)) {
$userItem = new GameUserItems();
$userItem->setId(-1);
$userItem->setUserId($toUser->userId);
$userItem->setItemCode($item->itemCode);
$userItem->setActive(1);
$userItem->setQuantity(0);
}
$userItem->setTime($time);
$userItem->setQuantity($item->quantity + $userItem->quantity);
try {
$userItem->updateInsertToDatabase(DBUtils::getConnection());
} catch (Exception $exc) {
error_log($exc->getMessage());
error_log($exc->getTraceAsString());
}
$result->success = true;
$result->data = new stdClass();
$user->items = ItemUtils::getUserItems($user->userId);
$result->data->user = $user;
$result->data->item = $item;
return $result;
} else {
$result->result = LanguageUtils::getText("LANG_API_NOT_ENOUGH_COIN");
return $result;
}
} else {
$result->result = LanguageUtils::getText("LANG_API_TO_ITEM_EMPTY");
return $result;
}
} else {
$result->result = LanguageUtils::getText("LANG_API_TO_USER_EMPTY");
return $result;
}
} else {
$result->result = LanguageUtils::getText("LANG_API_USER_EMPTY");
return $result;
}
}
示例4: updateCoin
public static function updateCoin(GameUsers $user, GameUsers $opponent, $roomGroupId, $action, $gameId = null, $double = 0, $normal = true, $type = null, $time = null)
{
//Add Log
$result = new FunctionResult();
$result->success = false;
if (!empty($user) && !empty($action)) {
$roomGroup = GameRoomGroups::getRoomGroupByGroupId($roomGroupId);
if (!empty($roomGroup)) {
$coin = $user->getCoins();
$maxCoin = $roomGroup->getMatchCoin() * 128;
$matchCoins = $roomGroup->getMatchCoin();
if (!$normal) {
$matchCoins = $matchCoins * 2;
}
if ($double > 1) {
$matchCoins = $matchCoins * pow(2, $double);
}
$calCcoin = $matchCoins;
$error = false;
if ($action == GameUtils::$GAME_RESULT_ACTION_WIN) {
if ($matchCoins > $maxCoin) {
$matchCoins = $maxCoin;
}
} else {
if ($action == GameUtils::$GAME_RESULT_ACTION_LOST) {
$matchCoins = -1 * $matchCoins;
if ($coin + $matchCoins < 0) {
$matchCoins = -1 * $coin;
}
} else {
$error = true;
}
}
if (!$error) {
$gameResult = $action . "_" . $normal . "_" . $double . "_" . $type;
$oppId = null;
if (!empty($opponent)) {
$oppId = $opponent->getUserId();
}
if (empty($time)) {
$time = time();
}
$add = 1;
if ($action == GameUtils::$GAME_RESULT_ACTION_LOST) {
$add = 0;
}
Queue::addUserCoinLog($user->userId, $calCcoin, $matchCoins, $time, GameUserXpLog::$CONSTANT_LOG_TYPE_GAME, $add, $gameId, $gameResult, $oppId);
Queue::addUserLeaderBoard($user->userId, $matchCoins, $time);
$user->setCoins($coin + $matchCoins);
$result->success = true;
} else {
$result->success = false;
$result->result = "Action unknown";
}
} else {
$result->success = false;
$result->result = "Room Group is unknown";
}
}
return $result;
}
示例5: buyProduct
public static function buyProduct($user, $product, $requestId, $paymentId, $signedReq, $status, $currency, $amount, $quantity, $type, $time)
{
if (empty($time)) {
$time = time();
}
$result = new FunctionResult();
$result->success = false;
if (!empty($user)) {
if (!empty($product)) {
if ($status == "completed") {
Queue::addUserCoinLog($user->userId, $product->coinCount, $product->coinCount, $time, GameUserXpLog::$CONSTANT_LOG_TYPE_BUY_PRODUCT, 1, null, $requestId . "_" . $product->id . "_" . $product->fbId . "_" . $product->coinCount . "_" . $product->coinCount, null);
Queue::addUserLeaderBoard($user->userId, $product->coinCount, $time);
$coin = $user->coins + $product->coinCount * $quantity;
$user->setCoins($coin);
$user->updateToDatabase(DBUtils::getConnection());
}
//if product campaign
if ($product->type == GameFbProducts::$TYPE_CAMPAIGN && !empty($product->products)) {
try {
$products = json_decode($product->products);
if (!empty($products)) {
foreach ($products as $pro) {
if (!empty($pro) && !empty($pro->itemId)) {
ItemUtils::buyCampaignItem($user, $pro->itemId, $pro->count, $time);
}
}
}
} catch (Exception $exc) {
error_log($exc->getMessage());
error_log($exc->getTraceAsString());
}
}
//if product campaign
$userProductLog = new GameUserFbProductLog();
$userProductLog->setAmount($amount);
$userProductLog->setCoinCount($product->coinCount);
$userProductLog->setCurrency($currency);
$userProductLog->setPaymentId($paymentId);
$userProductLog->setProdudctId($product->id);
$userProductLog->setQuantity($quantity);
$userProductLog->setRequestId($requestId);
$userProductLog->setSignedReq($signedReq);
$userProductLog->setStatus($status);
$userProductLog->setTime($time);
$userProductLog->setType($type);
$userProductLog->setUserId($user->userId);
$userProductLog->setUserLevel($user->userLevelNumber);
$userProductLog->setUserCoin($user->coins);
try {
$userProductLog->insertIntoDatabase(DBUtils::getConnection());
} catch (Exception $exc) {
error_log($exc->getMessage());
error_log($exc->getTraceAsString());
}
$result->success = true;
$result->data = new stdClass();
$result->data->user = $user;
return $result;
} else {
$result->result = LanguageUtils::getText("LANG_API_TO_ITEM_EMPTY");
return $result;
}
} else {
$result->result = LanguageUtils::getText("LANG_API_USER_EMPTY");
return $result;
}
}