Fix gem check being rolled twice. (#474)

This commit is contained in:
Nick Gal
2021-02-05 15:25:46 -08:00
committed by GitHub
parent b65ab89a53
commit 440a559c64
@@ -17,21 +17,20 @@ public class Mining {
private static final int[] GLORIES = {1706, 1708, 1710, 1712}; private static final int[] GLORIES = {1706, 1708, 1710, 1712};
public boolean giveGem(Player player) { public boolean giveGem(Player player) {
int chance = 256;
for (int i = 0; i < GLORIES.length; i++) { for (int i = 0; i < GLORIES.length; i++) {
if ((player.playerEquipment[player.playerAmulet] == GLORIES[i] && Misc.random(86) == 1) || Misc.random(256) == 1) { if (player.playerEquipment[player.playerAmulet] == GLORIES[i]) {
return true; chance = 86;
} }
} }
return false; return Misc.random(chance) == 1;
} }
public void obtainGem(Player player) { public void obtainGem(Player player) {
int reward = RANDOM_GEMS[(int)(RANDOM_GEMS.length * Math.random())]; int reward = RANDOM_GEMS[(int)(RANDOM_GEMS.length * Math.random())];
if (giveGem(player)) {
player.getItemAssistant().addItem(reward, 1); player.getItemAssistant().addItem(reward, 1);
player.getPacketSender().sendMessage("You found an " + ItemAssistant.getItemName(reward) + "."); player.getPacketSender().sendMessage("You found an " + ItemAssistant.getItemName(reward) + ".");
} }
}
public final int[][] Pick_Settings = { public final int[][] Pick_Settings = {
{1265, 1, 1, 625}, //Bronze {1265, 1, 1, 625}, //Bronze