v2.5.0: added a 4th trinket option: random

This commit is contained in:
Evan Debenham
2024-09-03 14:50:39 -04:00
parent 03eff7ff1d
commit f5c4ccf20b
2 changed files with 27 additions and 8 deletions

View File

@@ -1402,6 +1402,8 @@ items.trinkets.wondrousresin.stats_desc=At its current level this trinket will f
items.trinkets.trinketcatalyst.name=magical catalyst items.trinkets.trinketcatalyst.name=magical catalyst
items.trinkets.trinketcatalyst.window_text=The water begins to glow as you add the catalyst. There are a few nearby items you could imbue with energy to turn into a magical trinket. items.trinkets.trinketcatalyst.window_text=The water begins to glow as you add the catalyst. There are a few nearby items you could imbue with energy to turn into a magical trinket.
items.trinkets.trinketcatalyst.desc=This ball of magical golden dust glimmers in the darkness of the dungeon. This catalyst can be used at an alchemy pot with a little alchemical energy to produce a unique trinket item.\n\nTrinkets provide various different effects that slightly alter the dungeon or its inhabitants. Trinkets can be upgraded with more energy to make their effect more powerful, or dropped to forego the effect entirely. items.trinkets.trinketcatalyst.desc=This ball of magical golden dust glimmers in the darkness of the dungeon. This catalyst can be used at an alchemy pot with a little alchemical energy to produce a unique trinket item.\n\nTrinkets provide various different effects that slightly alter the dungeon or its inhabitants. Trinkets can be upgraded with more energy to make their effect more powerful, or dropped to forego the effect entirely.
items.trinkets.trinketcatalyst$randomtrinket.name=random trinket
items.trinkets.trinketcatalyst$randomtrinket.desc=One nearby item is stuck inside a pouch that you can't get open.\n\nThe alchemy process will dissolve the pouch away, but you won't know what trinket you'll get until you do it!
items.trinkets.trinket$placeholder.name=trinket items.trinkets.trinket$placeholder.name=trinket

View File

@@ -134,14 +134,22 @@ public class TrinketCatalyst extends Item {
} }
} }
public static class RandomTrinket extends Item {
{
image = ItemSpriteSheet.TRINKET_HOLDER;
}
}
public static class WndTrinket extends Window { public static class WndTrinket extends Window {
private static final int WIDTH = 120; private static final int WIDTH = 120;
private static final int BTN_SIZE = 32; private static final int BTN_SIZE = 24;
private static final int BTN_GAP = 5; private static final int BTN_GAP = 4;
private static final int GAP = 2; private static final int GAP = 2;
private static final int NUM_TRINKETS = 3; private static final int NUM_TRINKETS = 4; //last one is a random choice
public WndTrinket( TrinketCatalyst cata ){ public WndTrinket( TrinketCatalyst cata ){
@@ -157,18 +165,22 @@ public class TrinketCatalyst extends Item {
add( message ); add( message );
//roll new trinkets if trinkets were not already rolled //roll new trinkets if trinkets were not already rolled
while (cata.rolledTrinkets.size() < NUM_TRINKETS){ while (cata.rolledTrinkets.size() < NUM_TRINKETS-1){
cata.rolledTrinkets.add((Trinket) Generator.random(Generator.Category.TRINKET)); cata.rolledTrinkets.add((Trinket) Generator.random(Generator.Category.TRINKET));
} }
for (int i = 0; i < NUM_TRINKETS; i++){ for (int i = 0; i < NUM_TRINKETS; i++){
ItemButton btnReward = new ItemButton(){ ItemButton btnReward = new ItemButton() {
@Override @Override
protected void onClick() { protected void onClick() {
ShatteredPixelDungeon.scene().addToFront(new RewardWindow(item())); ShatteredPixelDungeon.scene().addToFront(new RewardWindow(item()));
} }
}; };
btnReward.item(cata.rolledTrinkets.get(i)); if (i == NUM_TRINKETS-1){
btnReward.item(new RandomTrinket());
} else {
btnReward.item(cata.rolledTrinkets.get(i));
}
btnReward.setRect( (i+1)*(WIDTH - BTN_GAP) / NUM_TRINKETS - BTN_SIZE, message.top() + message.height() + BTN_GAP, BTN_SIZE, BTN_SIZE ); btnReward.setRect( (i+1)*(WIDTH - BTN_GAP) / NUM_TRINKETS - BTN_SIZE, message.top() + message.height() + BTN_GAP, BTN_SIZE, BTN_SIZE );
add( btnReward ); add( btnReward );
@@ -194,13 +206,18 @@ public class TrinketCatalyst extends Item {
RewardWindow.this.hide(); RewardWindow.this.hide();
WndTrinket.this.hide(); WndTrinket.this.hide();
Item result = item;
if (result instanceof RandomTrinket){
result = Generator.random(Generator.Category.TRINKET);
}
TrinketCatalyst cata = Dungeon.hero.belongings.getItem(TrinketCatalyst.class); TrinketCatalyst cata = Dungeon.hero.belongings.getItem(TrinketCatalyst.class);
if (cata != null) { if (cata != null) {
cata.detach(Dungeon.hero.belongings.backpack); cata.detach(Dungeon.hero.belongings.backpack);
Catalog.countUse(cata.getClass()); Catalog.countUse(cata.getClass());
item.identify(); result.identify();
((AlchemyScene)ShatteredPixelDungeon.scene()).craftItem(null, item); ((AlchemyScene)ShatteredPixelDungeon.scene()).craftItem(null, result);
} }
} }
}; };