/** * update * @param $params * require u -- user * step -- 新手步数 * // v -- view * // d -- do * @return * s -- OK ,or other fail * money -- total money * exp -- total exp * award money exp items(物品对象数组) * d --新的manual对象 */ public function update($params) { $uid = $params['u']; //$da = $params['d']; $step = $params['step']; //$v = ;//$da['v']; $d = 1; //;$da['d']; $ret = array(); $conf = self::getAwardConf($step); if (!$v && !$d) { $ret['s'] = 'noaction'; return $ret; } if (!$conf) { $ret['s'] = 'noconf'; return $ret; } $tu = new TTUser($uid); $id = $tu->getoid('mannual', TT::OTHER_GROUP); $mano = $tu->getbyid($id); $mean_gap = 20; $now = time(); $mano['id'] = $id; $level = $tu->getLevel(); if ($level > $conf['maxlevel']) { $ret['s'] = 'level'; $ret['d'] = $mano; //return $ret; } if ($v && $mano[$step]['vtime'] > 0) { $ret['s'] = 'already'; $ret['d'] = $mano; return $ret; } if ($d && $mano[$step]['dtime'] > 0) { $ret['s'] = 'already'; $ret['d'] = $mano; return $ret; // } $award = array(); if ($v) { $mano[$step]['vtime'] = $now; $m = $conf['v_money']; if ($m > 0) { $ret['money'] = $tu->chMoney($m); $award['money'] = $m; } $m = $conf['v_gem']; if ($m > 0) { $ret['gem'] = $tu->chGem($m); $award['gem'] = $m; } $m = $conf['v_exp']; if ($m > 0) { $ret['exp'] = $tu->addExp($m); $award['exp'] = $m; } $items = $conf['v_items']; if ($items) { foreach ($items as $item) { $config = ItemConfig::getItem($item['tag']); $idp = $item['idp']; // $item['id']=$uid.$idp; unset($item['idp']); $item['pos'] = 's'; if ($config['group'] == 'g') { $item['num'] = $config['unitcout']; $tu->puto($item, TT::GOODS_GROUP); } else { $tu->puto($item, TT::ITEM_GROUP); } $award['items'][] = $item; } } $tu->puto($mano); $ret['award'] = $award; $ret['s'] = 'OK'; return $ret; } $mano[$step]['dtime'] = $now; $m = $conf['d_money']; if ($m > 0) { $ret['money'] = $tu->chMoney($m); $award['money'] = $m; } $m = $conf['d_gem']; if ($m > 0) { $ret['gem'] = $tu->chGem($m); $award['gem'] = $m; } $m = $conf['d_exp']; if ($m > 0) { $ret['exp'] = $tu->addExp($m); $award['exp'] = $m; } $items = $conf['d_items']; if ($items) { foreach ($items as $item) { $config = ItemConfig::getItem($item['tag']); $idp = $item['idp']; // $item['id']=$uid.$idp; unset($item['idp']); $item['pos'] = 's'; if ($config['group'] == 'g') { $item['num'] = $config['unitcout']; $tu->puto($item, TT::GOODS_GROUP); } else { $tu->puto($item, TT::ITEM_GROUP); } $award['items'][] = $item; } } $tu->puto($mano); TTLog::record(array('m' => __METHOD__, 'tm' => $_SERVER['REQUEST_TIME'], 'u' => $uid, 'intp1' => $step)); $ret['s'] = 'OK'; $ret['award'] = $award; return $ret; }
/** 五,增加好友箱数: 说明: 货车出发之后,放进仓库之前,好友均可点击,点击会增加货物箱数。 按钮问题:好友帮助加箱数的按钮,在货车运货过程中和货车回来都有。而当货车回来,但是没有放进仓库时,只有到好友家才有按钮,自己的副驾驶功能消失。 限制: 每人每日可帮一个好友一次。 级别越高增加的箱数越多。 级别: 箱数: 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; }
/** 五,增加好友箱数: 说明: 货车出发之后,放进仓库之前,好友均可点击,点击会增加货物箱数。 按钮问题:好友帮助加箱数的按钮,在货车运货过程中和货车回来都有。而当货车回来,但是没有放进仓库时,只有到好友家才有按钮,自己的副驾驶功能消失。 限制: 每人每日可帮一个好友一次。 级别越高增加的箱数越多。 级别: 箱数: 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; }
<div id='cinema-main'> <div class='user-info'> <span class='avatar'> <xn:profile-pic uid="<?php echo $pid; ?> " linked="false" size="tiny" /> </span> <h2><xn:name uid="<?php echo $pid; ?> " linked="false" shownetwork="false" /></h2> <p> <label> 声望等级: <span class='gem' id='gemValue'><?php echo $user->getLevel(); ?> </span> </label> </p> </div> <input type="hidden" name="linkid" value="<?php echo $linkid; ?> "/> <input type="hidden" name="fid" value="<?php echo $mypid; ?> "/> <div class='cinema-body'> <?php
function getUserLevel() { $ses = TTGenid::getbypid($_REQUEST['pid']); $user = new TTUser($ses['id']); return $user->getLevel(); }
} } $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 { $str = '50000金币,3个宝石,1份加两箱的道具'; } } } echo "<div style='font-size:16px;margin:20px;'>你的补偿<span style='font-weigth:bold;color:red;'>{$str}</span>已经领取过了。<a href='" . RenrenConfig::$canvas_url . "'>返回游戏</a></div>";