From 246a883f5760a30325726f858ec7307109041568 Mon Sep 17 00:00:00 2001 From: Sundog Date: Thu, 16 May 2024 09:35:44 -0400 Subject: [PATCH] adds ability to assign NPCs to POI from POI page, adds POI-NPCs page --- src/webserver/admin/index.php | 3 ++ src/webserver/admin/poi-npcs.php | 84 ++++++++++++++++++++++++++++++++ src/webserver/admin/pois.php | 12 ++++- 3 files changed, 98 insertions(+), 1 deletion(-) create mode 100644 src/webserver/admin/poi-npcs.php diff --git a/src/webserver/admin/index.php b/src/webserver/admin/index.php index ab06111..1c397b8 100644 --- a/src/webserver/admin/index.php +++ b/src/webserver/admin/index.php @@ -9,8 +9,11 @@

Tables

Players

+

Points of Interest

NPCs

+

NPCs assigned to POIs

+

Items

+ + +

Wander Admin

+ +

POI NPCs

+ +

Create New POI

+

Create New NPC

+ + + + + + + + + + +query('SELECT * FROM "POI-NPCs"'); + while ($row = $results->fetchArray()) { + $poiRes = $conn->query('SELECT * FROM POIs WHERE id = ' . $row['poi_id']); + if ($poiRes) { + $thisPoi = $poiRes->fetchArray(); + } + $npcRes = $conn->query('SELECT * FROM NPCs WHERE id = ' . $row['npc_id']); + if ($npcRes) { + $thisNpc = $npcRes->fetchArray(); + } + ?> + + + + + + + +
IDPOINPCGroup Size
'>
+ +query('SELECT * FROM NPCs WHERE id = ' . $npc_id); + if ($npcRes) { + $thisNpc = $npcRes->fetchArray(); + } + $groupSize = rand($thisNpc['minimum_group'], $thisNpc['maximum_group']); + $createQuery = 'INSERT INTO "POI-NPCs" (poi_id, npc_id, group_size) VALUES (' . $poi_id . ', ' . $npc_id . ', ' . $groupSize . ')'; + $createRes = $conn->query($createQuery); + if ($createRes) { + echo "

NPC added to POI. < View POI-NPCs

\n"; + } else { + echo "

oopsie! There was a problem adding the NPC to the POI. Check the logs!

\n"; + echo "

last error: " . $conn->lastErrorMsg() . "

\n"; + echo "

query: " . $createQuery . "

\n"; + } + break; + case 'edit': + case 'save': + default: + echo "Unknown action: " . $_GET['action']; + } + } + +?> + +

< back to Admin

+ + diff --git a/src/webserver/admin/pois.php b/src/webserver/admin/pois.php index 25840f6..65d34ae 100644 --- a/src/webserver/admin/pois.php +++ b/src/webserver/admin/pois.php @@ -25,6 +25,7 @@ Longitude Radius Map Marker +   query('SELECT * FROM POIs'); @@ -38,7 +39,16 @@ - + +
' method='POST' action='poi-npcs.php?action=create&poi_id='>' name='poi--submit' value='Assign NPC' />
+