@@ -13,7 +13,7 @@ import * as detailingFuncs from './modules/details/legacy';
13
13
'use strict' ;
14
14
15
15
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 ;
17
17
18
18
let mhhh_version = 0 ;
19
19
let hunter_id_hash = '0' ;
@@ -110,6 +110,7 @@ import * as detailingFuncs from './modules/details/legacy';
110
110
map_helper_url = base_domain_url + "/maphelper.php" ;
111
111
rh_intake_url = base_domain_url + "/rh_intake.php" ;
112
112
rejection_intake_url = base_domain_url + "/rejection_intake.php" ;
113
+ scav_helper_url = base_domain_url + "/scavhelper.php" ;
113
114
114
115
await createHunterIdHash ( ) ;
115
116
}
@@ -192,61 +193,80 @@ import * as detailingFuncs from './modules/details/legacy';
192
193
let glue = '' ;
193
194
let method = '' ;
194
195
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.' ) ;
203
+ return ;
204
+ }
205
+
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.' ) ;
206
210
return ;
207
211
}
208
212
209
213
const payload = {
210
- map_id : user . quests . QuestRelicHunter . default_map_id ,
214
+ map_id : treasure_map [ 0 ] . map_id ,
211
215
action : "map_info" ,
212
216
uh : user . unique_hash ,
213
217
last_read_journal_entry_id : lastReadJournalEntryId ,
214
218
} ;
219
+
215
220
$ . post ( 'https://www.mousehuntgame.com/managers/ajax/users/treasuremap.php' , payload , null , 'json' )
216
221
. done ( data => {
217
222
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 ;
223
+
224
+ if ( solver === 'mhmh' ) {
225
+ url = data . treasure_map . is_scavenger_hunt ? scav_helper_url : map_helper_url ;
226
+ glue = '\n' ;
227
+ method = 'POST' ;
228
+ input_name = data . treasure_map . is_scavenger_hunt ? 'items' : 'mice' ;
221
229
}
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 ;
230
+
231
+ if ( solver === 'ryonn' ) {
232
+ url = 'http://dbgames.info/mousehunt/tavern' ;
233
+ glue = ';' ;
234
+ method = 'GET' ;
235
+ input_name = 'q' ;
225
236
}
226
- const mice = getMapMice ( data , true ) ;
237
+
238
+ const goals = getMapGoals ( data , true ) ;
239
+
227
240
$ ( '<form method="' + method + '" action="' + url + '" target="_blank">' +
228
- '<input type="hidden" name="' + input_name + '" value="' + mice . join ( glue ) +
241
+ '<input type="hidden" name="' + input_name + '" value="' + goals . join ( glue ) +
229
242
'"></form>' ) . appendTo ( 'body' ) . submit ( ) . remove ( ) ;
230
243
}
231
244
} ) ;
232
245
}
233
246
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 ;
247
+ /**
248
+ * Extract goals from map (can be scav or treasure)
249
+ * @param {Object } data Data response from managers/ajax/users/treasuremap.php
250
+ * @param {boolean } remaining_only Boolean, if true, to filter out completed goals
251
+ * @returns {string[] } Goal names. If on treasure map, it will be mice names and if
252
+ * on scavenger it will be item names.
253
+ */
254
+ function getMapGoals ( data , remaining_only ) {
255
+ const goalCategory = data . treasure_map . is_scavenger_hunt ? 'item' : 'mouse' ;
256
+ const goals = { } ;
257
+ $ . each ( data . treasure_map . goals [ goalCategory ] , ( key , goal ) => {
258
+ goals [ goal . unique_id ] = goal . name ;
239
259
} ) ;
240
260
241
- if ( uncaught_only ) {
261
+ if ( remaining_only ) {
242
262
$ . each ( data . treasure_map . hunters , ( key , hunter ) => {
243
- $ . each ( hunter . completed_goal_ids . mouse , ( key , mouse_id ) => {
244
- delete mice [ mouse_id ] ;
263
+ $ . each ( hunter . completed_goal_ids [ goalCategory ] , ( key , goal_id ) => {
264
+ delete goals [ goal_id ] ;
245
265
} ) ;
246
266
} ) ;
247
267
}
248
268
249
- return Object . values ( mice ) ;
269
+ return Object . values ( goals ) ;
250
270
}
251
271
252
272
/**
@@ -496,7 +516,7 @@ import * as detailingFuncs from './modules/details/legacy';
496
516
return ;
497
517
}
498
518
const map = {
499
- mice : getMapMice ( resp ) ,
519
+ mice : getMapGoals ( resp ) ,
500
520
id : map_id ,
501
521
name : name . replace ( / t r e a s u r e / i, '' )
502
522
. replace ( / r a r e / i, '' )
0 commit comments