Jump to content

Banking Util


Joseph

Recommended Posts

My task interface is a simple node interface everybody uses. 

 

Contains three methods:

  1. String: status()
  2. int: run()
  3. boolean: activate();

you could remove dsAPI its my own api but i did release some of the methods some where in this section il give you links.

containsAll

 

This is an abstract class which is meant to be extended. You can override activate if it doesnt suit your needs.

package util;

import java.util.ArrayList;
import java.util.List;

import org.osbot.rs07.api.util.Utilities;
import org.osbot.rs07.script.Script;

import osb.setting.Task;
import osb.util.DsAPI;
import osb.web.WebBank;

public abstract class DsBanking implements Task {
	
	public List<String> requirements = new ArrayList<String>();
	public final Script ctx;
	private final DsAPI dsAPI;
	private WebBank webBank;
	
	public DsBanking(Script ctx, DsAPI dsAPI)	{
		this.ctx = ctx;
		this.dsAPI = dsAPI;
		this.webBank = dsAPI.getWebBank();
	}
	
	public abstract String status();	
	public abstract void run() throws InterruptedException;
	
	@Override
	public boolean activate() throws InterruptedException {
		return this.webBank.insideBank() && !dsAPI.containsAll(true, getList());
	}

	public void clearList()	{
		requirements.clear();
	}
	
	public void setupList(String...items)	{
		for (String item: items)	{
			requirements.add(item);
		}		
	}
	
	public String[] getList()	{
		return Utilities.convertStrings(requirements);
	}
	
	public boolean openBank()	{
		return webBank.openBank();
	}
	
	public boolean depositAll()	{
		if (ctx.inventory.contains(getList()))
			return ctx.bank.depositAllExcept(getList());
		else
			return ctx.bank.depositAll();
	}
	
	public void withdraw(String name, int amount) throws InterruptedException	{
		if (dsAPI.containsAll(false, name))	{
			boolean all = (amount == -2) ? true: false;
			boolean allButOne = (amount == -1) ? true: false;
			
			if (all)
				ctx.bank.withdrawAll(name);
			else if (allButOne)
				ctx.bank.withdrawAllButOne(name);
			else
				ctx.bank.withdraw(name, amount);
			dsAPI.conSleep(dsAPI.containsAll(true, name), 7000).sleep();
		}else{
			ctx.log("doesnt have " +name);
			ctx.bot.getScriptExecutor().stop();
		}
	}
}

Edited by josedpay
Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...