Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,12 @@ mod_info.json # the usual content, no need for mod plugin

## Integration with Other Mods

See various CSV files in [data/stelnet](assets/data/stelnet/) directory.
To be able to exclude/include markets and storages in the Stelnet intel tab results
see various CSV files in [data/stelnet](assets/data/stelnet) directory.
For example, to exclude a faction in your mod create a file:
`starsector/mods/{your_mod_dir}/data/stelnet/exclude/market_by_faction.csv`
with content:
```text
id
hegemony
```
2 changes: 2 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
Unreleased (TBD)
- Change Commodities Intel tab to filter out markets returned by the `Excluder` - related files:
`market_by_faction.csv`, `market_by_id.csv`, `market_by_system.csv`, `market_by_tag.csv` and `skill_by_id.csv`


Version 3.2.2 (2025.04.28)
Expand Down
23 changes: 9 additions & 14 deletions src/stelnet/board/commodity/market/MarketFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@

import com.fs.starfarer.api.Global;
import com.fs.starfarer.api.campaign.econ.MarketAPI;
import java.util.Collections;
import java.util.Comparator;
import java.util.Arrays;
import java.util.List;
import lombok.RequiredArgsConstructor;
import stelnet.board.commodity.price.Price;
import stelnet.filter.MarketNotHidden;
import stelnet.util.CollectionUtils;
import stelnet.util.Excluder;


@RequiredArgsConstructor
public abstract class MarketFactory {
Expand All @@ -17,24 +18,18 @@ public abstract class MarketFactory {

public List<MarketAPI> createMarkets() {
List<MarketAPI> markets = Global.getSector().getEconomy().getMarketsCopy();
CollectionUtils.reduce(markets, new MarketNotHidden());
CollectionUtils.reduce(markets, Arrays.asList(new MarketNotHidden(), Excluder.getMarketFilter()));
filterMarkets(markets);
sortMarkets(markets);
return markets;
}

protected void sortMarkets(List<MarketAPI> markets) {
Collections.sort(
markets,
new Comparator<MarketAPI>() {
@Override
public int compare(MarketAPI marketA, MarketAPI marketB) {
float priceA = getPrice().getUnitPrice(marketA);
float priceB = getPrice().getUnitPrice(marketB);
return (int) Math.signum(priceB - priceA);
}
}
);
markets.sort((marketA, marketB) -> {
float priceA = getPrice().getUnitPrice(marketA);
float priceB = getPrice().getUnitPrice(marketB);
return (int) Math.signum(priceB - priceA);
});
}

protected abstract Price getPrice();
Expand Down