
Originally Posted by
Tesla
In regards to:
Then I believe what you're looking for is using the 'bitwise AND'.
If your code requires all the methods to be run then I suggest using a 'bitwise AND', the symbol of which is
& (a single ampersand).
This is because using the regular AND (&&) symbol requires all values to be true/1, and as soon as it encounters a value which is
not true/1 (i.e. false or 0) then it will not check the rest (as not all of the values will be true/1).
Using a bitwise AND checks each individual value regardless of if any of them are false/0.
The code would then be written as such:
Code:
if (killer.isAtWild() & killer.getEp() > 0 & getRiskedWealth(killer) > 76000 & getRiskedWealth(player) > 76000) {
... and would not function as intended. This is the definitely not the appropriate operator to use, lol - may as well use logical or (||) in that case.
Also, to nitpick @ Clem and Arham, you'd probably want a combination of both of your solutions.
Code:
private static final int MIN_WEALTH = 76_000;
...
private boolean can(Player killer, player victim, int amount) {
...
}
...
public boolean can(Player killer, Player victim) {
return can(killer, victim, MIN_WEALTH);
}
...
if (can(killer, victim)) {
...
}