From a1ff3a2058852eaca7909db7265a795cac21579e Mon Sep 17 00:00:00 2001 From: G4mingJon4s Date: Sun, 25 Sep 2022 12:37:20 +0200 Subject: [PATCH 1/2] Fix for #4111 --- src/engine.tsx | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/engine.tsx b/src/engine.tsx index f7037ee06..aa10628de 100644 --- a/src/engine.tsx +++ b/src/engine.tsx @@ -256,17 +256,14 @@ const Engine: { const timeOffline = Engine._lastUpdate - lastUpdate; const numCyclesOffline = Math.floor(timeOffline / CONSTANTS._idleSpeed); + // Calculate the number of chances for a contract the player had whilst offline + const contractChancesWhileOffline = Math.floor(timeOffline / (1000 * 60 * 10)); + // Generate coding contracts if (Player.sourceFiles.length > 0) { let numContracts = 0; - if (numCyclesOffline < 3000 * 100) { - // if we have less than 100 rolls, just roll them exactly. - for (let i = 0; i < numCyclesOffline / 3000; i++) { - if (Math.random() <= 0.25) numContracts++; - } - } else { - // just average it. - numContracts = (numCyclesOffline / 3000) * 0.25; + if (contractChancesWhileOffline > 0) { + numContracts += Math.floor(contractChancesWhileOffline * 0.25); } for (let i = 0; i < numContracts; i++) { generateRandomContract(); From fd9bdb3b657c1a31103f8da45eabe64771fa0ad1 Mon Sep 17 00:00:00 2001 From: G4mingJon4s Date: Mon, 26 Sep 2022 19:19:03 +0200 Subject: [PATCH 2/2] Readded randomness for lower values of chances --- src/engine.tsx | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/engine.tsx b/src/engine.tsx index aa10628de..8f3d4d94f 100644 --- a/src/engine.tsx +++ b/src/engine.tsx @@ -262,9 +262,16 @@ const Engine: { // Generate coding contracts if (Player.sourceFiles.length > 0) { let numContracts = 0; - if (contractChancesWhileOffline > 0) { + if (contractChancesWhileOffline > 100) { numContracts += Math.floor(contractChancesWhileOffline * 0.25); } + if (contractChancesWhileOffline > 0 && contractChancesWhileOffline <= 100) { + for (let i = 0; i < contractChancesWhileOffline; ++i) { + if (Math.random() <= 0.25) { + numContracts++; + } + } + } for (let i = 0; i < numContracts; i++) { generateRandomContract(); }