Using Witchess Fights

syrinxlui

Member
Hi,

I am trying to adapt the code for getting the bag of park garbage to getting the ox shield. The bag of park garbage works like this:

ashq visit_url("place.php?whichplace=airport_stench&action=airport3_tunnels");
ashq visit_url("choice.php?whichchoice=1067&option=6");

When I look at the urls I click on to fight the witchess ox it looks like this:

http://127.0.0.1:60080/campground.php?action=witchess
http://127.0.0.1:60080/choice.php?option=1&pwd=hash&whichchoice=1182&piece=1937

So I tried:

ashq visit_url("campground.php?action=witchess")
ashq visit_url("choice.php?option=1&whichchoice=1182&piece=1937")

But nothing happened. So there's a lot here that I don't understand.
1) Does cutting out the password hash matter?
2) How do I capture the fact that I clicked on the first choice after selecting my witchess set? Is that fully captured by that "option=1" in the ox fight command?
3) Does the order of the stuff after the "choice.php?" matter? For the park garbage it was choice number and then option number. For the Ox it was option number and then choice number.
4) Why doesn't my approach work?

Thanks,
SyrinxLui
 

lostcalpolydude

Developer
Staff member
1) Does cutting out the password hash matter?
No, mafia adds that in for you.
2) How do I capture the fact that I clicked on the first choice after selecting my witchess set? Is that fully captured by that "option=1" in the ox fight command?
No, it's a separate visit_url() call, in this case choice 1181 option 1. This is why what you tried didn't work.
3) Does the order of the stuff after the "choice.php?" matter? For the park garbage it was choice number and then option number. For the Ox it was option number and then choice number.
The order does not matter.
 

Bale

Minion
1) Does cutting out the password hash matter?
No, mafia adds that in for you.

I have always found that to be true, but I wrote some code for doing my free Witchess fights and it didn't work until I explicitly added the password hash. Is a GET request treated differently?

PHP:
void witchess() {
	if(get_campground() contains $item[Witchess Set] && get_property("_witchessFights").to_int() < 5) {
		static {
			int [item] choice;
				choice[ $item[armored prawn] ] = 1935;
				choice[ $item[jumping horseradish] ] = 1936;
				choice[ $item[Sacramento wine] ] = 1942;
				choice[ $item[Greek fire] ] = 1938;
			item [int] priciest;
				foreach it in choice
					priciest[ count(priciest) ] = it;
		}
		sort priciest by -mall_price(value);
		
		while(get_property("_witchessFights").to_int() < 5) {
			visit_url("campground.php?action=witchess");
			run_choice(1);
			visit_url("choice.php?option=1&pwd="+my_hash()+"&whichchoice=1182&piece=" + choice[ priciest[0] ], false);
			run_combat();
		}
	}
}
 

syrinxlui

Member
Thanks for your help, calpoly. Adding in that choice adventure you said now sends me to the choose a witch piece to fight screen. But I can't make the third line work. I tried both jamming Bale's line in and actually writing out the hash from the right click link, but neither starts the fight. What am I doing incorrectly here?

ashq visit_url("choice.php?option=1&pwd="+my_hash()+"&whichchoice=1182&piece=1937")
 

Bale

Minion
The answer is in my example above. You need to add a second parameter to the visit_url() which is false. That changes the url call from POST to GET.
 

adeyke

Member
I encountered that same problem while writing my own witchess automatic (which I've now replaced with that given above). According to the wiki:
In a POST request, if &pwd is part of the page string, it will automatically be replaced by &pwd=###### where ###### is the password hash for the current session. For a GET request the password hash will not be added so you'll want to use my_hash().
 

Veracity

Developer
Staff member
That is correct; we will add "pwd" to the "data" - the form fields of a POST request - but do not touch the URL we are given for a GET request.
 

ckb

Minion
Staff member
I have always found that to be true, but I wrote some code for doing my free Witchess fights and it didn't work until I explicitly added the password hash. Is a GET request treated differently?

Every time I think about writing a script for something, I find out that Bale has already done it. And done it better than I have and solved all the issues I was about to run into. When will I ever learn to just ask Bale more often?
 

Bale

Minion
If you're gonna be like that, then here. Have the trilogy of free fight functions. The Snojo one is much longer because I'm choosing which scroll to earn.

PHP:
void machine_elf() {
	if(have_familiar($familiar[Machine Elf]) && $familiar[Machine Elf].fights_limit > $familiar[Machine Elf].fights_today) {
		use_familiar($familiar[Machine Elf]);
		if(my_basestat($stat[Moxie]) >= 150)
			outfit("drop items ONLY");
		else
			outfit("drop items");
		while($familiar[Machine Elf].fights_limit > $familiar[Machine Elf].fights_today)
			adv1($location[The Deep Machine Tunnels], -1, "");
	}
}

boolean set_snojo() {
	// Are there free snojo fights remaining?
	if(get_property("_snojoFreeFights").to_int() > 9)
		return false;
	
	static {
		record snojo {
			string mode;
			string wins;
			int choice;
		};
		snojo [item] reward;
		reward[ $item[training scroll:  Shattering Punch] ] = new snojo("MUSCLE", "snojoMuscleWins", 1);
		reward[ $item[training scroll:  Snokebomb] ] = new snojo("MYSTICALITY", "snojoMysticalityWins", 2);
		reward[ $item[training scroll:  Shivering Monkey Technique] ] = new snojo("MOXIE", "snojoMoxieWins", 3);
	}
	
	int wins(item it) { return to_int(get_property(reward[it].wins)); }
	
	void set_mode(item fave) {
		if(reward[fave].mode != get_property("snojoSetting")) {
			visit_url("place.php?whichplace=snojo&action=snojo_controller");
			run_choice(reward[fave].choice);
		}
	}
	
	item [int] choice;
	foreach it in reward
		if(wins(it) < 50)
			choice[ count(choice) ] = it;
	
	if(count(choice) == 0)
		return false;
	if(count(choice) > 1) {
		sort choice by -mall_price(value);	// This is a tie-breaker
		sort choice by -wins(value);		// Select most wins first
	}
	set_mode(choice[0]);
	return true;
}

void snojo() {
	if(to_boolean(get_property("snojoAvailable")) && get_property("_snojoFreeFights").to_int() < 10) {
		if(get_property("snojoSetting") == "NONE")
			visit_url("place.php?whichplace=snojo&action=snojo_controller");
		choose_familiar($familiars[Ms. Puck Man, Machine Elf]);
		maximize("mainstat, 0.4 hp  +effective, mp regen, +shield", false);
		# while(get_property("_snojoFreeFights").to_int() < 10)
		while(set_snojo())
			adv1($location[The X-32-F Combat Training Snowman], -1, "");
	}
}

void witchess() {
	if(get_campground() contains $item[Witchess Set] && get_property("_witchessFights").to_int() < 5) {
		static {
			int [item] choice;
				choice[ $item[armored prawn] ] = 1935;
				choice[ $item[jumping horseradish] ] = 1936;
				choice[ $item[Sacramento wine] ] = 1942;
				choice[ $item[Greek fire] ] = 1938;
			item [int] priciest;
				foreach it in choice
					priciest[ count(priciest) ] = it;
		}
		sort priciest by -mall_price(value);
		
		while(get_property("_witchessFights").to_int() < 5) {
			visit_url("campground.php?action=witchess");
			run_choice(1);
			visit_url("choice.php?option=1&pwd="+my_hash()+"&whichchoice=1182&piece=" + choice[ priciest[0] ], false);
			run_combat();
		}
	}
}
 

Crowther

Active member
Every time I think about writing a script for something, I find out that Bale has already done it. And done it better than I have and solved all the issues I was about to run into. When will I ever learn to just ask Bale more often?
Even if he hasn't written it, he'll see your script and write a better one. :D
 
Top