package rpgEngine.Logic.Game;

import rpgEngine.Data.Abstract.Game;
import rpgEngine.Data.Abstract.Item;

public class ItemTrader {
	private Game game;
	
	public ItemTrader(Game g) {
		game = g;
	}
	
	
	public Boolean buyItem(Item i) {
		Boolean result = false;
		
		if(game.getGold() >= i.getGoldCost()) {
			game.setGold(game.getGold() - i.getGoldCost());
			
			game.getInventory().addItemToInventory(i);
			
			result = true;
		}
		else {
			result = false;
		}
		
		return result;
	}
	
	
	public Boolean sellItem(Item i) {
		Boolean result = true;
		
		game.setGold(game.getGold() + (i.getGoldCost() / 2));
		
		game.getInventory().removeItemFromInventory(i);
		
		return result;
	}
	
}
