use of enums.Transport in project KaellyBot by Kaysoro.
the class DistanceCommand method request.
@Override
public boolean request(IMessage message) {
if (super.request(message)) {
Matcher m = getMatcher(message);
m.find();
Language lg = Translator.getLanguageFrom(message.getChannel());
Position position = new Position(Integer.parseInt(m.group(1)), Integer.parseInt(m.group(2)));
StringBuilder st = new StringBuilder();
Transport zaap = null;
Transport transportLimited = null;
if (!position.isNull()) {
double minDist = Double.MAX_VALUE;
double minDistLimited = Double.MAX_VALUE;
for (Transport transport : Transport.values()) {
double tmp = transport.getPosition().getDistance(position);
if (transport.isFreeAccess() && (zaap == null || minDist > tmp)) {
zaap = transport;
minDist = tmp;
}
if (!transport.isFreeAccess() && (transportLimited == null || minDistLimited > tmp)) {
transportLimited = transport;
minDistLimited = tmp;
}
}
st.append(Translator.getLabel(lg, "distance.request.1")).append(" ").append(zaap.toDiscordString(lg));
if (minDist > minDistLimited)
st.append("\n").append(Translator.getLabel(lg, "distance.request.2")).append(" ").append(transportLimited.toDiscordString(lg));
} else
st.append(Translator.getLabel(lg, "distance.request.3"));
Message.sendText(message.getChannel(), st.toString());
}
return false;
}
use of enums.Transport in project KaellyBot by Kaysoro.
the class Portal method determineTransports.
private void determineTransports() {
if (isValid()) {
double minDist = Double.MAX_VALUE;
double minDistLimited = Double.MAX_VALUE;
for (Transport transport : Transport.values()) {
double tmp = transport.getPosition().getDistance(coordonate);
if (transport.isFreeAccess() && (zaap == null || minDist > tmp)) {
zaap = transport;
minDist = tmp;
}
if (!transport.isFreeAccess() && (transportLimited == null || minDistLimited > tmp)) {
transportLimited = transport;
minDistLimited = tmp;
}
}
if (minDist < minDistLimited)
transportLimited = null;
} else {
zaap = null;
transportLimited = null;
}
}