Ejemplo n.º 1
0
def script(s, player=None):
    from NaoQuest.objective import Objective
    from NaoCreator.setting import Setting
    from NaoSensor.plant import Plant
    if not player:
        Setting.error("Error in execution of pre_script of objective \"RemplirDeTerre\": player is None")
        return
Ejemplo n.º 2
0
def script(s, player=None):
    from NaoQuest.quest import Quest
    from NaoCreator.setting import Setting
    import NaoCreator.Tool.speech_move as SM
    if not player:
        Setting.error(
            "Error in execution of post_script of objective \"ChoixService\": player is None"
        )
        return

    print s.__dict__
    if hasattr(s, "kw_answer"):
        print s.kw_answer
        # ajoue des quêtes en fonction du choix de l'utilisateur
        if s.kw_answer == "éxplication" or s.kw_answer == "éxplications":
            print "ajoue preparation jardin"
            new_qst = Quest(player.current_scenario.inner_name,
                            "PreparationJardin")

        else:
            SM.speech_and_move(u"Ajoue de l'arrosage")
            print "ajoue arrosage"
            new_qst = Quest(player.current_scenario.inner_name, "Arrosage")

        l = len(player.current_quest.next_quests)
        new_qst.branch_id = l + 1

        player.current_quest.next_quests.append(new_qst)
Ejemplo n.º 3
0
def script(s, player=None):
    from NaoQuest.quest import Quest
    from NaoCreator.setting import Setting
    import NaoCreator.Tool.speech_move as sm
    import NaoCreator.Tool.mailor as MA
    import codecs

    if not player:
        Setting.error(
            "Error in execution of post_script of objective \"ChoixArrosage\": player is None"
        )
        return

    if s.completed:
        # on chop le mail template
        f = codecs.open("datas/mailTemplate/mailArrosage",
                        'r',
                        encoding='utf-8')
        text = '\n'.join(f.readlines())
        mail = MA.get_user_mail()
        # on l'envoie est on récupaire le mail de l'utilisateur
        MA.nao_send_mail(mail, "Aide arrosage automatique", text)
        sm.speech_and_move(
            u"Je tes envoyer un mail avec tout se qui faut savoir sur l'arrosage automatique."
        )
    else:
        s.completed = True
Ejemplo n.º 4
0
def script(s, player=None):
    from NaoQuest.objective import Objective
    from NaoQuest.quest import Quest
    from NaoCreator.setting import Setting
    import NaoCreator.Tool.speech_move as sm

    if not player:
        Setting.error(
            "Error in execution of post_script of objective \"nbPots\": player is None"
        )
        return

    if not s.completed:
        return

    try:
        player.nb_pots = int(s.answer)

        for i in range(player.nb_pots):
            q = Quest(s.scenario_name, "infosPotN")
            q.name = q.name.format([
                "premier", "deuxième", "troisième", "quatrième", "cinquième",
                "sixième", "septième", "huitième", "neuvième", "dixième"
            ][i])

            q.branch_id = i + 1
            s.caller.next_quests += [q]
    except Exception as e:
        sm.speech_and_move("Je n'ai pas réussi à comprendre un nombre !")
        s.completed = False
Ejemplo n.º 5
0
def script(s, player=None):
    from NaoQuest.objective import Objective
    from NaoCreator.setting import Setting
    if not player:
        Setting.error("Error in execution of pre_script of objective \"resultat\": player is None")
        return
    s.desc = s.desc.format(player.point)
Ejemplo n.º 6
0
def script(s, player=None):
    from NaoQuest.objective import Objective
    from NaoCreator.setting import Setting
    if not player:
        Setting.error("Error in execution of pre_script of objective \"planterCapteur\": player is None")
        return

    s.question = s.question.format(["premier", "deuxième", "troisième", "quatrième", "cinquième", "sixième", "septième", "huitième", "neuvième", "dixième"][s.caller.branch_id - 1])
Ejemplo n.º 7
0
def script(s, player=None):
    from NaoQuest.objective import Objective
    from NaoCreator.setting import Setting
    if not player:
        Setting.error(
            "Error in execution of post_script of objective \"choix_outils_stat\": player is None"
        )
        return
Ejemplo n.º 8
0
def script(s, player=None):
    from NaoQuest.objective import Objective
    from NaoCreator.setting import Setting
    from NaoSensor.plant import Plant
    if not player:
        Setting.error("Error in execution of pre_script of objective \"FinEtRecolte\": player is None")
        return
    # on choppe la plante liée à cette quete pour modifier ce que doit dire nao
    s.desc = s.desc.format(player.current_quest.plante_lie.get_data(Plant.RECOLTE))
Ejemplo n.º 9
0
def script(s, player=None):
    from NaoQuest.objective import Objective
    from NaoCreator.setting import Setting
    from NaoSensor.plant import Plant
    if not player:
        Setting.error("Error in execution of pre_script of objective \"TheEnd\": player is None")
        return

    s.desc = s.desc.format(player.plante_lie.get_data(Plant.ARROSAGE))
Ejemplo n.º 10
0
def script(s, player=None):
    from NaoQuest.objective import Objective
    from NaoCreator.setting import Setting
    if not player:
        Setting.error(
            "Error in execution of post_script of objective \"recupCapteur\": player is None"
        )
        return

    player.current_quest.captor_in_use = s.answer[0]
Ejemplo n.º 11
0
 def _exec(self):
     if not hasattr(self, "question"):
         Setting.error("No \"question\" in KeyWordObjective \"{}\"".format(
             self.inner_name))
         return
     if not hasattr(self, "keywords"):
         Setting.error("No \"keywords\" in KeyWordObjective \"{}\"".format(
             self.inner_name))
         return
     sm.speech_and_move(self.question)
Ejemplo n.º 12
0
def script(s, player=None):
    from NaoQuest.objective import Objective
    from NaoCreator.setting import Setting
    if not player:
        Setting.error(
            "Error in execution of pre_script of objective \"recupInfoPot\": player is None"
        )
        return

    s.desc = s.desc.format(player.current_scenario.jardin.nb_pots() + 1)
Ejemplo n.º 13
0
    def reg_pot(self, pot):
        if pot in self.pots:
            Setting.error("Pot {} already in Jardin {}".format(pot, self))
            return False
        if (pot.timestamp, pot.nickname) in [(p.timestamp, p.nickname) for p in self.pots]:
            Setting.error("Pot {} has same timestamp & nickname than another Pot")
            return False

        self.pots += [pot]
        return True
Ejemplo n.º 14
0
def script(s, player=None):
    from NaoQuest.objective import Objective
    from NaoCreator.setting import Setting
    if not player:
        Setting.error(
            "Error in execution of post_script of objective \"planter\": player is None"
        )
        return
    if not s.completed:
        s.wait_for = False
Ejemplo n.º 15
0
def script(s, player=None):
    from NaoQuest.objective import Objective
    from NaoCreator.setting import Setting
    from NaoSensor.plant import Plant
    if not player:
        Setting.error("Error in execution of pre_script of objective \"PlanterBulbe\": player is None")
        return
    print "ici = ", player.plante_lie
    print "ici = ", player.plante_lie.get_data(Plant.NOM)
    s.desc = s.desc.format(player.plante_lie.get_data(Plant.PLANTATION)["creuser"] + " Puis, " + player.plante_lie.get_data(Plant.PLANTATION)["planter"])
def script(s, player=None):
    from NaoQuest.objective import Objective
    from NaoCreator.setting import Setting
    from NaoSensor.plant import Plant
    from NaoQuest.scenario import Scenario
    import NaoCreator.Tool.speech_move as sm

    print "il se lance ou pas ce fdp"

    if not player:
        Setting.error(
            "Error in execution of post_script of objective \"determienrTerrainPropice\": player is None"
        )
        return

    jardin = player.current_scenario.jardin
    plante_ideale = Plant()
    plante_ideale.data["valeursIdeales"] = {
        "soil_moisture": {
            "min": 50.0,
            "max": 80.0
        },
        "light": {
            "min": 5.0,
            "max": 8.0
        },
        "temperature": {
            "min": 20.0,
            "max": 50.0
        },
        "fertilizer": {
            "min": 0.2,
            "max": 0.4
        }
    }

    pots_ideals = [(p, i)
                   for p, i in zip(jardin.pots, range(1,
                                                      len(jardin.pots) + 1))
                   if p.is_ideal_for_plant(plante_ideale)]
    player.current_scenario.pots_ideals = pots_ideals

    if not pots_ideals:
        sm.speech_and_move(
            "Il semblerait qu'aucuns des pots que tu as enregistrés présentent des caractéristiques idéales. Assure toi de trouver un terrain lumineux, riche et humide et relance le scénario."
        )
        player.current_scenario = Scenario("terrainPropice")
        print("Redémarrage du Scénario \"Terrain Propice\" !")
        return

    texte = "Selon mes données, il semblerait que les pots. "
    for t in pots_ideals:
        texte += str(t[1]) + ", "
    texte += "présentent des caractéristiques intéressantes pour ton jardin."
    sm.speech_and_move(texte)
Ejemplo n.º 17
0
 def __init__(self, data):
     try:
         self.temperature = data["temperature"]
         self.timestamp = data["timestamp"]
         self.soil_moisture = data["soil_moisture"]
         self.light = data["light"]
         self.fertilizer = data["fertilizer"]
         self.nickname = data["nickname"]
     except KeyError as e:
         print(e)
         Setting.error("Uncomplete data given to Pot.__init__")
Ejemplo n.º 18
0
def script(s, player=None):
    from NaoQuest.objective import Objective
    from NaoCreator.setting import Setting
    from NaoSensor.captor_data import cpt_giselle, CaptorData
    if not player:
        Setting.error(
            "Error in execution of pre_script of objective \"InfoJardin\": player is None"
        )
        return

    s.desc = s.desc.format(cpt_giselle.data[0][CaptorData.SOIL_MOISTURE],
                           cpt_giselle.data[0][CaptorData.TEMPERATURE])
Ejemplo n.º 19
0
def script(s, player=None):
    from NaoQuest.objective import Objective
    from NaoCreator.setting import Setting
    if not player:
        Setting.error(
            "Error in execution of post_script of objective \"FinEtRecolte\": player is None"
        )
        return
    if not s.completed:

        # on vire la phrase bravo tu a fini
        s.desc = '.'.join(s.desc.split(".")[2:])
Ejemplo n.º 20
0
def script(s, player=None):
    from NaoQuest.objective import Objective
    from NaoCreator.setting import Setting
    if not player:
        Setting.error(
            "Error in execution of post_script of objective \"objNomCapteur\": player is None"
        )
        return
    if "bernard" in s.answer:
        player.current_scenario.cpt_name = "Bernard"
    elif any(w in s.answer for w in ("giselle", "gisèle")):
        player.current_scenario.cpt_name = "Giselle"
Ejemplo n.º 21
0
def script(s, player=None):
    from NaoQuest.objective import Objective
    from NaoCreator.setting import Setting
    import NaoCreator.Tool.speech_move as sm
    if not player:
        Setting.error(
            "Error in execution of post_script of objective \"obj2\": player is None"
        )
        return

    if s.completed:
        sm.speech_and_move("La phrase que tu as dite est: {}".format(
            s.raw_answer))
Ejemplo n.º 22
0
def script(s, player=None):
    from NaoQuest.objective import Objective
    from NaoCreator.Tool.speech_move import speech_and_move
    from NaoCreator.setting import Setting
    if not player:
        Setting.error(
            "Error in execution of post_script of objective \"q2\": player is None"
        )
        return

    if hasattr(s, "kw_answer"):

        if s.kw_answer == "python":
            player.point += 1
            speech_and_move(u"Bravo ! tu as dit la bonne réponse !")
Ejemplo n.º 23
0
def script(s, player=None):
    from NaoQuest.objective import Objective
    from NaoCreator.setting import Setting
    from NaoSensor.jardin import Jardin
    if not player:
        Setting.error(
            "Error in execution of pre_script of objective \"infosPot\": player is None"
        )
        return

    if not hasattr(player.current_scenario, "jardin"):
        player.current_scenario.jardin = Jardin()

    s.question = s.question.format(
        player.current_scenario.cpt_name,
        len(player.current_scenario.jardin.pots) + 1)
Ejemplo n.º 24
0
def script(s, player=None):
    from NaoQuest.objective import Objective
    from NaoCreator.setting import Setting
    from NaoCreator.Tool.speech_move import speech_and_move
    if not player:
        Setting.error("Error in execution of post_script of objective \"q1\": player is None")
        return

    if hasattr(s, "kw_answer"):

        if s.kw_answer == "3" or s.kw_answer == "trois":
            player.current_quest.point += 1
            speech_and_move(u"Félicitation tu a la bonne réponse.")
        else:
            speech_and_move(u"mauvaise réponse ! La bonne réponse était. 3.")

        speech_and_move(u"Le bouturage est un mode de multiplication. Cela consiste à donner naissance à une nouvelle "
                        u"plante à partir de la plaznte mère. C'est une technologie de clonage.")
Ejemplo n.º 25
0
def script(s, player=None):
    from NaoQuest.objective import Objective
    from NaoCreator.setting import Setting
    from NaoSensor.jardin import Jardin
    if not player:
        Setting.error(
            "Error in execution of post_script of objective \"nomCapteur\": player is None"
        )
        return

    if s.kw_answer == u"gisèle":
        s.kw_answer = "Giselle"
    elif s.kw_answer == "bernard":
        s.kw_answer = "Bernard"
    else:
        print "???"

    player.current_scenario.captorName = s.kw_answer
    player.current_scenario.jardin = Jardin()
Ejemplo n.º 26
0
def script(s, player=None):
    from NaoQuest.objective import Objective
    from NaoCreator.setting import Setting
    from NaoCreator.Tool.speech_move import speech_and_move
    import NaoCreator.SGBDDialogue.creer as C
    if not player:
        Setting.error("Error in execution of post_script of objective \"ValidationRemplirTerre\": player is None")
        return
    if not s.completed:

        # on recupaire le position de l'objectif courent dans la list
        index_curent_obj = player.current_quest.objectives.index(s)
        # on mais l'onjectif présédent comme non valider pour que nao reise les instruction
        player.current_quest.objectives[index_curent_obj - 1].completed = False
        p1 = C.Creer(C.Reponse, 41, 42, 43, 44)
        speech_and_move(u"{}".format(p1.out()))
    else:
        p1 = C.Creer(C.Reponse, 37, 38, 39, 40)
        speech_and_move(u"{}".format(p1.out()))
Ejemplo n.º 27
0
def script(s, player=None):
    from NaoQuest.objective import Objective
    from NaoCreator.setting import Setting
    from NaoCreator.Tool.speech_move import speech_and_move
    if not player:
        Setting.error("Error in execution of post_script of objective \"q1\": player is None")
        return

    if hasattr(s, "kw_answer"):

        if s.kw_answer == "1" or s.kw_answer == "un":
            player.current_quest.point += 1
            speech_and_move(u"Félicitation tu a la bonne réponse.")
        else:
            speech_and_move(u"mauvaise réponse ! La bonne réponse était. 1.")

        speech_and_move(u"Voici l'explication : Le purin d'ortie est un insecticide naturel, peu couteux et efficace"
                        u"pour lutter contre les pucerons. C'est aussi un excellent engrais pour les plantes."
                        u"Pour le préparer, il suffit de laisser macérer 1 kg d'orties dans 10 litres d'eau "
                        u"pendant 2 à 3 jours.")
Ejemplo n.º 28
0
def script(s, player=None):
    from NaoQuest.objective import Objective
    from NaoCreator.setting import Setting
    from NaoSensor.captor_data import cpt_giselle, CaptorData
    from NaoCreator.Tool.speech_move import speech_and_move
    from time import sleep
    if not player:
        Setting.error(
            "Error in execution of pre_script of objective \"InfoJardin\": player is None"
        )
        return
    try:

        tempetur = cpt_giselle.data[0][CaptorData.TEMPERATURE]
    except Exception as e:

        print e
        tempetur = 20

    if -50 <= tempetur <= -1:
        text = u"IL fait trop froit ! Tu vie au pole Nord ?"
    elif 0 <= tempetur <= 5:
        text = u"C'est trop froit pour t-on bullbe. Je te conseil de le rentrée au chaut"
    elif 6 <= tempetur <= 11:
        text = u"Il fait un peut froit pour t-on bullbe."
    elif 12 <= tempetur <= 19:
        text = u"La températur est un peut just. Je te conseille de rentrée t-on bulbe le matin. " \
               u"Est des qu'il fait plus chaud, tu peut le sortire"
    elif 20 <= tempetur <= 29:
        text = u"La température est très bien."
    elif 30 <= tempetur <= 32:
        text = u"Il commence a fire chaud ! Il faut bien pensser a aroser t-on bulbe. Mais que quand le soleil est coucher pour éviter de bruller t-on bulbe."
    elif 33 <= tempetur <= 35:
        text = u"Il fait trop chaud ! Rentre t-on pôt a l'intèrieur pour protéger t-on bulbe de la charleur"
    else:
        text = u"je ne peut rien dire"
    speech_and_move(
        u"Maintenemps que tu a mit le capteur dans t-on peau. Je vais regarder le température."
    )
    sleep(1)
    s.desc = s.desc.format(text)
Ejemplo n.º 29
0
def script(s, player=None):
    from NaoQuest.objective import Objective
    from NaoCreator.setting import Setting
    from NaoQuest.quest import Quest
    if not player:
        Setting.error(
            "Error in execution of post_script of objective \"choix\": player is None"
        )
        return

    if hasattr(s, "kw_answer"):

        if s.kw_answer == "qcm" or s.kw_answer == "QCM":
            new_qst = Quest(player.current_scenario.inner_name, "qcm")
            new_qst.point = 0
        else:
            new_qst = Quest(player.current_scenario.inner_name, "info")

        l = len(player.current_quest.next_quests)
        new_qst.branch_id = l + 1
        player.current_quest.next_quests.append(new_qst)
Ejemplo n.º 30
0
def script(s, player=None):
    from NaoQuest.objective import Objective
    from NaoCreator.setting import Setting
    from NaoCreator.Tool.speech_move import speech_and_move
    if not player:
        Setting.error(
            "Error in execution of post_script of objective \"q1\": player is None"
        )
        return

    if hasattr(s, "kw_answer"):

        if s.kw_answer == "2" or s.kw_answer == "deux":
            player.current_quest.point += 1
            speech_and_move(u"Félicitation tu a la bonne réponse.")
        else:
            speech_and_move(u"mauvaise réponse ! La bonne réponse était. 2.")

        speech_and_move(
            u"Voici l'explication : La grelinette est un outil de jardinage qui permet d'ameublir la terre"
            u"sans la retourner. La grelinette ressemble à une fourche à quatres dents, munie de deux bras."
        )