fudgenuggets1 / hax_free_pokemon

hax free pokemon
0 stars 0 forks source link

Image names are lower-case, but in code written as upper-case #1

Open graipher opened 7 years ago

graipher commented 7 years ago

Since the actual filenames are of the format images/pokemon_name_front.png, but in the code the pokemon are defined with the format images/Pokemon_name_front.png (note upper-case first letter), this does not even run. I fixed this by using this in pokemon.py, in the class Pokemon in lines 224, 225:

        self.front_image = pygame.image.load(front_image.lower())
        self.back_image = pygame.image.load(back_image.lower())
graipher commented 7 years ago

Even though this is an OS issue (or in my opinion, the Windows OS masking this bug), I still consider it a bug, because there is no README.md specifying that this code should only run on Windows.

Especially since fixing it for all OS's is as trivial as using the actual file names...

Peilonrayz commented 7 years ago

@graipher It's OS independent, it's file system dependent. But, yes this should be fixed. Which just requires setting global constants, preferably set in a settings file.

graipher commented 7 years ago

@Peilonrayz True.

But all UNIX file systems in use today AFAIK are case-sensitive and all Windows file systems (NTFS and whatever Windows 10 uses) are not. But that is semantics.

I would say it is easier to just have all filenames and all strings with filenames use only lowercase, then it will never become an issue (on any file system), than a file-system dependent config, that sometimes uses "Pokemon_name.png" and sometimes "pokemon_name.png", when the file is named pokemeon_name.png anyways.

Then it just becomes a matter of finding a nice regexp for sed or the like to change all those strings to lowercase...

BTW, the same could be true for Functions.py, but as far as I can see, you correctly used import Functions everywhere (since Python is case-sensitive).

graipher commented 7 years ago

It is actually not even all Pokemon, where this is a problem, only these 14:

$ grep -n 'image="images/[A-Z]' pokemon.py        
1880:        ptype1=Normal, name="Blissey", front_image="images/Blissey_front.png", back_image="images/Blissey_back.png")
1940:        ptype1=Water, name="Seadra", front_image="images/Seadra_front.png", back_image="images/Seadra_back.png")
1952:        ptype1=Water, name="Kingdra", front_image="images/Kingdra_front.png", back_image="images/Kingdra_back.png", ptype2=Dragon)
1976:        ptype1=Water, name="Seaking", front_image="images/Seaking_front.png", back_image="images/Seaking_back.png")
2224:        ptype1=Electric, name="Jolteon", front_image="images/Jolteon_front.png", back_image="images/Jolteon_back.png")
2236:        ptype1=Fire, name="Flareon", front_image="images/Flareon_front.png", back_image="images/Flareon_back.png")
2248:        ptype1=Psychic, name="Espeon", front_image="images/Espeon_front.png", back_image="images/Espeon_back.png")
2260:        ptype1=Dark, name="Umbreon", front_image="images/Umbreon_front.png", back_image="images/Umbreon_back.png")
2272:        ptype1=Grass, name="Leafeon", front_image="images/Leafeon_front.png", back_image="images/Leafeon_back.png")
2284:        ptype1=Ice, name="Glaceon", front_image="images/Glaceon_front.png", back_image="images/Glaceon_back.png")
2357:        ptype1=Rock, name="Kabuto", front_image="images/Kabuto_front.png", back_image="images/Kabuto_back.png", ptype2=Water)
2369:        ptype1=Rock, name="Kabutops", front_image="images/Kabutops_front.png", back_image="images/Kabutops_back.png", ptype2=Water)
2445:        ptype1=Electric, name="Zapdos", front_image="images/Zapdos_front.png", back_image="images/Zapdos_back.png", ptype2=Flying)
2457:        ptype1=Fire, name="Moltres", front_image="images/Moltres_front.png", back_image="images/Moltres_back.png", ptype2=Flying)