Skip to content

Instantly share code, notes, and snippets.

@McPolemic
Created July 24, 2020 19:02
Show Gist options
  • Save McPolemic/257565304bee5254f2b83036d8e44ee1 to your computer and use it in GitHub Desktop.
Save McPolemic/257565304bee5254f2b83036d8e44ee1 to your computer and use it in GitHub Desktop.
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