Created
July 24, 2020 19:02
-
-
Save McPolemic/257565304bee5254f2b83036d8e44ee1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'game-client' | |
class Position < Struct.new(:x, :y) | |
GameClient.configure do |config| | |
# Configure Bearer authorization: token | |
config.host = 'http://td-capture-the-flag.herokuapp.com' # https://example.com | |
config.access_token = 'adam@testdouble.com' # alice@example.com | |
end | |
api_instance = GameClient::GameApi.new | |
current_position = Position.new(x: 0, y: 0) | |
direction = 'west' | |
loop do | |
direction = if current_position.x == 0 && direction == 'west' | |
'east' | |
else | |
'west' | |
end | |
result = api_instance.post_moves(direction) | |
pp result | |
player = result.player | |
current_position = Position.new(x: player.x, y: player.y) | |
rescue | |
sleep 1 | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment