-
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 #190 from DiplomacyTeam/dev
v1.2.0 release
- Loading branch information
Showing
121 changed files
with
4,255 additions
and
1,175 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
files: | ||
- source: /src/Bannerlord.Diplomacy/_Module/ModuleData/Languages/*.xml | ||
translation: /src/Bannerlord.Diplomacy/_Module/ModuleData/Languages/%two_letters_code%/%original_file_name% | ||
content_segmentation: 0 | ||
translatable_elements: | ||
- '/base/tags/tag[@language],/base/strings/string[@text]' | ||
- '/LanguageData[@id],/LanguageData[@name],/LanguageData[@subtitle_extension],/LanguageData[@supported_iso],/LanguageData/LanguageFile[@xml_path]' |
34 changes: 34 additions & 0 deletions
34
src/Bannerlord.Diplomacy/Actions/DestroyKingdomSoftlyAction.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,34 @@ | ||
using System.Linq; | ||
|
||
using TaleWorlds.CampaignSystem; | ||
using TaleWorlds.CampaignSystem.Actions; | ||
|
||
namespace Diplomacy.Actions | ||
{ | ||
public static class DestroyKingdomSoftlyAction | ||
{ | ||
public static void Apply(Kingdom kingdomToDestroy) | ||
{ | ||
//Cold be already eliminated via CW or other mods | ||
if (kingdomToDestroy.IsEliminated) | ||
return; | ||
|
||
foreach (Clan clan in kingdomToDestroy.Clans.ToList()) | ||
{ | ||
if (!clan.IsEliminated) | ||
{ | ||
if (clan.IsUnderMercenaryService) | ||
{ | ||
ChangeKingdomAction.ApplyByLeaveKingdomAsMercenary(clan); | ||
} | ||
else | ||
{ | ||
ChangeKingdomAction.ApplyByLeaveKingdom(clan); | ||
} | ||
} | ||
} | ||
//Check again! | ||
if (!kingdomToDestroy.IsEliminated) DestroyKingdomAction.Apply(kingdomToDestroy); | ||
} | ||
} | ||
} |
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
93 changes: 93 additions & 0 deletions
93
src/Bannerlord.Diplomacy/Actions/GiveGoldToKingdomAction.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,93 @@ | ||
using TaleWorlds.CampaignSystem; | ||
using TaleWorlds.CampaignSystem.Actions; | ||
using TaleWorlds.Library; | ||
|
||
namespace Diplomacy.Actions | ||
{ | ||
public static class GiveGoldToKingdomAction | ||
{ | ||
private static void ApplyInternal(Kingdom? giverKingdom, Kingdom? receiverKingdom, int amount, WalletType giverWallet, WalletType receiverWallet) | ||
{ | ||
if (amount == 0) | ||
return; | ||
|
||
if (giverKingdom != null) | ||
{ | ||
switch (giverWallet) | ||
{ | ||
case WalletType.TributeWallet: | ||
giverKingdom.TributeWallet -= amount; | ||
break; | ||
case WalletType.BudgetWallet: | ||
//Leaders should benefit from those payments too | ||
var leaderAmount = amount < 0 ? amount / 3 : 0; | ||
if (leaderAmount > 0) GiveGoldAction.ApplyBetweenCharacters(null, giverKingdom.Leader, leaderAmount); | ||
giverKingdom.KingdomBudgetWallet -= (amount - leaderAmount); | ||
break; | ||
default: | ||
break; | ||
} | ||
} | ||
if (receiverKingdom != null) | ||
{ | ||
switch (receiverWallet) | ||
{ | ||
case WalletType.TributeWallet: | ||
receiverKingdom.TributeWallet += amount; | ||
break; | ||
case WalletType.BudgetWallet: | ||
//Leaders should benefit from those payments too | ||
var leaderAmount = amount > 0 ? amount / 3 : 0; | ||
if (leaderAmount > 0) GiveGoldAction.ApplyBetweenCharacters(null, receiverKingdom.Leader, leaderAmount); | ||
receiverKingdom.KingdomBudgetWallet += (amount - leaderAmount); | ||
break; | ||
default: | ||
break; | ||
} | ||
} | ||
} | ||
|
||
private static void ApplyInternal(Hero? giverHero, Kingdom? kingdom, int goldAmount) | ||
{ | ||
if (giverHero != null) | ||
{ | ||
GiveGoldAction.ApplyBetweenCharacters(giverHero, null, goldAmount, true); | ||
} | ||
if (kingdom != null) | ||
{ | ||
GiveGoldToKingdom(goldAmount, kingdom); | ||
} | ||
} | ||
|
||
private static void GiveGoldToKingdom(int gold, Kingdom kingdom) | ||
{ | ||
foreach ((var recipientClan, var amount) in MBMath.DistributeShares(gold, kingdom.Clans, CalculateShare)) | ||
{ | ||
GiveGoldToClanAction.ApplyToClan(recipientClan, amount); | ||
} | ||
} | ||
|
||
private static int CalculateShare(Clan clan) | ||
{ | ||
return (int) clan.TotalStrength + (clan == clan.Kingdom?.Leader?.Clan ? 1000 : 10); | ||
} | ||
|
||
public static void ApplyFromHeroToKingdom(Hero giverHero, Kingdom kingdom, int amount) | ||
{ | ||
ApplyInternal(giverHero, kingdom, amount); | ||
} | ||
|
||
public static void ApplyFromWalletToWallet(Kingdom? giverKingdom, Kingdom? receiverKingdom, int amount, WalletType giverWallet = WalletType.TributeWallet, WalletType receiverWallet = WalletType.BudgetWallet) | ||
{ | ||
ApplyInternal(giverKingdom, receiverKingdom, amount, giverWallet, receiverWallet); | ||
} | ||
|
||
public enum WalletType : byte | ||
{ | ||
None = 0, | ||
MercenaryWallet = 1, | ||
TributeWallet = 2, | ||
BudgetWallet = 3, | ||
} | ||
} | ||
} |
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
Oops, something went wrong.