-
-
Save chee/5267177 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
var replayURL = 'http://fightcodegame.com/robots/replay/'; | |
var ai = 'duck'; | |
function load ( event ) { | |
event.preventDefault(); | |
var playerNumber = $( '#playerNumber' ).val(); | |
var replayID = $( '#replayID' ).val(); | |
$.get( replayURL + replayID ).done(function ( data ) { | |
var player = $( data ).filter( '[id*="-code"]' ).eq( playerNumber ).text(); | |
$( '#' + ai + '-code' ).text( player ); | |
// refresh the ai | |
$( '#enemy' ).val( ai ).change(); | |
}); | |
} | |
if ( $( '.editor' ).length ) { | |
var form = $( '<form class="form"><input id="replayID"><select id="playerNumber"><option value="0" name="1">1</option><option value="1" name="2">2</option></select><button class="load">Load Bot</button></form>' ); | |
$( '.buttons-bar' ).append( form ); | |
form.on( 'click', '.load', load ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment