コード例 #1
0
ファイル: LemonadeGui.py プロジェクト: FOSSRIT/lemonade-stand
    def ingredient_count(self, items, money):
        # sides are at 650 and 675
        #            /1200    /900
        #            13/24   27/36
        ingredient_block = Surface((self.game_engine.width * 11/24,
                                    self.game_engine.height * 9/36))
        ingredient_block.fill((255, 255, 255))
        
        icon_size = int(ingredient_block.get_width() / (len(items) * 1.5))
        icon_width = ingredient_block.get_width() / len(items)
        j = icon_size / 3
        render_top = 15 + icon_size
        for name, count in items.items():
            icon = image.load("images/icon-%s.gif" % name).convert()
            icon = transform.scale(icon, (icon_size, icon_size))
            ingredient_block.blit(icon, (j, 10))

            # Put an item count under the icon.
            ren = self.__font.render(str(count), True, (0, 0, 0))
            fw, fh = ren.get_size()
            render_left = j + (icon_size / 2) - (fw / 2)
            ingredient_block.blit(ren, (render_left, render_top))
            j += icon_width

        ren = self.__font.render("Funds: %s" % format_money(money), True, (0, 0, 0))
        fw, fh = ren.get_size()
        render_left = ingredient_block.get_width() / 2 - fw / 2
        render_top = (ingredient_block.get_height() - render_top) / 2 + render_top
        ingredient_block.blit(ren, (render_left, render_top))

        return ingredient_block
コード例 #2
0
ファイル: LemonadeGui.py プロジェクト: nswarup14/Lemonade
    def ingredient_count(self, items, money):
        # sides are at 650 and 675
        #            /1200    /900
        #            13/24   27/36
        ingredient_block = Surface((self.game_engine.width * 11/24,
                                    self.game_engine.height * 9/36))
        ingredient_block.fill((255, 255, 255))
        
        icon_size = int(ingredient_block.get_width() / (len(items) * 1.5))
        icon_width = ingredient_block.get_width() / len(items)
        j = icon_size / 3
        render_top = 15 + icon_size
        for name, count in items.items():
            icon = image.load("images/icon-%s.gif" % name).convert()
            icon = transform.scale(icon, (icon_size, icon_size))
            ingredient_block.blit(icon, (j, 10))

            # Put an item count under the icon.
            ren = self.__font.render(str(count), True, (0, 0, 0))
            fw, fh = ren.get_size()
            render_left = j + (icon_size / 2) - (fw / 2)
            ingredient_block.blit(ren, (render_left, render_top))
            j += icon_width

        ren = self.__font.render("Funds: %s" % format_money(money), True, (0, 0, 0))
        fw, fh = ren.get_size()
        render_left = ingredient_block.get_width() / 2 - fw / 2
        render_top = (ingredient_block.get_height() - render_top) / 2 + render_top
        ingredient_block.blit(ren, (render_left, render_top))

        return ingredient_block
コード例 #3
0
    def draw_store(self, key):
        """Draws the store interface, including currently selected items."""

        store = image.load("images/store-outline.gif").convert()
        store = transform.scale(
            store, (self.game_engine.width, self.game_engine.height))

        # Store apron text.
        # block_arr = [Surface((self.game_engine.width / 4,
        #               self.game_engine.height / 6))] * 3
        # h = self.game_engine.width * 7 / 24
        # j = self.game_engine.width / 12
        # for num, block in enumerate(block_arr):
        #    store.blit(block, (j, 20))
        #    j += h

        # Store item display.
        spacer = self.game_engine.width / (len(ITEMS) * 4)
        icon_size = (self.game_engine.width -
                     (len(ITEMS) + 1) * spacer) / len(ITEMS)
        j = spacer
        for num, name in enumerate(ITEMS):
            outline = Surface((icon_size, icon_size))
            if num == key:
                outline.fill((255, 255, 0))
            else:
                outline.fill((0, 255, 0))
            icon = image.load("images/icon-%s.gif" % name).convert()
            icon = transform.scale(icon,
                                   (icon_size * 8 / 10, icon_size * 8 / 10))
            outline.blit(icon, (icon_size / 10, icon_size / 10))
            store.blit(outline, (j, self.game_engine.height / 4))

            # Put pricing info under the item.
            ren = self.__font.render(
                "%s for %d" %
                (format_money(ITEMS[name]["cost"] * ITEMS[name]["bulk"]),
                 ITEMS[name]["bulk"]), True, (0, 0, 0))
            fw, fh = ren.get_size()
            render_left = j + (icon_size / 2) - (fw / 2)
            store.blit(
                ren,
                (render_left, self.game_engine.height / 4 + icon_size + 5))

            # Put an item count under the icon.
            ren = self.__font.render(self.__input_string[0][num], True,
                                     (0, 0, 0))
            fw, fh = ren.get_size()
            render_left = j + (icon_size / 2) - (fw / 2)
            store.blit(ren, (render_left, self.game_engine.height * 5 / 8))

            j += icon_size + spacer

        return store
コード例 #4
0
ファイル: LemonadeGui.py プロジェクト: FOSSRIT/lemonade-stand
    def draw_store(self, key):
        """Draws the store interface, including currently selected items."""

        store = image.load("images/store-outline.gif").convert()
        store = transform.scale(store, (self.game_engine.width, self.game_engine.height))

        # Store apron text.
        #block_arr = [Surface((self.game_engine.width / 4, self.game_engine.height / 6))] * 3
        #h = self.game_engine.width * 7 / 24
        #j = self.game_engine.width / 12
        #for num, block in enumerate(block_arr):
        #    store.blit(block, (j, 20))
        #    j += h

        # Store item display.
        spacer = self.game_engine.width / (len(ITEMS) * 4)
        icon_size = (self.game_engine.width - (len(ITEMS) + 1) * spacer) / len(ITEMS)
        j = spacer
        for num, name in enumerate(ITEMS):
            outline = Surface((icon_size, icon_size))
            if num == key:
                outline.fill((255, 255, 0))
            else:
                outline.fill((0, 255, 0))
            icon = image.load("images/icon-%s.gif" % name).convert()
            icon = transform.scale(icon, (icon_size * 8 / 10, icon_size * 8 / 10))
            outline.blit(icon, (icon_size / 10, icon_size / 10))
            store.blit(outline, (j, self.game_engine.height / 4))

            # Put pricing info under the item.
            ren = self.__font.render("%s for %d" % (format_money(ITEMS[name]["cost"] * ITEMS[name]["bulk"]),
                            ITEMS[name]["bulk"]), True, (0, 0, 0))
            fw, fh = ren.get_size()
            render_left = j + (icon_size / 2) - (fw / 2)
            store.blit(ren, (render_left, self.game_engine.height / 4 + icon_size + 5))

            # Put an item count under the icon.
            ren = self.__font.render(self.__input_string[0][num], True, (0, 0, 0))
            fw, fh = ren.get_size()
            render_left = j + (icon_size / 2) - (fw / 2)
            store.blit(ren, (render_left, self.game_engine.height * 5 / 8))
            
            j += icon_size + spacer

        return store
コード例 #5
0
    def process_day_logic(self, items):
        self.clear_queue()
        self.__day += 1
        start_money = self.__resources['money']
        self.add_msg(_("Starting Money: %s" % format_money(start_money)))

        # Process Item Payment
        for item in items:
            status = self.buy_item(item, items[item])
            if status == -1:
                self.add_msg(_("You can't afford any units of %s.") % \
                    ITEMS[item]['name'])

            else:
                self.add_msg(_("Bought %d units of %s.") % \
                    (items[item], ITEMS[item]['name']))

        # Calculate how many can be bought
        inventory_hold = []
        for item_key in ITEMS.keys():
            if self.recipe(item_key) == 0:
                continue
            inventory_hold.append(\
                self.count_item(item_key) / self.recipe(item_key))

        sales = min(inventory_hold)

        # Calculate how many will be bought by weather
        if sales != 0:
            if self.__weather == 0:
                sales = int(sales * .8)
            elif self.__weather == -1:
                sales = int(sales * .6)

        # Remove items required per cup sold
        for item_key in ITEMS.keys():
            self.remove_item(item_key, sales * self.recipe(item_key))

        self.__resources['last_income'] = sales * self.__resources['price']

        self.add_msg(_("Sold %d cups, at %s each") % \
                (sales, format_money(self.__resources['price'])))

        # Show profit and expenses if the difficuly is less than impossible
        if self.__difficulty < DIFFICULTY.index("Impossible"):
            self.add_msg("You spent %s on supplies" % \
                    format_money(self.__resources['money'] - start_money))
            self.add_msg("and made %s in sales" % \
                    format_money(self.__resources['last_income']))

        profit_to_calculate = (self.__resources['money'] - start_money)\
                              + self.__resources['last_income']
        self.__resources['last_profit'] = profit_to_calculate

        if profit_to_calculate > 0:
            # Show the net porfit if difficulty is less than normal
            if self.__difficulty < DIFFICULTY.index("Hard"):
                self.add_msg("That comes to %s in profit" % \
                    (format_money(self.__resources['last_profit'])))
            return True

        else:
            self.__resources['money'] += self.__resources['last_income']
            self.process_day_end()
            return False
コード例 #6
0
    def process_day_logic(self, items):
        self.clear_queue()
        self.__day += 1
        start_money = self.__resources['money']
        self.add_msg(_("Starting Money: %s" % format_money(start_money)))

        # Process Item Payment
        for item in items:
            status = self.buy_item(item, items[item])
            if status == -1:
                self.add_msg(_("You can't afford any units of %s.") % \
                    ITEMS[item]['name'])

            else:
                self.add_msg(_("Bought %d units of %s.") % \
                    (items[item], ITEMS[item]['name']))

        # Calculate how many can be bought
        inventory_hold = []
        for item_key in ITEMS.keys():
            if self.recipe(item_key) == 0:
                continue
            inventory_hold.append(\
                self.count_item(item_key) / self.recipe(item_key))

        sales = min(inventory_hold)

        # Calculate how many will be bought by weather
        if sales != 0:
            if self.__weather == 0:
                sales = int(sales * .8)
            elif self.__weather == -1:
                sales = int(sales * .6)

        # Remove items required per cup sold
        for item_key in ITEMS.keys():
            self.remove_item(item_key, sales * self.recipe(item_key))

        self.__resources['last_income'] = sales * self.__resources['price']

        self.add_msg(_("Sold %d cups, at %s each") % \
                (sales, format_money(self.__resources['price'])))

        # Show profit and expenses if the difficuly is less than impossible
        if self.__difficulty < DIFFICULTY.index("Impossible"):
            self.add_msg("You spent %s on supplies" % \
                    format_money(self.__resources['money'] - start_money))
            self.add_msg("and made %s in sales" % \
                    format_money(self.__resources['last_income']))

        profit_to_calculate = (self.__resources['money'] - start_money)\
                              + self.__resources['last_income']
        self.__resources['last_profit'] = profit_to_calculate

        if profit_to_calculate > 0:
            # Show the net porfit if difficulty is less than normal
            if self.__difficulty < DIFFICULTY.index("Hard"):
                self.add_msg("That comes to %s in profit" % \
                    (format_money(self.__resources['last_profit'])))
            return True

        else:
            self.__resources['money'] += self.__resources['last_income']
            self.process_day_end()
            return False