Skip to content

Commit

Permalink
v0.2
Browse files Browse the repository at this point in the history
- Added sleeping 3 seconds.
- Optimized config.
- Optimized threads.
  • Loading branch information
Fede-Coder committed Dec 24, 2020
1 parent f24c4c1 commit f295b6a
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 14 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>com.srfairyox</groupId>
<artifactId>Corvus</artifactId>
<version>0.1</version>
<version>0.2</version>

<properties>
<maven.compiler.source>8</maven.compiler.source>
Expand Down
46 changes: 34 additions & 12 deletions src/main/java/com/srfairyox/Corvus/Controller.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,12 @@
import org.json.JSONObject;

import java.awt.*;
import java.awt.event.WindowEvent;
import java.io.File;
import java.io.IOException;
import java.net.URI;
import java.text.NumberFormat;
import java.time.OffsetDateTime;
import java.time.format.DateTimeFormatter;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

@SuppressWarnings("unchecked")
public class Controller {
Expand Down Expand Up @@ -113,7 +110,7 @@ public class Controller {

@FXML
public void initialize() {
Log("Corvus v0.1 started - Made by 'Heaven. and SrFairyox");
Log("Corvus v0.2 started - Made by 'Heaven. and SrFairyox");
tpSessionIDLogin.setCollapsible(false);
tpGeneralSettings.setCollapsible(false);

Expand Down Expand Up @@ -264,15 +261,11 @@ public void btnStartOnClick(ActionEvent actionEvent) {
}

private synchronized void InitializeGuiAsync() {
Platform.runLater(() -> {
Log("Initializing gui...");
Log("Reading Galaxy Gates...");
});
Log("Initializing gui...");
Log("Reading Galaxy Gates...");
account.ReadGatesAsync();
Platform.runLater(() -> {
UpdateGui();
Log("Initialization finished!");
});
UpdateGui();
Log("Initialization finished!");
}

private void UpdateGui() {
Expand Down Expand Up @@ -311,6 +304,11 @@ private synchronized void ExecuteSpinAsync() {
if(chkBoxPlaceGateOnMap.isSelected()) {
if((currentGateA.prepared && currentGateA.isReady()) || (currentGateB.prepared && currentGateB.isReady()) || (currentGateG.prepared && currentGateG.isReady())) {
Log("Stopping gate mode. Can not get more parts.");
try {
Thread.sleep(3000);
} catch (InterruptedException e) {
e.printStackTrace();
}
return;
}
if(currentGateA.isReady() && !currentGateA.prepared){
Expand All @@ -329,13 +327,19 @@ private synchronized void ExecuteSpinAsync() {
if (currentGateA.isReady() || currentGateB.isReady() || currentGateG.isReady())
{
Log("Stopping gate mode. Can not get more parts.");
try {
Thread.sleep(3000);
} catch (InterruptedException e) {
e.printStackTrace();
}
return;
}
}
} else {
if(chkBoxPlaceGateOnMap.isSelected()) {
if(currentGate.prepared && currentGate.isReady()) {
Log("Stopping gate mode. Can not get more parts.");
Sleeping(3000);
return;
}
if(currentGate.isReady() && !currentGate.prepared) {
Expand All @@ -345,25 +349,34 @@ private synchronized void ExecuteSpinAsync() {
} else {
if(currentGate.isReady()) {
Log("Stopping gate mode. Can not get more parts.");
Sleeping(3000);
return;
}
}
}

if(account.gateData.EnergyCost.Text > account.gateData.Money && account.gateData.Samples <= 0) {
Log("Stopping gate mode. No Uridium/EE left");
Sleeping(3000);
//Sleep 30 seconds
return;
}
if(account.gateData.Money <= Integer.parseInt(txtMinUridium.getText())) {
Log("Stopping gate mode. Minimum Uridium reached");
Sleeping(3000);
//Sleep 30 seconds
return;
}
if(chkBoxSpinOnlyEE.isSelected() && account.gateData.Samples <= 0) {
Log("Stopping gate mode. No EE left");
Sleeping(3000);
//Sleep 30 seconds
return;
}
if(!(account.gateData.EnergyCost.Text <= Integer.parseInt(txtMaxSpinCost.getText()))) {
Log("Stopping gate mode. Max Spin Cost");
Sleeping(3000);
//Sleep 30 seconds
return;
}

Expand Down Expand Up @@ -406,6 +419,14 @@ private synchronized void ExecuteSpinAsync() {
UpdateGui();
}

private void Sleeping(int ms) {
try {
Thread.sleep(ms);
} catch (InterruptedException e) {
e.printStackTrace();
}
}

private synchronized void DoWork() {
try {
Log("Reading Galaxy Gates...");
Expand Down Expand Up @@ -489,6 +510,7 @@ public void Log(String text) {
txtAreaLog.appendText("["+ DateTimeFormatter.ofPattern("HH:mm:ss").format(OffsetDateTime.now()) +"] " +text+"\n");
}
});

if(chkEnableDebugCMD.isSelected()) {
System.out.println(text);
}
Expand Down
1 change: 0 additions & 1 deletion src/main/java/com/srfairyox/Corvus/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import javafx.scene.image.Image;
import javafx.stage.Stage;

import java.io.File;
import java.io.IOException;

public class Main extends Application {
Expand Down

0 comments on commit f295b6a

Please sign in to comment.