Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- javascript: function upgrade(x, y) {
- if (map[x][y][2] == "w" && map[x][y][1] >= 1 || map[x][y][1] >= 8) {
- return;
- } else {
- if (mp < cellCost(x, y) || map[x][y][1] >= 15) return;
- var act = false;
- if (x - 1 > -1) {
- if (map[x - 1][y][0] == socketId) act = true
- }
- if (x + 1 < mapSize) {
- if (map[x + 1][y][0] == socketId) act = true
- }
- if (y - 1 > -1) {
- if (map[x][y - 1][0] == socketId) act = true
- }
- if (y + 1 < mapSize) {
- if (map[x][y + 1][0] == socketId) act = true
- }
- if (!act) return;
- mp += -cellCost(x, y);
- refresh();
- socket.emit('upgrade', x, y);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement