Jump to content

switching case if store contains items


Recommended Posts

Posted

You can write it like this -

private String items[] = new String[] {"item1", "item2", "item3", };


private State getState()   {			
		if(getStore().isOpen()) {
			if(getStore().getAmount(items) <= 0) {				
				return State.HOP;
			}
		}
		if(inventory.isFull()) {
			return State.BANK;
		}
		return State.SHOP;
	}

Inside the bank script you could put an if statement ascertain whether or not your character is at the bank, such as

case BANK: 
    if(whateverbank.contains(myPlayer())) {
       check if bank is open, deposit stuff etc..
    } 
    else {
       walk to bank
    } 
Posted

 

You can write it like this -

private String items[] = new String[] {"item1", "item2", "item3", };


private State getState()   {			
		if(getStore().isOpen()) {
			if(getStore().getAmount(items) <= 0) {				
				return State.HOP;
			}
		}
		if(inventory.isFull()) {
			return State.BANK;
		}
		return State.SHOP;
	}

Inside the bank script you could put an if statement ascertain whether or not your character is at the bank, such as

case BANK: 
    if(whateverbank.contains(myPlayer())) {
       check if bank is open, deposit stuff etc..
    } 
    else {
       walk to bank
    } 

got banking, walking to and from shop to bank down

 

private State getState() {
if (Shop.contains(myPlayer()) && !inventory.isFull())
return State.BUY;
if (!deposit.contains(myPlayer()) && inventory.isFull())
return State.WALK_BANK;
if (deposit.contains(myPlayer()) && inventory.isFull())
return State.BANK;
if (!Shop.contains(myPlayer()) && !inventory.isFull())
return State.WALK_SHOP;
if (store.isOpen()) {
if (store.getAmount(items) <= 0) {
return State.HOP;
}
}
return State.WAIT;
}
Posted

 

got banking, walking to and from shop to bank down

private State getState() {
if (Shop.contains(myPlayer()) && !inventory.isFull())
return State.BUY;
if (!deposit.contains(myPlayer()) && inventory.isFull())
return State.WALK_BANK;
if (deposit.contains(myPlayer()) && inventory.isFull())
return State.BANK;
if (!Shop.contains(myPlayer()) && !inventory.isFull())
return State.WALK_SHOP;
if (store.isOpen()) {
if (store.getAmount(items) <= 0) {
return State.HOP;
}
}
return State.WAIT;
}

 

Look on skype

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

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