const utilities = require('./utilities');

const limited   = (limited) => limited ? ' | limited' : '';
const unique    = (unique) => unique ? ' | unique' : '';
const points    = (points) => (typeof points !== 'undefined' ? `${points}pt${points > 1 || points === 0 ? 's': ''}` : '');
const multiCard = (card) => `\n• *${card.name}* (${card.slot}) use \`/card ${card.name} (${card.slot})\` or \`/card #id ${utilities.cardId(card)}\``;
const effect    = (effect) => effect ? `\n> ${effect}` : '';

function cardReduce(currentString, card) {
	if(typeof currentString === 'object') {
		currentString = cardReduce('', currentString);
	}

	return currentString + multiCard(card);
}

const templates = {
	// Template for a single card
	card: (card) => `${card.name} (${card.slot}${limited(card.limited)}${unique(card.unique)}): ${points(card.points)}\n${card.text}${effect(card.effect)}`,

	// Template for multiple cards
	multiple: (cards, query) => {
		let cardString = cards.reduce(cardReduce);

		return `I found more than one card matching *'${query.text}'*:${cardString}`;
	},

	// Template for no results
	notFound: (query) => `Sorry i couldn't find a card for *'${query.text}'*`
};

module.exports = templates;

@@ -149,24 +149,153 @@
 ique' : '';%0A
+const cardIntro = (card) =%3E %60$%7Bcard.name%7D ($%7Bcard.slot%7D$%7Blimited(card.limited)%7D$%7Bunique(card.unique)%7D): $%7Bpoints(card.points)%7D%60;%0A
 const points
@@ -877,97 +877,18 @@
 card
-.name%7D ($%7Bcard.slot%7D$%7Blimited(card.limited)%7D$%7Bunique(card.unique)%7D): $%7Bpoints(card.points
+Intro(card
 )%7D%5Cn

Split out the card template funciton