Update ShopAssistant.java (#121)

Adds ability to sell tokkul items back to shop for tokkul
This commit is contained in:
Mr Extremez
2019-10-27 13:13:37 -05:00
committed by Daniel Ginovker
parent 365e4a13be
commit e9480ee890
@@ -311,6 +311,7 @@ public class ShopAssistant {
player.getActionSender().sendMessage("You can't sell " + ItemAssistant.getItemName(removeId).toLowerCase() + " to this store.");
} else {
int ShopValue = (int) Math.floor(getItemShopValue(removeId, 1, true));
int tokkulValue = (int) Math.floor(getTokkulValue(removeId) *.85);
String ShopAdd = "";
if (ShopValue >= 1000 && ShopValue < 1000000) {
ShopAdd = " (" + (ShopValue / 1000) + "K)";
@@ -319,6 +320,8 @@ public class ShopAssistant {
}
if (player.myShopId != RANGE_SHOP && player.myShopId != PEST_SHOP && player.myShopId != CASTLE_SHOP && player.myShopId != 138 && player.myShopId != 58 && player.myShopId != 139) {
player.getActionSender().sendMessage(ItemAssistant.getItemName(removeId) + ": shop will buy for " + ShopValue + " coins." + ShopAdd);
} else if (player.myShopId == 138 || player.myShopId == 139 || player.myShopId == 58) {
player.getActionSender().sendMessage(ItemAssistant.getItemName(removeId) + ": shop will buy for " + tokkulValue + " tokkul.");
} else if (player.myShopId == RANGE_SHOP) {
player.getActionSender().sendMessage(ItemAssistant.getItemName(removeId) + ": shop will buy for " + getRGItemValue(removeId) + " archery tickets." + ShopAdd);
} else if (player.myShopId == PEST_SHOP) {
@@ -370,14 +373,23 @@ public class ShopAssistant {
// double ShopValue;
// double TotPrice;
String itemName = ItemAssistant.getItemName(itemID).toLowerCase();
int TotPrice2 = (int) Math.floor(getItemShopValue(itemID, amount, true) * amount); //Something about total price of item?
if (player.getItemAssistant().freeSlots() > 0 || player.getItemAssistant().playerHasItem(995)) { //Checks to see if player has room for coins.
int TotPrice2 = 0;
if (player.myShopId == 138 || player.myShopId == 58 || player.myShopId == 139) {
TotPrice2 = (int) (getTokkulValue(itemID) * .85);
} else {
TotPrice2 = (int) Math.floor(getItemShopValue(itemID, amount, true) * amount); //Something about total price of item?
}
if (player.getItemAssistant().freeSlots() > 0 || player.getItemAssistant().playerHasItem(995) || player.getItemAssistant().playerHasItem(6529)) { //Checks to see if player has room for coins.
if (!ItemDefinitions.getDef()[itemID].isNoteable) { //Check to see if its notable.
player.getItemAssistant().deleteItem(itemID, player.getItemAssistant().getItemSlot(itemID), amount); //don't really understand if the item isn't notable why it still needs to find the slot.
} else {
player.getItemAssistant().deleteItem(itemID, fromSlot, amount);
}
player.getItemAssistant().addItem(995, TotPrice2); //Add the coins to your inventory.
if (player.myShopId == 138 || player.myShopId == 139 || player.myShopId == 58) {
player.getItemAssistant().addItem(6529, TotPrice2); //Add the tokkul to your inventory.
} else {
player.getItemAssistant().addItem(995, TotPrice2); //Add the coins to your inventory.
}
addShopItem(itemID, amount); //Add item to the shop.
if (player.getPlayerAssistant().isPlayer()) { //Logger
GameLogger.writeLog(player.playerName, "shopselling", player.playerName + " sold " + itemName + " to store id: " + player.myShopId + " for" + GameLogger.formatCurrency(TotPrice2) + " coins");