Browse files

Added SkillRating class to represent a person's rating in a skill.

  • Loading branch information...
1 parent 240b17d commit b34cfb3286d1abb1027d35926ec2e1480d1de4e4 @drestuart committed May 2, 2012
Showing with 73 additions and 7 deletions.
  1. +73 −7 src/skills/SkillClass.py
View
80 src/skills/SkillClass.py
@@ -75,21 +75,17 @@ def setRatio(self, val):
class Skill(Base):
'''
- The Skill superclass.
+ The Skill class. This class describes skills in the abstract, and there will be another class to describe a character's actual skill rating which will FK to this one.
'''
__tablename__ = "skills"
id = Column(Integer, primary_key=True)
subskills = relationship("Skill", backref="parentskill")
parentId = Column(Integer, ForeignKey('skills.id'))
- name = Column(String)
- person = Column(String) # Will be a FK to the Person table
+ name = Column(String, unique = True)
crossSkills = relationship("skill_transfer_ratio", backref="toSkill")
- # Constraints
- UniqueConstraint(name, person)
-
def __init__(self, name, parent = None):
self.name = name
@@ -156,5 +152,75 @@ def addCrossSkill(self, val):
if val not in self.crossSkills:
self.crossSkills.append(val)
+class SkillRating(Base):
+ '''
+ This class actually describes a particular person's skill.
+ '''
+
+ def __init__(self, person, rating, skill):
+ self.person = person
+ self.rating = rating
+ self.skill = skill
+ self.skillId = skill.getId()
+
+
+ __tablename__ = 'skill_ratings'
+
+ id = Column(Integer, primary_key=True)
+ person = Column(String) # Will be a FK to the Person table
+ rating = Column(Integer)
+ skillId = Column(Integer, ForeignKey('skills.id'))
+ skill = relationship("Skill")
+
+ # Constraints
+ UniqueConstraint(person, skillId)
+
+ def getId(self):
+ return self.id
+
+ def setId(self, val):
+ self.id = val
+ return self
+
+ def getPerson(self):
+ return self.person
+
+ def setPerson(self, val):
+ self.person = val
+ return self
+
+ def getRating(self):
+ return self.rating
+
+ def setRating(self, val):
+ self.rating = val
+ return self
+
+ def getSkill(self):
+ return self.skill
+
+ def setSkill(self, val):
+ self.skill = val
+ return self
+
+ def getSkillId(self):
+ return self.skillId
+
+ def setSkillId(self, val):
+ self.skillId = val
+ return self
+
+
+def main():
+
+ db.saveDB.start()
+
+
+
+
+
+
+
-
+if __name__ == '__main__':
+ main()

0 comments on commit b34cfb3

Please sign in to comment.