def sync_loot_cost_offline(entityID, history): if not history["result"]: # lose if not cost_mats(entityID, history["loot"], history["count"]): return now = int(time.time()) Player.save_attributes(entityID, loot_protect_time=now + 3600) Player.pool.execute("LPUSH", "loot_history_p{%d}" % entityID, Player.fields['loot_history'].encoder(history)) Player.pool.execute("LTRIM", "loot_history_p{%d}" % entityID, 0, 10)
def sync_products_offline(entityID, history): from player.model import Player # pkey = make_key(Player.store_tag, entityID) cc, _, _ = cost_products( entityID, history['level'], history['booty'], history['type'] ) if cc: Player.pool.execute( "LPUSH", "mine_rob_history_p{%d}" % entityID, Player.fields["mine_rob_history"].encoder(history)) now = int(time.time()) Player.save_attributes( entityID, mine_protect_time=now + 3600 * history['protect_time'] ) return "FAILURE"