Adjust duplicate shop check to still spawn from intended list once all options have already been spawned once.

This commit is contained in:
jjayers99
2023-01-29 18:43:32 -05:00
parent b6364df7f2
commit 828e3cf59a

View File

@@ -599,20 +599,25 @@ public class MapStage extends GameStage {
restockPrice = 0; restockPrice = 0;
} }
possibleShops = new Array<>(shopList.split(",")); possibleShops = new Array<String>(shopList.split(","));
Array<String> filteredPossibleShops = possibleShops; Array<String> filteredPossibleShops = new Array<>();
if (!isRotatingShop) if (!isRotatingShop){
filteredPossibleShops.removeAll(shopsAlreadyPresent, false); for (String candidate : possibleShops)
if (filteredPossibleShops.notEmpty()){ {
possibleShops = filteredPossibleShops; if (!shopsAlreadyPresent.contains(candidate, false))
filteredPossibleShops.add(candidate);
}
}
if (filteredPossibleShops.isEmpty()){
filteredPossibleShops = possibleShops;
} }
Array<ShopData> shops; Array<ShopData> shops;
if (possibleShops.size == 0 || shopList.equals("")) if (filteredPossibleShops.size == 0 || shopList.equals(""))
shops = WorldData.getShopList(); shops = WorldData.getShopList();
else { else {
shops = new Array<>(); shops = new Array<>();
for (ShopData data : new Array.ArrayIterator<>(WorldData.getShopList())) { for (ShopData data : new Array.ArrayIterator<>(WorldData.getShopList())) {
if (possibleShops.contains(data.name, false)) { if (filteredPossibleShops.contains(data.name, false)) {
data.restockPrice = restockPrice; data.restockPrice = restockPrice;
shops.add(data); shops.add(data);
} }