Skip to content
This repository was archived by the owner on Nov 24, 2018. It is now read-only.

Refactor code #48

Merged
merged 1 commit into from
Jan 3, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
140 changes: 70 additions & 70 deletions src/main/java/examples/BotnetExample.java
Original file line number Diff line number Diff line change
@@ -1,79 +1,79 @@
package examples;

import me.checkium.vhackapi.vHackAPI;
import me.checkium.vhackapi.vHackAPIBuilder;
import me.checkium.vhackapi.VHackAPI;
import me.checkium.vhackapi.botnet.Bot;
import me.checkium.vhackapi.botnet.BotnetManager;
import me.checkium.vhackapi.botnet.BotnetTarget;
import me.checkium.vhackapi.VHackAPIBuilder;

public class BotnetExample {

//Creating an API instance
vHackAPI api = new vHackAPIBuilder().password("pass").username("user").getAPI();
//We need a botnet manager
BotnetManager mgr = api.getBotnetManager();
//We need a target
public void attack(BotnetTarget target){
//Let's check the input
switch(target){
case KFMSolutions:
if(mgr.getStrength() < 7){
//We shouldn't attack this target if our strength is under 7
System.out.println("You shouldn't attack this target");
break;
} else {
//We're using a boolean that will be true if the attack is successful
boolean success = mgr.attack(target);
if(success){
System.out.println("Attaccked KFM Solutions, got 200 NC");
} else {
//We verified that we have enough strength, so if we fail the target is already attacked
System.out.println("You already attacked this target");
}
}
case VHACKSERVER: //you could do it by yourself ;)
case NETCOINBANK: //you could do it by yourself ;)
}
}
public void getBotStats(){
//Maybe we want to see our stats
//How much bots do we have?
int count = mgr.getBotCount();
//Let's get bots' stats
for(int i = 1; i <= count; i++){
Bot bot = mgr.getBot(i);
//Get the botID
System.out.println(bot.getBID());
//Get the bot level
System.out.println(bot.getLevel());
//Get money needed for upgrade
System.out.println(bot.getPrice());
//Maybe we could upgrade our botnets?
bot.update();
try {
//Let's wait half second for avoiding crashes
Thread.sleep(500);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
//Creating an API instance
VHackAPI api = new VHackAPIBuilder().password("pass").username("user").getAPI();
//We need a botnet manager
BotnetManager mgr = api.getBotnetManager();

//We need a target
public void attack(BotnetTarget target) {

//Let's check the input
switch (target) {
case KFMSolutions:
if (mgr.getStrength() < 7) {
//We shouldn't attack this target if our strength is under 7
System.out.println("You shouldn't attack this target");
break;

} else {

//We're using a boolean that will be true if the attack is successful
boolean success = mgr.attack(target);
if (success) {

System.out.println("Attaccked KFM Solutions, got 200 NC");

} else {

//We verified that we have enough strength, so if we fail the target is already attacked
System.out.println("You already attacked this target");

}

}
case VHACKSERVER: //you could do it by yourself ;)

case NETCOINBANK: //you could do it by yourself ;)

}

}


public void getBotStats() {
//Maybe we want to see our stats
//How much bots do we have?
int count = mgr.getBotCount();
//Let's get bots' stats
for (int i = 1; i <= count; i++) {

Bot bot = mgr.getBot(i);
//Get the botID
System.out.println(bot.getBID());
//Get the bot level
System.out.println(bot.getLevel());
//Get MONEY needed for upgrade
System.out.println(bot.getPrice());
//Maybe we could upgrade our botnets?
bot.update();
try {
//Let's wait half second for avoiding crashes
Thread.sleep(500);
} catch (InterruptedException e) {
e.printStackTrace();
}

}

}

}
27 changes: 14 additions & 13 deletions src/main/java/examples/ChatExample.java
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
package examples;

import me.checkium.vhackapi.vHackAPI;
import me.checkium.vhackapi.vHackAPIBuilder;
import me.checkium.vhackapi.chat.ChatListener;
import me.checkium.vhackapi.chat.ChatMessage;
import me.checkium.vhackapi.VHackAPI;
import me.checkium.vhackapi.VHackAPIBuilder;

// implements ChatListener
public class ChatExample implements ChatListener {
// Create your API instance
vHackAPI api = new vHackAPIBuilder().password("pass").username("user").getAPI();
// Create your API instance
VHackAPI api = new VHackAPIBuilder().password("pass").username("user").getAPI();

public void onChatMessage(ChatMessage message) {
//this is executed every message

if (message.getMessage().contains("!test")) {
//if the message contains !test then send message with @ + message + Testing
api.getChat().sendChatMessage("@" + message.getAuthor() + " Testing");
}
}

public void onChatMessage(ChatMessage message) {
//this is executed every message

if (message.getMessage().contains("!test")) {
//if the message contains !test then send message with @ + message + Testing
api.getChat().sendChatMessage("@" + message.getAuthor() + " Testing");
}
}

}
16 changes: 8 additions & 8 deletions src/main/java/examples/PackageExample.java
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
package examples;

import me.checkium.vhackapi.vHackAPI;
import me.checkium.vhackapi.vHackAPIBuilder;
import me.checkium.vhackapi.VHackAPI;
import me.checkium.vhackapi.packages.PackageResult;
import me.checkium.vhackapi.VHackAPIBuilder;

public class PackageExample {

vHackAPI api = new vHackAPIBuilder().password("pass").username("user").getAPI();
public void openPackage() {
PackageResult openresult = api.getPackageManager().openPackage();
System.out.println("Got " + openresult.getResultAmount() + api.humanizeString(openresult.getResultType().toString()));
}
VHackAPI api = new VHackAPIBuilder().password("pass").username("user").getAPI();

public void openPackage() {
PackageResult openresult = api.getPackageManager().openPackage();
System.out.println("Got " + openresult.getResultAmount() + api.humanizeString(openresult.getResultType().toString()));
}
}
56 changes: 28 additions & 28 deletions src/main/java/examples/UpgradeExample.java
Original file line number Diff line number Diff line change
@@ -1,37 +1,37 @@
package examples;

import me.checkium.vhackapi.vHackAPI;
import me.checkium.vhackapi.vHackAPIBuilder;
import me.checkium.vhackapi.upgrades.Task;
import me.checkium.vhackapi.upgrades.UpgradeResult;
import me.checkium.vhackapi.upgrades.UpgradeType;
import me.checkium.vhackapi.VHackAPI;
import me.checkium.vhackapi.VHackAPIBuilder;

public class UpgradeExample {

vHackAPI api = new vHackAPIBuilder().password("pass").username("user").getAPI();
public void addUpgrade() {
UpgradeResult upgrade = api.getUpgradeManager().addUpdate(UpgradeType.adw);
if (upgrade == UpgradeResult.NoMoney || upgrade == UpgradeResult.Invalid || upgrade == UpgradeResult.NoMemory) {
System.out.println("Fail");
}
if (upgrade == UpgradeResult.Success) {
System.out.println("Success");
}
}
public void finishUpgrade() {
Task task = api.getUpgradeManager().getTasks().get(0);
if (api.getUpgradeManager().finishTask(task)) {
System.out.println("Task finished with netcoins successfully");
}
}
public void abortUpgrade() {
Task task = api.getUpgradeManager().getTasks().get(0);
if (api.getUpgradeManager().abortTask(task)) {
System.out.println("Task aborted successfully");
}
}
VHackAPI api = new VHackAPIBuilder().password("pass").username("user").getAPI();

public void addUpgrade() {
UpgradeResult upgrade = api.getUpgradeManager().addUpdate(UpgradeType.ADW);

if (upgrade == UpgradeResult.NO_MONEY || upgrade == UpgradeResult.INVALID || upgrade == UpgradeResult.NO_MEMORY) {
System.out.println("Fail");
}
if (upgrade == UpgradeResult.SUCCESS) {
System.out.println("SUCCESS");
}
}

public void finishUpgrade() {
Task task = api.getUpgradeManager().getTasks().get(0);
if (api.getUpgradeManager().finishTask(task)) {
System.out.println("Task finished with NETCOINS successfully");
}
}

public void abortUpgrade() {
Task task = api.getUpgradeManager().getTasks().get(0);
if (api.getUpgradeManager().abortTask(task)) {
System.out.println("Task aborted successfully");
}
}
}
Loading