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:
@@ -12,6 +12,7 @@ namespace Content.Shared.Roles
|
||||
[ImplicitDataDefinitionForInheritors]
|
||||
public abstract class JobRequirement
|
||||
{
|
||||
[DataField("inverted")] public bool Inverted;
|
||||
}
|
||||
|
||||
[UsedImplicitly]
|
||||
@@ -104,24 +105,53 @@ namespace Content.Shared.Roles
|
||||
|
||||
var deptDiff = deptRequirement.Time.TotalMinutes - playtime.TotalMinutes;
|
||||
|
||||
if (deptDiff <= 0)
|
||||
return true;
|
||||
if (!deptRequirement.Inverted)
|
||||
{
|
||||
if (deptDiff <= 0)
|
||||
return true;
|
||||
|
||||
reason = Loc.GetString(
|
||||
"role-timer-department-insufficient",
|
||||
("time", deptDiff),
|
||||
("department", Loc.GetString(deptRequirement.Department)));
|
||||
return false;
|
||||
reason = Loc.GetString(
|
||||
"role-timer-department-insufficient",
|
||||
("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 (overallDiff <= 0 || overallTime >= overallRequirement.Time)
|
||||
return true;
|
||||
if (!overallRequirement.Inverted)
|
||||
{
|
||||
if (overallDiff <= 0 || overallTime >= overallRequirement.Time)
|
||||
return true;
|
||||
|
||||
reason = Loc.GetString("role-timer-overall-insufficient", ("time", overallDiff));
|
||||
return false;
|
||||
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,14 +159,31 @@ namespace Content.Shared.Roles
|
||||
playTimes.TryGetValue(proto, out var roleTime);
|
||||
var roleDiff = roleRequirement.Time.TotalMinutes - roleTime.TotalMinutes;
|
||||
|
||||
if (roleDiff <= 0)
|
||||
return true;
|
||||
if (!roleRequirement.Inverted)
|
||||
{
|
||||
if (roleDiff <= 0)
|
||||
return true;
|
||||
|
||||
reason = Loc.GetString(
|
||||
"role-timer-role-insufficient",
|
||||
("time", roleDiff),
|
||||
("job", Loc.GetString(proto)));
|
||||
return false;
|
||||
reason = Loc.GetString(
|
||||
"role-timer-role-insufficient",
|
||||
("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();
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user