本文整理匯總了Python中visualizer.Visualizer.update_mood方法的典型用法代碼示例。如果您正苦於以下問題:Python Visualizer.update_mood方法的具體用法?Python Visualizer.update_mood怎麽用?Python Visualizer.update_mood使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類visualizer.Visualizer
的用法示例。
在下文中一共展示了Visualizer.update_mood方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: __init__
# 需要導入模塊: from visualizer import Visualizer [as 別名]
# 或者: from visualizer.Visualizer import update_mood [as 別名]
class Manager:
"""Frame of options to manage a monster."""
def __init__(self, name, master, total_var):
self.root = LabelFrame(master, text = name)
self.visualizer = Visualizer(name, self.root)
self.monster = Monster(name)
self.stats = Stat_Tracker()
self.total_var = total_var
self.total_var.set(total_var.get() + 1)
self.visualizer.monster_image.grid(row = 0, column = 6, rowspan = 3)
self.visualizer.mood_image.grid(row = 0, column = 7, rowspan = 3)
# controls whether the button's perform their action, for use when
# a monster is dead or a minigame is playing
self.button_bool = True
########## age ##################################
self.age_label = Label(self.root, text = "Age: ")
self.age_label.grid(row = 0, column = 2)
self.age_state = StringVar()
self.update_age()
Label(self.root, textvariable = self.age_state).grid(row = 0, column = 3)
########### mood ############################################
self.mood_label = Label(self.root, text = "Mood: ")
self.mood_label.grid(row = 0, column = 0)
self.mood_state = StringVar()
self.update_mood()
Label(self.root, textvariable = self.mood_state).grid(row = 0, column = 1)
######### hunger ############################################
self.hunger_label = Label(self.root, text = "Hunger: ")
self.hunger_label.grid(row = 1, column = 0)
self.hunger_state = StringVar()
self.update_hunger()
Label(self.root, textvariable = self.hunger_state).grid(row = 1, column = 1)
self.hunger_button = Button(self.root, text = "Feed", command = self.feed)
self.hunger_button.grid(row = 1, column = 2)
######## sleepiness ############################################
self.sleep_label = Label(self.root, text = "Sleepiness: ")
self.sleep_label.grid(row = 2, column = 0)
self.sleep_state = StringVar()
self.update_sleepiness()
Label(self.root, textvariable = self.sleep_state).grid(row = 2, column = 1)
self.sleep_button = Button(self.root, text = "Nap", command = self.nap)
self.sleep_button.grid(row = 2, column = 2)
######### boredom ############################################
self.boredom_label = Label(self.root, text = "Boredom: ")
self.boredom_label.grid(row = 1, column = 3)
self.boredom_state = StringVar()
self.update_boredom()
Label(self.root, textvariable = self.boredom_state).grid(row = 1, column = 4)
self.boredom_button = Button(self.root, text = "Play", command = self.play)
self.boredom_button.grid(row = 1, column = 5)
######### dirtiness ############################################
self.dirt_label = Label(self.root, text = "Dirtiness: ")
self.dirt_label.grid(row = 2, column = 3)
self.dirt_state = StringVar()
self.update_dirtiness()
Label(self.root, textvariable = self.dirt_state).grid(row = 2, column = 4)
self.dirt_button = Button(self.root, text = "Clean", command = self.clean)
self.dirt_button.grid(row = 2, column = 5)
self.root.pack()
def update_hunger(self):
"""Updates the hunger label by generating a string from the monster's hunger field."""
value = self.monster.hunger
if value >= 2 * Monster.HUNGRY:
text = "High"
elif value >= Monster.HUNGRY:
text = "Medium"
else:
text = "Low"
self.hunger_state.set(text)
def feed(self):
"""Feeds the monster."""
if self.button_bool:
self.stats.update_stats("feed", self.monster.mood, self.monster.age)
self.monster.feed()
self.update_all()
def update_sleepiness(self):
#.........這裏部分代碼省略.........