diff --git a/CharEditor.php b/CharEditor.php
index 24a0a13..c28f1e4 100644
--- a/CharEditor.php
+++ b/CharEditor.php
@@ -43,7 +43,7 @@ foreach ($ISCData as $k => $v) {
//$filePath = "D:\Diablo II\MODS\MedianXL2012\save\Test.d2s";
-$filePath = "Sorc.d2s";
+$filePath = "Test.d2s";
$char = new D2Char($filePath);
//$char->setChar("CharacterStatus", "Died", 0);
@@ -51,13 +51,14 @@ $char = new D2Char($filePath);
//$char->setChar("CharacterStatus", "Expansion", 1);
//$char->setChar("LeftmousebuttonskillID", 223);
-$char->setAllSkills(1);
+$char->setAllSkills(0);
//$char->setSkill(3, 20);
//$char->setChar("CharacterClass", "Necromancer"); // 127
//$char->setChar("CharacterProgression", 1); // 0 in normal, 1 finished normal, 2 finished nm, 3 finished hell
//$char->setChar("CharacterStatus", "Died", 1);
-//$char->setChar("CharacterLevel", 99);
+$char->setChar("CharacterLevel", 1);
+$char->setStat("newskills", 99);
//$char->setStat("strength", 270);
//$char->setStat("energy", 270);
//$char->setStat("dexterity", 270);
@@ -88,5 +89,5 @@ unset($char); // destroy $char so we can read it again after writing to it to ge
$char = new D2Char($filePath);
-var_dump($char->cData['items']);
+var_dump($char->cData);
//var_dump($char->cData['stats']);
diff --git a/res/app.js b/res/app.js
index 5688d19..0146d95 100755
--- a/res/app.js
+++ b/res/app.js
@@ -400,7 +400,7 @@ $(document).ready(function () {
return "/saveCharacter.php?cmd=" + cmd + "&name=" + name + "&value=" + value + "&filePath=" + filePath;
}
- $(".charform input[name='Difficulty'], .charform .skill, #CharacterName, #CharacterClass, #CharacterLevel, #CharacterClass, .stats input, .form-check-input").change(function () {
+ $(".charform input[name='Difficulty'], .charform .skill, #CharacterName, #CharacterClass, #CharacterLevel, #CharacterClass, .stats input, .form-check-input, #statsdiv input").change(function () {
var name = $(this).attr("name");
var newValue = $(this).val();
diff --git a/saveCharacter.php b/saveCharacter.php
index 6cc1f3c..a9de87b 100644
--- a/saveCharacter.php
+++ b/saveCharacter.php
@@ -115,66 +115,7 @@ switch ($cmd) {
echo "Handling skills command - Skill: $name, Value: $value, File Path: $filePath";
break;
- // stats
-// Handle strength command
- case "strength":
- $char->setStat("strength", $value); // Set the "strength" stat to the provided value
- echo "Handling strength command - Value: $value, File Path: $filePath"; // Display a message indicating the handling of the strength command
- break;
-
-// Handle dexterity command
- case "dexterity":
- $char->setStat("dexterity", $value); // Set the "dexterity" stat to the provided value
- echo "Handling dexterity command - Value: $value, File Path: $filePath"; // Display a message indicating the handling of the dexterity command
- break;
-
-// Handle vitality command
- case "vitality":
- $char->setStat("vitality", $value); // Set the "vitality" stat to the provided value
- echo "Handling vitality command - Value: $value, File Path: $filePath"; // Display a message indicating the handling of the vitality command
- break;
-
-// Handle energy command
- case "energy":
- $char->setStat("energy", $value); // Set the "energy" stat to the provided value
- echo "Handling energy command - Value: $value, File Path: $filePath"; // Display a message indicating the handling of the energy command
- break;
-
-// Handle hitpoints command
- case "hitpoints":
- $char->setStat("hitpoints", $value); // Set the "hitpoints" stat to the provided value
- echo "Handling hitpoints command - Value: $value, File Path: $filePath"; // Display a message indicating the handling of the hitpoints command
- break;
-
-// Handle maxhp command
- case "maxhp":
- $char->setStat("maxhp", $value); // Set the "maxhp" stat to the provided value
- echo "Handling maxhp command - Value: $value, File Path: $filePath"; // Display a message indicating the handling of the maxhp command
- break;
-
-// Handle mana command
- case "mana":
- $char->setStat("mana", $value); // Set the "mana" stat to the provided value
- echo "Handling mana command - Value: $value, File Path: $filePath"; // Display a message indicating the handling of the mana command
- break;
-
-// Handle maxmana command
- case "maxmana":
- $char->setStat("maxmana", $value); // Set the "maxmana" stat to the provided value
- echo "Handling maxmana command - Value: $value, File Path: $filePath"; // Display a message indicating the handling of the maxmana command
- break;
-
-// Handle stamina command
- case "stamina":
- $char->setStat("stamina", $value); // Set the "stamina" stat to the provided value
- echo "Handling stamina command - Value: $value, File Path: $filePath"; // Display a message indicating the handling of the stamina command
- break;
-
-// Handle maxstamina command
- case "maxstamina":
- $char->setStat("maxstamina", $value); // Set the "maxstamina" stat to the provided value
- echo "Handling maxstamina command - Value: $value, File Path: $filePath"; // Display a message indicating the handling of the maxstamina command
- break;
+
case "Died":
$char->setChar("CharacterStatus", "Died", $value); // Set the "CharacterStatusDied" value to the provided value
echo "Handling Died command - Value: $value, File Path: $filePath"; // Display a message indicating the handling of the Died command
@@ -317,6 +258,12 @@ switch ($cmd) {
fclose($fp);
break;
+ // stats commands
+ case "stats":
+ echo "Handling $name command. New value: $value";
+ $char->setStat($name, $value);
+ break;
+
// default command
default:
// Handle unknown command
diff --git a/src/D2Char.php b/src/D2Char.php
index fe62d28..fa10e3f 100644
--- a/src/D2Char.php
+++ b/src/D2Char.php
@@ -334,7 +334,7 @@ WHERE sk.charclass = '$class' AND sk.skilldesc != 'dummy'";
$len = $if - $gf;
$stats = new D2BitReader($this->ByteReader->toBits($this->ByteReader->readh($gf, $len)));
- $bits = $stats->getBits();
+ $bits = $stats->getBits();
$bytes = $this->ByteReader->toBytes($bits);
diff --git a/src/tabs/Chars.php b/src/tabs/Chars.php
index 6a98cca..fd8131f 100644
--- a/src/tabs/Chars.php
+++ b/src/tabs/Chars.php
@@ -20,90 +20,110 @@ EOT;
cData['Quests'] as $quest) {
- foreach ($quest as $difficulty => $q) {
- $isExpanded = ($accordionCounter === 1) ? 'show' : '';
- $collapseId = 'collapseq-' . $accordionCounter;
- $headingId = 'headingq-' . $accordionCounter;
+ foreach ($c->cData['Quests'] as $quest) {
+ foreach ($quest as $difficulty => $q) {
+ $isExpanded = ($accordionCounter === 1) ? 'show' : '';
+ $collapseId = 'collapseq-' . $accordionCounter;
+ $headingId = 'headingq-' . $accordionCounter;
- $quests .= "
";
- $quests .= "";
+ $quests .= "
";
+ $quests .= "";
- $quests .= "
";
- $quests .= "
";
+ $quests .= "
";
+ $quests .= "
";
- foreach ($q as $k => $v) {
- $kD = str_replace("_", " ", $k);
- $kD = str_replace([" NM", " Hell"], "", $kD);
- $checked = ($v == 1) ? 'checked' : '';
+ foreach ($q as $k => $v) {
+ $kD = str_replace("_", " ", $k);
+ $kD = str_replace([" NM", " Hell"], "", $kD);
+ $checked = ($v == 1) ? 'checked' : '';
- $quests .= "
";
- $quests .= " ";
- $quests .= "{$kD} ";
- $quests .= "
";
+ $quests .= "
";
+ $quests .= " ";
+ $quests .= "{$kD} ";
+ $quests .= "
";
+ }
+
+ $quests .= "
";
+ $quests .= "
";
+
+ $quests .= "
";
+ $accordionCounter++;
+ }
}
- $quests .= "
";
- $quests .= "
";
-
- $quests .= "
";
- $accordionCounter++;
- }
-}
-
$wps = '';
//$wps .= "
";
//$wps .= "
Enable All Waypoints ";
//$wps .= "
";
//$wps .= "
Disable All Waypoints ";
-$wps = '';
-$accordionCounter = 1;
+ $wps = '';
+ $accordionCounter = 1;
-foreach ($c->cData['Waypoints'] as $diff => $waypoints) {
- $isExpanded = ($accordionCounter === 1) ? 'show' : '';
- $collapseId = 'collapsewps-' . $accordionCounter;
- $headingId = 'headingwps-' . $accordionCounter;
+ foreach ($c->cData['Waypoints'] as $diff => $waypoints) {
+ $isExpanded = ($accordionCounter === 1) ? 'show' : '';
+ $collapseId = 'collapsewps-' . $accordionCounter;
+ $headingId = 'headingwps-' . $accordionCounter;
- $wps .= "
";
- $wps .= "";
+ $wps .= "
";
+ $wps .= "";
- $wps .= "
";
- $wps .= "
";
+ $wps .= "
";
+ $wps .= "
";
- array_pop($waypoints);
- $wp_count = 0;
- foreach ($waypoints as $k => $v) {
- $kD = str_replace("_", " ", $k);
- $kD = str_replace([" NM", " Hell"], "", $kD);
- $checked = ($v == 1 && $k != '') ? 'checked ' : '';
+ array_pop($waypoints);
+ $wp_count = 0;
+ foreach ($waypoints as $k => $v) {
+ $kD = str_replace("_", " ", $k);
+ $kD = str_replace([" NM", " Hell"], "", $kD);
+ $checked = ($v == 1 && $k != '') ? 'checked ' : '';
- $wps .= "
";
- $wps .= " ";
- $wps .= "{$kD} ";
- $wps .= "
";
- $wp_count++;
- }
+ $wps .= "
";
+ $wps .= " ";
+ $wps .= "{$kD} ";
+ $wps .= "
";
+ $wp_count++;
+ }
- $wps .= "
";
- $wps .= "
";
+ $wps .= "
";
+ $wps .= "
";
- $wps .= "
";
- $accordionCounter++;
-}
+ $wps .= "
";
+ $accordionCounter++;
+ }
$classOptions = [
'Amazon', 'Assassin', 'Barbarian', 'Druid', 'Paladin', 'Necromancer', 'Sorceress'
@@ -152,41 +172,41 @@ foreach ($c->cData['Waypoints'] as $diff => $waypoints) {
// $skillcounter++;
// }
-$skillsByPage = array();
-foreach ($c->cData['skills']['skills'] as $skNum => $skill) {
- $page = $skill['page'];
- if (!isset($skillsByPage[$page])) {
- $skillsByPage[$page] = array();
- }
- $skillsByPage[$page][$skNum] = $skill;
-}
+ $skillsByPage = array();
+ foreach ($c->cData['skills']['skills'] as $skNum => $skill) {
+ $page = $skill['page'];
+ if (!isset($skillsByPage[$page])) {
+ $skillsByPage[$page] = array();
+ }
+ $skillsByPage[$page][$skNum] = $skill;
+ }
-$skillDivs = '';
-$accordionCounter = 1;
-foreach ($skillsByPage as $page => $skills) {
- $isExpanded = ($accordionCounter === 1) ? 'show' : '';
- $collapseId = 'collapseskills-' . $accordionCounter;
- $headingId = 'headingskills-' . $accordionCounter;
+ $skillDivs = '';
+ $accordionCounter = 1;
+ foreach ($skillsByPage as $page => $skills) {
+ $isExpanded = ($accordionCounter === 1) ? 'show' : '';
+ $collapseId = 'collapseskills-' . $accordionCounter;
+ $headingId = 'headingskills-' . $accordionCounter;
- $skillDivs .= '
';
- $skillDivs .= '';
+ $skillDivs .= '
';
+ $skillDivs .= '';
- $skillDivs .= '
';
- $skillDivs .= '
';
- foreach ($skills as $skillNumber => $skill) {
- $skillNumber++;
- $skillDivs .= " : {$skill['skill']}
";
- }
- $skillDivs .= '';
- $skillDivs .= '
';
+ $skillDivs .= '
';
+ $skillDivs .= '
';
+ foreach ($skills as $skillNumber => $skill) {
+ $skillNumber++;
+ $skillDivs .= " : {$skill['skill']}
";
+ }
+ $skillDivs .= '';
+ $skillDivs .= '
';
- $skillDivs .= '
';
- $accordionCounter++;
-}
+ $skillDivs .= '
';
+ $accordionCounter++;
+ }
$statuses = [
@@ -202,12 +222,47 @@ foreach ($skillsByPage as $page => $skills) {
HTML;
}
+ $sql = "SELECT ID,Stat,CSvBits FROM itemstatcost WHERE Saved=1";
+ $ISCData = PDO_FetchAll($sql);
+
+ foreach ($ISCData as $k) {
+ $ISC[$k["Stat"]] = $k['CSvBits'];
+ }
+
+ // stats
+ $cDataStats = $c->cData["stats"];
+ $commonKeys = array_intersect_key($cDataStats, $ISC);
+
+ foreach ($commonKeys as $key => $value) {
+ $cDataStats[$key] = $ISC[$key];
+ }
+
+ $stats = '';
+
+ foreach ($cDataStats as $stat => $bits) {
+ // Calculate the maximum value for the number of bits
+ $maxValue = pow(2, $bits) - 1;
+
+ // Get the default value from $c->cData['stats']
+ $defaultValue = isset($c->cData['stats'][$stat]) ? $c->cData['stats'][$stat] : 0;
+
+ // Create an HTML input for the stat
+ $stats .= '
';
+
+ // Create an HTML label for the stat
+ $stats .= '' . ucfirst($stat) . ': Max Value - ' . $maxValue . '
';
+ }
+
+
+
+
+
// Create a new array to store objects sorted by container
$sortedArray = [];
// Iterate over the original array
@@ -232,58 +287,59 @@ HTML;
});
}
-
-$items = "
";
-foreach ($sortedArray as $index => $container) {
- $containerId = "container_" . $index;
+ $items = "
";
- // Create accordion card for the container
- $items .= "
";
- $items .= "";
+ foreach ($sortedArray as $index => $container) {
+ $containerId = "container_" . $index;
- // Create accordion content for the container
- $isExpanded = ($index === 0) ? "show" : "";
- $items .= "
";
- $items .= "
";
- $items .= "
";
+ if (empty($index)) $index = "Socketed";
+
+ // Create accordion card for the container
+ $items .= "
";
+ $items .= "";
- foreach ($container as $item) {
- $i = array_filter($item->iData);
+ // Create accordion content for the container
+ $isExpanded = ($index === 0) ? "show" : "";
+ $items .= "
";
+ $items .= "
";
+ $items .= "
";
+
+ foreach ($container as $item) {
+ $i = array_filter($item->iData);
+
+ $items .= "
";
+ $items .= "
";
+ $items .= "{$i['basename']} ";
+ $items .= " ";
+ $items .= "
";
+ $items .= "
";
+ $items .= "Code: {$i['code']} ";
+ $items .= "Socketed: {$i['gems_in']} ";
+ $items .= "Item Level: {$i['ilvl']} ";
+ $items .= "Identified: {$i['identified']} ";
+ $items .= "Starting Item: {$i['startingItem']} ";
+ $items .= "Ethereal: {$i['ethereal']} ";
+ $items .= "Quality: {$i['iquality']} ";
+ $items .= "Container: {$i['container']} ";
+ $items .= "Runeword: {$i['runeword']} ";
+ $items .= " ";
+ $items .= "
";
+ }
+
+ $items .= "
";
+ $items .= "
";
+ $items .= "
";
+
+ $items .= "
";
+ }
- $items .= "
";
- $items .= "
";
- $items .= "{$i['basename']} ";
- $items .= " ";
- $items .= "
";
- $items .= "
";
- $items .= "Code: {$i['code']} ";
- $items .= "Socketed: {$i['gems_in']} ";
- $items .= "Item Level: {$i['ilvl']} ";
- $items .= "Identified: {$i['identified']} ";
- $items .= "Starting Item: {$i['startingItem']} ";
- $items .= "Ethereal: {$i['ethereal']} ";
- $items .= "Quality: {$i['iquality']} ";
- $items .= "Container: {$i['container']} ";
- $items .= "Runeword: {$i['runeword']} ";
- $items .= " ";
$items .= "
";
- }
-
- $items .= "
";
- $items .= "
";
- $items .= "
";
-
- $items .= "
";
-}
-
-$items .= "
";
-
$tabContent .= <<
@@ -303,10 +359,10 @@ $items .= " ";
Difficulty:
- $radio
+ $radio
-
+