View Single Post
  #27  
Old 04-14-2008, 01:31 PM
John Adams
Demi-God
 
Join Date: Jul 2006
Posts: 1,552
Default

Not sure this will help any, but I built some arrays in php for these bitwise comparisons. It was so long ago, I am not really sure why I did it this way, but here it is nonetheless.

Code:
// Gear slots
$a = 1;
$gear_slots=array(
	"Charm" 				=> $a << 0,
	"Left Ear" 			=> $a << 1,
	"Head" 					=> $a << 2,
	"Face" 					=> $a << 3,
	"Right Ear" 		=> $a << 4,
	"Neck" 					=> $a << 5,
	"Shoulder" 			=> $a << 6,
	"Arms" 					=> $a << 7,
	"Back" 					=> $a << 8,
	"Left Bracer" 	=> $a << 9,
	"Right Bracer" 	=> $a << 10,
	"Range" 				=> $a << 11,
	"Hands" 				=> $a << 12,
	"Primary" 			=> $a << 13,
	"Secondary" 		=> $a << 14,
	"Left Ring" 		=> $a << 15,
	"Right Ring" 		=> $a << 16,
	"Chest" 				=> $a << 17,
	"Legs" 					=> $a << 18,
	"Feet" 					=> $a << 19,
	"Waist" 				=> $a << 20,
	"Ammo" 					=> $a << 21
);

//foreach($gear_slots as $row=>$val) {
//	echo $row.$val."<BR>";
//}

// Char Inventory slots (8)
$s=1;
for($i=22;$i<=29;$i++) {
	$inv="Inventory$s";
	$inv_slots[$inv]=$i;
	$s++;
}

// Char Inventory bag slots (8bags * 10slots)
$b=1; // bag 1
$s=1; // slot 1
for($i=251;$i<=330;$i++) {
	if($s>10) {
		$s=1;
		$b++;
	}
	$bag="Bag$b";
	$bagslot="Slot$s";
//	echo "$bag-$bagslot<br>";
	$inv_slots["$bag-$bagslot"]=$i;
	$s++;
}

// Char Bank Slots (16)
$s=1; // slot 1
for($i=2000;$i<=2015;$i++) {
	$inv="BankSlot$s";
	$inv_slots[$inv]=$i;
	$s++;
}

// Char Bank Bag slots (16bags * 10slots)
$b=1; // bag 1
$s=1; // slot 1
for($i=2031;$i<=2190;$i++) {
	if($s>10) {
		$s=1;
		$b++;
	}
	$bag="BankBag$b";
	$bagslot="Slot$s";
//	echo "$bag-$bagslot<br>";
	$inv_slots["$bag-$bagslot"]=$i;
	$s++;
}


// Create Classes Array
$a = 1;
$classes=array(
	"Unknown" 			=> 0,
	"Warrior" 			=> $a << 0,
	"Cleric" 				=> $a << 1,
	"Paladin" 			=> $a << 2,
	"Ranger" 				=> $a << 3,
	"Shadowknight"	=> $a << 4,
	"Druid" 				=> $a << 5,
	"Monk" 					=> $a << 6,
	"Bard" 					=> $a << 7,
	"Rogue" 				=> $a << 8,
	"Shaman" 				=> $a << 9,
	"Necromancer" 	=> $a << 10,
	"Wizard" 				=> $a << 11,
	"Magician" 			=> $a << 12,
	"Enchanter" 		=> $a << 13,
	"Beastlord" 		=> $a << 14,
	"Berserker" 		=> $a << 15
);

// Create Races Array
$a = 1;
$races=array(
	"Unknown" 	=> 0,
	"Human" 		=> $a << 0,
	"Barbarian" => $a << 1,
	"Erudite" 	=> $a << 2,
	"Wood Elf" 	=> $a << 3,
	"High Elf"	=> $a << 4,
	"Dark Elf" 	=> $a << 5,
	"Half Elf" 	=> $a << 6,
	"Dwarf" 		=> $a << 7,
	"Troll" 		=> $a << 8,
	"Ogre" 			=> $a << 9,
	"Halfling" 	=> $a << 10,
	"Gnome" 		=> $a << 11,
	"Iksar" 		=> $a << 12,
	"Vah Shir" 	=> $a << 13,
	"NPC" 			=> $a << 14,
	"PET" 			=> $a << 15,
	"Froglok" 	=> $a << 16
);
I used these arrays to build the combo boxes on my lookup page. Something like this:
Code:
<select name="searchClass" class="advSearch">
	<option value="-1">Pick a Class</option>
	<?php
	foreach($classes as $key=>$val) {
		if(isset($_POST['searchClass']) && $val==$_POST['searchClass']) {
			$selected=" selected";
		} else {
			$selected="";
		}
		echo '<option value="'.$val.'"'.$selected.'>'.$key.'</option>';
	}
	?>
</select>
Again, kinda barbaric, but it works. Good luck with the app. I like the idea.
Reply With Quote