-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #254 from eg3r/dev
Relation based war declaration additions
- Loading branch information
Showing
6 changed files
with
115 additions
and
4 deletions.
There are no files selected for viewing
42 changes: 42 additions & 0 deletions
42
src/Bannerlord.Diplomacy/DiplomaticAction/GenericConditions/BadRelationCondition.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,42 @@ | ||
using Diplomacy.Extensions; | ||
|
||
using TaleWorlds.CampaignSystem; | ||
using TaleWorlds.Localization; | ||
|
||
namespace Diplomacy.DiplomaticAction.GenericConditions | ||
{ | ||
internal sealed class BadRelationCondition : IDiplomacyCondition | ||
{ | ||
public bool ApplyCondition(Kingdom kingdom, | ||
Kingdom otherKingdom, | ||
out TextObject? textObject, | ||
bool forcePlayerCosts = false, | ||
bool bypassCosts = false) | ||
{ | ||
textObject = null; | ||
|
||
// if kingdom leaders are friends, do not allow war | ||
if (Settings.Instance!.NoWarBetweenFriends && kingdom.Leader.IsFriend(otherKingdom.Leader)) | ||
{ | ||
textObject = new TextObject("{=9aaZ8Ed4}Cannot declare war, kingdom leaders are friends."); | ||
return false; | ||
} | ||
|
||
// if relations are above "good" do not start wars | ||
if (Settings.Instance!.NoWarOnGoodRelations && kingdom.Leader.GetRelation(otherKingdom.Leader) >= Settings.Instance!.NoWarOnGoodRelationsThreshold) | ||
{ | ||
textObject = new TextObject("{=Zimavbgw}Cannot declare war, kingdom leaders personal relations are excellent."); | ||
return false; | ||
} | ||
|
||
// if leading clans have marriages between them => no wars | ||
if (Settings.Instance!.NoWarWhenMarriedLeaderClans && kingdom.RulingClan.HasMarriedClanLeaderRelation(otherKingdom.RulingClan)) | ||
{ | ||
textObject = new TextObject("{=pXD8Uf2e}Cannot declare war, kingdom leader clans have close family marriages."); | ||
return false; | ||
} | ||
|
||
return true; | ||
} | ||
} | ||
} |
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
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
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