1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495 |
- <?php
- namespace loyalsoft;
- /**
- * Description of TaskCardVo
- * 任务卡
- * @author gwang
- */
- class Ins_TaskCard extends Object_ext {
- /**
- * @var type 这个物品在玩家身上唯一的id
- */
- public $uid = 0;
- /**
- * @var type 当前已完成步骤数量
- */
- public $count = 0;
- /**
- * @var type 查询用的id
- */
- public $typeId = 0;
- /**
- * @var int 任务状态未完成/已完成:0/1
- */
- public $state = 0;
- /**
- * @var array[]当前任务步骤数据
- */
- public $curSteps;
- /**
- *
- * @return type
- */
- public function mo() {
- $mo = GameConfig::taskcard_getItem($this->typeId);
- my_Assert(null != $mo, ErrCode::err_const_no);
- return $mo;
- }
- public function __construct($args = 0) {
- if (isInt($args)) {
- $this->typeId = $args;
- $arr = array();
- $cfg = GameConfig::item_taskcard_getItem($this->typeId);
- my_Assert(null != $cfg, ErrCode::err_const_no);
- foreach (explode(',', $cfg->tasksteps) as $taskStepTypeId) {
- $arr [] = new Ins_TaskStep($taskStepTypeId);
- }
- $this->curSteps = $arr;
- } else {
- parent::__construct($args);
- }
- }
- /**
- * @return boolean 分析任务卡是否已经完成所有步骤
- */
- public function IsFinish() {
- if ($this->state >= Enum_TaskCardStateType::finish) { # 已经完成
- return true;
- }
- $isFinish = true;
- foreach ($this->curSteps as &$tsp) { # 初期里面只有一个任务
- $tsp = new Ins_TaskStep($tsp);
- if (!$tsp->isFinish()) {
- $isFinish = false;
- break;
- }
- }
- return $isFinish;
- }
- public function AddStep($stpid) {
- $exists = false;
- foreach ($this->curSteps as $stp) {
- // $stp = new Ins_TaskStep($stp);
- if ($stp->typeId == $stpid) {
- $exists = true;
- }
- }
- if (!$exists) {
- $newstp = new Ins_TaskStep($stpid);
- $this->curSteps[] = $newstp;
- // $newstp->doStartAct();
- }
- }
- }
|