Example #1
0
 /**
  * @param $params
  *  require             u          -- user id
  *                      d          -- item        支持购买多种物品
  *                                 tag            --  tag to distiguish item type
  *                                 pos            --  position for describe item 
  * @return 
  *                      s          -- OK ,or other fail
  *                                     notexsit ,配置不一致
  *                                     notbuy ,不能购买的物品
  *                                     level,等级未到 
  *                                     achive, 所需成就buy_need_achiveid 未达成 
  *                                     task,所需任务未达成
  *                                     buynumlimit,限量版已经卖完
  *                                     money,
  *				       gem
  *			index     -- 第几个物品开始后面的物品没有购买成功
  *
  *                      ids        -- the new generate id
  */
 public function buy($params)
 {
     $uid = $params['u'];
     $ids = array();
     $tu = new TTUser($uid);
     if ($tu->check_dup($params['_cid'], $ret)) {
         return $ret;
     }
     $pop = 0;
     $now = time();
     foreach ($params['d'] as $index => $row) {
         $tag = $row['tag'];
         $num = 1;
         $item = ItemConfig::getItem($tag);
         if (!$item) {
             $ret['s'] = 'notexsit';
             $ret['index'] = $index;
             return $ret;
         }
         $buy_ret = $tu->buyItem($tag, $num);
         if ($buy_ret['s'] != 'OK') {
             $buy_ret['index'] = $index;
             return $buy_ret;
         }
         if ($item['type'] == "ro") {
             $row['id'] = $tu->getdid(false, TT::SHOP_GROUP);
             //shop id
         } else {
             //不维护店面人气,但厕所的人气需包含
             $row['id'] = $tu->getdid(false, TT::ITEM_GROUP);
             //other
             $pop += $item['pop'];
             if ($item['type'] == 'rs') {
                 //特殊店需记录一个结算时间
                 $row['ctime'] = $now;
             }
         }
         $ret['ids'][$index] = $tu->puto($row, TT::ITEM_GROUP, false);
     }
     if ($pop) {
         $popu = $tu->numch(TT::POPU, $pop);
     }
     $ret['s'] = 'OK';
     return $ret;
 }
Example #2
0
 /**
  * 购买卡车
  * @param $params
  *  require u  -- user id
  *  require c  -- car type
  *             pos    --  position information about car
  *             tag    --  tag to distinguish car type
  * @return 
  *  s   -- OK ,or other fail
  *  ids  -- the new generate id
  *  a   --  the account of user 
  */
 public function buy($params)
 {
     $uid = $params['u'];
     $tu = new TTUser($uid);
     $ids = array();
     foreach ($params['c'] as $index => $row) {
         $buy_ret = $tu->buyItem($row['tag']);
         if ($buy_ret['s'] != 'OK') {
             $ret['index'] = $index;
             return $buy_ret;
         }
         $row['id'] = $tu->getdid(null, TT::CAR_GROUP);
         $tu->puto($row);
         $ids[$index] = $row['id'];
     }
     $ret['s'] = 'OK';
     $ret['ids'] = $ids;
     return $ret;
 }
Example #3
0
            ?>
			
				<h3>您的礼物已经领取,请在仓库中查收。</h3>
			
		<?php 
        }
        ?>
	         <a href='<?php 
        echo RenrenConfig::$canvas_url;
        ?>
' class='giftformsubmit' >返回游戏</a>	
	</div>
	</div>
		<?php 
        if (!$got) {
            $id = $ttu->getdid('', $gift[$gid]['group']);
            $data['tag'] = $gid;
            $data['id'] = $id;
            $data['pos'] = 's';
            $ttu->puto($data);
        }
    }
    if (!$got) {
        $link['geted'][$touser] = 1;
        $tw->put($link);
    }
    if (!$gid) {
        ?>
		<xn:redirect url="<?php 
        echo RenrenConfig::$canvas_url;
        ?>
Example #4
0
if ($session_key != $sess['session_key']) {
    $renren = new Renren();
    $renren->api_key = RenrenConfig::$api_key;
    $renren->secret = RenrenConfig::$secret;
    $renren->session_key = $session_key;
    $renren->init($session_key);
    $rt = $renren->api_client->users_getLoggedInUser();
    if ($rt['uid'] == $pid) {
        $sess['session_key'] = $session_key;
        TTGenid::update($sess, $sess['id']);
    } else {
        header('Location: ' . RenrenConfig::$canvas_url);
    }
}
$tu = new TTUser($uid);
$iid = $tu->getdid('installbar', TT::OTHER_GROUP);
$barobj = $tu->getbyid($iid);
$install_bar = true;
if ($barobj == null || $barobj['email'] == null) {
    $install_bar = true;
} else {
    $install_bar = false;
}
if ($gflg) {
    $data = $ts->getbyid($gflg);
    $bids = $data['rfids'];
    if (strstr($bids, $pid)) {
    } else {
        //给玩家礼物
        $flag = $data['gift_id'];
        $fconf = ItemConfig::get($flag);
Example #5
0
 /**
 			  五,增加好友箱数:						
  说明:	货车出发之后,放进仓库之前,好友均可点击,点击会增加货物箱数。				
 			  按钮问题:好友帮助加箱数的按钮,在货车运货过程中和货车回来都有。而当货车回来,但是没有放进仓库时,只有到好友家才有按钮,自己的副驾驶功能消失。				
 			  限制:	每人每日可帮一个好友一次。				
 			  级别越高增加的箱数越多。					
 			  级别:	箱数:				
 			  1	1				
 			  20	2				
 			  40	3				
 			  被帮助者奖励:	礼物为一箱货物。				
 			  帮助者奖励:	获得所进货物经验(进货+取货的经验和)相等的经验。	
 			 * @param $params
 			 *  require  u           --  user id
 			 *           f         --  friend id
 			 *           cid         --  car id
 			 * @return 
 			 *           s           --  OK
 			 --  helped,已经拜访过
 			 --  nofriend,不是朋友
 			 award        
 			 exp         --奖励经验
 			 money       --奖励金钱 
 */
 public function help_car($params)
 {
     $uid = $params['u'];
     $nid = $params['f'];
     $cid = $params['cid'];
     $tu = new TTUser($uid);
     $ftu = new TTUser($nid);
     $fdid = $tu->getdid($nid, 'fr');
     $now = time();
     $now_date = date('Ymd', $now);
     $fdata = $tu->getbyid($fdid);
     if (!$fdata) {
         $ret['s'] = 'nofriend';
         return $ret;
     }
     $vt = $fdata['ht'];
     $vt_date = date('Ymd', $vt);
     if ($vt_date == $now_date && $fdata['help_car'] == '1') {
         $ret['s'] = 'helped';
         return $ret;
         //for test
     }
     $car = $ftu->getbyid($cid);
     if (!$car) {
         $ret['s'] = 'nocar ' . $cid;
         return $ret;
     }
     $carconf = ItemConfig::getItem($car['tag']);
     $counts = count($car['help']);
     if ($counts > $carconf['gridWidth']) {
         $ret['help_time'] = $counts;
         $ret['gridW'] = $car['help'];
         $ret['s'] = 'max';
         return $ret;
     }
     $goodsid = $car['goodsTag'];
     $gconfig = ItemConfig::getItem($goodsid);
     $add_exp = $gconfig['exp'];
     if (!$add_exp) {
         $ret['s'] = 'nogoods';
         $ret['g'] = $gconfig;
         return $ret;
     }
     $level = $tu->getLevel();
     $num = 1;
     if ($level > 39) {
         $num = 2;
     }
     if ($level > 69) {
         $num = 3;
     }
     //$mydata = TTGenid::getbyid($uid);
     $car['help'][$uid] = $num;
     $add_exp *= 4;
     $ret['exp'] = $tu->addExp($add_exp);
     $ret['award']['exp'] = $add_exp;
     $fdata['ht'] = $now;
     $fdata['help_car'] = 1;
     $tu->puto($fdata, 'fr', false);
     $ftu->puto($car, '', false);
     $ret['cid'] = $cid;
     $ret['s'] = 'OK';
     $ret['t'] = $now;
     return $ret;
 }
Example #6
0
 /**
  * 收取礼物
  * @param $params
  *  require         u        -- user id
  *                  gids      -- gift ids
  * @return 
  *  s       -- OK ,or other fail
  *  id2id   -- 新旧ids映射
  */
 public function accept($params)
 {
     $uid = $params['u'];
     $tu = new TTUser($uid);
     $gifts = $params['gids'];
     foreach ($gifts as $gid) {
         $d = $tu->getbyid($gid);
         $oid = $d['id'];
         if ($d) {
             $tag = $d['gtag'];
             if ($tag) {
                 $d['tag'] = $tag;
             } else {
                 $tag = $d['tag'];
             }
             $conf = ItemConfig::getItem($tag);
             if (!$conf) {
                 continue;
             }
             $g = $conf['group'];
             if (!$g) {
                 $g = TT::ITEM_GROUP;
             }
             $id = $tu->getdid(null, $g);
             $id2id[$gid] = $id;
             $d['id'] = $id;
             unset($d['msg']);
             $d['pos'] = 's';
             $tu->puto($d);
         } else {
             $id2id[$gid] = null;
         }
         $rids[] = $oid;
     }
     $tu->remove($rids);
     $ret['s'] = 'OK';
     $ret['id2id'] = $id2id;
     TTLog::record(array('m' => __METHOD__, 'tm' => $_SERVER['REQUEST_TIME'], 'u' => $uid, 'intp1' => $d['fid'], 'sp1' => $tag));
     return $ret;
 }
Example #7
0
 public function test_tt()
 {
     $tu = new TTUser(1);
     $tt = TT::get_tt('main', 1);
     $id = $tu->getdid(TT::SHOP_NUM);
     $str = '$tu->numch(TT::SHOP_NUM,$shop_num)';
     echo "{$str}=";
     record_time($st);
     eval('print_r(  ' . $str . ');');
     record_time($st, $str);
     echo "\n";
     $shop_num = 10;
     $str = '$tu->numch(TT::SHOP_NUM,$shop_num)';
     echo "{$str}=";
     record_time($st);
     eval('print_r(  ' . $str . ');');
     record_time($st, $str);
     echo "\n";
     $shop_num = -10;
     $str = '$tu->numch(TT::SHOP_NUM,$shop_num)';
     echo "{$str}=";
     record_time($st);
     eval('print_r(  ' . $str . ');');
     record_time($st, $str);
     echo "\n";
     $tu->putf('strint', '0000');
     $str = '$tu->getf("strint")';
     echo "{$str}=";
     record_time($st);
     eval('print_r(  ' . $str . ');');
     record_time($st, $str);
     echo "\n";
     $shop_num = -10;
     $str = '$tu->numch("strint",$shop_num)';
     echo "{$str}=";
     record_time($st);
     eval('print_r(  ' . $str . ');');
     record_time($st, $str);
     echo "\n";
     $shop_num = 10;
     $str = '$tu->numch("strint",$shop_num)';
     echo "{$str}=";
     record_time($st);
     eval('print_r(  ' . $str . ');');
     record_time($st, $str);
     echo "\n";
     $tt->put("strint", 'a');
     $str = '$tt->get("strint")';
     echo "{$str}=";
     record_time($st);
     eval('print_r(  ' . $str . ');');
     record_time($st, $str);
     echo "\n";
     $str = '$tt->numch("strint",100)';
     echo "{$str}=";
     record_time($st);
     eval('print_r(  ' . $str . ');');
     record_time($st, $str);
     echo "\n";
     $str = '$tt->numch("strint",100)';
     echo "{$str}=";
     record_time($st);
     eval('print_r(  ' . $str . ');');
     record_time($st, $str);
     echo "\n";
 }
Example #8
0
 public function reset_cinema($params)
 {
     $uid = $params['u'];
     $tu = new TTUser($uid);
     $items = $tu->get(TT::ITEM_GROUP);
     if (!$items) {
         $ret['s'] = 'empty';
         return $ret;
     }
     $rids = array();
     foreach ($items as $item) {
         if ($item['tag'] == '60102') {
             $rids[] = $item['id'];
             $id = $tu->getdid(false, TT::CINEMA_GROUP);
             $new = $item;
             $new['id'] = $id;
             $tu->puto($new, TT::ITEM_GROUP, false);
         }
     }
     $tu->remove($rids);
     $ret['s'] = 'OK';
     return $ret;
 }
Example #9
0
 /**
  * 直接购买物品到商店 ——仅供测试用
  *   
  * @param $params
  *  require   u     -- uid
  *  require   d     -- item data map (多个时为数组)
  *                  num     -- 每箱物品个数
  *                  tag     -- 
  *                  pos     --
  *                  stime   --
  *  require   sid   -- 商店id
  * @return 
  *  s     --OK
  *  
  */
 public function buy($params)
 {
     $uid = $params['u'];
     $now = time();
     //$num = 1;//$item['unitcout'];
     $tu = new TTUser($uid);
     $ids = array();
     foreach ($params['d'] as $goods) {
         $item = ItemConfig::getItem($goods['tag']);
         if (!$item) {
             //写入日志
             continue;
         }
         $shop = $tu->getbyid($goods['pos']['y']);
         $goods['stag'] = $shop['tag'];
         $goods['stime'] = $now + $goods['pos']['x'];
         $goods['num'] = $item['unitcout'];
         $gid = $tu->getdid('', TT::GOODS_GROUP);
         $goods['id'] = $gid;
         $tu->puto($goods, TT::GOODS_GROUP);
         $ids[] = $gid;
         $shop['goods'][$gid] = $now;
         $tu->puto($shop);
     }
     $ret['s'] = 'OK';
     $ret['ids'] = $ids;
     return $ret;
 }
Example #10
0
 /**
 			  五,增加好友箱数:						
  说明:	货车出发之后,放进仓库之前,好友均可点击,点击会增加货物箱数。				
 			  按钮问题:好友帮助加箱数的按钮,在货车运货过程中和货车回来都有。而当货车回来,但是没有放进仓库时,只有到好友家才有按钮,自己的副驾驶功能消失。				
 			  限制:	每人每日可帮一个好友一次。				
 			  级别越高增加的箱数越多。					
 			  级别:	箱数:				
 			  1	1				
 			  40	2				
 			  70	3				
 			  被帮助者奖励:	礼物为一箱货物。				
 			  帮助者奖励:	获得所进货物经验(进货+取货的经验和)相等的经验。	
 			 * @param $params
 			 *  require  u           --  user id
 			 *           f           --  friend id
 			 *           cid         --  car id
 			 *           type        --  1    表示加货
 			 *                           2    表示保鲜
 			 * @return 
 			 *           s           --  OK
 			 --  helped,已经拜访过
 			 --  nofriend,不是朋友
 			 --  freshed  今天已经操作过了
 			 --  alreadyfresh  可能已被别人保鲜了
 			 --  notexpiration  货物未过期
 			 award        
 			 exp         --奖励经验
 			 money       --奖励金钱 
 */
 public function help_car($params)
 {
     $uid = $params['u'];
     $nid = $params['f'];
     $cid = $params['cid'];
     $type = $params['type'];
     //兼容在线的旧flash版本
     if (!$type) {
         $type = 1;
     }
     $tu = new TTUser($uid);
     $ftu = new TTUser($nid);
     $fdid = $tu->getdid($nid, 'fr');
     $now = time();
     $now_date = date('Ymd', $now);
     $fdata = $tu->getbyid($fdid);
     if (!$fdata) {
         $ret['s'] = 'nofriend';
         return $ret;
     }
     $car = $ftu->getbyid($cid);
     if (!$car) {
         $ret['s'] = 'nocar ' . $cid;
         return $ret;
     }
     $goodsid = $car['goodsTag'];
     $gconfig = ItemConfig::getItem($goodsid);
     $add_exp = $gconfig['exp'];
     if (!$add_exp) {
         $ret['s'] = 'nogoods';
         $ret['g'] = $gconfig;
         return $ret;
     }
     $level = $tu->getLevel();
     $vt = $fdata['ht'];
     $vt_date = date('Ymd', $vt);
     $fdata['ht'] = $now;
     if ($type == 1) {
         //加货
         if ($vt_date == $now_date && $fdata['help_car'] == '1') {
             $ret['s'] = 'helped';
             return $ret;
         }
         $carconf = ItemConfig::getItem($car['tag']);
         $counts = count($car['help']);
         if ($counts > $carconf['gridWidth']) {
             $ret['help_time'] = $counts;
             $ret['gridW'] = $car['help'];
             $ret['s'] = 'max';
             return $ret;
         }
         $num = 1;
         if ($level > 39) {
             $num = 2;
         }
         if ($level > 69) {
             $num = 3;
         }
         $car['help'][$uid] = $num;
         $fdata['help_car'] = 1;
     }
     if ($type == 2) {
         //保鲜
         if ($vt_date == $now_date && $fdata['fresh'] == '1') {
             $ret['s'] = 'freshed';
             return $ret;
         }
         if ($car['fresh']) {
             $ret['s'] = 'alreadyfresh';
             return $ret;
         }
         if ($now - $car['t'] <= 3 * $gconfig['buytime']) {
             //货物未过期
             $ret['s'] = 'notexpiration';
             return $ret;
         }
         $car['fresh'] = $nid;
         $car['fresh'] = $params['f'];
         $fdata['fresh'] = 1;
     }
     $add_exp *= 2;
     $ret['type'] = $type;
     $ret['exp'] = $tu->addExp($add_exp);
     $ret['award']['exp'] = $add_exp;
     $tu->puto($fdata, 'fr', false);
     $ftu->puto($car, '', false);
     $ret['cid'] = $cid;
     $ret['s'] = 'OK';
     $ret['t'] = $now;
     $ret['car'] = $car;
     // for debug
     return $ret;
 }
Example #11
0
                 $tu->chGem(3);
                 $copilot['bag'][2002] += 1;
                 //加两箱的道具
                 $str = '50000金币,3个宝石,1份加两箱的道具';
             }
         }
     }
     $tu->puto($copilot);
     $sess['caward'] += 1;
     TTGenid::genid($sess);
     echo "<div style='font-size:16px;margin:20px;'>已经补偿给你<span style='font-weigth:bold;color:red;'>{$str}</span>请注意查收。<a href='" . RenrenConfig::$canvas_url . "'>返回游戏</a></div>";
 } else {
     if ($sess['caward'] && $sess['caward'] == 2) {
         $tu = new TTUser($u);
         //$getids[]=$tu->getdid('caward');
         $getids[] = $tu->getdid('exp');
         $getids[] = $tu->getdid('');
         $coid = $tu->getoid('copilot', TT::OTHER_GROUP);
         $getids[] = $coid;
         $datas = $tu->getbyids($getids);
         $level = $tu->getLevel($datas['exp']);
         $str = "";
         if ($level > 30) {
             $str = '300000金币,15个宝石,4份加两箱的道具,6份加6小时的道具';
         } else {
             if ($level > 20) {
                 $str = '150000金币,8个宝石,3份加两箱的道具,4份加6小时的道具';
             } else {
                 if ($level > 10) {
                     $str = '100000金币,5个宝石,2份加两箱的道具,2份加6小时的道具';
                 } else {