Witchess choice.ash

digitrev

Member
Well, I don't know about you guys, but I don't feel like hitting up the wiki every time I'm deciding which Witchess piece to fight.

Screenshot 2016-03-06 23.09.49.png

This is based off of Bale's choice.ash, so if you're using that, just drop the code in the appropriate locations. Otherwise, this should work as is.
 

Attachments

  • witchess choice.ash
    3.1 KB · Views: 120

Bale

Minion
I like the idea. I didn't like the fact that ChIT was required as an import. (Not everyone wants to use ChIT.) Especially since the function you imported wasn't really necessary and decorated the browser with a whole lot of classes that aren't defined in the available CSS.

So re-worked your script to do all that without needing to import ChIT, plus a tiny bit more. Please feel free to steal it if you like.

Code:
buffer witchess_fights(buffer page) {
	record reward {
		string match_text;
		item it;
		string type;
		string additional_text;
	};

	static {
		reward [8] witch_pieces;
		witch_pieces[0] = new reward("<b>Pawn</b></a>", $item[armored prawn], "Spleen", "Init +50");
		witch_pieces[1] = new reward("<b>Knight</b></a>", $item[jumping horseradish], "Food", "Meat +100%");
		witch_pieces[2] = new reward("<b>Bishop</b></a>", $item[Sacramento wine], "Booze", "Item +50%");
		witch_pieces[3] = new reward("<b>Rook</b></a>", $item[Greek fire], "Potion", "ML +25, Exp +10");
		witch_pieces[4] = new reward("<b>Ox</b></a>", $item[ox-head shield], "Shield", "Max HP +100, DR +26, Fites +8, Never Fumble, Prismatic Res +2");
		witch_pieces[5] = new reward("<b>King</b></a>", $item[dented scepter], "Club", "Mus Exp +5, HP Regen 5-10, Mus +50%, Wpn Dmg +50%, Critical Hit +10%, Single Equip");
		witch_pieces[6] = new reward("<b>Witch</b></a>", $item[battle broom], "Accessory", "Myst Exp +5, MP Regen 5-10, Myst +50%, Spell Dmg +100%, Spell Critical +10%, Single Equip");
		witch_pieces[7] = new reward("<b>Queen</b></a>", $item[very pointy crown], "Hat", "Mox Exp +5, Adv +5, Mox +50%, Combat Rate -5");
	}

	foreach i, s in witch_pieces {
		buffer rep;
		rep.append(s.match_text);
		rep.append("<br><center><table><tr><td><img src='/images/itemimages/");
		rep.append(s.it.image);
		rep.append("' class='hand' onClick='javascript:descitem(");
		rep.append(s.it.descid);
		rep.append(")'></td><td><a onClick='javascript:descitem(");
		rep.append(s.it.descid);
		rep.append(")'><b>");
		rep.append(s.type);
		rep.append("</a></b></td></tr></table></center><div style="color:blue; font-size:75%">");
		rep.append(s.additional_text);
		rep.append("</div>");
		page.replace_string(s.match_text, rep);
	}
	return page;
}

I'm not entirely happy with the format yet. I want the chess pieces lined up neatly instead of staggered by the varying amount of description under them. I don't want to spend the time to do that right now, so I'm showing you what I have.
 
Last edited:

Bale

Minion
Fixing the alignment proved to be fairly simple once I had the time to look at it. Also, I made some other format improvements. Here it is:

Code:
buffer witchess_fights(buffer page) {
	record reward {
		string match_text;
		item it;
		string type;
		string additional_text;
	};

	static {
		reward [8] witch_pieces;
		witch_pieces[0] = new reward("<b>Pawn</b></a>", $item[armored prawn], "Spleen", "Init +50");
		witch_pieces[1] = new reward("<b>Knight</b></a>", $item[jumping horseradish], "Food", "Meat +100%");
		witch_pieces[2] = new reward("<b>Bishop</b></a>", $item[Sacramento wine], "Booze", "Item +50%");
		witch_pieces[3] = new reward("<b>Rook</b></a>", $item[Greek fire], "Potion", "ML +25<br>Exp +10");
		witch_pieces[4] = new reward("<b>Ox</b></a>", $item[ox-head shield], "Shield", "Max HP +100<br>DR +26<br>Prismatic Res +2<br>Rollover Fites +8<br>Never Fumble");
		witch_pieces[5] = new reward("<b>King</b></a>", $item[dented scepter], "Club", "Mus Exp +5<br>HP Regen 5-10<br>Mus +50%<br>Wpn Dmg +50%<br>Critical Hit +10%");
		witch_pieces[6] = new reward("<b>Witch</b></a>", $item[battle broom], "Accessory", "Myst Exp +5<br>MP Regen 5-10<br>Myst +50%<br>Spell Dmg +100%<br>Spell Critical +10%");
		witch_pieces[7] = new reward("<b>Queen</b></a>", $item[very pointy crown], "Hat", "Mox Exp +5<br>Rollover Adv +5<br>Mox +50%<br>Combat Rate -5<br>Critical Hit Delevel");
	}

	foreach i, s in witch_pieces {
		buffer rep;
		rep.append(s.match_text);
		rep.append("<br><center><table><tr><td><img src='/images/itemimages/");
		rep.append(s.it.image);
		rep.append("' class='hand' onClick='javascript:descitem(");
		rep.append(s.it.descid);
		rep.append(")'></td><td><a onClick='javascript:descitem(");
		rep.append(s.it.descid);
		rep.append(")'><b>");
		rep.append(s.type);
		rep.append("</a></b></td></tr></table></center><div style=\"color:blue; font-size:75%\">");
		rep.append(s.additional_text);
		rep.append("</div>");
		page.replace_string(s.match_text, rep);
	}
	
	// Line up the pieces neatly.
	page.replace_string('<div style="display:inline-block; text-align: center; width: 120px">', '<div style="vertical-align:top; display:inline-block; text-align: center; width: 120px">');
	
	return page;
}
 

Bale

Minion
You're welcome. And since I have a tendency to keep tinkering with things I added a helpful tooltip....

Edit: More improvements!
Code:
buffer witchess_fights(buffer page) {
	record reward {
		string match_text;
		item it;
		string type;
		string additional_text;
	};

	static {
		reward [8] witch_pieces;
		witch_pieces[0] = new reward("<b>Pawn</b></a>", $item[armored prawn], "Spleen", "Init +50%");
		witch_pieces[1] = new reward("<b>Knight</b></a>", $item[jumping horseradish], "Food", "Meat +100%");
		witch_pieces[2] = new reward("<b>Bishop</b></a>", $item[Sacramento wine], "Booze", "Item +50%");
		witch_pieces[3] = new reward("<b>Rook</b></a>", $item[Greek fire], "Potion", "ML +25<br>Exp +10");
		witch_pieces[4] = new reward("<b>Ox</b></a>", $item[ox-head shield], "Shield", "Max HP +100<br>DR +26<br>Prismatic Res +2<br>Rollover Fites +8<br>Never Fumble");
		witch_pieces[5] = new reward("<b>King</b></a>", $item[dented scepter], "Club", "Mus Exp +5<br>HP Regen 5-10<br>Mus +50%<br>Wpn Dmg +50%<br>Critical Hit +10%");
		witch_pieces[6] = new reward("<b>Witch</b></a>", $item[battle broom], "Accessory", "Myst Exp +5<br>MP Regen 5-10<br>Myst +50%<br>Spell Dmg +100%<br>Spell Critical +10%");
		witch_pieces[7] = new reward("<b>Queen</b></a>", $item[very pointy crown], "Hat", "Mox Exp +5<br>Rollover Adv +5<br>Mox +50%<br>Combat Rate -5<br>Critical Hit Delevel");
	}

	foreach i, s in witch_pieces {
		buffer rep;
		rep.append(s.match_text);
		rep.append("<br><center><table><tr title='");
		rep.append(s.it);
		rep.append(" (have ");
		rep.append(available_amount(s.it));
		rep.append(")");
		if($items[ox-head shield, dented scepter, battle broom, very pointy crown] contains s.it)
			rep.append("\nWill disappear at the end of day");
		rep.append("'><td><img src='/images/itemimages/");
		rep.append(s.it.image);
		rep.append("' class='hand' onClick='javascript:descitem(");
		rep.append(s.it.descid);
		rep.append(")'></td><td><a onClick='javascript:descitem(");
		rep.append(s.it.descid);
		rep.append(")'><b>");
		rep.append(s.type);
		rep.append("</a></b></td></tr></table></center><div style=\"color:blue; font-size:75%\">");
		rep.append(s.additional_text);
		rep.append("</div>");
		page.replace_string(s.match_text, rep);
	}
	
	// Line up the pieces neatly.
	page.replace_string('<div style="display:inline-block; text-align: center; width: 120px">', '<div style="vertical-align:top; display:inline-block; text-align: center; width: 120px">');
	
	return page;
}
 
Last edited:

Crowther

Active member
I feel like I should know the answer, but how do I install this? Put it in the relay directory and name it the same choice something, right?
 

Bale

Minion
What I posted was just part of a script. The real problem is that all scripts that modify choice.php have the same name so you can only have one, unless you keep adding the functionality of all of them into a single script. That's why I posted the part that was only relevant to this particular non-combat.

Here's my choice.ash script which adds functionality to a number of non-combats. Just plunk this into /relay and you'll be good to go for a number of wonderful enhancements.
 

Attachments

  • choice.ash
    15.9 KB · Views: 165
Last edited:

Crowther

Active member
Oh, I thought that problem had been fixed. I guess it was just suggestions on how to fix it. I don't mess with relay scripts much. Thanks for the script. I just replaced the choice.ash script I previously had from you. :)
 
Top