예제 #1
0
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
예제 #2
0
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()
예제 #3
0
파일: comp_sim.py 프로젝트: jnowaczek/tron
#!/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)
예제 #5
0
def test_simple_create_game(temp_dir):
    db = GameDB(temp_dir)
    token = db.add_new_game()
    assert db.is_game_token(token)
예제 #6
0
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"}
예제 #7
0
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"
예제 #8
0
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"
예제 #9
0
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
예제 #10
0
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