I'm new with both random and arrays and I'm trying to get them to work together.
I'm trying to write a program that can take lists of arrays, turn those arrays into die and 'roll' them, and then convert them back to arrays so I can edit the lists. I'm pretty sure the best approach to do this will be through arrays, as I will be editing the dice pools throughout the program. To make editing these dicepools easier, I have them stored in a separate file so I can track the changes and my internal code isn't constantly changing.
System.out.print("Welcome to the world of Pokemon, Trainer! "
+ " What is your name? ");
//Intro. Save playerName variable and create a doc for player's Pkmn
PlayerName = keyboard.nextLine();
System.out.println("Here's your first Pokemon. It's a little weak"
+ " but you'll just have to catch stronger ones."
+ " GO CATCH 'EM ALL!");
try (PrintWriter writer = new PrintWriter("MyPkmn.txt")) {
writer.println("int[][] MyPkmn =");
writer.println("{1, 1, 2, 2, 2, 3}");
writer.println("};");
The separate files that I will be editing so far look like this: MyPkmn: (generated from code above)
int[][] MyPkmn ={1, 1, 2, 2, 2, 3}};
And the array that I'm really struggling with, WildPkmn: (will be pre-existing)
int[][] WeakPkmn = {
{0, 0, 1, 1, 2, 2},
{0, 0, 1, 1, 2, 2},
{0, 0, 1, 1, 2, 2},
{0, 0, 1, 1, 2, 2},
{0, 0, 1, 1, 2, 2},
{0, 0, 1, 1, 2, 2},
{0, 0, 1, 1, 2, 2}
};
int[][] StrgPkmn = {
{0, 2, 2, 3, 3, 4},
{0, 2, 2, 4, 3, 4},
{0, 2, 2, 4, 3, 4},
{0, 2, 2, 4, 3, 4}
};
int[][] UltmPkmn = {
{0, 18, 16, 12, 10, 8},
{0, 18, 16, 12, 10, 8}
};
I'm not sure if I should be using three 2x2 arrays or a 3x3 array.
I want use random to pull a single die out of the list of WildPkmn array; (if I use a 3x3x(3), that is how I can have the code identify what kind and tell the player the 'type' of Pokemon they have encountered),then convert that array into a die and roll it.
Also I will roll each of the die from MyPkmn arrays and I will compare totals.
Depending on a win or loss, I want to be able to take the WildPkmn die, delete that specific row from the WildPkmn file, and add that row to the MyPkmn file.
I can attach my pseudocode if I'm still confusing.
Aucun commentaire:
Enregistrer un commentaire