Exemple #1
0
 def become_older(self, years):
     if self.age + years >= 74 or self.age >= 34 and (self.age + years % 4 == 0 or self.age % 4 >= self.age + years % 4):
         if self.age < 50:
             if test(roll(2, rng=self.rng), +8):
                 self.strength -= 1
             if test(roll(2, rng=self.rng), +7):
                 self.dexterity -= 1
             if test(roll(2, rng=self.rng), +8):
                 self.endurance -= 1
         elif self.age < 66:
             if test(roll(2, rng=self.rng), +9):
                 self.strength -= 1
             if test(roll(2, rng=self.rng), +8):
                 self.dexterity -= 1
             if test(roll(2, rng=self.rng), +9):
                 self.endurance -= 1
         else:
             if test(roll(2, rng=self.rng), +9):
                 self.strength -= 2
             if test(roll(2, rng=self.rng), +9):
                 self.dexterity -= 2
             if test(roll(2, rng=self.rng), +9):
                 self.endurance -= 2
             if test(roll(2, rng=self.rng), +9):
                 self.intelligence -= 1
     self.age += years
Exemple #2
0
 def become_older(self, years):
     if self.age + years >= 74 or self.age >= 34 and (
             self.age + years % 4 == 0
             or self.age % 4 >= self.age + years % 4):
         if self.age < 50:
             if test(roll(2, rng=self.rng), +8):
                 self.strength -= 1
             if test(roll(2, rng=self.rng), +7):
                 self.dexterity -= 1
             if test(roll(2, rng=self.rng), +8):
                 self.endurance -= 1
         elif self.age < 66:
             if test(roll(2, rng=self.rng), +9):
                 self.strength -= 1
             if test(roll(2, rng=self.rng), +8):
                 self.dexterity -= 1
             if test(roll(2, rng=self.rng), +9):
                 self.endurance -= 1
         else:
             if test(roll(2, rng=self.rng), +9):
                 self.strength -= 2
             if test(roll(2, rng=self.rng), +9):
                 self.dexterity -= 2
             if test(roll(2, rng=self.rng), +9):
                 self.endurance -= 2
             if test(roll(2, rng=self.rng), +9):
                 self.intelligence -= 1
     self.age += years
Exemple #3
0
 def test_survival(self, character, rng):
     skill, req = self.survival_skill
     if character.get_characteristic(skill) >= skill:
         dm = 2
     else:
         dm = 0
     return test(self.survival, roll(2, dm, rng=rng))
Exemple #4
0
 def tech_level(self):
     if self._tech_level is None:
         tech_level_dm = 0
         starport_tech_level_dm = {
             "A": 6,
             "B": 4,
             "C": 2,
             "X": -4
         }
         tech_level_dm += starport_tech_level_dm.get(self.starport, 0)
         if self.radius in (0, 1):
             tech_level_dm += 2
         elif self.radius in (2, 3, 4):
             tech_level_dm += 1
         if self.atmosphere < 4 or self.atmosphere > 9:
             tech_level_dm += 1
         if self.hydrographics > 8:
             tech_level_dm += self.hydrographics - 8
         if 6 > self.population_level > 0:
             tech_level_dm += 1
         elif self.population_level > 8:
             tech_level_dm += 2 * (self.population_level - 8)
         if self.government_type in (0, 5):
             tech_level_dm += 1
         elif self.government_type == 0xD:
             tech_level_dm -= 2
         self._tech_level = max(1, roll(1, tech_level_dm, rng=self.star.rng))
     return self._tech_level
Exemple #5
0
 def government_type(self):
     if self._government is None:
         self._government = min(
             0xD,
             max(0,
                 roll(2, -7, rng=self.star.rng) + self.population_level))
     return self._government
Exemple #6
0
 def test_promotion(self, character, rng):
     if self.promotion_skill is None:
         return False
     skill, req = self.commission_skill
     if character.get_characteristic(skill) >= skill:
         dm = 1
     else:
         dm = 0
     return test(self.promotion, roll(2, dm, rng=rng))
Exemple #7
0
 def atmosphere(self):
     if self._atmosphere is None:
         self._atmosphere = min(
             12,
             max(
                 0,
                 roll(2, -7, rng=self.star.rng) +
                 self.radius if self.radius else 0))
     return self._atmosphere
Exemple #8
0
 def test_enlistment(self, character, rng):
     dm = 0
     if self.enlistment_skill_one is not None:
         skill, req = self.enlistment_skill_one
         if character.get_characteristic(skill) >= skill:
             dm += 1
         skill, req = self.enlistment_skill_two
         if character.get_characteristic(skill) >= skill:
             dm += 2
     return test(self.enlistment, roll(2, dm, rng=rng))
Exemple #9
0
 def hydrographics(self):
     if self._hydrographics is None:
         hydrographic_dm = -11 if self.atmosphere in (
             0, 1) or self.atmosphere > 9 else -7
         self._hydrographics = min(
             10,
             max(
                 0,
                 roll(2, hydrographic_dm, rng=self.star.rng) +
                 self.atmosphere if self.radius else 0))
     return self._hydrographics
Exemple #10
0
 def tech_level(self):
     if self._tech_level is None:
         tech_level_dm = 0
         starport_tech_level_dm = {"A": 6, "B": 4, "C": 2, "X": -4}
         tech_level_dm += starport_tech_level_dm.get(self.starport, 0)
         if self.radius in (0, 1):
             tech_level_dm += 2
         elif self.radius in (2, 3, 4):
             tech_level_dm += 1
         if self.atmosphere < 4 or self.atmosphere > 9:
             tech_level_dm += 1
         if self.hydrographics > 8:
             tech_level_dm += self.hydrographics - 8
         if 6 > self.population_level > 0:
             tech_level_dm += 1
         elif self.population_level > 8:
             tech_level_dm += 2 * (self.population_level - 8)
         if self.government_type in (0, 5):
             tech_level_dm += 1
         elif self.government_type == 0xD:
             tech_level_dm -= 2
         self._tech_level = max(1, roll(1, tech_level_dm,
                                        rng=self.star.rng))
     return self._tech_level
Exemple #11
0
 def government_type(self):
     if self._government is None:
         self._government = min(0xD, max(0, roll(2, -7, rng=self.star.rng) + self.population_level))
     return self._government
Exemple #12
0
 def radius(self):
     if self._radius is None:
         self._radius = roll(2, -2, rng=self.star.rng)
     return self._radius
Exemple #13
0
 def law_level(self):
     if self._law_level is None:
         self._law_level = min(
             10, max(0, roll(2, self.government_type - 7,
                             rng=self.star.rng)))
     return self._law_level
Exemple #14
0
 def population_level(self):
     if self._population is None:
         self._population = roll(2, -2, rng=self.star.rng)
     return self._population
Exemple #15
0
 def law_level(self):
     if self._law_level is None:
         self._law_level = min(10, max(0, roll(2, self.government_type-7, rng=self.star.rng)))
     return self._law_level
Exemple #16
0
    def __init__(self, rng, name, profession, death=False):
        self.rng = rng

        self._name = name
        self.age = 18
        self.terms = 0
        self.half_terms = 0
        self.balance = 0
        self.equipment = []
        self.alive = True
        self.commissioned = False
        self.claimed_autoskills = []

        self.strength = roll(2, rng=self.rng)
        self.dexterity = roll(2, rng=self.rng)
        self.endurance = roll(2, rng=self.rng)
        self.intelligence = roll(2, rng=self.rng)
        self.education = roll(2, rng=self.rng)
        self.social = roll(2, rng=self.rng)

        self.skills = defaultdict(int)
        self._rank = 0

        if profession.test_enlistment(self, self.rng):
            self.profession = profession
            self.drafted = False
        else:
            self.profession = self.rng.choice(DRAFT)
            self.drafted = True

        terms = 7

        while True:
            survival = self.profession.test_survival(self, rng)

            if not survival:
                if death:
                    self.alive = False
                    return
                else:
                    self.become_older(2)
                    self.half_terms += 1
                    terms -= 1
                    continue

            self.become_older(4)

            for rank, kind, skill in (skill for skill in self.profession.autoskills if not skill in self.claimed_autoskills):
                if self._rank >= rank:
                    if kind == CHARACTERISTIC:
                        self.set_characteristic(skill, 1)
                    elif kind == SKILL:
                        self.skills[skill] += 1
                    self.claimed_autoskills.append((rank, kind, skill))

            if self.terms == 0:
                skills = 2
            else:
                skills = self.profession.advancements

            if not self.drafted:
                if not self.commissioned:
                    if self.profession.test_commission(self, rng):
                        self.commissioned = True
                        skills += 1
                else:
                    if self.profession.test_promotion(self, rng) and self._rank + 2 < len(self.profession.ranks):
                        self._rank += 1
                        skills += 1

            self.drafted = False
            for _ in range(skills*2):
                kind, skill = self.rng.choice(self.rng.choice(self.profession.skills))
                if kind == CHARACTERISTIC:
                    self.set_characteristic(skill, 1)
                elif kind == SKILL:
                    self.skills[skill] += 1

            self.terms += 1
            terms -= 1

            if not self.profession.test_reenlist(self, rng, terms > 0):
                break

        mustering_benefits = self.terms
        if self._rank in (0, 1):
            mustering_benefits += 1
        elif self._rank in (2, 3):
            mustering_benefits += 2
        elif self._rank in (4, 5):
            mustering_benefits += 3

        benfits_table = [
            [
                (BENEFIT, "Low Passage"), (BENEFIT, "Low Passage"), (BENEFIT, "Low Passage"),
                (BENEFIT, "Low Passage"), (BENEFIT, "Low Passage"), (BENEFIT, "Low Passage"),
            ],
            [
                (CHARACTERISTIC, (INTELLIGENCE, 1)), (CHARACTERISTIC, (INTELLIGENCE, 2)),
                (CHARACTERISTIC, (INTELLIGENCE, 1)), (CHARACTERISTIC, (INTELLIGENCE, 2)),
                (CHARACTERISTIC, (INTELLIGENCE, 1)), (CHARACTERISTIC, (INTELLIGENCE, 1)),
            ],
            [
                (CHARACTERISTIC, (EDUCATION, 1)), (CHARACTERISTIC, (EDUCATION, 2)),
                (CHARACTERISTIC, (EDUCATION, 2)), (CHARACTERISTIC, (EDUCATION, 2)),
                (CHARACTERISTIC, (EDUCATION, 1)), (CHARACTERISTIC, (EDUCATION, 1)),
            ],
            [
                (BENEFIT, "Gun"), (BENEFIT, "Gun"), (BENEFIT, "Gun"),
                (BENEFIT, "Blade"), (BENEFIT, "Blade"), (BENEFIT, "Blade"),
            ],
            [
                (BENEFIT, "Traveller's Aid Society Membership"), (BENEFIT, "Traveller's Aid Society Membership"),
                (BENEFIT, "High Passage"), (BENEFIT, "High Passage"), (BENEFIT, "Gun"), (BENEFIT, "Blade"),
            ],
            [
                (BENEFIT, "High Passage"), (BENEFIT, "High Passage"), (BENEFIT, "Mid Passage"),
                (BENEFIT, "Scout Ship"), (BENEFIT, "Low Passage")
            ],
            [
                (CHARACTERISTIC, (SOCIAL, 2)), (CHARACTERISTIC, (SOCIAL, 2)), (CHARACTERISTIC, (SOCIAL, 1)),
                (BENEFIT, "Free Trader")
            ],
        ]

        cash_table = [
            [1000, 2000, 2000, 20000, 1000, 1000],
            [5000, 5000, 5000, 5000, 5000, 20000],
            [5000, 5000, 10000, 20000, 5000, 5000],
            [10000, 10000, 10000, 30000, 20000, 10000],
            [20000, 20000, 10000, 50000, 20000, 10000],
            [50000, 30000, 20000, 50000, 40000, 50000],
            [50000, 40000, 30000, 50000, 40000, 100000],
        ]

        money_rolls = 3

        for _ in range(mustering_benefits):
            if money_rolls and self.rng.choice((True, False)):
                money_rolls -= 1
                self.balance += self.rng.choice(cash_table[roll(1, 0 if self.skills["Gambling"] else -1, rng=self.rng)])
            benefit_row_options = range(6) + ([n+1 for n in range(6)] if self._rank in (4, 5) else [])
            kind, benefit = self.rng.choice(benfits_table[self.rng.choice(benefit_row_options)])
            if kind == CHARACTERISTIC:
                characteristic, value = benefit
                self.set_characteristic(characteristic, value)
            elif kind == BENEFIT:
                thing = benefit
                while thing == "Traveller's Aid Society Membership" and thing in self.equipment:
                    kind, thing = self.rng.choice(benfits_table[4])
                if thing == "Blade" and thing in self.equipment:
                    self.skills["Blade Combat"] += 1
                    continue
                elif thing == "Gun" and thing in self.equipment:
                    self.skills["Gun Combat"] += 1
                    continue
                self.equipment.append(benefit)
            elif kind == SKILL:
                skill, value = benefit
                self.skills[skill] += value

        self.equipment = ["{} {}s".format(v, k) if v - 1 else k for k, v in Counter(self.equipment).items()]
        if not self.skills["Gambling"]:
            del self.skills["Gambling"]
Exemple #17
0
 def test_reenlist(self, character, rng, voluntary=True):
     result = roll(2, rng=rng)
     return (test(self.reenlist, result) and voluntary) or result == 12
Exemple #18
0
 def population_level(self):
     if self._population is None:
         self._population = roll(2, -2, rng=self.star.rng)
     return self._population
Exemple #19
0
 def radius(self):
     if self._radius is None:
         self._radius = roll(2, -2, rng=self.star.rng)
     return self._radius
Exemple #20
0
 def atmosphere(self):
     if self._atmosphere is None:
         self._atmosphere = min(12, max(0, roll(2, -7, rng=self.star.rng) + self.radius if self.radius else 0))
     return self._atmosphere
Exemple #21
0
    def __init__(self, rng, name, profession, death=False):
        self.rng = rng

        self._name = name
        self.age = 18
        self.terms = 0
        self.half_terms = 0
        self.balance = 0
        self.equipment = []
        self.alive = True
        self.commissioned = False
        self.claimed_autoskills = []

        self.strength = roll(2, rng=self.rng)
        self.dexterity = roll(2, rng=self.rng)
        self.endurance = roll(2, rng=self.rng)
        self.intelligence = roll(2, rng=self.rng)
        self.education = roll(2, rng=self.rng)
        self.social = roll(2, rng=self.rng)

        self.skills = defaultdict(int)
        self._rank = 0

        if profession.test_enlistment(self, self.rng):
            self.profession = profession
            self.drafted = False
        else:
            self.profession = self.rng.choice(DRAFT)
            self.drafted = True

        terms = 7

        while True:
            survival = self.profession.test_survival(self, rng)

            if not survival:
                if death:
                    self.alive = False
                    return
                else:
                    self.become_older(2)
                    self.half_terms += 1
                    terms -= 1
                    continue

            self.become_older(4)

            for rank, kind, skill in (skill
                                      for skill in self.profession.autoskills
                                      if not skill in self.claimed_autoskills):
                if self._rank >= rank:
                    if kind == CHARACTERISTIC:
                        self.set_characteristic(skill, 1)
                    elif kind == SKILL:
                        self.skills[skill] += 1
                    self.claimed_autoskills.append((rank, kind, skill))

            if self.terms == 0:
                skills = 2
            else:
                skills = self.profession.advancements

            if not self.drafted:
                if not self.commissioned:
                    if self.profession.test_commission(self, rng):
                        self.commissioned = True
                        skills += 1
                else:
                    if self.profession.test_promotion(
                            self, rng) and self._rank + 2 < len(
                                self.profession.ranks):
                        self._rank += 1
                        skills += 1

            self.drafted = False
            for _ in range(skills * 2):
                kind, skill = self.rng.choice(
                    self.rng.choice(self.profession.skills))
                if kind == CHARACTERISTIC:
                    self.set_characteristic(skill, 1)
                elif kind == SKILL:
                    self.skills[skill] += 1

            self.terms += 1
            terms -= 1

            if not self.profession.test_reenlist(self, rng, terms > 0):
                break

        mustering_benefits = self.terms
        if self._rank in (0, 1):
            mustering_benefits += 1
        elif self._rank in (2, 3):
            mustering_benefits += 2
        elif self._rank in (4, 5):
            mustering_benefits += 3

        benfits_table = [
            [
                (BENEFIT, "Low Passage"),
                (BENEFIT, "Low Passage"),
                (BENEFIT, "Low Passage"),
                (BENEFIT, "Low Passage"),
                (BENEFIT, "Low Passage"),
                (BENEFIT, "Low Passage"),
            ],
            [
                (CHARACTERISTIC, (INTELLIGENCE, 1)),
                (CHARACTERISTIC, (INTELLIGENCE, 2)),
                (CHARACTERISTIC, (INTELLIGENCE, 1)),
                (CHARACTERISTIC, (INTELLIGENCE, 2)),
                (CHARACTERISTIC, (INTELLIGENCE, 1)),
                (CHARACTERISTIC, (INTELLIGENCE, 1)),
            ],
            [
                (CHARACTERISTIC, (EDUCATION, 1)),
                (CHARACTERISTIC, (EDUCATION, 2)),
                (CHARACTERISTIC, (EDUCATION, 2)),
                (CHARACTERISTIC, (EDUCATION, 2)),
                (CHARACTERISTIC, (EDUCATION, 1)),
                (CHARACTERISTIC, (EDUCATION, 1)),
            ],
            [
                (BENEFIT, "Gun"),
                (BENEFIT, "Gun"),
                (BENEFIT, "Gun"),
                (BENEFIT, "Blade"),
                (BENEFIT, "Blade"),
                (BENEFIT, "Blade"),
            ],
            [
                (BENEFIT, "Traveller's Aid Society Membership"),
                (BENEFIT, "Traveller's Aid Society Membership"),
                (BENEFIT, "High Passage"),
                (BENEFIT, "High Passage"),
                (BENEFIT, "Gun"),
                (BENEFIT, "Blade"),
            ],
            [(BENEFIT, "High Passage"), (BENEFIT, "High Passage"),
             (BENEFIT, "Mid Passage"), (BENEFIT, "Scout Ship"),
             (BENEFIT, "Low Passage")],
            [(CHARACTERISTIC, (SOCIAL, 2)), (CHARACTERISTIC, (SOCIAL, 2)),
             (CHARACTERISTIC, (SOCIAL, 1)), (BENEFIT, "Free Trader")],
        ]

        cash_table = [
            [1000, 2000, 2000, 20000, 1000, 1000],
            [5000, 5000, 5000, 5000, 5000, 20000],
            [5000, 5000, 10000, 20000, 5000, 5000],
            [10000, 10000, 10000, 30000, 20000, 10000],
            [20000, 20000, 10000, 50000, 20000, 10000],
            [50000, 30000, 20000, 50000, 40000, 50000],
            [50000, 40000, 30000, 50000, 40000, 100000],
        ]

        money_rolls = 3

        for _ in range(mustering_benefits):
            if money_rolls and self.rng.choice((True, False)):
                money_rolls -= 1
                self.balance += self.rng.choice(cash_table[roll(
                    1, 0 if self.skills["Gambling"] else -1, rng=self.rng)])
            benefit_row_options = range(6) + ([n + 1 for n in range(6)]
                                              if self._rank in (4, 5) else [])
            kind, benefit = self.rng.choice(
                benfits_table[self.rng.choice(benefit_row_options)])
            if kind == CHARACTERISTIC:
                characteristic, value = benefit
                self.set_characteristic(characteristic, value)
            elif kind == BENEFIT:
                thing = benefit
                while thing == "Traveller's Aid Society Membership" and thing in self.equipment:
                    kind, thing = self.rng.choice(benfits_table[4])
                if thing == "Blade" and thing in self.equipment:
                    self.skills["Blade Combat"] += 1
                    continue
                elif thing == "Gun" and thing in self.equipment:
                    self.skills["Gun Combat"] += 1
                    continue
                self.equipment.append(benefit)
            elif kind == SKILL:
                skill, value = benefit
                self.skills[skill] += value

        self.equipment = [
            "{} {}s".format(v, k) if v - 1 else k
            for k, v in Counter(self.equipment).items()
        ]
        if not self.skills["Gambling"]:
            del self.skills["Gambling"]
Exemple #22
0
 def hydrographics(self):
     if self._hydrographics is None:
         hydrographic_dm = -11 if self.atmosphere in (0, 1) or self.atmosphere > 9 else -7
         self._hydrographics = min(10, max(0, roll(2, hydrographic_dm, rng=self.star.rng) + self.atmosphere if self.radius else 0))
     return self._hydrographics