Browse Source

Handler created for ModifyStatMsg

combat-2
MagicBot 8 months ago
parent
commit
a162377685
  1. 31
      src/engine/net/client/ClientMessagePump.java
  2. 2
      src/engine/net/client/Protocol.java
  3. 60
      src/engine/net/client/handlers/ModifyStatMsgHandler.java

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

@ -54,34 +54,6 @@ public class ClientMessagePump implements NetMsgHandler { @@ -54,34 +54,6 @@ public class ClientMessagePump implements NetMsgHandler {
Logger.error(msg.toString());
}
private static void modifyStat(ModifyStatMsg msg, ClientConnection origin) {
PlayerCharacter pc = SessionManager.getPlayerCharacter(origin);
if (pc == null)
return;
int type = msg.getType();
switch (type) {
case MBServerStatics.STAT_STR_ID:
pc.addStr(msg.getAmount());
break;
case MBServerStatics.STAT_DEX_ID:
pc.addDex(msg.getAmount());
break;
case MBServerStatics.STAT_CON_ID:
pc.addCon(msg.getAmount());
break;
case MBServerStatics.STAT_INT_ID:
pc.addInt(msg.getAmount());
break;
case MBServerStatics.STAT_SPI_ID:
pc.addSpi(msg.getAmount());
break;
}
}
// called when player clicks respawn button
private static void respawn(RespawnMsg msg, ClientConnection origin) throws MsgSendException {
@ -263,9 +235,6 @@ public class ClientMessagePump implements NetMsgHandler { @@ -263,9 +235,6 @@ public class ClientMessagePump implements NetMsgHandler {
break;
case OPENVAULT:
break;
case RAISEATTR:
modifyStat((ModifyStatMsg) msg, origin);
break;
case COSTTOOPENBANK:
ackBankWindowOpened((AckBankWindowOpenedMsg) msg, origin);
break;

2
src/engine/net/client/Protocol.java

@ -162,7 +162,7 @@ public enum Protocol { @@ -162,7 +162,7 @@ public enum Protocol {
POWERACTIONDD(0xD43052F8, ModifyHealthMsg.class, null), //Modify Health/Mana/Stamina using power
POWERACTIONDDDIE(0xC27D446B, null, null), //Modify Health/Mana/Stamina using power and kill target
POWERTARGNAME(0x5A807CCE, SendSummonsRequestMsg.class, null), // Send Summons Request
RAISEATTR(0x5EEB65E0, ModifyStatMsg.class, null), // Modify Stat
RAISEATTR(0x5EEB65E0, ModifyStatMsg.class, ModifyStatMsgHandler.class), // Modify Stat
RANDOM(0xAC5D0135, RandomMsg.class, RandomMsgHandler.class), //RequestSend random roll
READYTOENTER(0x490E4FE0, EnterWorldReceivedMsg.class, null), //Client Ack Receive Enter World
REALMDATA(0x2399B775, null, null), //Realm Data - Optional(?)

60
src/engine/net/client/handlers/ModifyStatMsgHandler.java

@ -0,0 +1,60 @@ @@ -0,0 +1,60 @@
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
// Magicbane Emulator Project © 2013 - 2022
// www.magicbane.com
package engine.net.client.handlers;
import engine.exception.MsgSendException;
import engine.net.client.ClientConnection;
import engine.net.client.msg.ClientNetMsg;
import engine.net.client.msg.ModifyStatMsg;
import engine.objects.PlayerCharacter;
import engine.server.MBServerStatics;
public class ModifyStatMsgHandler extends AbstractClientMsgHandler {
public ModifyStatMsgHandler() {
super(ModifyStatMsg.class);
}
@Override
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException {
PlayerCharacter playerCharacter = origin.getPlayerCharacter();
// Member variable declaration
ModifyStatMsg msg;
// Member variable assignment
msg = (ModifyStatMsg) baseMsg;
int type = msg.getType();
switch (type) {
case MBServerStatics.STAT_STR_ID:
playerCharacter.addStr(msg.getAmount());
break;
case MBServerStatics.STAT_DEX_ID:
playerCharacter.addDex(msg.getAmount());
break;
case MBServerStatics.STAT_CON_ID:
playerCharacter.addCon(msg.getAmount());
break;
case MBServerStatics.STAT_INT_ID:
playerCharacter.addInt(msg.getAmount());
break;
case MBServerStatics.STAT_SPI_ID:
playerCharacter.addSpi(msg.getAmount());
break;
}
return true;
}
}
Loading…
Cancel
Save