def test_overwrite(ex_db: GameDB): tok = ex_db.__players[0] ex_db.save_value(tok, "test_key", "str") assert ex_db.get_value(tok, "test_key") == "str" ex_db.save_value(tok, "test_key", 12) assert ex_db.get_value(tok, "test_key") == 12 ex_db.save_value(tok, "test_key", 3.14) assert ex_db.get_value(tok, "test_key") == 3.14
def main(): global gamedb print("Welcome to the GameDB Editor") print("!!!!WARNING!!!!!!") print("If you do NOT know what you are doing. Please exit now!!!") if len(sys.argv) > 1 and os.path.exists(sys.argv[1]): game_path = os.path.abspath(sys.argv[1]) print("You choose", game_path, "as a game path.") else: game_path = os.path.abspath( get_input("Your current dir is '" + os.path.abspath(os.curdir) + "'\nEnter path to game dir: ", lambda x: os.path.exists(x), error_msg="Invalid Game Directory. Try Again.")) gamedb = GameDB(game_path) option = "" while option != "Quit": options = get_main_menu_options() options = [(x, x) for x in options] option = print_menu(options, get_main_menu_title(), enable_no_selection=False) print("You selected:", option) if option == "Select School": select_school() elif option == "Select Competition": select_competition() elif option == "Add New Competition": add_competition() elif option == "Add School to Competition": add_school_to_comp() elif option == "List Schools in Competition": list_schools_in_comp() elif option == "Add New School": add_school() elif option == "Get new Tokens": get_new_tokens() elif option == "List current Tokens": list_tokens()
#!/usr/bin/python import sys from game import Tron from littlepython import Compiler from CYLGame.Database import GameDB from CYLGame.Comp import MultiplayerComp c_token = sys.argv[1] game = Tron compiler = Compiler() gamedb = GameDB(sys.argv[2]) MultiplayerComp.sim_comp(c_token, gamedb, game, compiler, debug=True)
#!/usr/bin/python import sys from apple_game import AppleFinder from littlepython import Compiler from CYLGame.Database import GameDB from CYLGame.Comp import sim_competition assert len(sys.argv) >= 2 comp_token = sys.argv[1] game = AppleFinder compiler = Compiler() gamedb = GameDB(sys.argv[2]) assert gamedb.is_comp_token(comp_token) sim_competition(compiler=compiler, game=game, gamedb=gamedb, token=comp_token, runs=100, debug=True)
def test_simple_create_game(temp_dir): db = GameDB(temp_dir) token = db.add_new_game() assert db.is_game_token(token)
def test_create_game_with_frames(temp_dir): db = GameDB(temp_dir) token = db.add_new_game(frames={"test": "test"}) assert db.is_game_token(token) assert db.get_game_frames(token) == {"test": "test"}
def test_simple_str(ex_db: GameDB): tok = ex_db.__players[0] ex_db.save_value(tok, "test_key", "test_value") assert ex_db.get_value(tok, "test_key") == "test_value"
def test_default_value(ex_db: GameDB): tok = ex_db.__players[0] # ex_db.save_value(tok, "test_key", "test_value") assert ex_db.get_value(tok, "test_key", "default_value") == "default_value"
def test_simple_float(ex_db: GameDB): tok = ex_db.__players[0] ex_db.save_value(tok, "test_key", 3.14) assert ex_db.get_value(tok, "test_key") == 3.14
def test_simple_int(ex_db: GameDB): tok = ex_db.__players[0] ex_db.save_value(tok, "test_key", 12) assert ex_db.get_value(tok, "test_key") == 12