Merge branch 'master' into master2

This commit is contained in:
Anthony Calosa
2024-10-16 20:45:48 +08:00
3 changed files with 15 additions and 12 deletions

View File

@@ -180,7 +180,7 @@ public class InventoryScene extends UIScene {
Deck data = (deckLocation.get(selected));
if (data == null) return;
done();
//done();
setSelected(null);
RewardScene.instance().loadRewards(data, RewardScene.Type.Loot, null, data.getTags().contains("noSell"));
Forge.switchScene(RewardScene.instance());
@@ -206,15 +206,7 @@ public class InventoryScene extends UIScene {
Deck data = deckLocation.get(selected);
if (data == null)
return;
if (openDialog == null) {
openDialog = createGenericDialog("", null, Forge.getLocalizer().getMessage("lblYes"),
Forge.getLocalizer().getMessage("lblNo"), () -> {
this.openBooster();
removeDialog();
}, this::removeDialog);
openDialog.getContentTable().add(Controls.newTextraLabel("Open Booster Pack?"));
}
showDialog(openDialog);
}
}
@@ -277,7 +269,7 @@ public class InventoryScene extends UIScene {
useButton.layout();
equipButton.setDisabled(true);
itemDescription.setText("Card Pack - " + data.getName() + "\n[%98]" + (data.getComment() == null?"":data.getComment()+" - ") + data.getAllCardsInASinglePool().countAll() + " cards");
itemDescription.setText(data.getName() + "\n[%98]" + (data.getComment() == null?"":data.getComment()+" - ") + data.getAllCardsInASinglePool().countAll() + " cards");
}

View File

@@ -26,6 +26,7 @@ import forge.item.PaperCard;
import forge.sound.SoundEffectType;
import forge.sound.SoundSystem;
import forge.util.ItemPool;
import java.util.Comparator;
/**
* Displays the rewards of a fight or a treasure
@@ -318,6 +319,14 @@ public class RewardScene extends UIScene {
}
public void loadRewards(Array<Reward> newRewards, Type type, ShopActor shopActor) {
// Sort the rewards based on the rarity of the card inside the reward/ lets give items rarity
newRewards.sort(Comparator.comparing(reward -> {
if (reward.getCard() != null && reward.getCard().getRarity() != null) {
return reward.getCard().getRarity().ordinal();
}
// Return a default value or handle the case where rarity is not present
return Integer.MAX_VALUE; // Assuming higher values mean less priority in sorting
}));
clearSelectable();
this.type = type;
doneClicked = false;

View File

@@ -11,6 +11,7 @@ import forge.item.SealedTemplate;
import forge.item.generation.BoosterGenerator;
import forge.item.generation.UnOpenedProduct;
import forge.model.CardBlock;
import forge.model.FModel;
import forge.util.Aggregates;
import java.io.Serializable;
@@ -136,7 +137,8 @@ public class AdventureEventController implements Serializable {
List<PaperCard> cards = BoosterGenerator.getBoosterPack(StaticData.instance().getBoosters().get(setCode));
Deck output = new Deck();
output.getMain().add(cards);
output.setName("Booster Pack: " + setCode);
String editionName = FModel.getMagicDb().getEditions().get(setCode).getName();
output.setName(editionName + " Booster");
output.setComment(setCode);
return output;
}