Beispiel #1
0
def age_stats(age, stats, history, automatic=False):
    if age < 34:
        if not automatic:
            print("No age effect as of yet.")
        return stats
    elif age < 50:
        if not automatic:
            print("Rolls for age related characteristics loss.")
        roll = sum_roll_dice(6, 2)
        if roll < 8:
            stats["Str"] -= 1
            history.append("Lost 1 Strength to age.")
        roll = sum_roll_dice(6, 2)
        if roll < 7:
            stats["Dex"] -= 1
            history.append("Lost 1 Dexterity to age.")
        roll = sum_roll_dice(6, 2)
        if roll < 8:
            stats["End"] -= 1
            history.append("Lost 1 Endurance to age.")
    elif age < 66:
        if not automatic:
            print("Rolls for age related characteristics loss.")
        roll = sum_roll_dice(6, 2)
        if roll < 9:
            stats["Str"] -= 1
            history.append("Lost 1 Strength to age.")
        roll = sum_roll_dice(6, 2)
        if roll < 8:
            stats["Dex"] -= 1
            history.append("Lost 1 Dexterity to age.")
        roll = sum_roll_dice(6, 2)
        if roll < 9:
            stats["End"] -= 1
            history.append("Lost 1 Endurance to age.")
    if age > 65:
        if not automatic:
            print("Rolls for age related characteristics loss.")
        roll = sum_roll_dice(6, 2)
        if roll < 9:
            stats["Str"] -= 2
            history.append("Lost 2 Strength to age.")
        roll = sum_roll_dice(6, 2)
        if roll < 9:
            stats["Dex"] -= 2
            history.append("Lost 2 Dexterity to age.")
        roll = sum_roll_dice(6, 2)
        if roll < 9:
            stats["End"] -= 2
            history.append("Lost 2 Endurance to age.")
        roll = sum_roll_dice(6, 2)
        if roll < 9:
            stats["Int"] -= 1
            history.append("Lost 1 Intelligence to age.")
    return stats
 def calc_gas_giant_presence(self):
     """
         Gas giants are common
     """
     roll = sum_roll_dice(6, 2)
     if roll < 10:
         self.has_gas_giant = True
Beispiel #3
0
def service_reenlistment(service_name: str):
    """
        Determines if character can, has to or cannot reenlist
        :return: 1 : has to reenlist (nat 12)
                 0 : can reenlist
                -1 : cannot reenlist
    """
    limit = 0
    if service_name == "Army":
        limit = 6
    elif service_name == "Marines" or service_name == "Navy":
        limit = 5
    elif service_name == "Merchants":
        limit = 3
    elif service_name == "Scouts":
        limit = 2
    elif service_name == "Others":
        limit = 4
    reenlist_roll = sum_roll_dice(6, 2)
    if reenlist_roll == 12:
        return 1
    elif reenlist_roll > limit:
        return 0
    else:
        return -1
Beispiel #4
0
def survive(stats: dict, service_name: str):
    dm = 0
    limit = 0
    if service_name == "Army":
        if stats["Edu"] > 6:
            dm += 2
        limit = 4
    elif service_name == "Marines":
        if stats["End"] > 7:
            dm += 2
        limit = 5
    elif service_name == "Navy" or service_name == "Merchants":
        if stats["Int"] > 6:
            dm += 2
        limit = 4
    elif service_name == "Scouts":
        if stats["End"] > 8:
            dm += 2
        limit = 6
    elif service_name == "Others":
        if stats["Int"] > 8:
            dm += 2
        limit = 4
    survival_roll = sum_roll_dice(6, 2) + dm
    if survival_roll > limit:
        return True
    else:
        return False
 def calc_naval_base(self):
     """
         Caculates the presence of a naval base
     """
     if self.starport not in ["C", "D", "E", "X"]:
         roll = sum_roll_dice(6, 2)
         if roll > 7:
             self.has_naval_base = True
Beispiel #6
0
def generate_attributes(generation_type, stats=None):
    """Allows for more than one type of attributes generation
    Takes an int to pick the type of generation (example)
        1: 4d6 drop lowest
        2: 3d6
        3: 3d6 re-roll lower than 7 (8?)
        4: pick all 6
        5: re-roll if not 3 < bonus < 7"""
    attributes = {}
    random_attributes = []
    if generation_type == 1:
        for _ in range(6):
            random_attributes.append(keep_n_highest_sum(6, 4))
    if generation_type == 2:
        random_attributes = []
        for _ in range(6):
            random_attributes.append(sum_roll_dice(6, 3))
    if generation_type == 3:
        random_attributes = []
        for _ in range(6):
            roll_not_ok = True
            while roll_not_ok:
                roll = sum_roll_dice(6, 3)
                if roll > 7:
                    roll_not_ok = False
                    random_attributes.append(roll)
    if generation_type == 4:
        random_attributes = stats
    if generation_type == 5:
        valid_results = False
        while not valid_results:
            random_attributes = []
            for _ in range(6):
                random_attributes.append(keep_n_highest_sum(6, 4))
            valid_results = 3 <= sum_modifiers(random_attributes) <= 7

    if random_attributes:
        attributes = {
            "Strength": random_attributes[0],
            "Dexterity": random_attributes[1],
            "Constitution": random_attributes[2],
            "Intelligence": random_attributes[3],
            "Wisdom": random_attributes[4],
            "Charisma": random_attributes[5]
        }
    return attributes
 def calc_government(self):
     if self.population == "A":
         pop = 10
     else:
         pop = str(self.population)
     roll = sum_roll_dice(6, 2) - 7 + int(pop)
     if roll < 0:
         roll = 0
     elif roll > 13:
         roll = 13
     self.government = hex(roll)[2:].upper()
 def calc_scout_base(self):
     """
         Calculates the presence of a scout base
     """
     dm = 0
     if self.starport == "C":
         dm += -1
     elif self.starport == "B":
         dm += -2
     elif self.starport == "A":
         dm += -3
     if self.starport not in ["E", "X"]:
         roll = sum_roll_dice(6, 2) + dm
         if roll > 6:
             self.has_scout_base = True
 def calc_atmosphere(self):
     """
         Calculates the atmosphere of the world
     """
     if self.size == "0":
         size = 0
     elif self.size == "A":
         size = 10
     else:
         size = int(self.size)
     roll = sum_roll_dice(6, 2) - 7 + size
     if roll < 0:
         roll = 0
     elif roll > 12:
         roll = 12
     self.atmosphere = hex(roll)[2:].upper()
 def calc_starport_type(self):
     """
         Calculates the type of starport
     """
     roll = sum_roll_dice(6, 2)
     if roll in [2, 3, 4]:
         self.starport = "A"
     elif roll in [5, 6]:
         self.starport = "B"
     elif roll in [7, 8]:
         self.starport = "C"
     elif roll == 9:
         self.starport = "D"
     elif roll in [10, 11]:
         self.starport = "E"
     elif roll == 12:
         self.starport = "X"
Beispiel #11
0
def roll_stats():
    """
        Rolls stats according to Classic Traveller's way
        and assigns them in order from Str to Dex to End
        to Int to Edu
        :return: an array of 6 results of 2d6 rolls
    """
    statistics = []
    for _ in range(6):
        statistics.append(sum_roll_dice(6, 2))
    dict_stats = {
        "Str": statistics[0],
        "Dex": statistics[1],
        "End": statistics[2],
        "Int": statistics[3],
        "Edu": statistics[4],
        "Soc": statistics[5]
    }
    return dict_stats
 def calc_hydrography(self):
     """
         Calculates planetary hydrographic percentage
     """
     if self.size == 0:
         self.hydrography = "0"
     dm = 0
     if self.atmosphere in ["0", "1", "A", "B", "C"]:
         dm = -4
     else:
         dm = int(self.atmosphere)
     roll = sum_roll_dice(6, 2) - 7 + dm
     if roll < 0:
         roll = 0
     if roll > 10:
         roll = 10
     hex_trans = hex(roll)[2:].upper()
     if len(hex_trans) > 1:
         hex_trans = hex_trans[len(hex_trans) - 1]
     self.hydrography = hex_trans
 def calc_law_level(self):
     if self.government == "A":
         gov = 10
     elif self.government == "B":
         gov = 11
     elif self.government == "C":
         gov = 12
     elif self.government == "D":
         gov = 13
     else:
         gov = int(self.government)
     roll = sum_roll_dice(6, 2) - 7 + int(gov)
     if roll < 0:
         roll = 0
     elif roll > 10:
         roll = 10
     hex_trans = hex(roll)[2:].upper()
     if len(hex_trans) > 1:
         hex_trans = hex_trans[len(hex_trans) - 1]
     self.law_level = hex_trans
Beispiel #14
0
def enlist(stats, service_name: str):
    dm = 0
    limit = 0
    if service_name == "Army":
        if stats["Dex"] > 5:
            dm += 1
        if stats["End"] > 4:
            dm += 2
        limit = 4
    elif service_name == "Marines":
        if stats["Int"] > 7:
            dm += 1
        if stats["Str"] > 7:
            dm += 2
        limit = 8
    elif service_name == "Navy":
        if stats["Int"] > 7:
            dm += 1
        if stats["Edu"] > 8:
            dm += 2
        limit = 7
    elif service_name == "Merchants":
        if stats["Str"] > 6:
            dm += 1
        if stats["Int"] > 5:
            dm += 2
        limit = 6
    elif service_name == "Scouts":
        if stats["Int"] > 5:
            dm += 1
        if stats["Str"] > 7:
            dm += 2
        limit = 6
    elif service_name == "Others":
        limit = 2
    enlist_roll = sum_roll_dice(6, 2) + dm
    if enlist_roll > limit:
        return True
    else:
        return False
Beispiel #15
0
def try_promotion(stats, service_name: str):
    dm = 0
    limit = 0
    if service_name == "Army":
        limit = 5
        if stats["Edu"] > 5:
            dm += 1
    elif service_name == "Marines":
        limit = 8
        if stats["Soc"] > 7:
            dm += 1
    elif service_name == "Navy":
        limit = 7
        if stats["Edu"] > 7:
            dm += 1
    elif service_name == "Merchants":
        limit = 9
        if stats["Int"] > 8:
            dm += 1
    promotion_roll = sum_roll_dice(6, 2) + dm
    if promotion_roll > limit:
        return True
    else:
        return False
Beispiel #16
0
def try_commission(stats, service_name: str):
    dm = 0
    limit = 0
    if service_name == "Army":
        if stats["End"] > 6:
            dm = 1
        limit = 4
    elif service_name == "Marines":
        if stats["Edu"] > 6:
            dm = 1
        limit = 8
    elif service_name == "Navy":
        if stats["Soc"] > 8:
            dm = 1
        limit = 9
    elif service_name == "Merchants":
        if stats["Int"] > 5:
            dm = 1
        limit = 3
    commission_roll = sum_roll_dice(6, 2) + dm
    if commission_roll > limit:
        return True
    else:
        return False
 def calc_size(self):
     """
         Calculates the world size
     """
     roll = sum_roll_dice(6, 2) - 2
     self.size = hex(roll)[2:].upper()
 def calc_population(self):
     roll = sum_roll_dice(6, 2) - 2
     self.population = hex(roll)[2:].upper()