@@ -34,6 +34,7 @@ import {
3434 mySoulsauce ,
3535 myTurncount ,
3636 numericModifier ,
37+ Phylum ,
3738 print ,
3839 printHtml ,
3940 restoreHp ,
@@ -60,6 +61,8 @@ import {
6061 $item ,
6162 $location ,
6263 $monster ,
64+ $monsters ,
65+ $phylum ,
6366 $skill ,
6467 $slot ,
6568 ActionSource ,
@@ -80,6 +83,7 @@ import {
8083 PropertiesManager ,
8184 property ,
8285 set ,
86+ Snapper ,
8387 SongBoom ,
8488 sum ,
8589 uneffect ,
@@ -683,3 +687,68 @@ export function printEventLog(): void {
683687 ) ;
684688 }
685689}
690+
691+ const rateCache = new Map < string , Map < Monster , number > > ( ) ;
692+
693+ export function barfEncounterRate ( options : {
694+ snapper ?: boolean ;
695+ snapperPhylum ?: Phylum ;
696+ olfact ?: Monster ;
697+ longCon ?: Monster ;
698+ motif ?: Monster ;
699+ turtle ?: Monster ;
700+ humanity ?: boolean ;
701+ } ) : Map < Monster , number > {
702+ const olfact = options . olfact ?? get ( "olfactedMonster" ) ;
703+ const longCon = options . longCon ?? get ( "longConMonster" ) ;
704+ const motif = options . motif ?? get ( "motifMonster" ) ;
705+ const turtle = options . turtle ?? get ( "_gallapagosMonster" ) ;
706+ const snapper = options . snapper ?? myFamiliar ( ) === $familiar `Red-Nosed Snapper` ;
707+ const snapperPhylum = options . snapperPhylum ?? Snapper . getTrackedPhylum ( ) ;
708+ const humanity = options . humanity ?? have ( $effect `Ew, The Humanity` ) ;
709+
710+ const cacheKey = [ olfact , longCon , motif , turtle , snapper , snapperPhylum , humanity ]
711+ . map ( ( v ) => `${ v } ` )
712+ . join ( ":" ) ;
713+
714+ const cachedValue = rateCache . get ( cacheKey ) ;
715+ if ( cachedValue ) {
716+ return cachedValue ;
717+ }
718+
719+ const zoneMonsters = $monsters `garbage tourist, angry tourist, horrible tourist family` ;
720+
721+ const copies = ( target : Monster | null , n : number ) : Monster [ ] =>
722+ n === 0 ? [ ] : [ ...zoneMonsters . filter ( ( m ) => m === target ) , ...copies ( target , n - 1 ) ] ;
723+
724+ const monsterQueue = [
725+ ...zoneMonsters ,
726+ ...copies ( olfact , 3 ) ,
727+ ...copies ( longCon , 3 ) ,
728+ ...copies ( motif , 2 ) ,
729+ ...copies ( turtle , 1 ) ,
730+ ...zoneMonsters
731+ . filter ( ( m ) => snapper && m . phylum === snapperPhylum )
732+ . flatMap ( ( m ) => copies ( m , 2 ) ) ,
733+ ...zoneMonsters
734+ . filter ( ( m ) => humanity && m . phylum === $phylum `dude` )
735+ . flatMap ( ( m ) => copies ( m , 2 ) ) ,
736+ ] ;
737+
738+ const encounterQueue = zoneMonsters . filter ( ( m ) =>
739+ $location `Barf Mountain` . combatQueue . includes ( `${ m } ` ) ,
740+ ) ;
741+
742+ const encounters = monsterQueue . flatMap ( ( m ) =>
743+ monsterQueue . map ( ( n ) =>
744+ // olfaction, longcon, and motif caus that monster to ignore queue rejection
745+ olfact === m || longCon === m || motif === m || ! encounterQueue . includes ( m ) ? m : n ,
746+ ) ,
747+ ) ;
748+
749+ const encounterRate = new Map < Monster , number > (
750+ zoneMonsters . map ( ( m ) => [ m , encounters . filter ( ( n ) => n === m ) . length / encounters . length ] ) ,
751+ ) ;
752+ rateCache . set ( cacheKey , encounterRate ) ;
753+ return encounterRate ;
754+ }
0 commit comments