Advertisement
Guest User

Untitled

a guest
Jul 21st, 2019
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.75 KB | None | 0 0
  1. // GistID: b3afe01b59ce579e20459e3b40a7eee6
  2. class Complimentor {
  3.  
  4. static compliments() {
  5. return new Complimentor().phrases();
  6. }
  7.  
  8. phrases() {
  9. return `${this.phrase()}. ${this.maybe(this.phrases)}`;
  10. }
  11.  
  12. phrase() {
  13. return this.pickOne([
  14. this.youMakeMe(),
  15. this.youHaveA(),
  16. this.youHave(),
  17. this.iLoveYou(),
  18. this.whenIAm(),
  19. this.youAre()
  20. ]);
  21. }
  22.  
  23. youAre() {
  24. return `You are${this.adverbs()}${this.adjective()}`;
  25. }
  26.  
  27. whenIAm() {
  28. return `When I am ${this.badEmotion()} you ${this.pickMeUp()}${this.emphatic()}`;
  29. }
  30.  
  31. pickMeUp() {
  32. return this.pickOne([
  33. 'cheer me up',
  34. 'kick my ass into gear',
  35. 'put the wind back in my sails'
  36. ]);
  37. }
  38.  
  39. badEmotion() {
  40. return this.pickOne([
  41. 'sad',
  42. 'down',
  43. 'upset',
  44. 'freaking out',
  45. 'in the lost-and-found',
  46. 'throwing a tantrum'
  47. ]);
  48. }
  49.  
  50. iLoveYou() {
  51. return 'I love you';
  52. }
  53.  
  54. youMakeMe() {
  55. return `You make me${this.maybe(this.adverbs)}${this.adverb()}${this.maybe(0.25, this.adverbs)}${this.emphatic()}`;
  56. }
  57.  
  58. youHave() {
  59. return `You have${this.adjectives()}${this.pluralAttribute()}${this.emphatic()}`;
  60. }
  61.  
  62. youHaveA() {
  63. return `You have a${this.adjectives()}${this.singularAttribute()}${this.emphatic()}`
  64. }
  65.  
  66. emphatic() {
  67. let picks = [
  68. 'really',
  69. 'you really do',
  70. 'you do',
  71. () => `I swear${this.maybe(' it')}`,
  72. () => `${this.maybe('up')}on my grandmother's grave`,
  73. 'by Jove',
  74. 'you don\'t even know',
  75. 'seriously',
  76. 'I mean it'
  77. ];
  78. return this.maybe(0.95, () => `, ${this.pickOne(picks)}${this.maybe(0.3, this.emphatic)}`);
  79. }
  80.  
  81. adjectives() {
  82. return `${this.adjective()}${this.maybe(0.25, this.adjectives)}`;
  83. }
  84.  
  85. adjective() {
  86. return ` ${this.pickOne(['beautiful', 'glorious', 'wonderful', 'wiggly'])}`;
  87. }
  88.  
  89. pluralAttribute() {
  90. return ` ${this.pickOne(['eyes', 'ears', 'fingers', 'thumbs', 'toes', 'feet', 'nostrils', 'hair'])}`;
  91. }
  92.  
  93. singularAttribute() {
  94. return ` ${this.pickOne(['voice', 'nose', 'face', 'sense of humor', 'poise', 'grace', 'mind', 'heart', 'soul', 'laugh'])}`;
  95. }
  96.  
  97. adverbs() {
  98. return `${this.adverb()}${this.maybe(0.25, this.adverbs)}`;
  99. }
  100.  
  101. adverb() {
  102. return ` ${this.pickOne(['with happiness', 'ecstatically', 'beautifully', 'gloriously'])}`;
  103. }
  104.  
  105. pickOne(choices) {
  106. let choice = choices[Math.floor(Math.random() * choices.length)];
  107. return typeof choice === 'function' ? choice.call(this) : choice;
  108. }
  109.  
  110. maybe(p, choice) {
  111. if (arguments.length === 1) {
  112. choice = p;
  113. p = 0.5;
  114. }
  115. if (Math.random() < p) {
  116. return typeof choice === 'function' ? choice.call(this) : choice;
  117. } else {
  118. return '';
  119. }
  120. }
  121.  
  122. }
  123.  
  124. console.log(Complimentor.compliments());
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement