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

Learn player info #4

Merged
merged 43 commits into from
Dec 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
357e1d7
Prettified Code!
SawJester Dec 18, 2024
2950eb9
Update TrackerInfo.js
SawJester Dec 19, 2024
794389b
Create BinaryTrackerInfo.js
SawJester Dec 19, 2024
9718972
Prettified Code!
SawJester Dec 19, 2024
3c87642
Update TrackPlayerBoolean.js
SawJester Dec 19, 2024
d91ce69
Update MissingSupplies.js
SawJester Dec 19, 2024
992b446
Create WatcherInfo.js
SawJester Dec 19, 2024
7bb16db
Update WatchPlayer.js
SawJester Dec 19, 2024
57b4525
Create BinaryWatcherInfo.js
SawJester Dec 20, 2024
33b1c2a
Update WatchPlayerBoolean.js
SawJester Dec 20, 2024
dc417cc
Update WatcherInfo.js
SawJester Dec 20, 2024
be56f97
Update WatcherInfo.js
SawJester Dec 20, 2024
e68b772
Update WatcherInfo.js
SawJester Dec 21, 2024
b18dc04
Update ModifierLoud.js
SawJester Dec 21, 2024
2b7bfa0
Update TrackAndWatchPlayer.js
SawJester Dec 21, 2024
f258d28
Update ModifierLoud.js
SawJester Dec 21, 2024
8f647b1
Update WatcherInfo.js
SawJester Dec 21, 2024
66f8baa
Update LearnVisitorsPerson.js
SawJester Dec 21, 2024
24652eb
Update LearnVisitorsAndArm.js
SawJester Dec 21, 2024
3ad24b2
Update BegumsSenses.js
SawJester Dec 21, 2024
69ff200
Update RoleInfo.js
SawJester Dec 21, 2024
0580a6d
Update AlignmentInfo.js
SawJester Dec 21, 2024
bdf82bb
Update Information.js
SawJester Dec 21, 2024
8121fdd
Create CompareAlignmentInfo.js
SawJester Dec 21, 2024
d81b9af
Create TwoPlayersOneEvilInfo.js
SawJester Dec 21, 2024
79a45f5
Update Information.js
SawJester Dec 21, 2024
62bd76a
Update modifiers.js
SawJester Dec 21, 2024
79944ef
Update TwoPlayersOneEvilInfo.js
SawJester Dec 21, 2024
fe56b5e
Update MakePlayerLearnOneOfTwoPlayersOnDeath.js
SawJester Dec 21, 2024
ed91140
m- "Beguiler"
SawJester Dec 21, 2024
93111a4
Prettified Code!
SawJester Dec 21, 2024
9dc111f
Update modifiers.js
SawJester Dec 21, 2024
20bc0f7
Prettified Code!
SawJester Dec 21, 2024
637d445
Update LearnAndLifeLinkToPlayer.js
SawJester Dec 21, 2024
4d8fb86
Prettified Code!
SawJester Dec 21, 2024
c9f2c1c
Create LearnTargetInfo.js
SawJester Dec 21, 2024
c620ef8
Update LearnTargetInfo.js
SawJester Dec 22, 2024
5060f59
Update BegumsSenses.js
SawJester Dec 22, 2024
7a4f8c2
Update RevealRoleToTarget.js
SawJester Dec 22, 2024
9a299ca
Update RevealNameToTarget.js
SawJester Dec 22, 2024
cacebbb
Update ConfirmSelf.js
SawJester Dec 22, 2024
08218eb
Update RoleDisguiser.js
SawJester Dec 22, 2024
b5c7e6f
Update IdentityStealer.js
SawJester Dec 23, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading