Stetim94 Pokémon Program

I haven’t got a chance to run it yet because I need tkinter so I have to look into downloading that. How is the refactoring going?
Also, I stopped personal messaging because of my dad for now, so I won’t respond. :grimacing:

1 Like

do you have linux? installing tkinter is simple in ubuntu:

sudo apt-get install python3-tk
1 Like

I only have Mac OS, it’s unix based, but not the same thing I believe.

1 Like

no, i was looking at it:

not the same, i have no idea the pokemon game will run on mac :stuck_out_tongue:

1 Like

:slight_frown: I don’t know… I will try to look into it more.
Thanks for looking it up. :slight_smile:

1 Like

seems you can download it here:

it should select the right package right away

2 Likes

Alright, thanks so much, I’ll do that later. You’re way helpful.

1 Like

well i want something, so it makes sense to help? :stuck_out_tongue:

2 Likes

how to achieve this? I thought about it, but i can’t seem how :frowning:

here is an updated version of my code:

ionatan.txt (17.9 KB)

1 Like

Leave it the way it is

The class would be for having a place to validate the data and possibly adding things like string representation. You define what moves are as data, I have some preference for giving it a type. You could argue for either.

What’s more interesting is implementing something like

pokemon1.attack('bite', pokemon2)

And also moving out both the pokemon data and class, so that you can then just get a bunch of them somewhat like:

from pokemon import predefined_pokemon

Or if they are mutable which they probably are, then a function that returns new instances of the predefined ones

I would also not give them variable names like blastoise_moves - I’d just stick them in a list, seems too specific

1 Like

but the moves and there associated power, pp, accuracy and so on are an actually representation of data from a pokemon game, so then it makes more to have them as data then as class? I don’t need to validate them.

i was just experimenting with moving the pokemon class, this seems successful.

so you recommend something like:

thundershock = { "type": "electric", "power":    40 , "acc": 1 ,     "pp" :   30 }
slam = { "type": "normal"  , "power":    80 , "acc": 0.75 ,  "pp" :   20 }
pikachu_moves = [thunderschok, slam]
pikachu    =  Pokemon ("pikachu", 35,  55,  30,  90,  50, ["electric"],pikachu_moves)

sounds like an interesting idea :slight_smile:

Or is this not what you mean?

Sorry, i ask a lot of questions which are time consuming :stuck_out_tongue:

If it is too much, just say so

1 Like

No I mean that the only variable you should create is predefined_pokemon, like this:

predefined_pokemon = [
    Pokemon('Pikachu', 35,  55,  30,  90,  50,
            [Move('thundershock', 'electric', power=40, acc=1, pp=30),
             Move('slam', 'normal', power=80, acc=0.75, pp=20)]),
    Pokemon(...),
]

The text “Pikachu” is data, but you have a variable by that name
And the fact that a pokemon has power is something that code should describe, but you’ve stored that in data as a string

1 Like

here:

Move('thundershock', 'electric', power=40, acc=1, pp=30),
Move('slam', 'normal', power=80, acc=0.75, pp=20)

Where does Move come from? What is it? an class instance?

1 Like

That would be a class, a pokemon would have a list of moves

To create variables for each pokemon is to take a strange amount of interest in what that pokemon is called. Its name is just data, doesn’t matter to the logic of the program, or at least not to the class that represents them.

1 Like

i can’t see how the Move method should look then:

class Move:
   def __init__(self, move, type, power, acc, pp):
      self.move = move
      self.type = type
      self.power = power
      self.acc = acc
      self.pp = pp

Move('thundershock', 'electric', 40, 1, 30)

something like that?

sorry, i see what you are trying to do is good, but i just can pull it together in my head

1 Like

Class*, yeah. And right now it’s just a glorified dictionary, and perhaps you won’t do any more with it than that.

1 Like

Thank you :slight_smile:

I will see if i can implant this, and if so, how, don’t forget it to has to match with the rest of the game.

i actually wanted to implant more moves, but i didn’t have the time yet, so i will see if using classes will help me in this matter

2 Likes

Mostly I just want to be rid of all those very specific variables and to treat them all the same until there’s actually need to mention a specific one, if ever

Perhaps there is a group of starting-pokemon and “the rest”, perhaps then there should be two lists/dicts

3 Likes

yep, the problem is that i want to implant more moves, and then a pokemon can have a maximum of 4 moves (picked random from all the possible moves if the pokemon can learn this move) so then i need to make something is fixed. I haven’t done this, because i first wanted to make sure i could pull it off (i wasn’t sure)

I know, now i spend a lot of time re-implanting, i guess i am not that good programmer

well, at least this is a very inspiring project which is good for my programming skills :slight_smile: I never have inspiration to code something, now i do, so good opportunity :slight_smile:

2 Likes

implement* :<

Splitting it into files is the most significant readability improvement right now. It’s kind of like having a django app with the template, view, and model all in the same file. They each do different things that make sense on their own, it’s easier to understand one at a time

3 Likes