-
-
Save dim0xff/7fe1c12387dc429d531b 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
javascript:(function(){ | |
var getXmlHttp = function () { | |
var xmlhttp; | |
try { | |
xmlhttp = new ActiveXObject('Msxml2.XMLHTTP'); | |
} catch (e) { | |
try { | |
xmlhttp = new ActiveXObject('Microsoft.XMLHTTP'); | |
} catch (e) { | |
xmlhttp = false; | |
} | |
} | |
if (!xmlhttp && typeof XMLHttpRequest != 'undefined') { | |
xmlhttp = new XMLHttpRequest(); | |
} | |
return xmlhttp; | |
}; | |
var initGame = function (gId, cb) { | |
var xmlhttp = getXmlHttp(); | |
xmlhttp.open('GET', '/game/AjaxPlayGame.do?gameFrom=1&gameId=' + gId, true); | |
xmlhttp.onreadystatechange = function () { | |
if (xmlhttp.readyState == 4) { | |
if (xmlhttp.status == 200) { | |
var res = JSON.parse(xmlhttp.responseText); | |
if (res.success) { | |
setTimeout(function () { | |
cb(res) | |
}, 1000 * 30); | |
} | |
else { | |
setTimeout(function () { | |
cb(res) | |
}, 1000 * 2); | |
} | |
} | |
} | |
}; | |
xmlhttp.send(null); | |
}; | |
var games = 0; | |
var play; | |
play = function (gId) { | |
games++; | |
initGame(gId, function (res) { | |
games--; | |
if (!res.success) { | |
setTimeout(function () { | |
if (games == 0) { | |
games--; | |
alert('Done!'); | |
} | |
}, 1000 * 5); | |
return; | |
} | |
var playRecordId = res.playRecordId; | |
var total = 0; | |
var scores = { | |
'red': 10, | |
'orange': 5, | |
'yellow': 3 | |
}; | |
for (var i in res.probabilityRule.ball) { | |
for (var j in res.probabilityRule.ball[i]) { | |
total += res.probabilityRule.ball[i][j] * scores[j]; | |
} | |
} | |
var xmlhttp = getXmlHttp(); | |
xmlhttp.open('GET', '/game/AjaxFinishGame.do?gameFrom=1&gameId=' + gId + '&score=' + total + '&playRecordId=' + playRecordId, true); | |
xmlhttp.onreadystatechange = function () { | |
if (xmlhttp.readyState == 4) { | |
if (xmlhttp.status == 200) { | |
var res = JSON.parse(xmlhttp.responseText); | |
setTimeout(function () { | |
play(gId) | |
}, 1000 * 3); | |
} | |
} | |
}; | |
xmlhttp.send(null); | |
}); | |
}; | |
setTimeout(function () { play(101111) }, 1000); | |
setTimeout(function () { play(101111) }, 2000); | |
setTimeout(function () { play(101111) }, 3000); | |
setTimeout(function () { play(100003) }, 4000); | |
setTimeout(function () { play(100004) }, 5000); | |
setTimeout(function () { play(100005) }, 6000); | |
setTimeout(function () { play(100006) }, 7000); | |
setTimeout(function () { play(100007) }, 8000); | |
setTimeout(function () { play(100008) }, 9000); | |
setTimeout(function () { play(100009) }, 10000); | |
setTimeout(function () { play(100010) }, 11000); | |
}()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment