runelite-client: Centralize the high alchemy multiplier
This commit is contained in:
@@ -108,4 +108,10 @@ public class Constants
|
|||||||
*/
|
*/
|
||||||
public static final int ITEM_SPRITE_HEIGHT = 32;
|
public static final int ITEM_SPRITE_HEIGHT = 32;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* High alchemy = shop price * HIGH_ALCHEMY_MULTIPLIER
|
||||||
|
*
|
||||||
|
* @see ItemComposition#getPrice
|
||||||
|
*/
|
||||||
|
public static final float HIGH_ALCHEMY_MULTIPLIER = .6f;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -87,6 +87,8 @@ public interface ItemComposition
|
|||||||
* alchemy values, respectively.
|
* alchemy values, respectively.
|
||||||
*
|
*
|
||||||
* @return the general store value of the item
|
* @return the general store value of the item
|
||||||
|
*
|
||||||
|
* @see Constants#HIGH_ALCHEMY_MULTIPLIER
|
||||||
*/
|
*/
|
||||||
int getPrice();
|
int getPrice();
|
||||||
|
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ import javax.inject.Inject;
|
|||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import net.runelite.api.Client;
|
import net.runelite.api.Client;
|
||||||
|
import net.runelite.api.Constants;
|
||||||
import net.runelite.api.InventoryID;
|
import net.runelite.api.InventoryID;
|
||||||
import net.runelite.api.Item;
|
import net.runelite.api.Item;
|
||||||
import net.runelite.api.ItemComposition;
|
import net.runelite.api.ItemComposition;
|
||||||
@@ -47,7 +48,6 @@ import net.runelite.client.game.ItemManager;
|
|||||||
@Slf4j
|
@Slf4j
|
||||||
class BankCalculation
|
class BankCalculation
|
||||||
{
|
{
|
||||||
private static final float HIGH_ALCHEMY_CONSTANT = 0.6f;
|
|
||||||
private static final ImmutableList<Varbits> TAB_VARBITS = ImmutableList.of(
|
private static final ImmutableList<Varbits> TAB_VARBITS = ImmutableList.of(
|
||||||
Varbits.BANK_TAB_ONE_COUNT,
|
Varbits.BANK_TAB_ONE_COUNT,
|
||||||
Varbits.BANK_TAB_TWO_COUNT,
|
Varbits.BANK_TAB_TWO_COUNT,
|
||||||
@@ -157,7 +157,7 @@ class BankCalculation
|
|||||||
|
|
||||||
if (price > 0)
|
if (price > 0)
|
||||||
{
|
{
|
||||||
haPrice += (long) Math.round(price * HIGH_ALCHEMY_CONSTANT) *
|
haPrice += (long) Math.round(price * Constants.HIGH_ALCHEMY_MULTIPLIER) *
|
||||||
(long) quantity;
|
(long) quantity;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ import lombok.Value;
|
|||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import net.runelite.api.ChatMessageType;
|
import net.runelite.api.ChatMessageType;
|
||||||
import net.runelite.api.Client;
|
import net.runelite.api.Client;
|
||||||
|
import net.runelite.api.Constants;
|
||||||
import net.runelite.api.Experience;
|
import net.runelite.api.Experience;
|
||||||
import net.runelite.api.IconID;
|
import net.runelite.api.IconID;
|
||||||
import net.runelite.api.ItemComposition;
|
import net.runelite.api.ItemComposition;
|
||||||
@@ -80,7 +81,6 @@ import org.apache.commons.text.WordUtils;
|
|||||||
@Slf4j
|
@Slf4j
|
||||||
public class ChatCommandsPlugin extends Plugin
|
public class ChatCommandsPlugin extends Plugin
|
||||||
{
|
{
|
||||||
private static final float HIGH_ALCHEMY_CONSTANT = 0.6f;
|
|
||||||
private static final Pattern KILLCOUNT_PATTERN = Pattern.compile("Your (.+) (?:kill|harvest) count is: <col=ff0000>(\\d+)</col>");
|
private static final Pattern KILLCOUNT_PATTERN = Pattern.compile("Your (.+) (?:kill|harvest) count is: <col=ff0000>(\\d+)</col>");
|
||||||
private static final Pattern RAIDS_PATTERN = Pattern.compile("Your completed (.+) count is: <col=ff0000>(\\d+)</col>");
|
private static final Pattern RAIDS_PATTERN = Pattern.compile("Your completed (.+) count is: <col=ff0000>(\\d+)</col>");
|
||||||
private static final Pattern WINTERTODT_PATTERN = Pattern.compile("Your subdued Wintertodt count is: <col=ff0000>(\\d+)</col>");
|
private static final Pattern WINTERTODT_PATTERN = Pattern.compile("Your subdued Wintertodt count is: <col=ff0000>(\\d+)</col>");
|
||||||
@@ -614,7 +614,7 @@ public class ChatCommandsPlugin extends Plugin
|
|||||||
ItemComposition itemComposition = itemManager.getItemComposition(itemId);
|
ItemComposition itemComposition = itemManager.getItemComposition(itemId);
|
||||||
if (itemComposition != null)
|
if (itemComposition != null)
|
||||||
{
|
{
|
||||||
int alchPrice = Math.round(itemComposition.getPrice() * HIGH_ALCHEMY_CONSTANT);
|
int alchPrice = Math.round(itemComposition.getPrice() * Constants.HIGH_ALCHEMY_MULTIPLIER);
|
||||||
builder
|
builder
|
||||||
.append(ChatColorType.NORMAL)
|
.append(ChatColorType.NORMAL)
|
||||||
.append(" HA value ")
|
.append(" HA value ")
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ import javax.inject.Inject;
|
|||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import net.runelite.api.ChatMessageType;
|
import net.runelite.api.ChatMessageType;
|
||||||
import net.runelite.api.Client;
|
import net.runelite.api.Client;
|
||||||
|
import net.runelite.api.Constants;
|
||||||
import net.runelite.api.ItemComposition;
|
import net.runelite.api.ItemComposition;
|
||||||
import net.runelite.api.events.ChatMessage;
|
import net.runelite.api.events.ChatMessage;
|
||||||
import net.runelite.api.events.GameStateChanged;
|
import net.runelite.api.events.GameStateChanged;
|
||||||
@@ -68,7 +69,6 @@ import net.runelite.http.api.examine.ExamineClient;
|
|||||||
@Slf4j
|
@Slf4j
|
||||||
public class ExaminePlugin extends Plugin
|
public class ExaminePlugin extends Plugin
|
||||||
{
|
{
|
||||||
private static final float HIGH_ALCHEMY_CONSTANT = 0.6f;
|
|
||||||
private static final Pattern X_PATTERN = Pattern.compile("^\\d+ x ");
|
private static final Pattern X_PATTERN = Pattern.compile("^\\d+ x ");
|
||||||
|
|
||||||
private final Deque<PendingExamine> pending = new ArrayDeque<>();
|
private final Deque<PendingExamine> pending = new ArrayDeque<>();
|
||||||
@@ -319,7 +319,7 @@ public class ExaminePlugin extends Plugin
|
|||||||
quantity = Math.max(1, quantity);
|
quantity = Math.max(1, quantity);
|
||||||
int itemCompositionPrice = itemComposition.getPrice();
|
int itemCompositionPrice = itemComposition.getPrice();
|
||||||
final int gePrice = itemManager.getItemPrice(id);
|
final int gePrice = itemManager.getItemPrice(id);
|
||||||
final int alchPrice = itemCompositionPrice <= 0 ? 0 : Math.round(itemCompositionPrice * HIGH_ALCHEMY_CONSTANT);
|
final int alchPrice = itemCompositionPrice <= 0 ? 0 : Math.round(itemCompositionPrice * Constants.HIGH_ALCHEMY_MULTIPLIER);
|
||||||
|
|
||||||
if (gePrice > 0 || alchPrice > 0)
|
if (gePrice > 0 || alchPrice > 0)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -46,6 +46,7 @@ import lombok.AccessLevel;
|
|||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
import net.runelite.api.Client;
|
import net.runelite.api.Client;
|
||||||
|
import net.runelite.api.Constants;
|
||||||
import net.runelite.api.GameState;
|
import net.runelite.api.GameState;
|
||||||
import net.runelite.api.Item;
|
import net.runelite.api.Item;
|
||||||
import net.runelite.api.ItemComposition;
|
import net.runelite.api.ItemComposition;
|
||||||
@@ -95,8 +96,6 @@ import net.runelite.client.util.Text;
|
|||||||
)
|
)
|
||||||
public class GroundItemsPlugin extends Plugin
|
public class GroundItemsPlugin extends Plugin
|
||||||
{
|
{
|
||||||
// Used when getting High Alchemy value - multiplied by general store price.
|
|
||||||
private static final float HIGH_ALCHEMY_CONSTANT = 0.6f;
|
|
||||||
// ItemID for coins
|
// ItemID for coins
|
||||||
private static final int COINS = ItemID.COINS_995;
|
private static final int COINS = ItemID.COINS_995;
|
||||||
// Ground item menu options
|
// Ground item menu options
|
||||||
@@ -369,7 +368,7 @@ public class GroundItemsPlugin extends Plugin
|
|||||||
final int itemId = item.getId();
|
final int itemId = item.getId();
|
||||||
final ItemComposition itemComposition = itemManager.getItemComposition(itemId);
|
final ItemComposition itemComposition = itemManager.getItemComposition(itemId);
|
||||||
final int realItemId = itemComposition.getNote() != -1 ? itemComposition.getLinkedNoteId() : itemId;
|
final int realItemId = itemComposition.getNote() != -1 ? itemComposition.getLinkedNoteId() : itemId;
|
||||||
final int alchPrice = Math.round(itemComposition.getPrice() * HIGH_ALCHEMY_CONSTANT);
|
final int alchPrice = Math.round(itemComposition.getPrice() * Constants.HIGH_ALCHEMY_MULTIPLIER);
|
||||||
|
|
||||||
final GroundItem groundItem = GroundItem.builder()
|
final GroundItem groundItem = GroundItem.builder()
|
||||||
.id(itemId)
|
.id(itemId)
|
||||||
@@ -481,7 +480,7 @@ public class GroundItemsPlugin extends Plugin
|
|||||||
final int realItemId = itemComposition.getNote() != -1 ? itemComposition.getLinkedNoteId() : itemComposition.getId();
|
final int realItemId = itemComposition.getNote() != -1 ? itemComposition.getLinkedNoteId() : itemComposition.getId();
|
||||||
final int itemPrice = itemManager.getItemPrice(realItemId);
|
final int itemPrice = itemManager.getItemPrice(realItemId);
|
||||||
final int price = itemPrice <= 0 ? itemComposition.getPrice() : itemPrice;
|
final int price = itemPrice <= 0 ? itemComposition.getPrice() : itemPrice;
|
||||||
final int haPrice = Math.round(itemComposition.getPrice() * HIGH_ALCHEMY_CONSTANT) * quantity;
|
final int haPrice = Math.round(itemComposition.getPrice() * Constants.HIGH_ALCHEMY_MULTIPLIER) * quantity;
|
||||||
final int gePrice = quantity * price;
|
final int gePrice = quantity * price;
|
||||||
final Color hidden = getHidden(itemComposition.getName(), gePrice, haPrice, itemComposition.isTradeable());
|
final Color hidden = getHidden(itemComposition.getName(), gePrice, haPrice, itemComposition.isTradeable());
|
||||||
final Color highlighted = getHighlighted(itemComposition.getName(), gePrice, haPrice);
|
final Color highlighted = getHighlighted(itemComposition.getName(), gePrice, haPrice);
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ import java.awt.Dimension;
|
|||||||
import java.awt.Graphics2D;
|
import java.awt.Graphics2D;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import net.runelite.api.Client;
|
import net.runelite.api.Client;
|
||||||
|
import net.runelite.api.Constants;
|
||||||
import net.runelite.api.InventoryID;
|
import net.runelite.api.InventoryID;
|
||||||
import net.runelite.api.Item;
|
import net.runelite.api.Item;
|
||||||
import net.runelite.api.ItemComposition;
|
import net.runelite.api.ItemComposition;
|
||||||
@@ -48,9 +49,6 @@ import net.runelite.client.util.StackFormatter;
|
|||||||
|
|
||||||
class ItemPricesOverlay extends Overlay
|
class ItemPricesOverlay extends Overlay
|
||||||
{
|
{
|
||||||
// Used when getting High Alchemy value - multiplied by general store price.
|
|
||||||
private static final float HIGH_ALCHEMY_CONSTANT = 0.6f;
|
|
||||||
|
|
||||||
private static final int INVENTORY_ITEM_WIDGETID = WidgetInfo.INVENTORY.getPackedId();
|
private static final int INVENTORY_ITEM_WIDGETID = WidgetInfo.INVENTORY.getPackedId();
|
||||||
private static final int BANK_INVENTORY_ITEM_WIDGETID = WidgetInfo.BANK_INVENTORY_ITEMS_CONTAINER.getPackedId();
|
private static final int BANK_INVENTORY_ITEM_WIDGETID = WidgetInfo.BANK_INVENTORY_ITEMS_CONTAINER.getPackedId();
|
||||||
private static final int BANK_ITEM_WIDGETID = WidgetInfo.BANK_ITEM_CONTAINER.getPackedId();
|
private static final int BANK_ITEM_WIDGETID = WidgetInfo.BANK_ITEM_CONTAINER.getPackedId();
|
||||||
@@ -204,7 +202,7 @@ class ItemPricesOverlay extends Overlay
|
|||||||
}
|
}
|
||||||
if (config.showHAValue())
|
if (config.showHAValue())
|
||||||
{
|
{
|
||||||
haPrice = Math.round(itemDef.getPrice() * HIGH_ALCHEMY_CONSTANT);
|
haPrice = Math.round(itemDef.getPrice() * Constants.HIGH_ALCHEMY_MULTIPLIER);
|
||||||
}
|
}
|
||||||
if (gePrice > 0 && haPrice > 0 && config.showAlchProfit())
|
if (gePrice > 0 && haPrice > 0 && config.showAlchProfit())
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user