public override float CalculateLoyaltyChange(Town town, StatExplainer explanation = null) { ExplainedNumber explainedNumber = new ExplainedNumber(0.0f, explanation, (TextObject)null); SettlementInfo info = RevolutionBehaviour.GetSettlementInformation(town.Settlement); if (!town.IsTown) { return(explainedNumber.ResultNumber + base.CalculateLoyaltyChange(town, explanation)); } if (info.Settlement.MapFaction.Leader == Hero.MainHero) { explainedNumber.Add(_basePlayerLoyalty, GameTexts.FindText("str_loyalty_bannerlord")); if (ModOptions.OptionsData.PlayerAffectedByOverextension && ModOptions.OptionsData.OverextensionMechanics) { Overextension(info, ref explainedNumber); } } else { BaseLoyalty(info, ref explainedNumber); if (ModOptions.OptionsData.OverextensionMechanics) { Overextension(info, ref explainedNumber); } } return(explainedNumber.ResultNumber + base.CalculateLoyaltyChange(town, explanation)); }
private void ImperialChange(SettlementInfo settlementInfo, ref ExplainedNumber explainedNumber) { if (!RevolutionsSettings.Instance.RevoltsImperialLoyaltyMechanic) { return; } if (settlementInfo.IsOfImperialCulture) { if (settlementInfo.IsCurrentFactionOfImperialCulture) { explainedNumber.Add(3, new TextObject(GameTexts.RevoltsLoyaltyCalculationImperialLoyalty)); } else { explainedNumber.Add(-1, new TextObject(GameTexts.RevoltsLoyaltyCalculationForeignRule)); } } else { if (settlementInfo.IsCurrentFactionOfImperialCulture) { explainedNumber.Add(-1, new TextObject(GameTexts.RevoltsLoyaltyCalculationImperialAversion)); } if (settlementInfo.LoyalFaction.StringId != settlementInfo.CurrentFactionId) { explainedNumber.Add(1, new TextObject(GameTexts.RevoltsLoyaltyCalculationForeignRule)); } } }
private void LuckyNationChange(SettlementInfo settlementInfo, ref ExplainedNumber explainedNumber) { if (settlementInfo.CurrentFaction.IsKingdomFaction) { if (Managers.Kingdom.Get(settlementInfo.Settlement.OwnerClan.Kingdom)?.LuckyNation == true) { explainedNumber.Add(5, new TextObject(GameTexts.RevoltsLoyaltyCalculationLuckyNation)); } } }
public SettlementMatterViewModel(string actionstepOrg, int matterId, int version, SettlementInfo settlementData, ActionstepMatter actionstepData = null) { ActionstepOrg = actionstepOrg; MatterId = matterId; Version = version; SettlementData = settlementData; ActionstepData = actionstepData; }
/// <summary> /// 获取单个结算单信息,包含结算单、结算单支付、结算单明细 /// </summary> /// <param name="settlementCode"></param> /// <returns></returns> public SettlementInfo getSettlementInfos(string settlementCode) { var settlementInfo = new SettlementInfo(); var orderInfo = Dao.getOrderInfo(settlementCode); var paymentInfo = Dao.getPaymentInfo(orderInfo.TradeCode); var productList = Dao.getOrderProducts(settlementCode); settlementInfo.OrderInfo = orderInfo; settlementInfo.PaymentInfo = paymentInfo; settlementInfo.OrderProducts = productList; return(settlementInfo); }
public void OpenCanvas(Settlement settlement, SettlementInfo info, List <Ship> shipsFromThisSettlement, Transform player) { currentSettlement = settlement; StaticCamera.instance.NewTarget(settlement.transform); currentlySelectedTransform = player; SetInfo(info); ships = shipsFromThisSettlement; SetTradeButtonStateDependingOnShipCount(); currentlySelectedButtonIndex = buttons[0].gameObject.activeSelf ? 0 : 3; ShowCanvas(true); }
private static void ConfigureSettlementMatter(ModelBuilder builder) { builder.Entity <SettlementMatter>() .Property(e => e.ActionstepData) .HasConversion( v => v.ToString(), v => Domain.Models.Settlement.ActionstepMatter.FromString(v)); builder.Entity <SettlementMatter>() .Property(e => e.SettlementData) .HasConversion( v => v.ToString(), v => SettlementInfo.FromString(v)); }
public ActionResult SettlementDetail(string settlementCode) { SettlementInfo settlementInfo = null; try { settlementInfo = settlement.getSettlementInfos(settlementCode); } catch (Exception ext) { LogHelper.Error(ext); } return(View(settlementInfo)); }
private void OverextensionChange(SettlementInfo settlementInfo, ref ExplainedNumber explainedNumber) { if (!RevolutionsSettings.Instance.RevoltsOverextensionMechanics || !RevolutionsSettings.Instance.RevoltsOverextensionAffectsPlayer && settlementInfo.CurrentFaction.Leader == Hero.MainHero || settlementInfo.CurrentFaction.StringId == settlementInfo.LoyalFaction.StringId) { return; } var loyalSettlements = settlementInfo.CurrentFaction.Settlements.Where(s => s.IsFortification && settlementInfo.CurrentFactionId == Managers.Settlement.Get(s).LoyalFaction.StringId).Count(); var illoyalSettlements = settlementInfo.CurrentFaction.Settlements.Where(s => s.IsFortification && settlementInfo.CurrentFactionId != Managers.Settlement.Get(s).LoyalFaction.StringId).Count(); var overextension = loyalSettlements - illoyalSettlements; var calculatedOverextension = overextension < 0 ? overextension * RevolutionsSettings.Instance.RevoltsOverextensionMultiplier : 1; explainedNumber.Add(calculatedOverextension, new TextObject(GameTexts.RevoltsLoyaltyCalculationOverextension)); }
private void NotablesChange(SettlementInfo settlementInfo, ref ExplainedNumber explainedNumber) { var notablesLoyaltyChange = 0f; var settlement = settlementInfo.Settlement; foreach (var notable in settlement.Notables.Where(notable => notable.SupporterOf != null)) { if (settlement.OwnerClan.MapFaction.StringId == notable.SupporterOf.MapFaction.StringId) { notablesLoyaltyChange += 1; } else { notablesLoyaltyChange -= 1; } } var textObject = new TextObject(GameTexts.RevoltsLoyaltyCalculationNotables); textObject.SetTextVariable("SETTLEMENT", settlement.Name); explainedNumber.Add(notablesLoyaltyChange, textObject); foreach (var village in settlement.BoundVillages.Select(village => village.Settlement)) { notablesLoyaltyChange = 0; foreach (var noteable in village.Notables.Where(notable => notable.SupporterOf != null)) { if (village.OwnerClan.MapFaction.StringId == noteable.SupporterOf.MapFaction.StringId) { notablesLoyaltyChange += 1; } else { notablesLoyaltyChange -= 1; } } textObject = new TextObject(GameTexts.RevoltsLoyaltyCalculationNotables); textObject.SetTextVariable("SETTLEMENT", settlement.Name); explainedNumber.Add(notablesLoyaltyChange, textObject); } }
public BaseBannerInfo GetBanner(SettlementInfo settlementInfo) { var availableBannerInfos = new List <BaseBannerInfo>(); BaseBannerInfo bannerInfo = null; foreach (var info in this.Infos.Where(i => !i.Used)) { if (info.Settlement == settlementInfo.Settlement.Name.ToString() && info.Culture == settlementInfo.Settlement.Culture.StringId) { availableBannerInfos.Add(info); break; } if (info.Faction == settlementInfo.LoyalFaction.StringId) { availableBannerInfos.Add(info); break; } if (info.Culture == settlementInfo.Settlement.Culture.StringId) { availableBannerInfos.Add(info); break; } } if (availableBannerInfos.Count > 0) { bannerInfo = availableBannerInfos.GetRandomElement(); } if (bannerInfo == null) { bannerInfo = this.GetBaseBanner(settlementInfo); } if (bannerInfo != null) { bannerInfo.Used = true; } return(bannerInfo); }
private void Overextension(SettlementInfo settlement, ref ExplainedNumber explainedNumber) { if (settlement.CurrentFaction.StringId == settlement.OriginalFaction.StringId) { return; } if (ModOptions.OptionsData.EmpireLoyaltyMechanics) { if (settlement.OriginalOwnerIsOfImperialCulture() && settlement.OwnerIsOfImperialCulture()) { return; } } int townsAboveInitialStart = RevolutionBehaviour.GetFactionInformation(settlement.CurrentFaction).TownsAboveInitial(); explainedNumber.Add(-townsAboveInitialStart * OverExtensionMultiplier, GameTexts.FindText("str_loyalty_overextension")); }
public async Task <string> Handle(SettlementMatterGeneratePDFQuery message, CancellationToken token) { ValidationResult result = _validator.Validate(message); if (!result.IsValid) { throw new ValidationException("Invalid input.", result.Errors); } SettlementInfo settlementInfo = message.Matter.SettlementData; var matterInfo = await _mediator.Send(new ActionstepMatterInfoQuery(message.Matter.ActionstepOrgKey, message.Matter.ActionstepMatterId, message.AuthenticatedUser)); var pdfContent = settlementInfo.GeneratePDFContent(matterInfo.OrgName); var tempPdfPath = Path.GetTempFileName(); var doc = new HtmlToPdfDocument() { GlobalSettings = { ColorMode = ColorMode.Color, Orientation = Orientation.Portrait, PaperSize = PaperKind.A4, Out = tempPdfPath }, Objects = { new ObjectSettings() { PagesCount = true, HtmlContent = pdfContent, WebSettings = { DefaultEncoding = "utf-8" }, HeaderSettings ={ Line = false, Spacing = 3} } } }; _converter.Convert(doc); return(tempPdfPath); }
private void BaseLoyalty(SettlementInfo info, ref ExplainedNumber explainedNumber) { if (ModOptions.OptionsData.EmpireLoyaltyMechanics) { if (info.OriginalOwnerIsOfImperialCulture()) { if (info.OwnerIsOfImperialCulture()) { explainedNumber.Add(10, GameTexts.FindText("str_loyalty_imperial")); } else { explainedNumber.Add(-5, GameTexts.FindText("str_loyalty_foreignRule")); } } else { if (info.OwnerIsOfImperialCulture()) { explainedNumber.Add(-5, GameTexts.FindText("str_loyalty_imperialAvers")); } if (info.OriginalFaction.StringId != info.CurrentFaction.StringId) { explainedNumber.Add(-5, GameTexts.FindText("str_loyalty_foreignRule")); } } } else { if (info.OriginalFaction.StringId != info.CurrentFaction.StringId) { explainedNumber.Add(-5, GameTexts.FindText("str_loyalty_foreignRule")); } } }
public TownRevoltsScreen(SettlementInfo settlementInfo) { this._settlementInfo = settlementInfo; }
public TownRevolutionScreen(SettlementInfo settinfo, FactionInfo factInfo) { this._settlementInfo = settinfo; this._factionInfo = factInfo; }
public string CreateSettlement(string customerCode, string[] inStorageIDs) { var listInStorageInfo = _inStorageInfoRepository.GetList(p => inStorageIDs.Contains(p.InStorageID) && p.CustomerCode == customerCode && !p.InStorageOrSettlementRelationals.Any() && (p.PaymentTypeID == 3 || p.PaymentTypeID == 4)); if (!listInStorageInfo.Any()) { throw new BusinessLogicException("该客户下没有未生成结算单的入仓单"); } //获取结算单号 string settlementNumber = SequenceNumberService.GetSequenceNumber(PrefixCode.SettlementID); List <ReceivingExpensesEditExt> listReceivingExpenses = new List <ReceivingExpensesEditExt>(); List <WayBillInfo> listWayBillInfo = new List <WayBillInfo>(); foreach (InStorageInfo inStorageInfo in listInStorageInfo) { _inStorageOrSettlementRelationalRepository.Add(new InStorageOrSettlementRelational() { InStorageID = inStorageInfo.InStorageID, SettlementNumber = settlementNumber, }); foreach (WayBillInfo wayBillInfo in inStorageInfo.WayBillInfos) { listWayBillInfo.Add(wayBillInfo); listReceivingExpenses.Add(_receivingExpensRepository.GetReceivingExpensesEditEx(wayBillInfo.WayBillNumber)); } } var customer = _customerRepository.GetFiltered(c => c.CustomerCode == customerCode).FirstOrDefault(); var customerManagerInfos = _customerManagerInfoRepository.GetFiltered(c => c.Name == customer.CustomerManager).FirstOrDefault(); SettlementInfo settlementInfo = new SettlementInfo() { SettlementNumber = settlementNumber, CustomerCode = customerCode, TotalNumber = listInStorageInfo.Select(s => s.TotalQty.Value).Sum(), TotalWeight = listInStorageInfo.Select(s => s.PhysicalTotalWeight).Sum(), TotalSettleWeight = listInStorageInfo.Select(s => s.TotalWeight.Value).Sum(), TotalFee = listReceivingExpenses.Select(s => s.TotalFeeOriginal.Value).Sum(), Status = 1, SalesMan = customer.CustomerManager, SalesManTel = customerManagerInfos == null?"":(customerManagerInfos.Tel ?? customerManagerInfos.Mobile), CreatedBy = _workContext.User.UserUame, CreatedOn = DateTime.Now, LastUpdatedBy = _workContext.User.UserUame, LastUpdatedOn = DateTime.Now, }; _settlementInfoRepository.Add(settlementInfo); var query = from w in listWayBillInfo join r in listReceivingExpenses on w.WayBillNumber equals r.WayBillNumber group w by w.InShippingMethodID; var listSettlementDetailsInfo = from q in query select new SettlementDetailsInfo { SettlementNumber = settlementNumber, ShippingMethodID = q.Key, ShippingMethodName = q.Select(w => w.InShippingMethodName).FirstOrDefault(), TotalNumber = q.Count(), TotalWeight = q.Select(w => w.Weight.Value).Sum(), TotalSettleWeight = q.Select(w => w.SettleWeight.Value).Sum(), TotalFee = listReceivingExpenses.Where(r => q.Select(w => w.WayBillNumber).Contains(r.WayBillNumber)).Select(r => r.TotalFeeOriginal.Value).Sum() }; foreach (SettlementDetailsInfo settlementDetailsInfo in listSettlementDetailsInfo) { _settlementDetailsInfoRepository.Add(settlementDetailsInfo); } using (var transaction = new TransactionScope(TransactionScopeOption.Required, new TimeSpan(0, 5, 0))) { _settlementInfoRepository.UnitOfWork.Commit(); _inStorageOrSettlementRelationalRepository.UnitOfWork.Commit(); _settlementDetailsInfoRepository.UnitOfWork.Commit(); transaction.Complete(); return(settlementNumber); } }
public void SetInfo(SettlementInfo info) { titleIntro.text = info.titleIntro; title.text = info.title; description.text = info.description; }
public TownRevoltViewModel(SettlementInfo settlementInfo) { this.SettlementInfo = settlementInfo; }
public async Task <SettlementInfo> BuildAsync() { TerrainHelper.SetTerrains(_heightMap); var minHeight = _terrainHelper.GetTerrain <Sand>().UpperBound; var maxHeight = _terrainHelper.GetTerrain <Lowland>().UpperBound; #region find water aquens byte waterUpperBound = _terrainHelper.GetTerrain <Water>().UpperBound; var map = (Pixel[, ])_heightMap.Clone(); var waterAreasBoundaryFunc = new Func <Pixel, bool>(p => p.Intensity <= waterUpperBound); var waterAreas = new List <IEnumerable <Point> >(); var potentialWaterPoints = GetPixels(map, waterAreasBoundaryFunc).ToList(); while (potentialWaterPoints.Count > 0) { var area = await ApplyFloodFillAsync( map, potentialWaterPoints.First(), waterAreasBoundaryFunc); potentialWaterPoints.RemoveAll(p => area.Contains(p)); waterAreas.Add(area); } var maxWaterArea = waterAreas.Max(w => w.Count()); waterAreas.RemoveAll(w => w.Count() < 0.4 * maxWaterArea); #endregion #region find settlement areas var previewBitmap = (Pixel[, ])_heightMap.Clone(); var settlementAreaBoundaryFunc = new Func <Pixel, bool>(color => color.G >= minHeight && color.G <= maxHeight); var areas = new List <IEnumerable <Point> >(); var potentialAreaPoints = GetPixels(previewBitmap, settlementAreaBoundaryFunc) .ToList(); while (potentialAreaPoints.Count > 0) { var area = await ApplyFloodFillAsync( previewBitmap, potentialAreaPoints.First(), settlementAreaBoundaryFunc); potentialAreaPoints.RemoveAll(p => area.Contains(p)); areas.Add(area); } var selectedArea = areas.OrderByDescending(a => a.Count()).First().ToList(); #endregion var builderHelper = new BuilderHelper(); var waterMatrix = new int[map.GetLength(1), map.GetLength(1)]; foreach (var point in waterAreas.SelectMany(w => w)) { waterMatrix[point.Y, point.X] = 1; } var boundaryPoints = builderHelper.GetBoundaryPoints(waterMatrix).OrderBy(p => p.X).ThenBy(p => p.Y).ToList(); var nStep = boundaryPoints.Count() / (100 * waterAreas.Count); var waterAreaBoundaryPoints = boundaryPoints.Where((x, i) => i % nStep == 0).ToList(); var fields = selectedArea.Select(a => new { Point = a, DistanceToWater = waterAreaBoundaryPoints.Min(w => builderHelper.DistanceTo(w, a)) }).OrderBy(f => f.DistanceToWater).ToList(); #region mark settlement area and water aquens on bitmap fields.Take((int)(fields.Count * 0.2)).ToList() .ForEach(p => MarkPoint(p.Point, previewBitmap, new Pixel(255, 0, 0), 1)); fields.Skip((int)(fields.Count * 0.2)).Take((int)(fields.Count * 0.3)).ToList() .ForEach(p => MarkPoint(p.Point, previewBitmap, new Pixel(200, 0, 0), 1)); fields.Skip((int)(fields.Count * 0.5)).ToList() .ForEach(p => MarkPoint(p.Point, previewBitmap, new Pixel(155, 0, 0), 1)); waterAreas.ForEach(w => w.ToList().ForEach(p => MarkPoint(p, previewBitmap, new Pixel(0, 0, 255), 1))); //waterAreaBoundaryPoints.ForEach(p => { MarkPoint(p, previewBitmap, new Pixel(0, 255, 0), 3); }); var fieldGrid = new Field[_heightMap.GetLength(0), _heightMap.GetLength(1)]; for (int i = 0; i < _heightMap.GetLength(0); i++) { for (int j = 0; j < _heightMap.GetLength(1); j++) { fieldGrid[i, j] = new Field() { Position = new Point(i, j), Terrain = _terrainHelper.GetTerrainForHeight(_heightMap[i, j].Intensity) }; } } foreach (var field in fields) { fieldGrid[field.Point.X, field.Point.Y].InSettlement = true; fieldGrid[field.Point.X, field.Point.Y].DistanceToWater = field.DistanceToWater; } var rand = new Random(); var verticalRoad = rand.NextDouble() >= 0.5; var min = verticalRoad ? fields.Min(f => f.Point.Y) : fields.Min(f => f.Point.X); var max = verticalRoad ? fields.Max(f => f.Point.Y) : fields.Max(f => f.Point.X); var startFields = verticalRoad ? fields.Where(f => f.Point.Y == min).ToArray() : fields.Where(f => f.Point.X == min).ToArray(); var start = startFields[rand.Next(0, startFields.Count())]; var endFields = verticalRoad ? fields.Where(f => f.Point.Y == max).ToArray() : fields.Where(f => f.Point.X == max).ToArray(); var end = endFields[rand.Next(0, endFields.Count())]; var mainRoadPoints = (await FindMainRoad(fieldGrid, start.Point, end.Point)).ToList(); mainRoadPoints.ForEach(p => { MarkPoint(new Point(p.X, p.Y), previewBitmap, new Pixel(0, 255, 255), 2); }); #endregion var mStep = mainRoadPoints.Count() / 100; var selectedRoadPoints = mainRoadPoints.OrderBy(p => p.X).ThenBy(p => p.Y).Where((x, i) => i % mStep == 0).ToList(); foreach (var field in fields) { fieldGrid[field.Point.X, field.Point.Y].DistanceToMainRoad = selectedRoadPoints.Min(p => builderHelper.DistanceTo(field.Point, p)); } var settlementInfo = new SettlementInfo() { PreviewBitmap = previewBitmap, MainRoad = mainRoadPoints, Fields = fieldGrid }; return(settlementInfo); }
public TownRevolutionViewModel(SettlementInfo settInfo, FactionInfo factInfo) { _settlementInfo = settInfo; _factionInfo = factInfo; _factionVisual = new ImageIdentifierVM(BannerCode.CreateFrom(_settlementInfo.OriginalFaction.Banner), true); }