ZURSULUS L2

A Game of Cards

ID
662
Название
A Game of Cards
start_npcs_json
[30845]
npc_ids_json
[30845]
constants_json
{"KLUMP":30845,"RED_GEM":8765,"EW_S":959,"EW_A":729,"EW_B":947,"EW_C":951,"EW_D":955,"EA_D":956,"ZIGGO_GEMSTONE":8868}
Статус разбора
metadata_only; dynamic Java conditions/rewards retained in source; unresolved starts: []
Источник
game/data/scripts/quests/Q00662_AGameOfCards/Q00662_AGameOfCards.java

NPC квеста

IDНазваниеСтарт квестаУровень
30845KlumpДа70

Условия уровней: выражения из Java

htmltext = (player.getLevel() < 61) ? "30845-02.htm" : "30845-01.htm";

Выдача предметов, адены и опыта: выражения из Java

giveItems(partyMember, RED_GEM, 1);
giveItems(player, item, count);
giveItems(player, item, 1);

Квесты содержат динамические условия Java. Выражения выдачи включают промежуточные предметы, варианты и случайные награды; это не гарантированная награда. Константы приведены выше. Полные условия — в исходнике.

Тексты квеста

[30845-01.htm] Warehouse Chief Klump: Are you here because you heard the rumor, too? These days, I spend a lot of my time playing cards with the travelers who pass this way. Naturally, there's plenty of reward for those who play a good game. Feel up to a game? Of course, since you stand to win a fair amount, you can't play for free. That's why it's a game of chance, eh? If you want to play with me, bring me some of those red gems that have recently caught my eye. What do you say? Will you bring me the gems so we can begin? Say yes. [30845-02.htm] Warehouse Chief Klump: Are you here because you heard the rumor, too? These days, I spend a lot of my time playing cards with the travelers who pass this way. Naturally, there's plenty of reward for those who play a good game. Feel up to a game? Of course, since you stand to win a fair amount, you can't play for free. That's why it's a game of chance, eh? If you want to play with me, bring me some of those red gems that have recently caught my eye. Ahh, but I think this task might be a little to much for you to take on right now. Perhaps another time, eh? (Only characters level 61 and above are permitted to take on this quest.) [30845-03.htm] Warehouse Chief Klump: Good! Then collect the Red Beads and bring them to me. There are many monsters from whom you can get get Red Beads, so listen carefully. You can get them by defeating the Tulben, Hames Orc Scout, Hames Orc Footman, Cursed Guardian, Hames Orc Overlord, Doom Scout, Dismal Pole, Doom Servant, Doom Archer, Doom Warrior, Bloody Queen, Trives, Falibati, Doom Knight, Ghostly Warrior, Bloody Priest, Bloody Knight, Dark Gaurd, Death Agent, Changed Creation, Chimera Piece, Nonexistent Man, Forgotten Ancient People, Shaman of Ancient Times, Antelope, Baffalo, Eye of Splendor, Wisdom of Splendor, Victory of Splendor, Signet of Splendor, Splinter Stakato, Splinter Stakato Soldier, Needle Stakato and Needle Stakato Soldier. To play one game of cards, bring 50 Red Beads. Good luck! [30845-04.htm] Warehouse Chief Klump: You haven't collected 50 Red Beads yet. You can get them by defeating the Tulben, Hames Orc Scout, Hames Orc Footman, Cursed Guardian, Hames Orc Overlord, Doom Scout, Dismal Pole, Doom Servant, Doom Archer, Doom Warrior, Bloody Queen, Trives, Falibati, Doom Knight, Ghostly Warrior,Bloody Priest, Bloody Knight, Dark Gaurd, Death Agent, Changed Creation, Chimera Piece, Nonexistent Man, Forgotten Ancient People, Shaman of Ancient Times, Antelope, Baffalo, Eye of Splendor, Wisdom of Splendor, Victory of Splendor, Signet of Splendor, Splinter Stakato, Splinter Stakato Soldier, Needle Stakato and Needle Stakato Soldier. "I'll come back later." "I think I'll quit." Listen to an explanation of the rules. Learn about the cards. [30845-05.htm] Warehouse Chief Klump: Hey, you've brought all 50 red gems. Terrific! What do say? Ready to play some cards? Play cards. Play next time. Listen to the explanation of the rules. Listen to the story about the cards. Ask about evil creatures that you can collect red gems from. [30845-06.htm] Warehouse Chief Klump: Okay, then. Once you collect all 50 red gems, come back. [30845-07.htm] Warehouse Chief Klump: Are you quitting? If you ever change your mind, come back any time. [30845-08.htm] Warehouse Chief Klump: Oh yeah? You're very cautious, I see. This game largely depends on luck, so I think it's a good idea to trust your intuition. When you feel like it, come back and challenge me again. [30845-09.htm] Warehouse Chief Klump: It's very simple. There are 70 cards, made up of 5 suits with 14 characters in each suit. You draw 5 cards from the lot, and if you get one of the combination of cards below, you can be rewarded. Five of a kind: Five cards containing the same character. Four of a kind: Four cards containing the same character. Full house: Three cards with the same character aLong with two cards with the same character. Three of a kind: Three cards with the same character. Two pairs: Two pairs of cards with the same characters in each pair. One pair: Two cards with the same character. If you don't have any of the hands I just mentioned, it's called having "no pair", and you don't get anything. Of course, a five of a kind is rare, so the reward for getting it is high; on the other hand, one pair is the easiest hand to get, so you'll receive only the lowest reward. Return. [30845-09a.htm] Warehouse Chief Klump: Actually, a fellow named Hindemith left these cards. Looks like they have some kind of message on them, but I have no idea what that means... I just use them to play cards... Ha ha ha! Return. [30845-09b.htm] Warehouse Chief Klump: You can obtain red gems from many evil creatures. Get them by slaying the Tulben, Hames Orc Scout, Hames Orc Footman, Cursed Guardian, Hames Orc Overlord, Doom Scout, Dismal Pole, Doom Servant, Doom Archer, Doom Warrior, Blood Queen, Trives, Falibati, Doom Knight, Ghostly Warrior, Bloody Priest, Bloody Knight, Dark Guard, Death Agent, Black Shadow, Chimera Piece, Nonexistent Man, Forgotten Ancient People, Shaman of Ancient Times, Antelope, Buffalo, Eye of Splendor, Wisdom of Splendor, Victory of Splendor, Signet of Splendor, Splinter Stakato, Splinter Stakato Soldier, Needle Stakato and Needle Stakato Soldier. To play the card game once, you'll need to bring me 50 red gems. Go back. [30845-10.htm] Warehouse Chief Klump: Good thinking! Just let me shuffle the cards... . . . Ah, there we go! Would you like to cut the deck? Cut the card deck. [30845-11.htm] Warehouse Chief Klump: Alrighty, time to play! Here are your 5 cards, face down. Check all 5 of your cards first, and then show them to me. ? ? ? ? ? Put the first card face up. Put the second card face up. Put the third card face up. Put the fourth card face up. Put the fifth card face up. [30845-11a.htm] Warehouse Chief Klump: Hey, I thought you were checking your cards! Where did you go? Your cards are untouched! Check all 5 of them and then show them to me. %Cell1% %Cell2% %Cell3% %Cell4% %Cell5% Put the first card face up. Put the second card face up. Put the third card face up. Put the fourth card face up. Put the fifth card face up. [30845-11b.htm] Warehouse Chief Klump: Huh? Where are the red gems? There were clearly more than 10 of them... Was I mistaken? [30845-12.htm] Warehouse Chief Klump: Check all 5 of your cards and then show them to me. %Cell1% %Cell2% %Cell3% %Cell4% %Cell5% Put the first card face up. Put the second card face up. Put the third card face up. Put the fourth card face up. Put the fifth card face up. [30845-13.htm] Warehouse Chief Klump: Did you have a look at your cards? Show them to me. %Cell1% %Cell2% %Cell3% %Cell4% %Cell5% Hmmmm....? This is... Five of a kind! What luck! The goddess of victory must be with you! Here is your prize! Well earned, well played! Play again. [30845-14.htm] Warehouse Chief Klump: Did you have a look at your cards? Show them to me. %Cell1% %Cell2% %Cell3% %Cell4% %Cell5% Hmmmm...? This is... Four of a kind! Well done, my young friend! That sort of hand doesn't come up very often, that's for sure. Here's your prize. Play again. [30845-15.htm] Warehouse Chief Klump: Did you have a look at your cards? Show them to me. %Cell1% %Cell2% %Cell3% %Cell4% %Cell5% Hmmmm...? This is... A full house? Excellent! You're better than I thought. Here's your prize. Play again. [30845-16.htm] Warehouse Chief Klump: Did you have a look at your cards? Show them to me. %Cell1% %Cell2% %Cell3% %Cell4% %Cell5% Hmmmm...? This is... Three of a kind? You're lucky, I'll say that for you! Here's your prize. Play again. [30845-17.htm] Warehouse Chief Klump: Did you have a look at your cards? Show them to me. %Cell1% %Cell2% %Cell3% %Cell4% %Cell5% Hmmmm...? This is... Two pair? Not bad. Here's your prize. Play again. [30845-18.htm] Warehouse Chief Klump: Did you have a look at your cards? Show them to me. %Cell1% %Cell2% %Cell3% %Cell4% %Cell5% Hmmmm...? This is... One pair? You got lucky this time, but I wonder if it'll last. Here's your prize. Play again. [30845-19.htm] Warehouse Chief Klump: Did you have a look at your cards? Show them to me. %Cell1% %Cell2% %Cell3% %Cell4% %Cell5% Hmmmm...? This is... No pair? Tough luck, my friend! Want to try again? Perhaps your luck will take a turn for the better... Play again. [30845-20.htm] Warehouse Chief Klump: How about another game? Just let me reshuffle these cards... . . . Ah, all set. Cut the deck, if you please. Cut the card deck. [30845-21.htm] Warehouse Chief Klump: Huh? Looks like you've run out of red gems. Too bad! Why don't you collect another 50 red gems and come back, eh?
Исходник условий и наград (Java)
/*
 * Copyright (c) 2013 L2jMobius
 * 
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 * 
 * The above copyright notice and this permission notice shall be
 * included in all copies or substantial portions of the Software.
 * 
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
 * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 */
package quests.Q00662_AGameOfCards;

import java.util.HashMap;
import java.util.Map;

import org.l2jmobius.gameserver.data.xml.ItemData;
import org.l2jmobius.gameserver.entity.actor.Npc;
import org.l2jmobius.gameserver.entity.actor.Player;
import org.l2jmobius.gameserver.entity.item.ItemTemplate;
import org.l2jmobius.gameserver.mechanics.script.Quest;
import org.l2jmobius.gameserver.mechanics.script.QuestSound;
import org.l2jmobius.gameserver.mechanics.script.QuestState;
import org.l2jmobius.gameserver.mechanics.script.State;

public class Q00662_AGameOfCards extends Quest
{
	// NPC
	private static final int KLUMP = 30845;
	
	// Quest Item
	private static final int RED_GEM = 8765;
	
	// Reward Items
	private static final int EW_S = 959;
	private static final int EW_A = 729;
	private static final int EW_B = 947;
	private static final int EW_C = 951;
	private static final int EW_D = 955;
	private static final int EA_D = 956;
	private static final int ZIGGO_GEMSTONE = 8868;
	
	// All cards
	private static final Map<Integer, String> CARDS = new HashMap<>();
	static
	{
		CARDS.put(0, "?");
		CARDS.put(1, "!");
		CARDS.put(2, "=");
		CARDS.put(3, "T");
		CARDS.put(4, "V");
		CARDS.put(5, "O");
		CARDS.put(6, "P");
		CARDS.put(7, "S");
		CARDS.put(8, "E");
		CARDS.put(9, "H");
		CARDS.put(10, "A");
		CARDS.put(11, "R");
		CARDS.put(12, "D");
		CARDS.put(13, "I");
		CARDS.put(14, "N");
	}
	
	// Drop chances
	private static final Map<Integer, Integer> CHANCES = new HashMap<>();
	static
	{
		CHANCES.put(18001, 232000); // Blood Queen
		CHANCES.put(20672, 357000); // Trives
		CHANCES.put(20673, 373000); // Falibati
		CHANCES.put(20674, 583000); // Doom Knight
		CHANCES.put(20677, 435000); // Tulben
		CHANCES.put(20955, 358000); // Ghostly Warrior
		CHANCES.put(20958, 283000); // Death Agent
		CHANCES.put(20959, 455000); // Dark Guard
		CHANCES.put(20961, 365000); // Bloody Knight
		CHANCES.put(20962, 348000); // Bloody Priest
		CHANCES.put(20965, 457000); // Chimera Piece
		CHANCES.put(20966, 493000); // Changed Creation
		CHANCES.put(20968, 418000); // Nonexistant Man
		CHANCES.put(20972, 350000); // Shaman of Ancient Times
		CHANCES.put(20973, 453000); // Forgotten Ancient People
		CHANCES.put(21002, 315000); // Doom Scout
		CHANCES.put(21004, 320000); // Dismal Pole
		CHANCES.put(21006, 335000); // Doom Servant
		CHANCES.put(21008, 462000); // Doom Archer
		CHANCES.put(21010, 397000); // Doom Warrior
		CHANCES.put(21109, 507000); // Hames Orc Scout
		CHANCES.put(21112, 552000); // Hames Orc Footman
		CHANCES.put(21114, 587000); // Cursed Guardian
		CHANCES.put(21116, 812000); // Hames Orc Overlord
		CHANCES.put(21278, 483000); // Antelope
		CHANCES.put(21279, 483000); // Antelope
		CHANCES.put(21280, 483000); // Antelope
		CHANCES.put(21281, 483000); // Antelope
		CHANCES.put(21286, 515000); // Buffalo
		CHANCES.put(21287, 515000); // Buffalo
		CHANCES.put(21288, 515000); // Buffalo
		CHANCES.put(21289, 515000); // Buffalo
		CHANCES.put(21508, 493000); // Splinter Stakato
		CHANCES.put(21510, 527000); // Splinter Stakato Soldier
		CHANCES.put(21513, 562000); // Needle Stakato
		CHANCES.put(21515, 598000); // Needle Stakato Soldier
		CHANCES.put(21520, 458000); // Eye of Splendor
		CHANCES.put(21526, 552000); // Wisdom of Splendor
		CHANCES.put(21530, 488000); // Victory of Splendor
		CHANCES.put(21535, 573000); // Signet of Splendor
	}
	
	public Q00662_AGameOfCards()
	{
		super(662, "A Game of Cards");
		registerQuestItems(RED_GEM);
		addStartNpc(KLUMP);
		addTalkId(KLUMP);
		addKillId(CHANCES.keySet());
	}
	
	@Override
	public String onEvent(String event, Npc npc, Player player)
	{
		String htmltext = event;
		final QuestState st = getQuestState(player, false);
		if (st == null)
		{
			return htmltext;
		}
		
		switch (event)
		{
			case "30845-03.htm":
			{
				st.startQuest();
				st.set("state", "0");
				st.set("stateEx", "0");
				break;
			}
			case "30845-04.htm":
			{
				final int state = st.getInt("state");
				final int stateEx = st.getInt("stateEx");
				if ((state == 0) && (stateEx == 0) && (getQuestItemsCount(player, RED_GEM) >= 50))
				{
					htmltext = "30845-05.htm";
				}
				break;
			}
			case "30845-07.htm":
			{
				st.exitQuest(true, true);
				break;
			}
			case "30845-11.htm":
			{
				final int state = st.getInt("state");
				final int stateEx = st.getInt("stateEx");
				if ((state == 0) && (stateEx == 0) && (getQuestItemsCount(player, RED_GEM) >= 50))
				{
					int i1 = getRandom(70) + 1;
					int i2 = getRandom(70) + 1;
					int i3 = getRandom(70) + 1;
					int i4 = getRandom(70) + 1;
					int i5 = getRandom(70) + 1;
					if (i1 >= 57)
					{
						i1 = i1 - 56;
					}
					else if (i1 >= 43)
					{
						i1 = i1 - 42;
					}
					else if (i1 >= 29)
					{
						i1 = i1 - 28;
					}
					else if (i1 >= 15)
					{
						i1 = i1 - 14;
					}
					
					if (i2 >= 57)
					{
						i2 = i2 - 56;
					}
					else if (i2 >= 43)
					{
						i2 = i2 - 42;
					}
					else if (i2 >= 29)
					{
						i2 = i2 - 28;
					}
					else if (i2 >= 15)
					{
						i2 = i2 - 14;
					}
					
					if (i3 >= 57)
					{
						i3 = i3 - 56;
					}
					else if (i3 >= 43)
					{
						i3 = i3 - 42;
					}
					else if (i3 >= 29)
					{
						i3 = i3 - 28;
					}
					else if (i3 >= 15)
					{
						i3 = i3 - 14;
					}
					
					if (i4 >= 57)
					{
						i4 = i4 - 56;
					}
					else if (i4 >= 43)
					{
						i4 = i4 - 42;
					}
					else if (i4 >= 29)
					{
						i4 = i4 - 28;
					}
					else if (i4 >= 15)
					{
						i4 = i4 - 14;
					}
					
					if (i5 >= 57)
					{
						i5 = i5 - 56;
					}
					else if (i5 >= 43)
					{
						i5 = i5 - 42;
					}
					else if (i5 >= 29)
					{
						i5 = i5 - 28;
					}
					else if (i5 >= 15)
					{
						i5 = i5 - 14;
					}
					
					st.set("state", String.valueOf((i4 * 1000000) + (i3 * 10000) + (i2 * 100) + i1));
					st.set("stateEx", String.valueOf(i5));
					takeItems(player, RED_GEM, 50);
				}
				break;
			}
			case "First":
			case "Second":
			case "Third":
			case "Fourth":
			case "Fifth":
			{
				final int state = st.getInt("state");
				final int stateEx = st.getInt("stateEx");
				int i0;
				int i1;
				int i2;
				int i3;
				int i4;
				int i5;
				int i6;
				int i8;
				int i9;
				i0 = state;
				i1 = stateEx;
				i5 = i1 % 100;
				i9 = i1 / 100;
				i1 = i0 % 100;
				i2 = (i0 % 10000) / 100;
				i3 = (i0 % 1000000) / 10000;
				i4 = (i0 % 100000000) / 1000000;
				switch (event)
				{
					case "First":
					{
						if ((i9 % 2) < 1)
						{
							i9 = i9 + 1;
						}
						break;
					}
					case "Second":
					{
						if ((i9 % 4) < 2)
						{
							i9 = i9 + 2;
						}
						break;
					}
					case "Third":
					{
						if ((i9 % 8) < 4)
						{
							i9 = i9 + 4;
						}
						break;
					}
					case "Fourth":
					{
						if ((i9 % 16) < 8)
						{
							i9 = i9 + 8;
						}
						break;
					}
					case "Fifth":
					{
						if ((i9 % 32) < 16)
						{
							i9 = i9 + 16;
						}
						break;
					}
				}
				
				if ((i9 % 32) < 31)
				{
					st.set("stateEx", String.valueOf((i9 * 100) + i5));
					htmltext = getHtm(player, "30845-12.htm");
				}
				else if ((i9 % 32) == 31)
				{
					i6 = 0;
					i8 = 0;
					if ((i1 >= 1) && (i1 <= 14) && (i2 >= 1) && (i2 <= 14) && (i3 >= 1) && (i3 <= 14) && (i4 >= 1) && (i4 <= 14) && (i5 >= 1) && (i5 <= 14))
					{
						if (i1 == i2)
						{
							i6 = i6 + 10;
							i8 = i8 + 8;
						}
						
						if (i1 == i3)
						{
							i6 = i6 + 10;
							i8 = i8 + 4;
						}
						
						if (i1 == i4)
						{
							i6 = i6 + 10;
							i8 = i8 + 2;
						}
						
						if (i1 == i5)
						{
							i6 = i6 + 10;
							i8 = i8 + 1;
						}
						
						if ((i6 % 100) < 10)
						{
							if ((i8 % 16) < 8)
							{
								if (((i8 % 8) < 4) && (i2 == i3))
								{
									i6 = i6 + 10;
									i8 = i8 + 4;
								}
								
								if (((i8 % 4) < 2) && (i2 == i4))
								{
									i6 = i6 + 10;
									i8 = i8 + 2;
								}
								
								if (((i8 % 2) < 1) && (i2 == i5))
								{
									i6 = i6 + 10;
									i8 = i8 + 1;
								}
							}
						}
						else if (((i6 % 10) == 0) && ((i8 % 16) < 8))
						{
							if (((i8 % 8) < 4) && (i2 == i3))
							{
								i6 = i6 + 1;
								i8 = i8 + 4;
							}
							
							if (((i8 % 4) < 2) && (i2 == i4))
							{
								i6 = i6 + 1;
								i8 = i8 + 2;
							}
							
							if (((i8 % 2) < 1) && (i2 == i5))
							{
								i6 = i6 + 1;
								i8 = i8 + 1;
							}
						}
						
						if ((i6 % 100) < 10)
						{
							if ((i8 % 8) < 4)
							{
								if (((i8 % 4) < 2) && (i3 == i4))
								{
									i6 = i6 + 10;
									i8 = i8 + 2;
								}
								
								if (((i8 % 2) < 1) && (i3 == i5))
								{
									i6 = i6 + 10;
									i8 = i8 + 1;
								}
							}
						}
						else if (((i6 % 10) == 0) && ((i8 % 8) < 4))
						{
							if (((i8 % 4) < 2) && (i3 == i4))
							{
								i6 = i6 + 1;
								i8 = i8 + 2;
							}
							
							if (((i8 % 2) < 1) && (i3 == i5))
							{
								i6 = i6 + 1;
								i8 = i8 + 1;
							}
						}
						
						if ((i6 % 100) < 10)
						{
							if (((i8 % 4) < 2) && ((i8 % 2) < 1) && (i4 == i5))
							{
								i6 = i6 + 10;
								i8 = i8 + 1;
							}
						}
						else if (((i6 % 10) == 0) && ((i8 % 4) < 2) && ((i8 % 2) < 1) && (i4 == i5))
						{
							i6 = i6 + 1;
							i8 = i8 + 1;
						}
					}
					
					if (i6 == 40)
					{
						giveReward(player, ZIGGO_GEMSTONE, 43);
						giveReward(player, EW_S, 3);
						giveReward(player, EW_A, 1);
						htmltext = getHtm(player, "30845-13.htm");
					}
					else if (i6 == 30)
					{
						giveReward(player, EW_S, 2);
						giveReward(player, EW_C, 2);
						htmltext = getHtm(player, "30845-14.htm");
					}
					else if ((i6 == 21) || (i6 == 12))
					{
						giveReward(player, EW_A, 1);
						giveReward(player, EW_B, 2);
						giveReward(player, EW_D, 1);
						htmltext = getHtm(player, "30845-15.htm");
					}
					else if (i6 == 20)
					{
						giveReward(player, EW_C, 2);
						htmltext = getHtm(player, "30845-16.htm");
					}
					else if (i6 == 11)
					{
						giveReward(player, EW_C, 1);
						htmltext = getHtm(player, "30845-17.htm");
					}
					else if (i6 == 10)
					{
						giveReward(player, EA_D, 2);
						htmltext = getHtm(player, "30845-18.htm");
					}
					else if (i6 == 0)
					{
						htmltext = getHtm(player, "30845-19.htm");
					}
					
					st.set("state", "0");
					st.set("stateEx", "0");
				}
				
				htmltext = htmltext.replace("%FontColor1%", ((i9 % 2) < 1) ? "ffff00" : "ff6f6f").replace("%Cell1%", ((i9 % 2) < 1) ? CARDS.get(0) : CARDS.get(i1));
				htmltext = htmltext.replace("%FontColor2%", ((i9 % 4) < 2) ? "ffff00" : "ff6f6f").replace("%Cell2%", ((i9 % 4) < 2) ? CARDS.get(0) : CARDS.get(i2));
				htmltext = htmltext.replace("%FontColor3%", ((i9 % 8) < 4) ? "ffff00" : "ff6f6f").replace("%Cell3%", ((i9 % 8) < 4) ? CARDS.get(0) : CARDS.get(i3));
				htmltext = htmltext.replace("%FontColor4%", ((i9 % 16) < 8) ? "ffff00" : "ff6f6f").replace("%Cell4%", ((i9 % 16) < 8) ? CARDS.get(0) : CARDS.get(i4));
				htmltext = htmltext.replace("%FontColor5%", ((i9 % 32) < 16) ? "ffff00" : "ff6f6f").replace("%Cell5%", ((i9 % 32) < 16) ? CARDS.get(0) : CARDS.get(i5));
				break;
			}
			case "30845-20.htm":
			{
				if (getQuestItemsCount(player, RED_GEM) < 50)
				{
					htmltext = "30845-21.htm";
				}
				break;
			}
		}
		
		return htmltext;
	}
	
	@Override
	public String onTalk(Npc npc, Player player)
	{
		String htmltext = getNoQuestMsg(player);
		final QuestState st = getQuestState(player, true);
		
		switch (st.getState())
		{
			case State.CREATED:
			{
				htmltext = (player.getLevel() < 61) ? "30845-02.htm" : "30845-01.htm";
				break;
			}
			case State.STARTED:
			{
				final int state = st.getInt("state");
				final int stateEx = st.getInt("stateEx");
				if ((state == 0) && (stateEx == 0))
				{
					htmltext = (getQuestItemsCount(player, RED_GEM) < 50) ? "30845-04.htm" : "30845-05.htm";
				}
				else if ((state != 0) && (stateEx != 0))
				{
					int i0;
					int i1;
					int i2;
					int i3;
					int i4;
					int i5;
					int i9;
					i0 = state;
					i1 = stateEx;
					i5 = i1 % 100;
					i9 = i1 / 100;
					i1 = i0 % 100;
					i2 = (i0 % 10000) / 100;
					i3 = (i0 % 1000000) / 10000;
					i4 = (i0 % 100000000) / 1000000;
					htmltext = getHtm(player, "30845-11a.htm");
					htmltext = htmltext.replace("%FontColor1%", ((i9 % 2) < 1) ? "ffff00" : "ff6f6f").replace("%Cell1%", ((i9 % 2) < 1) ? CARDS.get(0) : CARDS.get(i1));
					htmltext = htmltext.replace("%FontColor2%", ((i9 % 4) < 2) ? "ffff00" : "ff6f6f").replace("%Cell2%", ((i9 % 4) < 2) ? CARDS.get(0) : CARDS.get(i2));
					htmltext = htmltext.replace("%FontColor3%", ((i9 % 8) < 4) ? "ffff00" : "ff6f6f").replace("%Cell3%", ((i9 % 8) < 4) ? CARDS.get(0) : CARDS.get(i3));
					htmltext = htmltext.replace("%FontColor4%", ((i9 % 16) < 8) ? "ffff00" : "ff6f6f").replace("%Cell4%", ((i9 % 16) < 8) ? CARDS.get(0) : CARDS.get(i4));
					htmltext = htmltext.replace("%FontColor5%", ((i9 % 32) < 16) ? "ffff00" : "ff6f6f").replace("%Cell5%", ((i9 % 32) < 16) ? CARDS.get(0) : CARDS.get(i5));
				}
				break;
			}
		}
		
		return htmltext;
	}
	
	@Override
	public void onKill(Npc npc, Player player, boolean isPet)
	{
		final QuestState st = getRandomPartyMemberState(player, -1, 3, npc);
		if ((st == null) || !st.isStarted())
		{
			return;
		}
		
		if (getRandom(1000000) < CHANCES.get(npc.getId()))
		{
			final Player partyMember = st.getPlayer();
			giveItems(partyMember, RED_GEM, 1);
			playSound(partyMember, QuestSound.ITEMSOUND_QUEST_ITEMGET);
		}
	}
	
	private void giveReward(Player player, int item, int count)
	{
		final ItemTemplate template = ItemData.getInstance().getTemplate(item);
		if (template.isStackable())
		{
			giveItems(player, item, count);
		}
		else
		{
			for (int i = 0; i < count; i++)
			{
				giveItems(player, item, 1);
			}
		}
	}
}