Did I find the right examples for you? yes no

All Samples(46)  |  Call(46)  |  Derive(0)  |  Import(0)

src/d/a/darktower-rl-HEAD/storytelling/npc.py   darktower-rl(Download)
            return res[0]
        if util.onechancein(3):
    def _handle_desease(self, city):
        if self.plague and util.onechancein(15) and not self.invincible:
                self.history.append('In year %d %s became worshipper of %s' % (world.year, self.name, self.deity.name))
            elif util.onechancein(5): #in 1/5 cases giveup deity
                old_deity = self.deity
                new_deity = choice(city.deities)
    def item_was_stolen(self, what, who):
        super(GoodNPC, self).item_was_stolen(what, who)
        if util.onechancein(3):
            world.global_quests.append(RetrieveQuest(self, what, None))
            self.history.append('In year %d %s setted up bounty for anyone who can find %s' %
                    (world.year, self.name, what.unique_name))
    def free_action(self, city):
        if self.dead: return
        if util.onechancein(3):

src/d/a/darktower-rl-HEAD/storytelling/plot.py   darktower-rl(Download)
        while True:
            #first find target
            if util.onechancein(20): #mimic royalty
                if util.coinflip():
                    if wered_npc.has_key(world.king): continue
        if len(aarts) <= 0 : break
        if isinstance(npc, (ImmobileNPC, TraderNPC, DeityNPC)):continue
        if util.onechancein(ARTEFACT_OWNER_CHANCE):
            art = aarts.pop()
            if a.dead or b.dead: continue
            if not a.know(b) and util.onechancein(3):
                a.ack(b, city)
            elif a.know(b):
        if city.plague_src : #if there is a plague in the city
            if util.onechancein(15) and city==world.capital and len(world.royalties): 
                #infect royalty
                victim = choice(world.royalties)
                victim.plague = True
            elif util.onechancein(7) and len(city.denizens):

src/d/a/darktower-rl-HEAD/acquire.py   darktower-rl(Download)
    if util.coinflip():
        cost -= _make_brand(wep)
    if util.onechancein(5):
        cost += FIXED_ART_UP
        cost -= _make_randart(wep, unique)
    cost -= base_type.base_cost
    arm = base_type()
    if util.onechancein(6):
        cost -= _make_resist(arm)
    elif util.onechancein(7) or artefact:
def _make_resist(arm):
    """ This is used for items with single resistance alowed - like armor """
    if util.onechancein(5):
        arm.resist = "fire"
    return 400
        max_wait -= 1
        if single_digit:
            if util.onechancein(3) and wep.enchantment < wep.max_enchantment and cost > 0:
                wep.enchantment += 1
                cost -= ONE_PIECE_ENCHANTMENT

src/d/a/darktower-rl-HEAD/items.py   darktower-rl(Download)
    while artefacts_count > 0:
        artefacts_count -= 1
        if util.onechancein(3) and len(arts) > 0:

src/d/a/darktower-rl-HEAD/storytelling/quests.py   darktower-rl(Download)
    def fulfil(self, hero, chance=15):
        if util.onechancein(chance): #yeah, rescuing princesses is that simple
            hero.history.append('In year %d %s rescued %s' %
                    (world.year, hero.name, self.who.name))
    def fulfil(self, hero, chance=15):
        if util.onechancein(chance):
            thief = 'unknown man'
            if self.thief:
                thief = self.thief.name
    def fulfil(self, hero, chance=15):
        if util.onechancein(chance):
            hero.retrieve_lost(self.issuer, self.what)