Beispiel #1
0
def buy(uid, shop_id):
    print('buy', uid, shop_id)
    user_action = UserAction(uid)
    item_action = ItemAction(uid)
    shop_config_model = ConfigModel('shop')
    shop_info = shop_config_model.get_config_by_id(shop_id)
    item_config_model = ConfigModel('item')
    item_info = item_config_model.get_config_by_id(shop_info.get('item_id'))
    print shop_info
    price = shop_info.get('price', 10000)
    if shop_info.get(
            'method',
            'gold') == 'gold' and price >= user_action.get_value('gold', 0):
        return False
    else:
        user_action.reduce_gold(price)
    if shop_info.get('method') == 'diamond' and price >= user_action.get_value(
            'diamond', 0):
        return False
    else:
        user_action.reduce_diamond(price)
    print(item_info)
    item_action.add_model(item_info.get('config_id'), 1)
    return True
Beispiel #2
0
def get_my_friend_info(uid):
    action = FriendAction(uid)
    data = action.get_model_info()
    res = list()
    for f_id in data:
        p_model = PlatformAction(f_id)
        u_model = UserAction(f_id)
        f_action = FormationAction(f_id)
        p_model_info = p_model.get_private_info()
        item = {
            'id': f_id,
            'name': p_model_info['nickname'],
            'figureurl': p_model_info['figureurl'],
            'lv': u_model.get_value('lv'),
            'gold': u_model.get_gold(),
            'income': f_action.get_income(),
        }
        res.append(item)
    res = sorted(res, key=lambda x: x['gold'], reverse=True)
    return res