def feelErrors(): global shame_threshold affect = False if numErrors > shame_threshold: affect = True expressions.setEmotion(expressions.EXPRESION_AVERGONZADO) expressions.setText("Upss... Ha habido un error... ¡Qué vergüenza!") return affect
def feelPictures(): global numPictures global photographer_threshold affect = False if numPictures > photographer_threshold: affect = True expressions.setEmotion(expressions.EXPRESION_ENAMORADO) expressions.setText("¡Cuántas fotos!") elif numPictures > 0: affect = True expressions.setText("¡Me gustan las fotos!") expressions.setEmotion(expressions.EXPRESION_FELIZ) return affect
def feelLight(): global darkness_threshold global luminosity_threshold affect = False light = arduino.getLight() if light < darkness_threshold and light >= 0: affect = True expressions.setEmotion(expressions.EXPRESION_ASUSTADO) expressions.setText("¡Qué miedo, no hay luz!") elif light > luminosity_threshold: affect = True expressions.setEmotion(expressions.EXPRESION_ATURDIDO) expressions.setText("¡Me está dando toda la luz en la cara!") return affect
def feelEmotions(): global numNormalCycles global boredom_threshold if not feelLight(): if not feelErrors(): if not feelOrders(): if not feelPictures(): numNormalCycles += 1 if numNormalCycles < boredom_threshold: expressions.setEmotion(expressions.EXPRESION_NORMAL) expressions.setText("") else: # If I don't do nothing, I'm bored expressions.setEmotion(expressions.EXPRESION_ABURRIDO) expressions.setText("¡Me aburro!") expression = expressions.getEmotion() # If I do something I'm not bored if expression != expressions.EXPRESION_NORMAL and expression != expressions.EXPRESION_ABURRIDO: numNormalCycles = 0
def feelOrders(): global numOrders global anger_threshold global sick_threshold affect = False if numOrders > sick_threshold: affect = True expressions.setEmotion(expressions.EXPRESION_ENFERMO) expressions.setText("Estoy agotado...") if numOrders > anger_threshold: affect = True expressions.setEmotion(expressions.EXPRESION_ENFADADO) expressions.setText("¡Deja de mandarme cosas!") elif numOrders > 0: affect = True expressions.setEmotion(expressions.EXPRESION_PENSATIVO) expressions.setText("A ver qué me has pedido...") return affect