Jump to content

switching case if store contains items


Lewis

Recommended Posts

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
    } 
Link to comment
Share on other sites

 

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;
}
Link to comment
Share on other sites

 

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

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

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