<?php

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of MisCardIns
 * 任务卡实例
 * @author jgao
 */
class MisCardIns {
    //put your code here
    
    /**
     * 实例id
     * @var type 
     */
    public $id = 0;
    
    /**
     * 模板id
     * @var type 
     */
    public $tid = 0;
    
    /**
     * 任务卡状态
     * @var type 
     */
    public $state = 0;
    
    /**
     * 当前时间戳
     * @var type 
     */
    public $ts = 0;
    
    /**
     * 任务卡状态
     */
    public function getState(){
        if($this->state != MissionCardStateType::ing){
            return $this->state;
        }
        $mo = dataCenter()->getMissionCardData($this->tid);
        $misslist = strsplit_raw($mo->misslist);
        $missInfo = usrInfo()->missInfo();
        $bSign = true;
        foreach ($misslist as $missId){
            if(!$missInfo->onceFinished($missId)){
                $bSign = false;
                break;
            }
        }
        if($bSign){
            $this->state = MissionCardStateType::finish;
        }
        return $this->state;
    }
    
}
