Ejemplo n.º 1
0
    def battle_end(self, is_win, reward):
        if is_win:
            #已结束
            if not self._n_process:
                curr_process = config.MAX_FLOOR_NUM - 1

                self._n_auto_timer = -1

                self._b_in_auto_tower = False

                self._n_des_process = -1
            else:
                #月光之城通关
                if self._n_des_process == config.MAX_FLOOR_NUM - 1 and self._n_process == -1:
                    curr_process = config.MAX_FLOOR_NUM - 1
                else:
                    curr_process = self._n_process - 1

            self._dict_auto_battle_result[curr_process] = {
                "win": is_win,
                "result": reward
            }

            if curr_process < self._n_des_process:
                self._n_auto_timer = timer.set_timer(config.AUTO_TOWER_TIME, \
                                                     repeat_count=1, \
                                                     callback=self.auto_battle)
            else:
                self._n_auto_timer = -1

                self._b_in_auto_tower = False

                self._n_des_process = -1
        else:
            curr_process = self._n_process

            # 战斗失败,结束自动战斗
            self._dict_auto_battle_result[curr_process] = {
                "win": is_win,
                "result": reward
            }

            self._n_auto_timer = -1

            self._b_in_auto_tower = False

            self._n_des_process = -1

        net_trans.send_data(self._c_owner._hid, message.MSG_NET_AUTO_TOWER_SETTLE, \
                            self._dict_auto_battle_result)

        self._dict_auto_battle_result.clear()
Ejemplo n.º 2
0
    def auto_battle(self):
        if self._n_auto_timer == -1:
            self._b_in_auto_tower = True

            self._n_auto_timer = timer.set_timer(config.AUTO_TOWER_TIME, \
                                                 repeat_count=1, \
                                                 callback=self.auto_battle)
        else:
            #扣钱
            self._c_owner.change_money(-config.GOLD_PER_FLOOR,
                                       item_cfg.MONEY_YUANBAO,
                                       log_info.LOG_MONEY_CHG_AUTO_TOWER)

            curr_process = self._n_process

            #需动态检测格子数
            check_resp = self._c_owner._bag.check_grid_enough(
                config.FREE_BAG_GRID_NUM)

            if check_resp["err_code"] != err_code.ERR_OK:
                #背包剩余格子数不够, 结束自动战斗
                self._dict_auto_battle_result[curr_process] = {
                    "win":
                    False,
                    "result": {},
                    "bag_grid": [
                        self._c_owner._bag.get_free_grid_num(),
                        check_resp["detail"]
                    ]
                }

                self._n_auto_timer = -1
                self._b_in_auto_tower = False
                net_trans.send_data(self._c_owner._hid, message.MSG_NET_AUTO_TOWER_SETTLE,\
                                    self._dict_auto_battle_result)

                self._dict_auto_battle_result.clear()

                return

            battle_ins.get_manager().auto_launch_battle_in_tower(self._c_owner._uid,\
                                                                 self.get_npc(),\
                                                                 instance.tower_cfg[self._n_process]["name"],\
                                                                 self.battle_end)

        return {"process": self._n_process}
Ejemplo n.º 3
0
 def battle_end(self, is_win, reward):
         if is_win:
                 #已结束
                 if not self._n_process:
                         curr_process = config.MAX_FLOOR_NUM - 1
                         
                         self._n_auto_timer = -1
                         
                         self._b_in_auto_tower = False
                         
                         self._n_des_process = -1
                 else:
                         #月光之城通关
                         if self._n_des_process == config.MAX_FLOOR_NUM - 1 and self._n_process == -1:
                                 curr_process = config.MAX_FLOOR_NUM - 1
                         else:
                                 curr_process = self._n_process - 1
                         
                 self._dict_auto_battle_result[curr_process] = {"win":is_win, "result":reward}                        
                 
                 if curr_process < self._n_des_process:
                         self._n_auto_timer = timer.set_timer(config.AUTO_TOWER_TIME, \
                                                              repeat_count=1, \
                                                              callback=self.auto_battle)
                 else:
                         self._n_auto_timer = -1
                         
                         self._b_in_auto_tower = False
                         
                         self._n_des_process = -1
         else:
                 curr_process = self._n_process
                 
                 # 战斗失败,结束自动战斗
                 self._dict_auto_battle_result[curr_process] = {"win":is_win, "result":reward}
                               
                 self._n_auto_timer = -1
                 
                 self._b_in_auto_tower = False
                 
                 self._n_des_process = -1
                 
         net_trans.send_data(self._c_owner._hid, message.MSG_NET_AUTO_TOWER_SETTLE, \
                             self._dict_auto_battle_result)
                             
         self._dict_auto_battle_result.clear()
Ejemplo n.º 4
0
        def auto_battle(self):
                if self._n_auto_timer == -1:
                        self._b_in_auto_tower = True
                        
                        self._n_auto_timer = timer.set_timer(config.AUTO_TOWER_TIME, \
                                                             repeat_count=1, \
                                                             callback=self.auto_battle)
                else:   
                        #扣钱
                        self._c_owner.change_money(-config.GOLD_PER_FLOOR, item_cfg.MONEY_YUANBAO, log_info.LOG_MONEY_CHG_AUTO_TOWER)
                        
                        curr_process = self._n_process   
                        
                        #需动态检测格子数
                        check_resp = self._c_owner._bag.check_grid_enough(config.FREE_BAG_GRID_NUM)
                
                        if check_resp["err_code"] != err_code.ERR_OK:
                                #背包剩余格子数不够, 结束自动战斗
                                self._dict_auto_battle_result[curr_process] = {"win":False,
                                                                               "result":{},
                                                                               "bag_grid":[self._c_owner._bag.get_free_grid_num(), check_resp["detail"]]}
                                
                                self._n_auto_timer = -1
                                self._b_in_auto_tower = False
                                net_trans.send_data(self._c_owner._hid, message.MSG_NET_AUTO_TOWER_SETTLE,\
                                                    self._dict_auto_battle_result)
                                
                                self._dict_auto_battle_result.clear()
                                
                                return
                        
                        battle_ins.get_manager().auto_launch_battle_in_tower(self._c_owner._uid,\
                                                                             self.get_npc(),\
                                                                             instance.tower_cfg[self._n_process]["name"],\
                                                                             self.battle_end)

                return {"process":self._n_process}