Skip to content

Commit

Permalink
Merge branch 'main' into taketwo
Browse files Browse the repository at this point in the history
  • Loading branch information
jaadams5 committed Feb 26, 2023
2 parents 6de703a + e863c92 commit 26b6dca
Show file tree
Hide file tree
Showing 8 changed files with 112 additions and 18 deletions.
1 change: 1 addition & 0 deletions src/data/defaults.txt
Expand Up @@ -2122,6 +2122,7 @@ user _setOfJacksUsed false
user _sewingKitUsed false
user _sexChanged false
user _shadowBricksUsed 0
user _shadowRiftCombats 0
user _shatteringPunchUsed 0
user _shortOrderCookCharge 0
user _shrubCharge 0
Expand Down
24 changes: 12 additions & 12 deletions src/data/monsters.txt
Expand Up @@ -582,19 +582,19 @@ senile lihc 192 lich.gif Atk: 56 Def: 51 HP: 50 Init: 50 P: undead E: spooky Art
serialbus 982 serialbus.gif Atk: 60 Def: 54 HP: 60 Init: 50 Meat: 30 P: demon E: hot Article: a bus pass (25)
Servant of Grodstank 799 grodseal.gif NOCOPY FREE Atk: 175 Def: 157 HP: 200 Init: -10000 P: horror EA: stench Article: a fustulent seal grulch (35) infernal toilet brush (5)
sewer snake with a sewer snake in it 1752 sewersnake.gif Atk: 2 Def: 1 HP: 2 Init: -10000 P: beast SNAKE E: stench Article: a carton of snake milk (100) carton of snake milk (30) sewer snake (30)
shadow bat 2271 shadowbat.gif Atk: 100 Def: 100 HP: 100 Init: 300 P: horror Phys: 100 Elem: [min(pref(_shadowRiftCombats),90)] EA: cold EA: spooky Article: a shadow sausage (20)
shadow cow 2272 shadowcow.gif Atk: 100 Def: 100 HP: 100 Init: 200 P: horror Phys: 100 Elem: [min(pref(_shadowRiftCombats),90)] EA: cold EA: spooky Article: a shadow skin (15)
shadow devil 2273 shadowdevil.gif Atk: 100 Def: 100 HP: 100 Init: 400 P: horror Phys: 100 Elem: [min(pref(_shadowRiftCombats),90)] EA: cold EA: spooky Article: a shadow flame (25)
shadow guy 2274 shadowguy.gif Atk: 100 Def: 100 HP: 100 Init: 100 P: horror Phys: 100 Elem: [min(pref(_shadowRiftCombats),90)] EA: cold EA: spooky Article: a shadow bread (20)
shadow hexagon 2275 shadowhexagon.gif Atk: 100 Def: 100 HP: 200 Init: -10000 P: horror Phys: 100 Elem: [min(pref(_shadowRiftCombats),90)] EA: cold EA: spooky Article: a shadow ice (20)
shadow of Black Bubbles 798 shadowseal.gif NOCOPY FREE Atk: 175 Def: 157 HP: 200 Init: -10000 P: horror EA: spooky Article: a scrap of shadow (35) shadowy seal eye (5)
shadow bat 2271 shadowbat.gif Atk: 100 Def: 100 HP: 100 Init: 300 P: horror EA: cold EA: spooky Article: a shadow sausage (20)
shadow cow 2272 shadowcow.gif Atk: 100 Def: 100 HP: 100 Init: 200 P: horror EA: cold EA: spooky Article: a shadow skin (15)
shadow devil 2273 shadowdevil.gif Atk: 100 Def: 100 HP: 100 Init: 400 P: horror EA: cold EA: spooky Article: a shadow flame (25)
shadow guy 2274 shadowguy.gif Atk: 100 Def: 100 HP: 100 Init: 100 P: horror EA: cold EA: spooky Article: a shadow bread (20)
shadow hexagon 2275 shadowhexagon.gif Atk: 100 Def: 100 HP: 200 Init: -10000 P: horror EA: cold EA: spooky Article: a shadow ice (20)
shadow orb 2276 shadoworb.gif Atk: 100 Def: 100 HP: 100 Init: 100 P: horror EA: cold EA: spooky Article: a shadow fluid (20)
shadow prism 2277 shadowprism.gif Atk: 100 Def: 100 HP: 100 Init: -10000 P: horror EA: cold EA: hot EA: sleaze EA: spooky EA: stench Article: a shadow glass (15)
shadow slab 2278 shadowslab.gif Atk: 100 Def: 100 HP: 200 Init: 200 P: horror EA: cold EA: spooky Article: a shadow brick (10)
shadow snake 2279 shadowsnake.gif Atk: 100 Def: 100 HP: 100 Init: 300 P: horror EA: cold EA: spooky Article: a shadow sinew (15)
shadow spider 2280 shadowspider.gif Atk: 100 Def: 100 HP: 100 Init: 300 P: horror EA: cold EA: spooky Article: a shadow venom (20)
shadow stalk 2281 shadowstalk.gif Atk: 100 Def: 100 HP: 100 Init: -10000 P: horror EA: cold EA: spooky Article: a shadow nectar (20)
shadow tree 2282 shadowtree.gif Atk: 100 Def: 100 HP: 200 Init: -10000 P: horror EA: cold EA: spooky Article: a shadow stick (10)
shadow orb 2276 shadoworb.gif Atk: 100 Def: 100 HP: 100 Init: 100 P: horror Phys: 100 Elem: [min(pref(_shadowRiftCombats),90)] EA: cold EA: spooky Article: a shadow fluid (20)
shadow prism 2277 shadowprism.gif Atk: 100 Def: 100 HP: 100 Init: -10000 P: horror Phys: 100 Elem: [min(pref(_shadowRiftCombats),90)] EA: cold EA: hot EA: sleaze EA: spooky EA: stench Article: a shadow glass (15)
shadow slab 2278 shadowslab.gif Atk: 100 Def: 100 HP: 200 Init: 200 P: horror Phys: 100 Elem: [min(pref(_shadowRiftCombats),90)] EA: cold EA: spooky Article: a shadow brick (10)
shadow snake 2279 shadowsnake.gif Atk: 100 Def: 100 HP: 100 Init: 300 P: horror Phys: 100 Elem: [min(pref(_shadowRiftCombats),90)] EA: cold EA: spooky Article: a shadow sinew (15)
shadow spider 2280 shadowspider.gif Atk: 100 Def: 100 HP: 100 Init: 300 P: horror Phys: 100 Elem: [min(pref(_shadowRiftCombats),90)] EA: cold EA: spooky Article: a shadow venom (20)
shadow stalk 2281 shadowstalk.gif Atk: 100 Def: 100 HP: 100 Init: -10000 P: horror Phys: 100 Elem: [min(pref(_shadowRiftCombats),90)] EA: cold EA: spooky Article: a shadow nectar (20)
shadow tree 2282 shadowtree.gif Atk: 100 Def: 100 HP: 200 Init: -10000 P: horror Phys: 100 Elem: [min(pref(_shadowRiftCombats),90)] EA: cold EA: spooky Article: a shadow stick (10)
shady pirate 107 pirate1.gif Atk: 67 Def: 60 HP: 57 Init: 75 Meat: 30 P: pirate EA: sleaze Article: a safarrri hat (10)
shaky clown 285 clown.gif Atk: 19 Def: 17 HP: 16 Init: 80 Meat: 20 P: horror E: sleaze Article: a bloody clown pants (15) big red clown nose (15) bottle of gin (10) bottle of rum (10) bottle of tequila (10) bottle of whiskey (10) bottle of vodka (10) boxed wine (10) clown skin (10) polka-dot bow tie (p5)
sheet ghost 1555 sheetghost.gif Atk: 79 Def: 81 HP: 75 Init: 50 P: undead GHOST Article: a ghost key (15) sheet cake (15) ghost toga (5)
Expand Down
23 changes: 19 additions & 4 deletions src/net/sourceforge/kolmafia/KoLAdventure.java
Expand Up @@ -263,6 +263,12 @@ public boolean hasSnarfblat() {
}

public int getSnarfblat() {
if (this.adventureId.equals("shadow_rift")) {
// Going through a Shadow Rift redirects to
// adventure.php?snarfblat=567
return AdventurePool.SHADOW_RIFT;
}

if (!hasSnarfblat()) {
return -1;
}
Expand Down Expand Up @@ -3322,10 +3328,19 @@ public static KoLAdventure lastVisitedLocation() {

public static int lastAdventureId() {
KoLAdventure location = KoLAdventure.lastVisitedLocation;

return location == null || !StringUtilities.isNumeric(location.adventureId)
? 0
: StringUtilities.parseInt(location.adventureId);
if (location == null) {
return 0;
}
// adventure.php locations
if (location.adventureNumber != -1) {
return location.adventureNumber;
}
// Mines, for example
if (StringUtilities.isNumeric(location.adventureId)) {
return StringUtilities.parseInt(location.adventureId);
}
// Anything else
return 0;
}

public static String lastAdventureIdString() {
Expand Down
3 changes: 2 additions & 1 deletion src/net/sourceforge/kolmafia/KoLmafia.java
Expand Up @@ -809,7 +809,8 @@ private static void refreshSessionData() {
// We did this earlier before loading charsheet.
// Do it again so we can catch passive skills
ApiRequest.updateStatus();
} else if (KoLCharacter.getPath().canUseFamiliars() && !KoLCharacter.inPokefam()) {
} else if (!KoLCharacter.inPokefam()) {
// In an avatar path that can't use familiars, owned familiars still affect things
// Retrieve the Terrarium
RequestThread.postRequest(new FamiliarRequest());
}
Expand Down
11 changes: 10 additions & 1 deletion src/net/sourceforge/kolmafia/request/FamiliarRequest.java
Expand Up @@ -362,8 +362,17 @@ public void processResults() {
// Jarlsberg didn't trust any companion that he didn't summon himself.
// Familiars weren't cool enough for Pete.
// Ed already has more than enough servants.
if (!KoLCharacter.getPath().canUseFamiliars()) {
// even if we can't use familiars, we still want to know what familiars we own
if (changeTo == null) {
FamiliarData.registerFamiliarData(this.responseText);
KoLmafia.updateDisplay("Familiar data retrieved.");
}
return;
}

// In Quantum Terrarium, familiar sets you.
if (!KoLCharacter.getPath().canUseFamiliars() || KoLCharacter.inQuantum()) {
if (KoLCharacter.inQuantum()) {
return;
}

Expand Down
3 changes: 3 additions & 0 deletions src/net/sourceforge/kolmafia/request/FightRequest.java
Expand Up @@ -2160,6 +2160,9 @@ public static final void updateCombatData(
}
case AdventurePool.WARBEAR_FORTRESS_LEVEL_THREE -> ResultProcessor.processItem(
ItemPool.WARBEAR_BADGE, -1);
case AdventurePool.SHADOW_RIFT -> {
Preferences.increment("_shadowRiftCombats");
}
}

// Wearing any piece of papier equipment really messes up the results
Expand Down
36 changes: 36 additions & 0 deletions test/net/sourceforge/kolmafia/request/FightRequestTest.java
Expand Up @@ -9,6 +9,7 @@
import static internal.helpers.Player.withFamiliarInTerrarium;
import static internal.helpers.Player.withFight;
import static internal.helpers.Player.withHippyStoneBroken;
import static internal.helpers.Player.withHttpClientBuilder;
import static internal.helpers.Player.withItem;
import static internal.helpers.Player.withLastLocation;
import static internal.helpers.Player.withNextMonster;
Expand All @@ -33,6 +34,9 @@

import internal.helpers.Cleanups;
import internal.helpers.RequestLoggerOutput;
import internal.network.FakeHttpClientBuilder;
import java.util.List;
import java.util.Map;
import java.util.Set;
import net.sourceforge.kolmafia.AscensionPath.Path;
import net.sourceforge.kolmafia.KoLAdventure;
Expand All @@ -43,6 +47,7 @@
import net.sourceforge.kolmafia.combat.MonsterStatusTracker;
import net.sourceforge.kolmafia.equipment.Slot;
import net.sourceforge.kolmafia.modifiers.DoubleModifier;
import net.sourceforge.kolmafia.objectpool.AdventurePool;
import net.sourceforge.kolmafia.objectpool.EffectPool;
import net.sourceforge.kolmafia.objectpool.FamiliarPool;
import net.sourceforge.kolmafia.objectpool.ItemPool;
Expand Down Expand Up @@ -1950,4 +1955,35 @@ public void sloshingSetsSpitToFull() {
}
}
}

@Nested
class ShadowRift {
@Test
void canTrackShadowRiftCombats() {
var builder = new FakeHttpClientBuilder();
var client = builder.client;
var cleanups =
new Cleanups(
withHttpClientBuilder(builder),
withProperty("_shadowRiftCombats", 0),
withProperty("shadowRiftIngress", ""),
withLastLocation("None"));
try (cleanups) {
client.addResponse(
302,
Map.of("location", List.of("adventure.php?snarfblat=" + AdventurePool.SHADOW_RIFT)),
"");
client.addResponse(
302, Map.of("location", List.of("fight.php?ireallymeanit=1677340903")), "");
client.addResponse(200, html("request/test_shadow_rift_fight.html"));
client.addResponse(200, ""); // api.php

var request = new GenericRequest("place.php?whichplace=hiddencity&action=hc_shadowrift");
request.run();
assertThat("shadowRiftIngress", isSetTo("hiddencity"));
assertThat("lastAdventure", isSetTo("Shadow Rift (The Hidden City)"));
assertThat("_shadowRiftCombats", isSetTo(1));
}
}
}
}
29 changes: 29 additions & 0 deletions test/root/request/test_shadow_rift_fight.html
@@ -0,0 +1,29 @@
<html><head>
<script language=Javascript>
<!--
if (parent.frames.length == 0) location.href="game.php";
top.charpane.location.href="charpane.php";
//-->
</script>
<script language=Javascript src="https://d2uyhvukfffg5a.cloudfront.net/scripts/keybinds.min.2.js"></script>
<script language=Javascript src="https://d2uyhvukfffg5a.cloudfront.net/scripts/window.20111231.js"></script>
<script language=Javascript src="https://d2uyhvukfffg5a.cloudfront.net/scripts/jquery-1.3.1.min.js"></script>
<script language="javascript" src="https://d2uyhvukfffg5a.cloudfront.net/scripts/core.js"></script><script src="https://d2uyhvukfffg5a.cloudfront.net/scripts/fight.js"></script>
<script>
var onturn = 1;

</script> <link rel="stylesheet" type="text/css" href="https://d2uyhvukfffg5a.cloudfront.net/styles.20230117d.css">
<style type='text/css'>
.faded {
zoom: 1;
filter: alpha(opacity=35);
opacity: 0.35;
-khtml-opacity: 0.35;
-moz-opacity: 0.35;
}
</style>

</head>

<body>
<center><table width=95% cellspacing=0 cellpadding=0><tr><td style="color: white;" align=center bgcolor=blue><b>Combat!</b></td></tr><tr><td style="padding: 5px; border: 1px solid blue;"><center><table><tr><td><center><table><tr><td><div id=monsterpic style='position: relative;'> <img id='monpic' src="https://d2uyhvukfffg5a.cloudfront.net/adventureimages/shadowstalk.gif" width=100 height=100></div></td><td valign=center>You're fighting <span id='monname'>a shadow stalk</span></td><!-- MONSTERID: 2281 --><td width=30></td><td><table><tr><td width=30><img src=https://d2uyhvukfffg5a.cloudfront.net/itemimages/nicesword.gif width=30 height=30 alt="Enemy's Attack Power" title="Enemy's Attack Power"></td><td width=50 valign=center align=left><b><font size=+2>115</font></b></td><td><img src=https://d2uyhvukfffg5a.cloudfront.net/itemimages/skull.gif alt="This monster is a Horror" title="This monster is a Horror"></td></tr><tr><td width=30><img src=https://d2uyhvukfffg5a.cloudfront.net/itemimages/whiteshield.gif width=30 height=30 alt="Enemy's Defense" title="Enemy's Defense"></td><td width=50 valign=center align=left><b><font size=+2>118</font></b></td><td><img src=https://d2uyhvukfffg5a.cloudfront.net/itemimages/circle.gif width=30 height=30 alt="This monster has no particular elemental alignment." title="This monster has no particular elemental alignment."></td></tr><tr><td width=30><img src=https://d2uyhvukfffg5a.cloudfront.net/itemimages/hp.gif width=30 height=30 alt="Enemy's Hit Points" title="Enemy's Hit Points"></td><td width=50 valign=center align=left><b><font size=+2>118</font></b></td><td><img src=https://d2uyhvukfffg5a.cloudfront.net/itemimages/snail.gif alt="Never wins initiative" title="Never wins initiative"></td></tr></table></td></tr></table><br><script type="text/javascript">var monsterstats = {"hp":"118","def":"118","off":"115"};</script></center><blockquote>You shudder as you cross through the rift.<P>The emptiness parts to reveal a threat...<p>Some kind of void tentacle, or some kind of negatie-space plant? You'd probably know, if you had paid more attention in cosmic horror school.</blockquote><center><p><p>You get the jump on it.<p><center><table><tr><td align=center valign=center><img src="https://d2uyhvukfffg5a.cloudfront.net/itemimages/jparka7.gif" width=30 height=30></td><td valign=center>Your opponent seems to be thinking twice about attacking you, possibly because you are disguised as a monstrous thunder lizard!</td></tr></table></center><p><center><table><a name="end"><form name=attack action=fight.php method=post><input type=hidden name=action value="attack"><tr><td align=center><input id='tack' picurl=junecleaver onclick="return killforms(this)" class=button type=submit value="Attack with your June cleaver"></td></tr></form></a><form name=useitem action=fight.php method=post><input type=hidden name=action value="useitem"><tr><td align=left><select name=whichitem><option value=0>(select an item)</option><option picurl=beehive value=7969>beehive (1)</option><option picurl=matchbook value=6683>book of matches (1)</option><option picurl=bubblebath value=1965>bottle of Monsieur Bubble (2)</option><option picurl=bball value=6696>bowling ball (5)</option><option picurl=butterfly value=615>chaos butterfly (2)</option><option picurl=chimes value=2354>communications windchimes (1)</option><option picurl=cosmicball2 value=10891>cosmic bowling ball (1)</option><option picurl=camera value=7266>disposable instant camera (1)</option><option picurl=balm value=232>Doc Galaktik's Ailment Ointment (1)</option><option picurl=sitgrub value=11124>extra-grubby grub (1)</option><option picurl=softener value=7364>fabric softener (5)</option><option picurl=potion4 value=2091>fancy bath salts (1)</option><option picurl=cruft value=2714>floorboard cruft (1)</option><option picurl=hairwad value=1922>gob of wet hair (4)</option><option picurl=rggravel value=11101>groveling gravel (1)</option><option picurl=inkwell value=1958>inkwell (2)</option><option picurl=firecrack value=747>Knob Goblin firecracker (4)</option><option picurl=leftovers value=1777>leftovers of indeterminate origin (2)</option><option picurl=pencilstub value=6418>pencil stub (1)</option><option picurl=torpedo value=630>photoprotoneutron torpedo (5)</option><option picurl=hole value=613>plot hole (1)</option><option picurl=potion1 value=610>procrastination potion (4)</option><option picurl=canlid value=559>razor-sharp can lid (1)</option><option picurl=tatpaper value=1959>tattered scrap of paper (1)</option><option picurl=potion5 value=469>wussiness potion (2)</option><option picurl=fwrocket3 value=10765>yellow rocket (1)</option><option picurl=yeinsult value=6278>Ye Olde Medieval Insult (1)</option></select> <input class=button type=submit onclick="return killforms(this);" value="Use Item"></td></tr></form><form name=skill action=fight.php method=post><input type=hidden name=action value="skill"><tr><td align=center><select name=whichskill><option value='none'>(select a skill)</option><option value="15" picurl="commacha" >CLEESH (10 Mana Points)</option><option value="7421" picurl="waterglass" >Sweat Sip (5 sweat)</option><option value="7417" picurl="sprayup" >Sweat Spray (3 sweat)</option><option value="7416" picurl="waves" >Sweat Flood (5 sweat)</option><option value="7415" picurl="teardrop" >Sweat Flick (1 sweat)</option><option value="7407" picurl="bowlup" >Bowl Straight Up (0 Mana Points)</option><option value="7406" picurl="bowlside" >Bowl Sideways (0 Mana Points)</option><option value="7405" picurl="bowlcurve" >Bowl a Curveball (0 Mana Points)</option><option value="7404" picurl="bowlback" >Bowl Backwards (0 Mana Points)</option><option value="7381" picurl="backcamera" >Back-Up to your Last Enemy (11 uses today)</option><option value="7367" picurl="emochip5" >Feel Superior (0 Mana Points)</option><option value="7365" picurl="emochip6" >Feel Nostalgic (0 Mana Points)</option><option value="7362" picurl="emochip12" >Feel Envy (0 Mana Points)</option><option value="7359" picurl="emochip8" >Feel Hatred (0 Mana Points)</option><option value="7357" picurl="emochip9" >Feel Pride (0 Mana Points)</option><option value="28000" picurl="clobber" >Tackle (0 Mana Points)</option><option value="28013" picurl="tennisball" >Ball Throw (5 Mana Points)</option><option value="28014" picurl="headache" >Noogie (7 Mana Points)</option><option value="28015" picurl="firefoot" >Hot Foot (5 Mana Points)</option><option value="28016" picurl="wind" >Second Wind (10 Mana Points)</option><option value="28017" picurl="krakfist" >Stop Hitting Yourself (7 Mana Points)</option><option value="28019" picurl="explosion" >Free-For-All (50 Mana Points)</option><option value="28021" picurl="football2" >Punt (30 Mana Points)</option></select> <input class=button type=submit onclick="return killforms(this);" value="Use Skill"></td></tr></form><form name=macro action=fight.php method=post><input type=hidden name=action value="macro"><input type="hidden" name="macrotext" value=""><tr><td align=center><select name=whichmacro><option value='0'>(select a macro)</option><option value="192478" picurl="" >Extract Jelly</option></select> <input class=button type=submit onclick="return killforms(this);" value="Execute Macro"></td></tr></form><form name=runaway action=fight.php method=post><input type=hidden name=action value="runaway"><tr><td align=center><input class=button onclick="return killforms(this);" type=submit value="Run Away"></td></tr></form></table></center></td></tr></table></center></td></tr><tr><td height=4></td></tr></table></center></body></html>

0 comments on commit 26b6dca

Please sign in to comment.