package com.rs.game.player.content;

import java.util.HashMap;
import java.util.Map;
import java.util.TimerTask;
import java.util.concurrent.TimeUnit;

import com.rs.cache.loaders.ItemDefinitions;
import com.rs.game.Animation;
import com.rs.game.Graphics;
import com.rs.game.item.Item;
import com.rs.game.player.Player;
import com.rs.game.player.Skills;
import com.rs.game.tasks.WorldTask;
import com.rs.game.tasks.WorldTasksManager;
import com.rs.utils.Utils;
import com.rs.utils.Logger;

public class GildedAltar {

	public enum bonestoOffer {

		NORMAL(526, 200),

		NORMAL2(2530, 200),

		NORMAL3(3187, 200),

		NORMAL4(14638, 200),

		NORMAL5(14693, 200),

		NORMAL6(17670, 200),

		ROCK_CRAB_CARCASS(15188, 300),

		BURNT(528, 200),

		WOLF(2859, 200),

		MONKEY(3183, 225),

		MONKEY2(3179, 225),

		MONKEY3(3181, 225),

		MONKEY4(3185, 225),

		BAT(530, 225),

		BAT2(17672, 225),

		BIG(532, 300),

		BIG2(17674, 300),

		JOGRE(3125, 400),

		BJOGRE(3127, 400),

		PJOGRE(3128, 400),

		MJOGRE(3130, 400),

		ZOGRE(4812, 350),

		SHAIKAHAN(3123, 400),

		BABY(534, 450),

		TROLL_GENERAL(23031, 450),

		TROLL_LIEUTENANT(23032, 450),

		STRONG(11806, 450),

		REDEYES(11805, 450),

		MOSSCHIN(11804, 450),

		SNAILFEET(11803, 450),

		SNOTHEAD(11802, 450),

		WYVERN(6812, 500),

		LONG_BONE(10976, 600),

		CURVED_BONE(10977, 600),

		DRAGON(536, 600),

		DRAGON2(17676, 600),

		FAYRG(4830, 625),

		RAURG(4832, 650),

		DAGANNOTH(6729, 750),

		OURG(4834, 850),

		OURG2(14793, 850),

		ANCIENT(15410, 1300),

		FROST_DRAGON2(18832, 850),
		
		FROST_DRAGON(18830, 850);

		private int id;
		private double experience;

		private static Map<Integer, bonestoOffer> bones = new HashMap<Integer, bonestoOffer>();

		static {
			for (bonestoOffer bone : bonestoOffer.values()) {
				bones.put(bone.getId(), bone);
			}
		}

		public static bonestoOffer forId(int id) {
			return bones.get(id);
		}

		private bonestoOffer(int id, double experience) {
			this.id = id;
			this.experience = experience;
		}

		public int getId() {
			return id;
		}

		public double getExperience() {
			return experience;
		}

		public static boolean stopOfferGod = false;
		private static boolean imfuckingprayingfortheGods = false;
		
		public static void offerprayerGod(final Player player, Item item) {
			final int itemId = item.getId();
			final ItemDefinitions itemDef = new ItemDefinitions(item.getId());
			final bonestoOffer bone = bonestoOffer.forId(item.getId());
			WorldTasksManager.schedule(new WorldTask() {
				public void run() {
				try {
					if (!player.getInventory().containsItem(itemId, 1)) {
	                    stop();				
						return;
					}
					player.getPackets().sendGameMessage("The gods are very pleased with your offering.");
					player.setNextAnimation(new Animation(896));
					player.setNextGraphics(new Graphics(624));
					player.getInventory().deleteItem(new Item(itemId, 1));
					double xp = bone.getExperience() * player.getAuraManager().getPrayerMultiplier();
					player.getSkills().addXp(Skills.PRAYER, xp);
					player.getInventory().refresh();
				    } catch (Throwable e) {
					   Logger.handle(e);
				    }
				}
			}, 0, 3);
		}
	}
}