@@ -233,6 +233,7 @@ export default function GachaCalc({ location }: { location: string }) {
233233
234234 const enabledTargets = useMemo ( ( ) => gachaTargets . filter ( gt => gt . enabled ) , [ gachaTargets ] )
235235 const calculated = useMemo ( ( ) => calcSimsRegular ( pulls , enabledTargets ) , [ enabledTargets , pulls ] )
236+ const lastEntry = calculated [ calculated . length - 1 ] ?? [ ]
236237
237238 const consts = [ ]
238239 for ( let index = 0 ; index < enabledTargets . length ; index ++ ) {
@@ -319,11 +320,11 @@ export default function GachaCalc({ location }: { location: string }) {
319320 < div className = "w-full bg-slate-800 rounded-xl p-1 my-2 md:my-0 text-white col-start-1" >
320321 < Bar
321322 data = { {
322- labels : calculated [ calculated . length - 1 ] . filter ( ( x ) => x ) . map ( ( c ) => getName ( c ) ) ,
323+ labels : lastEntry . filter ( ( x ) => x ) . map ( ( c ) => getName ( c ) ) ,
323324 datasets : [ {
324325 label : "Rate" ,
325326 backgroundColor : "rgb(75, 192, 192)" ,
326- data : calculated [ calculated . length - 1 ] . filter ( x => x ) . map ( c => c . rate * 100 ) ,
327+ data : lastEntry . filter ( x => x ) . map ( c => c . rate * 100 ) ,
327328 borderColor : "white" ,
328329 borderWidth : 2 ,
329330 xAxisID : "xAxes" ,
@@ -351,13 +352,13 @@ export default function GachaCalc({ location }: { location: string }) {
351352 </ div >
352353 < div className = "w-full bg-slate-800 rounded-xl p-1 my-2 md:my-0 text-white col-start-2" >
353354 < Line data = { {
354- labels : calculated [ calculated . length - 1 ] . filter ( x => x ) . map ( c => getName ( c ) ) ,
355+ labels : lastEntry . filter ( x => x ) . map ( c => getName ( c ) ) ,
355356 datasets : [ {
356357 label : "Cumulative rate" ,
357358 borderColor : "rgb(255, 99, 132)" ,
358359 borderWidth : 2 ,
359360 fill : false ,
360- data : calculated [ calculated . length - 1 ]
361+ data : lastEntry
361362 . filter ( ( x ) => x )
362363 . map ( ( c , i , a ) => a . slice ( i , a . length ) . reduce ( ( p , c ) => p + c . rate , 0 ) * 100 ) ,
363364 } ] ,
@@ -446,7 +447,7 @@ export default function GachaCalc({ location }: { location: string }) {
446447 </ tr >
447448 </ thead >
448449 < tbody className = "divide-y divide-gray-200 dark:divide-gray-500" >
449- { calculated [ calculated . length - 1 ]
450+ { lastEntry
450451 . filter ( ( x ) => x )
451452 . map ( ( c , i , a ) => (
452453 < tr className = { `pr-1 divide-x divide-gray-200 dark:divide-gray-500 ${ c . rate < 0.0005 ? "opacity-60" : "" } ` } key = { i } >
@@ -704,7 +705,7 @@ function createStarterSim(gachaTargets: GachaTarget[], gachaTargetIndex: number
704705 guaranteed : init . guaranteed ,
705706 guaranteedPity : init . guaranteedPity ,
706707 lostPity : init . lostPity ,
707- rate : rate ,
708+ rate,
708709 }
709710}
710711
@@ -713,6 +714,8 @@ function calcSimsRegular(
713714 gachaTargets : GachaTarget [ ] ,
714715) : ReducedSim [ ] [ ] {
715716 console . log ( "calcSimsRegular" , pulls , gachaTargets )
717+ if ( gachaTargets . length == 0 ) return [ ]
718+
716719 console . time ( "calc" )
717720 const sims = calcSimsExact ( [ createStarterSim ( gachaTargets ) ] , pulls , gachaTargets , 0 , ( sims ) => {
718721 // Reducing to simple sims with less information
0 commit comments