mirror of
https://github.com/2revoemag/PSF-BotServer.git
synced 2026-07-15 00:14:40 +00:00
Eliminate return from AvatarActor
This commit is contained in:
parent
ce641cffbd
commit
63dea5af05
1 changed files with 138 additions and 142 deletions
|
|
@ -390,7 +390,9 @@ class AvatarActor(
|
||||||
case Success((loadouts, implants, certs)) =>
|
case Success((loadouts, implants, certs)) =>
|
||||||
avatar = avatar.copy(
|
avatar = avatar.copy(
|
||||||
loadouts = loadouts,
|
loadouts = loadouts,
|
||||||
certifications = certs.map(cert => Certification.withValue(cert.id)).toSet,
|
// make sure we always have the base certifications
|
||||||
|
certifications =
|
||||||
|
certs.map(cert => Certification.withValue(cert.id)).toSet ++ Certification.values.filter(_.cost == 0),
|
||||||
implants = implants.map(implant => Some(Implant(implant.toImplantDefinition))).padTo(3, None)
|
implants = implants.map(implant => Some(Implant(implant.toImplantDefinition))).padTo(3, None)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -416,9 +418,7 @@ class AvatarActor(
|
||||||
sessionActor ! SessionActor.SendResponse(
|
sessionActor ! SessionActor.SendResponse(
|
||||||
ItemTransactionResultMessage(terminalGuid, TransactionType.Learn, success = false)
|
ItemTransactionResultMessage(terminalGuid, TransactionType.Learn, success = false)
|
||||||
)
|
)
|
||||||
return Behaviors.same
|
} else {
|
||||||
}
|
|
||||||
|
|
||||||
val replace = certification.replaces.intersect(avatar.certifications)
|
val replace = certification.replaces.intersect(avatar.certifications)
|
||||||
Future
|
Future
|
||||||
.sequence(replace.map(cert => {
|
.sequence(replace.map(cert => {
|
||||||
|
|
@ -471,6 +471,7 @@ class AvatarActor(
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
Behaviors.same
|
Behaviors.same
|
||||||
|
|
||||||
case SellCertification(terminalGuid, certification) =>
|
case SellCertification(terminalGuid, certification) =>
|
||||||
|
|
@ -480,8 +481,7 @@ class AvatarActor(
|
||||||
sessionActor ! SessionActor.SendResponse(
|
sessionActor ! SessionActor.SendResponse(
|
||||||
ItemTransactionResultMessage(terminalGuid, TransactionType.Learn, success = false)
|
ItemTransactionResultMessage(terminalGuid, TransactionType.Learn, success = false)
|
||||||
)
|
)
|
||||||
return Behaviors.same
|
} else {
|
||||||
}
|
|
||||||
|
|
||||||
val deps = Certification.values.filter(_.requires.contains(certification)).toSet
|
val deps = Certification.values.filter(_.requires.contains(certification)).toSet
|
||||||
val remove = deps ++ Certification.values.filter(_.replaces.intersect(deps).nonEmpty).toSet + certification
|
val remove = deps ++ Certification.values.filter(_.replaces.intersect(deps).nonEmpty).toSet + certification
|
||||||
|
|
@ -522,6 +522,7 @@ class AvatarActor(
|
||||||
avatar.deployables.UpdateUI()
|
avatar.deployables.UpdateUI()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
Behaviors.same
|
Behaviors.same
|
||||||
|
|
||||||
case SetCertifications(certifications) =>
|
case SetCertifications(certifications) =>
|
||||||
|
|
@ -716,12 +717,12 @@ class AvatarActor(
|
||||||
if (!Avatar.purchaseCooldowns.contains(definition)) {
|
if (!Avatar.purchaseCooldowns.contains(definition)) {
|
||||||
// TODO only send for items with cooldowns
|
// TODO only send for items with cooldowns
|
||||||
//log.warn(s"UpdatePurchaseTime message for item '${definition.Name}' without cooldown")
|
//log.warn(s"UpdatePurchaseTime message for item '${definition.Name}' without cooldown")
|
||||||
return Behaviors.same
|
} else {
|
||||||
}
|
|
||||||
// TODO save to db
|
// TODO save to db
|
||||||
avatar = avatar.copy(purchaseTimes = avatar.purchaseTimes.updated(definition.Name, time))
|
avatar = avatar.copy(purchaseTimes = avatar.purchaseTimes.updated(definition.Name, time))
|
||||||
// we could be more selective and only send what changed, but it doesn't hurt to refresh everything
|
// we could be more selective and only send what changed, but it doesn't hurt to refresh everything
|
||||||
context.self ! RefreshPurchaseTimes()
|
context.self ! RefreshPurchaseTimes()
|
||||||
|
}
|
||||||
Behaviors.same
|
Behaviors.same
|
||||||
|
|
||||||
case UpdateUseTime(definition, time) =>
|
case UpdateUseTime(definition, time) =>
|
||||||
|
|
@ -779,18 +780,13 @@ class AvatarActor(
|
||||||
case Some((implant, slot)) =>
|
case Some((implant, slot)) =>
|
||||||
if (!implant.initialized) {
|
if (!implant.initialized) {
|
||||||
log.error(s"requested activation of uninitialized implant $implant")
|
log.error(s"requested activation of uninitialized implant $implant")
|
||||||
return Behaviors.same
|
} else if (!consumeStamina(implant.definition.ActivationStaminaCost)) {
|
||||||
}
|
|
||||||
if (!consumeStamina(implant.definition.ActivationStaminaCost)) {
|
|
||||||
sessionActor ! SessionActor.SendResponse(
|
sessionActor ! SessionActor.SendResponse(
|
||||||
AvatarImplantMessage(session.get.player.GUID, ImplantAction.OutOfStamina, slot, 1)
|
AvatarImplantMessage(session.get.player.GUID, ImplantAction.OutOfStamina, slot, 1)
|
||||||
)
|
)
|
||||||
return Behaviors.same
|
} else if (implant.definition.implantType.disabledFor.contains(session.get.player.ExoSuit)) {
|
||||||
}
|
|
||||||
if (implant.definition.implantType.disabledFor.contains(session.get.player.ExoSuit)) {
|
|
||||||
// TODO can this really happen? can we prevent it?
|
// TODO can this really happen? can we prevent it?
|
||||||
return Behaviors.same
|
} else {
|
||||||
}
|
|
||||||
|
|
||||||
avatar = avatar.copy(
|
avatar = avatar.copy(
|
||||||
implants = avatar.implants.updated(slot, Some(implant.copy(active = true)))
|
implants = avatar.implants.updated(slot, Some(implant.copy(active = true)))
|
||||||
|
|
@ -825,6 +821,7 @@ class AvatarActor(
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
case None => log.error(s"requested activation of unknown implant $implantType")
|
case None => log.error(s"requested activation of unknown implant $implantType")
|
||||||
}
|
}
|
||||||
|
|
@ -870,8 +867,7 @@ class AvatarActor(
|
||||||
|
|
||||||
case RestoreStamina(stamina) =>
|
case RestoreStamina(stamina) =>
|
||||||
assert(stamina > 0)
|
assert(stamina > 0)
|
||||||
if (!session.get.player.HasGUID) return Behaviors.same
|
if (session.get.player.HasGUID) {
|
||||||
|
|
||||||
val totalStamina = math.min(avatar.maxStamina, avatar.stamina + stamina)
|
val totalStamina = math.min(avatar.maxStamina, avatar.stamina + stamina)
|
||||||
val fatigued = if (avatar.fatigued && totalStamina >= 20) {
|
val fatigued = if (avatar.fatigued && totalStamina >= 20) {
|
||||||
context.self ! InitializeImplants(instant = true)
|
context.self ! InitializeImplants(instant = true)
|
||||||
|
|
@ -884,7 +880,7 @@ class AvatarActor(
|
||||||
sessionActor ! SessionActor.SendResponse(
|
sessionActor ! SessionActor.SendResponse(
|
||||||
PlanetsideAttributeMessage(session.get.player.GUID, 2, avatar.stamina)
|
PlanetsideAttributeMessage(session.get.player.GUID, 2, avatar.stamina)
|
||||||
)
|
)
|
||||||
|
}
|
||||||
Behaviors.same
|
Behaviors.same
|
||||||
|
|
||||||
case ConsumeStamina(stamina) =>
|
case ConsumeStamina(stamina) =>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue