package com.rs.game.player.dialogues.impl;

import com.rs.game.item.Item;
import com.rs.game.player.dialogues.Dialogue;

public class RecolorItemD extends Dialogue {

	private Item item;;

	@Override
	public void start() {
		stage = 1;
		item = (Item) this.parameters[0];
		switch (item.getId()) {
		case 2581:
			sendOptionsDialogue(DEFAULT_OPTIONS_TITLE,
					"Recolor to red - 2500 Warband points.",
					"Recolor to blue - 2500 Warband points.",
					"Recolor to white - 2500 Warband points.",
					"Recolor to yellow - 2500 Warband points.", "Nevermind.");
			break;
		case 9470:
		case 15486:
			sendOptionsDialogue(DEFAULT_OPTIONS_TITLE,
					"Recolor to red - 2500 Warband points.",
					"Recolor to yellow - 2500 Warband points.",
					"Recolor to blue - 2500 Warband points.",
					"Recolor to green - 2500 Warband points.", "Nevermind.");
			break;
		case 2577:
			sendOptionsDialogue(DEFAULT_OPTIONS_TITLE,
				"Recolor to Red - 2500 Warband points.",
				"Recolor to Blue - 2500 Warband points.",
				"Recolor to White - 2500 Warband points.",
				"Recolor to Yellow - 2500 Warband points.", "Nevermind.");
		break;
		case 6583:
			sendOptionsDialogue(DEFAULT_OPTIONS_TITLE,
					"Recolor to Red - 2500 Warband points.",
					"Recolor to Blue - 2500 Warband points.",
					"Recolor to Green - 2500 Warband points.",
					"Recolor to Yellow - 2500 Warband points.", "Nevermind.");
			break;
		case 9096:
		case 9097:
		case 9098:
		case 9099:
		case 9100:
		case 9101:
			sendOptionsDialogue(DEFAULT_OPTIONS_TITLE,
					"Recolor to Red - 2500 Warband points.",
					"Recolor to Green - 2500 Warband points.",
					"Recolor to Blue - 2500 Warband points.",
					"Recolor to Yellow - 2500 Warband points.", "Nevermind.");
			break;
		}
	}

	@Override
	public void run(int interfaceId, int componentId) {
		switch (stage) {
		case -1:
			end();
			break;
		case 1:
			switch (componentId) {
			case OPTION_1:
			case OPTION_2:
			case OPTION_3:
			case OPTION_4:
				if (player.getWarbandPoints() >= 2500) {
					stage = -1;
					player.setWarbandPoints(player.getWarbandPoints() - 2500);
					sendNPCDialogue(13727, HAPPY, "There you go.");
					transformItem(componentId);
				} else {
					stage = -1;
					sendDialogue("You need 2500 Warband Points to recolor this item.");
				}
				break;
			case OPTION_5:
				end();
				break;
			}
			break;
		}
	}

	private void transformItem(int colorId) {
		switch (item.getId()) {
		case 2577:
			if (player.getInventory().containsItem(2577, 1)) {
				player.getInventory().deleteItem(2577, 1);
				switch (colorId) {
				case 3:
					player.getInventory().addItem(22552, 1);
					break;
				case 4:
					player.getInventory().addItem(22554, 1);
					break;
				case 5:
					player.getInventory().addItem(22556, 1);
					break;
				case 6:
					player.getInventory().addItem(22558, 1);
					break;
				}
			} else {
				stage = -1;
				sendDialogue("You don't have that item in your inventory.");
			}
			break;
		case 6583:
			if (player.getInventory().containsItem(6583, 1)) {
				player.getInventory().deleteItem(6583, 1);
				switch (colorId) {
				case 3:
					player.getInventory().addItem(22560, 1);
					break;
				case 4:
					player.getInventory().addItem(22562, 1);
					break;
				case 5:
					player.getInventory().addItem(22564, 1);
					break;
				case 6:
					player.getInventory().addItem(22566, 1);
					break;
				}
			} else {
				stage = -1;
				sendDialogue("You don't have that item in your inventory.");
			}
			break;
		case 9096:
			if (player.getInventory().containsItem(9096, 1)) {
				player.getInventory().deleteItem(9096, 1);
				switch (colorId) {
				case 3:
					player.getInventory().addItem(22219, 1);
					break;
				case 4:
					player.getInventory().addItem(22231, 1);
					break;
				case 5:
					player.getInventory().addItem(22243, 1);
					break;
				case 6:
					player.getInventory().addItem(22255, 1);
					break;
				}
			} else {
				stage = -1;
				sendDialogue("You don't have that item in your inventory.");
			}
			break;
		case 9097:
			if (player.getInventory().containsItem(9097, 1)) {
				player.getInventory().deleteItem(9097, 1);
				switch (colorId) {
				case 3:
					player.getInventory().addItem(22221, 1);
					break;
				case 4:
					player.getInventory().addItem(22233, 1);
					break;
				case 5:
					player.getInventory().addItem(22245, 1);
					break;
				case 6:
					player.getInventory().addItem(22257, 1);
					break;
				}
			} else {
				stage = -1;
				sendDialogue("You don't have that item in your inventory.");
			}
			break;
		case 9098:
			if (player.getInventory().containsItem(9098, 1)) {
				player.getInventory().deleteItem(9098, 1);
				switch (colorId) {
				case 3:
					player.getInventory().addItem(22223, 1);
					break;
				case 4:
					player.getInventory().addItem(22235, 1);
					break;
				case 5:
					player.getInventory().addItem(22247, 1);
					break;
				case 6:
					player.getInventory().addItem(22259, 1);
					break;
				}
			} else {
				stage = -1;
				sendDialogue("You don't have that item in your inventory.");
			}
			break;
		case 9099:
			if (player.getInventory().containsItem(9099, 1)) {
				player.getInventory().deleteItem(9099, 1);
				switch (colorId) {
				case 3:
					player.getInventory().addItem(22225, 1);
					break;
				case 4:
					player.getInventory().addItem(22237, 1);
					break;
				case 5:
					player.getInventory().addItem(22249, 1);
					break;
				case 6:
					player.getInventory().addItem(22261, 1);
					break;
				}
			} else {
				stage = -1;
				sendDialogue("You don't have that item in your inventory.");
			}
			break;
		case 9100:
			if (player.getInventory().containsItem(9100, 1)) {
				player.getInventory().deleteItem(9100, 1);
				switch (colorId) {
				case 3:
					player.getInventory().addItem(22227, 1);
					break;
				case 4:
					player.getInventory().addItem(22239, 1);
					break;
				case 5:
					player.getInventory().addItem(22251, 1);
					break;
				case 6:
					player.getInventory().addItem(22263, 1);
					break;
				}
			} else {
				stage = -1;
				sendDialogue("You don't have that item in your inventory.");
			}
			break;
		case 9101:
			if (player.getInventory().containsItem(9101, 1)) {
				player.getInventory().deleteItem(9101, 1);
				switch (colorId) {
				case 3:
					player.getInventory().addItem(22229, 1);
					break;
				case 4:
					player.getInventory().addItem(22241, 1);
					break;
				case 5:
					player.getInventory().addItem(22253, 1);
					break;
				case 6:
					player.getInventory().addItem(22265, 1);
					break;
				}
			} else {
				stage = -1;
				sendDialogue("You don't have that item in your inventory.");
			}
			break;
		case 2581:
			if (player.getInventory().containsItem(2581, 1)) {
				player.getInventory().deleteItem(2581, 1);
				switch (colorId) {
				case 3:
					player.getInventory().addItem(20949, 1);
					break;
				case 4:
					player.getInventory().addItem(20951, 1);
					break;
				case 5:
					player.getInventory().addItem(20952, 1);
					break;
				case 6:
					player.getInventory().addItem(20950, 1);
					break;
				}
			} else {
				stage = -1;
				sendDialogue("You don't have that item in your inventory.");
			}
			break;
		case 9470:
			if (player.getInventory().containsItem(9470, 1)) {
				player.getInventory().deleteItem(9470, 1);
				switch (colorId) {
				case 3:
					player.getInventory().addItem(22215, 1);
					break;
				case 4:
					player.getInventory().addItem(22216, 1);
					break;
				case 5:
					player.getInventory().addItem(22217, 1);
					break;
				case 6:
					player.getInventory().addItem(22218, 1);
					break;
				}
			} else {
				stage = -1;
				sendDialogue("You don't have that item in your inventory.");
			}
			break;
		case 15486:
			if (player.getInventory().containsItem(15486, 1)) {
				player.getInventory().deleteItem(15486, 1);
				switch (colorId) {
				case 3:
					player.getInventory().addItem(22207, 1);
					break;
				case 4:
					player.getInventory().addItem(22209, 1);
					break;
				case 5:
					player.getInventory().addItem(22211, 1);
					break;
				case 6:
					player.getInventory().addItem(22213, 1);
					break;
				}
			} else {
				stage = -1;
				sendDialogue("You don't have that item in your inventory.");
			}
			break;
		}
	}

	@Override
	public void finish() {

	}
}
