From 92d7a81fabf59150cebe843ed3611061c7245635 Mon Sep 17 00:00:00 2001 From: Goppier Date: Mon, 8 Apr 2024 01:14:35 +0200 Subject: [PATCH] Add option to select the fixed game, fix Feebas spot code --- feebasCalcs.py | 41 ++++++++++++++++++------ feebasCoordinates.py | 76 +++++++++++++++++++++++++++++++++++++++++++- main.py | 10 ++++-- 3 files changed, 114 insertions(+), 13 deletions(-) diff --git a/feebasCalcs.py b/feebasCalcs.py index 9a0a3d2..dc88c91 100644 --- a/feebasCalcs.py +++ b/feebasCalcs.py @@ -10,7 +10,7 @@ from tkinter import ttk from tkinter import * from trendyPhrase import group_conditions, group_lifestyles, group_hobbies, DewfordTrend -from feebasCoordinates import FEEBAS_COORDINATES +from feebasCoordinates import FEEBAS_BRIDGE_TILES, FEEBAS_COORDINATES_ORIGINAL, FEEBAS_COORDINATES_NEW DEBUG_ENABLED = False @@ -19,7 +19,7 @@ class FeebasCalculator: This class calculates the exact spots of where Feebas is located based on the Trainer ID, the Lottery Number and the Trendy Phrase. This class can only find Feebas if a new game has started without a working battery. """ - def __init__(self, trainer_id, lottery_number, trendy_phrase_1, trendy_phrase_2, is_emerald): + def __init__(self, trainer_id, lottery_number, trendy_phrase_1, trendy_phrase_2, is_emerald, is_fixed_game): """ This function initialises AND calculates the Feebas spots based on the parameters given. @@ -75,17 +75,26 @@ class FeebasCalculator: # Seed the RNG with the value found for the Trendy Phrase self.seedRng(self.feebas_seed) - + # Calculate the actual Feebas spots x = 0 + add_bridge_tiles = False while(x != 6): - feebas_id = self.getRandomValue() % 447 + feebas_id = self.getFeebasRandomValue() % 447 if(feebas_id == 0): feebas_id = 447 - if(feebas_id >= 4): - self.calculated_feebas_spots.append(FEEBAS_COORDINATES[feebas_id]) + if((is_fixed_game == False and feebas_id >= 4)): + self.calculated_feebas_spots.append(FEEBAS_COORDINATES_ORIGINAL[feebas_id]) x += 1 - + if(feebas_id == 132): + add_bridge_tiles = True + elif(is_fixed_game == TRUE): + self.calculated_feebas_spots.append(FEEBAS_COORDINATES_NEW[feebas_id]) + x += 1 + if(add_bridge_tiles == True): + for tile in FEEBAS_BRIDGE_TILES: + self.calculated_feebas_spots.append(tile) + def isFeebasFound(self): """ This function indicates if the class has found the Feebas spots or not @@ -110,7 +119,6 @@ class FeebasCalculator: self.calculated_feebas_spots: An array containing the 6 Feebas spot coordinates """ return self.calculated_feebas_spots - def seedRng(self, seed): """ @@ -121,10 +129,23 @@ class FeebasCalculator: seed: A 32 bit value containing the seed for the RNG """ self.random_value = seed & 0xFFFFFFFF - + + def getFeebasRandomValue(self): + """ + This function progresses the RNG once and returns the newly generated value for the Feebas RNG + + Args: + self: The class itself + Returns: + self.random_value: The upper 16 bits of the randomly generated value. + """ + self.random_value = 0x41C64E6D * self.random_value + 0x00003039 + self.random_value &= 0xFFFFFFFF + return (self.random_value >> 16) + def getRandomValue(self): """ - This function progresses the RNG once and returns the newly generated value + This function progresses the RNG once and returns the newly generated value for the Regular RNG Args: self: The class itself diff --git a/feebasCoordinates.py b/feebasCoordinates.py index 57c40b0..3de9904 100644 --- a/feebasCoordinates.py +++ b/feebasCoordinates.py @@ -1,4 +1,9 @@ -FEEBAS_COORDINATES = [ +FEEBAS_BRIDGE_TILES = [ + [16*16, 33*16], [17*16, 33*16], [18*16, 33*16], [19*16, 33*16], [20*16, 33*16], + [16*16, 34*16], [17*16, 34*16], [18*16, 34*16], [19*16, 34*16], [20*16, 34*16] +] + +FEEBAS_COORDINATES_ORIGINAL = [ # Unreachable spots. Index 0 is never used, but needs to be defined in this tool [0, 0],[9*16, 7*16],[7*16, 13*16],[15*16, 16*16], [18*16, 18*16], [18*16, 19*16], [19*16, 19*16], [16*16, 20*16], [17*16, 20*16], [18*16, 20*16], [19*16, 20*16], @@ -66,3 +71,72 @@ FEEBAS_COORDINATES = [ [17*16, 110*16],[18*16, 110*16],[19*16, 110*16], [8*16, 111*16], [9*16, 111*16],[10*16, 111*16],[11*16, 111*16], [12*16, 111*16],[7*16, 112*16],[8*16, 112*16] ] + +FEEBAS_COORDINATES_NEW = [ + # Unreachable spots. Index 0 is never used, but needs to be defined in this tool + [0, 0], + [18*16, 18*16], [18*16, 19*16], [19*16, 19*16], [16*16, 20*16], [17*16, 20*16], [18*16, 20*16], [19*16, 20*16], + [17*16, 21*16], [18*16, 21*16], [19*16, 21*16], [17*16, 22*16], [18*16, 22*16], [19*16, 22*16], [17*16, 23*16], + [18*16, 23*16], [19*16, 23*16], [17*16, 24*16], [18*16, 24*16], [19*16, 24*16], [17*16, 29*16], [18*16, 29*16], + [19*16, 29*16], [17*16, 30*16], [18*16, 30*16], [19*16, 30*16], [16*16, 31*16], [17*16, 31*16], [18*16, 31*16], + [19*16, 31*16], [20*16, 31*16], [16*16, 32*16], [17*16, 32*16], [18*16, 32*16], [19*16, 32*16], [20*16, 32*16], + [16*16, 33*16], [17*16, 33*16], [18*16, 33*16], [19*16, 33*16], [20*16, 33*16], [16*16, 34*16], [17*16, 34*16], + [18*16, 34*16], [19*16, 34*16], [20*16, 34*16], [16*16, 35*16], [17*16, 35*16], [18*16, 35*16], [19*16, 35*16], + [20*16, 35*16], [16*16, 36*16], [17*16, 36*16], [18*16, 36*16], [19*16, 36*16], [20*16, 36*16], [16*16, 37*16], + [17*16, 37*16], [18*16, 37*16], [19*16, 37*16], [20*16, 37*16], [16*16, 38*16], [17*16, 38*16], [18*16, 38*16], + [19*16, 38*16], [20*16, 38*16], [21*16, 38*16], [22*16, 38*16], [16*16, 39*16], [17*16, 39*16], [18*16, 39*16], + [19*16, 39*16], [20*16, 39*16], [21*16, 39*16], [22*16, 39*16], [16*16, 40*16], [17*16, 40*16], [18*16, 40*16], + [19*16, 40*16], [20*16, 40*16], [21*16, 40*16], [22*16, 40*16], [16*16, 41*16], [17*16, 41*16], [18*16, 41*16], + [19*16, 41*16], [20*16, 41*16], [21*16, 41*16], [22*16, 41*16], [16*16, 42*16], [17*16, 42*16], [18*16, 42*16], + [19*16, 42*16], [20*16, 42*16], [21*16, 42*16], [22*16, 42*16], [23*16, 42*16], [16*16, 43*16], [17*16, 43*16], + [18*16, 43*16], [19*16, 43*16], [20*16, 43*16], [21*16, 43*16], [22*16, 43*16], [23*16, 43*16], [24*16, 43*16], + [25*16, 43*16], [26*16, 43*16], [27*16, 43*16], [28*16, 43*16], [29*16, 43*16], [30*16, 43*16], [20*16, 44*16], + [21*16, 44*16], [22*16, 44*16], [23*16, 44*16], [24*16, 44*16], [25*16, 44*16], [26*16, 44*16], [27*16, 44*16], + [28*16, 44*16], [29*16, 44*16], [30*16, 44*16], [31*16, 44*16], [32*16, 44*16], [21*16, 45*16], [22*16, 45*16], + [23*16, 45*16], [24*16, 45*16], [25*16, 45*16], [26*16, 45*16], [27*16, 45*16], [28*16, 45*16], [29*16, 45*16], + [30*16, 45*16], [31*16, 45*16], [32*16, 45*16], [24*16, 46*16], [25*16, 46*16], [26*16, 46*16], [27*16, 46*16], + [28*16, 46*16], [29*16, 46*16], [30*16, 46*16], [31*16, 46*16], [32*16, 46*16], [33*16, 46*16], [34*16, 46*16], + [28*16, 47*16], [29*16, 47*16], [30*16, 47*16], [31*16, 47*16], [32*16, 47*16], [33*16, 47*16], [34*16, 47*16], + [30*16, 48*16], [31*16, 48*16], [32*16, 48*16], [33*16, 48*16], [34*16, 48*16], [31*16, 49*16], [32*16, 49*16], + [33*16, 49*16], [34*16, 49*16], [35*16, 49*16], [31*16, 50*16], [32*16, 50*16], [33*16, 50*16], [31*16, 51*16], + [32*16, 51*16], [33*16, 51*16], [31*16, 52*16], [32*16, 52*16], [33*16, 52*16], [34*16, 52*16], [35*16, 52*16], + [31*16, 53*16], [32*16, 53*16], [33*16, 53*16], [34*16, 53*16], [35*16, 53*16], [33*16, 54*16], [34*16, 54*16], + [35*16, 54*16], [33*16, 55*16], [34*16, 55*16], [35*16, 55*16], [31*16, 56*16], [32*16, 56*16], [33*16, 56*16], + [34*16, 56*16], [35*16, 56*16], [31*16, 57*16], [32*16, 57*16], [33*16, 57*16], [34*16, 57*16], [35*16, 57*16], + [30*16, 58*16], [31*16, 58*16], [32*16, 58*16], [33*16, 58*16], [34*16, 58*16], [35*16, 58*16], [27*16, 59*16], + [28*16, 59*16], [29*16, 59*16], [30*16, 59*16], [31*16, 59*16], [32*16, 59*16], [33*16, 59*16], [34*16, 59*16], + [26*16, 60*16], [27*16, 60*16], [28*16, 60*16], [29*16, 60*16], [30*16, 60*16], [31*16, 60*16], [32*16, 60*16], + [33*16, 60*16], [26*16, 61*16], [27*16, 61*16], [28*16, 61*16], [29*16, 61*16], [30*16, 61*16], [31*16, 61*16], + [26*16, 62*16], [27*16, 62*16], [28*16, 62*16], [29*16, 62*16], [30*16, 62*16], [31*16, 62*16], [26*16, 63*16], + [27*16, 63*16], [28*16, 63*16], [29*16, 63*16], [30*16, 63*16], [31*16, 63*16], [32*16, 63*16], [24*16, 64*16], + [25*16, 64*16], [26*16, 64*16], [27*16, 64*16], [28*16, 64*16], [29*16, 64*16], [24*16, 65*16], [25*16, 65*16], + [26*16, 65*16], [27*16, 65*16], [28*16, 65*16], [22*16, 66*16], [23*16, 66*16], [24*16, 66*16], [25*16, 66*16], + [26*16, 66*16], [27*16, 66*16], [28*16, 66*16], [22*16, 67*16], [23*16, 67*16], [24*16, 67*16], [25*16, 67*16], + [26*16, 67*16], [27*16, 67*16], [28*16, 67*16], [22*16, 68*16], [23*16, 68*16], [24*16, 68*16], [25*16, 68*16], + [26*16, 68*16], [20*16, 69*16], [21*16, 69*16], [22*16, 69*16], [23*16, 69*16], [24*16, 69*16], [25*16, 69*16], + [26*16, 69*16], [20*16, 70*16], [21*16, 70*16], [22*16, 70*16], [23*16, 70*16], [24*16, 70*16], [25*16, 70*16], + [20*16, 71*16], [21*16, 71*16], [22*16, 71*16], [23*16, 71*16], [24*16, 71*16], [25*16, 71*16], [20*16, 72*16], + [21*16, 72*16], [22*16, 72*16], [23*16, 72*16], [24*16, 72*16], [25*16, 72*16], [20*16, 73*16], [21*16, 73*16], + [22*16, 73*16], [23*16, 73*16], [21*16, 74*16], [21*16, 75*16], [14*16, 98*16], [14*16, 99*16], [14*16, 100*16], + [15*16, 100*16],[16*16, 100*16],[19*16, 100*16],[20*16, 100*16],[23*16, 100*16],[24*16, 100*16],[14*16, 101*16], + [15*16, 101*16],[16*16, 101*16],[17*16, 101*16],[18*16, 101*16],[19*16, 101*16],[20*16, 101*16],[21*16, 101*16], + [22*16, 101*16],[23*16, 101*16],[24*16, 101*16],[14*16, 102*16],[15*16, 102*16],[16*16, 102*16],[17*16, 102*16], + [18*16, 102*16],[19*16, 102*16],[20*16, 102*16],[21*16, 102*16],[22*16, 102*16],[23*16, 102*16],[24*16, 102*16], + [14*16, 103*16],[15*16, 103*16],[16*16, 103*16],[17*16, 103*16],[18*16, 103*16],[19*16, 103*16],[20*16, 103*16], + [21*16, 103*16],[22*16, 103*16],[23*16, 103*16],[24*16, 103*16],[14*16, 104*16],[15*16, 104*16],[16*16, 104*16], + [17*16, 104*16],[18*16, 104*16],[19*16, 104*16],[20*16, 104*16],[21*16, 104*16],[22*16, 104*16],[23*16, 104*16], + [24*16, 104*16],[25*16, 104*16],[14*16, 105*16],[15*16, 105*16],[16*16, 105*16],[17*16, 105*16],[18*16, 105*16], + [19*16, 105*16],[20*16, 105*16],[21*16, 105*16],[22*16, 105*16],[23*16, 105*16],[24*16, 105*16],[25*16, 105*16], + [9*16, 106*16],[10*16, 106*16],[11*16, 106*16],[12*16, 106*16],[13*16, 106*16],[14*16, 106*16],[15*16, 106*16], + [16*16, 106*16],[17*16, 106*16],[18*16, 106*16],[19*16, 106*16],[20*16, 106*16],[23*16, 106*16],[24*16, 106*16], + [25*16, 106*16], [7*16, 107*16], [8*16, 107*16], [9*16, 107*16],[10*16, 107*16],[11*16, 107*16],[12*16, 107*16], + [13*16, 107*16],[14*16, 107*16],[15*16, 107*16],[16*16, 107*16],[17*16, 107*16],[18*16, 107*16],[19*16, 107*16], + [20*16, 107*16],[23*16, 107*16],[24*16, 107*16],[25*16, 107*16], [9*16, 108*16],[10*16, 108*16],[11*16, 108*16], + [12*16, 108*16],[13*16, 108*16],[14*16, 108*16],[15*16, 108*16],[16*16, 108*16],[17*16, 108*16],[18*16, 108*16], + [19*16, 108*16],[20*16, 108*16],[21*16, 108*16],[22*16, 108*16],[23*16, 108*16],[24*16, 108*16],[25*16, 108*16], + [9*16, 109*16],[10*16, 109*16],[11*16, 109*16],[12*16, 109*16],[13*16, 109*16],[14*16, 109*16],[15*16, 109*16], + [16*16, 109*16],[17*16, 109*16],[18*16, 109*16],[19*16, 109*16],[20*16, 109*16],[21*16, 109*16],[22*16, 109*16], + [23*16, 109*16], [8*16, 110*16], [9*16, 110*16],[10*16, 110*16],[11*16, 110*16],[12*16, 110*16],[13*16, 110*16], + [14*16, 110*16],[15*16, 110*16],[16*16, 110*16],[17*16, 110*16],[18*16, 110*16],[19*16, 110*16], [8*16, 111*16], + [9*16, 111*16],[10*16, 111*16],[11*16, 111*16],[12*16, 111*16], [7*16, 112*16], [8*16, 112*16] +] diff --git a/main.py b/main.py index a1ea6f6..a5874c3 100644 --- a/main.py +++ b/main.py @@ -141,6 +141,12 @@ class Route119: spot_button = ttk.Button(root, text='6', command= lambda: self.goToFeebasSpot(5), state= DISABLED, width=4) spot_button.place(x=320*6/7+320, y=500, anchor="center") self.feebas_spot_buttons.append(spot_button) + + + self.is_fixed_game = IntVar() + self.is_fixed_game.set(0) + fixed_game_checkbox = ttk.Checkbutton(self.root, text='Fixed Game',variable=self.is_fixed_game, onvalue=1, offvalue=0) + fixed_game_checkbox.place(x=320/7+320, y=540, anchor="center") def goToFeebasSpot(self, spot_id): """ @@ -182,8 +188,8 @@ class Route119: Args: self: The class itself """ - # GIve the parameters to the FeebasCalculator and check if it could find a feebas. If not, then make a noise to let the user know about this. - self.feebas_calcs = FeebasCalculator(self.tid_entry.get(), self.lot_enrty.get(), self.drop1.get(), self.drop2.get(), self.is_emerald.get()) + # Give the parameters to the FeebasCalculator and check if it could find a feebas. If not, then make a noise to let the user know about this. + self.feebas_calcs = FeebasCalculator(self.tid_entry.get(), self.lot_enrty.get(), self.drop1.get(), self.drop2.get(), self.is_emerald.get(), self.is_fixed_game.get()) if(self.feebas_calcs.isFeebasFound() == False): self.root.bell()