-
-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Mass Hysteria + Volcano Events + Butterfly Philsopher bug fix. (#1847)
Volcano: a random player will die every 30 Seconds until the day ends. Mass Hysteria: Everyone gains the Frustrated Modifier for 1 day A Philsopher that turns into butterfly no longer breaks the game --------- Co-authored-by: SawJester <SawJester@users.noreply.github.com>
- Loading branch information
Showing
9 changed files
with
238 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
const Effect = require("../Effect"); | ||
const Action = require("../Action"); | ||
const { PRIORITY_OVERTHROW_VOTE } = require("../const/Priority"); | ||
|
||
module.exports = class Frustrated extends Effect { | ||
constructor(lifespan) { | ||
super("Frustrated"); | ||
this.lifespan = lifespan || Infinity; | ||
this.immunity["condemn"] = 3; | ||
|
||
this.listeners = { | ||
state: function (stateInfo) { | ||
if (!this.player.alive) { | ||
return; | ||
} | ||
|
||
if (!stateInfo.name.match(/Day/)) { | ||
return; | ||
} | ||
|
||
var action = new Action({ | ||
actor: this.player, | ||
game: this.player.game, | ||
priority: PRIORITY_OVERTHROW_VOTE - 3, | ||
labels: ["hidden", "absolute"], | ||
run: function () { | ||
//if (this.game.getStateName() != "Day" && this.game.getStateName() != "Dusk") return; | ||
|
||
let villageMeeting = this.game.getMeetingByName("Village"); | ||
|
||
//New code | ||
const voteCounts = Object.values(villageMeeting.votes).reduce( | ||
(acc, vote) => { | ||
acc[vote] = (acc[vote] || 0) + 1; | ||
return acc; | ||
}, | ||
{} | ||
); | ||
|
||
const minVotes = Math.min(...Object.values(voteCounts)); | ||
const maxVotes = Math.max(...Object.values(voteCounts)); | ||
|
||
if ( | ||
voteCounts[this.actor.id] !== minVotes || | ||
voteCounts[this.actor.id] === maxVotes || | ||
voteCounts[this.actor.id] === 0 | ||
) { | ||
return; | ||
} | ||
|
||
for (let action of this.game.actions[0]) { | ||
if (action.hasLabel("condemn") && !action.hasLabel("overthrow")) { | ||
// Only one village vote can be overthrown | ||
action.cancel(true); | ||
break; | ||
} | ||
} | ||
|
||
let action = new Action({ | ||
actor: this.actor, | ||
target: this.actor, | ||
game: this.game, | ||
labels: ["kill", "frustration", "hidden"], | ||
power: 3, | ||
run: function () { | ||
this.game.sendAlert( | ||
`${this.target.name} feels immensely frustrated!` | ||
); | ||
if (this.dominates()) this.target.kill("basic", this.actor); | ||
}, | ||
}); | ||
action.do(); | ||
}, | ||
}); | ||
|
||
this.game.queueAction(action); | ||
}, | ||
}; | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
const Effect = require("../Effect"); | ||
const Action = require("../Action"); | ||
const Random = require("../../../../lib/Random"); | ||
|
||
module.exports = class Volcanic extends Effect { | ||
constructor(lifespan) { | ||
super("Volcanic"); | ||
this.lifespan = lifespan; | ||
|
||
this.listeners = { | ||
state: function (stateInfo) { | ||
if (!stateInfo.name.match(/Day/)) { | ||
return; | ||
} | ||
this.game.events.emit("Volcano"); | ||
}, | ||
Volcano: function () { | ||
if (this.timer) { | ||
return; | ||
} | ||
|
||
let toDetonate = 30000; | ||
this.timer = setTimeout(() => { | ||
if (this.game.finished) { | ||
return; | ||
} | ||
|
||
let players = this.game.alivePlayers(); | ||
this.target = Random.randArrayVal(players); | ||
|
||
let action = new Action({ | ||
target: this.target, | ||
game: this.target.game, | ||
labels: ["kill", "bomb"], | ||
run: function () { | ||
this.game.queueAlert( | ||
`The Volcano erupts hiting ${this.target.name} with a molten rock.` | ||
); | ||
if (this.dominates()) this.target.kill("bomb", this.target, true); | ||
}, | ||
}); | ||
|
||
this.game.instantAction(action); | ||
this.timer = null; | ||
this.game.events.emit("Volcano"); | ||
}, toDetonate); | ||
|
||
let toDetonateSound = toDetonate - 1800; | ||
this.soundTimer = setTimeout(() => { | ||
this.game.broadcast("explosion"); | ||
}, toDetonateSound); | ||
}, | ||
}; | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
const Event = require("../Event"); | ||
const Action = require("../Action"); | ||
const Random = require("../../../../lib/Random"); | ||
const { | ||
PRIORITY_EFFECT_GIVER_DEFAULT, | ||
PRIORITY_BECOME_DEAD_ROLE, | ||
} = require("../const/Priority"); | ||
|
||
module.exports = class MassHysteria extends Event { | ||
constructor(modifiers, game) { | ||
super("Mass Hysteria", modifiers, game); | ||
} | ||
|
||
getNormalRequirements() { | ||
return true; | ||
} | ||
|
||
doEvent() { | ||
super.doEvent(); | ||
let victim = Random.randArrayVal(this.game.alivePlayers()); | ||
this.action = new Action({ | ||
actor: victim, | ||
target: victim, | ||
game: this.game, | ||
priority: PRIORITY_EFFECT_GIVER_DEFAULT, | ||
labels: ["hidden", "absolute"], | ||
run: function () { | ||
if (this.game.SilentEvents != false) { | ||
this.game.queueAlert( | ||
`Event: Mass Hysteria, All players have Frustrated Modifier today!` | ||
); | ||
} | ||
for (const player of this.game.players) { | ||
player.giveEffect("Frustrated", 1); | ||
} | ||
}, | ||
}); | ||
this.game.queueAction(this.action); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
const Event = require("../Event"); | ||
const Action = require("../Action"); | ||
const Random = require("../../../../lib/Random"); | ||
const { | ||
PRIORITY_EFFECT_GIVER_DEFAULT, | ||
PRIORITY_BECOME_DEAD_ROLE, | ||
} = require("../const/Priority"); | ||
|
||
module.exports = class Volcano extends Event { | ||
constructor(modifiers, game) { | ||
super("Volcano", modifiers, game); | ||
} | ||
|
||
getNormalRequirements() { | ||
return true; | ||
} | ||
|
||
doEvent() { | ||
super.doEvent(); | ||
let victim = Random.randArrayVal(this.game.alivePlayers()); | ||
this.action = new Action({ | ||
actor: victim, | ||
target: victim, | ||
game: this.game, | ||
priority: PRIORITY_EFFECT_GIVER_DEFAULT, | ||
labels: ["hidden", "absolute"], | ||
run: function () { | ||
if (this.game.SilentEvents != false) { | ||
this.game.queueAlert( | ||
`Event: Volcano, A RANDOM PLAYER WILL DIE EVERY 30 SECONDS UNTIL THE DAY ENDS!` | ||
); | ||
} | ||
|
||
this.actor.giveEffect("Volcanic", 1); | ||
}, | ||
}); | ||
this.game.queueAction(this.action); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters