UI: Fix #3366 Sleeve UI would sometime display the stat in TaskSelector while working out.

fixes #3366

 Sleeve.gymStatType will now be constrainded to the following values by Sleeve.workoutAtGym() :
"none" , "str", "def", "dex", "agi". (could previously be anything inputted by player through API)
Sleeve.updateGainTaskRate() and TaskSelector.tasks's initializer block will now use a switch, expecting one of those value, instead of reevaluating the string.

(fixing commit issue)
This commit is contained in:
borisflagell 2022-05-23 20:03:13 +02:00
parent 27bf6cba39
commit 8af4fb1d5a
2 changed files with 47 additions and 22 deletions

@ -854,17 +854,22 @@ export class Sleeve extends Person {
// Set stat gain rate // Set stat gain rate
const baseGymExp = 1; const baseGymExp = 1;
const totalExpMultiplier = p.hashManager.getTrainingMult() * expMult; const totalExpMultiplier = p.hashManager.getTrainingMult() * expMult;
const sanitizedStat: string = this.gymStatType.toLowerCase(); switch (this.gymStatType) {
if (sanitizedStat.includes("str")) { case "none": // Note : due to the way Sleeve.workOutAtGym() is currently designed, this should never happend.
this.gainRatesForTask.str = baseGymExp * totalExpMultiplier * this.strength_exp_mult; break;
} else if (sanitizedStat.includes("def")) { case "str":
this.gainRatesForTask.def = baseGymExp * totalExpMultiplier * this.defense_exp_mult; this.gainRatesForTask.str = baseGymExp * totalExpMultiplier * this.strength_exp_mult;
} else if (sanitizedStat.includes("dex")) { break;
this.gainRatesForTask.dex = baseGymExp * totalExpMultiplier * this.dexterity_exp_mult; case "def":
} else if (sanitizedStat.includes("agi")) { this.gainRatesForTask.def = baseGymExp * totalExpMultiplier * this.defense_exp_mult;
this.gainRatesForTask.agi = baseGymExp * totalExpMultiplier * this.agility_exp_mult; break;
case "dex":
this.gainRatesForTask.dex = baseGymExp * totalExpMultiplier * this.dexterity_exp_mult;
break;
case "agi":
this.gainRatesForTask.agi = baseGymExp * totalExpMultiplier * this.agility_exp_mult;
break;
} }
return; return;
} }
@ -1058,19 +1063,27 @@ export class Sleeve extends Person {
// Set experience/money gains based on class // Set experience/money gains based on class
const sanitizedStat: string = stat.toLowerCase(); const sanitizedStat: string = stat.toLowerCase();
// Set cost // set stat to a default value.
this.gainRatesForTask.money = -1 * (CONSTANTS.ClassGymBaseCost * costMult); stat = "none";
if (sanitizedStat.includes("str")) {
// Validate "stat" argument stat = "str";
if ( }
!sanitizedStat.includes("str") && if (sanitizedStat.includes("def")) {
!sanitizedStat.includes("def") && stat = "def";
!sanitizedStat.includes("dex") && }
!sanitizedStat.includes("agi") if (sanitizedStat.includes("dex")) {
) { stat = "dex";
}
if (sanitizedStat.includes("agi")) {
stat = "agi";
}
// if stat is still equals its default value, then validation has failed.
if (stat === "none") {
return false; return false;
} }
// Set cost
this.gainRatesForTask.money = -1 * (CONSTANTS.ClassGymBaseCost * costMult);
this.gymStatType = stat; this.gymStatType = stat;
this.currentTask = SleeveTaskType.Gym; this.currentTask = SleeveTaskType.Gym;

@ -270,8 +270,20 @@ function getABC(sleeve: Sleeve): [string, string, string] {
return ["Commit Crime", sleeve.crimeType, "------"]; return ["Commit Crime", sleeve.crimeType, "------"];
case SleeveTaskType.Class: case SleeveTaskType.Class:
return ["Take University Course", sleeve.className, sleeve.currentTaskLocation]; return ["Take University Course", sleeve.className, sleeve.currentTaskLocation];
case SleeveTaskType.Gym: case SleeveTaskType.Gym: {
return ["Workout at Gym", sleeve.gymStatType, sleeve.currentTaskLocation]; switch (sleeve.gymStatType) {
case "none":
return ["Idle", "------", "------"];
case "str":
return ["Workout at Gym", "Train Strength", sleeve.currentTaskLocation];
case "def":
return ["Workout at Gym", "Train Defense", sleeve.currentTaskLocation];
case "dex":
return ["Workout at Gym", "Train Dexterity", sleeve.currentTaskLocation];
case "agi":
return ["Workout at Gym", "Train Agility", sleeve.currentTaskLocation];
}
}
case SleeveTaskType.Bladeburner: case SleeveTaskType.Bladeburner:
return ["Perform Bladeburner Actions", sleeve.bbAction, sleeve.bbContract]; return ["Perform Bladeburner Actions", sleeve.bbAction, sleeve.bbContract];
case SleeveTaskType.Recovery: case SleeveTaskType.Recovery: