This repository has been archived by the owner on Mar 29, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove the creation of instances in contructors as it creates errors when running other configs not launching the game. Add implementation for influential trader perk
- Loading branch information
Showing
11 changed files
with
109 additions
and
98 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 6 additions & 15 deletions
21
src/CommunityPatch/Patches/Perks/Cunning/Scouting/DesertLorePatch.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,24 @@ | ||
using Patches; | ||
using TaleWorlds.CampaignSystem; | ||
using TaleWorlds.Core; | ||
using static TaleWorlds.Core.TerrainType; | ||
|
||
namespace CommunityPatch.Patches.Perks.Cunning.Scouting { | ||
|
||
public class DesertLorePatch : PerkPatchBase<DesertLorePatch>, IPartySpeed, IDailyFoodConsumption { | ||
public class DesertLorePatch : ScoutingLorePerk<DesertLorePatch> { | ||
|
||
private readonly IDailyFoodConsumption _halfDailyFoodConsumption; | ||
private readonly IPartySpeed _modifyPartySpeed; | ||
|
||
public DesertLorePatch() : base("EeQv1qRD") { | ||
_halfDailyFoodConsumption = new HalfDailyFoodConsumption(Perk); | ||
_modifyPartySpeed = new ModifyPartySpeed(Perk); | ||
} | ||
public DesertLorePatch() : base("EeQv1qRD") { } | ||
|
||
public override void Apply(Game game) { | ||
Perk.SetPrimaryBonus(0.05f); | ||
base.Apply(game); | ||
} | ||
|
||
public void ModifyFinalSpeed(MobileParty mobileParty, float baseSpeed, ref ExplainedNumber finalSpeed) { | ||
if (mobileParty.IsInTerrainType(Desert)) | ||
_modifyPartySpeed.ModifyFinalSpeed(mobileParty, baseSpeed, ref finalSpeed); | ||
public override void ModifyFinalSpeed(MobileParty mobileParty, float baseSpeed, ref ExplainedNumber finalSpeed) { | ||
if (!mobileParty.IsInTerrainType(Desert)) | ||
return; | ||
base.ModifyFinalSpeed(mobileParty, baseSpeed, ref finalSpeed); | ||
} | ||
|
||
public void ModifyDailyFoodConsumption(ref float dailyFoodConsumption, MobileParty mobileParty, StatExplainer dailyFoodConsumptionExplanation) | ||
=> _halfDailyFoodConsumption.ModifyDailyFoodConsumption(ref dailyFoodConsumption, mobileParty, dailyFoodConsumptionExplanation); | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 7 additions & 15 deletions
22
src/CommunityPatch/Patches/Perks/Cunning/Scouting/ForestLorePatch.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,25 @@ | ||
using Patches; | ||
using TaleWorlds.CampaignSystem; | ||
using TaleWorlds.Core; | ||
using static TaleWorlds.Core.TerrainType; | ||
|
||
namespace CommunityPatch.Patches.Perks.Cunning.Scouting { | ||
|
||
public class ForestLorePatch : PerkPatchBase<ForestLorePatch>, IPartySpeed, IDailyFoodConsumption { | ||
public class ForestLorePatch : ScoutingLorePerk<ForestLorePatch> { | ||
|
||
private readonly IDailyFoodConsumption _halfDailyFoodConsumption; | ||
private readonly IPartySpeed _modifyPartySpeed; | ||
|
||
public ForestLorePatch() : base("TgOwisdD") { | ||
_halfDailyFoodConsumption = new HalfDailyFoodConsumption(Perk); | ||
_modifyPartySpeed = new ModifyPartySpeed(Perk); | ||
} | ||
public ForestLorePatch() : base("TgOwisdD") { } | ||
|
||
public override void Apply(Game game) { | ||
Perk.SetPrimaryBonus(0.05f); | ||
base.Apply(game); | ||
} | ||
|
||
public void ModifyFinalSpeed(MobileParty mobileParty, float baseSpeed, ref ExplainedNumber finalSpeed) { | ||
if (mobileParty.IsInTerrainType(Forest)) | ||
_modifyPartySpeed.ModifyFinalSpeed(mobileParty, baseSpeed, ref finalSpeed); | ||
public override void ModifyFinalSpeed(MobileParty mobileParty, float baseSpeed, ref ExplainedNumber finalSpeed) { | ||
if (!mobileParty.IsInTerrainType(Forest)) | ||
return; | ||
|
||
base.ModifyFinalSpeed(mobileParty, baseSpeed, ref finalSpeed); | ||
} | ||
|
||
public void ModifyDailyFoodConsumption(ref float dailyFoodConsumption, MobileParty mobileParty, StatExplainer dailyFoodConsumptionExplanation) | ||
=> _halfDailyFoodConsumption.ModifyDailyFoodConsumption(ref dailyFoodConsumption, mobileParty, dailyFoodConsumptionExplanation); | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 7 additions & 14 deletions
21
src/CommunityPatch/Patches/Perks/Cunning/Scouting/HillsLorePatch.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,25 @@ | ||
using Patches; | ||
using TaleWorlds.CampaignSystem; | ||
using TaleWorlds.Core; | ||
|
||
namespace CommunityPatch.Patches.Perks.Cunning.Scouting { | ||
|
||
public class HillsLorePatch : PerkPatchBase<HillsLorePatch>, IPartySpeed, IDailyFoodConsumption { | ||
public class HillsLorePatch : ScoutingLorePerk<HillsLorePatch> { | ||
|
||
private readonly IDailyFoodConsumption _halfDailyFoodConsumption; | ||
private readonly IPartySpeed _modifyPartySpeed; | ||
|
||
public HillsLorePatch() : base("67UGQ0Kd") { | ||
_halfDailyFoodConsumption = new HalfDailyFoodConsumption(Perk); | ||
_modifyPartySpeed = new ModifyPartySpeed(Perk); | ||
} | ||
public HillsLorePatch() : base("67UGQ0Kd") { } | ||
|
||
public override void Apply(Game game) { | ||
Perk.SetPrimaryBonus(0.05f); | ||
base.Apply(game); | ||
} | ||
|
||
public void ModifyFinalSpeed(MobileParty mobileParty, float baseSpeed, ref ExplainedNumber finalSpeed) { | ||
if (mobileParty.IsInHillTerrain()) | ||
_modifyPartySpeed.ModifyFinalSpeed(mobileParty, baseSpeed, ref finalSpeed); | ||
public override void ModifyFinalSpeed(MobileParty mobileParty, float baseSpeed, ref ExplainedNumber finalSpeed) { | ||
if (!mobileParty.IsInHillTerrain()) | ||
return; | ||
|
||
base.ModifyFinalSpeed(mobileParty, baseSpeed, ref finalSpeed); | ||
} | ||
|
||
public void ModifyDailyFoodConsumption(ref float dailyFoodConsumption, MobileParty mobileParty, StatExplainer dailyFoodConsumptionExplanation) | ||
=> _halfDailyFoodConsumption.ModifyDailyFoodConsumption(ref dailyFoodConsumption, mobileParty, dailyFoodConsumptionExplanation); | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 7 additions & 15 deletions
22
src/CommunityPatch/Patches/Perks/Cunning/Scouting/MarshesLorePatch.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,25 @@ | ||
using Patches; | ||
using TaleWorlds.CampaignSystem; | ||
using TaleWorlds.Core; | ||
using static TaleWorlds.Core.TerrainType; | ||
|
||
namespace CommunityPatch.Patches.Perks.Cunning.Scouting { | ||
|
||
public class MarshesLorePatch : PerkPatchBase<MarshesLorePatch>, IPartySpeed, IDailyFoodConsumption { | ||
public class MarshesLorePatch : ScoutingLorePerk<MarshesLorePatch> { | ||
|
||
private readonly IDailyFoodConsumption _halfDailyFoodConsumption; | ||
private readonly IPartySpeed _modifyPartySpeed; | ||
|
||
public MarshesLorePatch() : base("ywmjNJnH") { | ||
_halfDailyFoodConsumption = new HalfDailyFoodConsumption(Perk); | ||
_modifyPartySpeed = new ModifyPartySpeed(Perk); | ||
} | ||
public MarshesLorePatch() : base("ywmjNJnH") { } | ||
|
||
public override void Apply(Game game) { | ||
Perk.SetPrimaryBonus(0.05f); | ||
base.Apply(game); | ||
} | ||
|
||
public void ModifyFinalSpeed(MobileParty mobileParty, float baseSpeed, ref ExplainedNumber finalSpeed) { | ||
if (mobileParty.IsInTerrainType(Swamp) || mobileParty.IsInTerrainType(ShallowRiver)) | ||
_modifyPartySpeed.ModifyFinalSpeed(mobileParty, baseSpeed, ref finalSpeed); | ||
public override void ModifyFinalSpeed(MobileParty mobileParty, float baseSpeed, ref ExplainedNumber finalSpeed) { | ||
if (!mobileParty.IsInTerrainType(Swamp) && !mobileParty.IsInTerrainType(ShallowRiver)) | ||
return; | ||
|
||
base.ModifyFinalSpeed(mobileParty, baseSpeed, ref finalSpeed); | ||
} | ||
|
||
public void ModifyDailyFoodConsumption(ref float dailyFoodConsumption, MobileParty mobileParty, StatExplainer dailyFoodConsumptionExplanation) | ||
=> _halfDailyFoodConsumption.ModifyDailyFoodConsumption(ref dailyFoodConsumption, mobileParty, dailyFoodConsumptionExplanation); | ||
|
||
} | ||
|
||
} |
31 changes: 31 additions & 0 deletions
31
src/CommunityPatch/Patches/Perks/Social/Trade/InfluentialTrader.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
using System.Linq; | ||
using TaleWorlds.CampaignSystem; | ||
using TaleWorlds.Localization; | ||
|
||
namespace CommunityPatch.Patches.Perks.Social.Trade { | ||
|
||
public class InfluentialTrader : DailyInfluenceGainSubPatch<InfluentialTrader> { | ||
|
||
public InfluentialTrader() : base("esgxog1B") { } | ||
|
||
public override void ModifyDailyInfluenceGain(Clan clan, ref ExplainedNumber influenceChange) { | ||
var perk = Perk; | ||
if (perk == null || !(clan?.Leader?.GetPerkValue(perk) ?? false)) | ||
return; | ||
|
||
var influenceBonus = 0.25f; | ||
var caravans = clan.Leader.OwnedCaravans?.Count() ?? 0f; | ||
var workshops = clan.Leader.OwnedWorkshops?.Count ?? 0f; | ||
var extraCaravanInfluence = influenceBonus * caravans; | ||
var extraWorkshopInfluence = influenceBonus * workshops; | ||
|
||
if (extraCaravanInfluence > 0) | ||
influenceChange.Add(extraCaravanInfluence, new TextObject(perk.Name + " (caravans)")); | ||
|
||
if (extraWorkshopInfluence > 0) | ||
influenceChange.Add(extraWorkshopInfluence, new TextObject(perk.Name + " (workshops)")); | ||
} | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
using Patches; | ||
using TaleWorlds.CampaignSystem; | ||
|
||
namespace CommunityPatch.Patches { | ||
|
||
public abstract class ScoutingLorePerk<TPatch> : PerkPatchBase<TPatch>, IPartySpeed, IDailyFoodConsumption where TPatch : ScoutingLorePerk<TPatch> { | ||
|
||
protected ScoutingLorePerk(string perkId) : base(perkId) { } | ||
|
||
public virtual void ModifyFinalSpeed(MobileParty mobileParty, float baseSpeed, ref ExplainedNumber finalSpeed) { | ||
IPartySpeed modifyPartySpeed = new ModifyPartySpeed(Perk); | ||
modifyPartySpeed.ModifyFinalSpeed(mobileParty, baseSpeed, ref finalSpeed); | ||
} | ||
|
||
public virtual void ModifyDailyFoodConsumption(ref float dailyFoodConsumption, MobileParty mobileParty, StatExplainer dailyFoodConsumptionExplanation) { | ||
IDailyFoodConsumption halfDailyFoodConsumption = new HalfDailyFoodConsumption(Perk); | ||
halfDailyFoodConsumption.ModifyDailyFoodConsumption(ref dailyFoodConsumption, mobileParty, dailyFoodConsumptionExplanation); | ||
} | ||
|
||
} | ||
|
||
} |