mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-12-21 05:35:45 +01:00
Rework coffee/party (#201)
* Removed unused partyEmployees and coffeeEmployees members of OfficeSpace * Reworked formula for performance loss per market cycle. * Rework both coffee and party formulas to allow easier recovery from low values.
This commit is contained in:
parent
8367b68f46
commit
01b131526a
@ -325,15 +325,8 @@ export function UpgradeOfficeSize(corp: Corporation, office: OfficeSpace, size:
|
|||||||
|
|
||||||
export function BuyCoffee(corp: Corporation, office: OfficeSpace): boolean {
|
export function BuyCoffee(corp: Corporation, office: OfficeSpace): boolean {
|
||||||
const cost = office.getCoffeeCost();
|
const cost = office.getCoffeeCost();
|
||||||
if (corp.funds < cost) {
|
if (corp.funds < cost || !office.setCoffee()) return false;
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!office.setCoffee()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
corp.funds -= cost;
|
corp.funds -= cost;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,10 +37,8 @@ export class OfficeSpace {
|
|||||||
|
|
||||||
autoCoffee = false;
|
autoCoffee = false;
|
||||||
autoParty = false;
|
autoParty = false;
|
||||||
coffeeMult = 0;
|
coffeePending = false;
|
||||||
partyMult = 0;
|
partyMult = 0;
|
||||||
coffeeEmployees = 0;
|
|
||||||
partyEmployees = 0;
|
|
||||||
|
|
||||||
employeeProd: Record<EmployeePositions | "total", number> = {
|
employeeProd: Record<EmployeePositions | "total", number> = {
|
||||||
[EmployeePositions.Operations]: 0,
|
[EmployeePositions.Operations]: 0,
|
||||||
@ -115,46 +113,39 @@ export class OfficeSpace {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (this.totalEmployees > 0) {
|
if (this.totalEmployees > 0) {
|
||||||
// Calculate changes in Morale/Happiness/Energy for Employees
|
/** Multiplier for employee morale/happiness/energy based on company performance */
|
||||||
let perfMult = 1; //Multiplier for employee morale/happiness/energy based on company performance
|
const perfMult = Math.pow(
|
||||||
const reduction = 0.0015 * marketCycles; // Passive reduction every cycle
|
0.999 - (corporation.funds < 0 ? 0.002 : 0) - (industry.lastCycleRevenue < 0 ? 0.002 : 0),
|
||||||
if (corporation.funds < 0 && industry.lastCycleRevenue < 0) {
|
marketCycles,
|
||||||
perfMult = Math.pow(0.995, marketCycles);
|
);
|
||||||
} else if (corporation.funds > 0 && industry.lastCycleRevenue > 0) {
|
/** Flat reduction per cycle */
|
||||||
perfMult = Math.pow(0.999, marketCycles);
|
const reduction = 0.001 * marketCycles;
|
||||||
}
|
|
||||||
|
|
||||||
if (this.autoCoffee) {
|
if (this.autoCoffee) {
|
||||||
this.avgEne = this.maxEne;
|
this.avgEne = this.maxEne;
|
||||||
} else if (this.coffeeMult > 1) {
|
|
||||||
this.avgEne -= reduction;
|
|
||||||
this.avgEne *= (this.coffeeMult * this.coffeeEmployees) / this.totalEmployees;
|
|
||||||
} else {
|
} else {
|
||||||
this.avgEne -= reduction;
|
// Coffee gives a flat +3 to energy
|
||||||
this.avgEne *= perfMult;
|
this.avgEne = (this.avgEne - reduction) * perfMult + (this.coffeePending ? 3 : 0);
|
||||||
|
// Coffee also halves the difference between current and max energy
|
||||||
|
if (this.coffeePending) this.avgEne = this.maxEne - (this.maxEne - this.avgEne) / 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.autoParty) {
|
if (this.autoParty) {
|
||||||
this.avgMor = this.maxMor;
|
this.avgMor = this.maxMor;
|
||||||
this.avgHap = this.maxHap;
|
this.avgHap = this.maxHap;
|
||||||
} else if (this.partyMult > 1) {
|
|
||||||
this.avgHap -= reduction;
|
|
||||||
this.avgMor *= (this.partyMult * this.partyEmployees) / this.totalEmployees;
|
|
||||||
this.avgHap *= (this.partyMult * this.partyEmployees) / this.totalEmployees;
|
|
||||||
} else {
|
} else {
|
||||||
this.avgHap -= reduction;
|
// Each 5% multiplier gives an extra flat +1 to morale and happiness to make recovering from low morale easier.
|
||||||
this.avgMor *= perfMult;
|
const increase = this.partyMult > 1 ? (1 - this.partyMult) * 20 : 0;
|
||||||
this.avgHap *= perfMult;
|
this.avgHap = ((this.avgHap - reduction) * perfMult + increase) * this.partyMult;
|
||||||
|
this.avgMor = (this.avgMor * perfMult + increase) * this.partyMult;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.avgEne = Math.max(Math.min(this.avgEne, this.maxEne), this.minEne);
|
this.avgEne = Math.max(Math.min(this.avgEne, this.maxEne), this.minEne);
|
||||||
this.avgMor = Math.max(Math.min(this.avgMor, this.maxMor), this.minMor);
|
this.avgMor = Math.max(Math.min(this.avgMor, this.maxMor), this.minMor);
|
||||||
this.avgHap = Math.max(Math.min(this.avgHap, this.maxHap), this.minHap);
|
this.avgHap = Math.max(Math.min(this.avgHap, this.maxHap), this.minHap);
|
||||||
|
|
||||||
this.coffeeMult = 0;
|
this.coffeePending = false;
|
||||||
this.partyMult = 0;
|
this.partyMult = 0;
|
||||||
this.coffeeEmployees = 0;
|
|
||||||
this.partyEmployees = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get experience increase; unassigned employees do not contribute, employees in training contribute 5x
|
// Get experience increase; unassigned employees do not contribute, employees in training contribute 5x
|
||||||
@ -259,23 +250,19 @@ export class OfficeSpace {
|
|||||||
return 500e3 * this.totalEmployees;
|
return 500e3 * this.totalEmployees;
|
||||||
}
|
}
|
||||||
|
|
||||||
setCoffee(mult = 1.05): boolean {
|
setCoffee(): boolean {
|
||||||
if (mult > 1 && this.coffeeMult === 0 && !this.autoCoffee && this.totalEmployees > 0) {
|
if (!this.coffeePending && !this.autoCoffee && this.totalEmployees > 0) {
|
||||||
this.coffeeMult = mult;
|
this.coffeePending = true;
|
||||||
this.coffeeEmployees = this.totalEmployees;
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
setParty(mult: number): boolean {
|
setParty(mult: number): boolean {
|
||||||
if (mult > 1 && this.partyMult === 0 && !this.autoParty && this.totalEmployees > 0) {
|
if (mult > 1 && this.partyMult === 0 && !this.autoParty && this.totalEmployees > 0) {
|
||||||
this.partyMult = mult;
|
this.partyMult = mult;
|
||||||
this.partyEmployees = this.totalEmployees;
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -318,10 +318,10 @@ export function IndustryOffice(props: IProps): React.ReactElement {
|
|||||||
>
|
>
|
||||||
<span>
|
<span>
|
||||||
<Button
|
<Button
|
||||||
disabled={corp.funds < props.office.getCoffeeCost() || props.office.coffeeMult > 0}
|
disabled={corp.funds < props.office.getCoffeeCost() || props.office.coffeePending}
|
||||||
onClick={() => BuyCoffee(corp, props.office)}
|
onClick={() => BuyCoffee(corp, props.office)}
|
||||||
>
|
>
|
||||||
{props.office.coffeeMult > 0 ? (
|
{props.office.coffeePending ? (
|
||||||
"Buying coffee..."
|
"Buying coffee..."
|
||||||
) : (
|
) : (
|
||||||
<span>
|
<span>
|
||||||
|
Loading…
Reference in New Issue
Block a user