fixes for pointy-top square boards

This commit is contained in:
Gavin McDonald
2018-07-05 21:37:56 -04:00
parent fbd4805970
commit eb04c3f0eb
4 changed files with 120 additions and 40 deletions

View File

@@ -63,7 +63,14 @@ export function range (start, end) {
start = 0;
}
return Array.from(Array(end - start), (_value, index) => index + start);
if (start > end) {
const swap = start;
start = end;
end = swap;
}
return Array.from(Array(Math.abs(end - start)), (_value, index) => index + start);
}
export function rangeInclusive(start, end) {
@@ -72,6 +79,6 @@ export function rangeInclusive(start, end) {
start = 0;
}
return range(start, end+1);
return range(Math.min(start, end), Math.max(start, end)+1);
}