Skip to content

Commit

Permalink
hotfix: tract
Browse files Browse the repository at this point in the history
  • Loading branch information
Golbolco authored Dec 13, 2023
1 parent 5ece0e1 commit 39dca43
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 3 deletions.
10 changes: 10 additions & 0 deletions Games/types/Mafia/effects/ConvertImmune.js
Original file line number Diff line number Diff line change
@@ -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;
}
};
39 changes: 36 additions & 3 deletions Games/types/Mafia/items/Tract.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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();
Expand All @@ -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();
}
}
Expand All @@ -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;
}
};
};
1 change: 1 addition & 0 deletions Games/types/Mafia/roles/cards/CureAllMadness.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 39dca43

Please sign in to comment.