Skip to content
This repository has been archived by the owner on Nov 3, 2022. It is now read-only.

Commit

Permalink
[#830] cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Pozzi committed Dec 27, 2021
1 parent 4b2172f commit 1db92de
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import java.util.concurrent.atomic.AtomicLong;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import de.bonndan.nivio.output.map.hex.Hex;

public class FractionalHex {
class FractionalHex {

private final double q;
private final double r;
Expand All @@ -25,37 +25,24 @@ public double getS() {
}

public Hex toHex() {
int q = (int) Math.round(getQ());
int r = (int) Math.round(getR());
int tmpQ = (int) Math.round(getQ());
int tmpR = (int) Math.round(getR());
int s = (int) Math.round(getS());
double qDiff = Math.abs(q - getQ());
double rDiff = Math.abs(r - getR());
double qDiff = Math.abs(tmpQ - getQ());
double rDiff = Math.abs(tmpR - getR());
double sDiff = Math.abs(s - getS());

if (qDiff > rDiff && qDiff > sDiff) {
q = -(r + s);
tmpQ = -(tmpR + s);
} else if (rDiff > sDiff) {
r = -(q + s);
tmpR = -(tmpQ + s);
}

return new Hex(q, r);
return new Hex(tmpQ, tmpR);
}

@Override
public String toString() {
return String.format("fraction_hex{q: %d, r: %d}", q, r);
}

@Override
public boolean equals(Object obj) {
if (obj == null) {
return false;
}
if (!FractionalHex.class.isAssignableFrom(obj.getClass())) {
return false;
}
FractionalHex other = (FractionalHex)obj;

return other.q == q && other.r == r;
return String.format("fraction_hex{q: %s, r: %s}", q, r);
}
}

0 comments on commit 1db92de

Please sign in to comment.