clean up, format code

This commit is contained in:
Hash Borgir 2023-06-01 23:33:06 -06:00
parent 80c1395efc
commit 8c782c7d81

View File

@ -3,342 +3,419 @@
require_once 'D2BitReader.php';
/**
*
* Class D2CharItem
*/
class D2CharItem {
/**
* @var string
* @var string The raw binary data of the item
*/
private string $bits;
// Item properties
/**
* @var string
* @var string The name of the base item
*/
public $basename = ''; //name of the base item
public string $basename = '';
/**
* @var string
* @var string The name string of the item
*/
public $item_name = ''; //name string
public string $item_name = '';
/**
* @var string
* @var string The rank of the item (normal/exceptional/elite)
*/
public $item_rank = ''; //normal/exceptional/elite
public string $item_rank = '';
/**
* @var string
* @var string The basic type of the item (armor/weapon/misc)
*/
public $item_type = ''; //basic type: armor/weapon/misc
//flags
public string $item_type = '';
// Flags
/**
* @var int
* @var int The identification flag (0 or 1)
*/
public $identified = 0;
public int $identified = 0;
/**
* @var int
* @var int The number of sockets the item has
*/
public $sockets = 0;
public int $sockets = 0;
/**
* @var int
* @var int The ear flag (0 or 1)
*/
public $ear = 0;
public int $ear = 0;
/**
* @var int
* @var int The starter flag (0 or 1)
*/
public $starter = 0;
public int $starter = 0;
/**
* @var int
* @var int The compact flag (0 or 1)
*/
public $compact = 0;
public int $compact = 0;
/**
* @var
* @var mixed The ethereal flag
*/
public $ethereal;
/**
* @var
* @var mixed The personalized flag
*/
public $personalized;
/**
* @var
* @var mixed The runeword flag
*/
public $runeword;
/**
* @var
* @var mixed The version flag
*/
public $version;
/**
* @var string
* @var string The name of the runeword
*/
public $runeword_name = '';
public string $runeword_name = '';
/**
* @var string
* @var string The title of the runes used in the runeword
*/
public $runes_title = '';
//placement
public string $runes_title = '';
// Placement
/**
* @var int
* @var int The location of the item
*/
public $location = 0;
public int $location = 0;
/**
* @var int
* @var int The body location of the item
*/
public $body = 0;
public int $body = 0;
/**
* @var int
* @var int The column location of the item
*/
public $col = 0;
public int $col = 0;
/**
* @var int
* @var int The row location of the item
*/
public $row = 0;
public int $row = 0;
/**
* @var int
* @var int The container flag (0 or 1)
*/
public $container = 0;
public int $container = 0;
/**
* @var
* @var mixed The parent flag
*/
public $parent;
/**
* @var
* @var mixed The storage flag
*/
public $storage;
/**
* @var
* @var mixed The body part flag
*/
public $bodypart;
/**
* @var int
* @var int The height of the inventory
*/
public $invH = 0;
public int $invH = 0;
/**
* @var int
* @var int The width of the inventory
*/
public $invW = 0;
public int $invW = 0;
/**
* @var int
* @var int The number of rows in the belt
*/
public $beltrows = 1;
//features
public int $beltrows = 1;
// Features
/**
* @var string
* @var string The item code (3-letter code from txt)
*/
public $item_code = ''; //3 letter code from txt
public string $item_code = '';
/**
* @var int
* @var int The number of filled sockets
*/
public $SocketsFilled = 0;
public int $SocketsFilled = 0;
/**
* @var int
* @var int The number of sockets the item can have
*/
public $SocketsNum = 0;
public int $SocketsNum = 0;
/**
* @var bool
* @var bool The socketable flag (gem, rune, jewel)
*/
public $socketable = false; //gem, rune, jewel
public bool $socketable = false;
/**
* @var string
* @var string The fingerprint of the item
*/
public $fingerprint = '';
public string $fingerprint = '';
/**
* @var int
* @var int The item level
*/
public $itemlvl = 0; //item level
public int $itemlvl = 0;
/**
* @var int
* @var int The quality of the item
*/
public $quality = 0;
public int $quality = 0;
/**
* @var bool
* @var bool The charm flag (true or false)
*/
public $isCharm = false;
public bool $isCharm = false;
/**
* @var bool
* @var bool The jewel flag (true or false)
*/
public $isJewel = false;
public bool $isJewel = false;
/**
* @var string
* @var string The rank of the magic item (normal/magic/rare/crafted/set/unique)
*/
public $magic_rank = 'Normal'; //normal/magic/rare/crafted/set/unique
public string $magic_rank = 'Normal';
/**
* @var int
* @var int The set item ID from txt
*/
public $set_id = 0; //set item id from txt
public int $set_id = 0;
/**
* @var string
* @var string The set item
*/
public $set_item = '';
public string $set_item = '';
/**
* @var int
* @var int The set name (if it is a set item)
*/
public $set_name = 0; //set name, if it is set item,
public int $set_name = 0;
/**
* @var string
* @var string The name of the person (ear's name)
*/
public $personname = '';
public string $personname = '';
/**
* @var int
* @var int The quest difficulty (-1 if not applicable)
*/
public $questdif = -1;
public int $questdif = -1;
/**
* @var
* @var mixed The gold
*/
public $gold;
/**
* @var string
*/
public $GUID = '';
/**
* @var int
*/
public $defense = 0;
/**
* @var int
*/
public $mindam = 0;
/**
* @var int
*/
public $maxdam = 0;
/**
* @var int
*/
public $mindam2 = 0;
/**
* @var int
*/
public $maxdam2 = 0;
/**
* @var int
*/
public $mindammi = 0;
/**
* @var int
*/
public $maxdammi = 0;
/**
* @var int
*/
public $MaxDur = 0;
/**
* @var int
*/
public $CurDur = 0;
/**
* @var int
*/
public $reqlvl = 0;
/**
* @var int
*/
public $reqstr = 0;
/**
* @var int
*/
public $reqdex = 0;
/**
* @var int
*/
public $speed = 0;
/**
* @var int
*/
public $throwing = 0;
/**
* @var int
*/
public $stackable = 0;
/**
* @var string
*/
public $charName = ''; //ear's name
/**
* @var
*/
public $gfx; //graphic file name
/**
* @var int
*/
public $baseTrans = -1; //transform indexes for colour remap base item
/**
* @var int
*/
public $magicTrans = -1; //transform indexes for colour remap magic item
/**
* @var
*/
public $type; //type column from txt
/**
* @var string
*/
public $spelldesc = ''; //desc for potions
/**
* @var
*/
public $ditem; //link to item properties from txt
//mods
/**
* @var int
*/
public $dammult = 100; //damage multiply
/**
* @var int
*/
public $damminadd = 0; //damage add
/**
* @var int
*/
public $dammaxadd = 0; //damage add
/**
* @var int
*/
public $defmult = 100; //defense multiply
/**
* @var int
*/
public $defadd = 0; //defense multiply
/**
* @var int[]
*/
public $resist = array(0, 0, 0, 0, 0, 0); //phy, mag, fire, light, cold, poison
/**
* @var int[]
*/
public $attributes = array(0, 0, 0, 0); //str, dex, vit, ene
//arrays
/**
* @var string The global unique identifier (GUID) of the item
*/
public string $GUID = '';
//socketed items, collected in above function,
//because item has only data for itselt, and
//gems/runes/jewels are standalone
/**
* @var array
* @var int The defense value of the item
*/
public $SocketItems = array();
public int $defense = 0;
/**
* @var array
* @var int The minimum damage of the item
*/
public $properties = array(); //item variable properties
public int $mindam = 0;
/**
* @var array
* @var int The maximum damage of the item
*/
public $propids = array(); //properties ids list
public int $maxdam = 0;
/**
* @var int The second minimum damage of the item
*/
public int $mindam2 = 0;
/**
* @var int The second maximum damage of the item
*/
public int $maxdam2 = 0;
/**
* @var int The minimum missile damage of the item
*/
public int $mindammi = 0;
/**
* @var int The maximum missile damage of the item
*/
public int $maxdammi = 0;
/**
* @var int The maximum durability of the item
*/
public int $MaxDur = 0;
/**
* @var int The current durability of the item
*/
public int $CurDur = 0;
/**
* @var int The required level to use the item
*/
public int $reqlvl = 0;
/**
* @var int The required strength to use the item
*/
public int $reqstr = 0;
/**
* @var int The required dexterity to use the item
*/
public int $reqdex = 0;
/**
* @var int The speed of the item
*/
public int $speed = 0;
/**
* @var int The throwing value of the item
*/
public int $throwing = 0;
/**
* @var int The stackable value of the item
*/
public int $stackable = 0;
/**
* @var string The character name (ear's name)
*/
public string $charName = '';
/**
* @var mixed The graphic file name
*/
public $gfx;
/**
* @var int The transform indexes for color remap base item (-1 if not applicable)
*/
public int $baseTrans = -1;
/**
* @var int The transform indexes for color remap magic item (-1 if not applicable)
*/
public int $magicTrans = -1;
/**
* @var mixed The type column from txt
*/
public $type;
/**
* @var string The spell description for potions
*/
public string $spelldesc = '';
/**
* @var mixed The link to item properties from txt
*/
public $ditem;
/**
* @var int The damage multiplier of the item
*/
public int $dammult = 100;
/**
* @var int The minimum damage addition of the item
*/
public int $damminadd = 0;
/**
* @var int The maximum damage addition of the item
*/
public int $dammaxadd = 0;
/**
* @var int The defense multiplier of the item
*/
public int $defmult = 100;
/**
* @var int The defense addition of the item
*/
public int $defadd = 0;
/**
* @var int[] The resistances of the item (phy, mag, fire, light, cold, poison)
*/
public array $resist = [0, 0, 0, 0, 0, 0];
/**
* @var int[] The attributes of the item (str, dex, vit, ene)
*/
public array $attributes = [0, 0, 0, 0];
/**
* @var array The socketed items collected in the above function because the item has only data for itself and gems/runes/jewels are standalone
*/
public array $SocketItems = [];
/**
* @var array The item variable properties
*/
public array $properties = [];
/**
* @var array The properties IDs list
*/
public array $propids = [];
/**
* @param string $bits
* D2CharItem constructor.
*
* @param string $bits The item bits
*/
public function __construct(string $bits){
if ($bits == '') return false;
public function __construct(string $bits)
{
if ($bits === '') {
return false;
}
$this->bits = $bits;
return $this->parseItem();
}
/**
* Parses the item.
*
* @return void
*/
public function parseItem(){
public function parseItem()
{
// Implementation goes here
}
}