Skip to content

Instantly share code, notes, and snippets.

@saevarb
Created February 26, 2019 09:41
Show Gist options
  • Save saevarb/fb2cfdeae0698770c1788772c8f11f6a to your computer and use it in GitHub Desktop.
Save saevarb/fb2cfdeae0698770c1788772c8f11f6a to your computer and use it in GitHub Desktop.
import { BotManager } from "BotManager";
import { sendCM, Ticker } from "util/utils";
import { ComponentType, IComponent } from "components/Component";
import { myBots } from "util/constants";
export class SlaveComponent implements IComponent {
public componentType: ComponentType = "role";
public ticker: Ticker = new Ticker(500);
public onLoad = () => {
game_log("Starting waiting for party..");
on_party_invite = (from: string) => {
if (myBots.has(from)) {
accept_party_invite(from);
}
};
};
public update = () => {
if (character.party) {
return;
}
if (this.ticker.isDone) {
game_log("Asking for party invite");
// TODO: get leader generally
sendCM("sbrg", { msg: "request_party_invite" });
this.ticker.reset();
}
};
public onUnload = () => {
on_party_invite = undefined;
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment