示例#1
0
 def instantiate_crop(self):
     crop_type = self.crop_radio_buttons.selected_button() # get the radio that was selected
     if crop_type == 1:
         self.simulated_crop = Wheat()
     elif(crop_type == 2):
         self.simulated_crop = Potato()
     
     self.create_view_crop_layout(crop_type) # create the view crop growth layout
     self.stacked_layout.addWidget(self.view_crop_widget) # add rthis to stack
     self.stacked_layout.setCurrentIndex(1) # change the visible layout
示例#2
0
def create_crop():

    display_menu()
    choice = select_option()
    if choice == 1:
        new_crop = Potato()
    elif choice == 2:
        new_crop = Wheat()
    return new_crop
示例#3
0
class CropWindow(QMainWindow):
    """ This class creates a main window to observe the growth of the simulation"""
    
    # constructor
    def __init__(self):
        super().__init__() # call the soper class constructor
        self.setWindowTitle("Crop simulator") # set window title
        self.create_select_crop_layout()  
        
        self.stacked_layout = QStackedLayout() # creates a stacked layout that holds
                                                # the different layouts
        self.stacked_layout.addWidget(self.select_crop_widget)

        # set the central widget ot display the layout
        self.central_widget = QWidget()
        self.central_widget.setLayout(self.stacked_layout)
        self.setCentralWidget(self.central_widget)
        
        
        
    def create_select_crop_layout(self):
        # this is the initial lauout of the window
        # it lets us select a crop type
    
        self.crop_radio_buttons = RadioButtonWidget("Crop simulation", \
                                                    "Please select a crop",\
                                                    ("Wheat", "Potato"))
        self.instantiate_button = QPushButton("Create crop")
        
        # create the layout to hold the widgets
        self.initial_layout = QVBoxLayout()
        self.initial_layout.addWidget(self.crop_radio_buttons)
        self.initial_layout.addWidget(self.instantiate_button)
        
        self.select_crop_widget = QWidget()
        self.select_crop_widget.setLayout(self.initial_layout)
        

        # connections
        self.instantiate_button.clicked.connect(self.instantiate_crop)
        
    def create_view_crop_layout(self, crop_type):
        """ this method create the second layout of the window
            it lets us view the crops grow"""
            
        self.growth_label = QLabel("Growth")
        self.days_label = QLabel("Days growing")
        self.status_label = QLabel("Crop status")
        
        self.growth_line_edit = QLineEdit()
        self.days_line_edit = QLineEdit()
        self.status_line_edit = QLineEdit()
        
        self.manual_grow_button = QPushButton("Manually grow")
        self.automatic_grow_button = QPushButton("Automatically grow")
        
        self.grow_grid = QGridLayout()
        self.status_grid = QGridLayout()
        
        #add label widgets to the status layout
        self.status_grid.addWidget(self.growth_label, 0,0)
        self.status_grid.addWidget(self.days_label,1,0)
        self.status_grid.addWidget(self.status_label,2,0)
        
        #add line edit widgets to the status layout
        self.status_grid.addWidget(self.growth_line_edit, 0,1)
        self.status_grid.addWidget(self.days_line_edit,1,1)
        self.status_grid.addWidget(self.status_line_edit,2,1)
        
        # add widgets/ layout ot the grow layout
        self.grow_grid.addLayout(self.status_grid, 0, 1)
        self.grow_grid.addWidget(self.manual_grow_button, 1,0)
        self.grow_grid.addWidget(self.automatic_grow_button, 1,1)
        
        # create a widget to display the grow layout
        self.view_crop_widget = QWidget()
        self.view_crop_widget.setLayout(self.grow_grid)
    
		# connectionss
        self.automatic_grow_button.clicked.connect(self.automatically_grow_crop)
        self.manual_grow_button.clicked.connect(self.manually_grow_crop)
        
    def instantiate_crop(self):
        crop_type = self.crop_radio_buttons.selected_button() # get the radio that was selected
        if crop_type == 1:
            self.simulated_crop = Wheat()
        elif(crop_type == 2):
            self.simulated_crop = Potato()
        
        self.create_view_crop_layout(crop_type) # create the view crop growth layout
        self.stacked_layout.addWidget(self.view_crop_widget) # add rthis to stack
        self.stacked_layout.setCurrentIndex(1) # change the visible layout

    def automatically_grow_crop(self):
        """ this method grows the crop for 30 days"""
        for day in range(30):
            light = random.randint(1,10)
            water = random.randint(1,10)
            self.simulated_crop.grow(light, water)
            
        self.update_crop_view_status()
        
    def manually_grow_crop(self):
        manual_value_dialog = Manual_grow_dialog()
        manual_value_dialog.exec_() # run the dialog window
        
        light, water = manual_value_dialog.values()
        
        self.simulated_crop.grow(light, water)
        
        self.update_crop_view_status()
        
    def update_crop_view_status(self):
        crop_status_report = self.simulated_crop.report() # get the crop report
        
        # update the text fields
        self.growth_line_edit.setText(str(crop_status_report["growth"]))
        self.days_line_edit.setText(str(crop_status_report["days growing"]))
        self.status_line_edit.setText(str(crop_status_report["status"]))
示例#4
0
def whichTask(num):
    print('Found notification at ' + str(num))

    while True:
        food_type = None

        food_type = pyautogui.locateOnScreen('hamburger.png',
                                             region=(1356, 213, 124, 1),
                                             grayscale=True)
        if food_type:
            if food[num - 1] == 'hamburger':
                Hamburger.hamburgerIngredients(num)
            else:
                Hamburger.hamburgerMeat(num)
            return

        food_type = pyautogui.locateOnScreen('lobster.png',
                                             region=upper_center_region)
        if food_type:
            if food[num - 1] == 'lobster':
                Lobster.lobsterIngredients(num)
                return
        food_type = pyautogui.locateOnScreen('lobstercook.png',
                                             region=ingr_center_region)
        if food_type:
            Lobster.lobsterCook(num)
            return

        food_type = pyautogui.locateOnScreen('pasta.png', region=center_region)
        if food_type:
            if food[num - 1] == 'pasta':
                Pasta.pastaIngredients(num)
                return
        food_type = pyautogui.locateOnScreen('pastacook.png',
                                             region=ingr_center_region)
        if food_type:
            Pasta.pastaCook(num)
            return

        # This loop uses the dictionary index above ^
        for task_index in range(len(taskDict)):

            if (task_index == 22 or task_index == 16 or task_index == 17
                    or task_index == 25 or task_index == 28
                    or task_index == 31):
                food_type = pyautogui.locateOnScreen(
                    'FoodTaskImg' + str(task_index) + '.png',
                    region=offset_center_region,
                    grayscale=True)
            elif (task_index == 23 or task_index == 19):
                food_type = pyautogui.locateOnScreen(
                    'FoodTaskImg' + str(task_index) + '.png',
                    region=upper_center_region,
                    grayscale=True)
            elif (task_index == 2 or task_index == 7 or task_index == 21
                  or task_index == 10):
                food_type = pyautogui.locateOnScreen('FoodTaskImg' +
                                                     str(task_index) + '.png',
                                                     region=ingr_center_region,
                                                     grayscale=True)
            else:
                food_type = pyautogui.locateOnScreen('FoodTaskImg' +
                                                     str(task_index) + '.png',
                                                     region=center_region,
                                                     grayscale=True)

            if food_type:
                taskDict[task_index](num)
                return

        food_type = pyautogui.locateOnScreen('pancake.png',
                                             region=center_region)
        if food_type:
            if food[num - 1] == 'pancake':
                Pancake.pancakeIngredients(num)
                return
        food_type = pyautogui.locateOnScreen('pancakeCook.png',
                                             region=ingr_center_region)
        if food_type:
            Pancake.pancakeCook(num)
            return

        food_type = pyautogui.locateOnScreen('nachos.png',
                                             region=center_region,
                                             grayscale=True)
        if food_type:
            if food[num - 1] == 'nachos':
                Nachos.nachosIngredients(num, 1)
            else:
                Nachos.nachosIngredients(num, 0)
            return
        food_type = pyautogui.locateOnScreen('nachosMeat.png',
                                             region=ingr_center_region)
        if food_type:
            Nachos.nachosMeat(num)
            return
        food_type = pyautogui.locateOnScreen('nachosMeatevent.png',
                                             region=ingr_center_region)
        if food_type:
            Nachos.nachosMeat(num)
            return

        food_type = pyautogui.locateOnScreen('potato.png',
                                             region=center_region)
        if food_type:
            if food[num - 1] == 'potato':
                Potato.potatoIngredients(num)
                return
        food_type = pyautogui.locateOnScreen('potatocook.png',
                                             region=(1750, 150, 15, 15))
        if food_type:
            Potato.potatoCook(num)
            return

        food_type = pyautogui.locateOnScreen('thumb.png',
                                             region=recipe_region,
                                             grayscale=True)
        if food_type:
            pyautogui.press('t')
            pyautogui.press('enter')
            time.sleep(1)
            return

        food_type = pyautogui.locateOnScreen('love.png',
                                             region=recipe_region,
                                             grayscale=True)
        if food_type:
            pyautogui.press('z')
            time.sleep(1)
            pyautogui.press('x')
            """
			while True:
				print('I NEED AN ADULT')
				winsound.Beep(frequency, duration)
				time.sleep(0.5)
				if pyautogui.locateOnScreen('potatocook.png', region=(1750,150,15,15)):
					break
			"""
            time.sleep(1)
            return

        print('Failing to find order/task.')
        """
		for i in range(18):
			if run_time[i] > run_time[i+1]:
				worst = i
		print('Worst run_time was ' + str(i) + ' at ' + str(run_time[i]) + ' seconds.')
		"""

    return