def script(s, player=None): from NaoQuest.objective import Objective from NaoCreator.setting import Setting from NaoSensor.plant import Plant from NaoCreator.Tool.speech_move import speech_and_move if not player: Setting.error( "Error in execution of post_script of objective \"ChoixBulbe\": player is None" ) return if hasattr(s, "kw_answer"): if s.kw_answer == "1": p = Plant("glaieul") speech_and_move( u"Très bon choix le glaieul est l'une de mes fleur préférer.") elif s.kw_answer == "2": p = Plant("lys") speech_and_move(u"Tu a bien fait de choisir un lys.") else: print "3" p = Plant("freesias") speech_and_move( u"Sa tombe bien, c'est justement la saison des freesias") # creation d'un attribut qui va contenir la plante liée au joueur player.plante_lie = p print(u"Quete correctement ajoutée")
def script(s, player=None): from NaoQuest.objective import Objective from NaoCreator.setting import Setting import NaoCreator.Tool.facebookor as FC if not player: Setting.error( "Error in execution of pre_script of objective \"result\": player is None" ) return if 0 <= player.current_quest.point <= 3: s.question = s.question.format( str(player.current_quest.point) + u" point. " u"Tu peux faire mieux! " u"N'hésite pas a recommencer ce qcm") elif 4 <= player.current_quest.point <= 7: s.question = s.question.format( str(player.current_quest.point) + u" point. " u"Pas mal !") else: s.question = s.question.format( str(player.current_quest.point) + u" point. " u"G,G") FC.send_the_post("Le jardinier {} a marquer {} " "point dans la quête du QCM! GG a lui !".format( player.player_name, player.current_quest.point))
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)
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 NaoSensor.captor_data as Cp if not player: Setting.error( "Error in execution of post_script of objective \"valeurJardin\": player is None" ) return c1 = Cp.CaptorData().get_data_from_csv_file(Cp.datas[0]) c2 = Cp.CaptorData().get_data_from_csv_file(Cp.datas[1]) speech_and_move( u"Le taux d'humidité du capteur {} est de {} pour cent".format( c1.get_data(c1.NICKNAME, 0), c1.get_data(c1.SOIL_MOISTURE, 0))) speech_and_move( u"Le taux d'humidité du capteur {} est de {} pour cent".format( c2.get_data(c2.NICKNAME, 0), c2.get_data(c2.SOIL_MOISTURE, 0))) speech_and_move(u"Le taux d'ensoleillement du capteur {} est de {}".format( c1.get_data(c1.NICKNAME, 0), c1.get_data(c1.LIGHT, 0))) speech_and_move(u"Le taux d'ensoleillement du capteur {} est de {}".format( c2.get_data(c2.NICKNAME, 0), c2.get_data(c2.LIGHT, 0))) speech_and_move( u"Le taux d'engrais du capteur {} est de {} pour cent".format( c1.get_data(c1.NICKNAME, 0), c1.get_data(c1.FERTILIZER, 0))) speech_and_move( u"Le taux d'engrais du capteur {} est de {} pour cent".format( c2.get_data(c2.NICKNAME, 0), c2.get_data(c2.FERTILIZER, 0))) speech_and_move( u"Le capteur {} perçoit une température de {} degrés".format( c1.get_data(c1.NICKNAME, 0), c1.get_data(c1.TEMPERATURE, 0))) speech_and_move( u"Le capteur {} perçoit une température de {} degrés".format( c2.get_data(c2.NICKNAME, 0), c2.get_data(c2.TEMPERATURE, 0)))
def _exec(self): if not hasattr(self, "values_min") or not hasattr(self, "values_max"): Setting.error("No \"values_min / values_max\" in CptObjective \"{}\"".format(self.inner_name)) return if not hasattr(self, "nickname"): Setting.critical("No \"nickname\" in CptObjective \"{}\"".format(self.inner_name)) return
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
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
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
def script(s, player=None): from NaoQuest.objective import Objective from NaoCreator.setting import Setting from NaoSensor.captor_data import cpts from NaoSensor.jardin import Pot import NaoCreator.Tool.speech_move as sm if not player: Setting.error( "Error in execution of post_script of objective \"recupInfoPot\": player is None" ) return if s.success: jardin = player.current_scenario.jardin cpt = cpts[player.current_scenario.cpt_name] pot = Pot(cpt.get_datas()) if jardin.reg_pot(pot): sm.speech_and_move("Le pot a été ajouté avec succès !") else: sm.speech_and_move( "Impossible d'ajouter le pot, n'aurais-tu pas ajouté le même pot ou pas attendu assez ?" ) else: print "Impossible d'ajouter le pot; l'utilisateur a répondu 'non'."
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)
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])
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
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))
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))
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
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)
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)
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 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
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]
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)
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__")
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:])
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])
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"
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))
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 !")
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)
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.")
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()