Merge pull request #7384 from Abextm/farming-guild
farming: Support Kebos Lowlands update
This commit is contained in:
@@ -390,6 +390,15 @@ public enum Varbits
|
||||
FARMING_4772(4772),
|
||||
FARMING_4773(4773),
|
||||
FARMING_4774(4774),
|
||||
FARMING_4775(4775),
|
||||
FARMING_7904(7904),
|
||||
FARMING_7905(7905),
|
||||
FARMING_7906(7906),
|
||||
FARMING_7907(7907),
|
||||
FARMING_7908(7908),
|
||||
FARMING_7909(7909),
|
||||
FARMING_7910(7910),
|
||||
FARMING_7911(7911),
|
||||
|
||||
/**
|
||||
* Transmog controllers for grapes
|
||||
|
||||
@@ -220,6 +220,12 @@
|
||||
<version>4.12</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.hamcrest</groupId>
|
||||
<artifactId>hamcrest-library</artifactId>
|
||||
<version>1.3</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-all</artifactId>
|
||||
|
||||
@@ -226,7 +226,6 @@ public class GrandExchangeOfferSlot extends JPanel
|
||||
progressBar.setForeground(getProgressColor(newOffer));
|
||||
progressBar.setMaximumValue(newOffer.getTotalQuantity());
|
||||
progressBar.setValue(newOffer.getQuantitySold());
|
||||
progressBar.update();
|
||||
|
||||
/* Couldn't set the tooltip for the container panel as the children override it, so I'm setting
|
||||
* the tooltips on the children instead. */
|
||||
|
||||
@@ -250,7 +250,6 @@ public class FarmingTabPanel extends TabContentPanel
|
||||
panel.getProgress().setForeground(state.getCropState().getColor().darker());
|
||||
panel.getProgress().setMaximumValue(stages - 1);
|
||||
panel.getProgress().setValue(stage);
|
||||
panel.getProgress().update();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -57,7 +57,7 @@ class FarmingWorld
|
||||
// Some of these patches get updated in multiple regions.
|
||||
// It may be worth it to add a specialization for these patches
|
||||
add(new FarmingRegion("Al Kharid", 13106,
|
||||
new FarmingPatch("Cactus", Varbits.FARMING_4771, PatchImplementation.CACTUS)
|
||||
new FarmingPatch("", Varbits.FARMING_4771, PatchImplementation.CACTUS)
|
||||
));
|
||||
|
||||
add(new FarmingRegion("Ardougne", 10290,
|
||||
@@ -225,6 +225,25 @@ class FarmingWorld
|
||||
new FarmingPatch("", Varbits.FARMING_4771, PatchImplementation.HERB)
|
||||
));
|
||||
|
||||
add(new FarmingRegion("Farming Guild", 5021,
|
||||
new FarmingPatch("Hespori", Varbits.FARMING_7908, PatchImplementation.HESPORI)
|
||||
));
|
||||
|
||||
add(new FarmingRegion("Farming Guild", 4922,
|
||||
new FarmingPatch("", Varbits.FARMING_7905, PatchImplementation.TREE),
|
||||
new FarmingPatch("", Varbits.FARMING_4775, PatchImplementation.HERB),
|
||||
new FarmingPatch("", Varbits.FARMING_4772, PatchImplementation.BUSH),
|
||||
new FarmingPatch("", Varbits.FARMING_7906, PatchImplementation.FLOWER),
|
||||
new FarmingPatch("North", Varbits.FARMING_4773, PatchImplementation.ALLOTMENT),
|
||||
new FarmingPatch("South", Varbits.FARMING_4774, PatchImplementation.ALLOTMENT),
|
||||
new FarmingPatch("", Varbits.FARMING_7904, PatchImplementation.CACTUS),
|
||||
new FarmingPatch("", Varbits.FARMING_4771, PatchImplementation.SPIRIT_TREE),
|
||||
new FarmingPatch("", Varbits.FARMING_7909, PatchImplementation.FRUIT_TREE),
|
||||
new FarmingPatch("Anima", Varbits.FARMING_7911, PatchImplementation.ANIMA),
|
||||
new FarmingPatch("", Varbits.FARMING_7910, PatchImplementation.CELASTRUS),
|
||||
new FarmingPatch("", Varbits.FARMING_7907, PatchImplementation.REDWOOD)
|
||||
));
|
||||
|
||||
// Finalize
|
||||
this.regions = Collections.unmodifiableMap(regions);
|
||||
Map<Tab, Set<FarmingPatch>> umtabs = new TreeMap<>();
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -28,6 +28,7 @@ package net.runelite.client.plugins.timetracking.farming;
|
||||
import lombok.Getter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import net.runelite.api.ItemID;
|
||||
import net.runelite.api.NullItemID;
|
||||
|
||||
@RequiredArgsConstructor
|
||||
@Getter
|
||||
@@ -44,6 +45,7 @@ public enum Produce
|
||||
SWEETCORN("Sweetcorn", ItemID.SWEETCORN, 10, 6, 0, 3),
|
||||
STRAWBERRY("Strawberry", ItemID.STRAWBERRY, 10, 7, 0, 3),
|
||||
WATERMELON("Watermelon", ItemID.WATERMELON, 10, 8, 0, 3),
|
||||
SNAPE_GRASS("Snape grass", ItemID.SNAPE_GRASS, 10, 8, 0, 3),
|
||||
|
||||
// Flower crops
|
||||
MARIGOLD("Marigold", ItemID.MARIGOLDS, 5, 5),
|
||||
@@ -51,6 +53,7 @@ public enum Produce
|
||||
NASTURTIUM("Nasturtium", ItemID.NASTURTIUMS, 5, 5),
|
||||
WOAD("Woad", ItemID.WOAD_LEAF, 5, 5),
|
||||
LIMPWURT("Limpwurt", ItemID.LIMPWURT_ROOT, 5, 5),
|
||||
WHITE_LILY("While lily", ItemID.WHITE_LILY, 5, 5),
|
||||
|
||||
// Bush crops
|
||||
REDBERRIES("Redberry", ItemID.REDBERRIES, 20, 6, 20, 5),
|
||||
@@ -85,7 +88,7 @@ public enum Produce
|
||||
DWARF_WEED("Dwarf Weed", ItemID.DWARF_WEED, 20, 5, 0, 3),
|
||||
TORSTOL("Torstol", ItemID.TORSTOL, 20, 5, 0, 3),
|
||||
GOUTWEED("Goutweed", ItemID.GOUTWEED, 20, 5, 0, 2),
|
||||
ANYHERB("Any Herb", ItemID.GUAM_LEAF, 20, 5, 0, 3),
|
||||
ANYHERB("Any herb", ItemID.GUAM_LEAF, 20, 5, 0, 3),
|
||||
|
||||
// Tree crops
|
||||
OAK("Oak", ItemID.OAK_LOGS, 40, 5),
|
||||
@@ -102,17 +105,31 @@ public enum Produce
|
||||
PINEAPPLE("Pineapple", ItemID.PINEAPPLE, 160, 7, 45, 7),
|
||||
PAPAYA("Papaya", ItemID.PAPAYA_FRUIT, 160, 7, 45, 7),
|
||||
PALM("Palm", ItemID.COCONUT, 160, 7, 45, 7),
|
||||
DRAGONFRUIT("Dragonfruit", ItemID.DRAGONFRUIT, 160, 7, 45, 7),
|
||||
|
||||
// Cactus
|
||||
CACTUS("Cactus", ItemID.CACTUS_SPINE, 80, 8, 20, 4),
|
||||
POTATO_CACTUS("Potato cactus", ItemID.POTATO_CACTUS, 10, 8, 5, 7),
|
||||
|
||||
// Hardwood
|
||||
TEAK("Teak", ItemID.TEAK_LOGS, 560, 8),
|
||||
MAHOGANY("Mahogany", ItemID.MAHOGANY_LOGS, 640, 9),
|
||||
|
||||
// Anima
|
||||
ATTAS("Attas", NullItemID.NULL_22940, 640, 9),
|
||||
IASOR("Iasro", NullItemID.NULL_22939, 640, 9),
|
||||
KRONOS("Kronos", NullItemID.NULL_22938, 640, 9),
|
||||
|
||||
// Special crops
|
||||
SEAWEED("Seaweed", ItemID.GIANT_SEAWEED, 10, 5, 0, 4),
|
||||
TEAK("Teak", ItemID.TEAK_LOGS, 560, 8),
|
||||
GRAPE("Grape", ItemID.GRAPES, 5, 8, 0, 5),
|
||||
MUSHROOM("Mushroom", ItemID.MUSHROOM, 40, 7, 0, 7),
|
||||
MAHOGANY("Mahogany", ItemID.MAHOGANY_LOGS, 640, 9),
|
||||
CACTUS("Cactus", ItemID.POTATO_CACTUS, 80, 8, 20, 4),
|
||||
BELLADONNA("Belladonna", ItemID.CAVE_NIGHTSHADE, 80, 5),
|
||||
CALQUAT("Calquat", ItemID.CALQUAT_FRUIT, 160, 9, 0, 7),
|
||||
SPIRIT_TREE("Spirit Tree", ItemID.SPIRIT_TREE, 320, 13);
|
||||
SPIRIT_TREE("Spirit tree", ItemID.SPIRIT_TREE, 320, 13),
|
||||
CELASTRUS("Celastrus", ItemID.BATTLESTAFF, 160, 6, 0, 4),
|
||||
REDWOOD("Redwood", ItemID.REDWOOD_LOGS, 640, 11),
|
||||
HESPORI("Hespori", NullItemID.NULL_23044, 640, 4, 0, 2);
|
||||
|
||||
/**
|
||||
* User-visible name
|
||||
|
||||
@@ -144,8 +144,6 @@ public class BirdHouseTabPanel extends TabContentPanel
|
||||
panel.getEstimate().setText("Unknown");
|
||||
break;
|
||||
}
|
||||
|
||||
panel.getProgress().update();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,69 +25,71 @@
|
||||
*/
|
||||
package net.runelite.client.ui.components;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Color;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Graphics;
|
||||
import javax.swing.JPanel;
|
||||
import lombok.Setter;
|
||||
import net.runelite.client.ui.ColorScheme;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* A progress bar to be displayed underneath the GE offer item panels
|
||||
*/
|
||||
public class ThinProgressBar extends JPanel
|
||||
{
|
||||
@Setter
|
||||
private int maximumValue;
|
||||
@Getter
|
||||
private int maximumValue = 1;
|
||||
|
||||
@Setter
|
||||
@Getter
|
||||
private int value;
|
||||
|
||||
private final JPanel topBar = new JPanel();
|
||||
|
||||
public ThinProgressBar()
|
||||
{
|
||||
setLayout(new BorderLayout());
|
||||
setBackground(Color.GREEN.darker());
|
||||
|
||||
topBar.setPreferredSize(new Dimension(100, 4));
|
||||
topBar.setBackground(ColorScheme.PROGRESS_COMPLETE_COLOR);
|
||||
|
||||
add(topBar, BorderLayout.WEST);
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the UI based on the percentage progress
|
||||
*/
|
||||
public void update()
|
||||
{
|
||||
double percentage = getPercentage();
|
||||
int topWidth = (int) (getSize().width * (percentage / 100));
|
||||
|
||||
topBar.setPreferredSize(new Dimension(topWidth, 4));
|
||||
topBar.repaint();
|
||||
|
||||
revalidate();
|
||||
repaint();
|
||||
setForeground(Color.GREEN);
|
||||
setMaximumSize(new Dimension(Integer.MAX_VALUE, 4));
|
||||
setMinimumSize(new Dimension(0, 4));
|
||||
setPreferredSize(new Dimension(0, 4));
|
||||
setSize(new Dimension(0, 4));
|
||||
setOpaque(true);
|
||||
}
|
||||
|
||||
public double getPercentage()
|
||||
{
|
||||
if (value == 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
return (value * 100) / maximumValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setForeground(Color color)
|
||||
{
|
||||
if (topBar != null)
|
||||
{
|
||||
topBar.setBackground(color);
|
||||
}
|
||||
super.setForeground(color);
|
||||
setBackground(color.darker());
|
||||
}
|
||||
|
||||
public void setMaximumValue(int maximumValue)
|
||||
{
|
||||
if (maximumValue < 1)
|
||||
{
|
||||
maximumValue = 1;
|
||||
}
|
||||
this.maximumValue = maximumValue;
|
||||
repaint();
|
||||
}
|
||||
|
||||
public void setValue(int value)
|
||||
{
|
||||
this.value = value;
|
||||
repaint();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paintComponent(Graphics g)
|
||||
{
|
||||
super.paintComponent(g);
|
||||
int w = getWidth();
|
||||
int h = getHeight();
|
||||
int div = (value * w) / maximumValue;
|
||||
g.setColor(getBackground());
|
||||
g.fillRect(div, 0, w, h);
|
||||
g.setColor(getForeground());
|
||||
g.fillRect(0, 0, div, h);
|
||||
}
|
||||
}
|
||||
@@ -21,7 +21,8 @@
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/package net.runelite.client.plugins.timetracking.farming;
|
||||
*/
|
||||
package net.runelite.client.plugins.timetracking.farming;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
|
||||
@@ -26,11 +26,16 @@ package net.runelite.client.plugins.timetracking.farming;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.ErrorCollector;
|
||||
import static org.hamcrest.Matchers.*;
|
||||
|
||||
public class PatchImplementationTest
|
||||
{
|
||||
@Rule
|
||||
public ErrorCollector collector = new ErrorCollector();
|
||||
|
||||
@Test
|
||||
public void testRange()
|
||||
{
|
||||
@@ -43,20 +48,20 @@ public class PatchImplementationTest
|
||||
if (s != null)
|
||||
{
|
||||
String pfx = impl.name() + "[" + i + "]";
|
||||
Assert.assertNotNull(pfx + ": null cropState", s.getCropState());
|
||||
Assert.assertNotNull(pfx + ": null produce", s.getProduce());
|
||||
Assert.assertTrue(pfx + ": " + s.getStage() + " < 0", s.getStage() >= 0);
|
||||
collector.checkThat(pfx + ": cropState", s.getCropState(), notNullValue());
|
||||
collector.checkThat(pfx + ": produce", s.getProduce(), notNullValue());
|
||||
collector.checkThat(pfx + ": negative stage", s.getStage(), greaterThanOrEqualTo(0));
|
||||
int stages = s.getProduce().getStages();
|
||||
if (s.getCropState() == CropState.HARVESTABLE)
|
||||
{
|
||||
stages = s.getProduce().getHarvestStages();
|
||||
}
|
||||
Assert.assertTrue(pfx + ": " + s.getStage() + " >= " + stages, s.getStage() < stages);
|
||||
collector.checkThat(pfx + ": out of bounds stage", s.getStage(), lessThan(stages));
|
||||
if (s.getCropState() == CropState.DEAD || s.getCropState() == CropState.DISEASED)
|
||||
{
|
||||
Assert.assertTrue(pfx + ": dead seed", s.getStage() > 0);
|
||||
collector.checkThat(pfx + ": dead seed", s.getStage(), greaterThan(0));
|
||||
}
|
||||
if (s.getCropState() == CropState.GROWING && s.getProduce() != Produce.WEEDS)
|
||||
if (s.getCropState() == CropState.GROWING && s.getProduce() != Produce.WEEDS && s.getStage() < stages)
|
||||
{
|
||||
harvestStages.computeIfAbsent(s.getProduce(), k -> new boolean[s.getProduce().getStages()])[s.getStage()] = true;
|
||||
}
|
||||
@@ -69,7 +74,7 @@ public class PatchImplementationTest
|
||||
// Alot of time the final stage is not hit, because some plants do not have a "Check-health" stage
|
||||
for (int i = 0; i < states.length - 1; i++)
|
||||
{
|
||||
Assert.assertTrue(produce.getKey().getName() + " stage " + i + " never found by varbit", states[i]);
|
||||
collector.checkThat(produce.getKey().getName() + " stage " + i + " never found by varbit", states[i], is(true));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user