Skip to content

Instantly share code, notes, and snippets.

@jackphilippi
Last active April 3, 2020 02:33
Show Gist options
  • Save jackphilippi/3de365498a87ef115582f9c347cdd60e to your computer and use it in GitHub Desktop.
Save jackphilippi/3de365498a87ef115582f9c347cdd60e to your computer and use it in GitHub Desktop.
🤖🦖
const defaultAvailableCounters = [
'flying',
'first strike',
'deathtouch',
'hexproof',
'lifelink',
'menace',
'reach',
'trample',
'vigilance',
'+1/+1',
];
class MECHAGODZILLA {
private available: Array<string>;
private current: Array<string>;
constructor() {
this.available = defaultAvailableCounters;
this.current = [];
}
public messageMaro() {
console.log(`Here's a tweet to send to Mark Rosewater. https://ctt.ac/cfPby`);
}
public combatTrigger() {
if (this.available.length === 0) {
return console.log(`No more modes available... Mechagodzilla is pretty big already.`);
}
const roll = Math.floor(Math.random() * (this.available.length - 0)) + 0;
console.log(
`Rolled a ${roll + 1} (out of ${this.available.length + 1}). MECHAGODZILLA GAINS ${this.available[roll]}`,
);
this.addCounter(this.available[roll]);
this.removeAvailableCounter(roll);
}
public addCounter(modeName: string) {
this.current.push(modeName);
}
public removeCounter(modeName: string) {
this.current = this.current.filter(i => i !== modeName);
}
public addAvailableCounter(modeName: string) {
this.available.push(modeName);
}
public removeAvailableCounter(index: number) {
this.available.splice(index, 1);
}
public getCurrentCounters() {
console.log(`Mechagodzilla currently has ${this.current.join(', ')}`);
}
public reset() {
this.available = defaultAvailableCounters;
this.current = [];
}
}
const mecha = new MECHAGODZILLA();
for (let i = 1; i <= 10; i++) {
mecha.combatTrigger();
}
mecha.getCurrentCounters();
mecha.messageMaro();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment