All pastes #163323 Raw Edit

Untitled

public text v1 · immutable
·published 2006-09-07 12:44 UTC
rendered paste body

Map <String, Category> Categories = new Map<String,Category>;   // string to typ kategorii a Category to kategoria ;P

Categories.add("adena",null);

Categories.add("sealred",null);
Categories.add("sealblue",null);
Categories.add("sealgreen",null);

Categories.add("full_items",null);
Categories.add("others",null);


/////////////////////////////////////////////
Map <String, Category> CategoriesKoncowe = new Map<String,Category>;

CategoriesKoncowe.add("adena",null);

CategoriesKoncowe.add("sealred",null);
CategoriesKoncowe.add("sealblue",null);
CategoriesKoncowe.add("sealgreen",null);

CategoriesKoncowe.add("full_items",null);
CategoriesKoncowe.add("material",null);
CategoriesKoncowe.add("recipes",null);
CategoriesKoncowe.add("spellbooks",null);
CategoriesKoncowe.add("arrows",null);

CategoriesKoncowe.add("others",null);
////////////////////////////////////////////

String parseDrop(string slowo)
{
	parseCategories(substring(slowo,27,slowo.lenght()-1)); // << pewnie zle indeksy sprawdz
	remakeCategories(Categories, CategoriesKoncowe);
	changeRates(CategoriesKoncowe);
	return "addtitional_make_multilist={"+rebuildCategories()+"}";
}
parseCategories(string slowo)
{
	List<String> catList = new List<String>;
	// Podziel na podslowa bedace kategoriami i wrzuc do catList czyli jak jest    {{{[item];1,2;3};{[item];2;3;5}};234}; << to odziela dopiero kategorie
	foreach(String s: catList)
	{
		Category c = new Category(s);
		String type =c.type();
		Categories.index(type).put(c); // << chodzi o to, ze jak jest kategoria "adena" to ma ja dac do   listy o indexie "adena"
	}
}
/*** **************************************************************************************/
/*** **************************************************************************************/
/*** **************************************************************************************/
class Category
{
	String type;
	List<item> items;
	double chance;
	
	Category(String t,List<items> i,double chance)
	{
		 Tu musi skopiowac liste, a nie podpiac referencje, inaczej sie spieprzy
		// wiadomo
	}
	Category(String s)
	{
		List<String> itemsS = new List<String>;
		
		s.wywalzewnetrznenawiasy(); // :P :P
		//Sparsuj tak samo jak wczesniej kategorie, tylko teraz itemy, zeby do itemsS trafily slowa postaci  {[item1];min;max;szansa}
		foreach(String s: itemsS)
		{
			Item item = new Item(s);
			items.add(item);
		}
		
		//typ
		
		String pierwsza_rzecz_name = items[1].getname();
		/** 
		 *  Tu trzeba zobaczyc czy sa to "full_items" "red_sealstone" "blue_sealstone" "green_sealstone" "adena" czy "inne"
		 *  Nie wiem jak odroznic "full_items" od "inne"      To trzeba jakos wymyslec.
		 */
	}
	String type(){return type;}
	String categoryString()
	{
		String result="{";
		foreach(item i: items)
		{
			result+=i.itemString();
		}
		result+=";"+chance+"}";
	}
	List<item> getItems(){return items;}
	double getCahce(){return chance;}
}
class item
{
	String name;
	int min;
	int max
	double szansa;
	String type;
	
	item(String s)
	{
		// wywal zewnetrzne nawiasy, wyciagnij nazwe, min, max i szanse
		 /** TYP:
		  *  Jesli  nazwa zaczyna sie "sb_" to typ = "spellbook"
		  *  Jesli nazwa zaczyna sie  "rp_" to type = "recipe"
		  *  Jesli w itemdata.txt  jest type='material' to wtedy type = "mats"
		  *  Jesli nazwa to wooden_arrow, bone_arrow, fine_stell_arrow, silver_arrow, mithril_arrow czy shining_arrow to type ="arrow"
		  *  W.P.P type = "other" 
		  */
	}
	String type(){ return type;}
	String itemString()
	{
		return "{["+nazwa+"];"+min+";"+max+";"+szansa+"}";
	}
	double getchance(){return chance;}
}

remakeCategories(Map <String, Category> In, Map <String, Category> Out)
{
	foreach (Category c: In)
	{
		if (c.type()=="adena")
			Out.index["adena"].add(c);
		else if(c.type()=="red_sealston")
			Out.index["red_sealstone"].add(c);
		//  Tak samo blue i gree sealstone oraz full_items
		else if(c.type()=="others")
		{
			
			// I tu jest jazda :d
			/*********************************************************************************************************/
			List<item> _tempItems = new List<item>;
			double chanceSum = 0;
			 // wyciagamy recki =-=============================================
			foeach(item i: c.getItems())
			{
				if (i.type()=="recki")
				{
					_tempItems.add(i);
					chanceSum += i.getchance();
				}
			}
			 // Wyliczamy nowa szanse dla grupy
			double new_chance = c.getchance() * chanceSum / 100; 
			 // Poprawiamy szanse itemow i grupie
			foeach(item i: _tempItems)
			{
				i.setChance(i.getChance() * 100 / chanceSum );
			} // Teraz teoretycznie suma szans itemow w _tempItems powinna byc = 100    Na upartego mozna to jeszcze przejrzec i jezeli nie jest, to roznice dodac do tego z najwieksza szansa
			
			Out.index["recki"].add(new Category("recki"),_tempItems, new_chance);
			_tempItems.clear();
			chanceSum  = 0;
			new_chance = 0;
			////////////////////////////////////////////////////////////////
			/**
			 * 
			 * 
			 * 
			 * 
			 * 
			 *         Powtarzamy powyzsze (od "wyciagamy recki") dla   "spellbook" "recipes"  "arrow"  "mats"  "other"
			 * 
			 * 
			 * 
			 * 
			 * 
			 * 
			 */
			 */
		}
	}
}

changeRates( List<Category> cats)
{
	/** 
	 * Zaleznie od typu:
	 * Jesli "adena" "seal blue/green/red" "mats" "arrows" To zwiekszamy ilosc w kazdym itemie (min i max)
	 * Jesli full_item, recipes, spellbooks czy others to zwiekszamy szanse grupy  (ograniczenie do 100, ale raczej nie powinno byc problemow)
	 */
}

rebuildCategories()
{
	// Ma zwrocic w formacie   {category1};{category2};{category3}
	// gdzie   categoryX = {itemy};szansa
	// gdzie itemy = {item1};{item2};{item3}
	// gdzie  itemX = [nazwa];min;max;szansa
}