1
1

Reputation.ts 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. enum Reputations {
  2. HATED, // Pretty much Kill-on-sight
  3. NEUTRAL, // Doesn't care much
  4. ACCEPTED, // The player has done something that they liked
  5. ADORED, // The player is a hero to them
  6. SLUT2, // The player is known for being a slut among them
  7. SLUT1, // The player is known for being a little slutty among them
  8. PRUDE1, // The player is known for rejecting sexual advances often
  9. PRUDE2, // The player is expected to reject all sexual advances
  10. }
  11. /**
  12. * Never never use this in a permanent manne. Reputation must be generated and discarded after use.
  13. */
  14. class Reputation {
  15. private values : Array<Reputations> = [Reputations.NEUTRAL, undefined];
  16. constructor (...values : Array<Reputations>) {
  17. for (let i = 0; i < values.length; i++) {
  18. this.add(values[i]);
  19. }
  20. }
  21. public add (value : Reputations) {
  22. let mutual1 = [Reputations.HATED, Reputations.NEUTRAL, Reputations.ACCEPTED, Reputations.ADORED];
  23. let mutual2 = [Reputations.SLUT1, Reputations.SLUT2, Reputations.PRUDE1, Reputations.PRUDE2];
  24. if (mutual2.includes(value)) {
  25. this.values[1] = value;
  26. } else if (mutual1.includes(value)) {
  27. this.values[0] = value;
  28. }
  29. return this;
  30. }
  31. public contains (...values : Array<Reputations>) {
  32. for (let i = 0; i < values.length; i++) {
  33. if (!this.values.includes(values[i])) {
  34. return false;
  35. }
  36. }
  37. return true;
  38. }
  39. public is (value : Reputations) {
  40. return this.values.includes(value);
  41. }
  42. public isPrude () {
  43. return this.values.includes(Reputations.PRUDE1) || this.values.includes(Reputations.PRUDE2);
  44. }
  45. public isSlut () {
  46. return this.values.includes(Reputations.SLUT1) || this.values.includes(Reputations.SLUT2);
  47. }
  48. }