From d86718c4201861cd984d95c97828ec86d8456def Mon Sep 17 00:00:00 2001
From: quenousimporte <quenousimporte@riseup.net>
Date: Fri, 7 Mar 2025 10:54:12 +0100
Subject: [PATCH] initial commit

---
 dq3/dq3.ts  | 155 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 dq3/dq3.txt |  73 +++++++++++++++++++++++++
 2 files changed, 228 insertions(+)
 create mode 100644 dq3/dq3.ts
 create mode 100644 dq3/dq3.txt

diff --git a/dq3/dq3.ts b/dq3/dq3.ts
new file mode 100644
index 0000000..b0e8bd5
--- /dev/null
+++ b/dq3/dq3.ts
@@ -0,0 +1,155 @@
+// deno
+import { DOMParser } from 'https://deno.land/x/deno_dom/deno-dom-wasm.ts'
+
+function getdompareser(html)
+{
+	const parser = new DOMParser();
+	return parser.parseFromString(html, "text/html");
+}
+
+function getcategory(doc, category, notes)
+{
+	const result = [];
+	const items = [...doc.getElementById(category).nextSibling.nextSibling.nextSibling.firstChild.children[0].children];
+	const header = [...items.shift().children].map(h => h.textContent);
+	items.forEach(elt => {
+		const item = {};
+		const columns = [...elt.children];
+		header.forEach( (h,i) =>
+		{
+			item[h] = columns[i].textContent;
+		});
+		item.Notes = ""
+		const sup = parseInt(item.Name.split(" ").pop());
+		if (!isNaN(sup))
+		{
+			item.Notes = notes[sup - 1];
+			item.Name = item.Name.substr(0, item.Name.length - 2)
+		}
+		item.Value = item.At || item.De;
+		result.push(item);
+	});
+	return result;
+}
+
+function getnotes(doc)
+{
+	const lastsup = [...doc.getElementsByTagName("sup")].pop();
+	return lastsup.parentElement.textContent.split("\n")
+	.filter(i => i.length)
+	.map(i => i.substr(3));
+}
+
+function getarmor()
+{
+	return fetch("https://mikesrpgcenter.com/dw3/armor.html")
+	.then(response => response.text())
+	.then(html =>
+	{
+		const doc = getdompareser(html);
+		const notes = getnotes(doc);
+		["armor", "shields", "helmets"]
+		.forEach(category =>
+		{
+			equipment[category] = getcategory(doc, category, notes);
+		});
+	});
+}
+
+function getweapons()
+{
+	return fetch("https://mikesrpgcenter.com/dw3/weapons.html")
+	.then(response => response.text())
+	.then(html =>
+	{
+		const doc = getdompareser(html);
+		const notes = getnotes(doc);
+		equipment.weapons = getcategory(doc, "weapons", notes);
+	});
+}
+
+function outputcategory(category, characters)
+{
+	// todo : auto length
+	// todo: output in one string at the end 
+	console.log("=".repeat(46))
+	const columns = [
+		{ id: "Name", label: category.toUpperCase(), len: 21},
+		{ id: "Value", label: "Val", len: 4},
+		{ id: "Cost", label: "Cost", len: 6},
+		{ separator: true, label: "| "}
+	]
+
+	characters.forEach(char =>
+	{
+		columns.push(
+		{
+			id: char.job,
+			label: char.name,
+			len: char.name.length + 1,
+			character : true
+		})
+	})
+
+	// columns.push({ id: "Notes", label: "Notes", len: 6});
+
+	// headers
+	let line = "";
+	columns.forEach(column =>
+	{
+		let elt = column.label;
+		elt += " ".repeat(Math.max(0, column.len - elt.length))
+		line += elt;
+	})
+	console.log(line + "| ")
+	
+	// lines
+	equipment[category].forEach(item =>
+	{
+		let line = "";
+		let elt = "";
+		columns.forEach(column =>
+		{
+			if (column.separator)
+			{
+				elt = "| ";
+			}
+			else
+			{
+				elt = item[column.id];
+				if (column.character)
+				{
+					elt = elt == "x" ? " " : "##"
+				}
+				elt += " ".repeat(Math.max(0, column.len - elt.length))
+			}
+			line += elt;
+		})
+		console.log(line + "|")
+	});
+}
+
+function output()
+{
+	// todo: full name then cut to 2 char
+	const characters = [
+		{job: "Hr", name: "Yo"},
+		{job: "Sr", name: "Le"},
+		{job: "Pr", name: "Je"},
+		{job: "Wz", name: "Lu"}
+	];
+
+	console.log("Dragon Quest 3 equipment sheet");
+	outputcategory("weapons", characters)
+	outputcategory("armor", characters)
+	outputcategory("shields", characters)
+	outputcategory("helmets", characters)
+}
+	
+
+var equipment = {};
+
+getarmor()
+.then(getweapons)
+.then(output);
+
diff --git a/dq3/dq3.txt b/dq3/dq3.txt
new file mode 100644
index 0000000..f89b953
--- /dev/null
+++ b/dq3/dq3.txt
@@ -0,0 +1,73 @@
+Dragon Quest 3 equipment sheet
+==============================================
+WEAPONS              Val Cost  | Yo Le Je Lu | 
+Cypress Stick        2   5     |             |
+Falcon Sword         5   25000 |    ## ## ## |
+Club                 7   30    |          ## |
+Poison Needle        10  10    | ## ## ##    |
+Copper Sword         12  100   |          ## |
+Magic Knife          14  200   |             |
+Wizard's Wand        15  1500  | ## ## ##    |
+Thorn Whip           18  320   |       ## ## |
+Chain Sickle         24  550   |          ## |
+Iron Spear           28  750   |          ## |
+Iron Claw            30  770   | ## ## ## ## |
+Staff of Thunder     30  -     | ## ## ##    |
+Broad Sword          33  1500  |       ## ## |
+Staff of Judgement   35  2700  | ## ##    ## |
+Battle Axe           40  2500  |       ## ## |
+Giant Shears         48  3700  | ##    ## ## |
+Sword of Gaia        48  -     |       ## ## |
+Sledge Hammer        55  6500  | ##    ## ## |
+Staff of Force       55  2500  | ## ##       |
+Orochi Sword         63  -     |       ## ## |
+Zombie Slasher       65  9800  |          ## |
+Dragon Killer        77  15000 |       ## ## |
+Thunder Sword        85  -     |       ## ## |
+Demon Axe            90  -     | ##    ## ## |
+Thor's Sword         95  -     |       ## ## |
+Multi-edge Sword     100 -     |       ## ## |
+Sword of Destruction 110 45000 |       ## ## |
+Sword of Kings       120 35000 |    ## ## ## |
+==============================================
+ARMOR                Val Cost  | Yo Le Je Lu | 
+Revealing Swimsuit   1   78000 |             |
+Clothes              4   10    |             |
+Wayfarer's Clothes   8   70    |             |
+Training Suit        10  80    | ## ## ## ## |
+Leather Armor        12  150   |          ## |
+Animal Suit          15  -     |             |
+Shell Armor          16  300   |          ## |
+Chain Mail           20  480   |          ## |
+Cloak of Evasion     20  2900  |             |
+Iron Apron           22  700   | ## ## ## ## |
+Fighting Suit        23  800   | ## ## ## ## |
+Half Plate Armor     25  1100  |       ## ## |
+Flashy Clothes       28  1300  | ## ## ## ## |
+Sacred Robe          30  4400  | ## ##    ## |
+Full Plate Armor     32  2400  |       ## ## |
+Angel's Robe         35  3000  | ## ##       |
+Magic Armor          40  5800  |          ## |
+Water Flying Cloth   40  12500 | ## ## ##    |
+Dragon Mail          45  9800  |       ## ## |
+Armor of Terrafirma  50  -     |       ## ## |
+Swordedge Armor      55  -     |       ## ## |
+Armor of Hades       65  x     |    ## ## ## |
+Armor of Radiance    75  -     |    ## ## ## |
+==============================================
+SHIELDS              Val Cost  | Yo Le Je Lu | 
+Leather Shield       4   90    |          ## |
+Bronze Shield        7   180   |          ## |
+Iron Shield          12  700   |       ## ## |
+Silver Shield        30  8800  |          ## |
+Shield of Sorrow     35  -     |       ## ## |
+Shield of Strength   40  15000 |       ## ## |
+Shield of Heroes     50  -     |    ## ## ## |
+==============================================
+HELMETS              Val Cost  | Yo Le Je Lu | 
+Leather Helmet       2   80    |             |
+Turban               8   160   | ## ## ## ## |
+Iron Helmet          16  1000  |          ## |
+Iron Mask            25  3500  |       ## ## |
+Unlucky Helmet       35  -     |       ## ## |
+Noh Mask             255 -     |             |