def battle(self, _id): try: self.this_stage = STAGE_ACTIVITY[_id] except KeyError: raise SanguoException(errormsg.STAGE_ACTIVITY_NOT_EXIST, self.char_id, "StageActivity Battle", "StageActivity {0} not exist".format(_id)) if _id not in self.stage.activities: raise SanguoException(errormsg.STAGE_ACTIVITY_NOT_OPEN, self.char_id, "StageActivity Battle", "StageActivity {0} not open".format(_id)) counter = ActivityStageCount(self.char_id) counter.make_func_name(self.this_stage.tp) if counter.remained_value <= 0: raise SanguoException( errormsg.STAGE_ACTIVITY_TOTAL_NO_TIMES, self.char_id, "StageActivity Battle", "StageActivity no total times. battle {0}".format(_id)) battle_msg = protomsg.Battle() b = ActivityPVE(self.char_id, _id, battle_msg) b.start() if battle_msg.self_win: counter.incr() self.send_remained_times_notify() Task(self.char_id).trig(9) return battle_msg
def send_remained_times_notify(self): msg = protomsg.ActivityStageRemainedTimesNotify() counter = ActivityStageCount(self.char_id) for tp in STAGE_ACTIVITY_TPS: msg_time = msg.remained_times.add() counter.make_func_name(tp) msg_time.tp = tp msg_time.times = counter.remained_value publish_to_char(self.char_id, pack_msg(msg))
def battle(self, _id): try: self.this_stage = STAGE_ACTIVITY[_id] except KeyError: raise SanguoException( errormsg.STAGE_ACTIVITY_NOT_EXIST, self.char_id, "StageActivity Battle", "StageActivity {0} not exist".format(_id) ) if _id not in self.stage.activities: raise SanguoException( errormsg.STAGE_ACTIVITY_NOT_OPEN, self.char_id, "StageActivity Battle", "StageActivity {0} not open".format(_id) ) counter = ActivityStageCount(self.char_id) counter.make_func_name(self.this_stage.tp) if counter.remained_value <= 0: raise SanguoException( errormsg.STAGE_ACTIVITY_TOTAL_NO_TIMES, self.char_id, "StageActivity Battle", "StageActivity no total times. battle {0}".format(_id) ) battle_msg = protomsg.Battle() b = ActivityPVE(self.char_id, _id, battle_msg) b.start() if battle_msg.self_win: counter.incr() self.send_remained_times_notify() Task(self.char_id).trig(9) if _id in [101, 102, 103, 104, 105, 106]: TimesLogActivityStageWuChaoJieLiang(self.char_id).inc() TimesLogActivityStage(self.char_id).inc() return battle_msg