Make MCSkill immutable with record
This commit is contained in:
@@ -95,14 +95,14 @@ public final class MonsterCarnivalHandler extends AbstractPacketHandler {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final MCSkill skill = CarnivalFactory.getInstance().getSkill(skillid.get(num)); //ugh wtf
|
final MCSkill skill = CarnivalFactory.getInstance().getSkill(skillid.get(num)); //ugh wtf
|
||||||
if (skill == null || c.getPlayer().getCP() < skill.cpLoss) {
|
if (skill == null || c.getPlayer().getCP() < skill.cpLoss()) {
|
||||||
c.sendPacket(PacketCreator.CPQMessage((byte) 1));
|
c.sendPacket(PacketCreator.CPQMessage((byte) 1));
|
||||||
c.sendPacket(PacketCreator.enableActions());
|
c.sendPacket(PacketCreator.enableActions());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final Disease dis = skill.getDisease();
|
final Disease dis = skill.getDisease();
|
||||||
Party enemies = c.getPlayer().getParty().getEnemy();
|
Party enemies = c.getPlayer().getParty().getEnemy();
|
||||||
if (skill.targetsAll) {
|
if (skill.targetsAll()) {
|
||||||
int hitChance = rollHitChance(dis.getMobSkillType());
|
int hitChance = rollHitChance(dis.getMobSkillType());
|
||||||
if (hitChance <= 80) {
|
if (hitChance <= 80) {
|
||||||
for (PartyCharacter mpc : enemies.getPartyMembers()) {
|
for (PartyCharacter mpc : enemies.getPartyMembers()) {
|
||||||
@@ -128,11 +128,11 @@ public final class MonsterCarnivalHandler extends AbstractPacketHandler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
neededCP = skill.cpLoss;
|
neededCP = skill.cpLoss();
|
||||||
c.sendPacket(PacketCreator.enableActions());
|
c.sendPacket(PacketCreator.enableActions());
|
||||||
} else if (tab == 2) { //protectors
|
} else if (tab == 2) { //protectors
|
||||||
final MCSkill skill = CarnivalFactory.getInstance().getGuardian(num);
|
final MCSkill skill = CarnivalFactory.getInstance().getGuardian(num);
|
||||||
if (skill == null || c.getPlayer().getCP() < skill.cpLoss) {
|
if (skill == null || c.getPlayer().getCP() < skill.cpLoss()) {
|
||||||
c.sendPacket(PacketCreator.CPQMessage((byte) 1));
|
c.sendPacket(PacketCreator.CPQMessage((byte) 1));
|
||||||
c.sendPacket(PacketCreator.enableActions());
|
c.sendPacket(PacketCreator.enableActions());
|
||||||
return;
|
return;
|
||||||
@@ -163,7 +163,7 @@ public final class MonsterCarnivalHandler extends AbstractPacketHandler {
|
|||||||
c.sendPacket(PacketCreator.enableActions());
|
c.sendPacket(PacketCreator.enableActions());
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
neededCP = skill.cpLoss;
|
neededCP = skill.cpLoss();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1039,14 +1039,15 @@ public class StatEffect {
|
|||||||
if (skill != null) {
|
if (skill != null) {
|
||||||
final Disease dis = skill.getDisease();
|
final Disease dis = skill.getDisease();
|
||||||
Party opposition = applyfrom.getParty().getEnemy();
|
Party opposition = applyfrom.getParty().getEnemy();
|
||||||
if (skill.targetsAll) {
|
if (skill.targetsAll()) {
|
||||||
for (PartyCharacter enemyChrs : opposition.getPartyMembers()) {
|
for (PartyCharacter enemyChrs : opposition.getPartyMembers()) {
|
||||||
Character chrApp = enemyChrs.getPlayer();
|
Character chrApp = enemyChrs.getPlayer();
|
||||||
if (chrApp != null && chrApp.getMap().isCPQMap()) {
|
if (chrApp != null && chrApp.getMap().isCPQMap()) {
|
||||||
if (dis == null) {
|
if (dis == null) {
|
||||||
chrApp.dispel();
|
chrApp.dispel();
|
||||||
} else {
|
} else {
|
||||||
chrApp.giveDebuff(dis, MCSkill.getMobSkill(dis.getMobSkillType(), skill.level));
|
MobSkill mobSkill = MobSkillFactory.getMobSkill(dis.getMobSkillType(), skill.level());
|
||||||
|
chrApp.giveDebuff(dis, mobSkill);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1058,7 +1059,8 @@ public class StatEffect {
|
|||||||
if (dis == null) {
|
if (dis == null) {
|
||||||
chrApp.dispel();
|
chrApp.dispel();
|
||||||
} else {
|
} else {
|
||||||
chrApp.giveDebuff(dis, MCSkill.getMobSkill(dis.getMobSkillType(), skill.level));
|
MobSkill mobSkill = MobSkillFactory.getMobSkill(dis.getMobSkillType(), skill.level());
|
||||||
|
chrApp.giveDebuff(dis, mobSkill);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ public class MobSkillFactory {
|
|||||||
private static final Lock readLock = readWriteLock.readLock();
|
private static final Lock readLock = readWriteLock.readLock();
|
||||||
private static final Lock writeLock = readWriteLock.writeLock();
|
private static final Lock writeLock = readWriteLock.writeLock();
|
||||||
|
|
||||||
public static MobSkill getMobSkill(final MobSkillType type, final int level) { // TODO: return Optional
|
public static MobSkill getMobSkill(final MobSkillType type, final int level) {
|
||||||
readLock.lock();
|
readLock.lock();
|
||||||
try {
|
try {
|
||||||
MobSkill ms = mobSkills.get(createKey(type, level));
|
MobSkill ms = mobSkills.get(createKey(type, level));
|
||||||
|
|||||||
@@ -90,26 +90,9 @@ public class CarnivalFactory {
|
|||||||
return guardians.get(id);
|
return guardians.get(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class MCSkill {
|
public record MCSkill(int cpLoss, MobSkillType mobSkillType, int level, boolean targetsAll) {
|
||||||
|
|
||||||
public int cpLoss;
|
|
||||||
public MobSkillType mobSkillType;
|
|
||||||
public int level;
|
|
||||||
public boolean targetsAll;
|
|
||||||
|
|
||||||
public MCSkill(int _cpLoss, MobSkillType mobSkillType, int _level, boolean _targetsAll) {
|
|
||||||
cpLoss = _cpLoss;
|
|
||||||
mobSkillType = mobSkillType;
|
|
||||||
level = _level;
|
|
||||||
targetsAll = _targetsAll;
|
|
||||||
}
|
|
||||||
|
|
||||||
public MobSkill getSkill() {
|
public MobSkill getSkill() {
|
||||||
return getMobSkill(mobSkillType, level);
|
return MobSkillFactory.getMobSkill(mobSkillType, level);
|
||||||
}
|
|
||||||
|
|
||||||
public static MobSkill getMobSkill(MobSkillType type, int level) {
|
|
||||||
return MobSkillFactory.getMobSkill(type, level);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Disease getDisease() {
|
public Disease getDisease() {
|
||||||
|
|||||||
Reference in New Issue
Block a user