i have a few questions for this code...
18 hours ago, fpo said:I won't read your source code but let's say you manually shuffle your deck.
Come on man, you could have taken a peek at least.
On 6/2/2023 at 11:27 PM, SirFriendly2525 said:I have the pokemon type effectiveness already worked out but that also takes
a lot of code. I'm not sure if I need to try and minimize the amount of code for all of that or if its fine.
1) how can i add a third and fourth person, to allow for team battles?
You are writing Java code,
you should learn more about object oriented programming.
public class PokeD { // variable declarartion static int again = 2; static int loop = 2; static int counter = 1; static int hitRoll = 0; // player types static String playerType1 = "normal"; static String playerType2 = "normal"; static String playerMoveType = "normal"; // player 1 stats static int playerOneHP = 0; static String playerOneStatus = "normal"; static int playerOneSPD = 0; // player 2 stats static int playerTwoHP = 0; static String playerTwoStatus = "normal"; static int playerTwoSPD = 0; /** player 3 stats static int playerThreeHP = 0; static String playerThreeStatus = "normal"; static int playerThreeSPD = 0;
Player should be a class...
Then you can instantiate as many players as you'd like, a lot faster.
burnedStatus and poisnedStatus should inherit or extend something like statusEffect.
Speaking of these two, you are going about it the wrong way...
package poked; import static poked.PokeD.playerOneHP; import static poked.PokeD.playerTwoHP; import java.lang.Math; public class burnedStatus { static float burnedDMG = (float) 0.0; static void burnedP1() { System.out.println("player 2 is burned"); burnedDMG = playerTwoHP / 10; playerTwoHP = playerTwoHP - Math.round(burnedDMG); System.out.println("Player 2 HP is: "); } static void burnedP2() { System.out.println("player 1 is burned"); burnedDMG = playerOneHP / 10; playerOneHP = playerOneHP - Math.round(burnedDMG); System.out.println("Player 1 HP is: "); } }
Status effects shouldn't have players... players should have status effects.
Your logic, what goes where is wonky IMO .
What the heck is this? (never mind the comments, though those are bad as well)
public class turnOne { static int turnLoop1 = 2; static int crit = 1; static int finalDMG = 0; static void playerOneTurn() { fireTypeMoves Fire = new fireTypeMoves(); // Ln107 waterTypeMoves Water = new waterTypeMoves(); // Ln122 grassTypeMoves Grass = new grassTypeMoves(); // Ln137 electricTypeMoves Electric = new electricTypeMoves(); // Ln152 iceTypeMoves Ice = new iceTypeMoves(); // Ln167 fightingTypeMoves Fighting = new fightingTypeMoves(); // Ln182 poisonTypeMoves Poison = new poisonTypeMoves(); // Ln197 groundTypeMoves Ground = new groundTypeMoves(); // Ln212 flyingTypeMoves Flying = new flyingTypeMoves(); // Ln227 psychicTypeMoves Psychic = new psychicTypeMoves(); //Ln242 bugTypeMoves Bug = new bugTypeMoves(); // Ln257 rockTypeMoves Rock = new rockTypeMoves(); // Ln272 ghostTypeMoves Ghost = new ghostTypeMoves(); // Ln287 dragonTypeMoves Dragon = new dragonTypeMoves(); // Ln302 darkTypeMoves Dark = new darkTypeMoves(); // Ln317 steelTypeMoves Steel = new steelTypeMoves(); //Ln332 fairyTypeMoves Fairy = new fairyTypeMoves(); // Ln347 DmgCalculator DmgCal = new DmgCalculator(); // Ln362
public class turnTwo { static int turnLoop2 = 2; static int crit = 1; static int finalDMG = 0; static void playerTwoTurn() { fireTypeMoves Fire = new fireTypeMoves(); // Ln107 waterTypeMoves Water = new waterTypeMoves(); // Ln122 grassTypeMoves Grass = new grassTypeMoves(); // Ln137 electricTypeMoves Electric = new electricTypeMoves(); // Ln152 iceTypeMoves Ice = new iceTypeMoves(); // Ln167 fightingTypeMoves Fighting = new fightingTypeMoves(); // Ln182 poisonTypeMoves Poison = new poisonTypeMoves(); // Ln197 groundTypeMoves Ground = new groundTypeMoves(); // Ln212 flyingTypeMoves Flying = new flyingTypeMoves(); // Ln227 psychicTypeMoves Psychic = new psychicTypeMoves(); //Ln242 bugTypeMoves Bug = new bugTypeMoves(); // Ln257 rockTypeMoves Rock = new rockTypeMoves(); // Ln272 ghostTypeMoves Ghost = new ghostTypeMoves(); // Ln287 dragonTypeMoves Dragon = new dragonTypeMoves(); // Ln302 darkTypeMoves Dark = new darkTypeMoves(); // Ln317 steelTypeMoves Steel = new steelTypeMoves(); //Ln332 fairyTypeMoves Fairy = new fairyTypeMoves(); // Ln347 DmgCalculator DmgCal = new DmgCalculator(); // Ln362
That isn't just repeated code,
all these "moves" should be inside a super class of some sort.
Didn't see a proper constructor once, everything is static, all methods are static void without any arguments, excessive use of switch statements, Enums are nowhere to be seen, System.out.println...
I am gonna stop analyzing your code here.
On 6/2/2023 at 11:27 PM, SirFriendly2525 said:So, I have been working on this program for about a year now.
In a year you should have had a lot better understanding of how OOP works.
My advice would be to scratch this project,
complete a course, then look up similar projects to yours, then start writing code again.
You can do a lot better job after that, about 3-6 months I'd say.
PS I know, I sound like a d*ck... maybe I am one, but my advice is sincere.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now