//--------------------------------------------------------- /// <summary> /// this is for: <see cref="LabelControlSpecies.RankingBackGroundLabel"/> /// </summary> /// <param name="myRes"></param> /// <param name="father"></param> /// <param name="activeRankingLabel"></param> /// <param name="kingdomInfo"></param> public RankingBackGroundLabel(IRes myRes, SandBoxBase father, RankingKindLabel activeRankingLabel, KingdomInfo kingdomInfo) : base(myRes, LabelControlSpecies.RankingBackGroundLabel, father) { ActiveKindRankingLabel = activeRankingLabel; KingdomInfo = kingdomInfo; Initialize_ForRankingBackGround_Component(); }
//-------------------------------------------------- #region Constructors Region /// <summary> /// Create new instance of this KingdomInfoSandBox. /// </summary> /// <param name="myBackPage"> /// it is either <see cref="ThereIsConstants.Forming.GameClient"/>, /// or .. /// </param> /// <param name="IsPreview"></param> public KingdomInfoSandBox(GameControls.PageControl myBackPage, KingdomInfo myKingdomInfo, bool isPreview = true) : base(myBackPage) { Mode = SandBoxMode.KingdomInfoMode; IsPreview = isPreview; KingdomInfo = myKingdomInfo; InitializeComponent(); }
public PlayerActionResult Execute() { if (!CheckMP()) { return(new PlayerActionResult(false, ResultType.NoMovement)); } KingdomInfo kingdom = new KingdomInfo(Action.player); return(new PlayerActionResult(true, ResultType.Success, kingdom1: kingdom)); }
private void UpdatePlotState(KingdomInfo kingdomInfo, List <Clan> clans) { foreach (var clan in clans) { var clanLeader = clan.Leader; var clanLeaderInfo = Managers.Character.Get(clanLeader.CharacterObject); if (clanLeaderInfo.PlotState != PlotState.WillPlotting) { continue; } clanLeaderInfo.PlotState = PlotState.IsPlotting; if (RevolutionsSettings.Instance.DebugMode) { InformationManager.DisplayMessage(new InformationMessage($"Revolutions.CivilWars: {clanLeader.Name} ({clanLeader.Clan.Name}) is plotting.", ColorHelper.Gray)); } } }
private async void KingdomMapSigner_Click(object sender, EventArgs e) { if (sender is GameControls.MapSigner mySigner) { if (TheMap.MapDisplayer != null) { TheMap.MapDisplayer.Dispose(); TheMap.MapDisplayer = null; } this.ShowingSandBox = this.LoadingSandBox = new YuiLoadingSandbox(this); this.LoadingSandBox.Show(); this.IsShowingSandBox = true; TheMap.MapDisplayer = mySigner.MapDisplayer = new GameControls.MapSigner(this, mySigner.CurrentStatus, GameControls.LabelControlSpecies.MapDisplayer); mySigner.MapDisplayer.CurrentStatus = mySigner.CurrentStatus; mySigner.MapDisplayer.Location = new Point(mySigner.Location.X + (mySigner.Width / 2) - (mySigner.MapDisplayer.Width / 2), mySigner.Location.Y - mySigner.MapDisplayer.Height - (NoInternetConnectionSandBox.from_the_edge / 4)); ThereIsServer.GameObjects.MyProfile.KingdomInfo = await KingdomInfo.GetKingdomInfo(mySigner.MapDisplayer.CurrentStatus); this.LoadingSandBox.Close(true); this.ShowingSandBox = this.LoadingSandBox = null; this.IsShowingSandBox = false; mySigner.MapDisplayer.MessageLabel2.Text += ThereIsServer.GameObjects.MyProfile.KingdomInfo.KingdomName.GetValue(); mySigner.MapDisplayer.MessageLabel1.AddClickEventToAllChild(KingdomMapSignerInfoLabel_Click); this.Controls.Add(mySigner.MapDisplayer); mySigner.HasMouseClickedOnce = false; } else { throw new Exception(); } }
private bool CheckPlayerPlotState(KingdomInfo kingdomInfo) { if (kingdomInfo.Id == Hero.MainHero.Clan.Kingdom?.StringId && kingdomInfo.Kingdom.Leader != Hero.MainHero) { if (EventManager.Instance.InEvent) { return(true); } var mainHeroInfo = Managers.Character.Get(Hero.MainHero.CharacterObject); if (this._daysSinceConsider >= RevolutionsSettings.Instance.CivilWarsPlottingConsiderTime && mainHeroInfo.PlotState == PlotState.Considering && mainHeroInfo.DecisionMade == DecisionMade.No) { new PlottingEvent(); this._daysSinceConsider = 0; } else { this._daysSinceConsider++; } } return(false); }
private bool CheckWarState(KingdomInfo kingdomInfo, List <Clan> clans) { var loyalClans = new List <Clan>(); var plottingClans = new List <Clan>(); foreach (var clan in clans) { var clanLeader = clan.Leader; var clanLeaderInfo = Managers.Character.Get(clanLeader.CharacterObject); if (clanLeaderInfo.PlotState == PlotState.IsLoyal) { loyalClans.Add(clan); } else if (clanLeaderInfo.PlotState == PlotState.IsPlotting) { plottingClans.Add(clan); } } if (plottingClans.Count == 0) { if (RevolutionsSettings.Instance.DebugMode) { InformationManager.DisplayMessage(new InformationMessage($"Revolutions.CivilWars: There are no plotting clans.", ColorHelper.Gray)); } return(true); } var loyalTroopWeight = kingdomInfo.Kingdom.RulingClan.TotalStrength; foreach (var loyalClan in loyalClans) { loyalTroopWeight += loyalClan.TotalStrength; } var plottersTroopWeight = 0f; foreach (var plotterClan in plottingClans) { plottersTroopWeight += plotterClan.TotalStrength; } var plotLeadingClan = plottingClans.OrderByDescending(go => go.Tier).FirstOrDefault(); if (plotLeadingClan == null) { return(true); } var kingdomLeader = kingdomInfo.Kingdom.Leader; var plottingLeader = plotLeadingClan.Leader; var kingdomLeaderGenerosity = kingdomLeader.GetHeroTraits().Generosity; var kingdomLeaderMercy = kingdomLeader.GetHeroTraits().Mercy; var kingdomLeaderValor = kingdomLeader.GetHeroTraits().Valor; var kingdomLeaderCalculating = kingdomLeader.GetHeroTraits().Calculating; var plottingLeaderGenerosity = plottingLeader.GetHeroTraits().Generosity; var plottingLeaderMercy = plottingLeader.GetHeroTraits().Mercy; var plottingLeaderValor = plottingLeader.GetHeroTraits().Valor; var plottingLeaderCalculating = plottingLeader.GetHeroTraits().Calculating; float personalityTraits = plottingLeaderGenerosity + kingdomLeaderGenerosity + plottingLeaderMercy + kingdomLeaderMercy; var personalityWeight = MathF.Pow(RevolutionsSettings.Instance.CivilWarsWarPersonalityMultiplier, -personalityTraits); var troopWeight = plottersTroopWeight / loyalTroopWeight; float valorModifier = 1 + (plottingLeaderValor <= 0 ? 1 : plottingLeaderValor * 2); float clanCountModifier = plottingClans.Count / (loyalClans.Count + 1); float calculatingModifier = 1 + (plottingLeaderCalculating <= 0 ? 1 : plottingLeaderCalculating); var warChance = RevolutionsSettings.Instance.CivilWarsWarBaseChance * personalityWeight * (troopWeight * valorModifier) * MathF.Pow(clanCountModifier, calculatingModifier); if (RevolutionsSettings.Instance.DebugMode) { InformationManager.DisplayMessage(new InformationMessage($"Revolutions.CivilWars: War Chance is {warChance}%.", ColorHelper.Gray)); } if (warChance > new Random().Next(0, 100)) { if (kingdomInfo.Id == Hero.MainHero.Clan.Kingdom?.StringId && EventManager.Instance.InEvent) { return(true); } if (kingdomInfo.Id == Hero.MainHero.Clan.Kingdom?.StringId && kingdomLeader.StringId != Hero.MainHero.StringId) { new WarEvent(); } loyalClans.Clear(); plottingClans.Clear(); foreach (var clan in clans) { var clanLeader = clan.Leader; var clanLeaderInfo = Managers.Character.Get(clanLeader.CharacterObject); if (clanLeaderInfo.PlotState == PlotState.IsLoyal) { loyalClans.Add(clan); } else if (clanLeaderInfo.PlotState == PlotState.IsPlotting) { plottingClans.Add(clan); } } if (plottingClans.Count == 0) { if (RevolutionsSettings.Instance.DebugMode) { InformationManager.DisplayMessage(new InformationMessage($"Revolutions.CivilWars: There are no plotting clans.", ColorHelper.Gray)); } return(true); } Managers.Character.Get(plottingLeader.CharacterObject).IsCivilWarKingdomLeader = true; var settlementInfo = Managers.Settlement.Get(plotLeadingClan.HomeSettlement); var bannerInfo = Managers.Banner.GetBanner(settlementInfo); var textObject = new TextObject(Localization.GameTexts.CivilWarsKingdom); textObject.SetTextVariable("CLAN", plottingLeader.Name); var plotKingdom = Managers.Kingdom.CreateKingdom(plotLeadingClan.Leader, textObject, textObject, bannerInfo != null ? new Banner(bannerInfo.BannerId) : plotLeadingClan.Banner, false); Managers.Kingdom.Get(plotKingdom).IsCivilWarKingdom = true; ChangeRelationAction.ApplyRelationChangeBetweenHeroes(plottingLeader, kingdomLeader, -(int)(RevolutionsSettings.Instance.CivilWarsRelationshipChange * (RevolutionsSettings.Instance.CivilWarsRelationshipChangeMultiplier * 2)), false); foreach (var clan1 in clans.Where(c1 => c1.StringId != plotLeadingClan.StringId)) { var clanLeader1 = Managers.Character.Get(clan1.Leader.CharacterObject); if (clanLeader1.PlotState == PlotState.IsLoyal) { ChangeRelationAction.ApplyRelationChangeBetweenHeroes(clan1.Leader, kingdomLeader, (int)(RevolutionsSettings.Instance.CivilWarsRelationshipChange * RevolutionsSettings.Instance.CivilWarsRelationshipChangeMultiplier), false); ChangeRelationAction.ApplyRelationChangeBetweenHeroes(clan1.Leader, plottingLeader, -(int)(RevolutionsSettings.Instance.CivilWarsRelationshipChange * RevolutionsSettings.Instance.CivilWarsRelationshipChangeMultiplier), false); } else if (clanLeader1.PlotState == PlotState.IsPlotting) { ChangeRelationAction.ApplyRelationChangeBetweenHeroes(clan1.Leader, plottingLeader, (int)(RevolutionsSettings.Instance.CivilWarsRelationshipChange * RevolutionsSettings.Instance.CivilWarsRelationshipChangeMultiplier), false); ChangeRelationAction.ApplyRelationChangeBetweenHeroes(clan1.Leader, kingdomLeader, -(int)(RevolutionsSettings.Instance.CivilWarsRelationshipChange * RevolutionsSettings.Instance.CivilWarsRelationshipChangeMultiplier), false); } foreach (var clan2 in clans.Where(c2 => c2.StringId != clan1.StringId && c2.StringId != plotLeadingClan.StringId)) { var clanLeader2 = Managers.Character.Get(clan2.Leader.CharacterObject); if (clanLeader1.PlotState == clanLeader2.PlotState) { ChangeRelationAction.ApplyRelationChangeBetweenHeroes(clan1.Leader, clan2.Leader, RevolutionsSettings.Instance.CivilWarsRelationshipChange, false); } else { ChangeRelationAction.ApplyRelationChangeBetweenHeroes(clan1.Leader, clan2.Leader, -RevolutionsSettings.Instance.CivilWarsRelationshipChange, false); } } } textObject = new TextObject(Localization.GameTexts.CivilWarsWarMapNotification); textObject.SetTextVariable("PLOTKINGDOM", plotKingdom.Name); textObject.SetTextVariable("KINGDOM", kingdomInfo.Kingdom.Name); InformationManager.AddNotice(new WarMapNotification(plotKingdom, kingdomInfo.Kingdom, textObject)); textObject = new TextObject(Localization.GameTexts.CivilWarsQuickNotification); textObject.SetTextVariable("KINGDOM", kingdomInfo.Kingdom.Name); textObject.SetTextVariable("LEADER", plotLeadingClan.Leader.Name); textObject.SetTextVariable("CLAN", plotLeadingClan.Name); InformationManager.AddQuickInformation(textObject); var otherPlottingClans = plottingClans.Where(go => go.StringId != plotLeadingClan.StringId); if (otherPlottingClans.Count() == 0) { textObject = new TextObject(Localization.GameTexts.CivilWarsLeaderAlone); textObject.SetTextVariable("LEADER", plotLeadingClan.Leader.Name); textObject.SetTextVariable("CLAN", plotLeadingClan.Name); InformationManager.DisplayMessage(new InformationMessage(textObject.ToString(), ColorHelper.Orange)); } foreach (var plottingClan in otherPlottingClans) { textObject = new TextObject(Localization.GameTexts.CivilWarsJoinsConspirators); textObject.SetTextVariable("LEADER", plottingClan.Leader.Name); textObject.SetTextVariable("CLAN", plottingClan.Name); InformationManager.DisplayMessage(new InformationMessage(textObject.ToString(), ColorHelper.Orange)); ChangeKingdomAction.ApplyByJoinToKingdom(plottingClan, plotKingdom, false); } foreach (var loyalClan in loyalClans) { textObject = new TextObject(Localization.GameTexts.CivilWarsJoinsConspirators); textObject.SetTextVariable("LEADER", loyalClan.Leader.Name); textObject.SetTextVariable("CLAN", loyalClan.Name); InformationManager.DisplayMessage(new InformationMessage(textObject.ToString(), ColorHelper.Orange)); } DeclareWarAction.Apply(plotKingdom, kingdomInfo.Kingdom); if (RevolutionsSettings.Instance.CivilWarsKeepExistingWars) { foreach (var enemyFaction in FactionManager.GetEnemyFactions(kingdomInfo.Kingdom).ToList()) { if (!enemyFaction.Equals(plotKingdom)) { DeclareWarAction.Apply(plotKingdom, enemyFaction); } } } Managers.CivilWar.CivilWars.Add(new CivilWar(kingdomInfo.Kingdom, clans)); kingdomInfo.HasCivilWar = true; } return(false); }
private void CheckPlotState(KingdomInfo kingdomInfo, List <Clan> clans) { foreach (var clan in clans) { if (clan.Leader.StringId == Hero.MainHero.StringId) { continue; } if (RevolutionsSettings.Instance.DebugMode) { InformationManager.DisplayMessage(new InformationMessage($"Revolutions.CivilWars: {clan.Name} ({clan.Leader})", ColorHelper.Gray)); } var clanLeader = clan.Leader; var clanLeaderInfo = Managers.Character.Get(clanLeader.CharacterObject); var relationDifference = clanLeader.GetRelation(kingdomInfo.Kingdom.Leader); if (clanLeaderInfo.PlotState == PlotState.IsPlotting && relationDifference > RevolutionsSettings.Instance.CivilWarsPositiveRelationshipTreshold) { clanLeaderInfo.PlotState = PlotState.IsLoyal; if (RevolutionsSettings.Instance.DebugMode) { InformationManager.DisplayMessage(new InformationMessage($"Revolutions: Is now loyal.", ColorHelper.Green)); } var clanLeaderPlottingFriends = clans.Select(go => go.Leader) .Where(go => go.IsFriend(clanLeader) && go.StringId != Hero.MainHero.StringId) .Select(go => Managers.Character.Get(go.CharacterObject)) .Where(info => info.PlotState == PlotState.IsPlotting) .ToList(); foreach (var friend in clanLeaderPlottingFriends) { if (!this.WillPlotting(friend.Character.HeroObject)) { friend.PlotState = PlotState.IsLoyal; if (RevolutionsSettings.Instance.DebugMode) { InformationManager.DisplayMessage(new InformationMessage($"Revolutions.CivilWars: Friend {friend.Character.Name} ({friend.Character.HeroObject.Clan.Name}) is now loyal.", ColorHelper.Gray)); } } } } if (relationDifference > RevolutionsSettings.Instance.CivilWarsNegativeRelationshipTreshold) { continue; } if (this.WillPlotting(clanLeader)) { clanLeaderInfo.PlotState = PlotState.WillPlotting; if (RevolutionsSettings.Instance.DebugMode) { InformationManager.DisplayMessage(new InformationMessage($"Revolutions: {clanLeader.Name} ({clanLeader.Clan.Name}) will be plotting.", ColorHelper.Gray)); } } else { if (RevolutionsSettings.Instance.DebugMode) { InformationManager.DisplayMessage(new InformationMessage($"Revolutions: {clanLeader.Name} ({clanLeader.Clan.Name}) will not be plotting.", ColorHelper.Gray)); } } clanLeader = null; clanLeaderInfo = null; } }
public PlayerActionResult(bool succ = true, ResultType result = ResultType.NotFound, ArmyInfo army1 = null, ArmyInfo army2 = null, int amount = 0, KingdomInfo kingdom1 = null) { this.succ = succ; this.resulttype = result; this.army1 = army1; this.army2 = army2; this.kingdom1 = kingdom1; this.amount = amount; }