Ejemplo n.º 1
0
def updatagold_mongo():
    """
    更新mongoDB中用户金币
    :return:
    """
    gameID = str(request.form['User_Id_Data'])
    player_id = selectid_mongo()
    jb_num = int(request.form['Gold_Number_Data'])
    myquery = {'_id': player_id}
    newvalue = {'$set': {'money': jb_num}}
    try:
        data_function.con_mongo('playermoney').update_many(myquery, newvalue)
        data_function.con_mongo252('playermoney').update_many(
            myquery, newvalue)
    except:
        pass
    return gameID
Ejemplo n.º 2
0
def Ipswitch(gametype):
    """
    IP限制开关
    :param ganmetype: 游戏类型
    :return:
    """
    iplimit = request.form['ip']
    game_site = str(request.form['game_site'])
    myquery = {'gameType': gametype, 'name': game_site}
    if iplimit == 'open':
        newvalue = {'$set': {'matchIp': bool(2 > 1)}}
        data_function.con_mongo('gamekind').update_many(myquery, newvalue)
        return render_template(game_dict[gametype],
                               Tips=game_site + '-->IP限制已打开,现在相同IP不能配牌到一起了',
                               IPresult=data_function.iplimitinfo(gametype))
    if iplimit == 'close':
        newvalue = {'$set': {'matchIp': bool(1 > 2)}}
        data_function.con_mongo('gamekind').update_many(myquery, newvalue)
        return render_template(game_dict[gametype],
                               Tips=game_site + '-->IP限制已关闭,现在相同IP可以配牌到一起了',
                               IPresult=data_function.iplimitinfo(gametype))
Ejemplo n.º 3
0
def Robotswitch(gametype):
    """
    机器人开关
    :param gametype: 游戏类型
    :return:
    """
    switch_maj = request.form['robot']
    game_site = str(request.form['game_site'])
    myquery = {'gameType': gametype, 'name': game_site}
    if switch_maj == 'open':
        newvalue = {'$set': {'enableRobot': bool(2 > 1)}}
        data_function.con_mongo('gamekind').update_many(myquery, newvalue)
        return render_template(
            game_dict[gametype],
            Tips=game_site + '-->机器人已打开,现在能够匹配到机器人了',
            fieldresult=data_function.gamesiteinfo(gametype))
    if switch_maj == 'close':
        newvalue = {'$set': {'enableRobot': bool(1 > 2)}}
        data_function.con_mongo('gamekind').update_many(myquery, newvalue)
        return render_template(
            game_dict[gametype],
            Tips=game_site + '-->机器人已关闭,现在无法匹配到机器人了',
            fieldresult=data_function.gamesiteinfo(gametype))
Ejemplo n.º 4
0
def selectid_mongo():
    """
    通过user_id查询player_id
    :param user_id: 玩家id
    :return: 返回玩家唯一标识
    """
    user_id = str(request.form['User_Id_Data'])
    try:
        player_id = data_function.con_mongo('playerdata').find_one(
            {'userID': user_id}, {'_id': 1})
        print(player_id)
        if player_id is None:
            player_id = data_function.con_mongo252('playerdata').find_one(
                {'userID': user_id}, {'_id': 1})
            if player_id is None:
                return "找不到对应的ID"
            else:
                return player_id['_id']
        else:
            return player_id['_id']
    except:
        return "找不到对应的ID"
Ejemplo n.º 5
0
def Ipstate(gametype):
    """
    IP状态查询
    :param gameType: 游戏类型
    :return:
    """
    result = data_function.con_mongo('gamekind').find_one(
        {
            'gameType': gametype,
            'enabled': bool(2 > 1)
        }, {
            '_id': 0,
            'matchIp': 1
        })
    if bool(result) is False:
        IPresult = '数据库为空'
        return IPresult
    else:
        if result['matchIp'] is False:
            IPresult = '已关闭'
            return IPresult
        if result['matchIp'] is True:
            IPresult = '已打开'
            return IPresult