Skip to content

Commit

Permalink
feat: add preferences for extracting / donating mimic eggs (#2171)
Browse files Browse the repository at this point in the history
  • Loading branch information
midgleyc committed Jan 11, 2024
1 parent 5ec7c66 commit 845e9c8
Show file tree
Hide file tree
Showing 12 changed files with 831 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/data/dailylimits.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
1
# Limiter: daily limit
# Type Item name Tracking property [Max = 1]
Cast %fn, lay an egg _mimicEggsObtained 11
Cast Acquire Rhinestones _rhinestonesAcquired
Cast Advanced Cocktailcrafting cocktailSummons
Cast Advanced Saucecrafting reagentSummons
Expand Down
2 changes: 2 additions & 0 deletions src/data/defaults.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2167,6 +2167,8 @@ user _micrometeoriteUses 0
user _milkOfMagnesiumUsed false
user _mildEvilPerpetrated 0
user _mimeArmyShotglassUsed false
user _mimicEggsDonated 0
user _mimicEggsObtained 0
user _miniMartiniDrops 0
user _missGravesVermouthDrunk false
user _missileLauncherUsed false
Expand Down
1 change: 1 addition & 0 deletions src/net/sourceforge/kolmafia/objectpool/ItemPool.java
Original file line number Diff line number Diff line change
Expand Up @@ -3722,6 +3722,7 @@ public class ItemPool {
public static final int TRICK_COIN = 11480;
public static final int LIL_SNOWBALL_FACTORY = 11485;
public static final int PRANK_CRIMBO_CARD = 11487;
public static final int MIMIC_EGG = 11542;

private ItemPool() {}

Expand Down
1 change: 1 addition & 0 deletions src/net/sourceforge/kolmafia/objectpool/SkillPool.java
Original file line number Diff line number Diff line change
Expand Up @@ -581,6 +581,7 @@ public class SkillPool {
public static final int TOAST_YOUR_ENEMY = 7487;
public static final int SURPRISINGLY_SWEET_SLASH = 7488;
public static final int SURPRISINGLY_SWEET_STAB = 7489;
public static final int LAY_AN_EGG = 7494;
public static final int GOOD_SINGING_VOICE = 11016;
public static final int BANISHING_SHOUT = 11020;
public static final int DEMAND_SANDWICH = 11021;
Expand Down
7 changes: 7 additions & 0 deletions src/net/sourceforge/kolmafia/request/FightRequest.java
Original file line number Diff line number Diff line change
Expand Up @@ -10440,6 +10440,13 @@ private static void payActionCost(final String responseText) {
skillSuccess = true;
}
break;

case SkillPool.LAY_AN_EGG:
if (responseText.contains("shudders and lays an egg") || skillSuccess) {
skillSuccess = true;
KoLCharacter.getFamiliar().addNonCombatExperience(-50);
}
break;
}

if (skillSuccess || skillRunawaySuccess || familiarSkillSuccess) {
Expand Down
26 changes: 26 additions & 0 deletions src/net/sourceforge/kolmafia/session/ChoiceControl.java
Original file line number Diff line number Diff line change
Expand Up @@ -4758,6 +4758,17 @@ else if (text.contains("takes your nifty new watch")) {
Preferences.increment("_automatedFutureManufactures", 1, 11, false);
}
break;
case 1517:
// Mimic DNA Bank
if (ChoiceManager.lastDecision == 1 && text.contains("You donate your egg to science.")) {
ResultProcessor.processItem(ItemPool.MIMIC_EGG, -1);
Preferences.increment("_mimicEggsDonated", 1, 3, false);
}
if (ChoiceManager.lastDecision == 2 && text.contains("pops into a backroom")) {
Preferences.increment("_mimicEggsObtained", 1, 11, false);
KoLCharacter.getFamiliar().addNonCombatExperience(-100);
}
break;
}
}

Expand Down Expand Up @@ -8566,6 +8577,20 @@ else if (text.contains("Order a blueberry muffin")) {
Preferences.setInteger("_automatedFutureManufactures", 11);
}
break;

case 1517:
Matcher eggsSpawned = Pattern.compile("(\\d+)/11 eggs spawned today").matcher(text);
if (eggsSpawned.find()) {
int spawned = Integer.parseInt(eggsSpawned.group(1));
Preferences.setInteger("_mimicEggsObtained", spawned);
}
Matcher eggsDonated = Pattern.compile("(\\d+)/3 donations made for the day").matcher(text);
if (eggsDonated.find()) {
int donated = Integer.parseInt(eggsDonated.group(1));
Preferences.setInteger("_mimicEggsDonated", donated);
}

break;
}
}

Expand Down Expand Up @@ -9684,6 +9709,7 @@ public static boolean canWalkFromChoice(int choice) {
case 1501: // Make a Wish
case 1509: // Adjust Jill-of-All-Trades Lighting
case 1510: // Burning Leaves
case 1517: // Mimic DNA Bank
return true;

default:
Expand Down
13 changes: 13 additions & 0 deletions test/net/sourceforge/kolmafia/request/FightRequestTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -2602,4 +2602,17 @@ public void canTrackSurprisinglySweetStab() {
}
}
}

@Test
public void canTrackMimicEggLay() {
var cleanups = new Cleanups(withProperty("_mimicEggsObtained", 0), withFight());

try (cleanups) {
String urlString = "fight.php?action=skill&whichskill=7494";
String html = html("request/test_fight_lay_mimic_egg_success.html");
FightRequest.registerRequest(true, urlString);
FightRequest.updateCombatData(null, null, html);
assertThat("_mimicEggsObtained", isSetTo(1));
}
}
}
43 changes: 43 additions & 0 deletions test/net/sourceforge/kolmafia/session/ChoiceControlTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -461,4 +461,47 @@ void updatesProtestorsWithCandyCane() {
assertThat("zeppelinProtestors", isSetTo(78));
}
}

@Nested
class MimicDnaBank {
@Test
void updatesEggsObtainedAndDonatedIfPresent() {
var cleanups =
new Cleanups(withProperty("_mimicEggsDonated", 0), withProperty("_mimicEggsObtained", 0));

try (cleanups) {
var urlString = "choice.php?forceoption=0";
var responseText = html("request/test_choice_mimic_dna_bank.html");
var request = new GenericRequest(urlString);
request.responseText = responseText;
ChoiceManager.preChoice(request);
request.processResponse();

assertThat("_mimicEggsObtained", isSetTo(6));
assertThat("_mimicEggsDonated", isSetTo(1));
}
}

@Test
void handlesDonating() {
var cleanups =
new Cleanups(
withProperty("_mimicEggsDonated", 1),
withPostChoice1(1517, 1, html("request/test_choice_mimic_dna_bank_donate.html")));
try (cleanups) {
assertThat("_mimicEggsDonated", isSetTo(2));
}
}

@Test
void handlesExtracting() {
var cleanups =
new Cleanups(
withProperty("_mimicEggsObtained", 6),
withPostChoice1(1517, 2, html("request/test_choice_mimic_dna_bank_extract.html")));
try (cleanups) {
assertThat("_mimicEggsObtained", isSetTo(7));
}
}
}
}

0 comments on commit 845e9c8

Please sign in to comment.