def marciume(seed, room):

    if seed.code not in database["items"]:
        return
    frutto_marcio = Item("karpuram_item_mirtillo-rosso-00-frutto-marcio")
    if not frutto_marcio:
        log.bug("impossibile creare frutto_marcio: %r" % frutto_marcio)
        return

    if room != seed.location:
        # log da rimuovere
        log.bug("room di drop diversa da room attuale")
        return

    location = seed.location

    seed.act("$N appare tutto molliccio...", TO.OTHERS, seed)
    seed.act("$N appare tutto molliccio...", TO.ENTITY, seed)

    seed.extract()

    frutto_marcio.inject(location)

    frutto_marcio.act("... è $N buono solo come concime.", TO.OTHERS,
                      frutto_marcio)
    frutto_marcio.act("... è $N buono solo come concime.", TO.ENTITY,
                      frutto_marcio)
def growing(germoglio, room, age, fortuna):

    if germoglio.code not in database["items"]:
        return

    pianta = Item("karpuram_item_mirtillo-rosso-03-pianta")
    if not pianta:
        log.bug("impossibile creare pianta: %r" % pianta)
        return

    location = germoglio.location

    germoglio.act("Quel che poco tempo fa era solo $N, ora ...", TO.OTHERS,
                  germoglio)
    germoglio.act("Quel che poco tempo fa era solo $N, ora ...", TO.ENTITY,
                  germoglio)
    germoglio.extract(1)

    pianta.inject(location)

    pianta.act("... è $N.", TO.OTHERS, pianta)
    fortuna = fortuna - 1
    if random.randint(1, fortuna) == 1:
        reactor.callLater(random.randint(PLANT_WAIT_MIN, PLANT_WAIT_MAX),
                          desiccation, pianta, room, age)
        return
    reactor.callLater(random.randint(PLANT_WAIT_MIN, PLANT_WAIT_MAX), blooming,
                      pianta, room, age, fortuna)
def renew(fruttificato, room, age, fortuna):

    if fruttificato.code not in database["items"]:
        return

    pianta = Item("karpuram_item_mirtillo-rosso-03-pianta")
    if not pianta:
        log.bug("impossibile creare pianta: %r" % pianta)
        return

    age = age + 1
    location = fruttificato.location

    fruttificato.act("quel che un tempo doveva esser $N, ora ...", TO.OTHERS,
                     fruttificato)
    fruttificato.act("quel che un tempo doveva esser $N, ora ...", TO.ENTITY,
                     fruttificato)
    fruttificato.extract(1)

    pianta.inject(location)

    pianta.act("... è $N che fruttificherà più avanti", TO.OTHERS, pianta)
    pianta.act("... è $N che fruttificherà più avanti", TO.ENTITY, pianta)

    fortuna = fortuna - 1
    if random.randint(1, fortuna) == 1:
        reactor.callLater(random.randint(10, 20), desiccation, pianta, room,
                          age)
        return
    reactor.callLater(random.randint(10, 20), blooming, pianta, room, age,
                      fortuna)
def blooming(pianta, room, age, fortuna):

    if pianta.code not in database["items"]:
        return

    fiore = Item("karpuram_item_mirtillo-rosso-04-fiore")
    if not fiore:
        log.bug("impossibile creare fiore: %r" % fiore)
        return

    location = pianta.location

    pianta.act("Nelle scorse ore $N ha aperto i fiori", TO.OTHERS, pianta)
    pianta.act("Nelle scorse ore $N ha aperto i fiori", TO.ENTITY, pianta)
    pianta.extract(1)

    fiore.inject(location)

    fiore.act("$N rifulge di tutto il suo splendore.", TO.OTHERS, fiore)
    fiore.act("$N rifulge di tutto il suo splendore.", TO.ENTITY, fiore)
    fortuna = fortuna - 1
    if random.randint(1, fortuna) == 1:
        reactor.callLater(random.randint(FLOWER_WAIT_MIN, FLOWER_WAIT_MAX),
                          desiccation, fiore, room, age)
        return
    reactor.callLater(random.randint(FLOWER_WAIT_MIN, FLOWER_WAIT_MAX),
                      fructification, fiore, room, age, fortuna)
def marciume(seed, room):

    if seed.code not in database["items"]:
        return
    frutto_marcio = Item("karpuram_item_mirtillo-rosso-00-frutto-marcio")
    if not frutto_marcio:
        log.bug("impossibile creare frutto_marcio: %r" % frutto_marcio)
        return

    if room != seed.location:
        # log da rimuovere 
        log.bug("room di drop diversa da room attuale")
        return

    location=seed.location

    seed.act("$N appare tutto molliccio...", TO.OTHERS, seed)
    seed.act("$N appare tutto molliccio...", TO.ENTITY, seed)

    seed.extract()

    frutto_marcio.inject(location)

    frutto_marcio.act("... è $N buono solo come concime.", TO.OTHERS, frutto_marcio)
    frutto_marcio.act("... è $N buono solo come concime.", TO.ENTITY, frutto_marcio)
def renew(fruttificato, room, age, fortuna):

    if fruttificato.code not in database["items"]:
        return

    pianta = Item("karpuram_item_mirtillo-rosso-03-pianta")
    if not pianta:
        log.bug("impossibile creare pianta: %r" % pianta)
        return

    age = age +1
    location=fruttificato.location

    fruttificato.act("quel che un tempo doveva esser $N, ora ...", TO.OTHERS, fruttificato)
    fruttificato.act("quel che un tempo doveva esser $N, ora ...", TO.ENTITY, fruttificato)
    fruttificato.extract(1)

    pianta.inject(location)

    pianta.act("... è $N che fruttificherà più avanti", TO.OTHERS, pianta)
    pianta.act("... è $N che fruttificherà più avanti", TO.ENTITY, pianta)
    
    fortuna = fortuna -1
    if random.randint(1, fortuna) == 1:
        reactor.callLater(random.randint(10,20), desiccation, pianta, room, age )
        return
    reactor.callLater(random.randint(10,20), blooming, pianta, room, age, fortuna)
def blooming(pianta, room, age, fortuna):

    if pianta.code not in database["items"]:
        return

    fiore = Item("karpuram_item_mirtillo-rosso-04-fiore")
    if not fiore:
        log.bug("impossibile creare fiore: %r" % fiore)
        return

    location=pianta.location

    pianta.act("Nelle scorse ore $N ha aperto i fiori", TO.OTHERS, pianta)
    pianta.act("Nelle scorse ore $N ha aperto i fiori", TO.ENTITY, pianta)
    pianta.extract(1)

    fiore.inject(location)

    fiore.act("$N rifulge di tutto il suo splendore.", TO.OTHERS, fiore)
    fiore.act("$N rifulge di tutto il suo splendore.", TO.ENTITY, fiore)
    fortuna = fortuna -1
    if random.randint(1, fortuna) == 1:
        reactor.callLater(random.randint( FLOWER_WAIT_MIN , FLOWER_WAIT_MAX ), desiccation, fiore, room, age )
        return
    reactor.callLater(random.randint( FLOWER_WAIT_MIN , FLOWER_WAIT_MAX ),fructification , fiore, room, age, fortuna)
def fructification(fiore, room, age, fortuna):

    if fiore.code not in database["items"]:
        return

    fruttificato = Item("karpuram_item_mirtillo-rosso-05-fruttificato")
    if not fruttificato:
        log.bug("impossibile creare fruttificato: %r" % fruttificato)
        return
    #l'istruzione Item è eseguita qui per il chk
    #poi però è ripetuta più volte nel loop
    #qui in qualche modo è codice sporco...
    bacca_buona = Item("karpuram_item_mirtillo-rosso-01-frutto")
    if not fruttificato:
        log.bug("impossibile creare fruttificato: %r" % bacca_buona)
        return
    bacca_cattiva = Item("karpuram_item_mirtillo-rosso-00-frutto-sterile")
    if not fruttificato:
        log.bug("impossibile creare fruttificato: %r" % bacca_cattiva)
        return

    location = fiore.location

    fiore.act("Dei fiori d'un tempo $N non ne ha più...", TO.OTHERS, fiore)
    fiore.act("Dei fiori d'un tempo $N non ne ha più...", TO.ENTITY, fiore)
    fiore.extract(1)

    fruttificato.inject(location)

    for q in xrange(MAX_FRUIT_QUANTITY + 2 * age + random.randint(1, 4) - 2):
        bacca_buona = Item("karpuram_item_mirtillo-rosso-01-frutto")
        bacca_buona.inject(fruttificato)

    for q in xrange(MAX_FRUIT_QUANTITY + 2 * age + random.randint(1, 4) - 2):
        bacca_cattiva = Item("karpuram_item_mirtillo-rosso-00-frutto-sterile")
        bacca_cattiva.inject(fruttificato)

    fruttificato.act("in compenso ora è $N.", TO.OTHERS, fruttificato)
    fortuna = fortuna - 1
    if random.randint(1, fortuna) == 1:
        reactor.callLater(random.randint(GROWED_WAIT_MIN, GROWED_WAIT_MAX),
                          desiccation, fruttificato, room, age)
        return

    reactor.callLater(random.randint(GROWED_WAIT_MIN, GROWED_WAIT_MAX), renew,
                      fruttificato, room, age, fortuna)
def fructification(fiore, room, age, fortuna):

    if fiore.code not in database["items"]:
        return

    fruttificato = Item("karpuram_item_mirtillo-rosso-05-fruttificato")
    if not fruttificato:
        log.bug("impossibile creare fruttificato: %r" % fruttificato)
        return
    #l'istruzione Item è eseguita qui per il chk
    #poi però è ripetuta più volte nel loop
    #qui in qualche modo è codice sporco...
    bacca_buona = Item("karpuram_item_mirtillo-rosso-01-frutto")
    if not fruttificato:
        log.bug("impossibile creare fruttificato: %r" % bacca_buona)
        return
    bacca_cattiva = Item("karpuram_item_mirtillo-rosso-00-frutto-sterile")
    if not fruttificato:
        log.bug("impossibile creare fruttificato: %r" % bacca_cattiva)
        return

    location=fiore.location

    fiore.act("Dei fiori d'un tempo $N non ne ha più...", TO.OTHERS, fiore)
    fiore.act("Dei fiori d'un tempo $N non ne ha più...", TO.ENTITY, fiore)
    fiore.extract(1)

    fruttificato.inject(location)
    
    for q in xrange(MAX_FRUIT_QUANTITY + 2 * age + random.randint(1,4) - 2 ):
        bacca_buona = Item("karpuram_item_mirtillo-rosso-01-frutto")
        bacca_buona.inject(fruttificato) 

    for q in xrange(MAX_FRUIT_QUANTITY + 2 * age + random.randint(1,4) - 2 ):
        bacca_cattiva = Item("karpuram_item_mirtillo-rosso-00-frutto-sterile")
        bacca_cattiva.inject(fruttificato) 

    fruttificato.act("in compenso ora è $N.", TO.OTHERS, fruttificato)
    fortuna = fortuna -1
    if random.randint(1, fortuna) == 1:
        reactor.callLater(random.randint(GROWED_WAIT_MIN,GROWED_WAIT_MAX), desiccation, fruttificato, room, age )
        return
     
    reactor.callLater(random.randint(GROWED_WAIT_MIN,GROWED_WAIT_MAX), renew, fruttificato, room, age, fortuna )
def germinate(seed, room, age, fortuna):

    if seed.code not in database["items"]:
        return

    germoglio = Item("karpuram_item_mirtillo-rosso-02-germoglio")
    if not germoglio:
        log.bug("impossibile creare germoglio: %r" % germoglio)
        return

    #rudimentale contollo per vedere che il seme non sia stato spostato nel frattempo
    # 2 i problemi a cui si va incontro
    # aa) qualcuno lo droppa e poi lo raccatta e lo ridroppa 1ora dopo e comunque lui cresce (da evitare)
    # bb) la room stessa si resetta e anche se il seme non è stato spostato la room è cambiate e lui non cresce (da evitare)
    # forse il controllo con le coordinate xyz potrebbe risolvere b
    # (gatto dice che non si presenta il problema bb anche se la room resetta)
    # c'è da vedere perché al solito credo ci siam fraintesi ed io pensavo al reset di room diverse nelle stesse coordinate

    # per risolvere aa forse basta in qualche modo che un get interrompa lo script (come fare?)
    if room != seed.location:
        # log da rimuovere
        log.bug("room di drop diversa da room attuale")
        return

    location = seed.location

    seed.act("Di recente $N s'è schiuso...", TO.OTHERS, seed)
    seed.act("Di recente $N s'è schiuso...", TO.ENTITY, seed)

    seed.extract(1)

    germoglio.inject(location)

    germoglio.act("... in $N.", TO.OTHERS, germoglio)
    germoglio.act("... in $N.", TO.ENTITY, germoglio)
    fortuna = fortuna - 1
    if random.randint(1, fortuna) == 1:
        reactor.callLater(random.randint(GERM_WAIT_MIN, GERM_WAIT_MAX),
                          desiccation, germoglio, room, age)
        return
    reactor.callLater(random.randint(GERM_WAIT_MIN, GERM_WAIT_MAX), growing,
                      germoglio, room, age, fortuna)
def desiccation(generic_plant, room, age):

    if generic_plant.code not in database["items"]:
        return

    pianta_morta = Item("karpuram_item_mirtillo-rosso-06-pianta_morta")
    if not pianta_morta:
        # qui non dovrà uscire dallo script che sennò si frizza la pianta a questo stadio
        log.bug("impossibile creare pianta_morta: %r" % pianta_morta)
        return

    location = generic_plant.location

    generic_plant.act("Il rigoglio di $N ...", TO.OTHERS, generic_plant)
    generic_plant.act("Il rigoglio di $N ...", TO.ENTITY, generic_plant)
    generic_plant.extract()

    pianta_morta.inject(location)
    pianta_morta.descr_sixth = "una pianta che ha passato %r stagioni" % age
    pianta_morta.act("... è tramontato in $N.", TO.OTHERS, pianta_morta)
    pianta_morta.act("... è tramontato in $N.", TO.ENTITY, pianta_morta)
def desiccation(generic_plant, room, age):

    if generic_plant.code not in database["items"]:
        return

    pianta_morta = Item("karpuram_item_mirtillo-rosso-06-pianta_morta")
    if not pianta_morta:
        # qui non dovrà uscire dallo script che sennò si frizza la pianta a questo stadio
        log.bug("impossibile creare pianta_morta: %r" % pianta_morta)
        return

    location=generic_plant.location

    generic_plant.act("Il rigoglio di $N ...", TO.OTHERS, generic_plant)
    generic_plant.act("Il rigoglio di $N ...", TO.ENTITY, generic_plant)
    generic_plant.extract()

    pianta_morta.inject(location)
    pianta_morta.descr_sixth = "una pianta che ha passato %r stagioni" % age
    pianta_morta.act("... è tramontato in $N.", TO.OTHERS, pianta_morta)
    pianta_morta.act("... è tramontato in $N.", TO.ENTITY, pianta_morta)
def germinate(seed, room, age, fortuna):

    if seed.code not in database["items"]:
        return

    germoglio = Item("karpuram_item_mirtillo-rosso-02-germoglio")
    if not germoglio:
        log.bug("impossibile creare germoglio: %r" % germoglio)
        return

    #rudimentale contollo per vedere che il seme non sia stato spostato nel frattempo
    # 2 i problemi a cui si va incontro
    # aa) qualcuno lo droppa e poi lo raccatta e lo ridroppa 1ora dopo e comunque lui cresce (da evitare)
    # bb) la room stessa si resetta e anche se il seme non è stato spostato la room è cambiate e lui non cresce (da evitare)
    # forse il controllo con le coordinate xyz potrebbe risolvere b 
    # (gatto dice che non si presenta il problema bb anche se la room resetta)
    # c'è da vedere perché al solito credo ci siam fraintesi ed io pensavo al reset di room diverse nelle stesse coordinate

    # per risolvere aa forse basta in qualche modo che un get interrompa lo script (come fare?)
    if room != seed.location:
        # log da rimuovere 
        log.bug("room di drop diversa da room attuale")
        return

    location=seed.location

    seed.act("Di recente $N s'è schiuso...", TO.OTHERS, seed)
    seed.act("Di recente $N s'è schiuso...", TO.ENTITY, seed)

    seed.extract(1)

    germoglio.inject(location)

    germoglio.act("... in $N.", TO.OTHERS, germoglio)
    germoglio.act("... in $N.", TO.ENTITY, germoglio)
    fortuna = fortuna -1
    if random.randint(1, fortuna) == 1:
        reactor.callLater(random.randint( GERM_WAIT_MIN , GERM_WAIT_MAX ), desiccation, germoglio, room, age)
        return
    reactor.callLater(random.randint( GERM_WAIT_MIN , GERM_WAIT_MAX ), growing, germoglio, room, age, fortuna)
def growing(germoglio, room, age, fortuna):

    if germoglio.code not in database["items"]:
        return

    pianta = Item("karpuram_item_mirtillo-rosso-03-pianta")
    if not pianta:
        log.bug("impossibile creare pianta: %r" % pianta)
        return

    location=germoglio.location

    germoglio.act("Quel che poco tempo fa era solo $N, ora ...", TO.OTHERS, germoglio)
    germoglio.act("Quel che poco tempo fa era solo $N, ora ...", TO.ENTITY, germoglio)
    germoglio.extract(1)

    pianta.inject(location)

    pianta.act("... è $N.", TO.OTHERS, pianta)
    fortuna = fortuna -1
    if random.randint(1, fortuna) == 1:
        reactor.callLater(random.randint( PLANT_WAIT_MIN , PLANT_WAIT_MAX ), desiccation, pianta, room, age)
        return
    reactor.callLater(random.randint( PLANT_WAIT_MIN , PLANT_WAIT_MAX ), blooming, pianta, room, age, fortuna)
Пример #15
0
def on_sunrise(lupo):
    if not lupo:
        log.bug("lupo non è un parametro valido: %r" % lupo)
        return

    dosso = Item(PROTO_DOSSO_CODE)
    dosso.inject(lupo.location)

    dosso.act("Ti origini da $N e sei $n.", TO.ENTITY, lupo)
    dosso.act("Tra atroci ululati $N si trasforma in $n!", TO.OTHERS, lupo)
    dosso.act("$n si origina da te!", TO.TARGET, lupo)

    lupo.stop_repop()
    lupo.extract(1)
def on_sunrise(lupo):
    if not lupo:
        log.bug("lupo non è un parametro valido: %r" % lupo)
        return

    dosso = Item(PROTO_DOSSO_CODE)
    dosso.inject(lupo.location)

    dosso.act("Ti origini da $N e sei $n.", TO.ENTITY, lupo)
    dosso.act("Tra atroci ululati $N si trasforma in $n!", TO.OTHERS, lupo)
    dosso.act("$n si origina da te!", TO.TARGET, lupo)

    lupo.stop_repop()
    lupo.extract(1)