From 593d412f7e86faafcc29a5192e972ede553ad523 Mon Sep 17 00:00:00 2001 From: SawJester Date: Sun, 22 Dec 2024 22:04:57 -0500 Subject: [PATCH 01/14] Learn player info (#4) * Prettified Code! * Update TrackerInfo.js * Create BinaryTrackerInfo.js * Prettified Code! * Update TrackPlayerBoolean.js * Update MissingSupplies.js * Create WatcherInfo.js * Update WatchPlayer.js * Create BinaryWatcherInfo.js * Update WatchPlayerBoolean.js * Update WatcherInfo.js * Update WatcherInfo.js * Update WatcherInfo.js * Update ModifierLoud.js * Update TrackAndWatchPlayer.js * Update ModifierLoud.js * Update WatcherInfo.js * Update LearnVisitorsPerson.js * Update LearnVisitorsAndArm.js * Update BegumsSenses.js * Update RoleInfo.js * Update AlignmentInfo.js * Update Information.js * Create CompareAlignmentInfo.js * Create TwoPlayersOneEvilInfo.js * Update Information.js * Update modifiers.js * Update TwoPlayersOneEvilInfo.js * Update MakePlayerLearnOneOfTwoPlayersOnDeath.js * m- "Beguiler" * Prettified Code! * Update modifiers.js * Prettified Code! * Update LearnAndLifeLinkToPlayer.js * Prettified Code! * Create LearnTargetInfo.js * Update LearnTargetInfo.js * Update BegumsSenses.js * Update RevealRoleToTarget.js * Update RevealNameToTarget.js * Update ConfirmSelf.js * Update RoleDisguiser.js * Update IdentityStealer.js --------- Co-authored-by: SawJester --- .../Mafia/information/LearnTargetInfo.js | 81 +++++++++++++++++++ Games/types/Mafia/roles/cards/BegumsSenses.js | 24 +++--- Games/types/Mafia/roles/cards/ConfirmSelf.js | 21 ++--- .../Mafia/roles/cards/RevealNameToTarget.js | 18 ++--- .../Mafia/roles/cards/RevealRoleToTarget.js | 23 ++---- .../types/Mafia/roles/cards/RoleDisguiser.js | 27 ++----- 6 files changed, 122 insertions(+), 72 deletions(-) create mode 100644 Games/types/Mafia/information/LearnTargetInfo.js diff --git a/Games/types/Mafia/information/LearnTargetInfo.js b/Games/types/Mafia/information/LearnTargetInfo.js new file mode 100644 index 000000000..2c82ea125 --- /dev/null +++ b/Games/types/Mafia/information/LearnTargetInfo.js @@ -0,0 +1,81 @@ +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}`; + + //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); + } +}; diff --git a/Games/types/Mafia/roles/cards/BegumsSenses.js b/Games/types/Mafia/roles/cards/BegumsSenses.js index 4180f0c1f..ea63582f4 100644 --- a/Games/types/Mafia/roles/cards/BegumsSenses.js +++ b/Games/types/Mafia/roles/cards/BegumsSenses.js @@ -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 { + 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 ${this.actor.role.begumTarget.name}!` + `You learn that your target was ${info.getInfoRaw()}!` ); - } + delete this.actor.role.begumTarget; }, }, diff --git a/Games/types/Mafia/roles/cards/ConfirmSelf.js b/Games/types/Mafia/roles/cards/ConfirmSelf.js index a231769c8..d756f3f8d 100644 --- a/Games/types/Mafia/roles/cards/ConfirmSelf.js +++ b/Games/types/Mafia/roles/cards/ConfirmSelf.js @@ -14,20 +14,15 @@ module.exports = class ConfirmSelf extends Card { labels: ["investigate", "role"], priority: PRIORITY_INVESTIGATIVE_DEFAULT, run: function () { - var alert = `:mask: You learn that ${ - this.actor.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()}.`; - } + let info = this.game.createInformation( + "LearnTargetInfo", + this.actor, + this.game, + this.actor + ); + info.processInfo(); + var alert = `:mask: You learn that ${info.getInfoRaw()}'s role is ${this.actor.getRoleAppearance()}.`; this.target.queueAlert(alert); }, diff --git a/Games/types/Mafia/roles/cards/RevealNameToTarget.js b/Games/types/Mafia/roles/cards/RevealNameToTarget.js index 80ba31ab8..bafbe5154 100644 --- a/Games/types/Mafia/roles/cards/RevealNameToTarget.js +++ b/Games/types/Mafia/roles/cards/RevealNameToTarget.js @@ -50,16 +50,14 @@ module.exports = class RevealNameToTarget extends Card { priority: PRIORITY_INVESTIGATIVE_AFTER_RESOLVE_DEFAULT, labels: ["investigate", "hidden"], run: function () { - var alert = `:mask: You learn that you were visited by ${this.actor.name}.`; - - if (this.actor.hasEffect("FalseMode")) { - let players = this.game - .alivePlayers() - .filter((p) => p != this.actor); - alert = `:mask: You learn that you were visited by ${ - Random.randArrayVal(players).name - }.`; - } + let info = this.game.createInformation( + "LearnTargetInfo", + this.actor, + this.game, + this.actor + ); + info.processInfo(); + var alert = `:mask: You learn that you were visited by ${info.getInfoRaw()}.`; let visits = this.getVisits(this.actor); visits.map((v) => v.queueAlert(alert)); diff --git a/Games/types/Mafia/roles/cards/RevealRoleToTarget.js b/Games/types/Mafia/roles/cards/RevealRoleToTarget.js index f387e0f71..2973f3548 100644 --- a/Games/types/Mafia/roles/cards/RevealRoleToTarget.js +++ b/Games/types/Mafia/roles/cards/RevealRoleToTarget.js @@ -53,21 +53,14 @@ module.exports = class RevealRoleToTarget extends Card { priority: PRIORITY_INVESTIGATIVE_AFTER_RESOLVE_DEFAULT, labels: ["investigate", "hidden"], run: function () { - var alert = `:mask: You learn that you were targeted by ${this.actor.getRoleAppearance()}.`; - - if (this.actor.hasEffect("FalseMode")) { - let players = this.game - .alivePlayers() - .filter( - (p) => - p.getRoleAppearance("condemn").split(" (")[0] != - this.actor.role.name - ); - alert = `:mask: You learn that you were visited by ${Random.randArrayVal( - players - ).getRoleAppearance()}.`; - } - + let info = this.game.createInformation( + "RoleInfo", + this.actor, + this.game, + this.actor + ); + info.processInfo(); + var alert = `:mask: You learn that you were targeted by ${info.getInfoRaw()}.`; let visits = this.getVisits(this.actor); visits.map((v) => v.queueAlert(alert)); }, diff --git a/Games/types/Mafia/roles/cards/RoleDisguiser.js b/Games/types/Mafia/roles/cards/RoleDisguiser.js index 30103e203..d5b5f64e4 100644 --- a/Games/types/Mafia/roles/cards/RoleDisguiser.js +++ b/Games/types/Mafia/roles/cards/RoleDisguiser.js @@ -16,28 +16,17 @@ module.exports = class RoleDisguiser extends Card { priority: PRIORITY_INVESTIGATIVE_DEFAULT, run: function () { let role = this.target.getAppearance("investigate", true); + let info = this.game.createInformation( + "RoleInfo", + this.actor, + this.game, + this.actor.role.begumTarget + ); + info.processInfo(); let alert = `:mask: After studying ${ this.target.name - }, you learn to act like ${addArticle(role)}.`; + }, you learn to act like ${addArticle(info.getInfoRaw())}.`; this.actor.holdItem("Suit", { type: role }); - - if (this.actor.hasEffect("FalseMode")) { - let wrongPlayers = this.game - .alivePlayers() - .filter( - (p) => - p.getRoleAppearance("investigate").split(" (")[0] != - this.target.role.name - ); - let wrongRole = - Random.randArrayVal(wrongPlayers).getRoleAppearance( - "investigate" - ); - alert = `:mask: After studying ${ - this.target.name - }, you learn to act like ${addArticle(wrongRole)}.`; - } - this.actor.queueAlert(alert); }, }, From d1f83143417910687979fbcfdad1509fbdf722d2 Mon Sep 17 00:00:00 2001 From: SawJester Date: Mon, 23 Dec 2024 03:05:21 +0000 Subject: [PATCH 02/14] Prettified Code! --- .../Mafia/information/LearnTargetInfo.js | 29 ++++++++++--------- Games/types/Mafia/roles/cards/BegumsSenses.js | 8 ++--- Games/types/Mafia/roles/cards/ConfirmSelf.js | 3 +- .../Mafia/roles/cards/RevealNameToTarget.js | 2 +- .../types/Mafia/roles/cards/RoleDisguiser.js | 2 +- 5 files changed, 22 insertions(+), 22 deletions(-) diff --git a/Games/types/Mafia/information/LearnTargetInfo.js b/Games/types/Mafia/information/LearnTargetInfo.js index 2c82ea125..b77cf93b6 100644 --- a/Games/types/Mafia/information/LearnTargetInfo.js +++ b/Games/types/Mafia/information/LearnTargetInfo.js @@ -20,7 +20,6 @@ module.exports = class LearnTargetInfo extends Information { } this.target = target; this.mainInfo = this.target; - } getInfoRaw() { @@ -51,31 +50,33 @@ module.exports = class LearnTargetInfo extends Information { } } isFavorable() { - if(!this.isEvil(this.mainInfo)){ - return false; - } - return true; - } - isUnfavorable() { - if(this.isEvil(this.mainInfo)){ + if (!this.isEvil(this.mainInfo)) { + return false; + } return true; } - return false; + isUnfavorable() { + if (this.isEvil(this.mainInfo)) { + return true; + } + return false; } makeTrue() { - this.mainInfo = this.target; + this.mainInfo = this.target; } makeFalse() { - let players = this.game.alivePlayers().filter((p) => p != this.target && p != this.creator) - this.mainInfo = Random.randArrayVal(players); + 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); + this.mainInfo = Random.randArrayVal(players); } makeUnfavorable() { let players = this.game.alivePlayers().filter((p) => this.isEvil(p)); - this.mainInfo = Random.randArrayVal(players); + this.mainInfo = Random.randArrayVal(players); } }; diff --git a/Games/types/Mafia/roles/cards/BegumsSenses.js b/Games/types/Mafia/roles/cards/BegumsSenses.js index ea63582f4..fbe8509fd 100644 --- a/Games/types/Mafia/roles/cards/BegumsSenses.js +++ b/Games/types/Mafia/roles/cards/BegumsSenses.js @@ -25,10 +25,10 @@ module.exports = class BegumsSenses extends Card { this.actor.role.begumTarget ); info.processInfo(); - this.actor.queueAlert( - `You learn that your target was ${info.getInfoRaw()}!` - ); - + this.actor.queueAlert( + `You learn that your target was ${info.getInfoRaw()}!` + ); + delete this.actor.role.begumTarget; }, }, diff --git a/Games/types/Mafia/roles/cards/ConfirmSelf.js b/Games/types/Mafia/roles/cards/ConfirmSelf.js index d756f3f8d..334adff6f 100644 --- a/Games/types/Mafia/roles/cards/ConfirmSelf.js +++ b/Games/types/Mafia/roles/cards/ConfirmSelf.js @@ -14,14 +14,13 @@ 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(); + info.processInfo(); var alert = `:mask: You learn that ${info.getInfoRaw()}'s role is ${this.actor.getRoleAppearance()}.`; this.target.queueAlert(alert); diff --git a/Games/types/Mafia/roles/cards/RevealNameToTarget.js b/Games/types/Mafia/roles/cards/RevealNameToTarget.js index bafbe5154..3df009c36 100644 --- a/Games/types/Mafia/roles/cards/RevealNameToTarget.js +++ b/Games/types/Mafia/roles/cards/RevealNameToTarget.js @@ -50,7 +50,7 @@ module.exports = class RevealNameToTarget extends Card { priority: PRIORITY_INVESTIGATIVE_AFTER_RESOLVE_DEFAULT, labels: ["investigate", "hidden"], run: function () { - let info = this.game.createInformation( + let info = this.game.createInformation( "LearnTargetInfo", this.actor, this.game, diff --git a/Games/types/Mafia/roles/cards/RoleDisguiser.js b/Games/types/Mafia/roles/cards/RoleDisguiser.js index d5b5f64e4..7a25c0c08 100644 --- a/Games/types/Mafia/roles/cards/RoleDisguiser.js +++ b/Games/types/Mafia/roles/cards/RoleDisguiser.js @@ -25,7 +25,7 @@ module.exports = class RoleDisguiser extends Card { info.processInfo(); let alert = `:mask: After studying ${ this.target.name - }, you learn to act like ${addArticle(info.getInfoRaw())}.`; + }, you learn to act like ${addArticle(info.getInfoRaw())}.`; this.actor.holdItem("Suit", { type: role }); this.actor.queueAlert(alert); }, From b76cef8d3bbc9c1bea79562e79348ddcc046e2ff Mon Sep 17 00:00:00 2001 From: SawJester Date: Mon, 23 Dec 2024 01:47:58 -0500 Subject: [PATCH 03/14] Create PlayerArrayInfo.js --- .../Mafia/information/PlayerArrayInfo.js | 101 ++++++++++++++++++ 1 file changed, 101 insertions(+) create mode 100644 Games/types/Mafia/information/PlayerArrayInfo.js diff --git a/Games/types/Mafia/information/PlayerArrayInfo.js b/Games/types/Mafia/information/PlayerArrayInfo.js new file mode 100644 index 000000000..4165f9c8d --- /dev/null +++ b/Games/types/Mafia/information/PlayerArrayInfo.js @@ -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 = []; + } + + 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(possibleVisitors)); + this.mainInfo = fakeInfo; + } + makeFavorable() { + this.mainInfo = []; + } + makeUnfavorable() { + let players = this.target; + let possibleVisitors = this.game + .alivePlayers() + .filter((p) => p != this.creator); + this.mainInfo = [Random.randArrayVal(possibleVisitors)]; + } +}; From a33a043191b4f0fec99f38ed061d29926d37c49c Mon Sep 17 00:00:00 2001 From: SawJester Date: Mon, 23 Dec 2024 06:48:23 +0000 Subject: [PATCH 04/14] Prettified Code! --- .../Mafia/information/PlayerArrayInfo.js | 23 ++++++++----------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/Games/types/Mafia/information/PlayerArrayInfo.js b/Games/types/Mafia/information/PlayerArrayInfo.js index 4165f9c8d..bd0065d02 100644 --- a/Games/types/Mafia/information/PlayerArrayInfo.js +++ b/Games/types/Mafia/information/PlayerArrayInfo.js @@ -18,7 +18,7 @@ module.exports = class PlayerArrayInfo extends Information { this.randomTarget = true; target = []; } - + this.mainInfo = this.target; } @@ -29,12 +29,11 @@ module.exports = class PlayerArrayInfo extends Information { 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}` @@ -69,7 +68,7 @@ module.exports = class PlayerArrayInfo extends Information { isUnfavorable() { if (this.mainInfo.length <= 0) { return false; - } else { + } else { return true; } } @@ -80,22 +79,20 @@ module.exports = class PlayerArrayInfo extends Information { makeFalse() { let players = this.target; let possiblePlayers = this.game - .alivePlayers() - .filter( - (p) => p != this.creator && !players.includes(p) - ); - let fakeInfo = []; - fakeInfo.push(Random.randArrayVal(possibleVisitors)); - this.mainInfo = fakeInfo; + .alivePlayers() + .filter((p) => p != this.creator && !players.includes(p)); + let fakeInfo = []; + fakeInfo.push(Random.randArrayVal(possibleVisitors)); + this.mainInfo = fakeInfo; } makeFavorable() { - this.mainInfo = []; + this.mainInfo = []; } makeUnfavorable() { let players = this.target; let possibleVisitors = this.game .alivePlayers() .filter((p) => p != this.creator); - this.mainInfo = [Random.randArrayVal(possibleVisitors)]; + this.mainInfo = [Random.randArrayVal(possibleVisitors)]; } }; From fd55802756c7e2abad1a91d6a5c87cfb89b5e754 Mon Sep 17 00:00:00 2001 From: SawJester Date: Mon, 23 Dec 2024 01:51:31 -0500 Subject: [PATCH 05/14] Update PaintPortraits.js --- .../types/Mafia/roles/cards/PaintPortraits.js | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/Games/types/Mafia/roles/cards/PaintPortraits.js b/Games/types/Mafia/roles/cards/PaintPortraits.js index ff4ef97c3..4d238b6d5 100644 --- a/Games/types/Mafia/roles/cards/PaintPortraits.js +++ b/Games/types/Mafia/roles/cards/PaintPortraits.js @@ -84,19 +84,17 @@ module.exports = class PaintPortraits extends Card { } let uniquePortraits = unique(portraits); - if (this.player.hasEffect("FalseMode")) { - let wrongPlayers = this.game - .alivePlayers() - .filter((p) => p != this.player); - for (let l in uniquePortraits) { - wrongPlayers = wrongPlayers.filter((p) => p != l); - } - uniquePortraits = [Random.randArrayVal(wrongPlayers).name]; - } + let info = this.game.createInformation( + "PlayerArrayInfo", + this.actor, + this.game, + uniquePortraits + ); + info.processInfo(); let painterAuction = `:paintbrush: ${ this.player.name - }'s extensive collection of paintings have gone up for auction. Among them are portraits of ${uniquePortraits.join( + }'s extensive collection of paintings have gone up for auction. Among them are portraits of ${info.getInfoRaw().join( ", " )}.`; this.game.queueAlert(painterAuction); From 960d319c0dbb2ab78d7d09b4e54a2d4144b078d1 Mon Sep 17 00:00:00 2001 From: SawJester Date: Mon, 23 Dec 2024 06:51:55 +0000 Subject: [PATCH 06/14] Prettified Code! --- .../types/Mafia/roles/cards/PaintPortraits.js | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Games/types/Mafia/roles/cards/PaintPortraits.js b/Games/types/Mafia/roles/cards/PaintPortraits.js index 4d238b6d5..17f6ff5cb 100644 --- a/Games/types/Mafia/roles/cards/PaintPortraits.js +++ b/Games/types/Mafia/roles/cards/PaintPortraits.js @@ -84,19 +84,19 @@ module.exports = class PaintPortraits extends Card { } let uniquePortraits = unique(portraits); - let info = this.game.createInformation( - "PlayerArrayInfo", - this.actor, - this.game, - uniquePortraits - ); - info.processInfo(); + let info = this.game.createInformation( + "PlayerArrayInfo", + this.actor, + this.game, + uniquePortraits + ); + info.processInfo(); let painterAuction = `:paintbrush: ${ this.player.name - }'s extensive collection of paintings have gone up for auction. Among them are portraits of ${info.getInfoRaw().join( - ", " - )}.`; + }'s extensive collection of paintings have gone up for auction. Among them are portraits of ${info + .getInfoRaw() + .join(", ")}.`; this.game.queueAlert(painterAuction); } }, From aa1239a831fdb212f61590e958d7b90d3df1e2fa Mon Sep 17 00:00:00 2001 From: SawJester Date: Mon, 23 Dec 2024 02:03:58 -0500 Subject: [PATCH 07/14] Create CountVisitorsInfo.js --- .../Mafia/information/CountVisitorsInfo.js | 110 ++++++++++++++++++ 1 file changed, 110 insertions(+) create mode 100644 Games/types/Mafia/information/CountVisitorsInfo.js diff --git a/Games/types/Mafia/information/CountVisitorsInfo.js b/Games/types/Mafia/information/CountVisitorsInfo.js new file mode 100644 index 000000000..2e60f9eb3 --- /dev/null +++ b/Games/types/Mafia/information/CountVisitorsInfo.js @@ -0,0 +1,110 @@ +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]); + } +}; From 12393c9976cab128ad33d351b6702bdb0f02d30d Mon Sep 17 00:00:00 2001 From: SawJester Date: Mon, 23 Dec 2024 07:04:23 +0000 Subject: [PATCH 08/14] Prettified Code! --- .../Mafia/information/CountVisitorsInfo.js | 20 +++++++------------ 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/Games/types/Mafia/information/CountVisitorsInfo.js b/Games/types/Mafia/information/CountVisitorsInfo.js index 2e60f9eb3..4aeada5d1 100644 --- a/Games/types/Mafia/information/CountVisitorsInfo.js +++ b/Games/types/Mafia/information/CountVisitorsInfo.js @@ -29,11 +29,7 @@ module.exports = class CountVisitorsInfo extends Information { visitors = this.getVisitorsAppearance(this.target); let MafiaKill = this.getVisitors(this.target, "mafia"); - if ( - MafiaKill && - MafiaKill.length > 1 && - this.limtMafia == true - ) { + if (MafiaKill && MafiaKill.length > 1 && this.limtMafia == true) { for (let x = 1; x < MafiaKill.length; x++) { visitors.splice(visitors.indexOf(MafiaKill[x]), 1); } @@ -53,9 +49,7 @@ module.exports = class CountVisitorsInfo extends Information { 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 ${this.target.name} was visited by ${this.mainInfo} people during the night.`; //return `You Learn that your Target is ${this.mainInfo}` } @@ -77,14 +71,14 @@ module.exports = class CountVisitorsInfo extends Information { isFavorable() { if (this.mainInfo <= 0) { return true; - } else { + } else { return false; } } isUnfavorable() { if (this.mainInfo.length <= 0) { return false; - } else { + } else { return true; } } @@ -98,13 +92,13 @@ module.exports = class CountVisitorsInfo extends Information { if (visitors.length <= 0) { this.mainInfo = 1; } else { - this.mainInfo = this.mainInfo-1; + this.mainInfo = this.mainInfo - 1; } } makeFavorable() { - this.mainInfo = 0; + this.mainInfo = 0; } makeUnfavorable() { - this.mainInfo = Random.randArrayVal([1,2,3]); + this.mainInfo = Random.randArrayVal([1, 2, 3]); } }; From 23d3d9f0cdf97c0c5e691e970b97d027579f2ae6 Mon Sep 17 00:00:00 2001 From: SawJester Date: Mon, 23 Dec 2024 02:08:00 -0500 Subject: [PATCH 09/14] Update CountVisitors.js --- Games/types/Mafia/roles/cards/CountVisitors.js | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/Games/types/Mafia/roles/cards/CountVisitors.js b/Games/types/Mafia/roles/cards/CountVisitors.js index 69323e2ea..adb560870 100644 --- a/Games/types/Mafia/roles/cards/CountVisitors.js +++ b/Games/types/Mafia/roles/cards/CountVisitors.js @@ -55,18 +55,16 @@ module.exports = class CountVisitors extends Card { if (visitors) { let unique = new Set(visitors); - if (this.actor.hasEffect("FalseMode")) { - let num = 0; - if (unique.size == 0) num = 1; - else num = 0; - this.actor.queueAlert( - `:visited: You were visited by ${num} people last night.` - ); - return; - } + let info = this.game.createInformation( + "WatcherInfo", + this.actor, + this.game, + this.actor + ); + info.processInfo(); this.actor.queueAlert( - `:visited: You were visited by ${unique.size} people last night.` + `:visited: You were visited by ${info.getInfoRaw()} people last night.` ); } }, From 7e57cea50536defa94ff64289e8eae876ad3250e Mon Sep 17 00:00:00 2001 From: SawJester Date: Mon, 23 Dec 2024 07:08:24 +0000 Subject: [PATCH 10/14] Prettified Code! --- Games/types/Mafia/roles/cards/CountVisitors.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Games/types/Mafia/roles/cards/CountVisitors.js b/Games/types/Mafia/roles/cards/CountVisitors.js index adb560870..4f250efcd 100644 --- a/Games/types/Mafia/roles/cards/CountVisitors.js +++ b/Games/types/Mafia/roles/cards/CountVisitors.js @@ -56,12 +56,12 @@ module.exports = class CountVisitors extends Card { let unique = new Set(visitors); let info = this.game.createInformation( - "WatcherInfo", - this.actor, - this.game, - this.actor - ); - info.processInfo(); + "WatcherInfo", + this.actor, + this.game, + this.actor + ); + info.processInfo(); this.actor.queueAlert( `:visited: You were visited by ${info.getInfoRaw()} people last night.` From 24f9003315f519440a6e1b9336d9db2261a381d4 Mon Sep 17 00:00:00 2001 From: SawJester Date: Mon, 23 Dec 2024 08:45:00 +0000 Subject: [PATCH 11/14] m-"More information" --- Games/types/Mafia/information/LearnTargetInfo.js | 2 +- Games/types/Mafia/information/PlayerArrayInfo.js | 13 ++++++++----- Games/types/Mafia/information/RoleInfo.js | 6 +++--- Games/types/Mafia/roles/cards/BegumsSenses.js | 2 +- Games/types/Mafia/roles/cards/ConfirmSelf.js | 2 +- Games/types/Mafia/roles/cards/CountVisitors.js | 2 +- Games/types/Mafia/roles/cards/PaintPortraits.js | 11 +++++------ Games/types/Mafia/roles/cards/RevealNameToTarget.js | 2 +- data/modifiers.js | 4 ++-- 9 files changed, 23 insertions(+), 21 deletions(-) diff --git a/Games/types/Mafia/information/LearnTargetInfo.js b/Games/types/Mafia/information/LearnTargetInfo.js index b77cf93b6..e3abd5ac8 100644 --- a/Games/types/Mafia/information/LearnTargetInfo.js +++ b/Games/types/Mafia/information/LearnTargetInfo.js @@ -30,7 +30,7 @@ module.exports = class LearnTargetInfo extends Information { getInfoFormated() { super.getInfoRaw(); - return `You Learn ${this.mainInfo}`; + return `You Learn ${this.mainInfo.name}`; //return `You Learn that your Target is ${this.mainInfo}` } diff --git a/Games/types/Mafia/information/PlayerArrayInfo.js b/Games/types/Mafia/information/PlayerArrayInfo.js index bd0065d02..587e68097 100644 --- a/Games/types/Mafia/information/PlayerArrayInfo.js +++ b/Games/types/Mafia/information/PlayerArrayInfo.js @@ -18,7 +18,10 @@ module.exports = class PlayerArrayInfo extends Information { this.randomTarget = true; target = []; } - + if (!Array.isArray(target)) { + target = [target]; + } + this.target = target; this.mainInfo = this.target; } @@ -80,9 +83,9 @@ module.exports = class PlayerArrayInfo extends Information { let players = this.target; let possiblePlayers = this.game .alivePlayers() - .filter((p) => p != this.creator && !players.includes(p)); + .filter((p) => p != this.creator && !(players.includes(p))); let fakeInfo = []; - fakeInfo.push(Random.randArrayVal(possibleVisitors)); + fakeInfo.push(Random.randArrayVal(possiblePlayers)); this.mainInfo = fakeInfo; } makeFavorable() { @@ -90,9 +93,9 @@ module.exports = class PlayerArrayInfo extends Information { } makeUnfavorable() { let players = this.target; - let possibleVisitors = this.game + let possiblePlayers = this.game .alivePlayers() .filter((p) => p != this.creator); - this.mainInfo = [Random.randArrayVal(possibleVisitors)]; + this.mainInfo = [Random.randArrayVal(possiblePlayers)]; } }; diff --git a/Games/types/Mafia/information/RoleInfo.js b/Games/types/Mafia/information/RoleInfo.js index ad676e150..8a6094407 100644 --- a/Games/types/Mafia/information/RoleInfo.js +++ b/Games/types/Mafia/information/RoleInfo.js @@ -24,7 +24,7 @@ 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( @@ -103,7 +103,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; } } @@ -159,7 +159,7 @@ 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; } } diff --git a/Games/types/Mafia/roles/cards/BegumsSenses.js b/Games/types/Mafia/roles/cards/BegumsSenses.js index fbe8509fd..d744a6545 100644 --- a/Games/types/Mafia/roles/cards/BegumsSenses.js +++ b/Games/types/Mafia/roles/cards/BegumsSenses.js @@ -26,7 +26,7 @@ module.exports = class BegumsSenses extends Card { ); info.processInfo(); this.actor.queueAlert( - `You learn that your target was ${info.getInfoRaw()}!` + `You learn that your target was ${info.getInfoRaw().name}!` ); delete this.actor.role.begumTarget; diff --git a/Games/types/Mafia/roles/cards/ConfirmSelf.js b/Games/types/Mafia/roles/cards/ConfirmSelf.js index 334adff6f..8d44bd868 100644 --- a/Games/types/Mafia/roles/cards/ConfirmSelf.js +++ b/Games/types/Mafia/roles/cards/ConfirmSelf.js @@ -21,7 +21,7 @@ module.exports = class ConfirmSelf extends Card { this.actor ); info.processInfo(); - var alert = `:mask: You learn that ${info.getInfoRaw()}'s role is ${this.actor.getRoleAppearance()}.`; + var alert = `:mask: You learn that ${info.getInfoRaw().name}'s role is ${this.actor.getRoleAppearance()}.`; this.target.queueAlert(alert); }, diff --git a/Games/types/Mafia/roles/cards/CountVisitors.js b/Games/types/Mafia/roles/cards/CountVisitors.js index 4f250efcd..e05026291 100644 --- a/Games/types/Mafia/roles/cards/CountVisitors.js +++ b/Games/types/Mafia/roles/cards/CountVisitors.js @@ -56,7 +56,7 @@ module.exports = class CountVisitors extends Card { let unique = new Set(visitors); let info = this.game.createInformation( - "WatcherInfo", + "CountVisitorsInfo", this.actor, this.game, this.actor diff --git a/Games/types/Mafia/roles/cards/PaintPortraits.js b/Games/types/Mafia/roles/cards/PaintPortraits.js index 17f6ff5cb..9c163f3f4 100644 --- a/Games/types/Mafia/roles/cards/PaintPortraits.js +++ b/Games/types/Mafia/roles/cards/PaintPortraits.js @@ -52,7 +52,7 @@ module.exports = class PaintPortraits extends Card { let visitors = this.getVisitors(this.actor); for (let visitor of visitors) { - this.actor.data.portraits.push(visitor.name); + this.actor.data.portraits.push(visitor); } }, }); @@ -69,7 +69,7 @@ module.exports = class PaintPortraits extends Card { let noRepeat = true; for (const j of result) { - if (i === j) { + if (i.name === j.name) { noRepeat = false; break; } @@ -84,9 +84,10 @@ module.exports = class PaintPortraits extends Card { } let uniquePortraits = unique(portraits); + let info = this.game.createInformation( "PlayerArrayInfo", - this.actor, + this.player, this.game, uniquePortraits ); @@ -94,9 +95,7 @@ module.exports = class PaintPortraits extends Card { let painterAuction = `:paintbrush: ${ this.player.name - }'s extensive collection of paintings have gone up for auction. Among them are portraits of ${info - .getInfoRaw() - .join(", ")}.`; + }'s extensive collection of paintings have gone up for auction. Among them are portraits of ${info.getInfoRaw().map((p) => p.name).join(", ")}.`; this.game.queueAlert(painterAuction); } }, diff --git a/Games/types/Mafia/roles/cards/RevealNameToTarget.js b/Games/types/Mafia/roles/cards/RevealNameToTarget.js index 3df009c36..150242471 100644 --- a/Games/types/Mafia/roles/cards/RevealNameToTarget.js +++ b/Games/types/Mafia/roles/cards/RevealNameToTarget.js @@ -57,7 +57,7 @@ module.exports = class RevealNameToTarget extends Card { this.actor ); info.processInfo(); - var alert = `:mask: You learn that you were visited by ${info.getInfoRaw()}.`; + var alert = `:mask: You learn that you were visited by ${info.getInfoRaw().name}.`; let visits = this.getVisits(this.actor); visits.map((v) => v.queueAlert(alert)); diff --git a/data/modifiers.js b/data/modifiers.js index 4bb2bd4a8..43aeaeb5f 100644 --- a/data/modifiers.js +++ b/data/modifiers.js @@ -552,7 +552,7 @@ const modifierData = { description: "If killed at night, a player with this modifier learns that 1 of 2 players is evil.", }, - /* + False: { internal: ["FalseModifier"], tags: ["FalseMode"], @@ -581,7 +581,7 @@ const modifierData = { tags: ["Alignments"], description: "Joins the Red Mafia.", }, - */ + }, "Split Decision": {}, Resistance: {}, From 21ad16ec5a27c81e2ee4771718c159443c7f038e Mon Sep 17 00:00:00 2001 From: SawJester Date: Mon, 23 Dec 2024 08:45:46 +0000 Subject: [PATCH 12/14] Prettified Code! --- Games/types/Mafia/information/PlayerArrayInfo.js | 2 +- Games/types/Mafia/information/RoleInfo.js | 8 ++++++-- Games/types/Mafia/roles/cards/ConfirmSelf.js | 4 +++- Games/types/Mafia/roles/cards/PaintPortraits.js | 6 ++++-- Games/types/Mafia/roles/cards/RevealNameToTarget.js | 4 +++- data/modifiers.js | 3 +-- 6 files changed, 18 insertions(+), 9 deletions(-) diff --git a/Games/types/Mafia/information/PlayerArrayInfo.js b/Games/types/Mafia/information/PlayerArrayInfo.js index 587e68097..d446bdc65 100644 --- a/Games/types/Mafia/information/PlayerArrayInfo.js +++ b/Games/types/Mafia/information/PlayerArrayInfo.js @@ -83,7 +83,7 @@ module.exports = class PlayerArrayInfo extends Information { let players = this.target; let possiblePlayers = this.game .alivePlayers() - .filter((p) => p != this.creator && !(players.includes(p))); + .filter((p) => p != this.creator && !players.includes(p)); let fakeInfo = []; fakeInfo.push(Random.randArrayVal(possiblePlayers)); this.mainInfo = fakeInfo; diff --git a/Games/types/Mafia/information/RoleInfo.js b/Games/types/Mafia/information/RoleInfo.js index 8a6094407..6b7e7e8a3 100644 --- a/Games/types/Mafia/information/RoleInfo.js +++ b/Games/types/Mafia/information/RoleInfo.js @@ -24,7 +24,9 @@ module.exports = class RoleInfo extends Information { } this.target = target; - this.targetRole = this.target.getRoleAppearance(this.investType).split(" (")[0];; + this.targetRole = this.target + .getRoleAppearance(this.investType) + .split(" (")[0]; let role = target.getRoleAppearance(this.investType); let trueRole = this.game.formatRoleInternal( @@ -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).split(" (")[0]; + this.targetRole = player + .getRoleAppearance(this.investType) + .split(" (")[0]; return; } } diff --git a/Games/types/Mafia/roles/cards/ConfirmSelf.js b/Games/types/Mafia/roles/cards/ConfirmSelf.js index 8d44bd868..c82dcf36c 100644 --- a/Games/types/Mafia/roles/cards/ConfirmSelf.js +++ b/Games/types/Mafia/roles/cards/ConfirmSelf.js @@ -21,7 +21,9 @@ module.exports = class ConfirmSelf extends Card { this.actor ); info.processInfo(); - var alert = `:mask: You learn that ${info.getInfoRaw().name}'s role is ${this.actor.getRoleAppearance()}.`; + var alert = `:mask: You learn that ${ + info.getInfoRaw().name + }'s role is ${this.actor.getRoleAppearance()}.`; this.target.queueAlert(alert); }, diff --git a/Games/types/Mafia/roles/cards/PaintPortraits.js b/Games/types/Mafia/roles/cards/PaintPortraits.js index 9c163f3f4..57906ca09 100644 --- a/Games/types/Mafia/roles/cards/PaintPortraits.js +++ b/Games/types/Mafia/roles/cards/PaintPortraits.js @@ -84,7 +84,6 @@ module.exports = class PaintPortraits extends Card { } let uniquePortraits = unique(portraits); - let info = this.game.createInformation( "PlayerArrayInfo", this.player, @@ -95,7 +94,10 @@ module.exports = class PaintPortraits extends Card { let painterAuction = `:paintbrush: ${ this.player.name - }'s extensive collection of paintings have gone up for auction. Among them are portraits of ${info.getInfoRaw().map((p) => p.name).join(", ")}.`; + }'s extensive collection of paintings have gone up for auction. Among them are portraits of ${info + .getInfoRaw() + .map((p) => p.name) + .join(", ")}.`; this.game.queueAlert(painterAuction); } }, diff --git a/Games/types/Mafia/roles/cards/RevealNameToTarget.js b/Games/types/Mafia/roles/cards/RevealNameToTarget.js index 150242471..07abde11c 100644 --- a/Games/types/Mafia/roles/cards/RevealNameToTarget.js +++ b/Games/types/Mafia/roles/cards/RevealNameToTarget.js @@ -57,7 +57,9 @@ module.exports = class RevealNameToTarget extends Card { this.actor ); info.processInfo(); - var alert = `:mask: You learn that you were visited by ${info.getInfoRaw().name}.`; + var alert = `:mask: You learn that you were visited by ${ + info.getInfoRaw().name + }.`; let visits = this.getVisits(this.actor); visits.map((v) => v.queueAlert(alert)); diff --git a/data/modifiers.js b/data/modifiers.js index 43aeaeb5f..ee7d236f0 100644 --- a/data/modifiers.js +++ b/data/modifiers.js @@ -552,7 +552,7 @@ const modifierData = { description: "If killed at night, a player with this modifier learns that 1 of 2 players is evil.", }, - + False: { internal: ["FalseModifier"], tags: ["FalseMode"], @@ -581,7 +581,6 @@ const modifierData = { tags: ["Alignments"], description: "Joins the Red Mafia.", }, - }, "Split Decision": {}, Resistance: {}, From 44b3bb48230228f00265c57008aeb9a093ec643a Mon Sep 17 00:00:00 2001 From: SawJester Date: Mon, 23 Dec 2024 03:46:57 -0500 Subject: [PATCH 13/14] Update modifiers.js --- data/modifiers.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/data/modifiers.js b/data/modifiers.js index ee7d236f0..2224bf940 100644 --- a/data/modifiers.js +++ b/data/modifiers.js @@ -552,7 +552,7 @@ const modifierData = { description: "If killed at night, a player with this modifier learns that 1 of 2 players is evil.", }, - +/* False: { internal: ["FalseModifier"], tags: ["FalseMode"], @@ -581,6 +581,7 @@ const modifierData = { tags: ["Alignments"], description: "Joins the Red Mafia.", }, + */ }, "Split Decision": {}, Resistance: {}, From 04ba65feecc730d0cadd06dba9f68caba4d1e52f Mon Sep 17 00:00:00 2001 From: SawJester Date: Mon, 23 Dec 2024 08:47:21 +0000 Subject: [PATCH 14/14] Prettified Code! --- data/modifiers.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data/modifiers.js b/data/modifiers.js index 2224bf940..4bb2bd4a8 100644 --- a/data/modifiers.js +++ b/data/modifiers.js @@ -552,7 +552,7 @@ const modifierData = { description: "If killed at night, a player with this modifier learns that 1 of 2 players is evil.", }, -/* + /* False: { internal: ["FalseModifier"], tags: ["FalseMode"],