Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More Info Files #1797

Merged
merged 14 commits into from
Dec 23, 2024
104 changes: 104 additions & 0 deletions Games/types/Mafia/information/CountVisitorsInfo.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
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 CountVisitorsInfo extends Information {
constructor(creator, game, target, limtMafia) {
super("Count Visitors Info", creator, game);
if (target == null) {
this.randomTarget = true;
target = Random.randArrayVal(this.game.alivePlayers());
}
if (limtMafia == null || limtMafia == false) {
this.limtMafia = null;
} else {
this.limtMafia = true;
}
this.target = target;

let visitors;
visitors = this.getVisitorsAppearance(this.target);
let MafiaKill = this.getVisitors(this.target, "mafia");

if (MafiaKill && MafiaKill.length > 1 && this.limtMafia == true) {
for (let x = 1; x < MafiaKill.length; x++) {
visitors.splice(visitors.indexOf(MafiaKill[x]), 1);
}
}
this.mainInfo = visitors.length;
}

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

getInfoFormated() {
super.getInfoRaw();

if (this.target == this.creator) {
return `You learn that You were visited by ${this.mainInfo} people during the night.`;
}

return `You learn that ${this.target.name} was visited by ${this.mainInfo} people during the night.`;

//return `You Learn that your Target is ${this.mainInfo}`
}

isTrue() {
let visitors = this.getVisitors(this.target);
if (this.mainInfo != visitors.length) {
return false;
}
return true;
}
isFalse() {
if (this.isTrue()) {
return false;
} else {
return true;
}
}
isFavorable() {
if (this.mainInfo <= 0) {
return true;
} else {
return false;
}
}
isUnfavorable() {
if (this.mainInfo.length <= 0) {
return false;
} else {
return true;
}
}

makeTrue() {
let visitors = this.getVisitors(this.target);
this.mainInfo = visitors.length;
}
makeFalse() {
let visitors = this.getVisitors(this.target);
if (visitors.length <= 0) {
this.mainInfo = 1;
} else {
this.mainInfo = this.mainInfo - 1;
}
}
makeFavorable() {
this.mainInfo = 0;
}
makeUnfavorable() {
this.mainInfo = Random.randArrayVal([1, 2, 3]);
}
};
82 changes: 82 additions & 0 deletions Games/types/Mafia/information/LearnTargetInfo.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
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 LearnTargetInfo extends Information {
constructor(creator, game, target) {
super("Learn Target Info", creator, game);
if (target == null) {
this.randomTarget = true;
target = Random.randArrayVal(this.game.alivePlayers());
}
this.target = target;
this.mainInfo = this.target;
}

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

getInfoFormated() {
super.getInfoRaw();

return `You Learn ${this.mainInfo.name}`;

//return `You Learn that your Target is ${this.mainInfo}`
}

isTrue() {
if (this.mainInfo == this.target) {
return true;
} else {
return false;
}
}
isFalse() {
if (this.isTrue()) {
return false;
} else {
return true;
}
}
isFavorable() {
if (!this.isEvil(this.mainInfo)) {
return false;
}
return true;
}
isUnfavorable() {
if (this.isEvil(this.mainInfo)) {
return true;
}
return false;
}

makeTrue() {
this.mainInfo = this.target;
}
makeFalse() {
let players = this.game
.alivePlayers()
.filter((p) => p != this.target && p != this.creator);
this.mainInfo = Random.randArrayVal(players);
}
makeFavorable() {
let players = this.game.alivePlayers().filter((p) => !this.isEvil(p));
this.mainInfo = Random.randArrayVal(players);
}
makeUnfavorable() {
let players = this.game.alivePlayers().filter((p) => this.isEvil(p));
this.mainInfo = Random.randArrayVal(players);
}
};
101 changes: 101 additions & 0 deletions Games/types/Mafia/information/PlayerArrayInfo.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
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 PlayerArrayInfo extends Information {
constructor(creator, game, target) {
super("Player Array Info", creator, game);
if (target == null) {
this.randomTarget = true;
target = [];
}
if (!Array.isArray(target)) {
target = [target];
}
this.target = target;
this.mainInfo = this.target;
}

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

getInfoFormated() {
super.getInfoRaw();

let playerNames = this.mainInfo.map((p) => p.name);
playerNames = Random.randomizeArray(playerNames);
if (playerNames.length == 0) playerNames.push("no one");

return `You learn ${playerNames.join(", ")}`;

//return `You Learn that your Target is ${this.mainInfo}`
}

isTrue() {
let players = this.target;
if (this.mainInfo.length != players.length) {
return false;
}
for (let player of players) {
if (!this.mainInfo.includes(player)) {
return false;
}
}
return true;
}
isFalse() {
if (this.isTrue()) {
return false;
} else {
return true;
}
}
isFavorable() {
if (this.mainInfo.length <= 0) {
return true;
} else {
return false;
}
}
isUnfavorable() {
if (this.mainInfo.length <= 0) {
return false;
} else {
return true;
}
}

makeTrue() {
this.mainInfo = this.target;
}
makeFalse() {
let players = this.target;
let possiblePlayers = this.game
.alivePlayers()
.filter((p) => p != this.creator && !players.includes(p));
let fakeInfo = [];
fakeInfo.push(Random.randArrayVal(possiblePlayers));
this.mainInfo = fakeInfo;
}
makeFavorable() {
this.mainInfo = [];
}
makeUnfavorable() {
let players = this.target;
let possiblePlayers = this.game
.alivePlayers()
.filter((p) => p != this.creator);
this.mainInfo = [Random.randArrayVal(possiblePlayers)];
}
};
10 changes: 7 additions & 3 deletions Games/types/Mafia/information/RoleInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ module.exports = class RoleInfo extends Information {
}
this.target = target;

this.targetRole = target.getRoleAppearance(this.investType, true);
this.targetRole = this.target
.getRoleAppearance(this.investType)
.split(" (")[0];

let role = target.getRoleAppearance(this.investType);
let trueRole = this.game.formatRoleInternal(
Expand Down Expand Up @@ -103,7 +105,7 @@ module.exports = class RoleInfo extends Information {
for (let player of randomPlayers) {
if (player.getRoleAppearance(this.investType) != this.trueRole) {
this.mainInfo = player.getRoleAppearance(this.investType);
this.targetRole = player.getRoleAppearance(this.investType, true);
this.targetRole = player.getRoleAppearance(this.investType);
return;
}
}
Expand Down Expand Up @@ -159,7 +161,9 @@ module.exports = class RoleInfo extends Information {
) == this.creator.role.alignment
) {
this.mainInfo = player.getRoleAppearance(this.investType);
this.targetRole = player.getRoleAppearance(this.investType, true);
this.targetRole = player
.getRoleAppearance(this.investType)
.split(" (")[0];
return;
}
}
Expand Down
28 changes: 11 additions & 17 deletions Games/types/Mafia/roles/cards/BegumsSenses.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,17 @@ module.exports = class BegumsSenses extends Card {
run: function () {
if (this.target == "No") return;

if (this.actor.hasEffect("FalseMode")) {
let wrongTargets = this.game
.alivePlayers()
.filter((p) => p != this.actor);
wrongTargets = wrongTargets.filter(
(p) => p != this.actor.role.begumTarget
);
this.actor.queueAlert(
`You learn that your target was ${
Random.randArrayVal(wrongTargets).name
}!`
);
} else {
this.actor.queueAlert(
`You learn that your target was ${this.actor.role.begumTarget.name}!`
);
}
let info = this.game.createInformation(
"LearnTargetInfo",
this.actor,
this.game,
this.actor.role.begumTarget
);
info.processInfo();
this.actor.queueAlert(
`You learn that your target was ${info.getInfoRaw().name}!`
);

delete this.actor.role.begumTarget;
},
},
Expand Down
20 changes: 8 additions & 12 deletions Games/types/Mafia/roles/cards/ConfirmSelf.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,17 @@ module.exports = class ConfirmSelf extends Card {
labels: ["investigate", "role"],
priority: PRIORITY_INVESTIGATIVE_DEFAULT,
run: function () {
let info = this.game.createInformation(
"LearnTargetInfo",
this.actor,
this.game,
this.actor
);
info.processInfo();
var alert = `:mask: You learn that ${
this.actor.name
info.getInfoRaw().name
}'s role is ${this.actor.getRoleAppearance()}.`;

if (this.actor.hasEffect("FalseMode")) {
let players = this.game
.alivePlayers()
.filter((p) => p != this.target);
players = players.filter((p) => p != this.actor);
let playerNames = players.map((p) => p.name);
alert = `:mask: You learn that ${Random.randArrayVal(
playerNames
)}'s role is ${this.actor.getRoleAppearance()}.`;
}

this.target.queueAlert(alert);
},
},
Expand Down
Loading