@@ -5,6 +5,8 @@ import Icons from './icons';
55
66export default class Store {
77 items ;
8+ inventoryLoaded = false ;
9+ inventoryLoadedFromCache ;
810
911 #storeData;
1012 #tournamentData;
@@ -90,8 +92,8 @@ export default class Store {
9092 const map_name = Constant . TOURNAMENT_MAPS [ match . roundstats_legacy . map_id ] ;
9193 const stage_id = match . roundstats_legacy . reservation . tournament_event . event_stage_id ;
9294 const section = this . #tournamentData. tournamentinfo . sections . find ( section => section . groups . find ( group => group . stage_ids . includes ( stage_id ) ) ) ;
93- const team_1 = match . roundstats_legacy . reservation . tournament_teams [ 0 ] . team_name ;
94- const team_2 = match . roundstats_legacy . reservation . tournament_teams [ 1 ] . team_name ;
95+ const team_1 = match . roundstats_legacy . reservation . tournament_teams [ 0 ] ;
96+ const team_2 = match . roundstats_legacy . reservation . tournament_teams [ 1 ] ;
9597 const is_highlight = section . sectionid >= highlightSectionIDStart ;
9698 const hash_name = this . #GetHashName( item , map_name , is_highlight ) ;
9799 const non_highlight_hash_name = this . #GetHashName( item , map_name ) ; // Highlight packages use the same icons as non-highlight packages
@@ -126,13 +128,16 @@ export default class Store {
126128 layout_weight : this . #storeData. price_sheet . store_banner_layout [ item . def_index ] ?. w ,
127129 tournament_id : item . tournament_id ,
128130 requires_supplemental_data : item . requires_supplemental_data ,
131+ stage_id : stage_id ,
129132 section_id : section . sectionid ,
130133 section_name : section . name ,
131- team_1 : team_1 ,
134+ team_1 : team_1 . team_name ,
135+ team_1_id : team_1 . team_id ,
132136 team_1_score : match . roundstats_legacy . team_scores [ 0 ] ,
133- team_2 : team_2 ,
137+ team_2 : team_2 . team_name ,
138+ team_2_id : team_2 . team_id ,
134139 team_2_score : match . roundstats_legacy . team_scores [ 1 ] ,
135- teams_normalized : `${ team_1 } ${ team_2 } ` . normalize ( "NFD" ) . replace ( / [ \u0300 - \u036f ] / g, "" ) . toLowerCase ( ) ,
140+ teams_normalized : `${ team_1 . team_name } ${ team_2 . team_name } ` . normalize ( "NFD" ) . replace ( / [ \u0300 - \u036f ] / g, "" ) . toLowerCase ( ) ,
136141 match_result : match . roundstats_legacy . match_result
137142 } ) ;
138143 }
@@ -147,6 +152,36 @@ export default class Store {
147152 await Icons . FetchMarketIcons ( new Set ( [ ...storeItemsToGetIconsFor , ...marketItemsToGetIconsFor ] ) , progressCallback ) ;
148153 }
149154
155+ LoadInventory ( inventory ) {
156+ for ( const item of this . items ) {
157+ item . owned = [ ...inventory . items , ...inventory . storedItems ] . filter ( x => {
158+ if ( x . iteminfo . def_index == item . id ) {
159+ return true ;
160+ }
161+
162+ // Coupon items
163+ if ( ! item . requires_supplemental_data && item . hash_name && x . full_name == item . hash_name ) {
164+ return true ;
165+ }
166+
167+ // Souvenir packages
168+ if ( item . requires_supplemental_data
169+ && x . full_name == item . hash_name
170+ && x . attributes [ "tournament event stage id" ] == item . stage_id
171+ && x . attributes [ "tournament event team0 id" ] == item . team_1_id
172+ && x . attributes [ "tournament event team1 id" ] == item . team_2_id
173+ ) {
174+ return true ;
175+ }
176+
177+ return false ;
178+ } ) . length ;
179+ }
180+
181+ this . inventoryLoaded = true ;
182+ this . inventoryLoadedFromCache = inventory . loadedFromCache ;
183+ }
184+
150185 FormatCurrency ( valueInCents ) {
151186 let currencyFormat = ( valueInCents / 100 ) . toFixed ( 2 ) ;
152187
0 commit comments