case $location[The Neverending Party]: if (qprop("_questPartyFair < started") || qprop("_questPartyFair")) return;  // don't do anything if the quest isn't started OR is finished
         switch (get_property("_questPartyFairQuest")) {
            case "food": friendlyset(1324,"2","Go to the kitchen for food stuff.");
               if (get_property("_questPartyFairProgress") == "") friendlyset(1326,"3","Ask the kitchen lady which food to collect.");
                else if (item_amount(to_item(to_int(excise(get_property("_questPartyFairProgress")," ","")))) >= to_int(excise(get_property("_questPartyFairProgress"),""," ")))
                   friendlyset(1326,"4","Turn in your snacks to the kitchen lady.");
               return;
            case "booze": friendlyset(1324,"3","Go to the backyard for booze stuff.");
               if (get_property("_questPartyFairProgress") == "") friendlyset(1327,"3","Find Gerald.");
                else if (item_amount(to_item(to_int(excise(get_property("_questPartyFairProgress")," ","")))) >= to_int(excise(get_property("_questPartyFairProgress"),""," ")))
                   friendlyset(1327,"4","Turn in the food to Gerald.");
               return;
            case "dj": if (my_buffedstat($stat[moxie]) < 300) break;
               friendlyset(1324,"1","Go upstairs to look for meat.");
               friendlyset(1325,"4","Crack the safe!");
               return;
            case "trash": friendlyset(1324,"2","Go to the kitchen to burn trash.");
               friendlyset(1326,"5","Burn some trash! (25% progress)");
               return;
            case "woots": if (item_amount($item[very small red dress]) > 0 && !contains_text(session_logs(1)[0],"Encounter: A Room With a View")) {  // detection method imperfect but good enough
                  friendlyset(1324,"1","Go upstairs for the lamp.");
                  friendlyset(1325,"5","Throw a red dress on the lamp.");
               } else if (item_amount($item[electronics kit]) > 0 && !contains_text(session_logs(1)[0],"Encounter: Basement Urges")) {
                  friendlyset(1324,"4","Go to the basement for the lights.");
                  friendlyset(1328,"4","Modify the living room lights.");
               } else friendlyset(1324,"5","Fight a random partier.");
               return;
            case "partiers": if (have_item($item[intimidating chainsaw]) == 0) {  // saw -> 30% -> 20% is optimal regardless of easy/hard
                  friendlyset(1324,"4","Go to the basement for a chainsaw.");
                  friendlyset(1328,"3","Pick up a chainsaw.");
               } else if (item_amount($item[jam band bootleg]) > 0 && !contains_text(session_logs(1)[0],"Encounter: A Room With a View")) {
                  friendlyset(1324,"1","Go upstairs for the stereo.");
                  friendlyset(1325,"3","Put a jam band bootleg in the stereo.");
               } else if (item_amount($item[Purple Beast energy drink]) > 0 && get_property("_questPartyFairProgress").to_int() >= 10 && !contains_text(session_logs(1)[0],"Encounter: Forward to the Back")) {
                  friendlyset(1324,"3","Go to the backyard for the pool.");
                  friendlyset(1327,"5","Pour Purple Beast in the pool!");
               } else friendlyset(1324,"5","Fight a random partier.");
               return;
            default: friendlyset(1324,"0","Decide what to do yourself!");
         }boolean StockPartyConsumables() {
	string [int] PartyFairConsumableStrings;
	item PartyFairConsumable,PartyFairConsumableCreator;
	int PartyFairConsumableAmount, dummy;
	PartyFairConsumableStrings = split_string(get_property("_questPartyFairProgress")," ");
	if ( PartyFairConsumableStrings.count() == 2 ) {
		PartyFairConsumable = to_item(to_int(PartyFairConsumableStrings[1]));
		PartyFairConsumableAmount = to_int(PartyFairConsumableStrings[0]);
		if ( PartyFairConsumable.fullness > 0 )
			PartyFairConsumableCreator = $item[van key];
		else if ( PartyFairConsumable.inebriety > 0 )
			PartyFairConsumableCreator = $item[unremarkable duffel bag];
		else
			return false;
		while ( available_amount(PartyFairConsumable) < PartyFairConsumableAmount ) {
			if ( mall_price(PartyFairConsumable) > 2*mall_price(PartyFairConsumableCreator) ) {
				if ( item_amount(PartyFairConsumableCreator)==0 )
					buy(1,PartyFairConsumableCreator);
				use(item_amount(PartyFairConsumableCreator),PartyFairConsumableCreator);
			}
			else				
				dummy = buy(PartyFairConsumableAmount-available_amount(PartyFairConsumable),PartyFairConsumable,mall_price(PartyFairConsumable));
		}
	}
	return retrieve_item(PartyFairConsumableAmount,PartyFairConsumable);
}
void UpdateNeverendingParty() {
	string PartyNoncombatsVisited = get_property("_neverendingPartyNoncombatsVisited");
	if ( get_property("_neverendingPartyFreeTurns").to_int() == 9 && UseClaraForPartying && have_effect($effect[Eldritch Attunement])==0 && $strings[food,booze,woots] contains get_property("_questPartyFairQuest") )
		use(1,$item[Clara's Bell]);
	switch ( get_property("_questPartyFairQuest") ) {
		case "dj":			// crack the safe?
		case "trash":		// burn trash in the kitchen?
		case "":
			set_property("choiceAdventure1324",5);	// combat
			break;
		case "food":
			set_property("choiceAdventure1324",2);	// kitchen
			switch ( get_property("_questPartyFair") ) {
				case "started":
					set_property("choiceAdventure1326",3);	// talk to geraldine
					break;
				case "step1":
					if ( !StockPartyConsumables() )
						abort("Couldn't acquire the required consumables");
				case "step2":
					set_property("choiceAdventure1326",4);	// give food to geraldine
					break;
			}
			break;
		case "booze":
			set_property("choiceAdventure1324",3);	// backyard
			switch ( get_property("_questPartyFair") ) {
				case "started":
					set_property("choiceAdventure1327",3);	// talk to gerald
					break;
				case "step1":
					if ( !StockPartyConsumables() )
						abort("Couldn't acquire the required consumables");
				case "step2":
					set_property("choiceAdventure1327",4);	// give booze to gerald
					break;
			}
			break;
		case "woots":
			if ( item_amount($item[cosmetic football])>0 && equipped_item($slot[off-hand])!=$item[cosmetic football] )
				equip($slot[off-hand],$item[cosmetic football]);
			set_property("choiceAdventure1325",5);	// drape red dress over lamp
			set_property("choiceAdventure1328",4);	// adjust lights
			if ( !contains_text(PartyNoncombatsVisited,"1325-5") && item_amount($item[very small red dress])>0 )
				set_property("choiceAdventure1324",1);	// bedroom
			else if ( !contains_text(PartyNoncombatsVisited,"1328-5") && item_amount($item[electronics kit])>0 )
				set_property("choiceAdventure1324",4);	// basement
			else
				set_property("choiceAdventure1324",5);	// combat
			break;
		case "partiers":
			if ( item_amount($item[intimidating chainsaw])>0 && equipped_item($slot[weapon])!=$item[intimidating chainsaw] )
				equip($item[intimidating chainsaw]);
			set_property("choiceAdventure1328",3);	// intimidating chainsaw
			set_property("choiceAdventure1325",3);	// play jam bad bootleg
			set_property("choiceAdventure1327",5);	// throw purple energy drink into pool
			if ( !contains_text(PartyNoncombatsVisited,"1328-3") )
				set_property("choiceAdventure1324",4);	// basement
			else if ( !contains_text(PartyNoncombatsVisited,"1325-3") && item_amount($item[jam band bootleg])>0 )
				set_property("choiceAdventure1324",1);	// bedroom
			else if ( !contains_text(PartyNoncombatsVisited,"1327-5") && item_amount($item[Purple Beast energy drink])>0 )
				set_property("choiceAdventure1324",3);	// backyard
			else
				set_property("choiceAdventure1324",5);	// combat
			break;
		default: 
			abort("Huh, were we unable to recognize the party quest?");
	}
}
void NeverendingParty() {
	if ( get_property("_neverendingPartyFreeTurns").to_int() < 10 ) {
		HeavyRains((10-get_property("_neverendingPartyFreeTurns").to_int())*(have_effect($effect[Eldritch Attunement]) > 0 ? 2 : 1));
		InitializeNeverendingParty();
		if ( get_property("_partyHard").to_boolean() ) {
			libramBurn();
			equip($item[PARTY HARD T-shirt]);
		}
		while ( get_property("_neverendingPartyFreeTurns").to_int() < 10 && get_property("_questPartyFair") != "finished" ) {
			UpdateNeverendingParty();
			ChooseFamiliar();
			adv1($location[The Neverending Party], -1, "");
			while ( in_multi_fight() )
				run_combat();
			if ( last_choice()>=1325 && last_choice()<=1328 && last_decision()>=3 && !contains_text(get_property("_neverendingPartyNoncombatsVisited"),last_choice()+"-"+last_decision()) )
				set_property("_neverendingPartyNoncombatsVisited",get_property("_neverendingPartyNoncombatsVisited")+last_choice()+"-"+last_decision()+" ");
		}
		if ( get_property("_questPartyFair") == "step2" )
			adv1($location[The Neverending Party], -1, "");
		if ( ( get_property("lastEncounter") == "Party's Over" || get_property("lastEncounter") == "All Done!" ) && get_property("_questPartyFair") != "finished" )
			print(get_property("_questPartyFair"));
	}
}