Skip to content

Commit

Permalink
added Pit hag from BOTC (#1671)
Browse files Browse the repository at this point in the history
added MiGo role. It chooses a player and a role. If the role's alignment
matches the player's alignment and the role does not already exist. The
player becomes that role.

Golbolco wanted the role to be called "Mi-Go" but the "-" in the name
broke the code.

---------

Co-authored-by: SawJester <[email protected]>
  • Loading branch information
SawJester and SawJester committed Jul 29, 2024
1 parent e3ccc05 commit 995dedb
Show file tree
Hide file tree
Showing 3 changed files with 96 additions and 0 deletions.
15 changes: 15 additions & 0 deletions Games/types/Mafia/roles/Cult/MiGo.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
const Role = require("../../Role");

module.exports = class MiGo extends Role {
constructor(player, data) {
super("MiGo", player, data);

this.alignment = "Cult";
this.cards = [
"VillageCore",
"WinWithCult",
"MeetingCult",
"ConvertToChosenRole",
];
}
};
72 changes: 72 additions & 0 deletions Games/types/Mafia/roles/cards/ConvertToChosenRole.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
const Card = require("../../Card");
const { PRIORITY_CONVERT_DEFAULT } = require("../../const/Priority");
const { addArticle } = require("../../../../core/Utils");
module.exports = class ConvertToChosenRole extends Card {
constructor(role) {
super(role);
//const targetOptions = this.game.PossibleRoles.filter((r) => r);
this.meetings = {
"Select Player": {
states: ["Night"],
flags: ["voting"],
targets: { include: ["alive", "self"] },
action: {
priority: PRIORITY_CONVERT_DEFAULT - 1,
run: function () {
this.actor.role.data.targetPlayer = this.target;
},
},
},
"Convert To": {
states: ["Night"],
flags: ["voting"],
inputType: "custom",
//targets: { targetOptions },
action: {
labels: ["convert", "role"],
priority: PRIORITY_CONVERT_DEFAULT,
run: function () {
let targetPlayer = this.actor.role.data.targetPlayer;
if (targetPlayer) {
let players = this.game.players.filter((p) => p.role);
let currentRoles = [];

for (let x = 0; x < players.length; x++) {
currentRoles.push(players [x].role);
}
for(let y = 0; y < currentRoles.length;y++){
if(this.target.split(":")[0] == currentRoles[y].name){
return;
}
}

if (this.game.getRoleAlignment(this.target) == targetPlayer.role.alignment) {
targetPlayer.setRole(`${this.target}`);
}
delete this.actor.role.data.targetPlayer;
}
},
},
},
};

this.listeners = {
roleAssigned: function (player) {
if (player !== this.player) {
return;
}

this.data.ConvertOptions = this.game.PossibleRoles.filter((r) => r);
},
// refresh cooldown
state: function (stateInfo) {
if (!stateInfo.name.match(/Night/)) {
return;
}
var ConvertOptions = this.data.ConvertOptions;

this.meetings["Convert To"].targets = ConvertOptions;
},
};
}
};
9 changes: 9 additions & 0 deletions data/roles.js
Original file line number Diff line number Diff line change
Expand Up @@ -1924,6 +1924,15 @@ const roleData = {
"If a Count is created mid-game, 2 Village/Independant players will be converted to Banished Roles.",
],
},
"MiGo": {
alignment: "Cult",
newlyAdded: true,
description: [
"Each night chooses a player and a role.",
"If the role is the same alignment as the player's current role, The player is converted to the selected role.",
"If the selected role is already in play, The conversion fails.",
],
},

//Independent
Fool: {
Expand Down

0 comments on commit 995dedb

Please sign in to comment.