def apply_in(request): server_id = request._game_session.server_id char_id = request._game_session.char_id c = Championship(server_id, char_id) c.apply_in() response = ChampionApplyResponse() response.ret = 0 return ProtobufResponse(response)
def sync_group(request): server_id = request._game_session.server_id char_id = request._game_session.char_id c = Championship(server_id, char_id) c.sync_group() response = ChampionGroupSyncResponse() response.ret = 0 return ProtobufResponse(response)
def sync_level(request): server_id = request._game_session.server_id char_id = request._game_session.char_id c = Championship(server_id, char_id) c.sync_level() response = ChampionLevelSyncResponse() response.ret = 0 return ProtobufResponse(response)
def bet(request): server_id = request._game_session.server_id char_id = request._game_session.char_id club_id = request._proto.club_id bet_id = request._proto.bet_id c = Championship(server_id, char_id) c.bet(club_id, bet_id) response = ChampionBetResponse() response.ret = 0 return ProtobufResponse(response)
def set_position(request): server_id = request._game_session.server_id char_id = request._game_session.char_id way = request._proto.way slots = request._proto.slots slots = parse_protocol_sync_formation_slots(slots) c = Championship(server_id, char_id) c.set_position(way, slots) response = ChampionFormationSetPositionResponse() response.ret = 0 return ProtobufResponse(response)
def set_unit(request): server_id = request._game_session.server_id char_id = request._game_session.char_id way = request._proto.way slot_id = request._proto.slot_id unit_id = request._proto.unit_id c = Championship(server_id, char_id) c.set_unit(way, slot_id, unit_id) response = ChampionFormationSetUnitResponse() response.ret = 0 return ProtobufResponse(response)
def set_staff(request): server_id = request._game_session.server_id char_id = request._game_session.char_id way = request._proto.way slot_id = request._proto.slot_id staff_id = request._proto.staff_id c = Championship(server_id, char_id) c.set_staff(way, slot_id, staff_id) response = ChampionFormationSetStaffResponse() response.ret = 0 return ProtobufResponse(response)
def after_staff_change(self, staff_id, force_load_staffs=False): # force_load_staffs: 只有这个staff的改变可能会影响到其他staff的时候,才为True from core.club import Club from core.plunder import Plunder from core.championship import Championship if force_load_staffs: Club(self.server_id, self.char_id, load_staffs=False).force_load_staffs(send_notify=True) else: Club(self.server_id, self.char_id).send_notify() p = Plunder(self.server_id, self.char_id) if p.find_way_id_by_staff_id(staff_id): p.send_formation_notify() c = Championship(self.server_id, self.char_id) if c.find_way_id_by_staff_id(staff_id): c.send_formation_notify()
def club_level_up_handler(server_id, char_id, new_level, **kwargs): TaskDaily(server_id, char_id).try_open() energy_add = ConfigClubLevel.get(new_level - 1).energy Energy(server_id, char_id).add(energy_add) UnitManager(server_id, char_id).try_unlock() Welfare(server_id, char_id).send_level_reward_notify() Championship(server_id, char_id).try_initialize() ActivityLevelGrowing(server_id, char_id).record(new_level)
def after_change(self, uid): from core.formation import Formation from core.plunder import Plunder from core.championship import Championship self.load_units() unit = self.get_unit_object(uid) all_units = self.get_units_data() all_units_object = [ self.get_unit_object(k) for k, _ in all_units.iteritems() ] changed_units = {} for u in all_units_object: if u.config.race == unit.config.race: changed_units[u.id] = u self.send_notify_with_unit_objs(changed_units.values()) fm = Formation(self.server_id, self.char_id) _changed = False for k, v in fm.in_formation_staffs().iteritems(): if v['unit_id'] in changed_units: _changed = True break if _changed: club = Club(self.server_id, self.char_id, load_staffs=False) club.force_load_staffs(send_notify=True) _p = Plunder(self.server_id, self.char_id) if _p.find_way_id_by_unit_id(uid): _p.send_formation_notify() _c = Championship(self.server_id, self.char_id) if _c.find_way_id_by_unit_id(uid): _c.send_formation_notify()
def __init__(self, server_id, char_id): from core.formation import Formation from core.plunder import Plunder from core.inspire import Inspire from core.championship import Championship self.server_id = server_id self.char_id = char_id self.formation = Formation(server_id, char_id) p = Plunder(server_id, char_id) self.plunder_formation_1 = p.get_way_object(1) self.plunder_formation_2 = p.get_way_object(2) self.plunder_formation_3 = p.get_way_object(3) c = Championship(server_id, char_id) self.championship_formation_1 = c.get_way_object(1) self.championship_formation_2 = c.get_way_object(2) self.championship_formation_3 = c.get_way_object(3) self.inspire = Inspire(server_id, char_id)
def after_change(self, uid): from core.formation import Formation from core.plunder import Plunder from core.championship import Championship self.load_units() unit = self.get_unit_object(uid) all_units = self.get_units_data() all_units_object = [self.get_unit_object(k) for k, _ in all_units.iteritems()] changed_units = {} for u in all_units_object: if u.config.race == unit.config.race: changed_units[u.id] = u self.send_notify_with_unit_objs(changed_units.values()) fm = Formation(self.server_id, self.char_id) _changed = False for k, v in fm.in_formation_staffs().iteritems(): if v['unit_id'] in changed_units: _changed = True break if _changed: club = Club(self.server_id, self.char_id, load_staffs=False) club.force_load_staffs(send_notify=True) _p = Plunder(self.server_id, self.char_id) if _p.find_way_id_by_unit_id(uid): _p.send_formation_notify() _c = Championship(self.server_id, self.char_id) if _c.find_way_id_by_unit_id(uid): _c.send_formation_notify()
def skill_sequence_set_staff(request): server_id = request._game_session.server_id char_id = request._game_session.char_id way = request._proto.way seq_id = request._proto.seq_id index = request._proto.index staff_id = request._proto.staff_id Championship(server_id, char_id).skill_sequence_set_staff(way, seq_id, index, staff_id) response = ChampionSkillSequenceSetStaffResponse() response.ret = 0 return ProtobufResponse(response)
def game_start_handler(server_id, char_id, **kwargs): MessagePipe(char_id).clean() msg = UTCNotify() msg.timestamp = arrow.utcnow().timestamp MessagePipe(char_id).put(msg=msg) msg = SocketServerNotify() ss = random.choice(settings.SOCKET_SERVERS) msg.ip = ss['host'] msg.port = ss['tcp'] MessagePipe(char_id).put(msg=msg) _Resource.send_notify(server_id, char_id) UnitManager(server_id, char_id).send_notify() Bag(server_id, char_id).send_notify() StaffManger(server_id, char_id).send_notify() StaffRecruit(server_id, char_id).send_notify() f = Formation(server_id, char_id) f.send_formation_notify() f.send_slot_notify() club = Club(server_id, char_id) club.set_login() club.send_notify() msg = CreateDaysNotify() msg.days = days_passed(club.create_at) msg.create_at = club.create_at MessagePipe(char_id).put(msg=msg) chall = Challenge(server_id, char_id) chall.send_chapter_notify() chall.send_challenge_notify() FriendManager(server_id, char_id).send_notify() MailManager(server_id, char_id).send_notify() TaskMain(server_id, char_id).send_notify() TaskDaily(server_id, char_id).send_notify() Chat(server_id, char_id).send_notify() Notification(server_id, char_id).send_notify() FinanceStatistics(server_id, char_id).send_notify() TalentManager(server_id, char_id).send_notify() Dungeon(server_id, char_id).send_notify() a = Arena(server_id, char_id) a.send_notify() a.send_honor_notify() t = Tower(server_id, char_id) t.send_notify() t.send_goods_notify() Territory(server_id, char_id).send_notify() TerritoryStore(server_id, char_id).send_notify() TerritoryFriend(server_id, char_id).send_remained_times_notify() Store(server_id, char_id).send_notify() VIP(server_id, char_id).send_notify() Collection(server_id, char_id).send_notify() Energy(server_id, char_id).send_notify() w = Welfare(server_id, char_id) w.send_signin_notify() w.send_new_player_notify() w.send_level_reward_notify() w.send_energy_reward_notify() Union(server_id, char_id).send_all_notify() Purchase(server_id, char_id).send_notify() ac = ActivityNewPlayer(server_id, char_id) ac.send_notify() ac.send_daily_buy_notify() ActivityOnlineTime(server_id, char_id).send_notify() ActivityChallenge(server_id, char_id).send_notify() ActivityPurchaseDaily(server_id, char_id).send_notify() ActivityPurchaseContinues(server_id, char_id).send_notify() ActivityLevelGrowing(server_id, char_id).send_notify() p = Plunder(server_id, char_id) p.send_search_notify() p.send_result_notify() p.send_revenge_notify() p.send_station_notify() p.send_formation_notify() p.send_plunder_times_notify() p.send_plunder_daily_reward_notify() SpecialEquipmentGenerator(server_id, char_id).send_notify() Party(server_id, char_id).send_notify() ins = Inspire(server_id, char_id) ins.try_open_slots(send_notify=False) ins.send_notify() cs = Championship(server_id, char_id) cs.try_initialize(send_notify=False) cs.send_notify() WinningPlunder(server_id, char_id).send_notify() WinningArena(server_id, char_id).send_notify() WinningChampionship(server_id, char_id).send_notify() Worship(server_id, char_id).send_notify() CommonArenaWinningChat(server_id, char_id).send_notify() CommonPlunderWinningChat(server_id, char_id).send_notify() CommonChampionshipChat(server_id, char_id).send_notify() send_system_notify(server_id, char_id) BroadCast(server_id, char_id).try_cast_login_notify()