]> git.lizzy.rs Git - furrybot.git/blob - waifu.lua
4f78ba906aae6a7dba2015dc7560d447fb05dc61
[furrybot.git] / waifu.lua
1 local http, env, storage
2 local C = minetest.get_color_escape_sequence
3
4 furrybot.alphabeth = {
5         vowels = {},
6         consonants = {},
7 }
8
9 function furrybot.get_waifu_name()
10         local state = math.random() < 0.5
11         local r = math.random(3, 8)
12         local str = ""
13
14         for i = 1, r do
15                 local tbl = state and furrybot.alphabeth.vowels or furrybot.alphabeth.consonants
16                 str = str .. tbl[math.random(#tbl)]
17
18                 state = not state
19         end
20
21         return furrybot.uppercase(str)
22 end
23
24 function furrybot.random_distribution(tbl)
25         local accum = 0
26         local edges = {}
27
28         for i, v in ipairs(tbl) do
29                 accum = accum + v[2]
30                 edges[i] = accum
31         end
32
33         local r = math.random(accum)
34
35         for i, v in ipairs(tbl) do
36                 if r <= edges[i] then
37                         return v[1]
38                 end
39         end
40 end
41
42 function furrybot.get_waifu_species()
43         return furrybot.random_distribution({
44                 {nil, 100},                     -- Human
45                 {"Catgirl", 15},
46                 {"Foxgirl", 15},
47                 {"Wolfgirl", 15},
48                 {"Orc", 5},
49                 {"Elb", 5},
50                 {"Dwarf", 5},
51                 {"Femboy", 3},
52                 {"Apache Helicopter", 1},
53                 {"C++ Programmer", 1},
54         })
55 end
56
57 function furrybot.get_waifu_gender()
58         return furrybot.random_distribution({
59                 {"Male", 50},
60                 {"Female", 50},
61                 {"nil", 1},
62         })
63 end
64
65 function furrybot.get_waifu_hair()
66         return furrybot.random_distribution({
67                 {{"Brown", "#DDAE92"}, 25},
68                 {{"Black", "#433F3A"}, 25},
69                 {{"Blonde", "#ECC87E"}, 20},
70                 {{"Red", "#E2887F"}, 10},
71         })
72 end
73
74 function furrybot.get_waifu_eyes()
75         return furrybot.random_distribution({
76                 {{"Brown", "#463230"}, 15},
77                 {{"Blue", "#97C6FE"}, 10},
78                 {{"Green", "#36CC4E"}, 5},
79         })
80 end
81
82 function furrybot.get_waifu_age()
83         local agetab = furrybot.random_distribution({
84                 {{200, 600}, 25}, -- deamon
85                 {{1000, 2000}, 5}, -- next level deamon
86                 {{12, 16}, 50}, -- teen loli
87                 {{18, 19}, 5}, -- legal loli
88                 {{5, 9}, 5}, -- true loli
89                 {nil, 1}, -- unknown
90         })
91
92         return agetab and math.random(agetab[1], agetab[2])
93 end
94
95 function furrybot.get_waifu(id)
96         id = id or math.random(0, 32767)
97
98         math.randomseed(id)
99
100         local waifu = {
101                 id = id,
102                 name = furrybot.get_waifu_name(),
103                 species = furrybot.get_waifu_species(),
104                 gender = furrybot.get_waifu_gender(),
105                 hair = furrybot.get_waifu_hair(),
106                 eyes = furrybot.get_waifu_eyes(),
107                 age = furrybot.get_waifu_age(),
108         }
109
110         math.randomseed(os.time() + os.clock() + math.random())
111
112         return waifu
113 end
114
115 furrybot.commands.waifu = {
116         func = function(name, id)
117                 local waifu = furrybot.get_waifu(tonumber(id or ""))
118                 furrybot.send(waifu.name
119                         .. furrybot.colors.system .. (waifu.species and " | Species: " .. furrybot.colors.random .. waifu.species or "")
120                         .. furrybot.colors.system .. " | Age: " .. furrybot.colors.random .. (waifu.age or "Unknown")
121                         .. furrybot.colors.system .. " | Gender: " .. furrybot.colors.random .. waifu.gender
122                         .. furrybot.colors.system .. " | " .. C(waifu.hair[2]) .. waifu.hair[1] .. furrybot.colors.system .. " Hair"
123                         .. furrybot.colors.system .. " | " .. C(waifu.eyes[2]) .. waifu.eyes[1] .. furrybot.colors.system .. " Eyes"
124                         .. furrybot.colors.system .. " | " .. "#" .. waifu.id .. ""
125                 , furrybot.colors.random)
126         end,
127 }
128
129 return function(_http, _env, _storage)
130         http, env, storage = _http, _env, _storage
131
132         local is_vowel = {
133                 a = true,
134                 e = true,
135                 i = true,
136                 o = true,
137                 u = true,
138         }
139
140         local bounds = "az"
141
142         local f = env.io.open("clientmods/furrybot/LICENSE", "r")
143         local src = f:read("*a")
144
145         for i = 1, #src do
146                 local c = src:sub(i, i):lower()
147
148                 if c:byte(1) >= bounds:byte(1) and c:byte(1) <= bounds:byte(2) then
149                         table.insert(is_vowel[c] and furrybot.alphabeth.vowels or furrybot.alphabeth.consonants, c)
150                 end
151         end
152 end