mirror of
https://gitlab.com/hashborgir/d2tools.git
synced 2024-11-30 04:26:03 +00:00
Better stats editor
This commit is contained in:
parent
9c8f50f1f7
commit
e68dde2f23
@ -43,7 +43,7 @@ foreach ($ISCData as $k => $v) {
|
|||||||
//$filePath = "D:\Diablo II\MODS\MedianXL2012\save\Test.d2s";
|
//$filePath = "D:\Diablo II\MODS\MedianXL2012\save\Test.d2s";
|
||||||
|
|
||||||
|
|
||||||
$filePath = "Sorc.d2s";
|
$filePath = "Test.d2s";
|
||||||
$char = new D2Char($filePath);
|
$char = new D2Char($filePath);
|
||||||
|
|
||||||
//$char->setChar("CharacterStatus", "Died", 0);
|
//$char->setChar("CharacterStatus", "Died", 0);
|
||||||
@ -51,13 +51,14 @@ $char = new D2Char($filePath);
|
|||||||
//$char->setChar("CharacterStatus", "Expansion", 1);
|
//$char->setChar("CharacterStatus", "Expansion", 1);
|
||||||
//$char->setChar("LeftmousebuttonskillID", 223);
|
//$char->setChar("LeftmousebuttonskillID", 223);
|
||||||
|
|
||||||
$char->setAllSkills(1);
|
$char->setAllSkills(0);
|
||||||
//$char->setSkill(3, 20);
|
//$char->setSkill(3, 20);
|
||||||
//$char->setChar("CharacterClass", "Necromancer"); // 127
|
//$char->setChar("CharacterClass", "Necromancer"); // 127
|
||||||
//$char->setChar("CharacterProgression", 1); // 0 in normal, 1 finished normal, 2 finished nm, 3 finished hell
|
//$char->setChar("CharacterProgression", 1); // 0 in normal, 1 finished normal, 2 finished nm, 3 finished hell
|
||||||
|
|
||||||
//$char->setChar("CharacterStatus", "Died", 1);
|
//$char->setChar("CharacterStatus", "Died", 1);
|
||||||
//$char->setChar("CharacterLevel", 99);
|
$char->setChar("CharacterLevel", 1);
|
||||||
|
$char->setStat("newskills", 99);
|
||||||
//$char->setStat("strength", 270);
|
//$char->setStat("strength", 270);
|
||||||
//$char->setStat("energy", 270);
|
//$char->setStat("energy", 270);
|
||||||
//$char->setStat("dexterity", 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);
|
$char = new D2Char($filePath);
|
||||||
|
|
||||||
var_dump($char->cData['items']);
|
var_dump($char->cData);
|
||||||
//var_dump($char->cData['stats']);
|
//var_dump($char->cData['stats']);
|
||||||
|
@ -400,7 +400,7 @@ $(document).ready(function () {
|
|||||||
return "/saveCharacter.php?cmd=" + cmd + "&name=" + name + "&value=" + value + "&filePath=" + filePath;
|
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 name = $(this).attr("name");
|
||||||
var newValue = $(this).val();
|
var newValue = $(this).val();
|
||||||
|
|
||||||
|
@ -115,66 +115,7 @@ switch ($cmd) {
|
|||||||
echo "Handling skills command - Skill: $name, Value: $value, File Path: $filePath";
|
echo "Handling skills command - Skill: $name, Value: $value, File Path: $filePath";
|
||||||
break;
|
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":
|
case "Died":
|
||||||
$char->setChar("CharacterStatus", "Died", $value); // Set the "CharacterStatusDied" value to the provided value
|
$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
|
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);
|
fclose($fp);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
// stats commands
|
||||||
|
case "stats":
|
||||||
|
echo "Handling $name command. New value: $value";
|
||||||
|
$char->setStat($name, $value);
|
||||||
|
break;
|
||||||
|
|
||||||
// default command
|
// default command
|
||||||
default:
|
default:
|
||||||
// Handle unknown command
|
// Handle unknown command
|
||||||
|
@ -20,12 +20,32 @@ EOT;
|
|||||||
|
|
||||||
<div class="tab-content" id="CTabContent">
|
<div class="tab-content" id="CTabContent">
|
||||||
<?php
|
<?php
|
||||||
|
session_start();
|
||||||
|
ob_start();
|
||||||
|
|
||||||
|
require_once './config.php';
|
||||||
|
require_once './_pdo.php';
|
||||||
|
|
||||||
|
require_once './src/D2Functions.php';
|
||||||
|
require_once './src/D2ByteReader.php';
|
||||||
|
require_once './src/D2BitReader.php';
|
||||||
|
require_once './src/D2Item.php';
|
||||||
|
require_once './src/D2Char.php';
|
||||||
|
|
||||||
|
error_reporting(E_ERROR | E_PARSE);
|
||||||
|
set_time_limit(-1);
|
||||||
|
ini_set('max_input_time', '-1');
|
||||||
|
ini_set('max_execution_time', '0');
|
||||||
|
|
||||||
|
define('DB_FILE', $_SESSION['modname'] . ".db");
|
||||||
|
PDO_Connect("sqlite:" . DB_FILE);
|
||||||
|
|
||||||
foreach ($charData as $c) {
|
foreach ($charData as $c) {
|
||||||
|
|
||||||
$quests = '';
|
$quests = '';
|
||||||
$accordionCounter = 1;
|
$accordionCounter = 1;
|
||||||
|
|
||||||
foreach ($c->cData['Quests'] as $quest) {
|
foreach ($c->cData['Quests'] as $quest) {
|
||||||
foreach ($quest as $difficulty => $q) {
|
foreach ($quest as $difficulty => $q) {
|
||||||
$isExpanded = ($accordionCounter === 1) ? 'show' : '';
|
$isExpanded = ($accordionCounter === 1) ? 'show' : '';
|
||||||
$collapseId = 'collapseq-' . $accordionCounter;
|
$collapseId = 'collapseq-' . $accordionCounter;
|
||||||
@ -58,7 +78,7 @@ foreach ($c->cData['Quests'] as $quest) {
|
|||||||
$quests .= "</div>";
|
$quests .= "</div>";
|
||||||
$accordionCounter++;
|
$accordionCounter++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$wps = '';
|
$wps = '';
|
||||||
//$wps .= "<input type='radio' value='1' name='wp_all' id='wp_all'>";
|
//$wps .= "<input type='radio' value='1' name='wp_all' id='wp_all'>";
|
||||||
@ -66,10 +86,10 @@ foreach ($c->cData['Quests'] as $quest) {
|
|||||||
//$wps .= "<input type='radio' value='0' name='wp_all' id='wp_all_off'>";
|
//$wps .= "<input type='radio' value='0' name='wp_all' id='wp_all_off'>";
|
||||||
//$wps .= "<label style='font-size: 1.3em; color: red;' for='wp_all_off'>Disable All Waypoints</label><hr>";
|
//$wps .= "<label style='font-size: 1.3em; color: red;' for='wp_all_off'>Disable All Waypoints</label><hr>";
|
||||||
|
|
||||||
$wps = '';
|
$wps = '';
|
||||||
$accordionCounter = 1;
|
$accordionCounter = 1;
|
||||||
|
|
||||||
foreach ($c->cData['Waypoints'] as $diff => $waypoints) {
|
foreach ($c->cData['Waypoints'] as $diff => $waypoints) {
|
||||||
$isExpanded = ($accordionCounter === 1) ? 'show' : '';
|
$isExpanded = ($accordionCounter === 1) ? 'show' : '';
|
||||||
$collapseId = 'collapsewps-' . $accordionCounter;
|
$collapseId = 'collapsewps-' . $accordionCounter;
|
||||||
$headingId = 'headingwps-' . $accordionCounter;
|
$headingId = 'headingwps-' . $accordionCounter;
|
||||||
@ -103,7 +123,7 @@ foreach ($c->cData['Waypoints'] as $diff => $waypoints) {
|
|||||||
|
|
||||||
$wps .= "</div>";
|
$wps .= "</div>";
|
||||||
$accordionCounter++;
|
$accordionCounter++;
|
||||||
}
|
}
|
||||||
|
|
||||||
$classOptions = [
|
$classOptions = [
|
||||||
'Amazon', 'Assassin', 'Barbarian', 'Druid', 'Paladin', 'Necromancer', 'Sorceress'
|
'Amazon', 'Assassin', 'Barbarian', 'Druid', 'Paladin', 'Necromancer', 'Sorceress'
|
||||||
@ -152,18 +172,18 @@ foreach ($c->cData['Waypoints'] as $diff => $waypoints) {
|
|||||||
// $skillcounter++;
|
// $skillcounter++;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
$skillsByPage = array();
|
$skillsByPage = array();
|
||||||
foreach ($c->cData['skills']['skills'] as $skNum => $skill) {
|
foreach ($c->cData['skills']['skills'] as $skNum => $skill) {
|
||||||
$page = $skill['page'];
|
$page = $skill['page'];
|
||||||
if (!isset($skillsByPage[$page])) {
|
if (!isset($skillsByPage[$page])) {
|
||||||
$skillsByPage[$page] = array();
|
$skillsByPage[$page] = array();
|
||||||
}
|
}
|
||||||
$skillsByPage[$page][$skNum] = $skill;
|
$skillsByPage[$page][$skNum] = $skill;
|
||||||
}
|
}
|
||||||
|
|
||||||
$skillDivs = '';
|
$skillDivs = '';
|
||||||
$accordionCounter = 1;
|
$accordionCounter = 1;
|
||||||
foreach ($skillsByPage as $page => $skills) {
|
foreach ($skillsByPage as $page => $skills) {
|
||||||
$isExpanded = ($accordionCounter === 1) ? 'show' : '';
|
$isExpanded = ($accordionCounter === 1) ? 'show' : '';
|
||||||
$collapseId = 'collapseskills-' . $accordionCounter;
|
$collapseId = 'collapseskills-' . $accordionCounter;
|
||||||
$headingId = 'headingskills-' . $accordionCounter;
|
$headingId = 'headingskills-' . $accordionCounter;
|
||||||
@ -186,7 +206,7 @@ foreach ($skillsByPage as $page => $skills) {
|
|||||||
|
|
||||||
$skillDivs .= '</div>';
|
$skillDivs .= '</div>';
|
||||||
$accordionCounter++;
|
$accordionCounter++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$statuses = [
|
$statuses = [
|
||||||
@ -208,6 +228,41 @@ foreach ($skillsByPage as $page => $skills) {
|
|||||||
HTML;
|
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 .= '<div class="stats" id="statsdiv" style="border:1px solid #ccc;"><input cmd="stats" type="number" id="' . $stat . '" name="' . $stat . '" max="' . $maxValue . '" value="' . $defaultValue . '">';
|
||||||
|
|
||||||
|
// Create an HTML label for the stat
|
||||||
|
$stats .= '<label for="' . $stat . '">' . ucfirst($stat) . ':<br> Max Value - ' . $maxValue . '</label><br></div>';
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Create a new array to store objects sorted by container
|
// Create a new array to store objects sorted by container
|
||||||
$sortedArray = [];
|
$sortedArray = [];
|
||||||
// Iterate over the original array
|
// Iterate over the original array
|
||||||
@ -234,11 +289,13 @@ HTML;
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
$items = "<div class='accordion' id='accordionExample'>";
|
$items = "<div class='accordion' id='accordionExample'>";
|
||||||
|
|
||||||
foreach ($sortedArray as $index => $container) {
|
foreach ($sortedArray as $index => $container) {
|
||||||
$containerId = "container_" . $index;
|
$containerId = "container_" . $index;
|
||||||
|
|
||||||
|
if (empty($index)) $index = "Socketed";
|
||||||
|
|
||||||
// Create accordion card for the container
|
// Create accordion card for the container
|
||||||
$items .= "<div class='card'>";
|
$items .= "<div class='card'>";
|
||||||
$items .= "<div class='card-header' id='{$containerId}-heading'>";
|
$items .= "<div class='card-header' id='{$containerId}-heading'>";
|
||||||
@ -280,10 +337,9 @@ foreach ($sortedArray as $index => $container) {
|
|||||||
$items .= "</div>";
|
$items .= "</div>";
|
||||||
|
|
||||||
$items .= "</div>";
|
$items .= "</div>";
|
||||||
}
|
}
|
||||||
|
|
||||||
$items .= "</div>";
|
|
||||||
|
|
||||||
|
$items .= "</div>";
|
||||||
|
|
||||||
$tabContent .= <<<EOT
|
$tabContent .= <<<EOT
|
||||||
<div style="background: white; margin-top: 10px;" class="tab-pane fade" id="{$c->cData['CharacterName']}" role="tabpanel" aria-labelledby="{$c->cData['CharacterName']}-tab">
|
<div style="background: white; margin-top: 10px;" class="tab-pane fade" id="{$c->cData['CharacterName']}" role="tabpanel" aria-labelledby="{$c->cData['CharacterName']}-tab">
|
||||||
@ -315,7 +371,7 @@ $checkboxes
|
|||||||
|
|
||||||
|
|
||||||
<hr>
|
<hr>
|
||||||
<!-- STATS -->
|
<!-- STATS
|
||||||
<div class="stats">
|
<div class="stats">
|
||||||
<div class="form-row" style="background: #eed;">
|
<div class="form-row" style="background: #eed;">
|
||||||
<div class="form-group col-md-3">
|
<div class="form-group col-md-3">
|
||||||
@ -365,8 +421,9 @@ $checkboxes
|
|||||||
<input type="number" class="form-control" id="maxstamina" name="maxstamina" min="1" max="2097151" value="{$c->cData['stats']['maxstamina']}" required>
|
<input type="number" class="form-control" id="maxstamina" name="maxstamina" min="1" max="2097151" value="{$c->cData['stats']['maxstamina']}" required>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>-->
|
||||||
<hr>
|
<hr>
|
||||||
|
$stats
|
||||||
<div style="background:;">
|
<div style="background:;">
|
||||||
<h3 style="text-align: center">Skills</h3>
|
<h3 style="text-align: center">Skills</h3>
|
||||||
<div class="accordion" id="accordionExample">
|
<div class="accordion" id="accordionExample">
|
||||||
|
Loading…
Reference in New Issue
Block a user