Beispiel #1
0
    def __init__(self):
        lang = choice(['cs','fi','fr','gd','nl','no']) + '.txt'
        
        self.ethnicities = []

        remaining = 1.0
        while remaining:
            prop = remaining/2 + random() * remaining/2
            if prop < 0.1 or prop > 0.85 * remaining:
                prop = remaining
            if self.ethnicities:
                ethnicity = prop, Ethnicity(choice(['cs','fi','fr','gd','nl','no']) + '.txt')
            else:
                ethnicity = prop, Ethnicity(lang)
            self.ethnicities.append(ethnicity)
            remaining -= prop

        if len(self.ethnicities) == 1:
            self.noun = self.ethnicities[0][1].noun
            self.adjective = self.ethnicities[0][1].adjective
            self.plural = self.ethnicities[0][1].plural
        else:
            name = NameGenerator(lang, 2 if random() < 0.1 else 1).generate()

            self.noun = name.title()
            if isvowel(self.noun[-1]):
                self.adjective = (self.noun[:-1]
                                  if len(self.noun) > 1
                                  else self.noun) + _(u'an')
                self.plural = self.adjective + _(u's')
            else:
                self.adjective = self.noun + _(u'ish')
                self.plural = self.adjective
Beispiel #2
0
    def __init__(self, lang):
        name = NameGenerator(lang, 2 if random() < 0.1 else 1).generate()

        self.noun = name.title()
        if isvowel(self.noun[-1]):
            self.adjective = (self.noun[:-1]
                              if len(self.noun) > 1
                              else self.noun) + _(u'an')
            self.plural = self.adjective + _(u's')
        else:
            self.adjective = self.noun + _(u'ish')
            self.plural = self.adjective
        
        r = randint(80,225)
        self.characteristics = [Skin([Attribute(r),
                                      Attribute(r-40),
                                      Attribute(r-80)]),
                                Nose([Attribute(random()),
                                      Attribute(random())])]

        water = random() > 0.25
        resources = [FoodSource(_(u'food crops'), random()),
                     FoodSource(_(u'grazable land'), random()),
                     FreshWater(_(u'rainfall'), random()),
                     FreshWater(_(u'natural spring water'), random())]

        if water:
            source = FreshWater(_(u'rivers and lakes'), random())
            resources.append(source)
            resources.append(FoodSource(_(u'seafood'), source.amount * random()))

        for t in _(u'spice crops'), _(u'timber'), _(u'precious metals'):
            if random() > 0.5:
                resources.append(TradeGood(t, random()))

        self.region = (NameGenerator(lang, 2 if random() < 0.1 else 1).generate(),
                       Region(75000*random(), resources))