+ 1
Can anyone help me?
I'm Trying to make this rpg work but can't really find the problem. https://code.sololearn.com/c9UAD6L1S3G8/?ref=app
4 Réponses
+ 10
I'll point out *some* problems (there are probably more) that I see so that you can improve your code:
Your class names are in lowercase. It's a convention in many programming languages to name classes using CamelCase (e.g. `Char`, `Player`, ...).
After fixing that, line 122 should be `player = Player('player', 'normal', 20, 20, 3, 3, 1, 20, 20, 0 , 2)`.
In your Player class, you're using "player" to reference your Player objects, but you should really be using "self" (i.e. in function `attackph`, `player.status` should be `self.status`, and so on).
Also in your Player class, you're using "enemy" to reference an Enemy object, but you aren't receiving it as a parameter in your functions (i.e. `attackph(self)` should be `attackph(self, enemy)`, and so on).
Lines 39 and 40 introduce two different bugs (these bugs also appear on the Enemy class).
Line 39 should be `dealt = player.atk - enemy.d` so that the player's attack is decreased by the enemy's defense (not the opposite).
Line 40 introduces a bug which makes the player heal the enemy if `dealt` is negative (i.e. the enemy's defense was greater than the player's attack). You should test `if dealt > 0` before landing the attack, in order to fix that bug.
On lines 72 and 74 you mistyped your attributes `de` and `dentlu` as `ed` and `edntlu`.
I suggest you rename your attributes to some more significant names. I cannot easily tell what they are meant to be doing in the way they are currently named...
I hope that I covered enough bugs and that this ends being helpful to you in some way. My last word of advice is: don't write big programs before you are sure that small parts of it are working correctly by themselves, or you'll end up with a hard-to-debug program and a huge headache.
+ 1
I use a offline IDLE called Pydroid, Anyways thanks.
0
In Sololearn these kind of codes sadly don't work, since you have to provide all the input in advance.
One big drawback of this app
0
Thanks