コード例 #1
0
ファイル: charbuilder.py プロジェクト: jtsmith1287/gurpscg
  def setSkillLevel(self, skill):
    """Randomly sets the level of the skill.
    Args:
      skill: a list that is the skill to be leveled.
    Returns:
      skill: the skill with it's skill level appended.
    """
    skill_difficulty = skill[2]
    # We get the list of possible point costs
    point_table = utils.getColumnFromTable(SKILL_COST_TABLE, "PS")
    # Then we'll get a weighted random point cost from that list
    points_to_spend = point_table[utils.randBiDistrib(point_table, 1)]
    counter = 0
    while counter < 1000 and points_to_spend > int(self.misc["spent_points"]) + 3:
      counter +=1
      if counter > 998:Print("out of control while loop line 490")
      points_to_spend = point_table[utils.randBiDistrib(point_table, 1)]
    # We'll need the column for where we're going to get the relative skill level
    # based on the already chosen point cost
    table_index = SKILL_COST_TABLE[0].index(skill_difficulty)
    # This is where we get the row for all possible difficulties associated with
    # that point cost
    skill_levels = utils.getRowFromTable(SKILL_COST_TABLE, points_to_spend)
    # And now we actually get our skill level and we'll replace the skill
    # categories with the relative level, and then extend the skill to show the
    # actual level (which is the base attribute + the relative level
    relative_level = skill_levels[table_index]
    skill[-1] = relative_level
    skill.append(points_to_spend)
    self.updatePoints(points_to_spend)

    return skill
コード例 #2
0
ファイル: charbuilder.py プロジェクト: jtsmith1287/gurpscg
  def setAppearance(self):
    """Sets height, weight, build, and physical appearance."""
    height_options = utils.getColumnFromTable(HEIGHT_TABLE, "height")
    counter = 0
    while counter < 1000:
      counter +=1
      if counter > 998:Print("out of control while loop line 82")
      self.misc["build"] = BUILD_TABLE[0][utils.randBiDistrib(BUILD_TABLE[0], 2)]
      build_options = utils.getColumnFromTable(BUILD_TABLE, self.misc["build"])
      if self.checkDisadvantageLimit(build_options[-1]):
        break
    counter = 0
    while counter < 1000:
      counter +=1
      if counter > 998:Print("out of control while loop line 90")
      physical_appearance = APPEARANCE_TABLE[0][utils.randBiDistrib(APPEARANCE_TABLE[0], 5)]
      appearance_choice = utils.getColumnFromTable(APPEARANCE_TABLE, physical_appearance)
      if self.checkDisadvantageLimit(appearance_choice[-1]):
        break

    st = self.basic_attributes["ST"]
    if st < 6:
      st = 6
    elif st > 14:
      st = 14
    table_index = st - 6 # 6 is the lowest value in the table, which gives us 0

    # Set weight
    w_range = build_options[table_index]
    self.appearance["weight"] = str(random.randint(w_range[0], w_range[1])) + "lbs"

    # Set height
    ranges = (map(int, str(height_options[table_index][0]).split(".")),
              map(int, str(height_options[table_index][1]).split(".")))
    range_in_inches = (ranges[0][0] * 12 + ranges[0][1],
                       ranges[1][0] * 12 + ranges[1][1])
    height = divmod(random.randint(range_in_inches[0], range_in_inches[1]), 12)
    self.appearance["height"] = "%s ft %s inches" %(height[0], height[1])

    # Set physical appearance
    self.appearance["physical_appearance"] = "%s<br>%s" % (
        physical_appearance, appearance_choice[0])    

    # Set points
    self.updatePoints(build_options[-1])
    self.updatePoints(appearance_choice[-1])
コード例 #3
0
ファイル: charbuilder.py プロジェクト: jtsmith1287/gurpscg
  def setWealth(self):
    """Randomly selects starting wealth and status.

    Returns:
      wealth: a dictionary containing all wealth attributes for the character
    """

    wealth = {}
    counter = 0
    while counter < 1000:
      counter +=1
      if counter > 998:Print("out of control while loop line 146")
      wealth_status = WEALTH_TABLE[0][utils.randWeight(WEALTH_TABLE[0])]
      starting_wealth = STARTING_WEALTH[self.misc["TL"]]
      wealth_details = utils.getColumnFromTable(WEALTH_TABLE, wealth_status)
      if self.checkDisadvantageLimit(wealth_details[-1]):
        break
    wealth["starting_cash"] = "{:,}".format(int(starting_wealth * wealth_details[1]))
    wealth["status"] = wealth_status
    wealth["status_description"] = wealth_details[0]
    self.wealth.update(wealth)
    self.updatePoints(wealth_details[-1])