def Run(): global DeltaTime DeltaTime += 1 if DeltaTime > 2: DeltaTime = 0 # -- ItemID is 0 ItemLevel = items.GetItemLevel_ByID(0) ItemClickPerSecound = gameMain.DefaultCnt.Get_RegKey( "/ItemData/0/lv_{0}_click".format(ItemLevel), float) TotalValue = ( ItemClickPerSecound * gameMain.save.Current_MoneyMultiplier) * items.GetItemCount_ByID(0) AdderText = "+{0}".format(utils.FormatNumber(TotalValue)) try: # -- Items exists -- # Index = gameMain.ScreenGame.IncomingLog.TextGrind_Text.index( AdderText) gameMain.save.Current_Money += TotalValue except ValueError: # -- Item Does not Exist -- # gameMain.ScreenGame.IncomingLog.AddMessageText( AdderText, True, (150, 220, 150), TotalValue)
def ReloadItemsList(): global ListItems global SelectedItemLevel global LastClickedItem global SelectedItemPrice global SelectedItemID ListItems = gameObjs.VerticalListWithDescription( pygame.Rect(0, 0, 350, 250)) ListItems.ClearItems() print("ReloadItemsList : Add Store Items") for x in range(gameMain.DefaultCnt.Get_RegKey("/ItemData/minimum", int), gameMain.DefaultCnt.Get_RegKey("/ItemData/all", int) + 1): # -- Check if item is Visible -- # if gameMain.DefaultCnt.Get_RegKey("/ItemData/" + str(x) + "/is_upgradeable"): # -- Reg Keys Locations -- # CurrentItemRoot = "/ItemData/upgrade/" + str(x) + "_" CurrentItemLevel = gameItems.GetItemLevel_ByID(x) + 1 CurrentItemSprite = gameItems.GetItemSprite_ByID(x) CurrentItemDescription = CurrentItemRoot + "description_" + str( CurrentItemLevel) CurrentItemName = CurrentItemRoot + "name_" + str(CurrentItemLevel) print("ReloadItemsList : CurrentItem[" + CurrentItemRoot + "]") ListItems.AddItem( gameMain.DefaultCnt.Get_RegKey(CurrentItemName), gameMain.DefaultCnt.Get_RegKey(CurrentItemDescription), gameMain.DefaultCnt.Get_RegKey(CurrentItemSprite)) print("ReloadItemsList : Add Store Items") RestartAnimation()
def ReloadItemsList(): global ListItems ListItems.ClearItems() gameItems.RestartItems() # -- Load Items -- # for x in range(gameMain.DefaultCnt.Get_RegKey("/ItemData/minimum", int), gameMain.DefaultCnt.Get_RegKey("/ItemData/all", int) + 1): # -- Check if item is Visible -- # if gameMain.DefaultCnt.Get_RegKey("/ItemData/" + str(x) + "/is_buyable", bool): CurrentItemRoot = "/ItemData/store/" + str(x) + "_" ItemSprite = gameItems.GetItemSprite_ByID(x) ListItems.AddItem(gameMain.DefaultCnt.Get_RegKey(CurrentItemRoot + "name"), gameMain.DefaultCnt.Get_RegKey(CurrentItemRoot + "description"), gameMain.DefaultCnt.Get_RegKey(ItemSprite))
def BuyItem_ByID(ItemID): ItemID = int(ItemID) ItemPrice = gameItems.GetItemPrice_ByID(ItemID) ItemCount = gameItems.GetItemCount_ByID(ItemID) ItemIsUnlocker = gameItems.GetItemIsUnlocker_ByID(ItemID) BuySucefully = False if ItemIsUnlocker: # -- Buy Unlocker Items if not ItemCount >= 1: # -- Increase Item Count -- # gameItems.IncreaseItemCount_ByID(ItemID) # -- Create Item Object -- # gameItems.CreateItemObject(ItemID) BuySucefully = True else: # -- Buy Common Items -- # gameItems.IncreaseItemCount_ByID(ItemID) # -- Create Item Object -- # gameItems.CreateItemObject(ItemID) BuySucefully = True if BuySucefully: # -- Subtract the Money -- # IncomingLog.AddMessageText(utils.FormatNumber(-ItemPrice, 2), True, (250, 150, 150), -ItemPrice) # -- Add Item to the Item View on Game Screen -- # GameScreen.ItemsView.AddItem(str(ItemID)) else: # -- Subtract the Money -- # IncomingLog.AddMessageText(gameMain.DefaultCnt.Get_RegKey("/strings/window/store/cant_buy_item"), False, (250, 150, 150)) sound.PlaySound("/hit_2.wav", 0.5)
def Update(): global ItemsMaintenance global BaseMaintenance global LastMaintenancePrice global DayTrigger global NextMaintenanceDay if save.CurrentDate_Day == DayTrigger: # -- Dont let the Maintenance Day to the Day Limit -- # if save.CurrentDate_Day + 1 >= save.CurrentDate_MonthLimiter: DayTrigger = 0 else: DayTrigger = save.CurrentDate_Day + PerDayValue # -- Calculate Maintenance of All Items -- # TotalItems = 0 for item in gameItems.ItemsList: TotalItems += 1 ItemsMaintenance = ItemsMaintenance + item.maintenance_cost + randint( 1, TotalItems) # -- Add Maintenance of Auto Clicker -- # if gameItems.GetItemCount_ByID(0) > 1: ItemsMaintenance += (gameItems.GetItem_MaintenancePrice(0) * gameItems.GetItemCount_ByID(0)) # -- Calculate the Maintenance -- # MaintenancePrice = BaseMaintenance + ItemsMaintenance # -- Decrease Money -- # IncomingLog.AddMessageText(utils.FormatNumber(-MaintenancePrice, 2), True, ( 250, 150, 150, ), -MaintenancePrice) # -- Set Variables -- # LastMaintenancePrice = MaintenancePrice
def Update(): global DownBar_BuyPanelYOffset global DownBar_BuyPanelAnimEnabled global DownBar_BuyPanelYOffsetAdder global BuyAmout global LastItemIDSelected global SelectedItemPrice global SelectedItemID global LastClickedItem if ListItems.LastItemClicked != "null": if LastClickedItem != ListItems.LastItemClicked: DownBar_BuyPanelAnimEnabled = True DownBar_BuyPanelYOffset = 0 LastClickedItem = ListItems.LastItemClicked # -- Set Item Price and ID -- # SelectedItemID = ListItems.LastItemOrderID SelectedItemPrice = gameItems.GetItemPrice_ByID(SelectedItemID) # -- Set the Buy Button Location -- # BuyButton.Set_X(WindowObject.WindowRectangle[2] - BuyButton.Rectangle[2] - 5) BuyButton.Set_Y(WindowObject.WindowRectangle[3] - BuyButton.Rectangle[3] - DownBar_BuyPanelYOffset + 5) # -- Set the Buy Button Collision -- # BuyButton.Set_ColisionX(WindowObject.WindowRectangle[0] + BuyButton.Rectangle[0]) BuyButton.Set_ColisionY(WindowObject.WindowRectangle[1] + BuyButton.Rectangle[1] + BuyButton.Rectangle[3]) # -- Update Buy Button -- # if BuyButton.ButtonState == 2: if save.Current_Money >= SelectedItemPrice: # -- If you can buy the Item -- # BuyItem_ByID(SelectedItemID) else: # -- Notify that you can't buy that item IncomingLog.AddMessageText(gameMain.DefaultCnt.Get_RegKey("/strings/window/store/cant_buy_item"), False, (250, 150, 150)) gameMain.DefaultCnt.PlaySound("/hit_2.wav", 0.5) # -- Update the Items List -- # ListItems.Set_W(DrawnSurface.get_width()) ListItems.Set_H(DrawnSurface.get_height()) ListItems.ColisionXOffset = WindowObject.WindowRectangle[0] ListItems.ColisionYOffset = WindowObject.WindowRectangle[1] + 20 # -- Update Buy Panel Animation -- # if DownBar_BuyPanelAnimEnabled: DownBar_BuyPanelYOffsetAdder += 1 DownBar_BuyPanelYOffset += DownBar_BuyPanelYOffsetAdder if DownBar_BuyPanelYOffset >= 30: DownBar_BuyPanelYOffset = 30 DownBar_BuyPanelAnimEnabled = False DownBar_BuyPanelYOffsetAdder = 0
def Update(): global Current_Money global Current_MoneyValuePerClick global Current_MoneyPerSecond global Current_MoneyFormated global Current_MoneyPerSecondFormatted global MoneyPerSecond_Delta global MoneyPerSecond_Last global Current_ExperienceFormated global Current_MoneyPerClickBest global SaveDataLoaded global WelcomeMessageTriggered if SaveDataLoaded: # -- Update the Clock -- # UpdateClock() # -- Say the Initial Message -- # if not WelcomeMessageTriggered: WelcomeMessageTriggered = True TutorialTrigger("new_savegame") # -- Updated Formated Strings -- # if gameMain.DefaultCnt.Get_RegKey("/OPTIONS/format_numbers"): Current_MoneyFormated = utils.FormatNumber(Current_Money, 2) Current_MoneyPerSecondFormatted = utils.FormatNumber( Current_MoneyPerSecond, 2) Current_ExperienceFormated = utils.FormatNumber( Current_Experience, 2) else: Current_MoneyFormated = str(Current_Money) Current_MoneyPerSecondFormatted = str(Current_MoneyPerSecond) Current_ExperienceFormated = str(Current_Experience) # -- Update Money Per Second -- # MoneyPerSecond_Delta += 1 if MoneyPerSecond_Delta == 1000: Current_MoneyPerSecond = Current_Money - MoneyPerSecond_Last MoneyPerSecond_Last = Current_Money MoneyPerSecond_Delta = 0 # -- Set Best Click -- # if Current_MoneyPerClickBest < Current_MoneyPerSecond: Current_MoneyPerClickBest = Current_MoneyPerSecond # -- Update All Loaded Items -- # gameItems.UpdateItems() # -- Triggers Bankrupt -- # TriggerBankrupt()
def BuyItem_ByID(ItemID): global SelectedItemLevel global LastClickedItem global SelectedItemPrice global SelectedItemID Price = gameItems.GetItemUpgradePrice_ByID(ItemID) print("BuyItemUpgrade : ItemID[{0}] Price[{1}]".format( str(ItemID), str(Price))) if save.Current_Experience >= Price: save.Current_Experience -= Price IncomingLog.AddMessageText( gameMain.DefaultCnt.Get_RegKey( "/strings/window/expecience_store/item_upgrade"), False, (140, 240, 140)) # -- Write item level Information -- # gameItems.IncreaseItemLevel_ByID(ItemID) ReloadItemsList() else: sound.PlaySound("/hit_2.wav", 0.5)
def EventUpdate(event): # -- Update all buttons -- # global GrindButton global GameOptionsButton global SaveButton global BackToMainMenuButton global OpenStoreButton global StoreWindow_Enabled global ItemsView global IsControlsEnabled global OpenExperienceWindowButton global OpenInfosWindowButton global BlinkExperienceEnabled global HUD_Surface if IsControlsEnabled: GrindButton.Update(event) GameOptionsButton.Update(event) SaveButton.Update(event) BackToMainMenuButton.Update(event) OpenStoreButton.Update(event) ItemsView.Update(event) IncomingLog.EventUpdate(event) OpenInfosWindowButton.Update(event) if gameItems.GetItemCount_ByID(-1) == 1: OpenExperienceWindowButton.Update(event) # -- Update store Window -- # if StoreWindow_Enabled: storeWindow.EventUpdate(event) # -- Update Infos Window -- # if InfosWindow_Enabled: infosWindow.EventUpdate(event) if ExperienceStore_Enabled: expStoreWindow.EventUpdate(event) if event.type == pygame.KEYUP and event.key == pygame.K_z: save.GrindClick() if event.type == pygame.KEYUP and event.key == pygame.K_m: save.GrindClick()
def Update(): global DownBar_BuyPanelYOffset global DownBar_BuyPanelAnimEnabled global DownBar_BuyPanelYOffsetAdder # -- Set the Buy Button Location -- # BuyButton.Set_X(WindowObject.WindowRectangle[2] - BuyButton.Rectangle[2] - 5) BuyButton.Set_Y(WindowObject.WindowRectangle[3] - BuyButton.Rectangle[3] - DownBar_BuyPanelYOffset + 5) # -- Set the Buy Button Collision -- # BuyButton.Set_ColisionX(WindowObject.WindowRectangle[0] + BuyButton.Rectangle[0]) BuyButton.Set_ColisionY(WindowObject.WindowRectangle[1] + BuyButton.Rectangle[1] + BuyButton.Rectangle[3]) if BuyButton.ButtonState == 2: BuyButton.ButtonState = "INATIVE" if save.Current_Experience >= gameItems.GetItemUpgradePrice_ByID( SelectedItemID): BuyItem_ByID(SelectedItemID) # -- Set Items List Size -- # ListItems.Set_W(DrawnSurface.get_width()) ListItems.Set_H(DrawnSurface.get_height()) ListItems.ColisionXOffset = WindowObject.WindowRectangle[0] ListItems.ColisionYOffset = WindowObject.WindowRectangle[1] + 20 # -- Buy Panel -- # if DownBar_BuyPanelAnimEnabled: DownBar_BuyPanelYOffsetAdder += 1 DownBar_BuyPanelYOffset += DownBar_BuyPanelYOffsetAdder if DownBar_BuyPanelYOffset >= 30: DownBar_BuyPanelYOffset = 30 DownBar_BuyPanelAnimEnabled = False DownBar_BuyPanelYOffsetAdder = 0
def Update(): global GameOptionsButton global BackToMainMenuButton global OpenStoreButton global StoreWindow_Enabled global ItemsView global BackToMainMenu_Delay global BackToMainMenu global IsControlsEnabled global SavingScreenEnabled global ExperienceStore_Enabled global InfosWindow_Enabled if IsControlsEnabled: # -- Update Save -- # save.Update() # -- Update Experience Blink -- # UpdateExperienceBlink() ItemsView.Set_X(5) ItemsView.Set_Y(gameMain.DefaultDisplay.get_height() - 130) # -- Update General Maintenance -- # maintenance.Update() # -- Update Buttons Click -- # if GrindButton.ButtonState == 2: save.TutorialTrigger("clicking_button") save.GrindClick() # -- Game Options Button -- # if GameOptionsButton.ButtonState == 2: transition.Run() ScreenSettings.ScreenToReturn = 1 ScreenSettings.Initialize() storeWindow.RestartAnimation() gameMain.SetScreen_ByID(2) # -- Save Buttons -- # if SaveButton.ButtonState == 2: SavingScreenEnabled = True IsControlsEnabled = False # -- Back to Main Menu Button -- # if BackToMainMenuButton.ButtonState == 2: transition.Run() BackToMainMenu = True if BackToMainMenu: BackToMainMenu_Delay += 1 if BackToMainMenu_Delay >= 5: gameMain.SetScreen_ByID(0) # -- Reset Variables -- # BackToMainMenu_Delay = 0 BackToMainMenu = False SaveGame() # -- Store Button -- # if OpenStoreButton.ButtonState == 2: save.TutorialTrigger("store_window_button") if StoreWindow_Enabled: StoreWindow_Enabled = False storeWindow.RestartAnimation() else: StoreWindow_Enabled = True InfosWindow_Enabled = False ExperienceStore_Enabled = False # -- Infos Button -- # elif OpenInfosWindowButton.ButtonState == 2: save.TutorialTrigger("infos_window_button") if InfosWindow_Enabled: InfosWindow_Enabled = False else: InfosWindow_Enabled = True StoreWindow_Enabled = False ExperienceStore_Enabled = False # -- Experience Store Button -- # elif OpenExperienceWindowButton.ButtonState == 2 and gameItems.GetItemCount_ByID( -1) >= 1: save.TutorialTrigger("expstore_window_button") if ExperienceStore_Enabled: ExperienceStore_Enabled = False expStoreWindow.RestartAnimation() else: ExperienceStore_Enabled = True StoreWindow_Enabled = False InfosWindow_Enabled = False # -- Update Buttons Location -- # GameOptionsButton.Set_X(gameMain.DefaultDisplay.get_width() - 120) SaveButton.Set_X(gameMain.DefaultDisplay.get_width() - 120) BackToMainMenuButton.Set_X(gameMain.DefaultDisplay.get_width() - 120) GrindButton.Rectangle[2] = 130 GrindButton.Rectangle[3] = 150 OpenStoreButton.Set_X(5) OpenStoreButton.Set_Y(gameMain.DefaultDisplay.get_height() - OpenStoreButton.Rectangle[3] - 5) OpenInfosWindowButton.Set_X(OpenStoreButton.Rectangle[0] + OpenStoreButton.Rectangle[2] + 5) OpenInfosWindowButton.Set_Y(OpenStoreButton.Rectangle[1]) OpenExperienceWindowButton.Set_X(OpenInfosWindowButton.Rectangle[0] + OpenInfosWindowButton.Rectangle[2] + 5) OpenExperienceWindowButton.Set_Y(OpenInfosWindowButton.Rectangle[1]) # -- Update Windows -- # WindowsUpdate() # -- Update Objects -- # IncomingLog.Update() gameClock.Update()
def Unload(): global CurrentDate_Day global CurrentDate_Month global CurrentDate_Year global CurrentDate_Minute global CurrentDate_Second global CurrentDate_Microseconds global Current_TotalClicks global Current_TotalClicksNext global Current_TotalClicksForEach global Current_ExperiencePerEach global Current_MoneyPerClickBest global Current_Experience global Current_Money global Current_MoneyValuePerClick global CurrentDate_DayLimiter global CurrentDate_MonthLimiter global CurrentDate_MinuteLimiter global CurrentDate_SecondLimiter global CurrentDate_YearLimiter global Current_MoneyMinimun global SaveDataLoaded global triggered_tutorials global WelcomeMessageTriggered global LowerMoneyWarning global BankruptWarning global PlanetID global PlanetName CurrentDate_Day = None CurrentDate_Month = None CurrentDate_Year = None CurrentDate_Minute = None CurrentDate_Second = None CurrentDate_Microseconds = None Current_TotalClicks = None Current_TotalClicksNext = None Current_TotalClicksForEach = None Current_ExperiencePerEach = None Current_MoneyPerClickBest = None Current_Experience = None Current_Money = None Current_MoneyValuePerClick = None CurrentDate_DayLimiter = None CurrentDate_MonthLimiter = None CurrentDate_MinuteLimiter = None CurrentDate_SecondLimiter = None CurrentDate_YearLimiter = None Current_MoneyMinimun = None SaveDataLoaded = None triggered_tutorials = list() WelcomeMessageTriggered = None BankruptWarning = None LowerMoneyWarning = None PlanetID = None PlanetName = None storeWindow.ReloadItemsList() expStoreWindow.ReloadItemsList() gameItems.RestartItems() gameScr.IncomingLog.Unload() maintenance.Unload()
def Render(self, DISPLAY): # -- Recreate Surface -- # self.ListSurface = pygame.Surface((self.Rectangle[2], self.Rectangle[3]), pygame.SRCALPHA) mainScript.shape.Shape_Rectangle(DISPLAY, (0, 12, 30), (self.Rectangle[0], self.Rectangle[1] - 16, self.Rectangle[2], 16), 0, 0, 2, 2) mainScript.DefaultCnt.FontRender(DISPLAY, "/PressStart2P.ttf", 10, mainScript.DefaultCnt.Get_RegKey("/strings/game/game_items_view"), (255, 255, 255), self.Rectangle[0] + self.Rectangle[2] / 2 - mainScript.DefaultCnt.GetFont_width("/PressStart2P.ttf", 10, mainScript.DefaultCnt.Get_RegKey("/strings/game/game_items_view")) / 2, self.Rectangle[1] - 13) Draw_Panel(DISPLAY, self.Rectangle) for i, itemID in enumerate(self.ItemsID): ItemName = mainScript.DefaultCnt.Get_RegKey("/ItemData/name/" + str(itemID)) ItemWidth = 156 ItemX = self.ScrollX + ItemWidth * i ItemRect = (ItemX, self.Rectangle[3] / 2 - 90 / 2, ItemWidth - 5, 90) # -- Draw the Background -- # Draw_Panel(self.ListSurface, ItemRect, True) # -- Render the Item Title -- # mainScript.DefaultCnt.FontRender(self.ListSurface, "/PressStart2P.ttf", 9, ItemName, (250, 250, 250), ItemRect[0] + ItemRect[2] / 2 - mainScript.DefaultCnt.GetFont_width("/PressStart2P.ttf", 9, ItemName) / 2, ItemRect[1] + 2, mainScript.DefaultCnt.Get_RegKey("/OPTIONS/font_aa")) # -- Render the Item Sprite -- # mainScript.DefaultCnt.ImageRender(self.ListSurface, mainScript.DefaultCnt.Get_RegKey(gameItems.GetItemSprite_ByID(int(itemID))), ItemRect[0] + 3, ItemRect[1] + 15, 64, 64, mainScript.DefaultCnt.Get_RegKey("/OPTIONS/sprite_aa")) # -- Render the Item Info -- # LittleInfoText = mainScript.DefaultCnt.Get_RegKey("/strings/game/items_info").format(utils.FormatNumber(gameItems.GetItemCount_ByID(self.ItemsID[i])).replace(".00", ""), str(gameItems.GetItemLevel_ByID(self.ItemsID[i]))) # -- Render Item Info -- # mainScript.DefaultCnt.FontRender(self.ListSurface, "/PressStart2P.ttf", 10, LittleInfoText, (250, 250, 250), ItemRect[0] + 70, ItemRect[1] + 12, mainScript.DefaultCnt.Get_RegKey("/OPTIONS/font_aa")) DISPLAY.blit(self.ListSurface, (self.Rectangle[0], self.Rectangle[1]))
def SaveData(): global CurrentDate_Day global CurrentDate_Month global CurrentDate_Year global CurrentDate_Minute global CurrentDate_Second global CurrentDate_Microseconds global Current_TotalClicks global Current_TotalClicksNext global Current_TotalClicksForEach global Current_ExperiencePerEach global Current_Experience global Current_Money global Current_MoneyValuePerClick global CurrentDate_DayLimiter global CurrentDate_MonthLimiter global CurrentDate_MinuteLimiter global CurrentDate_SecondLimiter global CurrentDate_YearLimiter global Current_MoneyMinimun global triggered_tutorials global Current_MoneyPerClickBest global WelcomeMessageTriggered global LowerMoneyWarning global PlanetID global PlanetName # -- Money and Click Vars -- # appData.WriteAppData("money", Current_Money) appData.WriteAppData("experience", Current_Experience) appData.WriteAppData("money_per_click", Current_MoneyValuePerClick) appData.WriteAppData("total_clicks", Current_TotalClicks) appData.WriteAppData("total_clicks_for_each", Current_TotalClicksForEach) appData.WriteAppData("total_experience_per_each", Current_ExperiencePerEach) appData.WriteAppData("money_minimun", Current_MoneyMinimun) appData.WriteAppData("click_last_best", Current_MoneyPerClickBest) # -- ETC -- # appData.WriteAppData("welcome_message_triggered", WelcomeMessageTriggered) appData.WriteAppData("lower_money_warning", LowerMoneyWarning) # -- Maintenance Variables -- # appData.WriteAppData("maintenance_day_trigger", maintenance.DayTrigger) appData.WriteAppData("maintenance_per_day_value", maintenance.PerDayValue) appData.WriteAppData("maintenance_base_price", maintenance.BaseMaintenance) # -- Save Date -- # appData.WriteAppData("date/day", CurrentDate_Day) appData.WriteAppData("date/month", CurrentDate_Month) appData.WriteAppData("date/year", CurrentDate_Year) appData.WriteAppData("date/minute", CurrentDate_Minute) appData.WriteAppData("date/second", CurrentDate_Second) appData.WriteAppData("date/microseconds", CurrentDate_Microseconds) # -- Save Date Limiter -- # appData.WriteAppData("date/limiter/day", CurrentDate_DayLimiter) appData.WriteAppData("date/limiter/month", CurrentDate_MonthLimiter) appData.WriteAppData("date/limiter/year", CurrentDate_YearLimiter) appData.WriteAppData("date/limiter/minute", CurrentDate_MinuteLimiter) appData.WriteAppData("date/limiter/second", CurrentDate_SecondLimiter) # -- Save Passed Tutorials -- # FileData = "" for i, tutorial in enumerate(triggered_tutorials): if not tutorial == "": FileData += "%n" + str(tutorial) appData.WriteAppData("tutorials_triggered", FileData) # -- Planet Data -- # appData.WriteAppData("planet_name", PlanetName) appData.WriteAppData("planet_id", PlanetID) # -- Save Items Data -- # gameItems.SaveItems()
def Render(DISPLAY): global WindowObject global DrawnSurface global BuyButton global ListItems global DownBar_BuyPanelAnimEnabled global DownBar_BuyPanelYOffset global LastClickedItem global SelectedItemID global SelectedItemPrice global SelectedItemLevel global StoreLocked # -- Update the Surface -- # DrawnSurface = pygame.Surface((WindowObject.WindowSurface_Rect[2], WindowObject.WindowSurface_Rect[3]), pygame.SRCALPHA) if not StoreLocked: # -- Draw the List -- # ListItems.Render(DrawnSurface) # -- Render the Selected Item Text -- # if ListItems.LastItemClicked != "null": if LastClickedItem != ListItems.LastItemClicked: DownBar_BuyPanelAnimEnabled = True DownBar_BuyPanelYOffset = 0 LastClickedItem = ListItems.LastItemClicked # -- Set Item Price and ID -- # SelectedItemID = ListItems.LastItemOrderID - 1 SelectedItemLevel = gameItems.GetItemLevel_ByID(SelectedItemID) + 1 SelectedItemPrice = gameItems.GetItemUpgradePrice_ByID( SelectedItemID) # -- Down Panel Background -- # CONTENT_MANAGER.Shape_Rectangle( DrawnSurface, (0, 0, 0, 100), (0, DrawnSurface.get_height() - DownBar_BuyPanelYOffset, DrawnSurface.get_width(), DownBar_BuyPanelYOffset)) CONTENT_MANAGER.Shape_Rectangle( DrawnSurface, (16, 166, 152), (0, DrawnSurface.get_height() - DownBar_BuyPanelYOffset - 1, DrawnSurface.get_width(), 1)) # -- Draw the Buy Button -- # BuyButton.Render(DrawnSurface) # -- Draw the Item Title -- # CONTENT_MANAGER.FontRender( DrawnSurface, "/PressStart2P.ttf", 15, ListItems.LastItemClicked, (250, 250, 250), 10, DrawnSurface.get_height() - DownBar_BuyPanelYOffset + 5, gameMain.DefaultCnt.Get_RegKey("/OPTIONS/font_aa")) # -- Draw the Item Price -- # PriceTextOpacity = 255 if save.Current_Experience < SelectedItemPrice: PriceTextOpacity = 100 - abs(save.Current_Experience - SelectedItemPrice) if PriceTextOpacity <= 100: PriceTextOpacity = 100 CONTENT_MANAGER.FontRender( DrawnSurface, "/PressStart2P.ttf", 8, "€xp" + str(utils.FormatNumber(SelectedItemPrice)), (PriceTextOpacity, PriceTextOpacity, PriceTextOpacity), 10, DrawnSurface.get_height() - DownBar_BuyPanelYOffset + 20, gameMain.DefaultCnt.Get_RegKey("/OPTIONS/font_aa"), Opacity=PriceTextOpacity) WindowObject.Render(DISPLAY) # -- Render Window Border DISPLAY.blit( DrawnSurface, (WindowObject.WindowSurface_Rect[0], WindowObject.WindowSurface_Rect[1])) # -- Render Window Objects
def LoadSaveData(): global CurrentDate_Day global CurrentDate_Month global CurrentDate_Year global CurrentDate_Minute global CurrentDate_Second global CurrentDate_Microseconds global Current_TotalClicks global Current_TotalClicksNext global Current_TotalClicksForEach global Current_ExperiencePerEach global Current_MoneyPerClickBest global Current_Experience global Current_Money global Current_MoneyValuePerClick global CurrentDate_DayLimiter global CurrentDate_MonthLimiter global CurrentDate_MinuteLimiter global CurrentDate_SecondLimiter global CurrentDate_YearLimiter global Current_MoneyMinimun global SaveDataLoaded global triggered_tutorials global WelcomeMessageTriggered global LowerMoneyWarning global PlanetID global PlanetName print("Fogoso.SaveManager : Loading Save Data...") # -- Load Money and Click Variables -- # Current_Money = appData.ReadAppData_WithTry("money", float, 0.0) Current_MoneyValuePerClick = appData.ReadAppData_WithTry( "money_per_click", float, 0.50) Current_MoneyMinimun = appData.ReadAppData_WithTry("money_minimun", float, -5000) Current_Experience = appData.ReadAppData_WithTry("experience", int, 0) Current_TotalClicks = appData.ReadAppData_WithTry("total_clicks", int, 0) Current_TotalClicksForEach = appData.ReadAppData_WithTry( "total_clicks_for_each", int, 35) Current_ExperiencePerEach = appData.ReadAppData_WithTry( "total_experience_per_each", int, 15) Current_MoneyPerClickBest = appData.ReadAppData_WithTry( "click_last_best", float, 0) # -- Calculate the Total Clicks Next -- # Current_TotalClicksNext = Current_TotalClicks + Current_TotalClicksForEach # -- Load the Current Date -- # CurrentDate_Year = appData.ReadAppData_WithTry("date/year", int, 0) CurrentDate_Month = appData.ReadAppData_WithTry("date/month", int, 0) CurrentDate_Day = appData.ReadAppData_WithTry("date/day", int, 0) CurrentDate_Second = appData.ReadAppData_WithTry("date/second", int, 0) CurrentDate_Minute = appData.ReadAppData_WithTry("date/minute", int, 0) CurrentDate_Microseconds = appData.ReadAppData_WithTry( "date/microsecond", int, 0) # -- Load the Date Limiters -- # CurrentDate_MinuteLimiter = appData.ReadAppData_WithTry( "date/limiter/minute", int, 60) CurrentDate_SecondLimiter = appData.ReadAppData_WithTry( "date/limiter/second", int, 50) CurrentDate_DayLimiter = appData.ReadAppData_WithTry( "date/limiter/day", int, 5) CurrentDate_MonthLimiter = appData.ReadAppData_WithTry( "date/limiter/month", int, 7) CurrentDate_YearLimiter = appData.ReadAppData_WithTry( "date/limiter/year", int, 5) # -- Load Last Maintenance -- # maintenance.DayTrigger = appData.ReadAppData_WithTry( "maintenance_day_trigger", int, 1) maintenance.PerDayValue = appData.ReadAppData_WithTry( "maintenance_per_day_value", int, 1) maintenance.BaseMaintenance = appData.ReadAppData_WithTry( "maintenance_base_price", float, 15.0) # -- ETC -- # WelcomeMessageTriggered = appData.ReadAppData_WithTry( "welcome_message_triggered", bool, False) LowerMoneyWarning = appData.ReadAppData_WithTry("lower_money_warning", bool, False) # -- Load Passed Tutorials -- # try: FileData = appData.ReadAppData_WithTry("tutorials_triggered", str, "") SplitedData = FileData.split('%n') for tutorial in SplitedData: try: Index = triggered_tutorials.index(str(tutorial)) except ValueError: triggered_tutorials.append(str(tutorial)) except AttributeError: appData.WriteAppData("tutorials_triggered", "") gameItems.LoadItems() print("Fogoso.SaveManager : Loading Store Items...") storeWindow.ReloadItemsList() expStoreWindow.ReloadItemsList() # -- Load the Planet Data -- # PlanetName = appData.ReadAppData_WithTry("planet_name", str, "Aragubas") PlanetID = appData.ReadAppData_WithTry("planet_id", int, 0) planets.LoadPlanetsData() print("Fogoso.SaveManager : Operation Completed!") SaveDataLoaded = True
def GameDraw(DISPLAY): global BackToMainMenuButton global OpenStoreButton global OpenInfosWindowButton global OpenExperienceWindowButton global StoreWindow_Enabled global ItemsView global SavingScreenEnabled global BlinkExperienceValue global HUD_Surface if SavingScreenEnabled: UpdateSavingScreen(DISPLAY) if not SavingScreenEnabled: # -- Draw the Grind Text -- # IncomingLog.Draw(DISPLAY) # -- Draw the Grind Button -- # GrindButton.Render(DISPLAY) # -- Draw the Options Button -- # GameOptionsButton.Render(DISPLAY) # -- Draw the Save Button -- # SaveButton.Render(DISPLAY) # -- Draw the BackToMenu button -- # BackToMainMenuButton.Render(DISPLAY) # -- Draw the Store Button -- # OpenStoreButton.Render(DISPLAY) # -- Draw the Items View -- # ItemsView.Render(DISPLAY) # -- Draw the OpenInfosWindow -- # OpenInfosWindowButton.Render(DISPLAY) # -- Draw the OpenExperience -- # if gameItems.GetItemCount_ByID(-1) == 1: OpenExperienceWindowButton.Render(DISPLAY) # -- Render Money Text -- # MoneyColor = (250, 250, 255) PerSecoundColor = (220, 220, 220) if save.Current_Money > 0.1: MoneyColor = (120, 220, 120) elif save.Current_Money <= 0: MoneyColor = (220, 10, 10) if save.Current_MoneyPerSecond > 0.1: PerSecoundColor = (50, 200, 50) elif save.Current_MoneyPerSecond <= 0: PerSecoundColor = (120, 10, 10) # -- Render Current Money, at Top -- # MoneyText = gameMain.DefaultCnt.Get_RegKey( "/strings/game/money") + save.Current_MoneyFormated gameMain.DefaultCnt.FontRender( DISPLAY, "/PressStart2P.ttf", 18, gameMain.DefaultCnt.Get_RegKey("/strings/game/money") + save.Current_MoneyFormated, (0, 0, 0), 12, 22) gameMain.DefaultCnt.FontRender(DISPLAY, "/PressStart2P.ttf", 18, MoneyText, MoneyColor, 10, 20) # -- Render Money per Second -- # MoneyPerSecoundText = gameMain.DefaultCnt.Get_RegKey( "/strings/game/money_per_secound" ) + save.Current_MoneyPerSecondFormatted gameMain.DefaultCnt.FontRender(DISPLAY, "/PressStart2P.ttf", 18, MoneyPerSecoundText, (0, 0, 0), 12, 52) gameMain.DefaultCnt.FontRender(DISPLAY, "/PressStart2P.ttf", 18, MoneyPerSecoundText, PerSecoundColor, 10, 50) # -- Render Experience -- # ExperienceText = gameMain.DefaultCnt.Get_RegKey( "/strings/game/experience") + str( save.Current_ExperienceFormated) + "/" + str( save.Current_TotalClicks - save.Current_TotalClicksNext) + "=" + str( save.Current_ExperiencePerEach) gameMain.DefaultCnt.FontRender( DISPLAY, "/PressStart2P.ttf", 18, ExperienceText, (BlinkExperienceValue, BlinkExperienceValue, BlinkExperienceValue), 12, 82) gameMain.DefaultCnt.FontRender( DISPLAY, "/PressStart2P.ttf", 18, ExperienceText, (140 + BlinkExperienceValue, 130 + BlinkExperienceValue, 120 + BlinkExperienceValue), 10, 80) # -- Render the Clock -- # gameClock.Draw(DISPLAY) # -- Draw the Store Window -- # if StoreWindow_Enabled: storeWindow.Render(DISPLAY) # -- Draw the Infos Window -- # if InfosWindow_Enabled: infosWindow.Render(DISPLAY) # -- Draw the Exp Store Window -- # if ExperienceStore_Enabled and gameItems.GetItemCount_ByID(-1) >= 1: expStoreWindow.Render(DISPLAY) HUD_Surface = DISPLAY.copy()
def GetNextLevelByID(ItemID): CurrentLevel = gameItems.GetItemLevel_ByID(ItemID) CurrentLevel += 1 return CurrentLevel