Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.merccy.Shop;
- import java.awt.Rectangle;
- import org.osbot.script.Script;
- import org.osbot.script.mouse.RectangleDestination;
- public class ShopItem {
- private Script scr;
- public int slotID;
- private int parentID;
- private int childID;
- private int startWidth = 80;
- private int startHeight = 70;
- private int itemWidth = 30;
- private int itemHeight = 30;
- private int spaceWidth = 17;
- private int spaceHeight = 17;
- private int rowAmount = 8;
- public Rectangle slot;
- public String name;
- public int id;
- public int amount;
- public ShopItem(Script s, int slotID){
- this.scr = s;
- this.slotID = slotID;
- this.slot = this.getRectForSlot(this.slotID);
- }
- public ShopItem(Script s, int slotID, int p, int c){
- this.scr = s;
- this.slotID = slotID;
- this.parentID = p;
- this.childID = c;
- this.slot = this.getRectForSlot(this.slotID);
- }
- public int getAmount(){
- return this.amount;
- }
- public String getName(){
- return this.name;
- }
- public int getID(){
- return this.id;
- }
- public int getSlotID(){
- return this.slotID;
- }
- public boolean value() throws InterruptedException{
- this.scr.client.moveMouseTo(new RectangleDestination(this.slot), true, true, true);
- this.scr.sleep(250);
- return this.scr.selectOption(null, new RectangleDestination(this.slot), "Value");
- }
- public boolean buy1() throws InterruptedException{
- this.scr.client.moveMouseTo(new RectangleDestination(this.slot), true, true, true);
- this.scr.sleep(250);
- return this.scr.selectOption(null, new RectangleDestination(this.slot), "Buy 1");
- }
- public boolean buy5() throws InterruptedException{
- this.scr.client.moveMouseTo(new RectangleDestination(this.slot), true, true, true);
- this.scr.sleep(250);
- return this.scr.selectOption(null, new RectangleDestination(this.slot), "Buy 5");
- }
- public boolean buy10() throws InterruptedException{
- this.scr.client.moveMouseTo(new RectangleDestination(this.slot), true, true, true);
- this.scr.sleep(250);
- return this.scr.selectOption(null, new RectangleDestination(this.slot), "Buy 10");
- }
- private Rectangle getRectForSlot(int slotId) {
- return new Rectangle(this.calcWidth(slotId), this.calcHeight(slotId),
- this.itemWidth, this.itemHeight);
- }
- private int calcWidth(int slotId) {
- int mod = slotId % 8;
- if (mod == 0){
- mod = 8;
- }
- int column = mod - 1;
- int totalwidth = this.startWidth;
- for (int i = 1; i <= column; i++) {
- totalwidth += this.itemWidth;
- totalwidth += this.spaceWidth;
- }
- return totalwidth;
- }
- private int calcHeight(int slotId) {
- int row = (int) Math.ceil(slotId / 8D) - 1;
- int totalheight = this.startHeight;
- for (int i = 1; i <= row; i++) {
- totalheight += this.spaceHeight;
- totalheight += this.itemHeight;
- }
- return totalheight;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement