From 2a8ba701a73727036143ae5747a87939fa647027 Mon Sep 17 00:00:00 2001 From: Hash Borgir Date: Sat, 3 Jun 2023 15:26:07 -0600 Subject: [PATCH] D2S char stats and skills tabs done --- res/app.js | 2 +- saveCharacter.php | 65 ++++++++++++++++++++++- src/tabs/Chars.php | 128 ++++++++++++++++++++++++++++++++++++++++++--- 3 files changed, 186 insertions(+), 9 deletions(-) diff --git a/res/app.js b/res/app.js index 9ba0b1f..1409ad2 100755 --- a/res/app.js +++ b/res/app.js @@ -381,7 +381,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").change(function () { + $(".charform input[name='Difficulty'], .charform .skill, #CharacterName, #CharacterClass, #CharacterLevel, #CharacterClass, .stats input").change(function () { var name = $(this).attr("name"); var newValue = $(this).val(); diff --git a/saveCharacter.php b/saveCharacter.php index 3b6be2f..32f23dd 100644 --- a/saveCharacter.php +++ b/saveCharacter.php @@ -231,13 +231,76 @@ switch ($cmd) { $char->setChar("Difficulty", $value); echo "Handling Difficulty command - Difficulty: $value, File Path: $filePath"; break; - + // skills case "skills": //var_dump($char->cData); $char->setSkill($name, $value); 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; + + // default command default: // Handle unknown command echo "Unknown command: $cmd"; diff --git a/src/tabs/Chars.php b/src/tabs/Chars.php index be2e2f2..d30d3cb 100644 --- a/src/tabs/Chars.php +++ b/src/tabs/Chars.php @@ -84,7 +84,6 @@ EOT; $radio .= "
"; } - $skills = ''; /* 'skills' => array (size=1) @@ -100,13 +99,75 @@ EOT; 'col' => int 2 'icon' => int 0 */ - $skillcounter = 1; - foreach ($c->cData['skills']['skills'] as $k => $skill) { - $skills .= ": {$skill['skill']}
"; - $skillcounter++; +// $skillcounter = 1; +// foreach ($c->cData['skills']['skills'] as $k => $skill) { +// $skills .= ": {$skill['skill']}
"; +// $skillcounter++; +// } + + +// Sort the skills array by page +usort($c->cData['skills']['skills'], function($a, $b) { + return $a['page'] <=> $b['page']; +}); + +$skills = ''; +$skillcounter = 1; +$currentPage = null; +$tabLinks = ''; +$tabContents = ''; + +foreach ($c->cData['skills']['skills'] as $k => $skill) { + // Check if the current skill is on a new page + if ($skill['page'] !== $currentPage) { + // Close the previous tab content (if any) + if ($currentPage !== null) { + $tabContents .= ""; } + // Generate tab link + $tabLinks .= ""; + // Start a new tab content for the current page + $tabContents .= "
"; + $currentPage = $skill['page']; + } + + // Append the skill to the current page content + $tabContents .= "
"; + $tabContents .= "
" . $skill['skill'] . "
"; + $tabContents .= "
"; + $tabContents .= ""; + $tabContents .= "
"; + $tabContents .= "
"; + + $skillcounter++; +} + +// Close the last tab content +if ($currentPage !== null) { + $tabContents .= "
"; +} + +// Generate the complete tabs structure +$tabs = ""; +$tabs .= "
"; +$tabs .= $tabContents; +$tabs .= "
"; + +// Combine the tabs structure and skills content +$skillsMarkup = "
$tabs
"; + + + + + + + // dump($c['Waypoints']); $tabContent .= << @@ -122,13 +183,66 @@ EOT;
- Character Level:
+ Character Level: +
+ + +
+
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ +
+
+ + +
+
+ + +
+
+

Skills

- $skills + $skillsMarkup