Advertisement
Guest User

aaaa

a guest
May 27th, 2018
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. javascript: function upgrade(x, y) {
  2. if (map[x][y][2] == "w" && map[x][y][1] >= 1 || map[x][y][1] >= 8) {
  3. return;
  4. } else {
  5. if (mp < cellCost(x, y) || map[x][y][1] >= 15) return;
  6. var act = false;
  7. if (x - 1 > -1) {
  8. if (map[x - 1][y][0] == socketId) act = true
  9. }
  10. if (x + 1 < mapSize) {
  11. if (map[x + 1][y][0] == socketId) act = true
  12. }
  13. if (y - 1 > -1) {
  14. if (map[x][y - 1][0] == socketId) act = true
  15. }
  16. if (y + 1 < mapSize) {
  17. if (map[x][y + 1][0] == socketId) act = true
  18. }
  19. if (!act) return;
  20. mp += -cellCost(x, y);
  21. refresh();
  22. socket.emit('upgrade', x, y);
  23. }
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement