mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-11-08 08:43:53 +01:00
Merge pull request #4156 from G4mingJon4s/contractFix
Coding Contract: Saving and reloading no longer generates extra coding contracts.
This commit is contained in:
commit
f8a3a046de
@ -244,17 +244,21 @@ const Engine: {
|
|||||||
const timeOffline = Engine._lastUpdate - lastUpdate;
|
const timeOffline = Engine._lastUpdate - lastUpdate;
|
||||||
const numCyclesOffline = Math.floor(timeOffline / CONSTANTS._idleSpeed);
|
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
|
// Generate coding contracts
|
||||||
if (Player.sourceFiles.length > 0) {
|
if (Player.sourceFiles.length > 0) {
|
||||||
let numContracts = 0;
|
let numContracts = 0;
|
||||||
if (numCyclesOffline < 3000 * 100) {
|
if (contractChancesWhileOffline > 100) {
|
||||||
// if we have less than 100 rolls, just roll them exactly.
|
numContracts += Math.floor(contractChancesWhileOffline * 0.25);
|
||||||
for (let i = 0; i < numCyclesOffline / 3000; i++) {
|
}
|
||||||
if (Math.random() <= 0.25) numContracts++;
|
if (contractChancesWhileOffline > 0 && contractChancesWhileOffline <= 100) {
|
||||||
|
for (let i = 0; i < contractChancesWhileOffline; ++i) {
|
||||||
|
if (Math.random() <= 0.25) {
|
||||||
|
numContracts++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
// just average it.
|
|
||||||
numContracts = (numCyclesOffline / 3000) * 0.25;
|
|
||||||
}
|
}
|
||||||
for (let i = 0; i < numContracts; i++) {
|
for (let i = 0; i < numContracts; i++) {
|
||||||
generateRandomContract();
|
generateRandomContract();
|
||||||
|
Loading…
Reference in New Issue
Block a user