Lock non-newbies out of intern roles. (#10598)

* Lock non-newbies out of intern roles.

* Remove from service worker as it doesn't gate anything.
This commit is contained in:
Moony
2022-08-14 16:14:46 -05:00
committed by GitHub
parent 31b93dfd72
commit 37c64b69a5
5 changed files with 83 additions and 18 deletions

View File

@@ -12,6 +12,7 @@ namespace Content.Shared.Roles
[ImplicitDataDefinitionForInheritors]
public abstract class JobRequirement
{
[DataField("inverted")] public bool Inverted;
}
[UsedImplicitly]
@@ -104,6 +105,8 @@ namespace Content.Shared.Roles
var deptDiff = deptRequirement.Time.TotalMinutes - playtime.TotalMinutes;
if (!deptRequirement.Inverted)
{
if (deptDiff <= 0)
return true;
@@ -112,16 +115,43 @@ namespace Content.Shared.Roles
("time", deptDiff),
("department", Loc.GetString(deptRequirement.Department)));
return false;
}
else
{
if (deptDiff <= 0)
{
reason = Loc.GetString(
"role-timer-department-too-high",
("time", -deptDiff),
("department", Loc.GetString(deptRequirement.Department)));
return false;
}
return true;
}
case OverallPlaytimeRequirement overallRequirement:
var overallTime = playTimes.GetValueOrDefault(PlayTimeTrackingShared.TrackerOverall);
var overallDiff = overallRequirement.Time.TotalMinutes - overallTime.TotalMinutes;
if (!overallRequirement.Inverted)
{
if (overallDiff <= 0 || overallTime >= overallRequirement.Time)
return true;
reason = Loc.GetString("role-timer-overall-insufficient", ("time", overallDiff));
return false;
}
else
{
if (overallDiff <= 0 || overallTime >= overallRequirement.Time)
{
reason = Loc.GetString("role-timer-overall-too-high", ("time", -overallDiff));
return false;
}
return true;
}
case RoleTimeRequirement roleRequirement:
proto = roleRequirement.Role;
@@ -129,6 +159,8 @@ namespace Content.Shared.Roles
playTimes.TryGetValue(proto, out var roleTime);
var roleDiff = roleRequirement.Time.TotalMinutes - roleTime.TotalMinutes;
if (!roleRequirement.Inverted)
{
if (roleDiff <= 0)
return true;
@@ -137,6 +169,21 @@ namespace Content.Shared.Roles
("time", roleDiff),
("job", Loc.GetString(proto)));
return false;
}
else
{
if (roleDiff <= 0)
{
reason = Loc.GetString(
"role-timer-role-too-high",
("time", -roleDiff),
("job", Loc.GetString(proto)));
return false;
}
return true;
}
default:
throw new NotImplementedException();
}

View File

@@ -1,5 +1,8 @@
role-timer-department-insufficient = Require {TOSTRING($time, "0")} more minutes in {$department} department.
role-timer-department-too-high = Requires {TOSTRING($time, "0")} fewer minutes in {$department} department. (Are you trying to play a trainee role?)
role-timer-overall-insufficient = Require {TOSTRING($time, "0")} more minutes of playtime.
role-timer-overall-too-high = Require {TOSTRING($time, "0")} fewer minutes of playtime. (Are you trying to play a trainee role?)
role-timer-role-insufficient = Require {TOSTRING($time, "0")} more minutes with {$job} for this role.
role-timer-role-too-high = Require {TOSTRING($time, "0")} fewer minutes with {$job} for this role. (Are you trying to play a trainee role?)
role-timer-locked = Locked (hover for details)

View File

@@ -2,6 +2,11 @@
id: TechnicalAssistant
name: job-name-assistant
playTimeTracker: JobTechnicalAssistant
requirements:
- !type:DepartmentTimeRequirement
department: Engineering
time: 1800
inverted: true # stop playing intern if you're good at engineering!
startingGear: TechnicalAssistantGear
icon: "TechnicalAssistant"
supervisors: job-supervisors-engineering

View File

@@ -2,6 +2,11 @@
id: MedicalIntern
name: job-name-intern
playTimeTracker: JobMedicalIntern
requirements:
- !type:DepartmentTimeRequirement
department: Medical
time: 1800
inverted: true # stop playing intern if you're good at med!
startingGear: MedicalInternGear
icon: "MedicalIntern"
supervisors: job-supervisors-medicine

View File

@@ -2,6 +2,11 @@
id: SecurityCadet
name: job-name-cadet
playTimeTracker: JobSecurityCadet
requirements:
- !type:DepartmentTimeRequirement
department: Security
time: 1800
inverted: true # stop playing intern if you're good at security!
startingGear: SecurityCadetGear
icon: "SecurityCadet"
supervisors: job-supervisors-security