Skip to content

Commit

Permalink
Updates
Browse files Browse the repository at this point in the history
  • Loading branch information
haykam821 committed Jul 11, 2018
1 parent 0d1ba2c commit 1832967
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 10 deletions.
56 changes: 47 additions & 9 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,15 @@ class MoomooClient extends events.EventTarget {
this.socket.on("open", () => {
this.dispatchEvent(new events.Event("socketOpen"));
});

this.attacking = false;
}

/**
* Sends a message.
* @param {*[]} msg The message data.
*/
send(msg) {
send(...msg) {
this.socket.send(msgpack.pack(msg));
}

Expand All @@ -62,13 +64,49 @@ class MoomooClient extends events.EventTarget {
* @param {boolean} spawnBonus Whether to spawn with a bonus of 100 of each resource.
*/
spawn(name = "Bot", skin = 0, spawnBonus = true) {
this.send([
"1",
[{
name,
skin,
moofoll: spawnBonus,
}],
this.send("1", [{
name,
skin,
moofoll: spawnBonus,
}]);
}

direction(direction = 0, move = false) {
this.send("2", [
direction,
]);
this.send("3", [
move ? direction : null,
]);
}

/**
* Sends a ping on the minimap.
*/
ping() {
this.send(14, [
this.selfID,
]);
}

joinTribe(tribeName) {
this.send("10", [
tribeName,
]);
}

/**
* Changes attacking.
* @param {boolean} shouldAttack Whether bots should attack or not. If left blank, toggles attacking.
*/
changeAttack(shouldAttack) {
if (shouldAttack === undefined) {
this.attacking = !this.attacking;
} else {
this.attacking = shouldAttack;
}
this.send("7", [
this.attacking,
]);
}
}
Expand Down Expand Up @@ -106,7 +144,7 @@ function getIP(link) {
const servers = [];
let hasServerData = false;

request.get("http://dev.moomoo.io/serverData/", (error, response) => {
request.get("http://moomoo.io/serverData/", (error, response) => {
if (!error) {
const serverResponse = JSON.parse(response.body).servers;
serverResponse.forEach(server => {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,4 @@
"eslint-plugin-json": "^1.2.0",
"eslint-plugin-unicorn": "^4.0.3"
}
}
}

0 comments on commit 1832967

Please sign in to comment.