Skip to content

Commit

Permalink
-m "Bug Fixes"
Browse files Browse the repository at this point in the history
  • Loading branch information
SawJester committed Dec 4, 2024
1 parent 5b8fded commit 0184a21
Show file tree
Hide file tree
Showing 21 changed files with 174 additions and 29 deletions.
4 changes: 2 additions & 2 deletions Games/core/Player.js
Original file line number Diff line number Diff line change
Expand Up @@ -962,7 +962,7 @@ module.exports = class Player {

if (this.tempAppearance[type] != null){
return `${this.tempAppearance[type]}${
noModifier ? "" : ":" + this.tempAppearanceMod[type]
noModifier ? "" : ":" + this.tempAppearanceMods[type]
}`;
}
return `${this.role.appearance[type]}${
Expand All @@ -973,7 +973,7 @@ module.exports = class Player {
setTempAppearance(type, appearance) {
if (appearance == "real") appearance = this.role.name;

this.tempAppearanceMod[type] = appearance.split(":")[1];
this.tempAppearanceMods[type] = appearance.split(":")[1];

this.tempAppearance[type] = appearance.split(":")[0];
}
Expand Down
1 change: 1 addition & 0 deletions Games/core/Role.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ module.exports = class Role {
// Configure temporary appearance reset
this.game.events.on("afterActions", () => {
this.tempAppearance = {};
this.tempAppearanceMods = {};
});
}

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 @@ -384,7 +384,7 @@ module.exports = class MafiaGame extends Game {
}

createInformation(infoType, ...args) {
const infoClass = Utils.importGameClass(this.game.type, "information", infoType);
const infoClass = Utils.importGameClass(this.type, "information", infoType);
const info = new infoClass(...args);
return info;
}
Expand Down
4 changes: 2 additions & 2 deletions Games/types/Mafia/Information.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ module.exports = class MafiaInformation{
}

getInfoRaw(){
this.events.emit("Information",this);
this.game.events.emit("Information",this);
}

getInfoFormated(){
this.events.emit("Information",this);
this.game.events.emit("Information",this);
}

isTrue() {
Expand Down
7 changes: 7 additions & 0 deletions Games/types/Mafia/Role.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,12 @@ module.exports = class MafiaRole extends Role {
death: "real",
investigate: "real",
};
this.appearanceMods = {
self: "real",
reveal: "real",
condemn: "real",
death: "real",
investigate: "real",
};
}
};
8 changes: 8 additions & 0 deletions Games/types/Mafia/effects/FavorableMode.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
const Effect = require("../Effect");

module.exports = class FavorableMode extends Effect {
constructor(lifespan) {
super("FavorableMode");
this.lifespan = lifespan || Infinity;
}
};
8 changes: 8 additions & 0 deletions Games/types/Mafia/effects/TrueMode.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
const Effect = require("../Effect");

module.exports = class TrueMode extends Effect {
constructor(lifespan) {
super("TrueMode");
this.lifespan = lifespan || Infinity;
}
};
8 changes: 8 additions & 0 deletions Games/types/Mafia/effects/UnfavorableMode.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
const Effect = require("../Effect");

module.exports = class UnfavorableMode extends Effect {
constructor(lifespan) {
super("UnfavorableMode");
this.lifespan = lifespan || Infinity;
}
};
2 changes: 1 addition & 1 deletion Games/types/Mafia/information/AlignmentInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const {
module.exports = class AlignmentInfo extends Information{
constructor(creator, game, target) {
super("Alignment Info", creator, game);
if(target = null){
if(target == null){
this.randomTarget = true;
target = Random.randArrayVal(this.game.alivePlayers());
}
Expand Down
2 changes: 1 addition & 1 deletion Games/types/Mafia/information/BinaryAlignmentInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const {
module.exports = class BinaryAlignmentInfo extends Information{
constructor(creator, game, target) {
super("Binary Alignment Info", creator, game);
if(target = null){
if(target == null){
this.randomTarget = true;
target = Random.randArrayVal(this.game.alivePlayers());
}
Expand Down
42 changes: 23 additions & 19 deletions Games/types/Mafia/information/RoleInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,22 @@ const {

module.exports = class RoleInfo extends Information{
constructor(creator, game, target) {
super("Alignment Info", creator, game);
if(target = null){
super("Role Info", creator, game);
if(target == null){
this.randomTarget = true;
target = Random.randArrayVal(this.game.alivePlayers());
}
this.target = target;

this.targetRole = this.target.getAppearance("investigate", true);
this.targetRole = target.getRoleAppearance("investigate", true);


let role = this.target.getAppearance("investigate");
let trueRole = this.target.getAppearance("real");
let role = target.getRoleAppearance("investigate");
let trueRole = this.game.formatRoleInternal(target.role.name, target.role.modifier);
this.trueRole = this.game.formatRole(trueRole);
this.mainInfo = role;

//this.game.queueAlert(`:invest: Main ${this.mainInfo} Invest ${target.getRoleAppearance("investigate")} Real ${this.trueRole}.`);
}

getInfoRaw(){
Expand All @@ -42,15 +45,15 @@ module.exports = class RoleInfo extends Information{
}

isTrue() {
if(this.target.getAppearance("real") == this.mainInfo){
if(this.trueRole == this.mainInfo){
return true;
}
else{
return false;
}
}
isFalse() {
if(this.target.getAppearance("real") != this.mainInfo){
if(this.trueRole != this.mainInfo){
return true;
}
else{
Expand All @@ -76,8 +79,8 @@ module.exports = class RoleInfo extends Information{
}

makeTrue() {
this.mainInfo = this.target.getAppearance("real");
this.targetRole = this.target.getAppearance("real", true);
this.mainInfo = this.trueRole;
this.targetRole = this.target.role.name;
}
makeFalse() {
if(!this.game.setup.closed){
Expand All @@ -86,9 +89,9 @@ module.exports = class RoleInfo extends Information{
randomPlayers = Random.randomizeArray(this.game.players);
}
for(let player of randomPlayers){
if(player.getAppearance("real") != this.target.getAppearance("real");){
this.mainInfo = player.getAppearance("real");
this.targetRole = player.getAppearance("real", true);
if(player.getRoleAppearance("investigate") != this.trueRole){
this.mainInfo = player.getRoleAppearance("investigate");
this.targetRole = player.getRoleAppearance("investigate", true);
return;
}
}
Expand All @@ -100,7 +103,7 @@ let roles = this.game.PossibleRoles.filter((r) => r != this.game.formatRoleInter
}
makeFavorable(){

if((EVIL_FACTIONS.includes(this.creator.faction)){
if(EVIL_FACTIONS.includes(this.creator.faction)){
let villagers = this.game.players.filter((p)=> p.role.name == "Villager");
if(villagers.length > 1){
this.mainInfo = "Villager";
Expand All @@ -114,10 +117,11 @@ let roles = this.game.PossibleRoles.filter((r) => r != this.game.formatRoleInter
if(randomPlayers.length <= 0){
randomPlayers = Random.randomizeArray(this.game.players.filter((p)=> p.role.alignment == this.creator.alignment));
}
if(randomPlayers.length)
for(let player of randomPlayers){
if(player.getAppearance("real") != this.target.getAppearance("real");){
this.mainInfo = player.getAppearance("real");
this.targetRole = player.getAppearance("real", true);
if(this.game.getRoleAlignment(player.getRoleAppearance("investigate",true)) == this.creator.role.alignment){
this.mainInfo = player.getRoleAppearance("investigate");
this.targetRole = player.getRoleAppearance("investigate", true);
return;
}
}
Expand All @@ -137,9 +141,9 @@ let roles = this.game.PossibleRoles.filter((r) => this.game.getRoleAlignment(r)
randomPlayers = Random.randomizeArray(this.game.players.filter((p)=> p.role.alignment != this.creator.role.alignment));
}
for(let player of randomPlayers){
if(player.getAppearance("real") != this.target.getAppearance("real");){
this.mainInfo = player.getAppearance("real");
this.targetRole = player.getAppearance("real", true);
if(this.game.getRoleAlignment(player.getRoleAppearance("investigate",true)) != this.creator.role.alignment){
this.mainInfo = player.getRoleAppearance("investigate");
this.targetRole = player.getRoleAppearance("investigate", true);
return;
}
}
Expand Down
4 changes: 3 additions & 1 deletion Games/types/Mafia/roles/cards/AppearAsRandomEvil.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ module.exports = class AppearAsRandomEvil extends Card {

const randomEvilRole = Random.randArrayVal(evilRoles);

const roleAppearance = randomEvilRole.split(":")[0];
// const roleAppearance = randomEvilRole.split(":")[0];

const roleAppearance = randomEvilRole;

const selfAppearance = role.name == "Miller" ? "Villager" : "real";

Expand Down
10 changes: 10 additions & 0 deletions Games/types/Mafia/roles/cards/FalseModifier.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
const Card = require("../../Card");
const Random = require("../../../../../lib/Random");

module.exports = class FalseModifier extends Card {
constructor(role) {
super(role);

this.startEffects = ["FalseMode"];
}
};
10 changes: 10 additions & 0 deletions Games/types/Mafia/roles/cards/FavorableModifier.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
const Card = require("../../Card");
const Random = require("../../../../../lib/Random");

module.exports = class FavorableModifier extends Card {
constructor(role) {
super(role);

this.startEffects = ["FavorableMode"];
}
};
32 changes: 32 additions & 0 deletions Games/types/Mafia/roles/cards/LearnAlignment.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,37 @@ module.exports = class LearnAlignment extends Card {
labels: ["investigate", "alignment"],
priority: PRIORITY_INVESTIGATIVE_DEFAULT,
run: function () {

let info = this.game.createInformation("BinaryAlignmentInfo", this.actor, this.game, this.target);
info.processInfo();
var alignment = info.getInfoRaw();
//this.actor.queueAlert(alert);


//insane cop
if (this.actor.role.name == "Insane Cop") {
if (alignment == `Innocent`)
alignment = "Guilty";
else alignment = `Innocent`;
}
//confused cop
if (this.actor.role.name == "Confused Cop") {
alignment = Random.randArrayVal(["Innocent","Guilty"]);
}
// naive cop
if (this.actor.role.name == "Naive Cop") {
alignment = "Innocent";
}
// paranoid cop
if (this.actor.role.name == "Paranoid Cop") {
if (this.target.role.name === "Alien") alignment = "an Alien!";
else alignment = "Guilty";
}

var alert = `:invest: After investigating, you learn that your Target is ${alignment}!`;
this.game.queueAlert(alert, 0, this.meeting.getPlayers());

/*
var role = this.target.getAppearance("investigate", true);
var alignment = this.game.getRoleAlignment(role);
//sane cop
Expand Down Expand Up @@ -55,6 +86,7 @@ module.exports = class LearnAlignment extends Card {
var alert = `:invest: After investigating, you learn that ${this.target.name} is ${alignment}!`;
this.game.queueAlert(alert, 0, this.meeting.getPlayers());
*/
},
},
},
Expand Down
10 changes: 10 additions & 0 deletions Games/types/Mafia/roles/cards/LearnRole.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,15 @@ module.exports = class LearnRole extends Card {
labels: ["investigate", "role"],
priority: PRIORITY_INVESTIGATIVE_DEFAULT,
run: function () {


let info = this.game.createInformation("RoleInfo", this.actor, this.game, this.target);
info.processInfo();
var alert = `:invest: ${info.getInfoFormated()}.`;
this.actor.queueAlert(alert);


/*
var role = this.target.getRoleAppearance();
if (this.actor.hasEffect("FalseMode")) {
Expand All @@ -29,6 +38,7 @@ module.exports = class LearnRole extends Card {
var alert = `:invest: You learn that ${this.target.name}'s role is ${role}.`;
this.actor.queueAlert(alert);
*/
},
},
},
Expand Down
6 changes: 5 additions & 1 deletion Games/types/Mafia/roles/cards/ReadMind.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,11 @@ module.exports = class ReadMind extends Card {
return;
}

let alignment = this.target.role.alignment;
let info = this.game.createInformation("AlignmentInfo", this.actor, this.game, this.target);
info.makeTrue();
var alignment = info.getInfoRaw();

//let alignment = this.target.role.alignment;

if (alignment != "Independent") {
alignment = `sided with the ${alignment}`;
Expand Down
10 changes: 10 additions & 0 deletions Games/types/Mafia/roles/cards/TrueModifier.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
const Card = require("../../Card");
const Random = require("../../../../../lib/Random");

module.exports = class TrueModifier extends Card {
constructor(role) {
super(role);

this.startEffects = ["TrueMode"];
}
};
10 changes: 10 additions & 0 deletions Games/types/Mafia/roles/cards/UnfavorableModifier.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
const Card = require("../../Card");
const Random = require("../../../../../lib/Random");

module.exports = class UnfavorableModifier extends Card {
constructor(role) {
super(role);

this.startEffects = ["UnfavorableMode"];
}
};
2 changes: 1 addition & 1 deletion Games/types/Mafia/roles/cards/VampireAppearAsRoles.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ module.exports = class VampireAppearAsRoles extends Card {

const randomEvilRole = Random.randArrayVal(randomNonVampire);

const roleAppearance = randomEvilRole.split(":")[0];
const roleAppearance = randomEvilRole;

//const selfAppearance = role.name == "Miller" ? "Villager" : "real";

Expand Down
21 changes: 21 additions & 0 deletions data/modifiers.js
Original file line number Diff line number Diff line change
Expand Up @@ -545,6 +545,27 @@ const modifierData = {
description: "Attends a Night Meeting with their Neighbors.",
},
/*
False: {
internal: ["FalseModifier"],
tags: ["FalseMode"],
description: "All Information made by this role is false.",
},
True: {
internal: ["TrueModifier"],
tags: ["FalseMode"],
description: "All Information made by this role is true.",
},
Paranoid: {
internal: ["UnfavorableModifier"],
tags: ["FalseMode"],
description: "All Information made by this role will be unfavorable to the player being checked.",
},
Naive: {
internal: ["FavorableModifier"],
tags: ["FalseMode"],
description: "All Information made by this role will be favorable to the player being checked..",
},
Red: {
internal: ["BecomeRedMafia"],
tags: ["Alignments"],
Expand Down

0 comments on commit 0184a21

Please sign in to comment.