Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Vendor
- #Constant containing the number we have to hit to get a package.
- PACKAGE_THRESHOLD = 300
- #Define static methods for inheriting classes.
- class << self
- attr_accessor :reputation
- attr_accessor :hasPackage
- attr_accessor :rank
- end
- #Creates a .name method for us that allows us to access the name of the instance.
- attr_reader :name
- def initialize(name)
- @name = name
- end
- #Return the reputation of the calling class (e.g Cryptarch)
- def reputation
- self.class.reputation
- end
- #Set the reputation of the calling class (e.g Cryptarch)
- def setRep(value)
- self.class.reputation = value
- end
- #Increase the reputation of the calling class (e.g Cryptarch)
- def increaseRep(value)
- self.class.reputation += value
- #Set the hasPackage variable to true if we passed the threshold.
- if self.class.reputation >= PACKAGE_THRESHOLD then self.class.hasPackage = true end
- end
- def hasPackage?
- self.class.hasPackage
- end
- def claimPackage
- if hasPackage?
- #Reset package status.
- self.class.hasPackage = false
- #We should replace this with a ranking system later.
- self.class.reputation = 0
- "You have recieved a package from #{@name}"
- end
- end
- def rank
- self.class.rank
- end
- def setRank (ranklvl)
- self.class.rank = ranklvl
- end
- def rankUpCheck
- if self.class.reputation >= PACKAGE_THRESHOLD then self.class.increaseRank = true end
- end
- def increaseRank?(ranklvl)
- self.class.increaseRank
- self.class.rank += ranklvl
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement