Exemplo n.º 1
0
def discredit_offline(manager, entityID, current_floor):
    now = int(time.time())
    floor = manager.avail_floor(current_floor)

    attrs = ['climb_tower_accredit_earnings',
             'climb_tower_floor',
             'climb_tower_accredit_stash_time',
             'climb_tower_accredit_cd']
    p = Player.simple_load(entityID, Player.expend_fields(attrs))
    if p:
        if floor:
            value = p.climb_tower_accredit_earnings
            # 结束时间作为 score
            score = p.climb_tower_accredit_cd

            p.climb_tower_accredit_stash_earnings += value
            p.climb_tower_accredit_floor = floor
            p.climb_tower_accredit_stash_time = now
            # 取消当前层派驻
            manager.floors[current_floor].idx.unregister(p.entityID)
            manager.floors[floor].idx.register(p.entityID, score)

        else:
            p.climb_tower_accredit_cd = now
            manager.floors[current_floor].idx.unregister(p.entityID)
        p.save()
Exemplo n.º 2
0
 def get_players_info(self, playerIDs, attrs):
     objs = []
     pending = []
     playerIDs = list(playerIDs)
     for playerID in list(playerIDs):
         p = self.get_player(playerID)
         if p:
             objs.append(p)
         else:
             pending.append(playerID)
     from player.model import Player
     objs.extend(filter(lambda s: s, Player.batch_load(pending, Player.expend_fields(attrs))))
     result = []
     for p in objs:
         result.append({n: getattr(p, n) for n in attrs})
     return sorted(result, key=lambda s: playerIDs.index(s['entityID']))