Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement major/minor program support. #2074

Merged
merged 2 commits into from
Jul 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions GameData/RP-1/CustomBarnKit.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,11 @@
}
@ADMINISTRATION
{
@levels = 3
@upgradesVisual = 1, 2, 3
@upgrades = 25000, 250000, 750000
@activeStrategyLimit = 2, 3, 4
@strategyCommitRange = 0, 0, 0
@levels = 9
@upgradesVisual = 1, 1, 2, 2, 2, 3, 3, 3, 3
@upgrades = 25000, 40000, 140000, 250000, 400000, 500000, 500000, 500000, 500000
@activeStrategyLimit = 5, 6, 7, 8, 9, 10, 11, 12, 13
@strategyCommitRange = 0, 0, 0, 0, 0, 0, 0, 0, 0
}
@RESEARCH
{
Expand Down
6 changes: 3 additions & 3 deletions GameData/RP-1/Localization/en-us.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
RP0conf = True
en-us
{
#autoLOC_439627 = Active Programs: <<1>> [Max: <<2>>]
#autoLOC_900144 = Max Active Programs: [StrategyCount]
#autoLOC_439627 = Program Slots: <<1>> [Max: <<2>>]
#autoLOC_900144 = Max Program Slots: [StrategyCount]
#autoLOC_900268 = Active Programs
#autoLOC_6001741 = Programs
#autoLOC_6002231 = Max Active Programs:
#autoLOC_6002231 = Max Program Slots:
#autoLOC_304887 = Leader can be removed

#autoLOC_304890 = Leader: Cannot be removed as they have not yet served the minimum time.
Expand Down
31 changes: 31 additions & 0 deletions GameData/RP-1/Programs/Programs.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ RP0_PROGRAM
fundingCurve = BackloadedFundingCurve
repDeltaOnCompletePerYearEarly = 30
repPenaltyPerYearLate = 30
slots = 2

OBJECTIVES
{
Expand Down Expand Up @@ -66,6 +67,7 @@ RP0_PROGRAM
baseFunding = 210000
repDeltaOnCompletePerYearEarly = 20
repPenaltyPerYearLate = 20
slots = 2

OBJECTIVES
{
Expand Down Expand Up @@ -98,6 +100,7 @@ RP0_PROGRAM
baseFunding = 210000
repDeltaOnCompletePerYearEarly = 20
repPenaltyPerYearLate = 20
slots = 2

OBJECTIVES
{
Expand Down Expand Up @@ -150,6 +153,7 @@ RP0_PROGRAM
fundingCurve = MildBackloadedFundingCurve
repDeltaOnCompletePerYearEarly = 50
repPenaltyPerYearLate = 50
slots = 2

REQUIREMENTS
{
Expand Down Expand Up @@ -199,6 +203,7 @@ RP0_PROGRAM
baseFunding = 875000
repDeltaOnCompletePerYearEarly = 75
repPenaltyPerYearLate = 75
slots = 3

REQUIREMENTS
{
Expand Down Expand Up @@ -245,6 +250,7 @@ RP0_PROGRAM
baseFunding = 360000
repDeltaOnCompletePerYearEarly = 100
repPenaltyPerYearLate = 100
slots = 1

REQUIREMENTS
{
Expand Down Expand Up @@ -289,6 +295,7 @@ RP0_PROGRAM
baseFunding = 400000
repDeltaOnCompletePerYearEarly = 100
repPenaltyPerYearLate = 100
slots = 1

REQUIREMENTS
{
Expand Down Expand Up @@ -327,6 +334,7 @@ RP0_PROGRAM
fundingCurve = MildBackloadedFundingCurve
repDeltaOnCompletePerYearEarly = 400
repPenaltyPerYearLate = 400
slots = 2

REQUIREMENTS
{
Expand Down Expand Up @@ -361,6 +369,7 @@ RP0_PROGRAM
baseFunding = 800000
repDeltaOnCompletePerYearEarly = 200
repPenaltyPerYearLate = 200
slots = 2

REQUIREMENTS
{
Expand Down Expand Up @@ -403,6 +412,7 @@ RP0_PROGRAM
fundingCurve = MildBackloadedFundingCurve
repDeltaOnCompletePerYearEarly = 400
repPenaltyPerYearLate = 400
slots = 2

REQUIREMENTS
{
Expand Down Expand Up @@ -445,6 +455,7 @@ RP0_PROGRAM
repDeltaOnCompletePerYearEarly = 400
repPenaltyPerYearLate = 400
repToConfidence = 3
slots = 3

REQUIREMENTS
{
Expand Down Expand Up @@ -495,6 +506,7 @@ RP0_PROGRAM
fundingCurve = BackloadedFundingCurve
repDeltaOnCompletePerYearEarly = 400
repPenaltyPerYearLate = 400
slots = 3

REQUIREMENTS
{
Expand Down Expand Up @@ -539,6 +551,7 @@ RP0_PROGRAM
repDeltaOnCompletePerYearEarly = 300
repPenaltyPerYearLate = 300
repToConfidence = 2
slots = 2

REQUIREMENTS
{
Expand Down Expand Up @@ -577,6 +590,7 @@ RP0_PROGRAM
repDeltaOnCompletePerYearEarly = 800
repPenaltyPerYearLate = 800
repToConfidence = 2
slots = 4

REQUIREMENTS
{
Expand Down Expand Up @@ -630,6 +644,7 @@ disabled_RP0_PROGRAM
baseFunding = 15000000
repDeltaOnCompletePerYearEarly = 750
repPenaltyPerYearLate = 750
slots = 3

REQUIREMENTS
{
Expand Down Expand Up @@ -663,6 +678,7 @@ RP0_PROGRAM
repDeltaOnCompletePerYearEarly = 800
repPenaltyPerYearLate = 800
repToConfidence = 2
slots = 3

REQUIREMENTS
{
Expand Down Expand Up @@ -705,6 +721,7 @@ RP0_PROGRAM
repDeltaOnCompletePerYearEarly = 800
repPenaltyPerYearLate = 800
repToConfidence = 2
slots = 3

REQUIREMENTS
{
Expand Down Expand Up @@ -741,6 +758,7 @@ RP0_PROGRAM
baseFunding = 4000000
repDeltaOnCompletePerYearEarly = 600
repPenaltyPerYearLate = 600
slots = 2

REQUIREMENTS
{
Expand Down Expand Up @@ -777,6 +795,7 @@ RP0_PROGRAM
repDeltaOnCompletePerYearEarly = 600
repPenaltyPerYearLate = 600
repToConfidence = 3
slots = 3

REQUIREMENTS
{
Expand Down Expand Up @@ -813,6 +832,7 @@ RP0_PROGRAM
repDeltaOnCompletePerYearEarly = 600
repPenaltyPerYearLate = 600
repToConfidence = 3
slots = 2

REQUIREMENTS
{
Expand Down Expand Up @@ -850,6 +870,7 @@ RP0_PROGRAM
repDeltaOnCompletePerYearEarly = 600
repPenaltyPerYearLate = 600
repToConfidence = 3
slots = 3

REQUIREMENTS
{
Expand Down Expand Up @@ -896,6 +917,7 @@ disabled_RP0_PROGRAM
baseFunding = 14400000
repDeltaOnCompletePerYearEarly = 800
repPenaltyPerYearLate = 800
slots = 4

REQUIREMENTS
{
Expand Down Expand Up @@ -926,6 +948,7 @@ RP0_PROGRAM
repDeltaOnCompletePerYearEarly = 600
repPenaltyPerYearLate = 600
repToConfidence = 3
slots = 3

REQUIREMENTS
{
Expand Down Expand Up @@ -979,6 +1002,7 @@ disabled_RP0_PROGRAM
baseFunding = 21600000
repDeltaOnCompletePerYearEarly = 800
repPenaltyPerYearLate = 800
slots = 4

REQUIREMENTS
{
Expand Down Expand Up @@ -1009,6 +1033,7 @@ RP0_PROGRAM
repDeltaOnCompletePerYearEarly = 600
repPenaltyPerYearLate = 600
repToConfidence = 2
slots = 3

REQUIREMENTS
{
Expand Down Expand Up @@ -1052,6 +1077,7 @@ RP0_PROGRAM
repDeltaOnCompletePerYearEarly = 1000
repPenaltyPerYearLate = 1000
repToConfidence = 3
slots = 4

REQUIREMENTS
{
Expand Down Expand Up @@ -1106,6 +1132,7 @@ RP0_PROGRAM
baseFunding = 25200000
repDeltaOnCompletePerYearEarly = 1200
repPenaltyPerYearLate = 1200
slots = 4

REQUIREMENTS
{
Expand Down Expand Up @@ -1142,6 +1169,7 @@ disabled_RP0_PROGRAM
baseFunding = 20000000
repDeltaOnCompletePerYearEarly = 1500
repPenaltyPerYearLate = 1500
slots = 5

REQUIREMENTS
{
Expand Down Expand Up @@ -1175,6 +1203,7 @@ disabled_RP0_PROGRAM
baseFunding = 42000000
repDeltaOnCompletePerYearEarly = 2000
repPenaltyPerYearLate = 2000
slots = 5

REQUIREMENTS
{
Expand Down Expand Up @@ -1204,6 +1233,7 @@ disabled_RP0_PROGRAM
baseFunding = 15000000
repDeltaOnCompletePerYearEarly = 2000
repPenaltyPerYearLate = 2000
slots = 4

REQUIREMENTS
{
Expand Down Expand Up @@ -1233,6 +1263,7 @@ disabled_RP0_PROGRAM
baseFunding = 60000000
repDeltaOnCompletePerYearEarly = 2500
repPenaltyPerYearLate = 2500
slots = 6

REQUIREMENTS
{
Expand Down
14 changes: 8 additions & 6 deletions Source/Harmony/Administration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ internal class PatchAdministration
internal static void FixProgramCounts(Administration __instance)
{
// We need to reset the strategy count because we only want to track programs, not leaders too.
__instance.activeStrategyCount = ProgramHandler.Instance.ActivePrograms.Count;
__instance.maxActiveStrategies = ProgramHandler.Instance.ActiveProgramLimit;
__instance.activeStrategyCount = ProgramHandler.Instance.ActiveProgramSlots;
__instance.maxActiveStrategies = ProgramHandler.Instance.MaxProgramSlots;
}

[HarmonyPrefix]
Expand Down Expand Up @@ -252,7 +252,7 @@ internal static bool Prefix_CreateActiveStratList(Administration __instance)
_strategies.Clear();

FixProgramCounts(__instance);
__instance.activeStratCount.text = Localizer.Format("#autoLOC_439627", ProgramHandler.Instance.ActivePrograms.Count, ProgramHandler.Instance.ActiveProgramLimit);
__instance.UpdateStrategyCount();

return false;
}
Expand Down Expand Up @@ -386,8 +386,10 @@ internal static void OnActivateProgramConfirm()
{
var newActiveStrat = Administration.Instance.SelectedWrapper.strategy;
AdminExtender.Instance.SetTabView(AdministrationActiveTabView.Active);
Administration.StrategyWrapper selectedStrategy = Administration.Instance.AddActiveStratItem(Administration.Instance.SelectedWrapper.strategy);
Administration.Instance.SetSelectedStrategy(selectedStrategy);
Administration.Instance.scrollListActive.AddItem(Administration.Instance.CreateActiveStratItem(Administration.Instance.SelectedWrapper.strategy, out var wrapper));
Administration.Instance.SetSelectedStrategy(wrapper);
FixProgramCounts(Administration.Instance);
Administration.Instance.UpdateStrategyCount();
// Reset program speeds - safe because we early-out if a program is active or complete.
foreach (var strat in StrategySystem.Instance.Strategies)
{
Expand Down Expand Up @@ -531,7 +533,7 @@ internal static void Prefix_OnAcceptConfirm(Administration __instance)
[HarmonyPatch("UpdateStrategyCount")]
internal static bool Prefix_UpdateStrategyCount(Administration __instance)
{
__instance.activeStratCount.text = Localizer.Format("#autoLOC_439627", ProgramHandler.Instance.ActivePrograms.Count, ProgramHandler.Instance.ActiveProgramLimit);
__instance.activeStratCount.text = Localizer.Format("#autoLOC_439627", ProgramHandler.Instance.ActiveProgramSlots, ProgramHandler.Instance.MaxProgramSlots);
return false;
}
}
Expand Down
2 changes: 1 addition & 1 deletion Source/Harmony/Strategy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ internal static void Prefix_CanBeActivated(Strategies.Strategy __instance)
[HarmonyPatch("CanBeActivated")]
internal static void Postfix_CanBeActivated()
{
KSP.UI.Screens.Administration.Instance.activeStrategyCount = ProgramHandler.Instance.ActivePrograms.Count;
KSP.UI.Screens.Administration.Instance.activeStrategyCount = ProgramHandler.Instance.ActiveProgramSlots;
}

// For our Strategy class, replace the basic Activate with a virtual one.
Expand Down
8 changes: 7 additions & 1 deletion Source/Programs/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,12 @@ public static double RepPenaltyPerYearLateCalc(Speed spd, double pen)
}

[Persistent(isPersistant = false)]
public float repToConfidence = -1f;
private float repToConfidence = -1f;
public float RepToConfidence => repToConfidence >= 0f ? repToConfidence : ProgramHandler.Settings.repToConfidence;

[Persistent(isPersistant = false)]
public int slots = 2;

public List<string> programsToDisableOnAccept = new List<string>();

public List<string> optionalContracts = new List<string>();
Expand Down Expand Up @@ -191,6 +194,7 @@ public Program(Program toCopy) : this()
speed = toCopy.speed;
confidenceCosts = toCopy.confidenceCosts;
repToConfidence = toCopy.repToConfidence;
slots = toCopy.slots;
}

public override string ToString() => $"{name} ({(IsComplete ? "Complete" : IsActive ? "Active" : "Inactive")})";
Expand Down Expand Up @@ -464,6 +468,8 @@ public string GetDescription(bool extendedInfo)
text += $"\n\n{Localizer.Format("#rp0_Admin_Program_ConfidenceRequired", DisplayConfidenceCost.ToString("N0"))}";
}

text = $"Slots Taken: {slots}\n\n{text}";

var leadersUnlockedByThis = StrategySystem.Instance.SystemConfig.Strategies
.OfType<StrategyConfigRP0>()
.Where(s => s.DepartmentName != "Programs" &&
Expand Down
Loading