Merge pull request #671 from Mazo/cmt-warp-list

Restore `/warp -list` functionality
This commit is contained in:
Fate-JH 2021-02-08 10:38:05 -05:00 committed by GitHub
commit e9a7eb3d78
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 7 deletions

View file

@ -673,11 +673,11 @@ class ChatActor(
case (CMT_WARP, _, contents) if gmCommandAllowed =>
val buffer = contents.toLowerCase.split("\\s+")
val (coordinates, waypoint) = (buffer.lift(0), buffer.lift(1), buffer.lift(2)) match {
case (Some(x), Some(y), Some(z)) => (Some(x, y, z), None)
case (Some("to"), Some(character), None) => (None, None) // TODO not implemented
case (Some("near"), Some(objectName), None) => (None, None) // TODO not implemented
case (Some(waypoint), None, None) => (None, Some(waypoint))
case _ => (None, None)
case (Some(x), Some(y), Some(z)) => (Some(x, y, z), None)
case (Some("to"), Some(character), None) => (None, None) // TODO not implemented
case (Some("near"), Some(objectName), None) => (None, None) // TODO not implemented
case (Some(waypoint), None, None) if waypoint.nonEmpty => (None, Some(waypoint))
case _ => (None, None)
}
(coordinates, waypoint) match {
case (Some((x, y, z)), None) if List(x, y, z).forall { str =>
@ -685,6 +685,12 @@ class ChatActor(
coordinate.isDefined && coordinate.get >= 0 && coordinate.get <= 8191
} =>
sessionActor ! SessionActor.SetPosition(Vector3(x.toFloat, y.toFloat, z.toFloat))
case (None, Some(waypoint)) if waypoint == "-list" =>
val zone = PointOfInterest.get(session.player.Zone.id)
zone match {
case Some(zone: PointOfInterest) => sessionActor ! SessionActor.SendResponse(ChatMsg(UNK_229, true, "", PointOfInterest.listAll(zone), None))
case _ => ChatMsg(UNK_229, true, "", s"unknown player zone '${session.player.Zone.id}'", None)
}
case (None, Some(waypoint)) if waypoint != "-help" =>
PointOfInterest.getWarpLocation(session.zone.id, waypoint) match {
case Some(location) => sessionActor ! SessionActor.SetPosition(location)

View file

@ -187,7 +187,7 @@ object PointOfInterest {
* @return all of the location keys
*/
def listLocations(zone: PointOfInterest): String = {
var out: String = "warps: "
var out: String = "Locations: "
if (zone.locations.nonEmpty) {
out += zone.locations.keys.toArray.sorted.mkString(", ")
} else
@ -201,7 +201,7 @@ object PointOfInterest {
* @return all of the warpgate keys
*/
def listWarpgates(zone: PointOfInterest): String = {
var out: String = "gatenames: "
var out: String = "Gates: "
if (zone.gates.isEmpty)
out += "none"
else
@ -209,6 +209,15 @@ object PointOfInterest {
out
}
/**
* Get the name for all of the warpgates and locations that can be visited in this `CSRZone`.
* @param zone the `CSRZone`
* @return all of the warpgate and location keys
*/
def listAll(zone: PointOfInterest): String = {
s"${listWarpgates(zone)} ${listLocations(zone)}"
}
/**
* Select, of all the `CSRZone` locations and warpgates, a pseudorandom destination to spawn the player in the zone if none has been specified.
* @param zone the `CSRZone`