wait: function( first ) { print( 'wait' ); if ( first ) { Gitwar.poll( Gitfight.takeTurn ); } else { Gitwar.sync() .then( function() { return Gitwar.poll( Gitfight.takeTurn ); }); } },
.then( function( head ) { if ( !Gitwar.me ) { print( 'userMissing' ); process.exit(); } if ( Gitfight.score.me <= 0 ) { print( 'theyWin' ); process.exit(); } else if ( Gitfight.score.opponent <= 0 ) { print( 'youWin' ); if ( head.user != Gitwar.me ) { Gitwar.addLog( turn ) .then( function() { print( 'wrapUp' ); Gitwar.sync(); process.exit(); }); } else { print( 'wrapUp' ); Gitwar.sync() .then( function() { process.exit(); }); } } else { if ( !head.user && Gitwar.users[ 0 ] == Gitwar.me || head.user == Gitwar.me ) { return Gitfight.wait( true ); } else { return Gitfight.takeTurn(); } } });
.then( function() { print( 'wrapUp' ); Gitwar.sync(); process.exit(); });
.then( function() { print( 'wrapUp' ); return Gitwar.sync(); })