SwankyJank
New member
- Joined
- Jan 7, 2022
- Messages
- 4
- Programming Experience
- Beginner
hi guys im having a bit of trouble with this chunk of code that ive been working for the last 20 minutes.
my problem is that when i type "a" for my attack strats, it want me to press enter again afterwards but with defence strats its fine, also if i select either attack or defence strats it gives me the opposite. i also have a version of this code where attack and defence have their own methods and that gave me the same results. just need some help with this one thanks in advance
my problem is that when i type "a" for my attack strats, it want me to press enter again afterwards but with defence strats its fine, also if i select either attack or defence strats it gives me the opposite. i also have a version of this code where attack and defence have their own methods and that gave me the same results. just need some help with this one thanks in advance
C#:
public static void selscreen()
{
Console.Clear();
Console.WriteLine("Defending or Attacking?");
Console.WriteLine("Type d or a and press Enter.");
if (Console.ReadLine() != "a")
{
Console.Clear();
string[] atstrats = new string[] { "as1", "as2", "as3" };
Random rndat = new Random();
int indexat = rndat.Next(atstrats.Length);
Console.WriteLine($"The Strat: {atstrats[indexat]}");
Console.WriteLine("Press Enter to pick side");
Console.ReadLine();
selscreen();
}
else _= Console.ReadLine() != "d";
{
Console.Clear();
string[] defstrats = new string[] { "ds1", "ds2", "ds3" };
Random rnddef = new Random();
int indexdef = rnddef.Next(defstrats.Length);
Console.WriteLine($"The Strat: {defstrats[indexdef]}");
Console.WriteLine("Press Enter to pick side");
Console.ReadLine();
selscreen();
}
Console.ReadLine();
}
Last edited: