123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- <?php
- /*
- * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
- * Click nbfs://nbhost/SystemFileSystem/Templates/Scripting/PHPClass.php to edit this template
- */
- namespace loyalsoft;
- /**
- * Description of HeroProc
- *
- * @author gwang
- */
- class HeroProc {
- //put your code here
- /**
- * 逻辑分发
- * 所有的Proc中必须有这样一个方法
- * @param Req $req
- */
- public static function procMain($req) {
- switch ($req->cmd) {
- case CmdCode::hero_swith: # 6601 切换英雄
- return HeroProc::SwithHero();
- case CmdCode::hero_unlock: # 6602 解锁英雄
- return self::UnlockHero();
- case CmdCode::hero_buy:
- return self::BuyHero();
- default:
- Err(ErrCode::cmd_err);
- }
- }
-
- /**
- * 购买角色
- * @return type
- */
- private static function BuyHero(){
- list($heroId) = req()->paras; # 切换英雄id
- my_Assert(GameConfig::hero_getItem($heroId) != null, "找不到英雄配置数据!");
-
- ctx()->heros->Dic->$heroId->isUnlock = 1;
- return Resp::ok();
- }
- /**
- * 6602 解锁英雄
- * @return type
- */
- private static function UnlockHero() {
- list($newHeroId) = req()->paras; # 切换英雄id
- my_Assert(GameConfig::hero_getItem($newHeroId) != null, "找不到英雄配置数据!");
- // 解锁消耗,
- // 解锁成功.
- ctx()->heros->Dic->$newHeroId = new Ins_Hero();
- return Resp::ok();
- }
- /**
- * 6601 切换英雄
- */
- private static function SwithHero() {
- list($newHeroId) = req()->paras; # 切换英雄id
- my_Assert(CommUtil::isPropertyExists(ctx()->heros->Dic, $newHeroId), "尚未获得此英雄!");
- ctx()->heros->CurrentHeroId = $newHeroId;
- return Resp::ok();
- }
- }
|