Skip to content

Commit

Permalink
More Info Files + New Mafia Role (#1795)
Browse files Browse the repository at this point in the history
Beguiler- At night chooses two players, The 1st Player will appear to
visit the 2nd Player to Investigative Roles.

---------

Co-authored-by: SawJester <[email protected]>
  • Loading branch information
SawJester and SawJester authored Dec 22, 2024
1 parent d3b259e commit a237c2d
Show file tree
Hide file tree
Showing 38 changed files with 1,152 additions and 414 deletions.
9 changes: 7 additions & 2 deletions Games/core/Game.js
Original file line number Diff line number Diff line change
Expand Up @@ -1459,9 +1459,14 @@ module.exports = class Game {
);
}
for (let r of this.PossibleRoles) {
if (special[r.split(":")[0]] && !(this.SpecialInteractionText.includes(`:journ: ${role.split(":")[0]} has a Special Interaction With ${
if (
special[r.split(":")[0]] &&
!this.SpecialInteractionText.includes(
`:journ: ${role.split(":")[0]} has a Special Interaction With ${
r.split(":")[0]
}, ${special[r.split(":")[0]]}`))) {
}, ${special[r.split(":")[0]]}`
)
) {
this.SpecialInteractionText.push(
`:journ: ${role.split(":")[0]} has a Special Interaction With ${
r.split(":")[0]
Expand Down
4 changes: 2 additions & 2 deletions Games/core/Player.js
Original file line number Diff line number Diff line change
Expand Up @@ -873,7 +873,7 @@ module.exports = class Player {
!options.shouldMeetMod.bind(this.role)(meetingName, options)) ||
(options.shouldMeetOneShot != null &&
!options.shouldMeetOneShot.bind(this.role)(meetingName, options)) ||
(options.shouldMeetDeadMod != null &&
(options.shouldMeetDeadMod != null &&
!options.shouldMeetDeadMod.bind(this.role)(meetingName, options)) ||
//
(this.alive && options.whileAlive == false) ||
Expand Down Expand Up @@ -1369,7 +1369,7 @@ module.exports = class Player {
for (let effect of player.effects) effect.player = player;

for (let alert of player.game.alertQueue.items) {
if(!alert.recipients) {
if (!alert.recipients) {
continue;
}
for (let i = 0; i < alert.recipients.length; i++) {
Expand Down
2 changes: 1 addition & 1 deletion Games/types/Mafia/Game.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ module.exports = class MafiaGame extends Game {
labels: ["hidden", "absolute", "uncontrollable"],
run: function () {
this.target.kill("leave", this.actor, true);
this.exorcisePlayer(this.actor);
this.game.exorcisePlayer(this.actor);
},
});

Expand Down
179 changes: 165 additions & 14 deletions Games/types/Mafia/Information.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,27 +68,62 @@ module.exports = class MafiaInformation {
makeFavorable() {}
makeUnfavorable() {}

getKillVictims(){
var visits = [];
for (let action of this.game.actions[0]) {
getKillVictims() {
var visits = [];
for (let action of this.game.actions[0]) {
let toCheck = action.target;
if (action.hasLabels(["kill"]) && action.dominates()) {
if (!Array.isArray(action.target)) {
toCheck = [action.target];
toCheck = [action.target];
}

if (action.target &&
toCheck[0] instanceof Player
) {
visits.push(...toCheck);
}
if (action.target && toCheck[0] instanceof Player) {
visits.push(...toCheck);
}
}
}
return visits;
}

getVisits(player){
getVisitsAppearance(player) {
if (player.hasEffect("FakeVisit")) {
for (let effect of player.effects) {
if (effect.name == "FakeVisit") {
return Random.randomizeArray(effect.Visits);
}
}
} else {
return this.getVisits(player);
}
}

getVisitorsAppearance(player) {
var visitors = [];
for (let person of this.game.players) {
if (person.hasEffect("FakeVisit")) {
for (let effect of person.effects) {
if (effect.name == "FakeVisit") {
if (effect.Visits.includes(player)) {
visitors.push(person);
}
}
}
}
}
if (visitors.length > 0) {
let realVisitors = this.getVisitors(player);
for (let visit of realVisitors) {
if (!visitors.includes(visit)) {
visitors.push(visit);
}
}
return Random.randomizeArray(visitors);
} else {
return this.getVisitors(player);
}
}

getVisits(player) {
var visits = [];
for (let action of this.game.actions[0]) {
let toCheck = action.target;
Expand All @@ -106,11 +141,10 @@ module.exports = class MafiaInformation {
}
}

return visits;
return Random.randomizeArray(visits);
}

getVisitors(player, label){

getVisitors(player, label) {
var visitors = [];
for (let action of this.game.actions[0]) {
if (label && !action.hasLabel(label)) {
Expand All @@ -131,7 +165,7 @@ module.exports = class MafiaInformation {

return Random.randomizeArray(visitors);
}

isAppearanceEvil(player, type) {
let revealType = type || "investigate";
if (
Expand Down Expand Up @@ -168,4 +202,121 @@ module.exports = class MafiaInformation {
}
return false;
}

getAppearanceAlignment(player, type) {
let revealType = type || "investigate";
if (
player.getRoleAppearance(revealType) ==
this.game.formatRole(
this.game.formatRoleInternal(player.role.name, player.role.modifier)
)
) {
return this.getAlignment(player);
}
return this.game.getRoleAlignment(
player.getRoleAppearance().split(" (")[0]
);
}
getAlignment(player) {
return player.faction;
}
isVanilla(player) {
if (
player.role.name == "Villager" ||
player.role.name == "Mafioso" ||
player.role.name == "Cultist" ||
player.role.name == "Grouch"
) {
return true;
}
return false;
}
getMostValuableEvilPlayer() {
let score = 5;
let highest = 0;
let highestPlayer;
for (let player of this.game.players) {
score = 5;
if (this.isVanilla(player)) {
score = score - 1;
}
if (
this.game
.getRoleTags(
this.game.formatRoleInternal(player.role.name, player.role.modifier)
)
.includes("Demonic")
) {
score = score + 20;
}
if (
this.game
.getRoleTags(
this.game.formatRoleInternal(player.role.name, player.role.modifier)
)
.includes("Essential")
) {
score = score + 10;
}
if (
this.game
.getRoleTags(
this.game.formatRoleInternal(player.role.name, player.role.modifier)
)
.includes("Linchpin")
) {
score = score + 30;
}
if (
this.game
.getRoleTags(
this.game.formatRoleInternal(player.role.name, player.role.modifier)
)
.includes("Self Kill")
) {
score = score - 5;
}
if (
this.game
.getRoleTags(
this.game.formatRoleInternal(player.role.name, player.role.modifier)
)
.includes("Night Killer")
) {
score = score + 5;
}
if (
this.game
.getRoleTags(
this.game.formatRoleInternal(player.role.name, player.role.modifier)
)
.includes("Kills Cultist")
) {
score = score + 20;
}
if (
this.game
.getRoleTags(
this.game.formatRoleInternal(player.role.name, player.role.modifier)
)
.includes("Day Killer")
) {
score = score + 5;
}
if (player.role.name == "Assassin") {
score = score + 30;
}
if (!player.alive && !player.role.data.CountForMajWhenDead) {
score = 0;
}
if (!this.isEvil(player)) {
score = 0;
}
if (score > highest) {
highest = score;
highestPlayer = player;
}
}
return highestPlayer;
}
};
9 changes: 9 additions & 0 deletions Games/types/Mafia/effects/FakeVisit.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
const Effect = require("../Effect");

module.exports = class FakeVisit extends Effect {
constructor(lifespan, info) {
super("FakeVisit");
this.lifespan = lifespan || Infinity;
this.Visits = info;
}
};
1 change: 1 addition & 0 deletions Games/types/Mafia/events/MissingSupplies.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ module.exports = class MissingSupplies extends Event {
);
}
this.target.holdItem("Gun");
this.target.queueGetItemAlert("Gun");
},
});
this.game.queueAction(this.action);
Expand Down
2 changes: 1 addition & 1 deletion Games/types/Mafia/information/AlignmentInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ module.exports = class AlignmentInfo extends Information {
this.target = target;
let role = this.target.getAppearance("investigate", true);
let trueRole = this.target.getAppearance("real", true);
if ((role = trueRole)) {
if (role == trueRole) {
this.mainInfo = this.target.faction;
} else {
this.mainInfo = game.getRoleAlignment(role);
Expand Down
108 changes: 108 additions & 0 deletions Games/types/Mafia/information/BinaryTrackerInfo.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
const Information = require("../Information");
const Random = require("../../../../lib/Random");
const {
EVIL_FACTIONS,
NOT_EVIL_FACTIONS,
CULT_FACTIONS,
MAFIA_FACTIONS,
FACTION_LEARN_TEAM,
FACTION_WIN_WITH_MAJORITY,
FACTION_WITH_MEETING,
FACTION_KILL,
} = require("../const/FactionList");

module.exports = class BinaryTrackerInfo extends Information {
constructor(creator, game, target) {
super("Binary Tracker Info", creator, game);
if (target == null) {
this.randomTarget = true;
target = Random.randArrayVal(this.game.alivePlayers());
}
this.target = target;
let visits = this.getVisitsAppearance(this.target);
if (visits.length > 0) {
this.mainInfo = "visited somebody";
} else {
this.mainInfo = "did not visit anybody";
}
}

getInfoRaw() {
super.getInfoRaw();
return this.mainInfo;
}

getInfoFormated() {
super.getInfoRaw();
return `You learn that ${this.target.name} ${this.mainInfo} during the night.`;
//return `You Learn that your Target is ${this.mainInfo}`
}

isTrue() {
let visits = this.getVisits(this.target);
let temp;
if (visits.length > 0) {
temp = "visited somebody";
} else {
temp = "did not visit anybody";
}
if (temp == this.mainInfo) {
return true;
} else {
return false;
}
}
isFalse() {
if (this.isTrue()) {
return false;
} else {
return true;
}
}
isFavorable() {
if (this.mainInfo == "did not visit anybody") {
return true;
} else {
return;
}
}
isUnfavorable() {
let badVisits = this.getKillVictims();

if (badVisits.length <= 0 && this.mainInfo == "did not visit anybody") {
return true;
} else if (this.mainInfo == "visited somebody") {
return true;
}
return false;
}

makeTrue() {
let visits = this.getVisits(this.target);
if (visits.length > 0) {
this.mainInfo = "visited somebody";
} else {
this.mainInfo = "did not visit anybody";
}
}
makeFalse() {
let visits = this.getVisits(this.target);
if (visits.length > 0) {
this.mainInfo = "did not visit anybody";
} else {
this.mainInfo = "visited somebody";
}
}
makeFavorable() {
this.mainInfo = "did not visit anybody";
}
makeUnfavorable() {
let badVisits = this.getKillVictims();
badVisits = badVisits.filter((p) => p != this.target);
if (badVisits.length <= 0) {
this.mainInfo = "did not visit anybody";
} else {
this.mainInfo = "visited somebody";
}
}
};
Loading

0 comments on commit a237c2d

Please sign in to comment.