Last active
December 20, 2018 19:38
-
-
Save MitchBarnett/e33d5aded8acd59c4a2f813bb30a8465 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
CEnemyManager.prototype.BuildEnemy = function(){}; | |
(function(context) { | |
const app = gApp; | |
const GAME = gGame; | |
const SERVER = gServer; | |
const PLAYER = gPlayerInfo; | |
const TryContinue = function Continue() { | |
let continued = false; | |
if (GAME.m_State.m_VictoryScreen) { | |
GAME.m_State.m_VictoryScreen.children.forEach(function(child) { | |
if (child.visible && child.x == 155 && child.y == 300) {// TODO: not this | |
continued = true; | |
child.click(); | |
} | |
}) | |
} | |
if (GAME.m_State.m_LevelUpScreen) { | |
continued = false; | |
GAME.m_State.m_LevelUpScreen.children.forEach(function(child) { | |
if (child.visible && child.x == 155 && child.y == 300) {// TODO: not this | |
continued = true; | |
child.click(); | |
} | |
}) | |
} | |
if(GAME.m_State instanceof CBootState) { //First screen | |
GAME.ChangeState( new CBattleSelectionState( 2 ) ); | |
continued = true; | |
} | |
return continued; | |
} | |
const GetBestZone = function GetBestZone() { | |
let bestZoneIdx = -1; | |
let maxProgress = 0; | |
let maxDifficulty = 0; | |
for (let idx = GAME.m_State.m_Grid.m_Tiles.length-1; idx >= 0; idx--) { | |
let zone = GAME.m_State.m_Grid.m_Tiles[idx].Info; | |
if(!zone.captured) { | |
if(zone.boss) { | |
return idx; | |
} | |
if(zone.difficulty > maxDifficulty) { | |
maxDifficulty = zone.difficulty; | |
bestZoneIdx = idx; | |
} | |
} | |
} | |
if(bestZoneIdx > -1) { | |
console.log(`zone ${bestZoneIdx} progress: ${GAME.m_State.m_Grid.m_Tiles[bestZoneIdx].Info.progress}`); | |
console.log(`zone ${bestZoneIdx} difficulty: ${GAME.m_State.m_Grid.m_Tiles[bestZoneIdx].Info.difficulty}`); | |
} | |
return bestZoneIdx; | |
} | |
const InGame = function InGame() { | |
return GAME.m_State.m_bRunning; | |
} | |
const InZoneSelect = function InZoneSelect() { | |
return GAME.m_State instanceof CBattleSelectionState; | |
} | |
const InPlanetSelect = function InPlanetSelect() { | |
return GAME.m_State instanceof CPlanetSelectionState; | |
} | |
// context.lastZoneIndex; | |
let isJoining = false; | |
if (context.BOT_FUNCTION) { | |
app.ticker.remove(context.BOT_FUNCTION); | |
context.BOT_FUNCTION = undefined; | |
} | |
GAME.ChangeState( new CBattleSelectionState(3)); | |
context.BOT_FUNCTION = function ticker(delta) { | |
delta /= 10000; | |
if(GAME.m_IsStateLoading) { | |
return; | |
} | |
if (InPlanetSelect() && !isJoining){ | |
Game.ChangeState( new CBattleSelectionState(3)); | |
} | |
if (InZoneSelect() && !isJoining) { | |
let bestZoneIdx = GetBestZone(); | |
if(bestZoneIdx > -1) { | |
isJoining = true; | |
console.log("join to zone", bestZoneIdx); | |
SERVER.JoinZone( | |
bestZoneIdx, | |
function (results) { | |
GAME.ChangeState(new CBattleState(GAME.m_State.m_PlanetData, bestZoneIdx)); | |
}, | |
GameLoadError | |
); | |
return; | |
} | |
} | |
if (!InGame()) { | |
if (TryContinue()) { | |
console.log("continued!"); | |
} | |
return; | |
} | |
isJoining = false; | |
let buttonsOnErrorMessage = document.getElementsByClassName("btn_grey_white_innerfade btn_medium"); | |
if(buttonsOnErrorMessage.length > 0) { | |
buttonsOnErrorMessage[0].click(); | |
} | |
} | |
app.ticker.add(context.BOT_FUNCTION); | |
})(window); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment