Exemple #1
0
def reset(request):
    server_id = request._game_session.server_id
    char_id = request._game_session.char_id

    t = Tower(server_id, char_id)
    t.reset()

    response = TowerResetResponse()
    response.ret = 0
    return ProtobufResponse(response)
Exemple #2
0
def sweep(request):
    server_id = request._game_session.server_id
    char_id = request._game_session.char_id

    t = Tower(server_id, char_id)
    t.sweep()

    response = TowerSweepResponse()
    response.ret = 0
    return ProtobufResponse(response)
Exemple #3
0
def sweep(request):
    server_id = request._game_session.server_id
    char_id = request._game_session.char_id

    t = Tower(server_id, char_id)
    t.sweep()

    response = TowerSweepResponse()
    response.ret = 0
    return ProtobufResponse(response)
Exemple #4
0
def reset(request):
    server_id = request._game_session.server_id
    char_id = request._game_session.char_id

    t = Tower(server_id, char_id)
    t.reset()

    response = TowerResetResponse()
    response.ret = 0
    return ProtobufResponse(response)
Exemple #5
0
def sweep_finish(request):
    server_id = request._game_session.server_id
    char_id = request._game_session.char_id

    t = Tower(server_id, char_id)
    resource_classified = t.sweep_finish()

    response = TowerSweepFinishResponse()
    response.ret = 0
    response.drop.MergeFrom(resource_classified.make_protomsg())
    return ProtobufResponse(response)
Exemple #6
0
def sweep_finish(request):
    server_id = request._game_session.server_id
    char_id = request._game_session.char_id

    t = Tower(server_id, char_id)
    resource_classified = t.sweep_finish()

    response = TowerSweepFinishResponse()
    response.ret = 0
    response.drop.MergeFrom(resource_classified.make_protomsg())
    return ProtobufResponse(response)
Exemple #7
0
def buy_goods(request):
    server_id = request._game_session.server_id
    char_id = request._game_session.char_id
    goods_index = request._proto.goods_index

    t = Tower(server_id, char_id)
    rc = t.buy_goods(goods_index)

    response = TowerGoodsBuyResponse()
    response.ret = 0
    response.drop.MergeFrom(rc.make_protomsg())
    return ProtobufResponse(response)
Exemple #8
0
def buy_goods(request):
    server_id = request._game_session.server_id
    char_id = request._game_session.char_id
    goods_index = request._proto.goods_index

    t = Tower(server_id, char_id)
    rc = t.buy_goods(goods_index)

    response = TowerGoodsBuyResponse()
    response.ret = 0
    response.drop.MergeFrom(rc.make_protomsg())
    return ProtobufResponse(response)
Exemple #9
0
def turntable_pick(request):
    server_id = request._game_session.server_id
    char_id = request._game_session.char_id
    star = request._proto.star

    t = Tower(server_id, char_id)
    index = t.turntable_pick(star)

    response = TowerTurnTableResponse()
    response.ret = 0
    response.got_index = index
    return ProtobufResponse(response)
Exemple #10
0
def turntable_pick(request):
    server_id = request._game_session.server_id
    char_id = request._game_session.char_id
    star = request._proto.star

    t = Tower(server_id, char_id)
    index = t.turntable_pick(star)

    response = TowerTurnTableResponse()
    response.ret = 0
    response.got_index = index
    return ProtobufResponse(response)
Exemple #11
0
def match_start(request):
    server_id = request._game_session.server_id
    char_id = request._game_session.char_id

    formation_slots = parse_protocol_sync_formation_slots(request._proto.slots)

    t = Tower(server_id, char_id)
    msg = t.match(formation_slots)

    response = TowerMatchStartResponse()
    response.ret = 0
    response.match.MergeFrom(msg)
    return ProtobufResponse(response)
Exemple #12
0
def match_start(request):
    server_id = request._game_session.server_id
    char_id = request._game_session.char_id

    formation_slots = parse_protocol_sync_formation_slots(request._proto.slots)

    t = Tower(server_id, char_id)
    msg = t.match(formation_slots)

    response = TowerMatchStartResponse()
    response.ret = 0
    response.match.MergeFrom(msg)
    return ProtobufResponse(response)
Exemple #13
0
def tower_send_reward_and_reset_star(*args):
    logger = Logger("tower_send_reward_and_reset_star")
    logger.write("Start")

    try:
        for sid in Server.duty_server_ids():
            Tower.send_rank_reward_and_reset_star(sid)
            logger.write("Server {0} Finish".format(sid))
    except:
        logger.error(traceback.format_exc())
    else:
        logger.write("Done")
    finally:
        logger.close()
Exemple #14
0
def get_leader_board(request):
    server_id = request._game_session.server_id
    char_id = request._game_session.char_id

    t = Tower(server_id, char_id)
    info = t.get_leader_board()

    response = TowerLeaderBoardResponse()
    response.ret = 0

    for _id, name, star in info:
        response_leaders = response.leaders.add()
        response_leaders.id = str(_id)
        response_leaders.name = name
        response_leaders.star = star

    return ProtobufResponse(response)
Exemple #15
0
def get_leader_board(request):
    server_id = request._game_session.server_id
    char_id = request._game_session.char_id

    t = Tower(server_id, char_id)
    info = t.get_leader_board()

    response = TowerLeaderBoardResponse()
    response.ret = 0

    for _id, name, star in info:
        response_leaders = response.leaders.add()
        response_leaders.id = str(_id)
        response_leaders.name = name
        response_leaders.star = star

    return ProtobufResponse(response)
Exemple #16
0
def match_report(request):
    server_id = request._game_session.server_id
    char_id = request._game_session.char_id
    key = request._proto.key
    star = request._proto.star

    t = Tower(server_id, char_id)

    resource_classified, new_star, all_list, sale_goods = t.report(key, star)

    response = TowerMatchReportResponse()
    response.ret = 0
    response.drop.MergeFrom(resource_classified.make_protomsg())
    if all_list:
        response.star = new_star
        response.turntable_talent_ids.extend(all_list)

    response.sale_goods = sale_goods
    return ProtobufResponse(response)
Exemple #17
0
def match_report(request):
    server_id = request._game_session.server_id
    char_id = request._game_session.char_id
    key = request._proto.key
    star = request._proto.star

    t = Tower(server_id, char_id)

    resource_classified, new_star, all_list, sale_goods = t.report(key, star)

    response = TowerMatchReportResponse()
    response.ret = 0
    response.drop.MergeFrom(resource_classified.make_protomsg())
    if all_list:
        response.star = new_star
        response.turntable_talent_ids.extend(all_list)

    response.sale_goods = sale_goods
    return ProtobufResponse(response)
Exemple #18
0
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()
Exemple #19
0
    def buy(self, tp, goods_id):
        if tp not in ALL_TYPES:
            raise GameException(
                ConfigErrorMessage.get_error_id("INVALID_OPERATE"))

        config = ConfigStore.get(goods_id)
        if not config:
            raise GameException(
                ConfigErrorMessage.get_error_id("STORE_GOODS_NOT_EXIST"))

        try:
            data = self.doc['tp'][str(tp)]['goods'][str(goods_id)]
        except KeyError:
            raise GameException(
                ConfigErrorMessage.get_error_id("INVALID_OPERATE"))

        if data['times'] >= config.times_limit:
            raise GameException(
                ConfigErrorMessage.get_error_id("STORE_GOODS_NO_TIMES"))

        if config.condition_id == 1:
            # VIP 等级
            VIP(self.server_id, self.char_id).check(config.condition_value)
        elif config.condition_id == 2:
            # 爬塔历史最高星
            Tower(self.server_id,
                  self.char_id).check_history_max_star(config.condition_value)
        elif config.condition_id == 3:
            # 竞技场当前排名
            Arena(self.server_id,
                  self.char_id).check_current_rank(config.condition_value)
        elif config.condition_id == 4:
            # 当前公会等级
            Union(self.server_id,
                  self.char_id).check_level(config.condition_value)

        item_id, item_amount, need_id, need_amount = config.content[
            data['index']]
        resource_classify = ResourceClassification.classify([(need_id,
                                                              need_amount)])
        resource_classify.check_exist(self.server_id, self.char_id)
        resource_classify.remove(self.server_id,
                                 self.char_id,
                                 message="Store.buy:{0}".format(goods_id))

        resource_classify = ResourceClassification.classify([(item_id,
                                                              item_amount)])
        resource_classify.add(self.server_id,
                              self.char_id,
                              message="Store.buy:{0}".format(goods_id))

        data['times'] += 1

        MongoStore.db(self.server_id).update_one({'_id': self.char_id}, {
            '$set': {
                'tp.{0}.goods.{1}.times'.format(tp, goods_id): data['times']
            }
        })

        self.send_notify(tp=tp)
        return resource_classify
Exemple #20
0
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()