def start(self, dungeon_id, formation_slots=None): grade_conf = ConfigDungeonGrade.get(dungeon_id) if not grade_conf: raise GameException( ConfigErrorMessage.get_error_id("DUNGEON_NOT_EXIST")) map_name = ConfigDungeon.get(grade_conf.belong).map_name club_level = get_club_property(self.server_id, self.char_id, 'level') if grade_conf.need_level > club_level: raise GameException( ConfigErrorMessage.get_error_id( "DUNGEON_CLUB_LEVEL_NOT_ENOUGH")) f = Formation(self.server_id, self.char_id) if formation_slots: f.sync_slots(formation_slots) Energy(self.server_id, self.char_id).check(ConfigDungeon.get(grade_conf.belong).cost) ri = TimesInfo(self.server_id, self.char_id, grade_conf.belong) if not ri.remained_match_times: # 购买 self.buy_times(grade_conf.belong) club_one = Club(self.server_id, self.char_id) club_two = ConfigNPCFormation.get(grade_conf.npc) msg = ClubMatch(club_one, club_two, 6, f.get_skill_sequence(), {}).start() msg.key = str(dungeon_id) msg.map_name = map_name return msg
def start(self, dungeon_id, formation_slots=None): grade_conf = ConfigDungeonGrade.get(dungeon_id) if not grade_conf: raise GameException(ConfigErrorMessage.get_error_id("DUNGEON_NOT_EXIST")) map_name = ConfigDungeon.get(grade_conf.belong).map_name club_level = get_club_property(self.server_id, self.char_id, 'level') if grade_conf.need_level > club_level: raise GameException(ConfigErrorMessage.get_error_id("DUNGEON_CLUB_LEVEL_NOT_ENOUGH")) f = Formation(self.server_id, self.char_id) if formation_slots: f.sync_slots(formation_slots) Energy(self.server_id, self.char_id).check(ConfigDungeon.get(grade_conf.belong).cost) ri = TimesInfo(self.server_id, self.char_id, grade_conf.belong) if not ri.remained_match_times: # 购买 self.buy_times(grade_conf.belong) club_one = Club(self.server_id, self.char_id) club_two = ConfigNPCFormation.get(grade_conf.npc) msg = ClubMatch(club_one, club_two, 6, f.get_skill_sequence(), {}).start() msg.key = str(dungeon_id) msg.map_name = map_name return msg
def start(self, challenge_id, formation_slots=None): config = ConfigChallengeMatch.get(challenge_id) if not config: raise GameException(ConfigErrorMessage.get_error_id("CHALLENGE_NOT_EXIST")) if config.condition_challenge: doc = MongoChallenge.db(self.server_id).find_one( {'_id': self.char_id}, {'challenge_star.{0}'.format(config.condition_challenge): 1} ) if str(config.condition_challenge) not in doc['challenge_star']: raise GameException(ConfigErrorMessage.get_error_id("CHALLENGE_NOT_OPEN")) rt = RemainedTimes(self.server_id, self.char_id, challenge_id) if not rt.remained_match_times: raise GameException(ConfigErrorMessage.get_error_id("CHALLENGE_WITHOUT_TIMES")) f = Formation(self.server_id, self.char_id) if formation_slots: f.sync_slots(formation_slots) Energy(self.server_id, self.char_id).check(config.energy) club_one = Club(self.server_id, self.char_id) club_two = ChallengeNPCClub(challenge_id) match = ClubMatch(club_one, club_two, 6, f.get_skill_sequence(), {}) msg = match.start() msg.key = str(challenge_id) msg.map_name = config.map_name return msg
def match_start(self, key, formation_slots=None): try: friend_id, building_id, event_id = key.split(':') friend_id = int(friend_id) building_id = int(building_id) event_id = int(event_id) except: raise GameException(ConfigErrorMessage.get_error_id("BAD_MESSAGE")) f = Formation(self.server_id, self.char_id) if formation_slots: f.sync_slots(formation_slots) config = ConfigTerritoryEvent.get(event_id) npc_club = ConfigNPCFormation.get(config.npc) my_club = Club(self.server_id, self.char_id) match = ClubMatch(my_club, npc_club, 6, f.get_skill_sequence(), {}) msg = match.start() msg.key = "{0}:{1}:{2}".format(friend_id, building_id, event_id) msg.map_name = GlobalConfig.value_string("MATCH_MAP_TERRITORY_FRIEND") return msg
def match(self, formation_slots=None): sweep_end_at = self.doc.get('sweep_end_at', 0) if sweep_end_at: raise GameException(ConfigErrorMessage.get_error_id("TOWER_IN_SWEEP_CANNOT_OPERATE")) level = self.get_current_level() if not level: raise GameException(ConfigErrorMessage.get_error_id("TOWER_ALREADY_ALL_PASSED")) f = Formation(self.server_id, self.char_id) if formation_slots: f.sync_slots(formation_slots) config = ConfigTowerLevel.get(level) club_one = Club(self.server_id, self.char_id) if config.talent_id: club_one.add_talent_effects([config.talent_id]) club_two = config.make_club() if not club_one.formation_staffs: club_one.load_staffs() if not club_two.formation_staffs: club_two.load_staffs() club_one.add_tower_temporary_talent_effects() club_one.make_temporary_staff_calculate() club_two.add_tower_temporary_talent_effects() club_two.make_temporary_staff_calculate() club_match = ClubMatch(club_one, club_two, 6, f.get_skill_sequence(), {}) msg = club_match.start() msg.key = str(level) msg.map_name = config.map_name return msg
def match(self, formation_slots=None): doc = MongoArena.db(self.server_id).find_one( {'_id': str(self.char_id)}, {'rival': 1}) rival_id = doc['rival'] if not rival_id: raise GameException( ConfigErrorMessage.get_error_id("ARENA_MATCH_NO_RIVAL")) f = Formation(self.server_id, self.char_id) if formation_slots: f.sync_slots(formation_slots) self.check_and_buy_times() club_one = Club(self.server_id, self.char_id) club_two = ArenaClub(self.server_id, rival_id) club_match = ClubMatch(club_one, club_two, 6, f.get_skill_sequence(), {}) msg = club_match.start() msg.key = rival_id msg.map_name = GlobalConfig.value_string("MATCH_MAP_ARENA") return msg
def match(self, formation_slots=None): doc = MongoArena.db(self.server_id).find_one( {'_id': str(self.char_id)}, {'rival': 1} ) rival_id = doc['rival'] if not rival_id: raise GameException(ConfigErrorMessage.get_error_id("ARENA_MATCH_NO_RIVAL")) f = Formation(self.server_id, self.char_id) if formation_slots: f.sync_slots(formation_slots) self.check_and_buy_times() club_one = Club(self.server_id, self.char_id) club_two = ArenaClub(self.server_id, rival_id) club_match = ClubMatch(club_one, club_two, 6, f.get_skill_sequence(), {}) msg = club_match.start() msg.key = rival_id msg.map_name = GlobalConfig.value_string("MATCH_MAP_ARENA") return msg