def rewardMiningBound(self):
     '''获取挖掘奖励'''
     characterId = self._owner.baseInfo.id
     coinBound = self.getMiningBound()
     self._owner.finance.addCoin(coinBound)
     dbAfk.delCharacterMining(characterId)
     self.miningstart = None
     self.miningtype = 0
     self.miningmode = 1
     self.ismining = False
     return coinBound
    def initAFKData(self):
        '''初始化数据内容'''
        characterId = self._owner.baseInfo.id
        miningdata = dbAfk.getCharacterMining(characterId)
        traindata = dbAfk.getCharacterTrainData(characterId)
        turnrecord = dbAfk.getCharacterTurnRecord(characterId)
        nowday = datetime.datetime.now()
        if not turnrecord:
            dbAfk.InsertCharacterTurnRecord(characterId)
        else:
            turncoindate = turnrecord[2]
            if nowday.date() == turncoindate.date():
                self.turncointimes = turnrecord[1]
            turnexpdate = turnrecord[4]
            if nowday.date() == turnexpdate.date():
                self.turnexptimes = turnrecord[3]
            turnengpdate = turnrecord[6]
            if nowday.date() == turnengpdate.date():
                self.turnenergytimes = turnrecord[5]
            finishedWJdate = turnrecord[8]
            if nowday.date() == finishedWJdate.date():
                self.finishedMining = turnrecord[9]
            finishedTRdate = turnrecord[10]
            if nowday.date() == finishedTRdate.date():
                self.finishedTrain = turnrecord[11]
            self._owner.award.setViplevellibao(turnrecord[7],state=0)
        if miningdata:
            miningstart = miningdata[3]
            miningType = miningdata[2]
            miningmode = miningdata[4]
            sptime = MININGTYPE.get(miningType)
            miningtime = MININGTYPE.get(miningType)*3600
            seconddelta = miningtime - minusDatetimeForSecond(nowday, miningstart)
            if seconddelta< 0:
                miningpre = MININGMODE.get(miningmode)['pre']
                coinBound = int(self._owner.level.getLevel()*300*sptime*miningpre)
                self._owner.finance.addCoin(coinBound,state =0)
                dbAfk.delCharacterMining(characterId)
            else:
                self.miningstart = miningstart
                self.miningtype = miningType
                self.miningmode = miningmode
                self.ismining = True
                self.startMiningTimer()
#                sendTimerSingal(seconddelta,characterId, 1)
        if traindata:
            trainstart = traindata[2]
            trainType = traindata[3]
            trainId = traindata[1]
            trainmode = traindata[4]
            sptime = TRAINTYPE.get(trainType)
            traintime = TRAINTYPE.get(trainType)*3600
            seconddelta2 = traintime - minusDatetimeForSecond(nowday, trainstart)
            if seconddelta2< 0:
                trainpre = TRAINMODE.get(trainmode)['pre']
                expBound = int(self._owner.level.getLevel()*300*sptime*trainpre)
                if trainId == 0:
                    self._owner.level.addExp(expBound,state = 0)
                else:
                    pet = self._owner.pet.getPet(trainId)
                    if pet:
                        pet.level.addExp(expBound)
                dbAfk.delCharacterTrain(characterId)
            else:
                self.trainstart = trainstart
                self.traintype = trainType
                self.trainId = trainId
                self.trainmode = trainmode
                self.istrain = True
                self.startTrainTimer()
        self.startEnergyTimer()