def get_user(self, username: str): try: user = self.collection_users.find_one({"username": username}) if user is not None: u = User() u.load_json(user) return u else: return False except: return False
def register(): u = User() u.load_json(request.json) u.password = HASH.hash(u.password) cookie = users_db.save(u) if cookie: Authorization.save_session(u) return jsonify({ 'Authorization': encode(u.json_cookie_payload()), "Message": "Registered" }), 200 abort(401)
def modify_user(): logging.warning("llega") session_cookie = COOKIE_MANAGER.get_authorization_token_decoded(request) if session_cookie: session = sessions_db.get(session_cookie) if session: user = users_db.get(session_cookie.get("username")) if user: user2 = User() request.get_json()["password"] = user.password user2.load_json(request.get_json()) modify = users_db.modify(user.username, user.password, user2) if modify: removed = Authorization.remove_session(request) if removed: Authorization.save_session(user2) return jsonify({ 'Authorization': encode(user2.json_cookie_payload()), "Message": "Modified" }), 200 abort(401)
import random from logic.game import Game from logic.user import User from logic.ai import AI from logic.ai_v2 import AIV2 from logic.game_essentials import LINES from logic.ai_v2 import CPU_NAME boardSize = 4 # bestParams = [1, 4, 20, 10**10] # bestUserParams = [1, 4, 20, 10**10] bestParams = [10, 31, 80, 10**10] bestUserParams = [10, 31, 80, 10**10] user = User() cpu = AI(boardSize, CPU_NAME, user.getName(), bestParams, bestUserParams, LINES) game = Game(user, cpu) game.play() # Playing the machines against each other # while True: # # bar = random.randint(100, 1000000) # champ = AI(boardSize, 'Champ', 'Challenger', bestParams, bestUserParams, LINES) # challengerParams = [] # lastNum = 1 # first_param = random.randint(1, 10) # second_param = random.randint(first_param, 100) # third_param = random.randint(second_param, 1000)