solo-rpg-lib
Version:
A library to include several solo rpg systems and oracles to use to build bigger software to play solo rpg sessions
3 lines (2 loc) • 6.37 kB
JavaScript
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self)["solo-rpg-lib"]={})}(this,(function(e){"use strict";const t=e=>1+Math.floor(Math.random()*e),a=()=>t(6),l=()=>t(10),s=()=>t(100),i=e=>e%2,r={chaosFactor:4,setChaosFactor:function(e){const t=e>6?6:e<3?3:e;this.chaosFactor=t},increaseChaosFactor:function(){return this.setChaosFactor(this.chaosFactor+1)},decreaseChaosFactor:function(){return this.setChaosFactor(this.chaosFactor-1)},fateCheck:function(e){const t=l(),a=l(),s=l();console.log(t,a,e);let r=t+a+e<10?"No":"Yes",n=!1;return s<=this.chaosFactor&&(t===a||(i(t)&&i(a)?r=`Exceptional ${r.toLowerCase()}`:i(t)||i(a)||(n=!0,r+=" and random event - ",n=!0,r=`Exceptional ${r.toLowerCase()} and random event - `)),n&&(r+=this.eventCheck())),r},eventCheck:function(){const e=s();let t="";return e<8?t="Remove event: ":e>7&&e<29?t="NPC action: ":e>28&&e<36?t="Introduce a new NPC: ":e>35&&e<46?t="Move toward a thread: ":e>45&&e<53?t="Move away from a thread: ":e>52&&e<56?t="Close a thread: ":e>55&&e<68?t="PC negative: ":e>67&&e<76?t="PC positive: ":e>75&&e<84?t="Ambiguous event: ":e>83&&e<93?t="NPC negative: ":e>92&&e<100&&(t="NPC positive: "),t+=this.getEventMeaning(),t},getEventMeaning:function(){return`${this.getActions()}, ${this.getDescriptors()}`},getActions:function(){return l()>5?n[s()-1]:o[s()-1]},getDescriptors:function(){return l()>5?u[s()-1]:y[s()-1]},detailsCheck:function(){let e=l()+l();return e+=3===this.chaosFactor?2:6===this.chaosFactor?-2:0,e=e<4?4:e>18?18:e,console.log(e),`${c[e-4]}: ${this.getEventMeaning()}`}},n=["Attainment","Starting","Neglect","Fight","Recruit","Triumph","Violate","Oppose","Malice","Communicate","Persecute","Increase","Decrease","Abandon","Gratify","Inquire","Antagonize","Move","Waste","Truce","Expose","Haggle","Imprison","Release","Celebrate","Develop","Travel","Block","Harm","Debase","Overindulge","Adjourn","Adversity","Kill","Disrupt","Usurp","Create","Betray","Agree","Abuse","Excitement","Activity","Assist","Care","Negligence","Passion","Work","Control","Attract","Failure","Pursue","Vengeance","Proceedings","Dispute","Punish","Guide","Transform","Overthrow","Oppress","Change","Release","Befriend","Judge","Desert","Dominate","Procrastinate","Praise","Separate","Take","Break","Heal","Delay","Stop","Lie","Return","Imitate","Struggle","Inform","Bestow","Postpone","Oppress","Inspect","Ambush","Spy","Attach","Carry","Open","Carelessness","Ruin","Extravagance","Trick","Arrive","Propose","Divide","Refuse","Mistrust","Deceive","Cruelty","Intolerance","Trust"],o=["Goals","Dreams","Environment","Outside","Inside","Reality","Allies","Enemies","Evil","Good","Emotions","Opposition","War","Peace","Innocent","Love","Spirit","Intellect","Ideas","Joy","Advice","Plot","Competition","Prison","Illness","Food","Attention","Success","Failure","Travel","Jealousy","Dispute","Home","Investment","Suffering","Wishes","Tactics","Stalemate","Randomness","Misfortune","Victory","Dispute","Riches","Normal","Technology","Hope","Magic","Illusions","Portals","Danger","Weapons","Animals","Weather","Elements","Nature","Masses","Leadership","Fame","Anger","Information","Messages","Energy","Balance","Tension","Friendship","Physical","Project","Pleasures","Pain","Possessions","Benefits","Plans","Lies","Expectations","Legal","Bureaucracy","Business","Path","News","Exterior","Death","Disruption","Power","Burden","Intrigues","Fears","Ambush","Rumor","Wounds","Extravagance","Representative","Adversities","Opulence","Liberty","Military","Mundane","Trials","Masses","Vehicle","Art"],u=["Abnormally","Adventurously","Aggressively","Angrily","Anxiously","Awkwardly","Beautifully","Bleakly","Boldly","Bravely","Busily","Calmly","Carefully","Carelessly","Cautiously","Ceaselessly","Cheerfully","Combatively","Coolly","Crazily","Fully","Generously","Gently","Gladly","Gracefully","Gratefully","Happily","Hastily","Healthily","Helpfully","Helplessly","Hopelessly","Innocently","Intensely","Interestingly","Irritatingly","Jovially","Joyfully","Judgementally","Kindly","Peacefully","Perfectly","Playfully","Politely","Positively","Powerfully","Quaintly","Quarrelsomely","Quietly","Roughly","Rudely","Ruthlessly","Slowly","Softly","Swiftly","Threateningly","Very","Violently","Wildly","Yieldingly","Curiously","Daintily","Dangerously","Defiantly","Deliberately","Delightfully","Dimly","Efficiently","Energetically","Enormously","Enthusiastically","Excitedly","Fearfully","Ferociously","Fiercely","Foolishly","Fortunately","Frantically","Freely","Frighteningly","Kookily","Lazily","Lightly","Loosely","Loudly","Lovingly","Loyally","Majestically","Meaningfully","Mechanically","Miserably","Mockingly","Mysteriously","Naturally","Neatly","Nicely","Oddly","Offensively","Officially","Partially"],y=["Abandoned","Abnormal","Amusing","Ancient","Aromatic","Average","Beautiful","Bizarre","Classy","Clean","Cold","Colorful","Creepy","Cute","Damaged","Dark","Defeated","Delicate","Delightful","Dirty","Graceful","Hard","Harsh","Healthy","Heavy","Historical","Horrible","Important","Interesting","Juvenile","Lacking","Lame","Large","Lavish","Lean","Less","Lethal","Lonely","Lovely","Macabre","Remarkable","Rotten","Rough","Ruined","Rustic","Scary","Simple","Small","Smelly","Smooth","Soft","Strong","Tranquil","Ugly","Valuable","Warlike","Warm","Watery","Weak","Young","Disagreeable","Disgusting","Drab","Dry","Dull","Empty","Enormous","Exotic","Faded","Familiar","Fancy","Fat","Feeble","Feminine","Festive","Flawless","Fresh","Full","Glorious","Good","Magnificent","Masculine","Mature","Messy","Mighty","Military","Modern","Extravagant","Mundane","Mysterious","Natural","Nondescript","Odd","Pale","Petite","Poor","Powerful","Quaint","Rare","Reassuring"],c=["Anger","Sadness","Fear","Disfavors Thread","Disfavors PC","Focus NPC","Favors NPC","Focus PC","Disfavors NPC","Focus Thread","Favors PC","Favors Thread","Courage","Happiness","Calm"],g=1,h=0,d=-1,f=e=>{const t=a();return e<t?t:e},m={check:(e=h)=>{let t=a();e===g&&(t=f(t));let l=a();e===d&&(l=f(l));let s=t>l?"Yes":"No";return s+=t<4&&l<4?" but...":"",s+=t>3&&l>3?" and...":"",s=t===l?"The question was wrong! Why?":s,s}};e.mythic=r,e.recluse=m,Object.defineProperty(e,"__esModule",{value:!0})}));
//# sourceMappingURL=umd.min.js.map