Skip to content

Commit

Permalink
Simplify roomNameToXY
Browse files Browse the repository at this point in the history
There's no reason to bring floating points into this.
  • Loading branch information
laverdet committed Dec 26, 2018
1 parent 27f933b commit b255034
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,12 @@ exports.getRoomNameFromXY = function(x,y) {

exports.roomNameToXY = function(name) {
let xx = parseInt(name.substr(1), 10);
let verticalPos = (xx === 0 ? 1 : Math.ceil(Math.log10(xx + 1))) + 1;
let verticalPos = 2;
if (xx >= 100) {
verticalPos = 4;
} else if (xx >= 10) {
verticalPos = 3;
}
let yy = parseInt(name.substr(verticalPos + 1), 10);
let horizontalDir = name.charAt(0);
let verticalDir = name.charAt(verticalPos);
Expand Down

0 comments on commit b255034

Please sign in to comment.