11// title case helpers
22const TITLE_CASE_MINORS = new Set ( [
33 'a' , 'an' , 'and' , 'as' , 'at' , 'but' , 'by' , 'en' , 'for' , 'from' , 'how' , 'if' , 'in' , "n'" , "'n'" ,
4- 'neither' , 'nor' , 'of' , 'on' , 'only' , 'onto' , 'out' , 'or' , 'over' , 'per' , 'so' , 'than' , 'that' ,
4+ 'neither' , 'nor' , 'of' , 'on' , 'only' , 'onto' , 'out' , 'or' , 'over' , 'per' , 'so' , 'than' ,
55 'the' , 'to' , 'until' , 'up' , 'upon' , 'v' , 'v.' , 'versus' , 'vs' , 'vs.' , 'via' , 'when' ,
66 'with' , 'without' , 'yet' ,
77] ) ;
@@ -394,8 +394,21 @@ function generate_code_note_stats(notes)
394394 }
395395
396396 stats . notes_count = notes . length ;
397- let all_addresses = current . set . getAchievements ( ) . reduce ( ( a , e ) => a . concat ( e . logic . getAddresses ( ) ) , [ ] ) ;
398- let used_notes = notes . filter ( x => all_addresses . some ( y => x . contains ( y ) ) ) ;
397+ let asset_addresses = [ ...current . set . getAchievements ( ) . map ( e => e . logic . getAddresses ( ) ) ,
398+ ...current . set . getLeaderboards ( ) . map ( e => e . components ) . flatMap ( cmps => Object . values ( cmps ) ) . map ( cmp => cmp . getAddresses ( ) )
399+ ] ;
400+
401+ if ( current . rp ) {
402+ const display_cond_addrs = current . rp . display . map ( display => display . condition ) . filter ( cond => cond !== null ) . flatMap ( cond => cond . getAddresses ( ) ) ;
403+ const lookup_addrs = current . rp . display . flatMap ( display => display . lookups ) . flatMap ( lookup => lookup . calc . getAddresses ( ) ) ;
404+ asset_addresses . push ( [ ...display_cond_addrs , ...lookup_addrs ] ) ;
405+ }
406+
407+ notes . forEach ( note => {
408+ note . assetCount = asset_addresses . filter ( addrs => addrs . includes ( note . addr ) ) . length ;
409+ } ) ;
410+
411+ let used_notes = notes . filter ( x => x . assetCount > 0 ) ;
399412
400413 stats . notes_used = used_notes . length ;
401414 stats . notes_unused = stats . notes_count - stats . notes_used ;
@@ -684,11 +697,7 @@ function* check_pointers(logic)
684697 if ( ! note ) continue ;
685698
686699 if ( note . isProbablePointer ( ) && req . isComparisonOperator ( ) && req . rhs . type == ReqType . VALUE && req . rhs . value != 0 )
687- yield new Issue ( Feedback . POINTER_COMPARISON , req ,
688- < ul >
689- < li > Accessing < code > { toDisplayHex ( operand . value ) } </ code > as < code > { operand . size . name } </ code > </ li >
690- < li > Matching code note at < code > { toDisplayHex ( note . addr ) } </ code > is marked as < code > { note . type . name } </ code > </ li >
691- </ ul > ) ;
700+ yield new Issue ( Feedback . POINTER_COMPARISON , req ) ; // TODO: provide better feedback
692701 }
693702 }
694703}
@@ -957,7 +966,7 @@ function* check_title_case(asset)
957966 < li > < a href = { `https://titlecaseconverter.com/?style=CMOS&showExplanations=1&keepAllCaps=1&multiLine=1&highlightChanges=1&convertOnPaste=1&straightQuotes=1&title=${ q } ` } > titlecaseconverter.com</ a > </ li >
958967 < li > < a href = { `https://capitalizemytitle.com/style/Chicago/?title=${ q } ` } > capitalizemytitle.com</ a > </ li >
959968 </ ul >
960- < li > < em > Warning: automated suggestions don't handle hyphenated or otherwise-separated words gracefully.</ em > </ li >
969+ < li > < em > Warning: automated suggestions don't handle hyphenated or otherwise-separated words gracefully. When in doubt, please rely on the sites linked above. </ em > </ li >
961970 </ ul > ) ;
962971 }
963972}
@@ -1282,6 +1291,7 @@ function get_leaderboard_issues(lb)
12821291
12831292function assess_achievement ( ach )
12841293{
1294+ console . log ( 'assessing' , ach ) ;
12851295 let res = new Assessment ( ) ;
12861296
12871297 res . stats = generate_logic_stats ( ach . logic ) ;
@@ -1342,4 +1352,4 @@ function assess_set(set)
13421352
13431353 // attach feedback to the asset
13441354 return set . feedback = res ;
1345- }
1355+ }
0 commit comments