예제 #1
0
def do_play(args, config):
    name = args.name
    hand = args.hand.upper()

    url = config.get('DEFAULT', 'url')
    key_file = config.get('DEFAULT', 'key_file')

    client = RPSClient(base_url=url, keyfile=key_file)
    client.shoot(name=name, hand=hand)
    state = client.get_state()
    comp = state[name].get('Computer')
    if comp:
        username = config.get('DEFAULT', 'username')
        # Create computer/switch to computer
        hand = random.choice(['ROCK', 'PAPER', 'SCISSORS'])
        d = vars(args)
        d["username"] = "******"
        do_init(args, config)
        # Create correct client
        url = config.get('DEFAULT', 'url')
        key_file = config.get('DEFAULT', 'key_file')
        # send Computers move
        client = RPSClient(base_url=url, keyfile=key_file)
        client.shoot(name=name, hand=hand)
        # Switch back to orignal player
        d = vars(args)
        d["username"] = username
        do_init(args, config)

    if args.wait:
        client.wait_for_commit()
예제 #2
0
def do_play(args, config):
    name = args.name
    hand = args.hand.upper()

    url = config.get('DEFAULT', 'url')
    key_file = config.get('DEFAULT', 'key_file')

    client = RPSClient(base_url=url, keyfile=key_file)
    client.shoot(name=name, hand=hand)
    state = client.get_all_store_objects()
    comp = state[name].get('Computer')
    if comp:
        username = config.get('DEFAULT', 'username')
        # Create computer/switch to computer
        hand = random.choice(['ROCK', 'PAPER', 'SCISSORS'])
        d = vars(args)
        d["username"] = "******"
        do_init(args, config)
        # Create correct client
        url = config.get('DEFAULT', 'url')
        key_file = config.get('DEFAULT', 'key_file')
        # send Computers move
        client = RPSClient(base_url=url, keyfile=key_file)
        client.shoot(name=name, hand=hand)
        # Switch back to orignal player
        d = vars(args)
        d["username"] = username
        do_init(args, config)

    if args.wait:
        client.wait_for_commit()
예제 #3
0
def do_create(args, config):
    name = args.name
    players = args.players

    url = config.get('DEFAULT', 'url')
    key_file = config.get('DEFAULT', 'key_file')

    client = RPSClient(base_url=url, keyfile=key_file)
    client.create(name=name, players=players)

    if args.wait:
        client.wait_for_commit()
예제 #4
0
def do_create(args, config):
    name = args.name
    players = args.players

    url = config.get('DEFAULT', 'url')
    key_file = config.get('DEFAULT', 'key_file')

    client = RPSClient(base_url=url, keyfile=key_file)
    client.create(name=name, players=players)

    if args.wait:
        client.wait_for_commit()