当前位置: 首页>>代码示例>>PHP>>正文


PHP Queue::addUserCoinLog方法代码示例

本文整理汇总了PHP中Queue::addUserCoinLog方法的典型用法代码示例。如果您正苦于以下问题:PHP Queue::addUserCoinLog方法的具体用法?PHP Queue::addUserCoinLog怎么用?PHP Queue::addUserCoinLog使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Queue的用法示例。


在下文中一共展示了Queue::addUserCoinLog方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: 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;
     }
 }
开发者ID:bsormagec,项目名称:tavlamania-php,代码行数:74,代码来源:ItemFunctions.php

示例2: 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;
 }
开发者ID:bsormagec,项目名称:tavlamania-php,代码行数:61,代码来源:GameFunctions.php

示例3: 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;
     }
 }
开发者ID:bsormagec,项目名称:tavlamania-php,代码行数:67,代码来源:FBProductFunctions.php


注:本文中的Queue::addUserCoinLog方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。