79 Set<MarketAPI> already =
new HashSet<MarketAPI>();
84 ListMap<MarketAPI> locationIdToMarket =
new ListMap<MarketAPI>();
85 for (MarketAPI market :
Global.
getSector().getEconomy().getMarketsCopy()) {
86 if (market.isHidden())
continue;
87 locationIdToMarket.add(market.getContainingLocation().getId(), market);
90 WeightedRandomPicker<MarketAPI> pickerWithPirateActivity =
new WeightedRandomPicker<MarketAPI>();
91 WeightedRandomPicker<MarketAPI> picker =
new WeightedRandomPicker<MarketAPI>();
92 OUTER:
for (MarketAPI market :
Global.
getSector().getEconomy().getMarketsCopy()) {
93 if (market.isHidden())
continue;
94 if (market.getSize() <= 4)
continue;
95 if (market.isPlayerOwned())
continue;
96 if (already.contains(market))
continue;
98 if (market.getFaction().getCustom().optBoolean(Factions.CUSTOM_POSTS_NO_BOUNTIES)) {
102 if (
Global.
getSector().isInNewGameAdvance() && market.getId().equals(
"jangala")) {
106 for (MarketAPI other : locationIdToMarket.getList(market.getContainingLocation().getId())) {
107 if (market.getFaction() == other.getFaction() && already.contains(other)) {
112 float w = market.getSize() * 0.25f;
113 for (MarketAPI other : locationIdToMarket.getList(market.getContainingLocation().getId())) {
114 if (market.getFaction().isHostileTo(other.getFaction())) {
121 if (other.getMemoryWithoutUpdate().getBoolean(MemFlags.MARKET_MILITARY) ||
122 other.getMemoryWithoutUpdate().getBoolean(MemFlags.MARKET_PATROL)) {
125 if (market.getMemoryWithoutUpdate().getBoolean(MemFlags.MARKET_MILITARY)) {
127 }
else if (market.getMemoryWithoutUpdate().getBoolean(MemFlags.MARKET_PATROL)) {
133 if (market.hasCondition(Conditions.PIRATE_ACTIVITY)) {
135 pickerWithPirateActivity.add(market, w);
137 picker.add(market, w);
143 MarketAPI market = pickerWithPirateActivity.pick();
144 float w = pickerWithPirateActivity.getWeight(market);
145 if (market ==
null) {
146 market = picker.pick();
147 w = picker.getWeight(market);
152 if ((
float) Math.random() > w * 0.01f * probMult) {