Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 3 additions & 3 deletions src/classes/Handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import consola from "consola";
* used by the screens of the game
*/
class Handler {
private dataframe: TrialData;
private dataframe: Dataframe;
public callback: () => void;

/**
Expand All @@ -32,7 +32,7 @@ class Handler {
* @param {function} callback default callback after the handlers
* @constructor
*/
constructor(dataframe: TrialData, callback: () => void) {
constructor(dataframe: Dataframe, callback: () => void) {
this.dataframe = dataframe;
this.callback = callback;
}
Expand All @@ -41,7 +41,7 @@ class Handler {
* Get the dataframe being modified
* @return {Data}
*/
public getDataframe(): TrialData {
public getDataframe(): Dataframe {
return this.dataframe;
}

Expand Down
44 changes: 22 additions & 22 deletions src/classes/factories/ScreenPropFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,18 @@ import Handler from "src/classes/Handler";
*/
class ScreenPropFactory implements Factory {
// jsPsych trial data
private trial: Trial;
private trial: IntentionsNode;

// Callback function from 'Handler' class
private handler: Handler;

/**
* Default constructor
* @param {Trial} trial jsPsych trial data
* @param {IntentionsNode} trial jsPsych trial data
* @param {Handler} handler callback function from 'Handler' class
* @constructor
*/
constructor(trial: Trial, handler: Handler) {
constructor(trial: IntentionsNode, handler: Handler) {
this.trial = trial;
this.handler = handler;
}
Expand Down Expand Up @@ -82,7 +82,7 @@ class ScreenPropFactory implements Factory {
case "playerChoice2": {
// Setup the props
returned.props = {
trial: this.trial.trial,
trial_number: this.trial.trial_number,
display: this.trial.display,
isPractice: this.trial.isPractice,
spotlight: this.trial.spotlight,
Expand Down Expand Up @@ -112,7 +112,7 @@ class ScreenPropFactory implements Factory {

// Setup the props
returned.props = {
trial: this.trial.trial,
trial_number: this.trial.trial_number,
display: this.trial.display,
state: this.trial.state,
handler: this.handler.callback.bind(this.handler),
Expand All @@ -125,7 +125,7 @@ class ScreenPropFactory implements Factory {

// Setup the props
returned.props = {
trial: this.trial.trial,
trial_number: this.trial.trial_number,
display: this.trial.display,
state: this.trial.state,
};
Expand All @@ -135,7 +135,7 @@ class ScreenPropFactory implements Factory {
case "statusPreview":
// Setup the props
returned.props = {
trial: this.trial.trial,
trial_number: this.trial.trial_number,
display: this.trial.display,
isPartnerHighStatus: this.trial.isPartnerHighStatus,
handler: this.handler.callback.bind(this.handler),
Expand All @@ -159,7 +159,7 @@ class ScreenPropFactory implements Factory {

// Setup the props
returned.props = {
trial: this.trial.trial,
trial_number: this.trial.trial_number,
display: this.trial.display,
state: this.trial.state || "default", // Default to "default" type if not specified
runComputeSetup: this.trial.runComputeSetup,
Expand All @@ -172,7 +172,7 @@ class ScreenPropFactory implements Factory {
case "selection":
// Setup the props
returned.props = {
trial: this.trial.trial,
trial_number: this.trial.trial_number,
display: this.trial.display,
handler: this.handler.selection.bind(this.handler),
};
Expand All @@ -182,7 +182,7 @@ class ScreenPropFactory implements Factory {
case "inference":
// Setup the props
returned.props = {
trial: this.trial.trial,
trial_number: this.trial.trial_number,
display: this.trial.display,
handler: this.handler.inference.bind(this.handler),
};
Expand All @@ -192,7 +192,7 @@ class ScreenPropFactory implements Factory {
case "agency":
// Setup the props
returned.props = {
trial: this.trial.trial,
trial_number: this.trial.trial_number,
display: this.trial.display,
handler: this.handler.agency.bind(this.handler),
};
Expand All @@ -202,7 +202,7 @@ class ScreenPropFactory implements Factory {
case "classification":
// Setup the props
returned.props = {
trial: this.trial.trial,
trial_number: this.trial.trial_number,
display: this.trial.display,
handler: this.handler.classification.bind(this.handler),
};
Expand All @@ -212,7 +212,7 @@ class ScreenPropFactory implements Factory {
case "status":
// Setup the props
returned.props = {
trial: this.trial.trial,
trial_number: this.trial.trial_number,
display: this.trial.display,
handler: this.handler.status.bind(this.handler),
};
Expand All @@ -222,7 +222,7 @@ class ScreenPropFactory implements Factory {
case "dass":
// Setup the props
returned.props = {
trial: this.trial.trial,
trial_number: this.trial.trial_number,
display: this.trial.display,
version: Configuration.manipulations.useAdultQuestionnaires ? "adult" : "adolescent",
handler: this.handler.dass.bind(this.handler),
Expand All @@ -233,7 +233,7 @@ class ScreenPropFactory implements Factory {
case "screentime":
// Setup the props
returned.props = {
trial: this.trial.trial,
trial_number: this.trial.trial_number,
display: this.trial.display,
handler: this.handler.screentime.bind(this.handler),
};
Expand All @@ -243,7 +243,7 @@ class ScreenPropFactory implements Factory {
case "demographics":
// Setup the props
returned.props = {
trial: this.trial.trial,
trial_number: this.trial.trial_number,
display: this.trial.display,
version: Configuration.manipulations.useAdultQuestionnaires ? "adult" : "adolescent",
handler: this.handler.demographics.bind(this.handler),
Expand All @@ -254,7 +254,7 @@ class ScreenPropFactory implements Factory {
case "summary":
// Setup the props
returned.props = {
trial: this.trial.trial,
trial_number: this.trial.trial_number,
display: this.trial.display,
postPhase: postPhase,
handler: this.handler.callback.bind(this.handler),
Expand All @@ -271,15 +271,15 @@ class ScreenPropFactory implements Factory {

// Setup the props
returned.props = {
trial: this.trial.trial,
trial_number: this.trial.trial_number,
display: this.trial.display,
};
break;

// Waiting screen
case "waiting":
returned.props = {
trial: this.trial.trial,
trial_number: this.trial.trial_number,
display: this.trial.display,
mode: this.trial.mode,
handler: this.handler.callback.bind(this.handler),
Expand All @@ -289,7 +289,7 @@ class ScreenPropFactory implements Factory {
// Cyberball screen
case "cyberball":
returned.props = {
trial: this.trial.trial,
trial_number: this.trial.trial_number,
display: this.trial.display,
isInclusive: this.trial.isInclusive,
partnerHighStatus: this.trial.partnerHighStatus,
Expand All @@ -301,9 +301,9 @@ class ScreenPropFactory implements Factory {
// Resources screen
case "resources":
returned.props = {
trial: this.trial.trial,
trial_number: this.trial.trial_number,
display: this.trial.display,
callback: this.handler.callback.bind(this.handler),
handler: this.handler.callback.bind(this.handler),
};
break;

Expand Down
6 changes: 3 additions & 3 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -943,7 +943,7 @@ for (let i = 0; i < dataCollection.length; i++) {
const stageOneTrials = shuffle(randomisedTrials.phaseOne);
let stageOneCounter = 1;
for (const trial of stageOneTrials) {
trial.trial = stageOneCounter;
trial.trial_number = stageOneCounter;
stageOneCounter++;
}

Expand Down Expand Up @@ -1286,7 +1286,7 @@ for (let i = 0; i < dataCollection.length; i++) {
const stageTwoTrials = shuffle(randomisedTrials.phaseTwo);
let stageTwoCounter = 1;
for (const trial of stageTwoTrials) {
trial["trial"] = stageTwoCounter;
trial.trial_number = stageTwoCounter;
stageTwoCounter++;
}

Expand Down Expand Up @@ -1541,7 +1541,7 @@ for (let i = 0; i < dataCollection.length; i++) {
const stageThreeTrials = shuffle(randomisedTrials.phaseThree);
let stageThreeCounter = 1;
for (const trial of stageThreeTrials) {
trial["trial"] = stageThreeCounter;
trial.trial_number = stageThreeCounter;
stageThreeCounter++;
}

Expand Down
8 changes: 4 additions & 4 deletions src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import { saveToLocalStorage, setCompleted } from "./util";
jsPsych.plugins[Configuration.studyName] = (() => {
const plugin = {
info: {},
trial: (_displayElement: HTMLElement, _trial: Trial) => {
trial: (_displayElement: HTMLElement, _trial: IntentionsNode) => {
// Should raise an error
consola.error(`Not implemented.`);
},
Expand Down Expand Up @@ -116,14 +116,14 @@ jsPsych.plugins[Configuration.studyName] = (() => {
},
};

plugin.trial = (displayElement: HTMLElement, trial: Trial) => {
plugin.trial = (displayElement: HTMLElement, trial: IntentionsNode) => {
// Get the global 'Experiment' instance
const experiment = window.Experiment;

// Setup the trial data to be stored
const dataframe: TrialData = {
const dataframe: Dataframe = {
// Trial identification
trial: trial.trial,
trial_number: trial.trial_number,
display: trial.display,
participantID: experiment.getState().get("participantID"),

Expand Down
6 changes: 3 additions & 3 deletions src/view/components/Card/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ import { Money } from "grommet-icons";

/**
* @summary Generate a 'Card' component that displays player information including name, avatar and points
* @param {Props.Components.Card} props component props containing:
* @param {Components.Card} props component props containing:
* - name: {string} Display name for the player
* - avatar: {string} Unique identifier for the avatar
* - points: {string} Current points total
* - gridArea: {string} Grid area name for positioning
* @return {ReactElement} 'Card' component with player info arranged vertically in a Box
*/
const Card: FC<Props.Components.Card> = (
props: Props.Components.Card
const Card: FC<Components.Card> = (
props: Components.Card
): ReactElement => {
return (
<Box
Expand Down
6 changes: 3 additions & 3 deletions src/view/components/Character/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ import { Configuration } from "src/configuration";
* Renders a clickable avatar that can be selected/deselected by the participant.
* The component uses CSS classes to provide visual feedback for the selection state.
*
* @param {Props.Components.Character} props - Component properties
* @param {Components.Character} props - Component properties
* @param {string} props.name - Unique identifier for the avatar
* @param {number} props.size - Size in pixels for the avatar
* @param {string | null} props.state - Currently selected avatar name
* @param {(name: string) => void} props.setState - Function to update selected avatar
* @returns {ReactElement} Clickable avatar component with selection state handling
*/
const Character: FC<Props.Components.Character> = (
props: Props.Components.Character
const Character: FC<Components.Character> = (
props: Components.Character
): ReactElement => {
return (
<Box
Expand Down
6 changes: 3 additions & 3 deletions src/view/components/Option/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ import { Grid, Heading } from "grommet";

/**
* @summary Generate an 'Option' component that displays a grid of points to split between participant and partner
* @param {Props.Components.Option} props component props containing:
* @param {Components.Option} props component props containing:
* - optionKey: {string} Unique identifier for the option
* - pointsParticipant: {number} Points allocated to the participant
* - pointsPartner: {number} Points allocated to the partner
* @return {ReactElement} 'Option' component with points arranged in a 2x2 grid
*/
const Option: FC<Props.Components.Option> = (
props: Props.Components.Option
const Option: FC<Components.Option> = (
props: Components.Option
): ReactElement => {
return (
<Grid
Expand Down
6 changes: 3 additions & 3 deletions src/view/components/Slider/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { Box, Heading, RangeInput } from "grommet";

/**
* @summary Generate a 'Slider' component that displays a horizontal range input with labels
* @param {Props.Components.Slider} props component props containing:
* @param {Components.Slider} props component props containing:
* - min: {number} Minimum value for the slider
* - max: {number} Maximum value for the slider
* - value: {number} Current value of the slider
Expand All @@ -29,8 +29,8 @@ import { Box, Heading, RangeInput } from "grommet";
* - setValue?: {(value: number) => void} Optional callback to update value externally
* @return {ReactElement} 'Slider' component with a labeled range input
*/
const Slider: FC<Props.Components.Slider> = (
props: Props.Components.Slider
const Slider: FC<Components.Slider> = (
props: Components.Slider
): ReactElement => {
// Value presented by the slide
const [value, setValue] = useState(props.max / 2);
Expand Down
6 changes: 3 additions & 3 deletions src/view/components/Status/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ import { Configuration } from "src/configuration";

/**
* @summary Generate a 'Status' component that displays social status positions
* @param {Props.Components.Status} props component props containing:
* @param {Components.Status} props component props containing:
* - participantStatus: {number} Social status value for participant (0-100)
* - partnerStatus: {number} Social status value for partner (0-100)
* @return {ReactElement} 'Status' component with horizontal scale and avatar indicators
*/
const Status: FC<Props.Components.Status> = (
props: Props.Components.Status
const Status: FC<Components.Status> = (
props: Components.Status
): ReactElement => {
const [participantStatus] = useState(props.participantStatus);
const [partnerStatus] = useState(props.partnerStatus);
Expand Down
Loading