Skip to content

Instantly share code, notes, and snippets.

@arturaz
Created September 13, 2011 20:04
Show Gist options
  • Select an option

  • Save arturaz/1214962 to your computer and use it in GitHub Desktop.

Select an option

Save arturaz/1214962 to your computer and use it in GitHub Desktop.
Scala side
object Finder {
def find(
source: Locatable,
sourceJumpgates: Set[SolarSystemPoint],
sourceSs: Option[SolarSystem],
sourceSsGalaxyCoords: Option[Coords],
target: Locatable,
targetJumpgates: Set[SolarSystemPoint],
targetSs: Option[SolarSystem],
targetSsGalaxyCoords: Option[Coords],
avoidablePoints: Option[Seq[SolarSystemPoint]]
): Seq[ServerLocation] = { ... }
}
trait Locatable {
def toServerLocation(timeMultiplier: Double): ServerLocation
def toServerLocation: ServerLocation = toServerLocation(1.0)
}
case class SolarSystemPoint(
solarSystem: SolarSystem, coords: Coords
) extends Locatable with InSolarSystem {
def this(planet: Planet) = this(planet.solarSystem, planet.coords)
def toServerLocation(timeMultiplier: Double) =
ServerLocation(solarSystem.id,
objects.Location.SolarSystem,
Some(coords),
timeMultiplier)
def solarSystemId = solarSystem.id
def solarSystemPoint = this
}
case class SolarSystemPoint(
solarSystem: SolarSystem, coords: Coords
) extends Locatable with InSolarSystem {
def this(planet: Planet) = this(planet.solarSystem, planet.coords)
def toServerLocation(timeMultiplier: Double) =
ServerLocation(solarSystem.id,
objects.Location.SolarSystem,
Some(coords),
timeMultiplier)
def solarSystemId = solarSystem.id
def solarSystemPoint = this
}
class Coords(initialX: Int, initialY: Int) extends WithCoords {
x = initialX
y = initialY
override def toString = "<Coords %d,%d>".format(x, y)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment