Skip to content

Commit

Permalink
Dev (#177)
Browse files Browse the repository at this point in the history
* noblueprint なモジュールをモジュール選択画面に表示しないようにした

* パラニド派閥首都と凝縮物質格納施設をWebの計算機にエクスポートしないようにした

* 日光の最大値を100000%に変更した

* モジュール生産時の追加効果を取得する際の誤りを修正

* テストに通るようにした
  • Loading branch information
Ocelot1210 authored Apr 30, 2023
1 parent cabd4cb commit 787e1ed
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 10 deletions.
19 changes: 19 additions & 0 deletions LibX4/Xml/XAttributeExtension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,25 @@ public static double GetDouble(this XAttribute? attr)
}


/// <summary>
/// XML 属性の値を double として取得する。変換できない場合は default と見なす。
/// </summary>
/// <param name="attr">値を取得する XML 属性</param>
/// <returns>変換済みの属性値又は 0.0</returns>
public static double GetDoubleOrDefault(this XAttribute? attr)
{
try
{
var value = attr?.Value ?? throw XmlFormatException.CreateFrom(attr);
return double.Parse(value, CultureInfo.InvariantCulture);
}
catch
{
return default;
}
}


/// <summary>
/// XML 属性の値を int として取得する
/// </summary>
Expand Down
2 changes: 1 addition & 1 deletion X4_ComplexCalculator/Localization/Lang.csv
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ CheckUpdate_NowDownloading;Downloading the update...
# Station Calculator import/export dialog
# ------------------------------------------------------
StationCalculatorExport_Title;Export to Station Calculator
StationCalculatorExport_Description;Please copy the URL.\r\nNote: The following modules are excluded.\r\n・Venture module
StationCalculatorExport_Description;Please copy the URL.\r\nNote: The following modules are excluded.\r\n・Venture module\r\n・Paranid Faction Capital\r\n・Condensate Containment Facility
StationCalculatorImport_Title;Importing from Station Calculator
StationCalculatorImport_Description;Please enter the URL displayed when you click the \r\nShare button at the top of Station Calculator.

Expand Down
2 changes: 1 addition & 1 deletion X4_ComplexCalculator/Localization/Lang.ja-JP.csv
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ CheckUpdate_NowDownloading;ダウンロード中...
# Station Calculator import/export dialog
# ------------------------------------------------------
StationCalculatorExport_Title;Station Calculatorへエクスポート
StationCalculatorExport_Description;URLをコピーして下さい\r\n注) 以下のモジュールは除外しています。\r\n・探検モジュール
StationCalculatorExport_Description;URLをコピーして下さい\r\n注) 以下のモジュールは除外しています。\r\n・探検モジュール\r\n・パラニド 派閥首都\r\n・凝縮物質格納施設
StationCalculatorImport_Title;Station Calculatorからインポート
StationCalculatorImport_Description;Station Calculator上部のShareボタンをクリックした時に\r\n表示されるURLを入力してください

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Prism.Mvvm;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Input;
Expand Down Expand Up @@ -49,9 +50,19 @@ public bool Export(IWorkArea WorkArea)
// モジュール情報を追加
sb.Append("l=@");


var ignoreModuleTypeIds = new HashSet<string>() {
"ventureplatform",
};

var ignoreModuleIds = new HashSet<string>() {
"module_gen_dock_m_venturer_01",
"module_par_def_claim_story_01",
"module_pir_stor_condensate_s_01",
};

var modules = WorkArea.StationData.ModulesInfo.Modules
.Where(x => x.Module.ModuleType.ModuleTypeID != "ventureplatform"
&& x.Module.ID != "module_gen_dock_m_venturer_01");
.Where(x => !ignoreModuleTypeIds.Contains(x.Module.ModuleType.ModuleTypeID) && !ignoreModuleIds.Contains(x.Module.ID));

foreach (var module in modules)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ private void UpdateModulesMain()

var newModules = X4Database.Instance.Ware.GetAll<IX4Module>()
.Where(x =>
!x.Tags.Contains("noplayerblueprint") &&
!(x.Tags.Contains("noplayerblueprint") || x.Tags.Contains("noblueprint")) &&
checkedModuleTypes.Contains(x.ModuleType.ModuleTypeID) &&
checkedOwners.Intersect(x.Owners.Select(y => y.FactionID)).Any())
.Select(x => new ModulesListItem(x));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
DefaultValue="100"
FormatString="{}{0:F3} %"
Increment="0.001"
Maximum="1000"
Maximum="100000"
Minimum="0"
Value="{Binding Sunlight, Mode=TwoWay, Converter={StaticResource DoubleUpDownConverter}}" />
</StackPanel>
Expand Down
5 changes: 1 addition & 4 deletions X4_DataExporterWPF/Export/Ware/WareEffectExporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,7 @@ internal IEnumerable<WareEffect> GetRecords(IProgress<(int currentStep, int maxS
var effectID = effect.Attribute("type")?.Value;
if (string.IsNullOrEmpty(effectID)) continue;

if (!double.TryParse(effect.Attribute("product")?.Value, out var product))
{
product = 0.0;
}
var product = effect.Attribute("product")?.GetDoubleOrDefault() ?? 0.0;

yield return new WareEffect(wareID, method, effectID, product);
}
Expand Down

0 comments on commit 787e1ed

Please sign in to comment.