Advertisement
Guest User

Untitled

a guest
Oct 26th, 2016
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.63 KB | None | 0 0
  1. class Vendor
  2.  
  3. #Constant containing the number we have to hit to get a package.
  4. PACKAGE_THRESHOLD = 300
  5.  
  6. #Define static methods for inheriting classes.
  7. class << self
  8. attr_accessor :reputation
  9. attr_accessor :hasPackage
  10. attr_accessor :rank
  11. end
  12.  
  13.  
  14.  
  15. #Creates a .name method for us that allows us to access the name of the instance.
  16. attr_reader :name
  17.  
  18. def initialize(name)
  19. @name = name
  20. end
  21.  
  22. #Return the reputation of the calling class (e.g Cryptarch)
  23. def reputation
  24. self.class.reputation
  25. end
  26.  
  27. #Set the reputation of the calling class (e.g Cryptarch)
  28. def setRep(value)
  29. self.class.reputation = value
  30. end
  31.  
  32. #Increase the reputation of the calling class (e.g Cryptarch)
  33. def increaseRep(value)
  34. self.class.reputation += value
  35. #Set the hasPackage variable to true if we passed the threshold.
  36. if self.class.reputation >= PACKAGE_THRESHOLD then self.class.hasPackage = true end
  37. end
  38.  
  39. def hasPackage?
  40. self.class.hasPackage
  41. end
  42.  
  43. def claimPackage
  44. if hasPackage?
  45. #Reset package status.
  46. self.class.hasPackage = false
  47. #We should replace this with a ranking system later.
  48. self.class.reputation = 0
  49. "You have recieved a package from #{@name}"
  50. end
  51. end
  52.  
  53. def rank
  54. self.class.rank
  55. end
  56.  
  57. def setRank (ranklvl)
  58. self.class.rank = ranklvl
  59. end
  60.  
  61. def rankUpCheck
  62. if self.class.reputation >= PACKAGE_THRESHOLD then self.class.increaseRank = true end
  63. end
  64.  
  65. def increaseRank?(ranklvl)
  66. self.class.increaseRank
  67. self.class.rank += ranklvl
  68.  
  69. end
  70.  
  71.  
  72. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement