@@ -13,7 +13,7 @@ import * as detailingFuncs from './modules/details/legacy';
1313 'use strict' ;
1414
1515 let base_domain_url = "https://www.mhct.win" ;
16- let main_intake_url , map_intake_url , convertible_intake_url , map_helper_url , rh_intake_url , rejection_intake_url ;
16+ let main_intake_url , map_intake_url , convertible_intake_url , map_helper_url , rh_intake_url , rejection_intake_url , scav_helper_url ;
1717
1818 let mhhh_version = 0 ;
1919 let hunter_id_hash = '0' ;
@@ -110,6 +110,7 @@ import * as detailingFuncs from './modules/details/legacy';
110110 map_helper_url = base_domain_url + "/maphelper.php" ;
111111 rh_intake_url = base_domain_url + "/rh_intake.php" ;
112112 rejection_intake_url = base_domain_url + "/rejection_intake.php" ;
113+ scav_helper_url = base_domain_url + "/scavhelper.php" ;
113114
114115 await createHunterIdHash ( ) ;
115116 }
@@ -192,61 +193,86 @@ import * as detailingFuncs from './modules/details/legacy';
192193 let glue = '' ;
193194 let method = '' ;
194195 let input_name = '' ;
195- if ( solver === 'mhmh' ) {
196- url = map_helper_url ;
197- glue = '\n' ;
198- method = 'POST' ;
199- input_name = 'mice' ;
200- } else if ( solver === 'ryonn' ) {
201- url = 'http://dbgames.info/mousehunt/tavern' ;
202- glue = ';' ;
203- method = 'GET' ;
204- input_name = 'q' ;
205- } else {
196+
197+ if ( ! [ 'mhmh' , 'ryonn' ] . includes ( solver ) ) return ;
198+
199+ let treasure_map = user . quests . QuestRelicHunter . maps ;
200+
201+ if ( ! treasure_map . length ) {
202+ alert ( 'Please make sure you are logged in into MH and are currently member of a treasure map.' ) ;
206203 return ;
207204 }
208205
209- const payload = {
210- map_id : user . quests . QuestRelicHunter . default_map_id ,
211- action : "map_info" ,
212- uh : user . unique_hash ,
213- last_read_journal_entry_id : lastReadJournalEntryId ,
214- } ;
215- $ . post ( 'https://www.mousehuntgame.com/managers/ajax/users/treasuremap.php' , payload , null , 'json' )
216- . done ( data => {
217- if ( data ) {
218- if ( ! data . treasure_map || data . treasure_map . view_state === "noMap" ) {
219- alert ( 'Please make sure you are logged in into MH and are currently member of a treasure map.' ) ;
220- return ;
221- }
222- if ( ! [ 'treasure' , 'event' ] . includes ( data . treasure_map . map_class ) ) {
223- alert ( 'This seems to be a new kind of map and not yet supported.' ) ;
224- return ;
206+ treasure_map = treasure_map . filter ( map => [ 'treasure' , 'event' ] . includes ( map . map_class ) ) ;
207+
208+ if ( ! treasure_map . length ) {
209+ alert ( 'This seems to be a new kind of map and not yet supported.' ) ;
210+ return ;
211+ }
212+
213+
214+ for ( const i in treasure_map ) {
215+
216+ const payload = {
217+ map_id : treasure_map [ i ] . map_id ,
218+ action : "map_info" ,
219+ uh : user . unique_hash ,
220+ last_read_journal_entry_id : lastReadJournalEntryId ,
221+ } ;
222+
223+ $ . post ( 'https://www.mousehuntgame.com/managers/ajax/users/treasuremap.php' , payload , null , 'json' )
224+ . done ( data => {
225+ if ( data ) {
226+
227+ if ( solver === 'mhmh' ) {
228+ url = data . treasure_map . is_scavenger_hunt ? scav_helper_url : map_helper_url ;
229+ glue = '\n' ;
230+ method = 'POST' ;
231+ input_name = data . treasure_map . is_scavenger_hunt ? 'items' : 'mice' ;
232+ }
233+
234+ if ( solver === 'ryonn' ) {
235+ url = 'http://dbgames.info/mousehunt/tavern' ;
236+ glue = ';' ;
237+ method = 'GET' ;
238+ input_name = 'q' ;
239+ }
240+
241+ const goals = getMapGoals ( data , true ) ;
242+
243+ $ ( '<form method="' + method + '" action="' + url + '" target="_blank">' +
244+ '<input type="hidden" name="' + input_name + '" value="' + goals . join ( glue ) +
245+ '"></form>' ) . appendTo ( 'body' ) . submit ( ) . remove ( ) ;
225246 }
226- const mice = getMapMice ( data , true ) ;
227- $ ( '<form method="' + method + '" action="' + url + '" target="_blank">' +
228- '<input type="hidden" name="' + input_name + '" value="' + mice . join ( glue ) +
229- '"></form>' ) . appendTo ( 'body' ) . submit ( ) . remove ( ) ;
230- }
231- } ) ;
247+ } ) ;
248+ }
249+
250+
232251 }
233252
234- // Extract map mice from a map
235- function getMapMice ( data , uncaught_only ) {
236- const mice = { } ;
237- $ . each ( data . treasure_map . goals . mouse , ( key , mouse ) => {
238- mice [ mouse . unique_id ] = mouse . name ;
253+ /**
254+ * Extract goals from map (can be scav or treasure)
255+ * @param {Object } data Data response from managers/ajax/users/treasuremap.php
256+ * @param {boolean } remaining_only Boolean, if true, to filter out completed goals
257+ * @returns {string[] } Goal names. If on treasure map, it will be mice names and if
258+ * on scavenger it will be item names.
259+ */
260+ function getMapGoals ( data , remaining_only ) {
261+ const goalCategory = data . treasure_map . is_scavenger_hunt ? 'item' : 'mouse' ;
262+ const goals = { } ;
263+ $ . each ( data . treasure_map . goals [ goalCategory ] , ( key , goal ) => {
264+ goals [ goal . unique_id ] = goal . name ;
239265 } ) ;
240266
241- if ( uncaught_only ) {
267+ if ( remaining_only ) {
242268 $ . each ( data . treasure_map . hunters , ( key , hunter ) => {
243- $ . each ( hunter . completed_goal_ids . mouse , ( key , mouse_id ) => {
244- delete mice [ mouse_id ] ;
269+ $ . each ( hunter . completed_goal_ids [ goalCategory ] , ( key , goal_id ) => {
270+ delete goals [ goal_id ] ;
245271 } ) ;
246272 } ) ;
247273 }
248274
249- return Object . values ( mice ) ;
275+ return Object . values ( goals ) ;
250276 }
251277
252278 /**
@@ -496,7 +522,7 @@ import * as detailingFuncs from './modules/details/legacy';
496522 return ;
497523 }
498524 const map = {
499- mice : getMapMice ( resp ) ,
525+ mice : getMapGoals ( resp ) ,
500526 id : map_id ,
501527 name : name . replace ( / t r e a s u r e / i, '' )
502528 . replace ( / r a r e / i, '' )
0 commit comments