import handler.ScriptHandler;
import org.osbot.rs07.script.Script;
import org.osbot.rs07.script.ScriptManifest;
import java.awt.*;
import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics2D;
import java.util.concurrent.TimeUnit;
import org.osbot.rs07.api.ui.Message;
import org.osbot.rs07.utility.ConditionalSleep;
@ScriptManifest(author="ASD1", info="Makes Uncooked pizzas", name="asd1", version=1.0D, logo="")
public class PizzaMan
extends ScriptHandler
{
public static enum Making
{
INCOMPLETE_PIZZA("Tomato", "Pizza base", "Incomplete pizza"), UNCOOKED_PIZZA("Cheese", "Incomplete pizza", "Uncooked pizza");
private String secondItem;
private String product;
private Making(String firstItem, String secondItem, String product)
{
this.secondItem = secondItem;
this.product = product;
}
public String getSecondItem()
{
return this.secondItem;
}
public String getProduct()
{
return this.product;
}
}
public boolean advancedPaint = true;
private int paint_x = 10;
private int paint_y = 160;
private long timeBegan;
private long timeRan;
public static Making making;
public String firstItem;
public String secondItem;
public String product;
public boolean recentMessage = false;
public int[] itemsMade = new int[3];
@Override
public void onStart() {
log("Let's get started!");
this.timeBegan = System.currentTimeMillis();
synchronized (PizzaMan.class)
{
try
{
PizzaMan.class.wait();
}
catch (InterruptedException e)
{
e.printStackTrace();
}
}
loadMode(making);
this.camera.moveYaw(100);
log("Let's get started!");
}
public int onLoop()
throws InterruptedException
{
if (getDialogues().isPendingContinuation())
{
this.recentMessage = false;
getDialogues().clickContinue();
}
if (getMessageHandler().isActive()) {
getMessageHandler().setRecentMessage(true);
} else {
getMessageHandler().setRecentMessage(false);
}
if (getInventory().contains(new String[] { this.firstItem })) {
if ((getInventory().contains(new String[] { this.secondItem })) && (!getBank().isOpen())) {
if ((!getMessageHandler().isActive()) &&
(getInventoryHandler().itemOnItem(this.firstItem, this.secondItem)))
{
new ConditionalSleep(2000)
{
public boolean condition()
throws InterruptedException
{
return (PizzaMan.this.getDialogues().isPendingOption()) || (PizzaMan.this.getWidgets().isVisible(309, 2));
}
}.sleep();
if ((getDialogues().isPendingOption()) &&
(getDialogues().selectOption(3))) {
sleep(random(1000, 1200));
}
if (getWidgets().interact(309, 2, "Make All"))
{
sleep(random(600, 1000));
this.mouse.moveOutsideScreen();
sleep(2000L);
}
}
}
}
if (getInventory().contains(new String[] { this.firstItem }))
{
if (getInventory().contains(new String[] { this.secondItem })) {}
}
else
{
this.recentMessage = false;
if (!getBank().isOpen())
{
getBankHandler().open();
new ConditionalSleep(2000)
{
public boolean condition()
throws InterruptedException
{
return PizzaMan.this.getBank().isOpen();
}
}.sleep();
}
else if (getInventory().contains(new String[] { this.product }))
{
getBank().depositAll();
sleep(600L);
}
else
{
if (getBank().contains(new String[] { this.firstItem }))
{
if (getBank().contains(new String[] { this.secondItem })) {}
}
else
{
{
making = Making.INCOMPLETE_PIZZA;
loadMode(making);
}
if (making == Making.INCOMPLETE_PIZZA)
{
making = Making.UNCOOKED_PIZZA;
loadMode(making);
}
stop(true);
}
{
getBank().withdraw(this.firstItem, 9);
sleep(600L);
getBank().withdraw(this.secondItem, 9);
sleep(600L);
}
{
getBank().withdraw(this.secondItem, 14);
sleep(600L);
getBank().withdraw(this.firstItem, 14);
sleep(600L);
}
getBank().close();
}
}
return
random(200, 300);
}
public void onExit() {}
public void onMessage(Message message)
throws InterruptedException
{
String gameMessage = message.getMessage().toString();
if (gameMessage.contains("You mix the water and flour"))
{
this.itemsMade[0] += 1;
getMessageHandler().activate();
}
else if (gameMessage.contains("You add the tomato"))
{
this.itemsMade[1] += 1;
getMessageHandler().activate();
}
else if (gameMessage.contains("You add the cheese"))
{
this.itemsMade[2] += 1;
getMessageHandler().activate();
}
else if (gameMessage.contains("You add the anchovies"))
{
this.itemsMade[2] += 1;
getMessageHandler().activate();
}
}
private String ft(long duration)
{
String res = "";
long days = TimeUnit.MILLISECONDS.toDays(duration);
long hours = TimeUnit.MILLISECONDS.toHours(duration) -
TimeUnit.DAYS.toHours(TimeUnit.MILLISECONDS.toDays(duration));
long minutes = TimeUnit.MILLISECONDS.toMinutes(duration) -
TimeUnit.HOURS.toMinutes(TimeUnit.MILLISECONDS.toHours(duration));
long seconds = TimeUnit.MILLISECONDS.toSeconds(duration) -
TimeUnit.MINUTES.toSeconds(TimeUnit.MILLISECONDS.toMinutes(duration));
if (days == 0L) {
res = String.format("%02d:%02d:%02d", new Object[] { Long.valueOf(hours), Long.valueOf(minutes), Long.valueOf(seconds) });
} else {
res = String.format("%02d:%02d:%02d:%02d", new Object[] { Long.valueOf(days), Long.valueOf(hours), Long.valueOf(minutes), Long.valueOf(seconds) });
}
return res;
}
public int getY(int i)
{
return this.paint_y + 15 * i;
}
public void onPaint(Graphics2D g)
{
this.timeRan = (System.currentTimeMillis() - this.timeBegan);
int currentlyMaking = 0;
if (making == Making.INCOMPLETE_PIZZA) {
currentlyMaking = 0;
} else if (making == Making.INCOMPLETE_PIZZA) {
currentlyMaking = 1;
} else if (making == Making.UNCOOKED_PIZZA) {
currentlyMaking = 2;
}
int madePerHour = (int)(this.itemsMade[currentlyMaking] / (
(System.currentTimeMillis() - this.timeBegan) / 3600000.0D));
int averagePerHour = (int)(this.itemsMade[currentlyMaking] / (
(System.currentTimeMillis() - this.timeBegan) / 3600000.0D));
super.onPaint(g);
Color c = new Color(0.0F, 0.0F, 0.0F, 0.2F);
Color insideGreen = new Color(0, 255, 0, 80);
g.setColor(c);
g.fillRect(this.paint_x - 5, this.paint_y, 200, getY(4) - this.paint_y + 10);
g.setFont(new Font("Trebuchet", 0, 12));
g.setColor(Color.WHITE);
g.drawString("Incuso's Pizza", this.paint_x, getY(1));
g.drawString("Running time: " + ft(this.timeRan), this.paint_x, getY(2));
g.drawString("Currently making " + this.product, this.paint_x, getY(3));
g.drawString(this.product + "s made: " + this.itemsMade[currentlyMaking] + " (" + madePerHour + ")", this.paint_x, getY(4));
if (this.advancedPaint)
{
g.setColor(Color.RED);
}
}
public void loadMode(Making mode)
{
this.secondItem = mode.getSecondItem();
this.product = mode.getProduct();
}
}