skycalc/calculator.py
def simulate_training(original_skill_levels, current, goal, selected_from):
    """Simulate skill training and return resulting information.

    Attributes:
        original_skill_levels: dict containing current levels of used skills.
        current (int): current character level
        goal (int): goal level
        selected_from: selection method used for optimization
    """

    def done(xp):
        return xp <= 0

    def make_result_dict(original_dict):
        """Return formatted skill data dictionary.

        Attributes:
            original_dict: dict containing current levels of used skills.
        """

        def reformat(entry):
            """Reformat dictionary entry."""
            return {"Start Level": original_dict[entry],
                    "Times Leveled": 0,
                    "Times Legendary": 0,
                    "Final Level": original_dict[entry]}

        return {entry: reformat(entry) for entry in original_dict}

    def total_xp(current_lvl, goal_lvl):
        """Return xp needed to advance from a current level to a goal level.

        Attributes:
            current_lvl (int): current character level
            goal_lvl (int): goal level
        """

        def level_up_xp(level):
            """Return xp needed for next level-up at a given level."""
            return (level + 3) * 25

        return sum(level_up_xp(lvl) for lvl in range(current_lvl, goal_lvl))

    # TODO: get rid of side effects
    def train(data, skill):
        """Update data as if a skill was trained."""

        def trained(skill_level):
            """Return level reached by training a skill with a given level."""
            if skill_level == 100:  # 'make legendary'
                return 16
            else:
                return skill_level + 1

        data[skill]["Final Level"] = trained(data[skill]["Final Level"])
        data[skill]["Times Leveled"] += 1

    # TODO: make 'prettier'
    needed_xp = total_xp(current, goal)
    skill_data = make_result_dict(original_skill_levels)

    while not done(needed_xp):
        selected_skill = selected_from(skill_data)
        train(skill_data, selected_skill)
        needed_xp -= skill_data[selected_skill]["Final Level"]
    return skill_data
Simulate skill training and return resulting information.

    Attributes:
        original_skill_levels: dict containing current levels of used skills.
        current (int): current character level
        goal (int): goal level
        selected_from: selection method used for optimization
    
Simulate skill training and return resulting information.
Simulate skill training and return resulting information .
def simulate_training(original_skill_levels, current, goal, selected_from):
    def done(xp):
        return xp <= 0
    def make_result_dict(original_dict):
        def reformat(entry):
            return {"Start Level": original_dict[entry],
                    "Times Leveled": 0,
                    "Times Legendary": 0,
                    "Final Level": original_dict[entry]}
        return {entry: reformat(entry) for entry in original_dict}
    def total_xp(current_lvl, goal_lvl):
        def level_up_xp(level):
            return (level + 3) * 25
        return sum(level_up_xp(lvl) for lvl in range(current_lvl, goal_lvl))
    def train(data, skill):
        def trained(skill_level):
            if skill_level == 100:  
                return 16
            else:
                return skill_level + 1
        data[skill]["Final Level"] = trained(data[skill]["Final Level"])
        data[skill]["Times Leveled"] += 1
    needed_xp = total_xp(current, goal)
    skill_data = make_result_dict(original_skill_levels)
    while not done(needed_xp):
        selected_skill = selected_from(skill_data)
        train(skill_data, selected_skill)
        needed_xp -= skill_data[selected_skill]["Final Level"]
    return skill_data
def simulate_training ( original_skill_levels , current , goal , selected_from ) : def done ( xp ) : return xp <= 0 def make_result_dict ( original_dict ) : """Return formatted skill data dictionary.

        Attributes:
            original_dict: dict containing current levels of used skills.
        """ def reformat ( entry ) : """Reformat dictionary entry.""" return { "Start Level" : original_dict [ entry ] , "Times Leveled" : 0 , "Times Legendary" : 0 , "Final Level" : original_dict [ entry ] } return { entry : reformat ( entry ) for entry in original_dict } def total_xp ( current_lvl , goal_lvl ) : """Return xp needed to advance from a current level to a goal level.

        Attributes:
            current_lvl (int): current character level
            goal_lvl (int): goal level
        """ def level_up_xp ( level ) : """Return xp needed for next level-up at a given level.""" return ( level + 3 ) * 25 return sum ( level_up_xp ( lvl ) for lvl in range ( current_lvl , goal_lvl ) ) def train ( data , skill ) : """Update data as if a skill was trained.""" def trained ( skill_level ) : """Return level reached by training a skill with a given level.""" if skill_level == 100 : return 16 else : return skill_level + 1 data [ skill ] [ "Final Level" ] = trained ( data [ skill ] [ "Final Level" ] ) data [ skill ] [ "Times Leveled" ] += 1 needed_xp = total_xp ( current , goal ) skill_data = make_result_dict ( original_skill_levels ) while not done ( needed_xp ) : selected_skill = selected_from ( skill_data ) train ( skill_data , selected_skill ) needed_xp -= skill_data [ selected_skill ] [ "Final Level" ] return skill_data
Simulate skill training and return resulting information.
Simulate skill training and return resulting information .
"""Simulate skill training and return resulting information.

    Attributes:
        original_skill_levels: dict containing current levels of used skills.
        current (int): current character level
        goal (int): goal level
        selected_from: selection method used for optimization
    """ """Return formatted skill data dictionary.

        Attributes:
            original_dict: dict containing current levels of used skills.
        """ """Reformat dictionary entry.""" """Return xp needed to advance from a current level to a goal level.

        Attributes:
            current_lvl (int): current character level
            goal_lvl (int): goal level
        """ """Return xp needed for next level-up at a given level.""" # TODO: get rid of side effects """Update data as if a skill was trained.""" """Return level reached by training a skill with a given level.""" # 'make legendary' # TODO: make 'prettier'
original_skill_levels
dict containing current levels of used skills.
dict containing current levels of used skills .
current
current character level
current character level
goal
None
selected_from
selection method used for optimization
selection method used for optimization