'use strict';

const fs = require('fs');
const path = require('path');

function loadSvg(name) {
  return fs.readFileSync(path.join(__dirname, 'cat', 'frames', `${name}.svg`), 'utf8');
}

function frame(name) {
  return {
    name,
    svg: loadSvg(name)
  };
}

module.exports = {
  width: 48,
  height: 32,
  clips: {
    idle: {
      fps: 3,
      frames: [
        frame('idle-1'),
        frame('idle-2'),
        frame('idle-3')
      ]
    },
    walk: {
      fps: 10,
      frames: [
        frame('walk-1'),
        frame('walk-2'),
        frame('walk-3'),
        frame('walk-4')
      ]
    },
    inspect: {
      fps: 5,
      frames: [
        frame('inspect-1'),
        frame('inspect-2'),
        frame('inspect-3')
      ]
    },
    chase: {
      fps: 12,
      frames: [
        frame('chase-1'),
        frame('chase-2'),
        frame('chase-3'),
        frame('chase-4')
      ]
    },
    sleep: {
      fps: 2,
      frames: [
        frame('sleep-1'),
        frame('sleep-2')
      ]
    },
    transitionIdleWalk: {
      fps: 10,
      frames: [
        frame('transition-idle-walk-1'),
        frame('transition-idle-walk-2'),
        frame('transition-idle-walk-3')
      ],
      nextClip: 'walk'
    },
    transitionWalkSleep: {
      fps: 9,
      frames: [
        frame('transition-walk-sleep-1'),
        frame('transition-walk-sleep-2'),
        frame('transition-walk-sleep-3')
      ],
      nextClip: 'sleep'
    },
    transitionSleepIdle: {
      fps: 8,
      frames: [
        frame('transition-sleep-idle-1'),
        frame('transition-sleep-idle-2'),
        frame('transition-sleep-idle-3')
      ],
      nextClip: 'idle'
    }
  },
  transitions: {
    'idle->walk': 'transitionIdleWalk',
    'inspect->walk': 'transitionIdleWalk',
    'walk->sleep': 'transitionWalkSleep',
    'chase->sleep': 'transitionWalkSleep',
    'sleep->idle': 'transitionSleepIdle',
    'sleep->walk': 'transitionSleepIdle',
    'sleep->inspect': 'transitionSleepIdle'
  }
};
