0
0
Fork 0

Make docstrings better. (resolves #77)

This commit is contained in:
Oliver-Akins 2021-02-28 18:23:26 -07:00
parent a3b3cfa71f
commit 3b797ca9d8
4 changed files with 82 additions and 75 deletions

View file

@ -25,55 +25,54 @@ export class Team {
get questions(): string[] { return this._questions; };
/**
* Adds the question(s) to the medium's hand
*
* @param questions The array of question text to add the medium's hand.
*/
public addCardsToHand(questions: string[]): void {
/**
* Adds the question(s) to the medium's hand
*
* @param questions -> The array of question text to add the medium's
* hand.
*/
this._hand.push(...questions);
};
/**
* Resets all the per-game data related to this team
*/
public reset(): void {
/**
* Resets all the per-game data related to this team
*/
this._hand = [];
this._questions = [];
this._answers = new Array<string>(8).fill(``);
}
/**
* Removes the given question from the medium's hand
*
* @param question The card text to remove from the hand.
*/
public removeCard(question: string) {
/**
* Removes the given question from the medium's hand
*
* @param question -> The card text to remove from the hand.
*/
this._hand = this._hand.filter(x => x != question);
};
/**
* Adds the given question to the history of the questions.
*
* @param question The question the spirit is answering
*/
public selectQuestion(question: string) {
/**
* Adds the given question to the history of the questions.
*
* @param question -> The question the spirit is answering
*/
this._questions.push(question);
};
/**
* Takes the value of an answer and modifies in the storage.
*
* @param answerIndex The value of the answer between 1 and 8 (inclusive)
* @param answer The new answer for that index
* @throws Error If the answerIndex is not in range
*/
public modifyAnswer(answerIndex: answer, answer: string) {
/**
* Takes the value of an answer and modifies in the storage.
*
* @param answerIndex -> The value of the answer between 1 and 8 (inclusive)
* @param answer -> The new answer for that index
* @throws Error -> If the answerIndex is not in range
*/
if (answerIndex > this._answers.length || answerIndex <= 0) {
throw new Error(`Cannot set answer at index ${answerIndex}.`)
};
@ -81,10 +80,10 @@ export class Team {
};
/**
* Converts the given object into a JSON representation of the data
*/
public toJSON(): datastoreTeam {
/**
* Converts the given object into a JSON representation of the data
*/
return {
questions: this._questions,
answers: this._answers,
@ -93,10 +92,10 @@ export class Team {
};
};
/**
* Converts a team JSON object back into a Team object.
*/
public static fromJSON(data: datastoreTeam): Team {
/**
* Converts a team JSON object back into a Team object.
*/
let t = new Team(data.id);
t._questions = data.questions;
t._answers = data.answers;