1
1

Bodypart.ts 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  1. /// <reference path="../Thing.ts" />
  2. interface BodypartValueResult {
  3. value : number;
  4. weight : number;
  5. }
  6. class Bodypart extends Thing {
  7. public static WEIGHT_LOWEST = 1;
  8. public static WEIGHT_LOW = 3;
  9. public static WEIGHT_MEDIUM = 5;
  10. public static WEIGHT_HIGH = 7;
  11. public static WEIGHT_HIGHEST = 9;
  12. public static SLUTTINESS_LOWEST_SAINTLY = 0;
  13. public static SLUTTINESS_LOW_PRUDE = 25;
  14. public static SLUTTINESS_MEDIUM_AVERAGE = 50;
  15. public static SLUTTINESS_HIGH_SLUT = 75;
  16. public static SLUTTINESS_HIGHEST_WHORE = 100;
  17. public static GENDER_LOWEST_MANLIEST = 0;
  18. public static GENDER_LOW_MANLY = 25;
  19. public static GENDER_MEDIUM_ANDROGYNE = 50;
  20. public static GENDER_HIGH_FEMININE = 75;
  21. public static GENDER_HIGHEST_FEMININEST = 100;
  22. // The higher this number, the more the bodypart will be worth for health.
  23. // For instance, HEAD should be worth more than FINGERNAIL.
  24. public sorenessWeight : number = 1;
  25. // 0 to 10
  26. // says how fucked up the bodypart is
  27. public soreness : number = 0;
  28. // How much soreness is healed every turn
  29. public sorenessPerTurn : number = 0.05;
  30. // Last turn soreness got updated
  31. public lastSorenessUpdate : number = 0;
  32. public constructor (options? : ThingOptions) {
  33. super(options);
  34. this.addGetAlterations((bp : Bodypart) => {
  35. return {
  36. Soreness : bp.soreness,
  37. GenderValue : bp.genderValue,
  38. Sluttiness : bp.getSluttiness()
  39. }
  40. });
  41. this.addSetAlterations((bp : Bodypart, changes) => {
  42. this.soreness = changes.Soreness;
  43. this.genderValue = changes.GenderValue;
  44. this.sluttiness = changes.Sluttiness;
  45. });
  46. }
  47. public changeSoreness (soreness : number) {
  48. this.soreness += soreness;
  49. if (this.soreness < 0) {
  50. this.soreness = 0;
  51. }
  52. }
  53. public regenerate() {
  54. this.changeSoreness(- this.sorenessPerTurn);
  55. }
  56. public getSoreness () {
  57. return this.soreness;
  58. }
  59. public getWeightedSoreness() {
  60. return this.getSoreness() * this.sorenessWeight;
  61. }
  62. public getSorenessWeight () {
  63. return this.sorenessWeight;
  64. }
  65. // These are the slots the bodypart is visible on
  66. // Should use Humanoid.SLOT_* !
  67. public slots : Array<number> = [];
  68. public visibleSlots : Array<number> = [];
  69. // GenderValue is how masculine/feminine this bodypart is.
  70. // At 0 = the most masculine possible, at 100 = the most feminine eveter
  71. // 50 would be completely androgynous
  72. public genderValue : number = Bodypart.GENDER_MEDIUM_ANDROGYNE;
  73. // Like with health, the weight makes this bodypart matter more for deciding gender.
  74. // Gender presentation is not about prettiness, so, for instance, having huge breasts will
  75. // strongly push you to the "is a woman" side, even if you're manly as fuck everywhere else.
  76. // If you're too manly everywhere else, though, you'll probably end up closer on the spectrum to male
  77. // or at least androgynous, which might result in not passing.
  78. public genderWeight : number = 1;
  79. /**
  80. * Sluttiness goes from 0 to 100.
  81. * A bodypart's sluttiness is dependent on it being seen.
  82. * @type {number}
  83. */
  84. public sluttiness : number = 10;
  85. public sluttinessWeight : number = Bodypart.WEIGHT_LOWEST;
  86. public getGenderWeight () {
  87. if (this.slots.length == 0) {
  88. return 0;
  89. }
  90. return this.genderWeight * (this.visibleSlots.length / this.slots.length);
  91. }
  92. public getGenderValue () {
  93. return this.genderValue;
  94. }
  95. public getWeightedGenderValue () {
  96. return this.getGenderValue() * this.getGenderWeight();
  97. }
  98. public getSluttiness() {
  99. return this.sluttiness;
  100. }
  101. public getSluttinessWeight () {
  102. if (this.slots.length == 0) {
  103. return 0;
  104. }
  105. return this.sluttinessWeight * (this.visibleSlots.length / this.slots.length);
  106. }
  107. public getWeightedSluttinessValue () {
  108. return this.getSluttiness() * this.getSluttinessWeight();
  109. }
  110. public updateVisibility () {
  111. this.visibleSlots = this.slots.slice(0);
  112. let parent = Thing.PartRelation.getLeft(this);
  113. if (parent != undefined) {
  114. let clothing = <Array<Clothing>>Thing.WearRelation.getRight(parent);
  115. for (let i = 0; i < clothing.length; i++) {
  116. let covering = clothing[i].getCoveringSlots();
  117. for (let k = 0; k < covering.length; k++) {
  118. let idx = this.visibleSlots.indexOf(covering[k]);
  119. if (idx >= 0) {
  120. this.visibleSlots.splice(idx, 1);
  121. }
  122. }
  123. if (this.visibleSlots.length == 0) break;
  124. }
  125. }
  126. }
  127. public isUncovered () {
  128. this.updateVisibility();
  129. return this.visibleSlots.length == this.slots.length && this.slots.length > 0;
  130. }
  131. public updateStatus () {
  132. this.updateVisibility();
  133. }
  134. public static getSoreness (thing : Thing) {
  135. let bodyparts = Thing.PartRelation.getRightType(thing, Bodypart);
  136. let soreness = 0;
  137. bodyparts.forEach((bodypart : Bodypart) => {
  138. soreness += bodypart.getWeightedSoreness();
  139. });
  140. return soreness;
  141. }
  142. public static getGenderValueOn (thing : Thing) : BodypartValueResult {
  143. let weight = 0;
  144. let value = 0;
  145. let bodyparts = Thing.PartRelation.getRightType(thing, Bodypart);
  146. bodyparts.forEach((bodypart : Bodypart) => {
  147. weight += bodypart.getGenderWeight();
  148. value += bodypart.getWeightedGenderValue();
  149. });
  150. return {
  151. weight : weight,
  152. value : value
  153. };
  154. }
  155. public static getSluttinessValueOn (thing : Thing) : BodypartValueResult {
  156. let weight = 0;
  157. let value = 0;
  158. let bodyparts = Thing.PartRelation.getRightType(thing, Bodypart);
  159. bodyparts.forEach((bodypart : Bodypart) => {
  160. weight += bodypart.getSluttinessWeight();
  161. value += bodypart.getWeightedSluttinessValue();
  162. });
  163. return {
  164. weight : weight,
  165. value : value
  166. };
  167. }
  168. /**
  169. * Changes the bodypart so that it matches the desired genderValue.
  170. * This needs to be implemented in all classes inheriting from Bodypart, as not all bodyparts have a simple "genderValue" to assign.
  171. * @param {number} genderValue
  172. */
  173. public arrangeGenderValue (genderValue : number) {
  174. this.genderValue = genderValue;
  175. (<Humanoid> this.getPartOne()).invalidateCaches();
  176. }
  177. /**
  178. * Attempts to increase Femininity by 5 * amount. Will read Current Gender Value and try to reassign it.
  179. * @param {number} amount
  180. */
  181. public increaseFemininity (amount : number) {
  182. let currentGV = this.getGenderValue();
  183. this.arrangeGenderValue(currentGV + (5 * amount));
  184. }
  185. /**
  186. * Attempts to increase Masculinity by 5 * amount. Will read Current Gender Value and try to reassign it.
  187. * @param {number} amount
  188. */
  189. public increaseMasculinity (amount : number) {
  190. let currentGV = this.getGenderValue();
  191. this.arrangeGenderValue(currentGV - (5 * amount));
  192. }
  193. }