public static bool CheckAndSignalRelevantHandlers(TransportPodsArrivalAction_GiveGift __instance, List <ActiveDropPodInfo> pods) { Settlement settlement = Traverse.Create(__instance).Field("settlement").GetValue <Settlement>(); Map mapOfSender = DesynchronizedMain.ArrivalActionAndSenderLinker.SafelyGetMapOfGivenAction(__instance); for (int i = 0; i < pods.Count; i++) { for (int j = 0; j < pods[i].innerContainer.Count; j++) { Pawn pawn = pods[i].innerContainer[j] as Pawn; if (pawn == null) { continue; } } } FactionGiftUtility.GiveGift(pods, settlement); // Original method need not be called. return(false); }
public void TestSettlement() { Customer merchant = createPersonCustomer(); Account payableAccount = merchant.PayableAccount(); BankAccount ba = createBankAccount(); ba.AssociateToCustomer(merchant); Order order = merchant.CreateOrder(null); Card card = createCard(); Dictionary <string, object> debitPayload = new Dictionary <string, object>(); debitPayload.Add("description", "Debit for Order #234123"); debitPayload.Add("amount", 5000); Debit debit = order.DebitFrom(card, debitPayload); Dictionary <string, object> creditPayload = new Dictionary <string, object>(); creditPayload.Add("description", "Payout for Order #234123"); creditPayload.Add("amount", 5000); creditPayload.Add("order", order.href); Credit credit = payableAccount.Credit(creditPayload); payableAccount.Reload(); Assert.AreEqual(payableAccount.balance, 5000); Dictionary <string, object> settlementPayload = new Dictionary <string, object>(); settlementPayload.Add("description", "Payout for Order #234123"); settlementPayload.Add("funding_instrument", ba.href); Settlement settlement = payableAccount.Settle(settlementPayload); payableAccount.Reload(); Assert.AreEqual(0, payableAccount.balance); Assert.AreEqual(5000, settlement.amount); }
public static float GetSettlementAdvantage(Settlement settlement) { if (settlement.SiegeEvent != null && settlement.IsFortification) { int wallLevel = settlement.Town.GetWallLevel(); bool flag = false; int num1 = 0; int num2 = 0; int num3 = 0; foreach (SiegeEvent.SiegeEngineConstructionProgress allSiegeEngine in settlement.SiegeEvent.GetSiegeEventSide(BattleSideEnum.Attacker).SiegeEngines.AllSiegeEngines()) { if (allSiegeEngine.IsConstructed) { if (allSiegeEngine.SiegeEngine == DefaultSiegeEngineTypes.Ram) { flag = true; } else if (allSiegeEngine.SiegeEngine == DefaultSiegeEngineTypes.SiegeTower) { ++num1; } else if (allSiegeEngine.SiegeEngine == DefaultSiegeEngineTypes.Trebuchet || allSiegeEngine.SiegeEngine == DefaultSiegeEngineTypes.Onager || allSiegeEngine.SiegeEngine == DefaultSiegeEngineTypes.Ballista) { ++num2; } else if (allSiegeEngine.SiegeEngine == DefaultSiegeEngineTypes.FireOnager || allSiegeEngine.SiegeEngine == DefaultSiegeEngineTypes.FireBallista) { ++num3; } } } float num4 = (float)(2.0 + (double)(wallLevel - 1) * 0.5); if ((double)settlement.SettlementTotalWallHitPoints < 9.99999974737875E-06) { num4 *= 0.25f; } return((float)((1.0 + (double)num4) / Math.Sqrt(1.0 + (flag | num1 > 0 ? 0.300000011920929 : 0.0) + (flag ? 0.4 : 0.0) + (num1 > 1 ? 0.449999988079071 : (num1 == 1 ? 0.300000011920929 : 0.0)) + (double)num2 * 0.200000002980232 + (double)num3 * 0.300000011920929))); } return(settlement.IsVillage ? 1.25f : 1f); }
private static bool Prefix( MobileParty side1Party, Settlement side2Party, CharacterObject subject, ref int number) { TroopRoster troopRoster; if (side1Party == null) { troopRoster = (TroopRoster)null; } else { Hero leaderHero = side1Party.LeaderHero; troopRoster = leaderHero != null?leaderHero.getTemplate() : (TroopRoster)null; } if (!(troopRoster != (TroopRoster)null)) { return(true); } int troopCount = side1Party.LeaderHero.getTemplate().GetTroopCount(subject); if (side1Party.Party.PartySizeLimit <= side1Party.Party.NumberOfAllMembers || troopCount == 0) { return(false); } if (troopCount == 1) { return(true); } int val2 = troopCount - side1Party.MemberRoster.GetTroopCount(subject); if (val2 <= 0) { return(false); } number = Math.Min(number, val2); return(true); }
public static MobileParty CreateBanditParty(string cultureObjectID = null, string partyName = null) { MobileParty banditParty = null; try { List <Settlement> hideouts = Settlement.FindAll((s) => { return(s.IsHideout()); }).ToList(); Settlement closestHideout = hideouts.MinBy((s) => { return(MobileParty.MainParty.GetPosition().DistanceSquared(s.GetPosition())); }); CultureObject banditCultureObject = null; if (cultureObjectID != null) { banditCultureObject = MBObjectManager.Instance.GetObject <CultureObject>(cultureObjectID); } else { banditCultureObject = closestHideout.Culture; } if (partyName == null) { partyName = $"{banditCultureObject.Name} (Random Event)"; } PartyTemplateObject partyTemplate = MBObjectManager.Instance.GetObject <PartyTemplateObject>($"{banditCultureObject.StringId}_template"); banditParty = MBObjectManager.Instance.CreateObject <MobileParty>($"randomevent_{banditCultureObject.StringId}_{MBRandom.RandomInt(int.MaxValue)}"); TextObject partyNameTextObject = new TextObject(partyName, null); Clan banditClan = Clan.BanditFactions.FirstOrDefault(clan => clan.StringId == banditCultureObject.StringId); banditParty.InitializeMobileParty(partyTemplate, MobileParty.MainParty.Position2D, 0.2f, 0.1f); banditParty.SetCustomName(partyNameTextObject); banditParty.HomeSettlement = closestHideout; } catch (Exception ex) { MessageBox.Show($"Error while trying to create a mobile bandit party :\n\n {ex.Message} \n\n { ex.StackTrace}"); } return(banditParty); }
public void InitializeCult(Pawn newFounder) { var map = newFounder.Map; founder = newFounder; leader = newFounder; foundingFaction = newFounder.Faction; foundingCity = Find.WorldObjects.SettlementAt(newFounder.Map.Tile); influences = new List <CultInfluence>(); foreach (var set in Find.WorldObjects.Settlements) { if (set == foundingCity) { influences.Add(new CultInfluence(set, 1.0f)); } else { influences.Add(new CultInfluence(set, 0.0f)); } } active = true; Find.World.GetComponent <WorldComponent_GlobalCultTracker>().worldCults.Add(this); if (foundingFaction == Faction.OfPlayerSilentFail) { SendCultLetterFounded(newFounder); //It's a day to remember var taleToAdd = TaleDef.Named("FoundedCult"); if ((newFounder.IsColonist || newFounder.HostFaction == Faction.OfPlayer) && taleToAdd != null) { TaleRecorder.RecordTale(taleToAdd, newFounder); } //The founder will remember that, too. newFounder.needs.mood.thoughts.memories.TryGainMemory(CultsDefOf.Cults_FoundedCult); map.GetComponent <MapComponent_LocalCultTracker>().ResolveTerribleCultFounder(newFounder); } }
public void SendFirstMeetingDialog(Pawn imperial) { Settlement playerSettlement = imperial.Map.info.parent as Settlement; string text = "PJ_ImperialGreeting".Translate(imperial.Name.ToStringFull, imperial.kindDef.label, playerSettlement.Label, empireLandRightsTax.ToString(), empireTaxRate.ToStringPercent()); DiaNode diaNode = new DiaNode(text); DiaOption diaOption = new DiaOption("PJ_ImperialGreeting_Accept".Translate()); diaOption.action = delegate { taxedColony = true; }; diaOption.resolveTree = true; diaNode.options.Add(diaOption); string text2 = "PJ_ImperialGreeting_Rejected".Translate( imperial.LabelShort ); DiaNode diaNode2 = new DiaNode(text2); DiaOption diaOption2 = new DiaOption("OK".Translate()); diaOption2.resolveTree = true; diaNode2.options.Add(diaOption2); DiaOption diaOption3 = new DiaOption("PJ_ImperialGreeting_Reject".Translate()); diaOption3.action = delegate { ResolveDeclarationOfHostility(imperial); }; diaOption3.link = diaNode2; diaNode.options.Add(diaOption3); string title = "PJ_ImperialGreeting_Title".Translate(); Find.WindowStack.Add(new Dialog_NodeTree(diaNode, true, true, title)); }
public static Vec2 GetSettlementLoc() //This is to get the vector of a HC settlement...Possible Todo Home town { Vec2 sresult; Settlement settlement; string sCulture = Hero.MainHero.MapFaction.Culture.StringId; switch (sCulture) { case "sturgia": settlement = Settlement.Find("town_S2"); sresult = settlement.GatePosition; break; case "aserai": settlement = Settlement.Find("town_A8"); sresult = settlement.GatePosition; break; case "vlandia": settlement = Settlement.Find("town_V3"); sresult = settlement.GatePosition; break; case "battania": settlement = Settlement.Find("town_B2"); sresult = settlement.GatePosition; break; case "khuzait": settlement = Settlement.Find("town_K4"); sresult = settlement.GatePosition; break; default: settlement = Settlement.Find("tutorial_training_field"); sresult = settlement.GatePosition; break; } return(sresult); }
private bool game_menu_enter_practice_fight_on_condition(MenuCallbackArgs args) { Settlement currentSettlement = Settlement.CurrentSettlement; ArenaMaster am = (ArenaMaster)Campaign.Current.GetCampaignBehavior <ArenaMaster>(); FieldInfo knowTournaments = typeof(ArenaMaster).GetField("_knowTournaments", BindingFlags.NonPublic | BindingFlags.Instance); args.optionLeaveType = GameMenuOption.LeaveType.HostileAction; if (!(bool)knowTournaments.GetValue(am) || knowTournaments.GetValue(am) == null) { args.Tooltip = new TextObject("{=Sph9Nliz}You need to learn more about the arena by talking with the arena master.", (Dictionary <string, TextObject>)null); args.IsEnabled = false; return(true); } if (Hero.MainHero.IsWounded && Campaign.Current.IsMainHeroDisguised) { args.Tooltip = new TextObject("{=DqZtRBXR}You are wounded and in disguise.", (Dictionary <string, TextObject>)null); args.IsEnabled = false; return(true); } if (Hero.MainHero.IsWounded) { args.Tooltip = new TextObject("{=yNMrF2QF}You are wounded", (Dictionary <string, TextObject>)null); args.IsEnabled = false; return(true); } if (Campaign.Current.IsMainHeroDisguised) { args.Tooltip = new TextObject("{=jcEoUPCB}You are in disguise.", (Dictionary <string, TextObject>)null); args.IsEnabled = false; return(true); } if (!currentSettlement.HasTournament) { return(true); } args.Tooltip = new TextObject("{=NESB0CVc}There is no practice fight because of the Tournament.", (Dictionary <string, TextObject>)null); args.IsEnabled = false; return(true); }
public static void GenerateFactionsIntoWorld() { int i = 0; foreach (FactionDef current in DefDatabase <FactionDef> .AllDefs) { for (int j = 0; j < current.requiredCountAtGameStart; j++) { Faction faction = FactionGenerator.NewGeneratedFaction(current); Find.FactionManager.Add(faction); if (!current.hidden) { i++; } } } while (i < 5) { FactionDef facDef = (from fa in DefDatabase <FactionDef> .AllDefs where fa.canMakeRandomly && Find.FactionManager.AllFactions.Count((Faction f) => f.def == fa) < fa.maxCountAtGameStart select fa).RandomElement <FactionDef>(); Faction faction2 = FactionGenerator.NewGeneratedFaction(facDef); Find.World.factionManager.Add(faction2); i++; } int num = GenMath.RoundRandom((float)Find.WorldGrid.TilesCount / 100000f * FactionGenerator.SettlementsPer100kTiles.RandomInRange); num -= Find.WorldObjects.Settlements.Count; for (int k = 0; k < num; k++) { Faction faction3 = (from x in Find.World.factionManager.AllFactionsListForReading where !x.def.isPlayer && !x.def.hidden select x).RandomElementByWeight((Faction x) => x.def.settlementGenerationWeight); Settlement settlement = (Settlement)WorldObjectMaker.MakeWorldObject(WorldObjectDefOf.Settlement); settlement.SetFaction(faction3); settlement.Tile = TileFinder.RandomSettlementTileFor(faction3, false, null); settlement.Name = SettlementNameGenerator.GenerateSettlementName(settlement, null); Find.WorldObjects.Add(settlement); } }
public void DoRebelResult() { float successChance = 0.45f; if (Rand.Chance(successChance)) { Faction.Notify_LeaderDied(); string playerAffect = ""; if (supress) { Faction.TryAffectGoodwillWith(Faction.OfPlayer, -15); playerAffect = "Quest_SuppressionRebelplayerAffect".Translate(); } else { playerAffect = "Quest_SuppressionRebelNonplayerAffect".Translate(); } Find.LetterStack.ReceiveLetter("Quest_SuppressionRebellionRebelWinTitle".Translate(), "Quest_SuppressionRebellionRebelWinDesc".Translate(RebelSettlement.Name, playerAffect), LetterDefOf.NeutralEvent); } else { Faction faction = DoNewFaction(); Find.LetterStack.ReceiveLetter("Quest_SuppressionRebellionNewFactionTitle".Translate(), "Quest_SuppressionRebellionNewFactionDesc".Translate(RebelSettlement.Name, faction.Name), LetterDefOf.PositiveEvent); int tile = TileFinder.RandomSettlementTileFor(faction); Settlement settlement = (Settlement)WorldObjectMaker.MakeWorldObject(WorldObjectDefOf.Settlement); settlement.SetFaction(faction); settlement.Name = SettlementNameGenerator.GenerateSettlementName(settlement); settlement.Tile = tile; Find.WorldObjects.Add(settlement); } Site.EndQuest(null, EndCondition.None); }
public static MemoryStream SettlementToXlsxStream(Settlement settlement) { var wb = new XLWorkbook(); var dt = new DataTable(); dt.TableName = "Overview"; dt.Columns.Add("Tab", typeof(string)); dt.Columns.Add("Sum", typeof(decimal)); foreach (var tabToOrders in settlement.TabToOrders) { var sum = Math.Round(tabToOrders.Orders.Sum(e => e.Quantity * e.ProductPrice), 2); dt.Rows.Add(tabToOrders.Tab.Name, sum); } wb.Worksheets.Add(dt); var stream = new MemoryStream(); wb.SaveAs(stream); stream.Position = 0; return(stream); }
internal void ApplyInitialBankRetaliationForUnpaidLoan(Settlement settlement) { var bankData = GetBankDataAtSettlement(settlement); bankData.HasBankPerformedInitialRetaliationForUnpaidLoan = true; ChangeCrimeRatingAction.Apply(settlement.MapFaction, SubModule.Config.CrimeRatingIncreaseForUnpaidLoan); Hero.MainHero.Clan.Renown -= SubModule.Config.RenownLossForUnpaidLoan; InformationManager.DisplayMessage(new InformationMessage($"You failed to repay your loan. Lost {SubModule.Config.RenownLossForUnpaidLoan} renown.")); InformationManager.ShowInquiry( new InquiryData( "Loan Payment Overdue", $"You failed to repay your loan on time with the {settlement.Name} bank. The {settlement.MapFaction.Name} will treat you as an outlaw if you do not repay your debts.", true, false, "OK", "", () => InformationManager.HideInquiry(), () => { } ), true ); }
protected override void Click() { Vector2 pos = Camera.main.ScreenToWorldPoint(Input.mousePosition); switch (currentAction) { case PlayerAction.BuildSettlement: RaycastHit2D hit = RaycastPosition(pos); Settlement s = GetTypeFromRaycast <Settlement>(hit); if (s) { print("Attempting build"); BuildSettlement(s); } break; } }
public void ApplySuccessfulAssassination(Settlement settlement, Hero assassin, Hero victim) { var party = victim.OwnedParties.Where(p => p.LeaderHero == victim).FirstOrDefault(); if (party != null) { party.MobileParty.RemoveParty(); } KillCharacterAction.ApplyByMurder(victim); PrintAssassinatedText(victim); _assassinationHistoryService.AddAssassinationEvent(new AssassinationEvent() { Settlement = settlement, Assassin = assassin, Victim = victim, Succeeded = true, CampaignTime = CampaignTime.Now }); }
private bool TryFindEnemySettlement(Settlement root, List <FactionInteraction> enemies, out Settlement resultTarget) { resultTarget = null; Settlement settlement = null; Find.WorldFloodFiller.FloodFill(root.Tile, (int x) => !Find.World.Impassable(x), delegate(int tile, int traversalDistance) { Settlement tmp = Find.WorldObjects.SettlementAt(tile); if (tmp != null && enemies.Contains(tmp.Faction)) { settlement = tmp; return(true); } return(false); }); resultTarget = settlement; return(resultTarget != null); }
public void TestInsertSettlement() { SettlementBL settlementBL = new SettlementBL(connectionString); Settlement settlement = new Settlement(); settlement.CicleId = 1; //Assume we have a cicle with ID 1 settlement.ProducerId = 1; //Assume we have a producer with ID 1 settlement.CashAdvancesTotal = 1000; settlement.Date = System.DateTime.Now; settlement.Paid = true; settlement.CreditsTotal = 3000; settlement.WeightTicketsTotal = 4000; settlement.Total = 5000; settlement.User = "******"; //Assume we have a user with this ID settlement.WeightTicketsIds = new System.Collections.ObjectModel.Collection <int>() { 1 }; settlementBL.InsertSettlement(settlement); settlementBL.UpdateSettlement(settlement); List <Settlement> settlements = settlementBL.GetSettlement(null, null); }
public void LaunchLightPod(int destinationTile, IntVec3 destinationCell, TransportPodsArrivalAction arrivalAction) { Map map = this.CasterPawn.Map; CreatePodGroup(); podTList[0].TryRemoveLord(map); int groupID = podTList[0].groupID; for (int i = 0; i < podTList.Count; i++) { ThingOwner directlyHeldThings = podTList[i].GetDirectlyHeldThings(); ActiveDropPod activeDropPod = (ActiveDropPod)ThingMaker.MakeThing(ThingDefOf.ActiveDropPod); activeDropPod.Contents = new ActiveDropPodInfo(); activeDropPod.Contents.innerContainer.TryAddRangeOrTransfer(directlyHeldThings, canMergeWithExistingStacks: true, destroyLeftover: true); WorldTransport.TM_DropPodLeaving obj = (WorldTransport.TM_DropPodLeaving)SkyfallerMaker.MakeSkyfaller(TorannMagicDefOf.TM_LightPodLeaving, activeDropPod); obj.groupID = groupID; obj.destinationTile = destinationTile; obj.arrivalAction = arrivalAction; obj.arrivalCell = destinationCell; obj.draftFlag = this.draftFlag; podTList[i].CleanUpLoadingVars(map); podTList[i].parent.Destroy(); GenSpawn.Spawn(obj, podTList[i].parent.Position, map); } CameraJumper.TryHideWorld(); if (!map.mapPawns.AnyColonistSpawned && !map.IsPlayerHome) { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append("TM_AbandoningMap".Translate(map.Parent.LabelCap)); Find.WindowStack.Add(Dialog_MessageBox.CreateConfirmation(stringBuilder.ToString(), delegate { Settlement sm = map.Parent as Settlement; WorldTransport.TM_DelayedDestroyMap ddm = new WorldTransport.TM_DelayedDestroyMap(); ddm.parent = sm; ddm.delayTicks = 120; sm.AllComps.Add(ddm); })); } }
public async Task <ActionResult> Create([Bind(Include = "id,shipmentId,creationDate,modificationDate,year,month,sum,approved")] Settlement settlement) { settlement.creationDate = DateTime.Now; settlement.modificationDate = DateTime.Now; settlement.approved = false; do { settlement.id = new Random().Next().ToString(); } while (db.Settlements.Where(x => x.id == settlement.id).ToList().Count > 0); if (ModelState.IsValid && db.Settlements.Where(x => x.shipmentId == settlement.shipmentId).ToList().Count == 0) { db.Settlements.Add(settlement); await db.SaveChangesAsync(); return(RedirectToAction("Index")); } ModelState.AddModelError("shipmentId", "Istnieje już rozliczenie dla tej dostawy"); ViewBag.shipmentId = settlementLogic.CreateShipmentList(); return(View(settlement)); }
/// <summary> /// On campaign start, if there was no CultureConfig.dat, lookups need to be initialized /// </summary> public void OnCampaignLoad() { // There was no current influence stored in the save file if (CurrentInfluences == null) { Settlement settlement = Settlement.Find(settlementId); if (settlement.Name.ToString() == "Thractorae Castle") { int u = 0; } CurrentInfluences = new Dictionary <string, decimal>(); CurrentInfluences.Add(settlement.Culture.StringId, 1m); } // there was no target influence stored in the save file if (TargetInfluences == null) { TargetInfluences = new Dictionary <string, decimal>(); RecalculateInfluencers(true); } }
public static void Postfix(Hero arg1, Settlement settlement, Hero individual, CharacterObject troop, int count) { if (individual != null && settlement != null) { if (settlement.IsTown) { settlement.Prosperity -= SubModule.Settings.TownRecruitProsperityCost * (float)count; if (settlement.Prosperity < 0f) { settlement.Prosperity = 0f; } } if (settlement.IsVillage) { settlement.Village.Hearth -= SubModule.Settings.VillageRecruitProsperityCost * (float)count; if (settlement.Village.Hearth < 0f) { settlement.Village.Hearth = 0f; } } } }
public override void CalculateMilitiaSpawnRate(Settlement settlement, out float meleeTroopRate, out float rangedTroopRate, out float meleeEliteTroopRate, out float rangedEliteTroopRate) { meleeTroopRate = 0.5f; rangedTroopRate = 1f - meleeTroopRate; rangedEliteTroopRate = 0.1f; meleeEliteTroopRate = 0.1f; if (settlement.IsTown && settlement.Town.Governor != null && settlement.Town.Governor.GetPerkValue(DefaultPerks.Leadership.CitizenMilitia) && settlement.Town.Governor.CurrentSettlement != null && settlement.Town.Governor.CurrentSettlement.IsTown && settlement.Town.Governor.CurrentSettlement.Town == settlement.Town) { rangedEliteTroopRate += DefaultPerks.Leadership.CitizenMilitia.PrimaryBonus / 100f; meleeEliteTroopRate += DefaultPerks.Leadership.CitizenMilitia.PrimaryBonus / 100f; } if (settlement.IsTown && settlement.Town.Governor != null) { ExplainedNumber explainedNumber = new ExplainedNumber(0f, null); PerkHelper.AddPerkBonusForTown(DefaultPerks.OneHanded.StrongArms, settlement.Town, ref explainedNumber); rangedEliteTroopRate += explainedNumber.ResultNumber; meleeEliteTroopRate += explainedNumber.ResultNumber; } rangedEliteTroopRate *= SettlementSetting.Instance.EliteTroopRate; meleeEliteTroopRate *= SettlementSetting.Instance.EliteTroopRate; }
protected override bool TryExecuteWorker(IncidentParms parms) { int tile; if (!TileFinder.TryFindNewSiteTile(out tile, minDist, maxDist, false, true, -1)) { return(false); } Faction faction = (from x in Find.World.factionManager.AllFactionsListForReading where !x.def.isPlayer && !x.def.hidden select x).RandomElementByWeight((Faction x) => x.def.settlementGenerationWeight); Settlement settlement = (Settlement)WorldObjectMaker.MakeWorldObject(WorldObjectDefOf.Settlement); settlement.SetFaction(faction); settlement.Tile = tile; settlement.Name = SettlementNameGenerator.GenerateSettlementName(settlement, null); Find.WorldObjects.Add(settlement); Find.LetterStack.ReceiveLetter("LetterLabelNewSettlementLGE".Translate(), "LetterNewSettlementLGE".Translate(faction.Name), LetterDefOf.NeutralEvent, settlement, null); return(true); }
public static void Postfix(ref float __result, Hero hero, int index, Settlement settlement) { if (settlement.IsTown) { double multiplier = (settlement.Prosperity - SubModule.Settings.townMinProsperityForRecruit) / (SubModule.Settings.townProsperityThreshold - SubModule.Settings.townMinProsperityForRecruit); multiplier = Math.Max(multiplier, 0); multiplier = Math.Pow(multiplier, 0.7); __result *= (float)multiplier; } if (settlement.IsVillage) { double multiplier = (settlement.Village.Hearth - SubModule.Settings.villageMinProsperityForRecruit) / (SubModule.Settings.villageProsperityThreshold - SubModule.Settings.villageMinProsperityForRecruit); multiplier = Math.Max(multiplier, 0); multiplier = Math.Pow(multiplier, 0.7); __result *= (float)multiplier; } }
private void Withdraw(int amount, Settlement settlement) { var bankData = GetBankDataAtSettlement(settlement); if (amount > bankData.Balance) { InformationManager.DisplayMessage(new InformationMessage("You do not have enough money to withdraw.")); return; } var settlementFundsInfo = GetSettlementFundsInfo(settlement); if (amount > settlementFundsInfo.AvailableFunds) { InformationManager.DisplayMessage(new InformationMessage($"The bank does not have enough funds available for you to withdraw. Only {settlementFundsInfo.AvailableFunds}<img src=\"Icons\\Coin@2x\"> is available.")); return; } bankData.Balance -= amount; GiveGoldAction.ApplyForSettlementToCharacter(settlement, Hero.MainHero, amount, true); InformationManager.DisplayMessage(new InformationMessage($"You withdrew {amount}<img src=\"Icons\\Coin@2x\">.", "event:/ui/notification/coins_positive")); UpdateBankMenuTextVariables(); GameMenu.SwitchToMenu("bank_account"); }
private void PrepareCharacterWindow_Internal() { characterWindowSettlement = characterWindowHero.StayingInSettlementOfNotable; characterWindowEvents = new List <string>(characterWindowHero.GetHeroOccupiedEvents()); string evt; while ((evt = characterWindowHero.GetHeroOccupiedEvents().FirstOrDefault()) != default) { characterWindowHero.RemoveEventFromOccupiedHero(evt); } characterWindowParty = characterWindowHero.PartyBelongedTo; if (characterWindowParty != MobileParty.MainParty) { if (characterWindowParty != null) { characterWindowParty.MemberRoster.AddToCounts(characterWindowHero.CharacterObject, -1); } MobileParty.MainParty.MemberRoster.AddToCounts(characterWindowHero.CharacterObject, 1); } }
public EncounterConfig GetSneakInEncounter(Settlement settlement) { if (settlement.IsCastle) { return(new EncounterConfig() { LocationEncounter = new CastleEncounter(settlement), LocationId = LordsHallId, WallLevel = settlement.GetComponent <Town>().GetWallLevel() }); } return(new EncounterConfig() { LocationEncounter = new TownEncounter(settlement) { IsInsideOfASettlement = true, }, LocationId = LordsHallId, WallLevel = settlement.GetComponent <Town>().GetWallLevel() }); }
private void InitializeSiege(Hero leader, Clan clan, Settlement target, MobileParty party) { try { FactionManager.DeclareWar(leader.MapFaction, target.MapFaction); Campaign.Current.FactionManager.RegisterCampaignWar(leader.MapFaction, target.MapFaction); ChangeRelationAction.ApplyRelationChangeBetweenHeroes(leader, clan.Leader, -20, false); ChangeRelationAction.ApplyRelationChangeBetweenHeroes(leader, clan.Kingdom.Leader, -20, false); party.Ai.SetDoNotMakeNewDecisions(true); SetPartyAiAction.GetActionForBesiegingSettlement(party, target); } catch (Exception e) { Log.Info("Exception when trying to siege settlement"); Log.Error(e); } }
/// <summary> /// Gets the influence strength from otherSettlement on thisSettlement /// </summary> /// <param name="otherSettlement">Influencer</param> /// <param name="thisSettlement">Influencee</param> /// <param name="firstTimeSetup">First time setup will ignore the Ratio calculation, because the InfluenceMap has not been fully populated</param> /// <returns></returns> int getInfluenceFromSettlement(Settlement otherSettlement, Settlement thisSettlement, bool firstTimeSetup) { var otherCulture = DynaCultureUtils.GetOwnerCulture(otherSettlement); int influenceValue = BASE_INFLUENCE; if (otherSettlement.IsTown) { influenceValue *= 3; } if (otherSettlement.IsCastle) { influenceValue *= 2; } if (otherSettlement.IsVillage) { influenceValue *= 1; } // Self influence bonus if (otherSettlement.StringId == this.settlementId) { influenceValue *= 2; } // Homeland bonus only applied for self influence if (otherCulture.StringId == homelandCultureId && otherSettlement.StringId == thisSettlement.StringId) { influenceValue *= 2; } // Scale the influence based on the influence ratios of the other settlement. Skip on first time setup. if (!firstTimeSetup) { influenceValue = (int)decimal.Round((decimal)influenceValue * DynaCultureManager.Instance.InfluenceMap[otherSettlement.StringId].getTopCultureValue()); } return(influenceValue); }
private static void NameSettlement() { List <DebugMenuOption> list = new List <DebugMenuOption>(); list.Add(new DebugMenuOption("Faction", DebugMenuOptionMode.Action, delegate { Find.WindowStack.Add(new Dialog_NamePlayerFaction()); })); if (Find.CurrentMap != null && Find.CurrentMap.IsPlayerHome && Find.CurrentMap.Parent is Settlement) { Settlement factionBase = (Settlement)Find.CurrentMap.Parent; list.Add(new DebugMenuOption("Faction base", DebugMenuOptionMode.Action, delegate { Find.WindowStack.Add(new Dialog_NamePlayerSettlement(factionBase)); })); list.Add(new DebugMenuOption("Faction and faction base", DebugMenuOptionMode.Action, delegate { Find.WindowStack.Add(new Dialog_NamePlayerFactionAndSettlement(factionBase)); })); } Find.WindowStack.Add(new Dialog_DebugOptionListLister(list)); }
public Swaption(VanillaSwap simpleSwap, Exercise exercise, Settlement.Type type) : this(NQuantLibcPINVOKE.new_Swaption__SWIG_0(VanillaSwap.getCPtr(simpleSwap), Exercise.getCPtr(exercise), (int)type), true) { if (NQuantLibcPINVOKE.SWIGPendingException.Pending) throw NQuantLibcPINVOKE.SWIGPendingException.Retrieve(); }
public void UpgradeSettlement(Settlement set) { }
internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Settlement obj) { return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr; }
public MakeSwaption withSettlementType(Settlement.Type delivery) { delivery_ = delivery; return this; }
public void AddSettlements(Settlement set) { }
// cleanup // SavedSettings backup; // utilities public Swaption makeSwaption(VanillaSwap swap,Date exercise,double volatility,Settlement.Type settlementType) { Handle<Quote> vol=new Handle <Quote>(new SimpleQuote(volatility)); IPricingEngine engine=new BlackSwaptionEngine(termStructure, vol); Swaption result=new Swaption(swap,new EuropeanExercise(exercise),settlementType); result.setPricingEngine(engine); return result; }
public Settlement BuildSettlement() { Settlement set = new Settlement(); return set; }
/// <summary> /// 建立股票期貨商品資料表格 /// </summary> /// <param name="DdeClient"></param> /// <param name="DicSymbol">成對商品代號[股票期貨代號,對應股票代號]</param> private void CreateProductStockDgvData( ref DDEClient DdeClient, Dictionary<string, string> DicSymbol, bool IsStock ) { //建立商品資料;// foreach (KeyValuePair<string, string> Item in DicSymbol) { //取得股票及期貨資料;// List<string> listStockData = m_DdeClient.GetProductData(Item.Value); List<string> listOptionData = m_DdeClient.GetProductData(Item.Key); //判斷有無取得資料;// if (listStockData == null || listOptionData == null) continue; //DataGridView建立列的資料;// string[] arrRowData = { listStockData[(int)DDEClient.ItemField.eSymbol], //股票代號;// listStockData[(int)DDEClient.ItemField.eName], //股票名稱;// listStockData[(int)DDEClient.ItemField.ePrice], //股票成交價;// listOptionData[(int)DDEClient.ItemField.eSymbol], //期貨代號;// listOptionData[(int)DDEClient.ItemField.eName], //期貨名稱;// listOptionData[(int)DDEClient.ItemField.ePrice], //期貨成交價;// listOptionData[(int)DDEClient.ItemField.eBidPrice], //期貨買價;// listOptionData[(int)DDEClient.ItemField.eAskPrice], //期貨賣價;// listOptionData[(int)DDEClient.ItemField.eCumulativeVolume], //期貨成交交量;// "null", //預估結算價;// "0", //掛買;// "0", //掛賣;// "0", //賣出期貨買價價差;// "0" //買進期貨賣價價差;// }; //增加一列資料,並取得Row的編號及Row資料;// DataGridViewRow Rows; if (IsStock) { int RowIdX = dgvInform.Rows.Add(arrRowData); Rows = dgvInform.Rows[RowIdX]; } else { int RowIdX = dgvInformIndex.Rows.Add(arrRowData); Rows = dgvInformIndex.Rows[RowIdX]; } //判斷此資料是否已經設定過變更不同的增加方式;// if ( m_htProductRowsNo.ContainsKey(listStockData[(int)DDEClient.ItemField.eSymbol]) == true ) { //紀錄商品資料所在的Rows;// ((List<DataGridViewRow>)m_htProductRowsNo[listStockData[(int)DDEClient.ItemField.eSymbol]]).Add(Rows); } else { List<DataGridViewRow> RowLists = new List<DataGridViewRow>(); RowLists.Add(Rows); m_htProductRowsNo.Add(listStockData[(int)DDEClient.ItemField.eSymbol], RowLists); } if (m_htProductRowsNo.ContainsKey(listOptionData[(int)DDEClient.ItemField.eSymbol]) == true) { //紀錄商品資料所在的Rows;// ((List<DataGridViewRow>)m_htProductRowsNo[listOptionData[(int)DDEClient.ItemField.eSymbol]]).Add(Rows); } else { List<DataGridViewRow> RowLists = new List<DataGridViewRow>(); RowLists.Add(Rows); m_htProductRowsNo.Add(listOptionData[(int)DDEClient.ItemField.eSymbol], RowLists); } if (IsStock) { //新增股票的結算價計算物件;// if (m_htStockSettlement.Contains(listStockData[(int)DDEClient.ItemField.eSymbol]) == false) { Settlement StockSettlement = new Settlement(m_nSettlementStockNums); m_htStockSettlement.Add(listStockData[(int)DDEClient.ItemField.eSymbol], StockSettlement); } } else { //新增指數的結算價計算物件;// if (m_htIndexSettlement.Contains(listStockData[(int)DDEClient.ItemField.eSymbol]) == false) { Settlement StockSettlement = new Settlement(m_nSettlementIndexNums); m_htIndexSettlement.Add(listStockData[(int)DDEClient.ItemField.eSymbol], StockSettlement); } } string ReferencePrice = listStockData[(int)DDEClient.ItemField.eReference]; SetFontColor(ReferencePrice, listStockData[(int)DDEClient.ItemField.ePrice], Rows.Cells[(int)DgvColumnCell.eSTOCK_PRICE]); ReferencePrice = listOptionData[(int)DDEClient.ItemField.eReference]; SetFontColor(ReferencePrice, listOptionData[(int)DDEClient.ItemField.ePrice], Rows.Cells[(int)DgvColumnCell.eOPTION_PRICE]); SetFontColor(ReferencePrice, listOptionData[(int)DDEClient.ItemField.eBidPrice], Rows.Cells[(int)DgvColumnCell.eOPTION_BUY]); SetFontColor(ReferencePrice, listOptionData[(int)DDEClient.ItemField.eAskPrice], Rows.Cells[(int)DgvColumnCell.eOPTION_SELL]); //設定DDE更新資料的回Call Function;// DdeClient.mEventDdeAdvice += DdeAdvice; } }