예제 #1
0
파일: GetUserInfo.php 프로젝트: bsdcfp/wxmp
 public function process()
 {
     try {
         $this->_oTable->setTableName('cUser');
         $data = $this->_oTable->getObject($this->_args);
         $this->_data = $data;
     } catch (DB_Exception $e) {
         $errorNum = $this->_oTable->getErrorNum();
         $this->_retMsg = $this->_oTable->getErrorInfo() . $e->getMessage();
         $this->_retValue = genRetCode($errorNum);
         interface_log(ERROR, $this->_retValue, $this->_retMsg);
         return false;
     }
     return true;
 }
예제 #2
0
파일: Ready.php 프로젝트: bsdcfp/wxmp
 public function process()
 {
     try {
         $this->_oTable->setTableName('cUser');
         $data = $this->_oTable->getObject(array('userId' => $this->_args['userId']));
         if (count($data) == 0) {
             $this->_retValue = EC_RECORD_NOT_EXIST;
             $this->_retMsg = "userId:" . $this->_args['userId'];
             interface_log(ERROR, $this->_retValue, $this->_retMsg);
             return false;
         }
         //检查用户是否有子弹
         if ($data[0]['bulletNum'] == 0) {
             $this->_retValue = EC_NOT_ENOUGH_BULLET;
             $this->_retMsg = "userId:" . $this->_args['userId'];
             interface_log(ERROR, $this->_retValue, $this->_retMsg);
             return false;
         }
         //检查用户是否已经在游戏中
         $this->_oTable->setTableName('cFight');
         $data = $this->_oTable->getObject(array('user1' => $this->_args['userId'], 'user2' => $this->_args['userId']), 1);
         if (count($data)) {
             $this->_retValue = EC_ALREADY_FIGHT;
             $this->_retMsg = "userId:" . $this->_args['userId'];
             interface_log(ERROR, $this->_retValue, $this->_retMsg);
             return false;
         }
         //检查用户是否已经在准备队列中
         $this->_oTable->setTableName('cWaitingUser');
         $data = $this->_oTable->getObject(array('userId' => $this->_args['userId']));
         if (empty($data)) {
             //把用户插入到准备队列
             $this->_oTable->addObject(array('userId' => $this->_args['userId']));
         }
         $this->_responseText = MYZL_HINT_READY_SUC;
     } catch (DB_Exception $e) {
         $errorNum = $this->_oTable->getErrorNum();
         $this->_retMsg = $this->_oTable->getErrorInfo() . $e->getMessage();
         $this->_retValue = genRetCode($errorNum);
         interface_log(ERROR, $this->_retValue, $this->_retMsg);
         return false;
     }
     return true;
 }
예제 #3
0
파일: AddUser.php 프로젝트: bsdcfp/wxmp
 public function process()
 {
     try {
         $oTableOperate = new SingleTableOperation('cUser', "MYZL");
         $data = $oTableOperate->getObject(array('userId' => $this->_args['userId']));
         if (count($data)) {
             $this->_retValue = EC_RECORD_EXIST;
             $this->_retMsg = "user already exist!";
             interface_log(ERROR, $this->_retValue, $this->_retMsg);
             return false;
         }
         //添加用户记录,设置相关的字段,这里可以根据自己的策略设置
         $oTableOperate->addObject(array('userId' => $this->_args['userId'], 'password' => $this->_args['password'], 'email' => $this->_args['email'], 'money' => 100, 'bulletNum' => 5, 'xsft' => 5, 'hdcx' => 5, 'chxs' => 5, 'sszm' => 5, 'addTimeStamp' => getCurrentTime()));
         $this->_responseText = MYZL_HINT_ADDUSER_SUC;
     } catch (DB_Exception $e) {
         $errorNum = $oTableOperate->getErrorNum();
         $this->_retMsg = $oTableOperate->getErrorInfo() . $e->getMessage();
         $this->_retValue = genRetCode($errorNum);
         interface_log(ERROR, $this->_retValue, $this->_retMsg);
         return false;
     }
     return true;
 }
예제 #4
0
 public function process()
 {
     try {
         $this->_oTable->setTableName('cUser');
         $userId = $this->_args['userId'];
         unset($this->_args['userId']);
         $data = $this->_oTable->getObject(array('userId' => $userId));
         if (count($data) != 1) {
             $this->_retValue = EC_RECORD_NOT_EXIST;
             $this->_retMsg = "user not exist or internel error!";
             interface_log(ERROR, $this->_retValue, $this->_retMsg);
             return false;
         }
         $this->_oTable->updateObject($this->_args, array('userId' => $userId));
     } catch (DB_Exception $e) {
         $errorNum = $this->_oTable->getErrorNum();
         $this->_retMsg = $this->_oTable->getErrorInfo() . $e->getMessage();
         $this->_retValue = genRetCode($errorNum);
         interface_log(ERROR, $this->_retValue, $this->_retMsg);
         return false;
     }
     return true;
 }
예제 #5
0
파일: GetOpponent.php 프로젝트: bsdcfp/wxmp
 public function process()
 {
     try {
         $this->_oTable->setTableName('cUser');
         $data = $this->_oTable->getObject(array('userId' => $this->_args['userId']));
         if (count($data) == 0) {
             $this->_retValue = EC_RECORD_NOT_EXIST;
             $this->_retMsg = "userId:" . $this->_args['userId'];
             interface_log(ERROR, $this->_retValue, $this->_retMsg);
             return false;
         }
         $this->_oTable->setTableName('cFight');
         $data = $this->_oTable->getObject(array('user1' => $this->_args['userId'], 'user2' => $this->_args['userId']), 1);
         if (count($data) > 1) {
             $this->_retValue = EC_MULTIPLE_FIGHT;
             $this->_retMsg = "userId:" . $this->_args['userId'];
             interface_log(ERROR, $this->_retValue, $this->_retMsg);
             return false;
         } else {
             if (empty($data)) {
                 $this->_data = array();
                 return true;
             } else {
                 //match sucess
                 $this->_data = $data[0];
                 return true;
             }
         }
     } catch (DB_Exception $e) {
         $errorNum = $this->_oTable->getErrorNum();
         $this->_retMsg = $this->_oTable->getErrorInfo() . $e->getMessage();
         $this->_retValue = genRetCode($errorNum);
         interface_log(ERROR, $this->_retValue, $this->_retMsg);
         return false;
     }
     return true;
 }
예제 #6
0
파일: ChipIn.php 프로젝트: bsdcfp/wxmp
 public function process()
 {
     try {
         DbFactory::getInstance('MYZL')->autoCommit();
         //先获取游戏数据中的msgForOther,如果otherId是当前用户,把msgForOther添加到用户提示文本_responseText中
         $msgForOther = $this->_fightInfo['msgForOther'];
         $otherId = $this->_fightInfo['otherId'];
         if ($otherId == $this->_fromUserName) {
             $this->_responseText .= $msgForOther;
             $this->_fightInfo['msgForOther'] = "";
         }
         //设置msgForOhter和otherId
         $this->_fightInfo['otherId'] = $this->_fromUserName == $this->_fightInfo['user1'] ? $this->_fightInfo['user2'] : $this->_fightInfo['user1'];
         if ($this->_fightInfo['msgForOther'] == "") {
             $this->_fightInfo['msgForOther'] = "对方已加注" . $this->_operand . "金币";
         } else {
             $this->_fightInfo['msgForOther'] .= ", 对方已加注" . $this->_operand . "金币";
         }
         //用户金币不足的情况
         if ($this->_userInfo['money'] < $this->_args['money']) {
             $this->_retValue = EC_NOT_ENOUGH_MONEY;
             interface_log(ERROR, $this->_retValue);
             return false;
         }
         //用户减金币,游戏加金币
         $this->_oTable->setTableName('cUser');
         $newMoney = $this->_userInfo['money'] - $this->_args['money'];
         $this->_oTable->updateObject(array('money' => $newMoney), array('userId' => $this->_args['userId']));
         $this->_fightInfo['money'] += $this->_args['money'];
         //设置下一个动作的操作码和操作人
         $ret = $this->setNextOpAndUser();
         if ($ret['code']) {
             $this->_retValue = EC_STEP_ERROR;
             $this->_retMsg = "fightId:" . $this->_fightId . " step:" . $this->_fightInfo['historyOp'];
             interface_log(ERROR, $this->_retValue, $this->_retMsg);
             return false;
         }
         //设置历史操作记录
         if ($this->_fightInfo['historyOp'] == '') {
             $newHistoyOp = "CHIP_IN," . $this->_args['userId'];
         } else {
             $newHistoyOp = $this->_fightInfo['historyOp'] . "|CHIP_IN," . $this->_args['userId'];
         }
         $this->_fightInfo['historyOp'] = $newHistoyOp;
         //更新下注金额的下限
         if ($this->_args['money'] > $this->_fightInfo['minMoney']) {
             $this->_fightInfo['minMoney'] = $this->_args['money'];
         }
         //更新游戏数据
         $this->_oTable->setTableName('cFight');
         $this->_oTable->updateObject($this->_fightInfo, array('fightId' => $this->_fightId));
         DbFactory::getInstance('MYZL')->tryCommit();
         //设置用户提示文本
         if ($this->_responseText) {
             $this->_responseText .= ', ' . sprintf(MYZL_HINT_CHIPIN_SUC, $this->_operand, $GLOBALS['constants']['stepName'][$this->_fightInfo['operation']]);
         } else {
             $this->_responseText = sprintf(MYZL_HINT_CHIPIN_SUC, $this->_operand, $GLOBALS['constants']['stepName'][$this->_fightInfo['operation']]);
         }
     } catch (DB_Exception $e) {
         DbFactory::getInstance('MYZL')->rollback();
         $errorNum = $this->_oTable->getErrorNum();
         $this->_retMsg = $this->_oTable->getErrorInfo() . $e->getMessage();
         $this->_retValue = genRetCode($errorNum);
         interface_log(ERROR, $this->_retValue, $this->_retMsg);
         return false;
     }
     return true;
 }
예제 #7
0
파일: Shoot.php 프로젝트: bsdcfp/wxmp
 public function process()
 {
     try {
         DbFactory::getInstance('MYZL')->autoCommit();
         //获取msgForOther并设置用户提示文本
         $msgForOther = $this->_fightInfo['msgForOther'];
         $otherId = $this->_fightInfo['otherId'];
         if ($otherId == $this->_fromUserName) {
             $this->_responseText .= $msgForOther;
             $this->_fightInfo['msgForOther'] = "";
         }
         //设置用户提示文本
         $this->_fightInfo['otherId'] = $this->_fromUserName == $this->_fightInfo['user1'] ? $this->_fightInfo['user2'] : $this->_fightInfo['user1'];
         if ($this->_fightInfo['msgForOther'] == "") {
             $this->_fightInfo['msgForOther'] = "对方开枪,";
         } else {
             $this->_fightInfo['msgForOther'] .= ", 对方开枪,";
         }
         //保存上一次操作状态
         unset($this->_fightInfo['lastInfo']);
         $this->_fightInfo['lastInfo'] = json_encode($this->_fightInfo);
         //计算结果
         $this->_result = $this->calculateResult();
         interface_log(DEBUG, 0, var_export($this->_result, true));
         //根据开枪结果设置用户提示文本和
         if ($this->_result['out']) {
             //子弹打出的情况
             $this->_responseText .= "子弹打出,";
             $this->_fightInfo['msgForOther'] .= "子弹打出,";
             if ($this->_fightInfo['gameNumber'] == 2) {
                 $this->_responseText .= "下半局结束,";
                 $this->_fightInfo['msgForOther'] .= "下半局结束,";
                 if ($this->_result['dead']) {
                     $this->_fightInfo['loss2'] = $this->_args['userId'];
                 } else {
                     $this->_fightInfo['loss2'] = -1;
                 }
                 $this->_fightInfo['operation'] = SECOND_END;
                 $this->_fightInfo['operator'] = 0;
                 $this->_fightInfo['count'] == 0;
                 //$this->_fightInfo ['current'] = $this->_fightInfo['first'];
             } else {
                 $this->_responseText .= "上半局结束,";
                 $this->_fightInfo['msgForOther'] .= "上半局结束,";
                 if ($this->_result['dead']) {
                     $this->_fightInfo['loss1'] = $this->_args['userId'];
                 } else {
                     $this->_fightInfo['loss1'] = -1;
                 }
                 $this->_fightInfo['first'] = $this->_fightInfo['first'] == $this->_fightInfo['user1'] ? $this->_fightInfo['user2'] : $this->_fightInfo['user1'];
                 $this->_fightInfo['operation'] = FIRST_END;
                 $this->_fightInfo['operator'] = 0;
                 $this->_fightInfo['count'] == 0;
                 $this->_fightInfo['current'] = $this->_fightInfo['first'];
             }
         } else {
             //子弹未打出的情况
             if ($this->_result['magicEffect'] == CHXS) {
                 $this->_responseText .= "本局游戏重新开始,";
                 $this->_fightInfo['msgForOther'] .= "本局游戏重新开始,";
                 $this->_fightInfo['count'] = 0;
                 if ($this->_fightInfo['gameNumber'] == 1) {
                     $this->_fightInfo['operation'] = START;
                 } else {
                     $this->_fightInfo['operation'] = FIRST_END;
                 }
                 $this->_fightInfo['operator'] = 0;
                 $this->_fightInfo['current'] = $this->_fightInfo['first'];
             } else {
                 //set current
                 $this->_responseText .= "子弹未打出,游戏继续";
                 $this->_fightInfo['msgForOther'] .= "子弹未打出,游戏继续";
                 $this->_fightInfo['current'] = $this->_fightInfo['current'] == $this->_fightInfo['user1'] ? $this->_fightInfo['user2'] : $this->_fightInfo['user1'];
                 $ret = $this->setNextOpAndUser();
                 if ($ret['code']) {
                     $this->_retValue = EC_STEP_ERROR;
                     $this->_retMsg = "fightId:" . $this->_fightId . " step:" . $this->_fightInfo['historyOp'];
                     interface_log(ERROR, $this->_retValue, $this->_retMsg);
                     return false;
                 }
                 if ($this->_result['magicEffect'] == SSZM) {
                 } else {
                     $this->_fightInfo['count']--;
                 }
             }
         }
         if ($this->_fightInfo['historyOp'] == '') {
             $newHistoyOp = SHOOT . ',' . $this->_args['userId'];
         } else {
             $newHistoyOp = $this->_fightInfo['historyOp'] . "|" . SHOOT . ',' . $this->_args['userId'];
         }
         $this->_fightInfo['historyOp'] = $newHistoyOp;
         if ($this->_result['out']) {
             //子弹打出的情况,分钱逻辑
             $this->divideMoney();
         }
         //清空magic1和magic2
         $this->_fightInfo['magic1'] = '';
         $this->_fightInfo['magic2'] = '';
         if ($this->_fightInfo['operation'] == SECOND_END) {
             //在操作码为SECOND_END的情况,把游戏数据移动到cFightUncheck中
             $this->_oTable->setTableName('cFightUncheck');
             $this->_oTable->addObject($this->_fightInfo);
             $this->_oTable->setTableName('cFight');
             $this->_oTable->delObject(array('fightId' => $this->_fightId));
             $this->_data = $this->_fightInfo;
         } else {
             //更新游戏数据
             unset($this->_fightInfo['fightId']);
             $this->_oTable->setTableName('cFight');
             $this->_oTable->updateObject($this->_fightInfo, array('fightId' => $this->_fightId));
             $this->_data = $this->_fightInfo;
         }
         DbFactory::getInstance('MYZL')->tryCommit();
     } catch (DB_Exception $e) {
         DbFactory::getInstance('MYZL')->rollback();
         $errorNum = $this->_oTable->getErrorNum();
         $this->_retMsg = $this->_oTable->getErrorInfo() . $e->getMessage();
         $this->_retValue = genRetCode($errorNum);
         interface_log(ERROR, $this->_retValue, $this->_retMsg);
         return false;
     }
     return true;
 }
예제 #8
0
파일: PutMagic.php 프로젝트: bsdcfp/wxmp
 public function process()
 {
     try {
         DbFactory::getInstance('MYZL')->autoCommit();
         //获取msgForOther并设置用户提示文本
         $msgForOther = $this->_fightInfo['msgForOther'];
         $otherId = $this->_fightInfo['otherId'];
         if ($otherId == $this->_fromUserName) {
             $this->_responseText .= $msgForOther;
             $this->_fightInfo['msgForOther'] = "";
         }
         //设置用户提示文本
         $this->_fightInfo['otherId'] = $this->_fromUserName == $this->_fightInfo['user1'] ? $this->_fightInfo['user2'] : $this->_fightInfo['user1'];
         if ($this->_fightInfo['msgForOther'] == "") {
             $this->_fightInfo['msgForOther'] = "对方已经使用道具";
         } else {
             $this->_fightInfo['msgForOther'] .= ", 对方已经使用道具";
         }
         //获取道具变量,使用这种方式是为了兼容后续可能出现的一次使用多个道具的情况
         $magic = $this->_args['magic'];
         if ($magic != '') {
             $xsft = 0;
             $hdcx = 0;
             $chxs = 0;
             $sszm = 0;
             if ($magic == XSFT) {
                 $xsft = 1;
             } else {
                 if ($magic == HDCX) {
                     $hdcx = 1;
                 } else {
                     if ($magic == CHXS) {
                         $chxs = 1;
                     } else {
                         if ($magic == SSZM) {
                             $sszm = 1;
                         } else {
                             $this->_retValue = EC_ERROR_MAGIC;
                             $this->_retMsg = "fightId:" . $this->_fightId . " userId:" . $this->_args['userId'] . " magic:" . $magic;
                             interface_log(ERROR, $this->_retValue, $this->_retMsg);
                             return false;
                         }
                     }
                 }
             }
             if ($this->_fightInfo['current'] == $this->_args['userId']) {
                 if ($hdcx) {
                     //如果当前轮次开枪的操作者是当前玩家,则当前玩家不能使用壶底抽薪的技能
                     $this->_retValue = EC_ERROR_MAGIC;
                     $this->_retMsg = "fightId:" . $this->_fightId . " userId:" . $this->_args['userId'] . " magic:" . HDCX;
                     interface_log(ERROR, $this->_retValue, $this->_retMsg);
                     return false;
                 }
             } else {
                 if ($xsft || $chxs || $sszm) {
                     //如果当前轮次开枪的操作者不是当前玩家,则当前玩家只能使用壶底抽薪的技能,其他的技能不可用
                     $this->_retValue = EC_ERROR_MAGIC;
                     $this->_retMsg = "fightId:" . $this->_fightId . " userId:" . $this->_args['userId'] . " magic:" . ($xsft ? XSFT : "") . ($chxs ? CHXS : "") . ($sszm ? SSZM : "");
                     interface_log(ERROR, $this->_retValue, $this->_retMsg);
                     return false;
                 }
             }
             if ($this->_args['magic']) {
                 //更新用户道具数
                 if ($this->_userInfo['xsft'] - $xsft < 0 || $this->_userInfo['hdcx'] - $hdcx < 0 || $this->_userInfo['chxs'] - $chxs < 0 || $this->_userInfo['sszm'] - $sszm < 0) {
                     $this->_retValue = EC_NOT_ENOUGH_MAGIC;
                     $this->_retMsg = "fightId:" . $this->_fightId . " userId:" . $this->_args['userId'] . " magic:" . ($xsft ? XSFT : " ") . ($chxs ? CHXS : " ") . ($sszm ? SSZM : " ") . ($hdcx ? HDCX : " ");
                     interface_log(ERROR, $this->_retValue, $this->_retMsg);
                     return false;
                 }
                 $this->_oTable->setTableName('cUser');
                 $this->_oTable->updateObject(array('xsft' => $this->_userInfo['xsft'] - $xsft, 'hdcx' => $this->_userInfo['hdcx'] - $hdcx, 'chxs' => $this->_userInfo['chxs'] - $chxs, 'sszm' => $this->_userInfo['sszm'] - $sszm), array('userId' => $this->_args['userId']));
             }
         }
         //设置下一步动作和操作码和操作人
         $ret = $this->setNextOpAndUser();
         if ($ret['code']) {
             $this->_retValue = EC_STEP_ERROR;
             $this->_retMsg = "fightId:" . $this->_fightId . " step:" . $this->_fightInfo['historyOp'];
             interface_log(ERROR, $this->_retValue, $this->_retMsg);
             return false;
         }
         //更新游戏数据中的magic1,magic2和magicUsed1和magicUsed2
         if ($this->_args['magic']) {
             $this->setMagic();
         }
         //更新历史操作记录
         if ($this->_fightInfo['historyOp'] == '') {
             $newHistoyOp = PUT_MAGIC . ',' . $this->_args['userId'];
         } else {
             $newHistoyOp = $this->_fightInfo['historyOp'] . "|" . PUT_MAGIC . ',' . $this->_args['userId'];
         }
         $this->_fightInfo['historyOp'] = $newHistoyOp;
         //更新游戏记录
         unset($this->_fightInfo['fightId']);
         $this->_oTable->setTableName('cFight');
         $this->_oTable->updateObject($this->_fightInfo, array('fightId' => $this->_fightId));
         DbFactory::getInstance('MYZL')->tryCommit();
         //设置用户提示文本
         if ($this->_responseText) {
             if ($this->_args['magic']) {
                 $this->_responseText .= ', ' . sprintf(MYZL_HINT_PUTMAGIC_SUC, $GLOBALS['constants']['magicName'][$this->_operand], $GLOBALS['constants']['stepName'][$this->_fightInfo['operation']]);
             } else {
                 $this->_responseText .= ', ' . sprintf(MYZL_HINT_PUTMAGIC_SUC_NO, $GLOBALS['constants']['stepName'][$this->_fightInfo['operation']]);
             }
         } else {
             if ($this->_args['magic']) {
                 $this->_responseText = sprintf(MYZL_HINT_PUTMAGIC_SUC, $GLOBALS['constants']['magicName'][$this->_operand], $GLOBALS['constants']['stepName'][$this->_fightInfo['operation']]);
             } else {
                 $this->_responseText = sprintf(MYZL_HINT_PUTMAGIC_SUC_NO, $GLOBALS['constants']['stepName'][$this->_fightInfo['operation']]);
             }
         }
     } catch (DB_Exception $e) {
         DbFactory::getInstance('MYZL')->rollback();
         $errorNum = $this->_oTable->getErrorNum();
         $this->_retMsg = $this->_oTable->getErrorInfo() . $e->getMessage();
         $this->_retValue = genRetCode($errorNum);
         interface_log(ERROR, $this->_retValue, $this->_retMsg);
         return false;
     }
     return true;
 }
예제 #9
0
파일: Start.php 프로젝트: bsdcfp/wxmp
 public function process()
 {
     try {
         //获取msgForOther并设置用户提示文本
         $msgForOther = $this->_fightInfo['msgForOther'];
         $otherId = $this->_fightInfo['otherId'];
         if ($otherId == $this->_fromUserName) {
             $this->_responseText .= $msgForOther;
         }
         //设置用户提示文本
         $this->_fightInfo['otherId'] = $this->_fromUserName == $this->_fightInfo['user1'] ? $this->_fightInfo['user2'] : $this->_fightInfo['user1'];
         //$this->_fightInfo['lastOp'] = $this->_fromUserName . ',' . START . ',';
         if ($this->_fightInfo['operation'] == START) {
             $this->_fightInfo['gameNumber'] = 1;
             $this->_fightInfo['msgForOther'] = "对方开始上半局游戏";
         } else {
             $this->_fightInfo['gameNumber'] = 2;
             $this->_fightInfo['msgForOther'] = "对方开始下半局游戏";
         }
         //设置游戏数据
         $this->_fightInfo['current'] = $this->_fightInfo['first'];
         $this->_fightInfo['operator'] = $this->_fightInfo['first'];
         $this->_fightInfo['operation'] = CHIP_IN;
         //随机设置子弹在左轮中的位置
         $this->_fightInfo['count'] = rand(1, 6);
         $magicList1 = explode(',', $this->_fightInfo['magicUsed1']);
         $magicList2 = explode(',', $this->_fightInfo['magicUsed2']);
         if ($magicList1[count($magicList1) - 1] == CHXS || $magicList2[count($magicList2) - 1] == CHXS) {
         } else {
             //除非是用户使用CHXS导致的重新开始,否则重置游戏的money值为0
             $this->_fightInfo['money'] = 0;
         }
         //更新游戏数据
         unset($this->_fightInfo['fightId']);
         $this->_oTable->setTableName('cFight');
         $this->_oTable->updateObject($this->_fightInfo, array('fightId' => $this->_fightId));
         $this->_data = $this->_fightInfo;
         //设置用户提示文本
         $this->_responseText = sprintf(MYZL_HINT_START_SUC . ",", $this->_fightInfo['gameNumber'] == 1 ? "上" : "下");
         if ($this->_fromUserName == $this->_fightInfo['operator']) {
             $this->_responseText .= "请你下注";
         } else {
             $this->_responseText .= "等待对方下注";
         }
     } catch (DB_Exception $e) {
         $errorNum = $this->_oTable->getErrorNum();
         $this->_retMsg = $this->_oTable->getErrorInfo() . $e->getMessage();
         $this->_retValue = genRetCode($errorNum);
         interface_log(ERROR, $this->_retValue, $this->_retMsg);
         return false;
     }
     return true;
 }
예제 #10
0
파일: GetOp.php 프로젝트: bsdcfp/wxmp
 public function process()
 {
     try {
         $this->_oTable->setTableName('cUser');
         $data = $this->_oTable->getObject(array('userId' => $this->_args['userId']));
         if (count($data) == 0) {
             $this->_retValue = EC_USER_NOT_EXIST;
             $this->_retMsg = "userId:" . $this->_args['userId'];
             interface_log(ERROR, $this->_retValue, $this->_retMsg);
             return false;
         }
         $this->_args['userId'] = DbFactory::getInstance('MYZL')->escape($this->_args['userId']);
         //分别获取cFight和cFightUncheck中的记录
         $this->_oTable->setTableName('cFight');
         $data = $this->_oTable->getObject(array("_where" => " (user1='" . $this->_args['userId'] . "' OR user2='" . $this->_args['userId'] . "')"));
         $this->_oTable->setTableName('cFightUncheck');
         $data1 = $this->_oTable->getObject(array("_where" => "operation='SECOND_END' AND (user1='" . $this->_args['userId'] . "' OR user2='" . $this->_args['userId'] . "')"));
         if (empty($data) && !empty($data1)) {
             //有一方尚未查看游戏结果的情况
             $data = $data1;
             //delete fight info in uncheck table
             $fightId = $data[0]['fightId'];
             if ($data[0]['current'] != $this->_args['userId']) {
                 //当前用户非最后一下开枪的用户,清理游戏数据
                 $this->_oTable->setTableName('cFightEnd');
                 $this->_oTable->addObject($data[0]);
                 $this->_oTable->setTableName('cFightUncheck');
                 $this->_oTable->delObject(array('fightId' => $fightId));
             }
         }
         if (empty($data) && empty($data1)) {
             $this->_retValue = EC_FIGHT_NOT_EXIST;
             $this->_retMsg = "fightId:" . $this->_args['fightId'] . " userId:" . $this->_args['userId'];
             interface_log(ERROR, $this->_retValue, $this->_retMsg);
             return false;
         } else {
             if (count($data) > 1) {
                 $this->_retValue = EC_MULTIPLE_FIGHT;
                 $this->_retMsg = "userId:" . $this->_args['userId'];
                 interface_log(ERROR, $this->_retValue, $this->_retMsg);
                 return false;
             } else {
                 $this->_fightInfo = $data[0];
                 $msgForOther = $this->_fightInfo['msgForOther'];
                 $otherId = $this->_fightInfo['otherId'];
                 if ($otherId == $this->_args['userId']) {
                     //设置用户提示文本,并把msgForOther更新为空,以免给用户重复的提示
                     $this->_responseText .= $msgForOther;
                     $this->_oTable->setTableName('cFight');
                     $this->_oTable->updateObject(array('msgForOther' => ""), array("fightId" => $this->_fightInfo['fightId']));
                 }
                 interface_log(DEBUG, 0, "reponseText:" . $this->_responseText);
                 $this->_data = $this->_fightInfo;
                 return true;
             }
         }
         $this->_data = array();
     } catch (DB_Exception $e) {
         $errorNum = $this->_oTable->getErrorNum();
         $this->_retMsg = $this->_oTable->getErrorInfo() . $e->getMessage();
         $this->_retValue = genRetCode($errorNum);
         interface_log(ERROR, $this->_retValue, $this->_retMsg);
         return false;
     }
     return true;
 }