1
1

Weapon.ts 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /// <reference path="../Clothing.ts" />
  2. /// <reference path="../Person/Attribute.ts" />
  3. interface WeaponOptions extends ClothingOptions {
  4. leftHand : boolean;
  5. rightHand : boolean;
  6. attribute? : Attribute;
  7. attackCost? : number;
  8. attributeDamageFactor? : number;
  9. attributeForceFactor? : number;
  10. accuracy? : number;
  11. }
  12. class Weapon extends Clothing implements Weaponized {
  13. private attribute : Attribute;
  14. private attributeDamageFactor : number;
  15. private attackCost : number;
  16. private attributeForceFactor : number;
  17. private accuracy : number;
  18. constructor (t : WeaponOptions) {
  19. super(t);
  20. if (t.leftHand) {
  21. this.slots.push(Humanoid.SLOT_LEFTHAND);
  22. }
  23. if (t.rightHand) {
  24. this.slots.push(Humanoid.SLOT_RIGHTHAND);
  25. }
  26. this.attackCost = t.attackCost == undefined ? 1 : t.attackCost;
  27. this.attributeDamageFactor = t.attributeDamageFactor == undefined ? 1 : t.attributeDamageFactor;
  28. this.attributeForceFactor = t.attributeForceFactor == undefined ? 1 : t.attributeForceFactor;
  29. this.accuracy = t.accuracy == undefined ? 0 : t.accuracy;
  30. this.attribute = t.attribute;
  31. }
  32. /**
  33. * Implements Weaponized
  34. */
  35. public getAttribute () {
  36. return this.attribute;
  37. }
  38. public getAttributeDamageFactor () {
  39. return this.attributeDamageFactor;
  40. }
  41. public getAttributeForceFactor () {
  42. return this.attributeForceFactor;
  43. }
  44. public getAccuracy () {
  45. return this.accuracy;
  46. }
  47. public getCost () {
  48. return this.attackCost;
  49. }
  50. }