-
-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Event Code Refactor + Event Modifiers + Emperor Icon (#1758)
Odd, Even, Delayed, and One Shot now work on Events. Added a Cave In Event, Blocks Night Actions like a blizzard but it also forces players to Vote a player to kill, Will also feed all players during famine if kill is successful. Events are now coded more like effects/items/roles. --------- Co-authored-by: SawJester <[email protected]>
- Loading branch information
Showing
24 changed files
with
630 additions
and
143 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
const shortid = require("shortid"); | ||
const Utils = require("./Utils"); | ||
|
||
module.exports = class Event { | ||
constructor(name, modifiers, game) { | ||
this.game = game; | ||
this.id = shortid.generate(); | ||
this.fullName = `${name}:${modifiers}`; | ||
this.name = name; | ||
this.modifiers = modifiers; | ||
//this.game.queueAlert(`Core ${modifiers}`); | ||
/* | ||
if(this.modifiers <= 0){ | ||
this.modifiers = []; | ||
} | ||
else{ | ||
this.modifiers = this.modifiers.split("/"); | ||
} | ||
*/ | ||
this.actions = []; | ||
} | ||
|
||
getRequirements() { | ||
if ( | ||
this.getModifierRequirements() == true && | ||
this.getNormalRequirements() == true | ||
) { | ||
return true; | ||
} else { | ||
return false; | ||
} | ||
} | ||
|
||
getModifierRequirements() { | ||
return true; | ||
} | ||
|
||
getNormalRequirements() { | ||
return true; | ||
} | ||
|
||
doEvent() {} | ||
|
||
queueActions() { | ||
for (let action of this.actions) this.game.queueAction(action); | ||
} | ||
|
||
dequeueActions() { | ||
for (let action of this.actions) this.game.dequeueAction(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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
const Event = require("../../core/Event"); | ||
|
||
module.exports = class MafiaEvent extends Event { | ||
constructor(name, modifiers, game, data) { | ||
super(name, modifiers, game, data); | ||
//this.game.queueAlert(`Mafia ${modifiers}`); | ||
} | ||
|
||
getModifierRequirements() { | ||
if(this.modifiers == null) return true; | ||
//this.game.queueAlert("Checks Null"); | ||
if ( | ||
this.game.dayCount % 2 == 0 && | ||
this.modifiers.includes("Odd") | ||
) { | ||
return false; | ||
} | ||
//this.game.queueAlert(`${this.modifiers} ${this.modifiers.includes("Odd")}`); | ||
if ( | ||
this.game.dayCount % 2 == 1 && | ||
this.modifiers.includes("Even") | ||
) { | ||
return false; | ||
} | ||
if ( | ||
this.game.dayCount == 1 && | ||
this.modifiers.includes("Delayed") | ||
) { | ||
return false; | ||
} | ||
return true; | ||
} | ||
|
||
doEvent() { | ||
if(this.modifiers != null){ | ||
if ( | ||
this.modifiers.includes("One Shot") && | ||
!this.modifiers.includes("Banished") | ||
) { | ||
this.game.PossibleEvents.splice(this.game.PossibleEvents.indexOf(this.fullName),1); | ||
} else if ( | ||
this.modifiers.includes("One Shot") && | ||
this.modifiers.includes("Banished") | ||
) { | ||
this.game.BanishedEvents.splice( | ||
this.game.BanishedEvents.indexOf(this.fullName), | ||
1 | ||
); | ||
} | ||
} | ||
|
||
} | ||
}; |
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_ITEM_GIVER_DEFAULT, | ||
PRIORITY_BECOME_DEAD_ROLE, | ||
} = require("../const/Priority"); | ||
|
||
module.exports = class Brainblast extends Event { | ||
constructor(modifiers, game) { | ||
super("Brainblast", 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_ITEM_GIVER_DEFAULT, | ||
labels: ["hidden", "absolute"], | ||
run: function () { | ||
if (this.game.SilentEvents != false) { | ||
this.game.queueAlert( | ||
`Event: Brainblast, A player got a brainblast and can learn another player's role!` | ||
); | ||
} | ||
let targetTypes = ["neighbors", "even", "odd"]; | ||
let targetType = Random.randArrayVal(targetTypes); | ||
this.target.holdItem("WackyRoleLearner", targetType, "Day"); | ||
}, | ||
}); | ||
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,35 @@ | ||
const Event = require("../Event"); | ||
const Action = require("../Action"); | ||
const Random = require("../../../../lib/Random"); | ||
const { | ||
PRIORITY_ITEM_GIVER_DEFAULT, | ||
PRIORITY_BECOME_DEAD_ROLE, | ||
} = require("../const/Priority"); | ||
|
||
module.exports = class CaveIn extends Event { | ||
constructor(modifiers, game) { | ||
super("Cave In", 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_ITEM_GIVER_DEFAULT, | ||
labels: ["hidden", "absolute"], | ||
run: function () { | ||
for (const player of this.game.players) { | ||
player.holdItem("CaveIn"); | ||
} | ||
}, | ||
}); | ||
this.game.queueAction(this.action); | ||
} | ||
}; |
Oops, something went wrong.