diff --git a/Games/types/Mafia/effects/ConvertImmune.js b/Games/types/Mafia/effects/ConvertImmune.js new file mode 100644 index 000000000..7dd039db4 --- /dev/null +++ b/Games/types/Mafia/effects/ConvertImmune.js @@ -0,0 +1,10 @@ +const Effect = require("../Effect"); + +module.exports = class KillImmune extends Effect { + constructor(immunity, lifespan) { + super("Convert Immune"); + + this.immunity["convert"] = immunity || 1; + this.lifespan = lifespan ?? Infinity; + } +}; diff --git a/Games/types/Mafia/items/Tract.js b/Games/types/Mafia/items/Tract.js index 8689a599f..628032d6c 100644 --- a/Games/types/Mafia/items/Tract.js +++ b/Games/types/Mafia/items/Tract.js @@ -5,11 +5,27 @@ module.exports = class Tract extends Item { super("Tract"); this.uses = 1; + // if tract starts out cursed, the setter will handle the logic of making it cursed + this.cursedUses = 0; + this.optionCursed = options?.cursed; this.listeners = { immune: function (action, player) { + //let converter = this.getVisitors(this.target, "convert"); + if (player == this.holder && action.hasLabel("convert")) { - if (this.holder.tempImmunity["convert"]) return; + if (this.holder.tempImmunity["convert", 1]) return; + + // check for effect immunity + for (let effect of this.holder.effects) + if (effect.immunity["convert"] && effect.name != "Convert Immune") return; + + // check for saves + for (let action of this.game.actions[0]) { + if (action.target === this.holder && action.hasLabel("reinforce")) { + return; + } + } this.uses--; this.holder.queueAlert( @@ -18,12 +34,27 @@ module.exports = class Tract extends Item { if (this.uses <= 0) { this.removeEffectsIfNeeded(); + if (this.cursedUses <= 0) { + this.drop(); + } } } }, }; } + set cursed(cursed) { + if (cursed) { + this.cursedUses += this.uses; + this.uses = 0; + this.removeEffectsIfNeeded(); + } else { + this.uses += this.cursedUses; + this.cursedUses = 0; + this.applyEffectsIfNeeded(); + } + } + removeEffectsIfNeeded() { if (this.effects.length > 0) { this.removeEffects(); @@ -33,7 +64,7 @@ module.exports = class Tract extends Item { applyEffectsIfNeeded() { if (this.uses > 0 && this.effects.length == 0) { - this.effects = ["Kill Immune"]; + this.effects = ["Convert Immune"]; this.applyEffects(); } } @@ -42,11 +73,13 @@ module.exports = class Tract extends Item { for (let item of player.items) { if (item.name == "Tract") { item.uses += this.uses; + item.cursedUses += this.cursedUses; item.applyEffectsIfNeeded(); return; } } super.hold(player); + this.cursed = this.optionCursed; } -}; +}; \ No newline at end of file diff --git a/Games/types/Mafia/roles/cards/CureAllMadness.js b/Games/types/Mafia/roles/cards/CureAllMadness.js index 7246d6f6f..2bf972a4c 100644 --- a/Games/types/Mafia/roles/cards/CureAllMadness.js +++ b/Games/types/Mafia/roles/cards/CureAllMadness.js @@ -10,6 +10,7 @@ module.exports = class CureAllMadness extends Card { states: ["Night"], flags: ["voting"], action: { + labels: ["reinforce"], priority: PRIORITY_EFFECT_GIVER_DEFAULT + 1, run: function () { // cure insanity