Skip to content

Instantly share code, notes, and snippets.

@emestee
Created June 10, 2014 15:53
Show Gist options
  • Save emestee/c322cf8bc3981c1ed47d to your computer and use it in GitHub Desktop.
Save emestee/c322cf8bc3981c1ed47d to your computer and use it in GitHub Desktop.
<?php
define('WARRIOR_OFFSET', 16);
define('MAGE_OFFSET', 17);
define('CLASS_MASK', ( 1 << WARRIOR_OFFSET ) | ( 1 << MAGE_OFFSET ));
$bitmask = 1 << MAGE_OFFSET | 1 << WARRIOR_OFFSET;
$classMap = array(
0b00 => 'error',
0b01 => 'warrior',
0b10 => 'mage',
0b11 => 'seyan',
);
$class = $bitmask & CLASS_MASK;
$class = $class >> WARRIOR_OFFSET;
$class_name = $classMap[$class];
print "$class_name\n";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment