Public
HTTP (deprecated)
Val Town is a social website to write and deploy JavaScript.
Build APIs and schedule functions from your browser.
Readme

Loot Generator API

How It Works

Components

The Loot Generator API creates random loot items by combining:

  • 30 adjectives
  • 29 materials
  • 15 item types

resulting in 13,050 possible items.

Legendary Items

Occasionally, a rare legendary item is generated. An item becomes legendary if all three components are rare. Rarity is determined by a threshold:

Threshold = max(1,⌊log(length)×0.6⌋)

Probability of a legendary item with the default settings:

P(Legendary) = 1/13,050 ≈ 0.00766%

Only one legendary item is possible: ✨💎 Arcane Diamond Rock.

Customization

You can expand the lists or adjust the 0.6 multiplier to control rarity.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
const adjectives = [
"Arcane",
"Ancient",
"Mysterious",
"Enchanted",
"Shiny",
"Glowing",
"Cursed",
"Powerful",
"Sturdy",
"Rusty",
"Fragile",
"Majestic",
"Haunted",
"Radiant",
"Mystic",
"Ethereal",
"Legendary",
"Corroded",
"Worn",
"Elegant",
"Pristine",
"Divine",
"Gleaming",
"Weathered",
"Sacred",
"Luminous",
"Blessed",
"Celestial",
"Frosted",
];
const materials = [
"Diamond",
"Meteorite",
"Bone",
"Iron",
"Gold",
"Silver",
"Stone",
"Wood",
"Crystal",
"Leather",
"Platinum",
"Obsidian",
"Adamantine",
"Emerald",
"Ruby",
"Sapphire",
"Jade",
"Amethyst",
"Copper",
"Bronze",
"Silk",
"Granite",
"Ivory",
"Opal",
"Onyx",
"Malachite",
"Tungsten",
"Nickel",
"Zinc",
];
const itemTypes = [
"Rock",
"Key",
"Tome",
"Potion",
"Sword",
"Shield",
"Ring",
"Amulet",
"Boots",
"Helmet",
"Gloves",
"Scroll",
"Wand",
"Axe",
"Dagger",
];
const itemEmojis = {
"Rock": "💎",
"Key": "🗝️",
"Tome": "📔",
"Potion": "🧪",
"Sword": "🗡️",
"Shield": "🛡️",
"Ring": "💍",
"Amulet": "📿",
"Boots": "🥾",
"Helmet": "🪖",
"Gloves": "🥊",
"Scroll": "📜",
"Wand": "🪄",
"Axe": "🪓",
"Dagger": "🔪",
};
roramigator-lootgenapi.web.val.run
September 1, 2024