/// <summary> /// 记录收获详情文本(以及当月收获银钱) /// </summary> private static void RecordHarvestDetails() { var currDate = new TaiwuDate(); int earnedMoney = 0; string details = GetHarvestedResourcesDetails(ref earnedMoney); if (!string.IsNullOrEmpty(details)) { MajordomoWindow.instance.AppendMessage(currDate, Message.IMPORTANCE_HIGH, TaiwuCommon.SetColor(TaiwuCommon.COLOR_LIGHT_GRAY, "本月收获资源") + ":" + details); } MajordomoWindow.instance.SetEarnedMoney(currDate, earnedMoney); details = GetHarvestedItemsDetails(); if (!string.IsNullOrEmpty(details)) { MajordomoWindow.instance.AppendMessage(currDate, Message.IMPORTANCE_HIGH, TaiwuCommon.SetColor(TaiwuCommon.COLOR_LIGHT_GRAY, "本月收获物品") + ":" + details); } details = GetHarvestedActorsDetails(); if (!string.IsNullOrEmpty(details)) { MajordomoWindow.instance.AppendMessage(currDate, Message.IMPORTANCE_HIGH, TaiwuCommon.SetColor(TaiwuCommon.COLOR_LIGHT_GRAY, "本月接纳新村民") + ":" + details); } }
public Record(TaiwuDate date) { this.messages = new List <Message> { new Message(Message.IMPORTANCE_HIGHEST, $"进入{date.ToString(richText: true)}。"), }; }
public void SetEarningStats(TaiwuDate date, EarningStats earningStats) { if (!this.history.ContainsKey(date)) { this.history[date] = new Record(date); } this.history[date].earningStats = earningStats; }
public void SetWorkingStats(TaiwuDate date, WorkingStats workingStats) { if (!this.history.ContainsKey(date)) { this.history[date] = new Record(date); } this.history[date].workingStats = workingStats; }
public void AppendMessage(TaiwuDate date, int importance, string message) { if (!this.history.ContainsKey(date)) { this.history[date] = new Record(date); } this.history[date].messages.Add(new Message(importance, message)); }
public void SetEarnedMoney(TaiwuDate date, int earnedMoney) { if (!this.history.ContainsKey(date)) { this.history[date] = new Record(date); } this.history[date].earnedMoney = earnedMoney; }
public void SetCompositeWorkIndex(TaiwuDate date, float compositeWorkIndex) { if (!this.history.ContainsKey(date)) { this.history[date] = new Record(date); } this.history[date].compositeWorkIndex = compositeWorkIndex; }
public Record(TaiwuDate date) { this.messages = new List <Message> { new Message(Message.IMPORTANCE_HIGHEST, $"进入{date.ToString(richText: true)}。"), }; this.workerStats = new WorkerStats(); this.workingStats = new WorkingStats(); this.earningStats = new EarningStats(); }
public static void LogBuildingAndWorker(BuildingWorkInfo info, int selectedWorkerId, int partId, int placeId, TaiwuDate currDate, Dictionary <int, Dictionary <int, int> > workerAttrs, bool suppressNoWorkerWarnning) { var building = DateFile.instance.homeBuildingsDate[partId][placeId][info.buildingIndex]; int baseBuildingId = building[0]; int buildingLevel = building[1]; var baseBuilding = DateFile.instance.basehomePlaceDate[baseBuildingId]; string buildingName = baseBuilding[0]; string attrName = Output.GetRequiredAttrName(info.requiredAttrId); string logText = string.Format("{0}:{1} ({2}) {3} [{4}, {5}] - ", TaiwuCommon.SetColor(TaiwuCommon.COLOR_LIGHT_GRAY, Common.ToFullWidth(info.priority.ToString("F0").PadLeft(4))), TaiwuCommon.SetColor(TaiwuCommon.COLOR_YELLOW, Common.ToFullWidth(buildingName.PadRight(5))), TaiwuCommon.SetColor(TaiwuCommon.COLOR_LIGHT_GRAY, Common.ToFullWidth(buildingLevel.ToString().PadLeft(2))), TaiwuCommon.SetColor(TaiwuCommon.COLOR_RICE_WHITE, Common.ToFullWidth(attrName.PadRight(2))), TaiwuCommon.SetColor(TaiwuCommon.COLOR_LIGHT_GRAY, Common.ToFullWidth(info.halfWorkingAttrValue.ToString().PadLeft(3))), TaiwuCommon.SetColor(TaiwuCommon.COLOR_LIGHT_GRAY, Common.ToFullWidth(info.fullWorkingAttrValue.ToString().PadLeft(3)))); if (selectedWorkerId >= 0) { string workerName = DateFile.instance.GetActorName(selectedWorkerId); int attrValue = info.requiredAttrId != 0 ? workerAttrs[selectedWorkerId][info.requiredAttrId] : -1; int mood = int.Parse(DateFile.instance.GetActorDate(selectedWorkerId, 4, false)); int favor = DateFile.instance.GetActorFavor(false, DateFile.instance.MianActorID(), selectedWorkerId, getLevel: true); // 这里的工作效率并不一定等于最终工作效率,因为可能还有厢房未分配 int workEffectiveness = info.requiredAttrId != 0 ? Original.GetWorkEffectiveness(partId, placeId, info.buildingIndex, selectedWorkerId) : -1; string workEffectivenessStr = workEffectiveness >= 0 ? workEffectiveness / 2 + "%" : "N/A"; MajordomoWindow.instance.AppendMessage(currDate, Message.IMPORTANCE_LOW, logText + string.Format( "{0} 资质: {1} 心情: {2} 好感: {3} 工作效率: {4}", TaiwuCommon.SetColor(TaiwuCommon.COLOR_YELLOW, Common.ToFullWidth(workerName.PadRight(5))), TaiwuCommon.SetColor(TaiwuCommon.COLOR_LIGHT_GRAY, Common.ToFullWidth(attrValue.ToString().PadLeft(3))), TaiwuCommon.SetColor(TaiwuCommon.COLOR_LIGHT_GRAY, Common.ToFullWidth(mood.ToString().PadLeft(4))), TaiwuCommon.SetColor(TaiwuCommon.COLOR_LIGHT_GRAY, Common.ToFullWidth(favor.ToString().PadLeft(2))), TaiwuCommon.SetColor(TaiwuCommon.COLOR_WHITE, Common.ToFullWidth(workEffectivenessStr.PadLeft(4))))); } else { if (suppressNoWorkerWarnning) { MajordomoWindow.instance.AppendMessage(currDate, Message.IMPORTANCE_LOW, logText + TaiwuCommon.SetColor(TaiwuCommon.COLOR_LIGHT_GRAY, "无合适人选")); } else { MajordomoWindow.instance.AppendMessage(currDate, Message.IMPORTANCE_HIGH, logText + TaiwuCommon.SetColor(TaiwuCommon.COLOR_RED, "无合适人选")); } } }
public static void LogAuxiliaryBedroomAndWorker(int bedroomIndex, List <BuildingWorkInfo> relatedBuildings, int priority, int selectedWorkerId, int partId, int placeId, TaiwuDate currDate, Dictionary <int, Dictionary <int, int> > workerAttrs) { var building = DateFile.instance.homeBuildingsDate[partId][placeId][bedroomIndex]; int baseBuildingId = building[0]; int buildingLevel = building[1]; var baseBuilding = DateFile.instance.basehomePlaceDate[baseBuildingId]; string buildingName = baseBuilding[0]; var attrNames = new List <string>(); foreach (var info in relatedBuildings) { string attrName = Common.ToFullWidth(Output.GetRequiredAttrName(info.requiredAttrId).PadRight(2)); attrNames.Add(TaiwuCommon.SetColor(TaiwuCommon.COLOR_RICE_WHITE, attrName)); } string logText = string.Format("{0}:{1} ({2}) [{3}] - ", TaiwuCommon.SetColor(TaiwuCommon.COLOR_LIGHT_GRAY, Common.ToFullWidth(priority.ToString().PadLeft(4))), TaiwuCommon.SetColor(TaiwuCommon.COLOR_YELLOW, Common.ToFullWidth(buildingName.PadRight(5))), TaiwuCommon.SetColor(TaiwuCommon.COLOR_LIGHT_GRAY, Common.ToFullWidth(buildingLevel.ToString().PadLeft(2))), string.Join(", ", attrNames.ToArray())); if (selectedWorkerId >= 0) { string workerName = DateFile.instance.GetActorName(selectedWorkerId); var attrValues = new List <string>(); foreach (var info in relatedBuildings) { string attrValue = Common.ToFullWidth(workerAttrs[selectedWorkerId][info.requiredAttrId].ToString().PadLeft(3)); attrValues.Add(TaiwuCommon.SetColor(TaiwuCommon.COLOR_LIGHT_GRAY, attrValue)); } int mood = int.Parse(DateFile.instance.GetActorDate(selectedWorkerId, 4, addValue: false)); int favor = DateFile.instance.GetActorFavor(false, DateFile.instance.MianActorID(), selectedWorkerId, getLevel: true); MajordomoWindow.instance.AppendMessage(currDate, Message.IMPORTANCE_LOW, logText + string.Format( "{0} 资质: [{1}] 心情: {2} 好感: {3}", TaiwuCommon.SetColor(TaiwuCommon.COLOR_YELLOW, Common.ToFullWidth(workerName.PadRight(5))), string.Join(", ", attrValues.ToArray()), TaiwuCommon.SetColor(TaiwuCommon.COLOR_LIGHT_GRAY, Common.ToFullWidth(mood.ToString().PadLeft(4))), TaiwuCommon.SetColor(TaiwuCommon.COLOR_LIGHT_GRAY, Common.ToFullWidth(favor.ToString().PadLeft(2))))); } else { MajordomoWindow.instance.AppendMessage(currDate, Message.IMPORTANCE_HIGH, logText + TaiwuCommon.SetColor(TaiwuCommon.COLOR_RED, "无合适人选")); } }
public HumanResource(int partId, int placeId) { this.partId = partId; this.placeId = placeId; this.currDate = new TaiwuDate(); if (Main.settings.excludedBuildings.ContainsKey(partId) && Main.settings.excludedBuildings[partId].ContainsKey(placeId)) { this.excludedBuildings = new HashSet <int>(Main.settings.excludedBuildings[partId][placeId]); } else { this.excludedBuildings = new HashSet <int>(); } this.excludedWorkers = new HashSet <int>(); }
/// <summary> /// 计算待展示序列,以及对应坐标标签 /// </summary> /// <param name="xLabels"></param> /// <param name="drawXLabels"></param> /// <returns></returns> private List <double> GetChartData(out List <string> xLabels, out List <bool> drawXLabels) { if (this.selectedMetricId < 0 || this.selectedMetricId >= PanelCharts.METRICS_SELECTORS.Count) { throw new Exception("MetricId out of range: " + this.selectedMetricId); } if (this.selectedGranularityId < 0 || this.selectedGranularityId >= PanelCharts.GRANULARITY_MONTHS.Length) { throw new Exception("GranularityId out of range: " + this.selectedGranularityId); } var metricSelector = PanelCharts.METRICS_SELECTORS[this.selectedMetricId]; int nGranularityMonths = PanelCharts.GRANULARITY_MONTHS[this.selectedGranularityId]; int nFetchingMonths = PanelCharts.MAX_X_COUNT * nGranularityMonths; var results = this.history.OrderByDescending(entry => entry.Key).Take(nFetchingMonths) .GroupBy( entry => TaiwuDate.CreateWithMonth(entry.Key.year, entry.Key.GetMonthIndex() / nGranularityMonths * nGranularityMonths), metricSelector, (key, values) => new { key, count = values.Count(), value = values.Average() }) .Where(data => data.count == nGranularityMonths) .OrderBy(data => data.key); var yValues = results.Select(data => data.value) .Select(value => double.IsInfinity(value) || double.IsNaN(value) ? 0 : value) .ToList(); xLabels = new List <string>(); drawXLabels = new List <bool>(); var dates = results.Select(data => data.key).ToList(); int labelSkipStep = dates.Count > PanelCharts.X_LABEL_COUNT ? dates.Count / PanelCharts.X_LABEL_COUNT : 1; for (int i = 0; i < dates.Count; ++i) { var date = dates[i]; xLabels.Add(string.Format("{0:D}-{1:D2}", date.year, date.GetMonthIndex() + 1)); drawXLabels.Add(i % labelSkipStep == 0); } return(yValues); }