예제 #1
0
파일: tower.py 프로젝트: fycheung/misc
 def fight(self):
         self._c_owner.change_money(-config.GOLD_PER_FLOOR, item_cfg.MONEY_YUANBAO, log_info.LOG_MONEY_CHG_AUTO_TOWER)
         
         # 战斗,不需要发送战斗消息,返回战斗结果
         battle_ins.get_manager().auto_launch_battle_in_tower(self._c_owner._uid,\
                                                              self.get_npc(),\
                                                              instance.tower_cfg[self._n_process]["name"],\
                                                              self.settle_battle_end)
예제 #2
0
    def fight(self):
        self._c_owner.change_money(-config.GOLD_PER_FLOOR,
                                   item_cfg.MONEY_YUANBAO,
                                   log_info.LOG_MONEY_CHG_AUTO_TOWER)

        # 战斗,不需要发送战斗消息,返回战斗结果
        battle_ins.get_manager().auto_launch_battle_in_tower(self._c_owner._uid,\
                                                             self.get_npc(),\
                                                             instance.tower_cfg[self._n_process]["name"],\
                                                             self.settle_battle_end)
예제 #3
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}
예제 #4
0
    def start_battle(self):
        if self._c_owner.get_lv() < config.MIN_ENTER_LEVEL:
            return {"err_code": err_code.ERR_TOWER_ENTER_LEVEL_NOT_ENOUGH}

        if self._enter_state != ENTER_STATE_INSIDE: raise Exception

        return battle_ins.get_manager().launch_battle_in_tower(self._c_owner._uid, \
                                                         self.get_npc(),
                                                         instance.tower_cfg[self._n_process]["name"])
예제 #5
0
파일: tower.py 프로젝트: fycheung/misc
 def start_battle(self):
         if self._c_owner.get_lv() < config.MIN_ENTER_LEVEL:
                 return {"err_code":err_code.ERR_TOWER_ENTER_LEVEL_NOT_ENOUGH}
         
         if self._enter_state != ENTER_STATE_INSIDE: raise Exception
         
         return battle_ins.get_manager().launch_battle_in_tower(self._c_owner._uid, \
                                                          self.get_npc(), 
                                                          instance.tower_cfg[self._n_process]["name"])
예제 #6
0
파일: tower.py 프로젝트: fycheung/misc
        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}