How do you calculate room distance across regions (E->W, N->S)?



  • I try to calculate room distance across long distance and found that 

    // Return 2
    Game.map.getRoomLinearDistance('E19N31', 'S17N32');

    if you measure these room distance manually, it should be 37. Is this a bug or it's an intend feature for distance across regions.

    This distance also apply for Game.market.calcTransactionCost



  • looks like a bug. 

    As a walkaround you can use 

    function(roomName1, roomName2, diagonal){
      if( roomName1 == roomName2 ) return 0;
      let posA = roomName1.split(/([N,E,S,W])/);
      let posB = roomName2.split(/([N,E,S,W])/);
      let xDif = posA[1] == posB[1] ? Math.abs(posA[2]-posB[2]) : posA[2]+posB[2]+1;
      let yDif = posA[3] == posB[3] ? Math.abs(posA[4]-posB[4]) : posA[4]+posB[4]+1;
      if( diagonal ) return Math.max(xDif, yDif); // count diagonal as 1
      return xDif + yDif; // count diagonal as 2
    }

  • Dev Team

    You have a typo in your code: S17N32 should be W17N32.



  • Ah yes 😄 South 17 North 32 is a great place ^^



  • OH, my mistake. Thanks for point that out