Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/haven/purus/DrinkWater.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import haven.*;

import java.util.regex.Pattern;

public class DrinkWater implements Runnable {

GameUI gui;
Expand Down Expand Up @@ -75,13 +77,19 @@ private void drink() {
}

private boolean canDrinkFrom(WItem item) {
Pattern liquidPattern = Pattern.compile(String.format("[0-9.]+ l of (%s)",
// String.join("|", new String[] { "Water", "Piping Hot Tea", "Tea" }), Pattern.CASE_INSENSITIVE));
String.join("|", Config.liquids), Pattern.CASE_INSENSITIVE));
ItemInfo.Contents contents = getContents(item);
if (contents != null && contents.sub != null) {
synchronized(item.item.ui) {
for(ItemInfo info : contents.sub) {
if(info instanceof ItemInfo.Name) {
ItemInfo.Name name = (ItemInfo.Name) info;
if(name.str != null && name.str.text.contains(Config.autoDrinkLiquid)) //"Water"
if (name.str != null)
if (Config.autoDrinkWhatever && liquidPattern.matcher(name.str.text).matches())
return true;
else if (name.str.text.contains(Config.autoDrinkLiquid)) //"Water"
return true;
}
}
Expand Down