Skip to content

Commit

Permalink
Miller/Vampire Fix (#1775)
Browse files Browse the repository at this point in the history
Miller/Vampire now show with Modifiers
  • Loading branch information
SawJester authored Dec 5, 2024
1 parent 36d4fe5 commit a3bae02
Show file tree
Hide file tree
Showing 21 changed files with 613 additions and 8 deletions.
13 changes: 8 additions & 5 deletions Games/core/Player.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ module.exports = class Player {
this.effects = [];
this.tempImmunity = {};
this.tempAppearance = {};
this.tempAppearanceMods = {};
this.history = new History(this.game, this);
this.ready = false;
this.won = false;
Expand Down Expand Up @@ -959,20 +960,22 @@ module.exports = class Player {
getAppearance(type, noModifier) {
noModifier = noModifier || this.role.hideModifier[type];

if (this.tempAppearance[type] != null)
if (this.tempAppearance[type] != null){
return `${this.tempAppearance[type]}${
noModifier ? "" : ":" + this.role.modifier
noModifier ? "" : ":" + this.tempAppearanceMods[type]
}`;

}
return `${this.role.appearance[type]}${
noModifier ? "" : ":" + this.role.modifier
noModifier ? "" : ":" + this.role.appearanceMods[type]
}`;
}

setTempAppearance(type, appearance) {
if (appearance == "real") appearance = this.role.name;

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

this.tempAppearance[type] = appearance.split(":")[0];
}

sendMeeting(meeting) {
Expand Down
8 changes: 8 additions & 0 deletions Games/core/Role.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ module.exports = class Role {
self: "real",
reveal: "real",
};
this.appearanceMods = {
self: "real",
reveal: "real",
};
this.hideModifier = {};
this.oblivious = {};
this.actions = [];
Expand Down Expand Up @@ -151,6 +155,9 @@ module.exports = class Role {
for (let key in this.appearance) {
if (this.appearance[key] == "real") this.appearance[key] = this.name;
}
for (let key in this.appearanceMods) {
if (this.appearanceMods[key] == "real") this.appearanceMods[key] = this.modifier;
}

// Bind role to winCheck
this.winCheck.check = this.winCheck.check.bind(this);
Expand Down Expand Up @@ -196,6 +203,7 @@ module.exports = class Role {
// Configure temporary appearance reset
this.game.events.on("afterActions", () => {
this.tempAppearance = {};
this.tempAppearanceMods = {};
});
}

Expand Down
7 changes: 7 additions & 0 deletions Games/types/Mafia/Game.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const Game = require("../../core/Game");
const Utils = require("../../core/Utils");
const Player = require("./Player");
const Event = require("./Event");
const Queue = require("../../core/Queue");
Expand Down Expand Up @@ -382,6 +383,12 @@ module.exports = class MafiaGame extends Game {
return `${role}:${modifiers}`;
}

createInformation(infoType, ...args) {
const infoClass = Utils.importGameClass(this.type, "information", infoType);
const info = new infoClass(...args);
return info;
}

getRoleNightOrder() {
var roleName;
var nightActions = [];
Expand Down
63 changes: 63 additions & 0 deletions Games/types/Mafia/Information.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
module.exports = class MafiaInformation{
constructor(name, creator, game) {
this.name = name;
this.creator = creator;
this.game = game;
this.mainInfo = true;
}

processInfo(){
if(this.creator != null){
if(this.creator.hasEffect("TrueMode")){
if(!this.isTrue()){
this.makeTrue();
}
}
else if(this.creator.hasEffect("FalseMode")){
if(!this.isFalse()){
this.makeFalse();
}
}
else if(this.creator.hasEffect("UnfavorableMode")){
if(!this.isUnfavorable()){
this.makeUnfavorable();
}
}
else if(this.creator.hasEffect("FavorableMode")){
if(!this.isFavorable()){
this.makeFavorable();
}
}
}
}

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

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

isTrue() {
return true;
}
isFalse() {
return false;
}
isFavorable(){
return false;
}
isUnfavorable(){
return true;
}

makeTrue() {
}
makeFalse() {
}
makeFavorable(){
}
makeUnfavorable(){
}
};
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;
}
};
108 changes: 108 additions & 0 deletions Games/types/Mafia/information/AlignmentInfo.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 AlignmentInfo extends Information{
constructor(creator, game, target) {
super("Alignment Info", creator, game);
if(target == null){
this.randomTarget = true;
target = Random.randArrayVal(this.game.alivePlayers());
}
this.target = target;
let role = this.target.getAppearance("investigate", true);
let trueRole = this.target.getAppearance("real", true);
if(role = trueRole){
this.mainInfo = this.target.faction;
}
else{
this.mainInfo = game.getRoleAlignment(role);
}
}

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

getInfoFormated(){
super.getInfoRaw();
if(this.randomTarget == true){
return `You Learn that your ${this.target.name}'s Alignment is ${this.mainInfo}`
}
return `You Learn that your Target's Alignment is ${this.mainInfo}`
}

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

makeTrue() {
this.mainInfo = this.target.faction;
}
makeFalse() {
if(EVIL_FACTIONS.includes(this.target.faction) || (this.target.faction == "Independent" && this.game.getRoleTags(this.target.role.name).includes("Hostile"))){
this.mainInfo = "Village";
}
else{
for(let player of this.game.players){
if(EVIL_FACTIONS.includes(player) && player.faction != this.target.faction){
this.mainInfo = player.faction;
}
}
}
}
makeFavorable(){
this.mainInfo = this.creator.faction;
}
makeUnfavorable(){
if(EVIL_FACTIONS.includes(this.creator.faction) || (this.creator.faction == "Independent" && this.game.getRoleTags(this.creator.role.name).includes("Hostile"))){
this.mainInfo = "Village";
}
else{
for(let player of this.game.players){
if(EVIL_FACTIONS.includes(player) && player.faction != this.creator.faction){
this.mainInfo = player.faction;
}
}
}
}
};
Loading

0 comments on commit a3bae02

Please sign in to comment.