Exemple #1
0
 /**
  * 移动
  * @param $params
  *  require u              --             user id
  *          d              --             item数组
  *                         id             --        type id(类型id)
  *                         pos            --        position information of items
  * @return 
  *                         s              --        OK ,or other fail
  *                                     notexsit ,不存在
  *				      gem
  */
 public function move($params)
 {
     $uid = $params['u'];
     $tu = new TTUser($uid);
     if ($tu->check_dup($params['_cid'], $ret)) {
         return $ret;
     }
     $index = 1;
     $ids = array();
     $pop = 0;
     $now = time();
     foreach ($params['d'] as $index => $row) {
         $item_obj = $tu->getbyid($row['id']);
         if (!$item_obj) {
             $ret['s'] = 'notexsit';
             $ret['index'] = $index;
             return $ret;
         }
         $item = ItemConfig::getItem($item_obj['tag']);
         if (!$item) {
             $ret['s'] = 'notexsit';
             $ret['index'] = $index;
             return $ret;
         }
         if ($item['type'] == 'ro' && $row['pos'] == 's') {
             //todo $tu 结算
             if ($item_obj['pos'] != 's') {
                 require_once 'GoodsController.php';
                 GoodsController::checkout($params);
                 $item_obj = $tu->getbyid($row['id']);
             }
             //*{//对货物尚未卖完的店面进行移动时要先单个结算,确定货物队列为空时才能移动
             if ($item_obj['_s'] == 'goods') {
                 $ret['error'] = 'notempty';
                 $ret['s'] = 'OK';
                 $ret['index'] = $index;
                 TTLog::record(array('m' => __METHOD__, 'tm' => $_SERVER['REQUEST_TIME'], 'u' => $uid, 'sp2' => 'movegoodsshop', 'shoptag' => $item_obj['tag'], 'sp1' => $item_obj['id']));
                 continue;
             }
             //*/
         }
         if ($item['type'] != 'ro') {
             //改为不计算店面的人气
             if ($item['tag'] == '60102') {
                 //移动电影院后,结算时间应当
                 $row['ctime'] = $now;
             }
             if ($row['pos'] != 's' && $item_obj['pds'] == 's') {
                 $pop += $item['pop'];
                 if ($item['type'] == 'rs') {
                     //特殊店需从仓库摆出,结算时间为摆放时间
                     $row['ctime'] = $now;
                 }
             } else {
                 if ($row['pos'] == 's' && $item_obj['pds'] != 's') {
                     $pop -= $item['pop'];
                     if ($item['type'] == 'rs') {
                         //特殊店放入仓库结算时间需置零
                         unset($row['ctime']);
                     }
                 }
             }
         }
         foreach ($row as $k => $v) {
             $item_obj[$k] = $v;
         }
         $ret[$row['id']] = $item;
         $tu->puto($item_obj, '', false);
         //reduce a get op
     }
     if ($pop) {
         $popu = $tu->numch(TT::POPU, $pop);
     }
     if (!$ret['s']) {
         $ret['s'] = 'OK';
     }
     return $ret;
 }
Exemple #2
0
 /**
  * 卖出
  * @param $params
  *  require u  -- user id
  *  require d  -- item_id 数组
  *     
  * @return 
  *  s   -- OK ,or other fail
  *                                     notexsit ,不存在配置
  *                                     notsale ,不能购买的物品
  *                                     level,等级未到 
  *                                     achive, 所需成就buy_need_achiveid 未达成 
  *                                     task,所需任务未达成
  *                                     buynumlimit,限量版已经卖完
  *                                     money,
  *				      gem
  */
 public function sale($params)
 {
     $uid = $params['u'];
     $tu = new TTUser($uid);
     if ($tu->check_dup($params['_cid'], $ret)) {
         return $ret;
     }
     foreach ($params['d'] as $index => $id) {
         $item_obj = $tu->getbyid($id);
         if (!$item_obj) {
             $ret['s'] = 'notexsit';
             $ret['index'] = $index;
             return $ret;
         }
         $item = ItemConfig::getItem($item_obj['tag']);
         if (!$item) {
             $ret['s'] = 'notexsit';
             $ret['index'] = $index;
             return $ret;
         }
         $sale_ret = $tu->saleItem($item_obj);
         if ($sale_ret['s'] != 'OK') {
             $sale_ret['index'] = $index;
             return $sale_ret;
         }
         if ($item_obj['pos'] != 's') {
             $pop -= $item['pop'];
         }
     }
     if ($pop) {
         $tu->numch(TT::POPU, $pop);
     }
     $tu->remove($params['d']);
     $ret['s'] = 'OK';
     return $ret;
 }
Exemple #3
0
 /**
  * 扩大商厦
  * @param $params
  *   require  u         -- 玩家id
  * @return 
  *            s         --  OK
  */
 public function enlarge_mall($params)
 {
     $level2money = array(0 => 0, 2 => 500, 5 => 1000, 9 => 10000, 13 => 10000, 17 => 30000, 21 => 30000, 25 => 50000, 29 => 80000, 33 => 100000, 37 => 200000, 41 => 300000, 45 => 500000, 54 => 800000, 66 => 1000000);
     $uid = $params['u'];
     $tu = new TTUser($uid);
     if ($tu->check_dup($params['_cid'], $ret)) {
         return $ret;
     }
     $user = $tu->getf(array(TT::EXP_STAT, TT::CAPACITY_STAT));
     $capa = $user[TT::CAPACITY_STAT];
     $cap = explode(",", $capa);
     //		$ret['capa'] = $capa;         // for debug
     //		$ret['cap'] = $cap;         // for debug
     $width = $cap[0];
     $height = $cap[1];
     //		$ret['width'] = $width;         // for debug
     //		$ret['height'] = $height;         // for debug
     $length = count(UpgradeConfig::$_upgrade);
     //必须先遍历找出最大值
     $max_width = UpgradeConfig::$_upgrade[$length]['shopwidth'];
     $max_height = UpgradeConfig::$_upgrade[$length]['shopheight'];
     foreach (UpgradeConfig::$_upgrade as $upgrade) {
         if ($width > $upgrade['shopwidth'] || $height > $upgrade['shopheight']) {
             continue;
         }
         if ($width == $upgrade['shopwidth'] && $height == $upgrade['shopheight']) {
             if ($width == $max_width && $height == $max_height) {
                 $need = $upgrade;
                 break;
             }
             continue;
         }
         $need = $upgrade;
         break;
     }
     //		$ret['need'] = $need;    // for debug
     //		$leftmoney = $tu->change( TT::MONEY_STAT,0-$level2money[$need['level']]); //有可能在之间的某个level调用此函数
     $l = 0;
     foreach ($level2money as $level => $money) {
         if ($level < $need['level']) {
             $l = $level;
             continue;
         }
         break;
     }
     $leftmoney = $tu->change(TT::MONEY_STAT, 0 - $level2money[$l]);
     if ($leftmoney < 0) {
         $ret['s'] = 'money';
         return $ret;
     }
     $tu->putf(TT::CAPACITY_STAT, $need['shopwidth'] . "," . $need['shopheight']);
     TTLog::record(array('m' => __METHOD__, 'tm' => $_SERVER['REQUEST_TIME'], 'u' => $uid, 'intp1' => $level2money[$l], 'sp1' => $need['shopwidth'] . "," . $need['shopheight']));
     $ret['s'] = 'OK';
     return $ret;
 }