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

Add Mafia search capability #10467

Open
wants to merge 27 commits into
base: master
Choose a base branch
from

Conversation

Lucas-Meijer
Copy link
Contributor

@Lucas-Meijer Lucas-Meijer commented Aug 2, 2024

Overhauls the 'mafia listdata' command, to instead show data in a neater way. Allows for the user to search within the various Mafia data categories, and also generate random data, like the 'ds' command.

Collaboration with @Alexander489

Copy link
Member

@HoeenCoder HoeenCoder left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I'm not done with this review yet but I need to go deal with other things and there appears to be some fundamental design issues here since you just stuck [key: string]: any on MafiaData, lets figure out how we want to deal with that before anything else.

Comment on lines 349 to 350
this.hostid = toID("");
this.host = "";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
this.hostid = toID("");
this.host = "";

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your setting these values below, why set them to empty strings here?


this.hostid = host.id;
this.host = Utils.escapeHTML(host.name);
this.host = Utils.escapeHTML(host.name) && '';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
this.host = Utils.escapeHTML(host.name) && '';
this.host = Utils.escapeHTML(host.name);

&& ''; will mean this always returns '', you probably meant || ''; to say "use the HTML escaped host name or an empty string as a default". However, that isn't needed, if you look at the definition for escapeHTML, you can see that it always returns a string (even an empty one if needed).

Comment on lines 1899 to 1909
hostPregame() {

}

hostDay() {

}

hostNight() {

}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we have three empty methods?

@@ -1,6 +1,7 @@
import {Utils, FS} from '../../lib';

interface MafiaData {
[key: string]: any;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This typing says "you can put anything in a MafiaData object at all! We have no idea whats in here as a result" and thats bad. Is there a more specific typing you could be using? Why do we need this typing?

Comment on lines 167 to 176
if (!MafiaData.themes.nominations) {
MafiaData.themes.nominations = {
name: `Nominations`,
desc: `Every odd night, the Mafia select three players. The next day, you can only vote for one of these three players.`,
7: `Mafia Goon, Mafia Goon, Villager, Villager, Villager, Villager, Villager`,
11: `Mafia Goon, Mafia Goon, Mafia Goon, Villager, Villager, Villager, Villager, Villager, Villager, Villager, Villager`,
15: `Mafia Goon, Mafia Goon, Mafia Goon, Mafia Goon, Villager, Villager, Villager, Villager, Villager, Villager, Villager, Villager, Villager, Villager, Villager`,
19: `Mafia Goon, Mafia Goon, Mafia Goon, Mafia Goon, Mafia Goon, Villager, Villager, Villager, Villager, Villager, Villager, Villager, Villager, Villager, Villager, Villager, Villager, Villager, Villager`,
};
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why does nommy need to be hardcoded here, isn't theme data usually just located in the appropriate JSON file?

@@ -3988,7 +4018,7 @@ export const commands: Chat.ChatCommands = {
let foundTarget = false;
for (const entry of ['alignments', 'roles', 'themes', 'IDEAs', 'terms'] as (keyof MafiaData)[]) {
const dataEntry = MafiaData[entry];
if (from in dataEntry) return this.errorReply(`${from} is already a ${entry.slice(0, -1)}`);
if (from in dataEntry) return this.errorReply(`${from} is already a ${entry.toString().slice(0, -1)}`);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

entry should already implicitly defined as a string, this extra method call isn't needed.

If its not its likely a problem caused by introducing [key: string]: any as a type on MafiaData.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants