Browse Source

NPC special price option

lakebane2
FatBoy-DOTC 2 weeks ago
parent
commit
520219404c
  1. 1
      src/engine/db/handlers/dbNPCHandler.java
  2. 7
      src/engine/net/client/ClientMessagePump.java
  3. 2
      src/engine/objects/NPC.java

1
src/engine/db/handlers/dbNPCHandler.java

@ -206,6 +206,7 @@ public class dbNPCHandler extends dbHandlerBase { @@ -206,6 +206,7 @@ public class dbNPCHandler extends dbHandlerBase {
try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE obj_npc SET specialPrice=? WHERE UID = ?")) {
preparedStatement.setInt(1, npc.getSpecialPrice());
preparedStatement.setInt(2, npc.getDBID());
preparedStatement.executeUpdate();

7
src/engine/net/client/ClientMessagePump.java

@ -1683,6 +1683,13 @@ public class ClientMessagePump implements NetMsgHandler { @@ -1683,6 +1683,13 @@ public class ClientMessagePump implements NetMsgHandler {
int cost = ((int)((toRepair.getMagicValue()/max*(max - dur)) + (npc.getSpecialPrice() * npc.buyPercent))) + (int)(npc.getSpecialPrice() * (max - dur));
//int pointsToRepair = max - dur;
//int magicValue = toRepair.getMagicValue();
//if(magicValue == 0)
// magicValue = 1;
//int calculatedValue = toRepair.getDurabilityMax() * magicValue;
//float costPerPoint = (magicValue / max) * ( 1 + npc.buyPercent);
//cost = (int)(pointsToRepair * costPerPoint) + npc.getSpecialPrice();
Building b = (!npc.isStatic()) ? npc.getBuilding() : null;
if (b != null)

2
src/engine/objects/NPC.java

@ -1302,7 +1302,7 @@ public class NPC extends AbstractCharacter { @@ -1302,7 +1302,7 @@ public class NPC extends AbstractCharacter {
public void setSpecialPrice(int specialPrice) {
this.specialPrice = specialPrice;
DbManager.NPCQueries.updateDatabase(this);
DbManager.NPCQueries.updateSpecialPricing(this);
}
public void processUpgradeNPC(PlayerCharacter player) {

Loading…
Cancel
Save