123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179 |
- <?php
- /**
- * Role.php UTF-8
- * 角色处理
- *
- * @date : 2018/5/30 16:48
- *
- * @license 这不是一个自由软件,未经授权不许任何使用和传播。
- * @author : wuyonghong <wyh@huosdk.com>
- * @version : HUOSDK 8.0
- */
- namespace huo\controller\queue;
- use huo\controller\member\MemCache;
- use huo\controller\request\Channel;
- use huo\controller\request\Device;
- use huo\controller\request\Game;
- use huo\controller\request\Mem as MemRq;
- use huo\controller\request\Role as RoleRq;
- use huolib\constant\MemConst;
- use huolib\queue\constant\EventConst;
- class Role extends SdkQueue {
- /**huo\controller\request
- * 角色创建
- * 记录玩家创建角色时刻的日志。
- * 在创角界面,输入完角色名后,系统显示“创角成功”即可调用该接口。
- * http://doc.1tsdk.com/138?page_id=3383
- *
- * @param Device $device_rq
- * @param Game $game_rq
- * @param Channel $agent_rq
- * @param MemRq $mem_rq
- * @param RoleRq $role_rq
- *
- * @return array
- */
- public function create(Device $device_rq, Game $game_rq, Channel $agent_rq, MemRq $mem_rq, RoleRq $role_rq) {
- $this->param['event'] = EventConst::EVENT_ROLE_CREATE;
- $this->setParamDevice($device_rq);
- $this->setParamGame($game_rq);
- $this->setParamChannel($agent_rq);
- $this->setParamRole($role_rq);
- $this->setParamMem($mem_rq);
- return $this->pushQueue();
- }
- /**
- * 角色登录
- * 记录玩家角色登录的日志。此处应与账户登录区分。
- *
- * 在角色界面,点击“登录游戏”后进入到游戏界面时调用该接口。
- *
- * ①一个服务器下只有一个角色,没有“登录游戏”按钮,以角色登录到游戏界面时调用接口;
- *
- * ②一个服务器下可有多个角色,以执行“登录游戏”操作进入游戏界面时调用接口。
- * http://doc.1tsdk.com/138?page_id=3384
- *
- * @param Device $device_rq
- * @param Game $game_rq
- * @param Channel $agent_rq
- * @param MemRq $mem_rq
- * @param RoleRq $role_rq
- *
- * @return array
- */
- public function online(Device $device_rq, Game $game_rq, Channel $agent_rq, MemRq $mem_rq, RoleRq $role_rq) {
- $this->param['event'] = EventConst::EVENT_ROLE_ONLINE;
- $this->setParamDevice($device_rq);
- $this->setParamGame($game_rq);
- $this->setParamChannel($agent_rq);
- $this->setParamRole($role_rq);
- $this->setParamMem($mem_rq);
- return $this->pushQueue();
- }
- /**
- * 角色升级
- * 记录玩家升级的日志。玩家升级的时候调用该接口。
- * http://doc.1tsdk.com/138?page_id=3385
- *
- * @param Device $device_rq
- * @param Game $game_rq
- * @param Channel $agent_rq
- * @param MemRq $mem_rq
- * @param RoleRq $role_rq
- *
- * @return array
- */
- public function levelup(Device $device_rq, Game $game_rq, Channel $agent_rq, MemRq $mem_rq, RoleRq $role_rq) {
- $this->param['event'] = EventConst::EVENT_ROLE_LEVELUP;
- $this->setParamDevice($device_rq);
- $this->setParamGame($game_rq);
- $this->setParamChannel($agent_rq);
- $this->setParamRole($role_rq);
- $this->setParamMem($mem_rq);
- return $this->pushQueue();
- }
- /**
- * 角色退出
- * 记录玩家角色登出的日志。此处应与账户登出区分。
- *
- * ①一个服务器只存在一个角色且不能重建的情况下,返回“选择服务器”界面即可调用该接口。
- *
- * ②一个服务器可存在多个角色,返回“选择角色”界面即可调用该接口。
- * http://doc.1tsdk.com/138?page_id=3386
- *
- * @param Device $device_rq
- * @param Game $game_rq
- * @param Channel $agent_rq
- * @param MemRq $mem_rq
- * @param RoleRq $role_rq
- *
- * @return array
- */
- public function offline(Device $device_rq, Game $game_rq, Channel $agent_rq, MemRq $mem_rq, RoleRq $role_rq) {
- $this->param['event'] = EventConst::EVENT_ROLE_OFFLINE;
- $this->setParamDevice($device_rq);
- $this->setParamGame($game_rq);
- $this->setParamChannel($agent_rq);
- $this->setParamRole($role_rq);
- $this->setParamMem($mem_rq);
- return $this->pushQueue();
- }
- /**
- * http://doc.1tsdk.com/138?page_id=2907
- *
- * @param Game $game_rq
- * @param MemRq $mem_rq
- * @param RoleRq $role_rq
- *
- * @param Device|null $device_rq
- *
- * @return array
- */
- public function upRole(Game $game_rq, MemRq $mem_rq, RoleRq $role_rq, Device $device_rq = null) {
- $agent_rq = new Channel();
- $agent_rq->setCh($mem_rq->getAgentId());
- $_mem_info = MemCache::ins()->getInfoById($mem_rq->getMemId());
- switch ($role_rq->getEvent()) {
- case 1:
- /* 角色登录 */
- $role_rq->setLastLoginTime(time());
- if (isset($_mem_info['status']) && $_mem_info['status'] == MemConst::STATUS_TRY) {
- $mem_rq->setStatus(MemConst::STATUS_NORMAL);
- }
- return $this->online($device_rq, $game_rq, $agent_rq, $mem_rq, $role_rq);
- case 2:
- /* 创建角色 */
- $role_rq->setLastLoginTime(time());
- if (isset($_mem_info['status']) && $_mem_info['status'] == MemConst::STATUS_TRY) {
- $mem_rq->setStatus(MemConst::STATUS_NORMAL);
- }
- return $this->create($device_rq, $game_rq, $agent_rq, $mem_rq, $role_rq);
- case 3:
- /* 提升等级 */
- return $this->levelup($device_rq, $game_rq, $agent_rq, $mem_rq, $role_rq);
- case 4:
- /* 角色退出 */
- return $this->offline($device_rq, $game_rq, $agent_rq, $mem_rq, $role_rq);
- default:
- $role_rq->setLastLoginTime(time());
- if (isset($_mem_info['status']) && $_mem_info['status'] == MemConst::STATUS_TRY) {
- $mem_rq->setStatus(MemConst::STATUS_NORMAL);
- }
- return $this->online($device_rq, $game_rq, $agent_rq, $mem_rq, $role_rq);
- }
- }
- }
|