Browse Source

boons refreshable, boon level determined by votary rank, shrines should work for all, boons nation friendly again

lakebane-new
FatBoy-DOTC 4 months ago
parent
commit
7688d21fe6
  1. 57
      src/engine/net/client/handlers/MerchantMsgHandler.java
  2. 26
      src/engine/objects/Shrine.java

57
src/engine/net/client/handlers/MerchantMsgHandler.java

@ -17,6 +17,7 @@ import engine.powers.PowersBase;
import engine.server.MBServerStatics; import engine.server.MBServerStatics;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Objects;
/* /*
* @Author: * @Author:
@ -105,7 +106,7 @@ public class MerchantMsgHandler extends AbstractClientMsgHandler {
// Validate player can obtain blessing // Validate player can obtain blessing
if (GuildStatusController.isGuildLeader(player.getGuildStatus()) == false) { if (!GuildStatusController.isGuildLeader(player.getGuildStatus())) {
ErrorPopupMsg.sendErrorPopup(player, 173); // You must be the leader of a guild to receive a blessing ErrorPopupMsg.sendErrorPopup(player, 173); // You must be the leader of a guild to receive a blessing
return; return;
} }
@ -126,12 +127,12 @@ public class MerchantMsgHandler extends AbstractClientMsgHandler {
realm = RealmMap.getRealmForCity(city); realm = RealmMap.getRealmForCity(city);
if (realm.getCanBeClaimed() == false) { if (!realm.getCanBeClaimed()) {
ErrorPopupMsg.sendErrorPopup(player, 180); // This territory cannot be ruled by anyone ErrorPopupMsg.sendErrorPopup(player, 180); // This territory cannot be ruled by anyone
return; return;
} }
if (realm.isRuled() == true) { if (realm.isRuled()) {
ErrorPopupMsg.sendErrorPopup(player, 178); // This territory is already claimed ErrorPopupMsg.sendErrorPopup(player, 178); // This territory is already claimed
return; return;
} }
@ -142,12 +143,12 @@ public class MerchantMsgHandler extends AbstractClientMsgHandler {
} }
private static void requestBoon(MerchantMsg msg, ClientConnection origin, PlayerCharacter player, NPC npc) { private static void requestBoon(PlayerCharacter player, NPC npc) {
Building shrineBuilding; Building shrineBuilding;
Shrine shrine; Shrine shrine;
if (npc.getGuild() != player.getGuild()) if (!npc.getGuild().getNation().equals(player.getGuild().getNation()))
return; return;
shrineBuilding = npc.getBuilding(); shrineBuilding = npc.getBuilding();
@ -155,7 +156,7 @@ public class MerchantMsgHandler extends AbstractClientMsgHandler {
if (shrineBuilding == null) if (shrineBuilding == null)
return; return;
if (shrineBuilding.getBlueprint() != null && shrineBuilding.getBlueprint().getBuildingGroup() != engine.Enum.BuildingGroup.SHRINE) if (shrineBuilding.getBlueprint() != null && !shrineBuilding.getBlueprint().getBuildingGroup().equals(engine.Enum.BuildingGroup.SHRINE))
return; return;
if (shrineBuilding.getRank() == -1) if (shrineBuilding.getRank() == -1)
@ -171,11 +172,9 @@ public class MerchantMsgHandler extends AbstractClientMsgHandler {
return; return;
} }
//already haz boon.
if (player.containsEffect(shrine.getShrineType().getPowerToken())) { if (player.containsEffect(shrine.getShrineType().getPowerToken())) {
ErrorPopupMsg.sendErrorPopup(player, 199); //remove old boon to apply new one, allows boon refreshing
return; player.effects.remove(PowersManager.getPowerByToken(shrine.getShrineType().getPowerToken()).name);
} }
if (!Shrine.canTakeFavor(player, shrine)) if (!Shrine.canTakeFavor(player, shrine))
@ -191,16 +190,34 @@ public class MerchantMsgHandler extends AbstractClientMsgHandler {
return; return;
} }
int rank = shrine.getRank(); int trains = 0;
//R8 trees always get atleast rank 2 boons. rank uses index, where 0 is first place, 1 is second, etc... switch(npc.getRank()){
if (shrineBuilding.getCity() != null && shrineBuilding.getCity().getTOL() != null && shrineBuilding.getCity().getTOL().getRank() == 8) case 1:
if (rank != 0) trains = 5;
rank = 1; break;
int trains = 40 - (rank * 10); case 2:
if (trains < 0) trains = 10;
trains = 0; break;
case 3:
trains = 15;
break;
case 4:
trains = 20;
break;
case 5:
trains = 25;
break;
case 6:
trains = 30;
break;
case 7:
trains = 35;
break;
}
if(Objects.requireNonNull(shrineBuilding.getCity()).getTOL() != null && shrineBuilding.getCity().getTOL().getRank() == 8)
trains += 5;
//System.out.println(trains);
PowersManager.applyPower(player, player, player.getLoc(), shrinePower.getToken(), trains, false); PowersManager.applyPower(player, player, player.getLoc(), shrinePower.getToken(), trains, false);
ChatManager.chatGuildInfo(player.getGuild(), player.getName() + " has recieved a boon costing " + 1 + " point of favor."); ChatManager.chatGuildInfo(player.getGuild(), player.getName() + " has recieved a boon costing " + 1 + " point of favor.");
shrineBuilding.addEffectBit(1000000 << 2); shrineBuilding.addEffectBit(1000000 << 2);
@ -420,7 +437,7 @@ public class MerchantMsgHandler extends AbstractClientMsgHandler {
if (isHermit(npc)) if (isHermit(npc))
requestHermitBlessing(msg, origin, player, npc); requestHermitBlessing(msg, origin, player, npc);
else else
requestBoon(msg, origin, player, npc); requestBoon(player, npc);
break; break;
case 15: case 15:
LeaderboardMessage lbm = new LeaderboardMessage(); LeaderboardMessage lbm = new LeaderboardMessage();

26
src/engine/objects/Shrine.java

@ -43,7 +43,7 @@ public class Shrine extends AbstractWorldObject implements Comparable<Shrine> {
public static boolean canTakeFavor(PlayerCharacter grantee, Shrine shrine) { public static boolean canTakeFavor(PlayerCharacter grantee, Shrine shrine) {
if (shrine.shrineType.isRace()) if (shrine.shrineType.isRace()) {
switch (grantee.getRaceID()) { switch (grantee.getRaceID()) {
case 2000: case 2000:
case 2001: case 2001:
@ -107,7 +107,7 @@ public class Shrine extends AbstractWorldObject implements Comparable<Shrine> {
break; break;
} }
else }else {
switch (grantee.getPromotionClassID()) { switch (grantee.getPromotionClassID()) {
case 2504: case 2504:
if (shrine.shrineType == ShrineType.Assassin) if (shrine.shrineType == ShrineType.Assassin)
@ -198,7 +198,7 @@ public class Shrine extends AbstractWorldObject implements Comparable<Shrine> {
return true; return true;
break; break;
} }
}
return false; return false;
} }
@ -227,26 +227,6 @@ public class Shrine extends AbstractWorldObject implements Comparable<Shrine> {
} }
public void decay() {
if (this.getFavors() == 0)
return;
int decayAmount = (int) (this.getFavors() - (this.getFavors() * .10f));
if (decayAmount < 0)
decayAmount = 0;
if (!DbManager.ShrineQueries.updateFavors(this, decayAmount, this.getFavors())) {
Logger.error("Shrine Decay", "Error writing to DB. UUID: " + this.getObjectUUID());
return;
}
this.favors = decayAmount;
Logger.info(shrineType.name() + " uuid:" + this.getObjectUUID() + " Amount: " + this.getFavors() * .10f);
}
public synchronized boolean addFavor(PlayerCharacter boonOwner, Item boonItem) { public synchronized boolean addFavor(PlayerCharacter boonOwner, Item boonItem) {
if (boonOwner == null) if (boonOwner == null)

Loading…
Cancel
Save