00:0.24 Let's talk about another cool and powerful.
00:2.43 Refactoring So what we've done over here in this 'actors.py' f is we
00:7.42 put every class that's going to be participating in our game.
00:10.74 So we've got the creature, we've got the wizard,
00:12.75 we've got the small animal. One of the things I prefer to do in general
00:16.37 Not always, but in general is to have a class dedicated to its own
00:21.05 file. So if I want to go mess with the wizard,
00:22.95 I know right where to go and how to make changes to it and so on
00:26.18 But what I'm going to do is move this wizard over to its own file
00:30.78 Now I could go over here and right click new python file,
00:37.74 call it something like lowercase wizard and then copy this over and that would work except
00:42.86 remember other parts of our program depend upon this.
00:46.0 So here we say from actors import wizard.
00:49.64 If I were to move that code manually over to another file,
00:52.91 this is going to break. It's going to say there's no wizard and actors because
00:56.14 it's not, it's somewhere else wherever I put it,
00:58.74 we're going to not just want to move the file or move the code into a
01:2.37 file. We also need to fix up things like these imports or if I had
01:6.52 done something like import actors and then actors dot wizard and work with it in this
01:12.16 way. Right. We need to make sure that all that stuff is consistent.
01:15.74 There's this really cool re factoring called move and let's do the main animals first and
01:20.53 then we'll deal with creature in a moment.
01:22.74 First of all, let's go and come down here and just hit move and I'm
01:26.34 gonna call this wizard and down here we now have the wizard class,
01:32.61 so we're importing the creature that we can derive from it.
01:36.34 And besides a little white space at the end,
01:38.69 this looks great importantly over here,
01:42.12 notice now we have from wizard import wizard and it's gone from up there,
01:46.05 so it's not just moving the code is actually keeping everything in sync,
01:49.37 which is fantastic. Let me do the others as well.
01:52.24 Do the dragon and the small animal.
02:3.64 So in our game core, all that stuff has been fixed.
02:6.74 The other thing I would like to do is maybe just call this.
02:9.06 Well now it's not actors, it's just the creature.
02:11.03 So I'm gonna just rename this file two creature base when I do that,
02:18.82 notice it renamed and refactors that as well.
02:21.82 That's not exactly a move, but it's pretty close,
02:25.34 make sure everything's running, we can attack something.
02:28.74 We have been defeated. Let's try again.
02:34.74 We have handily defeated. A frog I believe.
02:36.92 Noah toad. Alright, we're out so it looks like it's still working now.
02:41.2 This is looking cluttered to me.
02:42.88 I don't know how you all feel about it,
02:44.06 but let's go back and sort of give this some naming here.
02:47.13 Like I'm going to create an actor's folder and I want to put all of these
02:51.25 in there. So we are last move action.
02:54.07 If we just take all of those and drop them in there,
02:57.74 notice this is not a move button,
02:59.54 but this is a refactor button.
03:1.51 Search for references. Boom. Go back to our game core from actors dot creature
03:7.35 based actors dot small animal actors dot dragon.
03:9.84 So now our code is nice and organized.
03:11.98 Here's the program, here's the game code,
03:14.02 here's all the animals and there's not a folder and all of those operations,
03:18.29 renaming a file, extracting code to another file,
03:21.64 grabbing a bunch of files and throwing them into another folder.
03:24.59 All of that remained consistent because they're all under this general manner of a move re
03:30.25 factory in PyCharm. Love it.
