-
Notifications
You must be signed in to change notification settings - Fork 6
/
Descriptions.cs
494 lines (448 loc) · 17.1 KB
/
Descriptions.cs
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
using System;
using System.Collections.Generic;
using System.Linq;
namespace Noxico
{
public static class Descriptions
{
public static TokenCarrier descTable;
static Descriptions()
{
descTable = new TokenCarrier();
descTable.Tokens.AddRange(Mix.GetTokenTree("bodyparts.tml"));
}
public static string Length(float cm)
{
if (!IniFile.GetValue("misc", "imperial", false))
{
if (cm >= 100)
{
var m = Math.Floor(cm / 100);
cm %= 100;
if (cm > 0)
return m + "." + Math.Floor(cm) + "m";
else
return m + "m";
}
if (Math.Floor(cm) != cm)
return cm.ToString("F1") + "cm";
else
return cm.ToString("F0") + "cm";
}
else
{
var i = cm * 0.3937;
if (i > 12)
{
var f = Math.Floor(i / 12);
i %= 12;
if (i > 0)
return f + "\x15E" + i.ToString("F0") + "\x15F";
else
return f + "\x15E";
}
if (Math.Floor(i) != i)
return i.ToString("F1") + "\x15F";
else
return i.ToString("F0") + "\x15F";
}
}
public static string GetSizeDescription(string path, float upTo)
{
var set = descTable.Path(path);
if (set == null)
throw new Exception(string.Format("Could not find bodyparts.tml item \"{0}\".", path));
var ret = set.Tokens[0].Tokens.PickOne().Name;
foreach (var item in set.Tokens)
{
if (item.Value <= upTo)
ret = item.Tokens.PickOne().Name;
else
return ret;
}
return ret;
}
public static string GetPartDescription(string path)
{
var set = descTable.Path(path);
if (set == null)
throw new Exception(string.Format("Could not find bodyparts.tml item \"{0}\".", path));
return set.Tokens.Where(t => t.Name[0] != '_').Select(t => t.Name).ToArray().PickOne();
//return set.Tokens[Random.Next(set.Tokens.Count)].Name;
}
public static string GetPartDescription(string path, params string[] alternatives)
{
var set = descTable.Path(path);
if (set == null)
return alternatives.PickOne();
return set.Tokens.Where(t => t.Name[0] != '_').Select(t => t.Name).ToArray().PickOne();
//return set.Tokens[Random.Next(set.Tokens.Count)].Name;
}
public static string BreastSize(Token breastToken, bool inCups = false)
{
if (breastToken == null)
return "glitch";
var size = breastToken.HasToken("size") ? breastToken.GetToken("size").Value : 0f;
return GetSizeDescription(inCups ? "breasts/cupsize" : "breasts/size", size);
}
public static string Looseness(Token loosenessToken, bool forButts = false)
{
if (loosenessToken == null)
return null;
return GetSizeDescription(forButts ? "ass/looseness" : "vagina/looseness", loosenessToken.Value);
}
public static string Wetness(Token wetnessToken)
{
if (wetnessToken == null)
return null;
return GetSizeDescription("vagina/wetness", wetnessToken.Value);
}
/*
public static string Tail(Token tailToken)
{
if (tailToken == null)
return "glitch";
var tails = new Dictionary<string, string>()
{
{ "stinger", "stinger" }, //needed to prevent "stinger tail"
{ "webber", "webber" },
{ "genbeast", Random.NextDouble() < 0.5 ? "ordinary tail" : "tail" }, //"Your (ordinary) tail"
};
var tailName = tailToken.Text;
if (tails.ContainsKey(tailName))
return tails[tailName];
else
return tailName + " tail";
}
*/
#region Random descriptions
/// <summary>
/// Chooses a random euphemism for penis and returns it as a string.
/// </summary>
/// <returns>A string containing a euphemism for penis.</returns>
public static string CockRandom()
{
throw new Exception("This method is deprecated.");
//return Toolkit.PickOne(i18n.GetArray("cockrandom"));
}
/// <summary>
/// Chooses a random euphemism for vagina and returns it as a string.
/// </summary>
/// <returns>A string containing a euphemism for vagina.</returns>
public static string PussyRandom()
{
throw new Exception("This method is deprecated.");
//return Toolkit.PickOne(i18n.GetArray("pussyrandom"));
}
/// <summary>
/// Chooses a random euphemism for anus and returns it as a string.
/// </summary>
/// <returns>A string containing a euphemism for anus.</returns>
public static string AnusRandom()
{
throw new Exception("This method is deprecated.");
//return Toolkit.PickOne(i18n.GetArray("anusrandom"));
}
/// <summary>
/// Chooses a random euphemism for ass and returns it as a string.
/// </summary>
/// <returns>A string containing a euphemism for ass.</returns>
public static string ButtRandom()
{
throw new Exception("This method is deprecated.");
//return Toolkit.PickOne(i18n.GetArray("buttrandom"));
}
/// <summary>
/// Chooses a random euphemism for clitoris and returns it as a string.
/// </summary>
/// <returns>A string containing a euphemism for clitoris.</returns>
public static string ClitRandom()
{
throw new Exception("This method is deprecated.");
//return Toolkit.PickOne(i18n.GetArray("clitrandom"));
}
/// <summary>
/// Chooses a random euphemism for breast and returns it as a string.
/// </summary>
/// <param name="plural">Flag for returning a plural euphemism instead of a singular.</param>
/// <returns>A string containing a euphemism for breast(s).</returns>
public static string BreastRandom(bool plural = false)
{
throw new Exception("This method is deprecated.");
//if (plural)
// return Toolkit.PickOne(i18n.GetArray("breastsrandom"));
//else
// return Toolkit.PickOne(i18n.GetArray("breastrandom"));
}
/// <summary>
/// Chooses a random euphemism for semen and returns it as a string.
/// </summary>
/// <returns>A string containing a euphemism for semen.</returns>
public static string CumRandom()
{
throw new Exception("This method is deprecated.");
//return Toolkit.PickOne(i18n.GetArray("cumrandom"));
}
#endregion
/// <summary>
/// Returns a string describing a piece of equipment using its name, (optionally) color (if available), and (optionally) an appropriate article.
/// </summary>
/// <param name="knownItem">An InventoryItem from <see cref="NoxicoGame.KnownItems"/>.</param>
/// <param name="token">An item token from a <see cref="Character"/>'s inventory that matches the type of item in the first parameter.</param>
/// <param name="article">Adds either the definite article (if "the" is passed), the indefinite article (if "a" is passed), or no article (anything else is passed)
/// to the front of the descriptive string.</param>
/// <param name="withColor">If set to true, the returned string will also describe the color of the item if it has one.</param>
/// <returns>A string containing the description of the item as defined by the parameters. If 'item' is null, then null is returned instead.</returns>
public static string Item(InventoryItem knownItem, Token token, string article = "", bool withColor = false)
{
if (knownItem == null)
return null;
var name = (token != null && token.HasToken("unidentified") && !knownItem.UnknownName.IsBlank()) ? knownItem.UnknownName : knownItem.Name;
var color = (token != null && token.HasToken("color")) ? Color.NameColor(token.GetToken("color").Text) : "";
var reps = new Dictionary<string, string>()
{
{ "[color]", color },
{ "[, color]", ", " + color },
{ "[color ]", color + " " },
{ "[color, ]", color + ", " },
};
if (withColor && !string.IsNullOrEmpty(color))
{
foreach (var i in reps)
name = name.Replace(i.Key, i.Value);
}
else
{
foreach (var key in reps.Keys)
name = name.Replace(key, string.Empty);
}
//TODO: see Mutamorph/GetMorphDeltas about scripted articles.
if (article == "the")
name = knownItem.Definite + ' ' + name;
else if (article == "a")
name = knownItem.Indefinite + ' ' + name;
return name;
}
#region Head descriptions
/// <summary>
/// Returns a string describing the ear token passed to the function.
/// </summary>
/// <param name="earToken">The 'ears' token of a character.</param>
/// <returns>A string containing the description of the ear type.</returns>
public static string EarType(Token earToken)
{
if (earToken == null)
return "glitch";
return GetPartDescription("ears/" + earToken.Text, i18n.GetArray("unusual"));
}
/// <summary>
/// Returns a string describing the face token passed to the function.
/// </summary>
/// <param name="faceToken">The 'face' token of a character.</param>
/// <returns>A string containing the description of the face type.</returns>
public static string FaceType(Token faceToken)
{
if (faceToken == null)
return "glitch";
return GetPartDescription("face/" + faceToken.Text, i18n.GetArray("unusual_odd"));
}
/// <summary>
/// Returns a string describing the color of the passed hair token.
/// </summary>
/// <param name="hairToken">A character's 'hair' token.</param>
/// <returns>A string that describes the hair's color.</returns>
public static string HairColor(Token hairToken)
{
return Color.NameColor(hairToken.GetToken("color").Text);
}
/// <summary>
/// Returns a string describing the length of a the passed hair token in plain English.
/// </summary>
/// <param name="hairToken">A character's hair token.</param>
/// <returns>An all lower case string describing the hair's length.</returns>
public static string HairLength(Token hairToken)
{
if (hairToken == null)
return "glitch";
return GetSizeDescription("hair/length", hairToken.HasToken("length") ? hairToken.GetToken("length").Value : 0f);
}
public static string HairStyle(Token hairToken)
{
if (hairToken == null)
return "glitch";
var style = hairToken.GetToken("style").Text;
var path = "hair/names/" + style.ToLowerInvariant().Replace(' ', '_');
var set = descTable.Path(path);
if (set == null)
throw new Exception("Could not find bodyparts.tml item \"" + path + "\".");
if (set.HasToken("noun"))
return set.GetToken("noun").Text;
if (set.HasToken("adj"))
return set.GetToken("adj").Text;
return set.Name.Replace('_', ' ');
}
public static string Hair(Token hairToken)
{
//TODO: finish hair
return null;
}
/// <summary>
/// Returns a string describing the teeth token passed to the function.
/// </summary>
/// <param name="teethToken">The 'teeth' token to be evaluated.</param>
/// <returns>A string containing a description of the teeth type. Returns 'glitch' if 'teeth' is null.</returns>
public static string TeethType(Token teethToken)
{
if (teethToken == null)
return "glitch";
return GetPartDescription("teeth/" + teethToken.Text, i18n.GetArray("unusual"));
}
/// <summary>
/// Returns a string containing a description of the parameter 'tongue's type.
/// </summary>
/// <param name="tongueToken">A tongue token from a character.</param>
/// <returns>A string containing the description of the tongue based on its type.</returns>
public static string TongueType(Token tongueToken)
{
if (tongueToken == null)
return "glitch";
return GetPartDescription("tongue/" + tongueToken.Text, i18n.GetArray("unusual"));
}
public static string HairMaterial(string skinType)
{
return GetPartDescription("skintohair/" + skinType, new string[] { null });
}
//TODO
public static string Horn(Token hornToken)
{
return "<TODO>";
}
#endregion
#region Upperbody descriptions
public static string BodyMaterial(string skinType)
{
return GetPartDescription("skin/" + skinType, new string[] { null });
}
/// <summary>
/// Returns a string containing a description of the passed 'nipple' token's size.
/// </summary>
/// <param name="nipplesToken">The 'nipple' token of a character.</param>
/// <returns>A string containing the description of the 'nipple' token's size.</returns>
public static string NippleSize(Token nipplesToken)
{
if (nipplesToken == null)
return "glitch";
return GetSizeDescription("breasts/nipples", nipplesToken.HasToken("size") ? nipplesToken.GetToken("size").Value : 0.25f);
}
/// <summary>
/// Returns a string containing a description of the passed 'waist' token's size.
/// </summary>
/// <param name="waistToken">The 'waist' token of a character.</param>
/// <returns>A string containging the description of the 'waist' token's size.</returns>
public static string WaistSize(Token waistToken)
{
return GetSizeDescription("waist", waistToken != null ? waistToken.Value : 5);
}
/// <summary>
/// Takes a wing type token from a character and returns a string describing that wing's type.
/// </summary>
/// <param name="wingToken">The 'wings' token to be evaluated.</param>
/// <returns>A string containing a description of the wings' type. Returns 'glitch' if 'tail is null.</returns>
public static string WingType(Token wingToken)
{
if (wingToken == null)
return "glitch";
return GetPartDescription("wings/" + wingToken.Text, i18n.GetArray("unusual"));
}
#endregion
#region Lowerbody descriptions
/// <summary>
/// Returns a string describing the token 'cock's type.
/// </summary>
/// <param name="cockToken">The penis token to be evaluated.</param>
/// <returns>A string containing only the 'cock's type.</returns>
public static string CockType(Token cockToken)
{
if (cockToken == null)
return "glitch";
return GetPartDescription("penis/" + cockToken.Text, i18n.GetArray("unusual_odd"));
}
/// <summary>
/// Returns a string containing a description of the passed 'balls' token size.
/// </summary>
/// <param name="ballsToken">The 'balls' token of a character.</param>
/// <returns>A string containing the description of the 'balls' token's size.</returns>
public static string BallSize(Token ballsToken)
{
if (ballsToken == null)
return "glitch";
return GetSizeDescription("balls", ballsToken.HasToken("size") ? ballsToken.GetToken("size").Value : 1f);
}
/// <summary>
/// Returns a string containing a description of the passed 'ass' token size.
/// </summary>
/// <param name="buttToken">The 'ass' token of a character.</param>
/// <returns>A string containing the description of the 'ass' token's size.</returns>
public static string ButtSize(Token buttToken)
{
if (buttToken == null)
return "glitch";
return GetSizeDescription("ass/size", buttToken.HasToken("size") ? buttToken.GetToken("size").Value : 5);
}
/// <summary>
/// Provides a description of a character's foot based on their leg type.
/// </summary>
/// <param name="legsToken">The leg token to be evaluated.</param>
/// <param name="plural">If set to true, the returned description will be for both feet.</param>
/// <returns>A string containing a description of the foot type.</returns>
public static string Foot(Token legsToken, bool plural = false)
{
var request = descTable.Path("feet/" + (legsToken == null ? "default" : legsToken.Text)) ?? descTable.Path("feet/default");
return request.Text.Pluralize(plural ? 2 : 1);
}
/// <summary>
/// Returns a string containing a description of the passed 'hips' token size.
/// </summary>
/// <param name="hipToken">The 'hips' token of a character.</param>
/// <returns>A string containing a description based on the hipToken's value.</returns>
public static string HipSize(Token hipToken)
{
if (hipToken == null)
return "glitch";
return GetSizeDescription("hips", hipToken.Value);
}
/// <summary>
/// Takes a tail type token from a character and returns a string describing that tail's type.
/// </summary>
/// <param name="tailToken">The tail token to be evaluated.</param>
/// <returns>A string containing a description of the tail's type. Returns 'glitch' if 'tail is null.</returns>
public static string TailType(Token tailToken)
{
//TODO: allow cock-ends
if (tailToken == null)
return "glitch";
return GetPartDescription("tail/" + tailToken.Text, i18n.GetArray("unusual"));
}
public static string Leg(Token legsToken)
{
if (legsToken == null)
return "glitch";
return GetPartDescription("legs/" + legsToken.Text, i18n.GetArray("unusual"));
}
#endregion
/// <summary>
/// Provides a description of a character's hand based on their body type.
/// </summary>
/// <param name="character">The character to be evaluated.</param>
/// <param name="plural">If set to true, the returned description will be for both hands.</param>
/// <returns>A string containing a description of the hand type.</returns>
public static string Hand(Character character, bool plural = false)
{
if (character.HasToken("quadruped"))
return Foot(character.GetToken("legs"), plural);
//Clawed hands and such can go here.
var request = descTable.Path("hand/default");
return request.Text.Pluralize(plural ? 2 : 1);
}
}
}