From 209f408f1f22b881db3046476625d8a95a237631 Mon Sep 17 00:00:00 2001 From: Pan Date: Mon, 15 Apr 2019 18:40:41 +1200 Subject: [PATCH] home --- enemyAI/buildingManagerAI.java | 39 ++++++++++++++++++++++++++++++++-- enemyAI/economyManagerAI.java | 3 +-- 2 files changed, 38 insertions(+), 4 deletions(-) diff --git a/enemyAI/buildingManagerAI.java b/enemyAI/buildingManagerAI.java index 3b52a21..5b43ec3 100644 --- a/enemyAI/buildingManagerAI.java +++ b/enemyAI/buildingManagerAI.java @@ -103,7 +103,6 @@ public class buildingManagerAI { powerPlantUnderConstruction = buildingUnderProduction(101); - //build power plant, if the base is in lower power status or we have more money to spend on make extra one if(theBaseInfo.canBuildRefinery == false || theBaseInfo.lowPower || (theBaseInfo.currentPowerConsumption >= (theBaseInfo.currentPowerLevel - 500) && theBaseInfo.currentCredit > 500 && theBaseInfo.numberOfPowerPlant >=2 && frameIndex > 300)){ addBuildingToQueue(101); @@ -190,8 +189,44 @@ public class buildingManagerAI { h.goToTheNearestGoldMine(); constructionYards[i].finishDeployment(); } + }else if(constructionYards[i].refineryProgress < 240 && frameIndex > 300) { + //if there is not enough money to finish building the refinery, reset all other production. + + + // first reset construction yard production + boolean hasEnoughCredit = theBaseInfo.currentCredit > 1200 -constructionYards[i].creditSpentOnBuilding; + if(!hasEnoughCredit) { + for(int j = 0; j < constructionYards.length; j++) { + if(constructionYards[j] != null && constructionYards[j] != constructionYards[i] && constructionYards[j].teamNo != 0) { + int currentBuildingType = constructionYards[j].currentBuildingType; + if(currentBuildingType != -1) { + constructionYards[j].cancelBuilding(); + constructionYards[j].build(currentBuildingType); + } + hasEnoughCredit = theBaseInfo.currentCredit > 1200 -constructionYards[i].creditSpentOnBuilding; + if(hasEnoughCredit) + break; + } + } + } + + //then reset factory production if still dont have enough credit to finish building + hasEnoughCredit = theBaseInfo.currentCredit > 1200 -constructionYards[i].creditSpentOnBuilding; + if(!hasEnoughCredit) { + factory[] factories = mainThread.theAssetManager.factories; + for(int j = 0; j < factories.length; j++) { + if(factories[j] != null && factories[j].teamNo != 0) { + factories[j].cancelBuilding(); + } + hasEnoughCredit = theBaseInfo.currentCredit > 1200 -constructionYards[i].creditSpentOnBuilding; + if(hasEnoughCredit) + break; + } + } + } + //deploy factory if(constructionYards[i].factoryProgress == 240){ @@ -613,7 +648,7 @@ public class buildingManagerAI { refinery[] refineries = mainThread.theAssetManager.refineries; for(int i = 0; i < refineries.length; i++){ - if(refineries[i] != null && refineries[i].teamNo != 0 && refineries[i].nearestGoldMine != null && refineries[i].nearestGoldMine.goldDeposite > 10000){ + if(refineries[i] != null && refineries[i].teamNo != 0 && refineries[i].nearestGoldMine != null && refineries[i].nearestGoldMine.goldDeposite > 5000){ numberOfFunctionalRefinery++; } } diff --git a/enemyAI/economyManagerAI.java b/enemyAI/economyManagerAI.java index 68d8409..01e3348 100644 --- a/enemyAI/economyManagerAI.java +++ b/enemyAI/economyManagerAI.java @@ -39,7 +39,6 @@ public class economyManagerAI { } - //find an ideal goldmine goldMine[] goldMines = mainThread.theAssetManager.goldMines; constructionYard[] constructionYards = mainThread.theAssetManager.constructionYards; @@ -116,7 +115,7 @@ public class economyManagerAI { } //only go to the gold mine that has a refinery nearby and its not saturated with harvesters - if(numberOfHarvestersOnTheMine < 6) + if(numberOfHarvestersOnTheMine < 6 && hasRefineryNearby) o.myGoldMine = preferedGoldMine; } }