Home Reference Source

src/objects/LionAvatars.js

import {
    CharacterExpression,
    CharacterPosture,
} from '../utils/CharacterConstants';

/**
 * All variations of lion-helper, with id.
 * @type {Object[]}
 */
const lionAvatars = [
    {
        id: 0,
        description: 'Satisfied lion',
        posture: CharacterPosture.STANDING,
        expression: CharacterExpression.SATISFIED_HELP,
    },
    {
        id: 1,
        description: 'Happy lion, helping',
        posture: CharacterPosture.STANDING,
        expression: CharacterExpression.HAPPY_HELP,
    },
    {
        id: 2,
        description: 'Lion thumb up, helping',
        posture: CharacterPosture.STANDING,
        expression: CharacterExpression.THUMBUP_HELP,
    },
    {
        id: 3,
        description: 'Curious lion, helping',
        posture: CharacterPosture.STANDING,
        expression: CharacterExpression.CURIOUS_HELP,
    },
    {
        id: 4,
        description: 'Sitting lion, helping',
        posture: CharacterPosture.SITTING,
        expression: CharacterExpression.SITTING_HELP,
    },
    {
        id: 5,
        description: 'Laying lion',
        posture: CharacterPosture.LAYING,
        expression: CharacterExpression.RESTING_HELP,
    },
    {
        id: 6,
        description: 'Lion thumb up',
        posture: CharacterPosture.STANDING,
        expression: CharacterExpression.THUMP_UP,
    },
    {
        id: 7,
        description: 'Lion doubt, warning',
        posture: CharacterPosture.NONE,
        expression: CharacterExpression.DOUBT_WARNING,
    },
    {
        id: 8,
        description: 'Lion thumb up, confirmation',
        posture: CharacterPosture.NONE,
        expression: CharacterExpression.THUMP_UP,
    },
];

/**
 * Returns the avatar of the lion having the specified id.
 * @param {number} id
 * @returns {Object} Lion avatar with specified id.
 */
function findLionAvatarWithId(id) {
    return lionAvatars.find(a => a.id === id);
}

/**
 * Returns properties of the lion corresponding to the given help-object.
 * @param {Object} help - Help object
 * @returns {Object[]} Array containing the posture corresponding to the given parameter, and the image.
 *                     Returns null if the paramter is undefined.
 */
function getPropertiesWithHelp(help) {
    if (help !== undefined) {
        const helper = findLionAvatarWithId(help.helperId);
        const posture = helper.posture;
        const expression = helper.expression;
        return [posture, expression];
    } else return null;
}
export {getPropertiesWithHelp};