Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // GistID: b3afe01b59ce579e20459e3b40a7eee6
- class Complimentor {
- static compliments() {
- return new Complimentor().phrases();
- }
- phrases() {
- return `${this.phrase()}. ${this.maybe(this.phrases)}`;
- }
- phrase() {
- return this.pickOne([
- this.youMakeMe(),
- this.youHaveA(),
- this.youHave(),
- this.iLoveYou(),
- this.whenIAm(),
- this.youAre()
- ]);
- }
- youAre() {
- return `You are${this.adverbs()}${this.adjective()}`;
- }
- whenIAm() {
- return `When I am ${this.badEmotion()} you ${this.pickMeUp()}${this.emphatic()}`;
- }
- pickMeUp() {
- return this.pickOne([
- 'cheer me up',
- 'kick my ass into gear',
- 'put the wind back in my sails'
- ]);
- }
- badEmotion() {
- return this.pickOne([
- 'sad',
- 'down',
- 'upset',
- 'freaking out',
- 'in the lost-and-found',
- 'throwing a tantrum'
- ]);
- }
- iLoveYou() {
- return 'I love you';
- }
- youMakeMe() {
- return `You make me${this.maybe(this.adverbs)}${this.adverb()}${this.maybe(0.25, this.adverbs)}${this.emphatic()}`;
- }
- youHave() {
- return `You have${this.adjectives()}${this.pluralAttribute()}${this.emphatic()}`;
- }
- youHaveA() {
- return `You have a${this.adjectives()}${this.singularAttribute()}${this.emphatic()}`
- }
- emphatic() {
- let picks = [
- 'really',
- 'you really do',
- 'you do',
- () => `I swear${this.maybe(' it')}`,
- () => `${this.maybe('up')}on my grandmother's grave`,
- 'by Jove',
- 'you don\'t even know',
- 'seriously',
- 'I mean it'
- ];
- return this.maybe(0.95, () => `, ${this.pickOne(picks)}${this.maybe(0.3, this.emphatic)}`);
- }
- adjectives() {
- return `${this.adjective()}${this.maybe(0.25, this.adjectives)}`;
- }
- adjective() {
- return ` ${this.pickOne(['beautiful', 'glorious', 'wonderful', 'wiggly'])}`;
- }
- pluralAttribute() {
- return ` ${this.pickOne(['eyes', 'ears', 'fingers', 'thumbs', 'toes', 'feet', 'nostrils', 'hair'])}`;
- }
- singularAttribute() {
- return ` ${this.pickOne(['voice', 'nose', 'face', 'sense of humor', 'poise', 'grace', 'mind', 'heart', 'soul', 'laugh'])}`;
- }
- adverbs() {
- return `${this.adverb()}${this.maybe(0.25, this.adverbs)}`;
- }
- adverb() {
- return ` ${this.pickOne(['with happiness', 'ecstatically', 'beautifully', 'gloriously'])}`;
- }
- pickOne(choices) {
- let choice = choices[Math.floor(Math.random() * choices.length)];
- return typeof choice === 'function' ? choice.call(this) : choice;
- }
- maybe(p, choice) {
- if (arguments.length === 1) {
- choice = p;
- p = 0.5;
- }
- if (Math.random() < p) {
- return typeof choice === 'function' ? choice.call(this) : choice;
- } else {
- return '';
- }
- }
- }
- console.log(Complimentor.compliments());
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement