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

Role Sharing Roles and Bug Fixes #1770

Merged
merged 35 commits into from
Nov 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
28ce265
Prettified Code!
SawJester Nov 22, 2024
9fbb0f1
Update FalseMode.js
SawJester Nov 22, 2024
df84c34
Create CannotRoleShare.js
SawJester Nov 22, 2024
81ed021
Create MustRoleShare.js
SawJester Nov 22, 2024
b492a1b
Update RoleShareAccept.js
SawJester Nov 22, 2024
1fc4364
Prettified Code!
SawJester Nov 22, 2024
8fb7251
Update RoleSharing.js
SawJester Nov 22, 2024
eeb8630
Prettified Code!
SawJester Nov 22, 2024
b613c83
Update ForceSplitDecision.js
SawJester Nov 22, 2024
ea3c0e2
Prettified Code!
SawJester Nov 22, 2024
6c8c0a4
Create MakeSkittishOnRoleShare.js
SawJester Nov 22, 2024
3568468
Prettified Code!
SawJester Nov 22, 2024
b92a37c
Create MakeShyOnRoleShare.js
SawJester Nov 22, 2024
d9becd4
Create MakeInsaneOnRoleShare.js
SawJester Nov 22, 2024
f3571b2
Update CleanseVisitors.js
SawJester Nov 22, 2024
3d1a23d
Update Action.js
SawJester Nov 22, 2024
a956935
Create CleanseOnRoleShare.js
SawJester Nov 22, 2024
8f122d9
Create ConvertOnRoleShare.js
SawJester Nov 22, 2024
17c1e98
Update Apothecary.js
SawJester Nov 22, 2024
15da8bf
Create Brute.js
SawJester Nov 22, 2024
80073b7
Create Recluse.js
SawJester Nov 22, 2024
39766f3
Create Dealer.js
SawJester Nov 22, 2024
613ee1f
Create Blackmailer.js
SawJester Nov 22, 2024
91142d4
Create Bully.js
SawJester Nov 22, 2024
da1a074
Update Doomsayer.js
SawJester Nov 22, 2024
8d6e815
Update Cthulhu.js
SawJester Nov 22, 2024
fee7e66
Update roles.js
SawJester Nov 22, 2024
aa7b6e5
Create CultureExchange.js
SawJester Nov 22, 2024
4b883c5
Update roles.js
SawJester Nov 23, 2024
5ed6f6f
Update Player.js
SawJester Nov 23, 2024
a9cf0bb
Update RoleSharing.js
SawJester Nov 23, 2024
1b64469
Update ConvertOnRoleShare.js
SawJester Nov 23, 2024
85d1bea
Prettified Code!
SawJester Nov 23, 2024
8cb32f6
Update ModifierLoud.js
SawJester Nov 25, 2024
7a2b5e0
Prettified Code!
SawJester Nov 25, 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
31 changes: 31 additions & 0 deletions Games/core/Player.js
Original file line number Diff line number Diff line change
Expand Up @@ -531,6 +531,37 @@ module.exports = class Player {
const modifiers = roleName.split(":")[1];
roleName = roleName.split(":")[0];

for (let effect of this.effects) {
if (effect.name == "Blind" && effect.lifespan == Infinity) {
effect.remove();
} else if (
effect.name == "Condemn Immune" &&
effect.lifespan == Infinity
) {
effect.remove();
} else if (
effect.name == "Convert Immune" &&
effect.lifespan == Infinity
) {
effect.remove();
} else if (effect.name == "Immortal" && effect.lifespan == Infinity) {
effect.remove();
} else if (effect.name == "Kill Immune" && effect.lifespan == Infinity) {
effect.remove();
} else if (
effect.name == "Leak Whispers" &&
effect.lifespan == Infinity
) {
effect.remove();
} else if (effect.name == "Save Immune" && effect.lifespan == Infinity) {
effect.remove();
} else if (effect.name == "Scrambled" && effect.lifespan == Infinity) {
effect.remove();
} else if (effect.name == "Tree" && effect.lifespan == Infinity) {
effect.remove();
}
}

if (!faction) {
this.faction = this.game.getRoleAlignment(roleName);

Expand Down
2 changes: 2 additions & 0 deletions Games/types/Mafia/Action.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ module.exports = class MafiaAction extends Action {
target.removeEffect("Gassed", true);
target.removeEffect("Lovesick", true);
target.removeEffect("Zombification", true);
target.removeEffect("CannotRoleShare", true);
target.removeEffect("MustRoleShare", true);
}

preventConvert(power, target) {
Expand Down
23 changes: 18 additions & 5 deletions Games/types/Mafia/Game.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,11 +160,24 @@ module.exports = class MafiaGame extends Game {
this.alivePlayers()[0].holdItem("EventManager", 1);
this.events.emit("ManageRandomEvents");
}
if(this.getStateName() == "Day" && (this.setup.RoleShare || this.setup.AlignmentShare || this.setup.PrivateShare || this.setup.PublicShare)){
for(let player of this.alivePlayers()){
if(player.items.filter((i) => i.name == "RoleSharing").length <= 0){
player.holdItem("RoleSharing", 1, this.setup.RoleShare, this.setup.AlignmentShare, this.setup.PrivateShare,this.setup.PublicShare);
}
if (
this.getStateName() == "Day" &&
(this.setup.RoleShare ||
this.setup.AlignmentShare ||
this.setup.PrivateShare ||
this.setup.PublicShare)
) {
for (let player of this.alivePlayers()) {
if (player.items.filter((i) => i.name == "RoleSharing").length <= 0) {
player.holdItem(
"RoleSharing",
1,
this.setup.RoleShare,
this.setup.AlignmentShare,
this.setup.PrivateShare,
this.setup.PublicShare
);
}
}
}
}
Expand Down
8 changes: 8 additions & 0 deletions Games/types/Mafia/effects/CannotRoleShare.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
const Effect = require("../Effect");

module.exports = class CannotRoleShare extends Effect {
constructor(lifespan) {
super("CannotRoleShare");
this.lifespan = lifespan || Infinity;
}
};
2 changes: 1 addition & 1 deletion Games/types/Mafia/effects/FalseMode.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const Effect = require("../Effect");

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

module.exports = class MustRoleShare extends Effect {
constructor(lifespan) {
super("MustRoleShare");
this.lifespan = lifespan || Infinity;
}
};
43 changes: 43 additions & 0 deletions Games/types/Mafia/events/CultureExchange.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
const Event = require("../Event");
const Action = require("../Action");
const Random = require("../../../../lib/Random");
const {
PRIORITY_ITEM_GIVER_DEFAULT,
PRIORITY_BECOME_DEAD_ROLE,
} = require("../const/Priority");

module.exports = class CultureExchange extends Event {
constructor(modifiers, game) {
super("Culture Exchange", modifiers, game);
}

getNormalRequirements() {
return true;
}

doEvent() {
super.doEvent();
let victim = Random.randArrayVal(this.game.alivePlayers());
let victim2 = Random.randArrayVal(
this.game.alivePlayers().filter((p) => p != victim)
);
this.action = new Action({
actor: victim2,
target: victim,
game: this.game,
priority: PRIORITY_ITEM_GIVER_DEFAULT,
labels: ["hidden", "absolute"],
run: function () {
if (this.game.SilentEvents != false) {
this.game.queueAlert(
`Event: Culture Exchange! 2 players wil gain the ability to role share today!`
);
}

this.target.holdItem("RoleSharing", 1, true, false, false, false);
this.actor.holdItem("RoleSharing", 1, true, false, false, false);
},
});
this.game.queueAction(this.action);
}
};
80 changes: 51 additions & 29 deletions Games/types/Mafia/items/RoleShareAccept.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,49 +9,71 @@ module.exports = class RoleShareAccept extends Item {
this.cannotBeStolen = true;
this.cannotBeSnooped = true;
let meetingName;
if(this.type == "Role Share"){
meetingName = "Role Share between " + accepter.name + " and " + this.proposer.name;
if (this.type == "Role Share") {
meetingName =
"Role Share between " + accepter.name + " and " + this.proposer.name;
} else {
meetingName =
"Alignment Share between " +
accepter.name +
" and " +
this.proposer.name;
}
else{
meetingName = "Alignment Share between " + accepter.name + " and " + this.proposer.name;

this.shareTypes = [];
if (accepter.hasEffect("CannotRoleShare")) {
this.shareTypes = ["No"];
} else if (accepter.hasEffect("MustRoleShare")) {
this.shareTypes = ["Yes"];
} else {
this.shareTypes = ["Yes", "No"];
}

this.meetings[meetingName] = {
states: ["Day"],
flags: ["voting", "instant"],
inputType: "boolean",
inputType: "custom",
targets: this.shareTypes,
action: {
labels: ["marriage"],
item: this,
run: function () {
if (this.target == "Yes") {
if(this.item.type == "Role Share"){
this.actor.role.revealToPlayer(this.item.proposer);
this.item.proposer.role.revealToPlayer(this.actor);
this.game.events.emit("ShareRole", this.actor, this.item.proposer, false);
}
else if(this.item.type == "Alignment Share"){
if (this.item.type == "Role Share") {
this.actor.role.revealToPlayer(this.item.proposer);
this.item.proposer.role.revealToPlayer(this.actor);
this.game.events.emit(
"ShareRole",
this.actor,
this.item.proposer,
false
);
} else if (this.item.type == "Alignment Share") {
var roleActor = this.actor.getAppearance("reveal", true);
var alignmentActor = this.game.getRoleAlignment(roleActor);
var roleProposer = this.item.proposer.getAppearance(
"reveal",
true
);
var alignmentProposer = this.game.getRoleAlignment(roleProposer);

var roleActor = this.actor.getAppearance("reveal", true);
var alignmentActor = this.game.getRoleAlignment(roleActor);
var roleProposer = this.item.proposer.getAppearance("reveal", true);
var alignmentProposer = this.game.getRoleAlignment(roleProposer);


this.actor.queueAlert(
`${this.item.proposer.name}'s Alignment is ${alignmentProposer}.`
);
this.item.proposer.queueAlert(
`${this.actor.name}'s Alignment is ${alignmentActor}.`
);
this.game.events.emit("ShareRole", this.actor, this.item.proposer, true);
this.actor.queueAlert(
`${this.item.proposer.name}'s Alignment is ${alignmentProposer}.`
);
this.item.proposer.queueAlert(
`${this.actor.name}'s Alignment is ${alignmentActor}.`
);
this.game.events.emit(
"ShareRole",
this.actor,
this.item.proposer,
true
);
}

}
else{
} else {
this.item.proposer.queueAlert(
`${this.actor.name} has declined to Share.`
);
`${this.actor.name} has declined to Share.`
);
}
this.item.drop();
},
Expand Down
Loading