package de.siphalor.was.content.quest;

import de.siphalor.was.WhatAStorage;
import de.siphalor.was.content.product.Product;

import java.util.Random;

/**
 * An implementation of {@link QuestGenerator} that randomly spits out all kinds of quests with all kinds of products loaded.
 */
public class RandomQuestGenerator implements QuestGenerator {
	/**
	 * The internal random instance
	 */
	private static final Random RANDOM = new Random();

	/**
	 * Does nothing.
	 */
	@Override
	public void restart() {

	}

	/**
	 * This runs infinitely, so always <code>true</code>.
	 * @return <code>true</code>
	 */
	@Override
	public boolean hasMoreElements() {
		return true;
	}

	/**
	 * Gets the next quest.
	 * @return Another quest
	 */
	@Override
	public Quest nextElement() {
		Product product = WhatAStorage.getInstance().getProductManager().randomProduct(RANDOM);
		return new Quest(
				RANDOM.nextBoolean() ? Quest.Type.IN : Quest.Type.OUT,
				(RANDOM.nextInt(14) + 1) * 100 * product.getDepth(),
				product
		);
	}
}
