255 lines
5.3 KiB
JavaScript
255 lines
5.3 KiB
JavaScript
// Hierarchical species tree based on Dragon Code V2.6 specification
|
|
const SPECIES_DATA = {
|
|
// Dragons (D)
|
|
D: {
|
|
name: "Dragon",
|
|
subtypes: {
|
|
w: "Western Dragon",
|
|
e: "Eastern Dragon",
|
|
p: "Pernese Dragon",
|
|
f: "Faerie Dragon",
|
|
r: "Reformed Dragon",
|
|
c: "Chromatic Dragon",
|
|
m: "Metallic Dragon",
|
|
g: "Gem Dragon"
|
|
}
|
|
},
|
|
|
|
// Humanoid (H)
|
|
H: {
|
|
name: "Human",
|
|
subtypes: {}
|
|
},
|
|
|
|
// Avian (A)
|
|
A: {
|
|
name: "Avian",
|
|
subtypes: {
|
|
c: "Cockatrice",
|
|
g: "Griffin",
|
|
h: "Hippogriff",
|
|
p: "Phoenix",
|
|
r: "Roc"
|
|
}
|
|
},
|
|
|
|
// Bovine (B)
|
|
B: {
|
|
name: "Bovine",
|
|
subtypes: {
|
|
c: "Cattle",
|
|
m: "Minotaur"
|
|
}
|
|
},
|
|
|
|
// Canine (C)
|
|
C: {
|
|
name: "Canine",
|
|
subtypes: {
|
|
c: "Coyote",
|
|
d: "Dog",
|
|
f: "Fox",
|
|
j: "Jackal",
|
|
w: "Wolf"
|
|
}
|
|
},
|
|
|
|
// Serpent (S)
|
|
S: {
|
|
name: "Serpent",
|
|
subtypes: {
|
|
b: "Basilisk",
|
|
h: "Hydra",
|
|
n: "Naga",
|
|
s: "Sea Serpent"
|
|
}
|
|
},
|
|
|
|
// Equine (E)
|
|
E: {
|
|
name: "Equine",
|
|
subtypes: {
|
|
c: "Centaur",
|
|
h: "Horse",
|
|
p: "Pegasus",
|
|
u: "Unicorn",
|
|
z: "Zebra"
|
|
}
|
|
},
|
|
|
|
// Feline (F)
|
|
F: {
|
|
name: "Feline",
|
|
subtypes: {
|
|
c: "Cat",
|
|
h: "Cheetah",
|
|
j: "Jaguar",
|
|
l: "Lion",
|
|
o: "Ocelot",
|
|
p: "Panther",
|
|
t: "Tiger",
|
|
x: "Lynx"
|
|
}
|
|
},
|
|
|
|
// Insectoid (I)
|
|
I: {
|
|
name: "Insectoid",
|
|
subtypes: {}
|
|
},
|
|
|
|
// Leporine (L)
|
|
L: {
|
|
name: "Leporine",
|
|
subtypes: {
|
|
h: "Hare",
|
|
r: "Rabbit"
|
|
}
|
|
},
|
|
|
|
// Mammal (M)
|
|
M: {
|
|
name: "Mammal",
|
|
subtypes: {
|
|
a: {
|
|
name: "Aquatic",
|
|
subtypes: {
|
|
d: "Dolphin",
|
|
o: "Orca",
|
|
p: "Porpoise",
|
|
s: "Seal",
|
|
w: "Walrus",
|
|
h: "Whale"
|
|
}
|
|
},
|
|
b: "Badger",
|
|
e: "Elephant",
|
|
f: {
|
|
name: "Feral",
|
|
subtypes: {
|
|
p: {
|
|
name: "Pantherine",
|
|
subtypes: {
|
|
c: "Cougar",
|
|
j: "Jaguar",
|
|
l: "Leopard",
|
|
n: "Panther",
|
|
s: "Snow Leopard",
|
|
t: "Tiger"
|
|
}
|
|
}
|
|
}
|
|
},
|
|
k: "Skunk",
|
|
m: "Mink",
|
|
o: "Otter",
|
|
r: "Rodent",
|
|
t: "Taur",
|
|
w: "Weasel"
|
|
}
|
|
},
|
|
|
|
// Otter (O)
|
|
O: {
|
|
name: "Otter",
|
|
subtypes: {}
|
|
},
|
|
|
|
// Mythological (Y)
|
|
Y: {
|
|
name: "Mythological",
|
|
subtypes: {
|
|
c: "Chimera",
|
|
g: "Gargoyle",
|
|
m: "Manticore",
|
|
s: "Sphinx"
|
|
}
|
|
},
|
|
|
|
// Porcine (P)
|
|
P: {
|
|
name: "Porcine",
|
|
subtypes: {
|
|
b: "Boar",
|
|
p: "Pig"
|
|
}
|
|
},
|
|
|
|
// Reptile (R)
|
|
R: {
|
|
name: "Reptile",
|
|
subtypes: {
|
|
a: "Alligator",
|
|
c: "Crocodile",
|
|
d: "Dinosaur",
|
|
l: "Lizard",
|
|
t: "Turtle"
|
|
}
|
|
},
|
|
|
|
// Aquatic (Q)
|
|
Q: {
|
|
name: "Aquatic",
|
|
subtypes: {
|
|
d: "Dolphin",
|
|
f: "Fish",
|
|
m: "Mermaid/Merman",
|
|
o: "Orca",
|
|
s: "Shark"
|
|
}
|
|
},
|
|
|
|
// Ursine (U)
|
|
U: {
|
|
name: "Ursine",
|
|
subtypes: {
|
|
b: "Bear",
|
|
g: "Grizzly",
|
|
p: "Panda",
|
|
l: "Polar Bear"
|
|
}
|
|
}
|
|
};
|
|
|
|
// Function to resolve a species code to its full name
|
|
function resolveSpeciesCode(code) {
|
|
if (!code || code.length === 0) return null;
|
|
|
|
const parts = code.split('');
|
|
let current = SPECIES_DATA;
|
|
let path = [];
|
|
|
|
for (let i = 0; i < parts.length; i++) {
|
|
const char = parts[i];
|
|
|
|
if (!current[char]) {
|
|
// If we can't find the next level, return what we have
|
|
break;
|
|
}
|
|
|
|
current = current[char];
|
|
|
|
if (typeof current === 'string') {
|
|
// We've reached a leaf node (species name)
|
|
return current;
|
|
} else if (current.name) {
|
|
// We're at a node with a name, but there might be subtypes
|
|
path.push(current.name);
|
|
if (current.subtypes) {
|
|
current = current.subtypes;
|
|
} else {
|
|
// No more subtypes, return the name
|
|
return current.name;
|
|
}
|
|
}
|
|
}
|
|
|
|
// Return the accumulated path or the name if we have it
|
|
return path.length > 0 ? path[path.length - 1] : null;
|
|
}
|
|
|
|
// Export for Node.js (CommonJS)
|
|
if (typeof module !== 'undefined' && module.exports) {
|
|
module.exports = { SPECIES_DATA, resolveSpeciesCode };
|
|
}
|