def count_game(self, values, target): """ Verifies the values of the counting game. @param values: A dictionary (keys must match CURRENCY) and values are how many of each currency type are required to make the optimum change @return: Returns true if they pass the mini-game """ currency_values = sorted(CURRENCY.items(), key=itemgetter(1), reverse=True) # Set previous_value to target so it always accepts the first key previous_value = target for key, value in currency_values: cal_val = (value * values[key]) if cal_val > previous_value: return False target -= cal_val previous_value = value if target == 0: return True else: return False
def __init__(self): GameEngineElement.__init__(self, has_draw=True, has_event=True) self.__font = self.game_engine.get_object('font') self.add_to_engine() self.game_mode = 0 self.__input_keys = [ITEMS.keys(), CURRENCY.keys(), [None]] self.__input_mode = [0, 0, 0] self.__input_string = [] for key in self.__input_keys: self.__input_string.append(['0'] * len(key))
def __init__(self): GameEngineElement.__init__(self, has_draw=True, has_event=True) self.__font = self.game_engine.get_object('font') self.add_to_engine() self.game_mode = 2 self.__input_keys = [ITEMS.keys(), CURRENCY.keys(), [None]] self.__input_mode = [0, 0, 0] self.__input_string = [] for key in self.__input_keys: self.__input_string.append(['0'] * len(key))