public static void Kezdes() { Console.Write("Kerem adja meg a nevet a Harcosnak: "); string nev = Console.ReadLine(); int valasz; Console.WriteLine("Udvozoljuk: " + nev + "Valasz karakter osztalyt: \n\t (1)Haros: alapEletero = 15, alapSebzes = 3 \n\t (2)Ijasz: alapEletero = 12, alapSebzes = 4 \n\t (3)Magus: alapEletero = 8, alapSebzes = 5"); bool isNumber = Int32.TryParse(Console.ReadLine(), out valasz); while (!isNumber || valasz < 1 || valasz > 3) { Console.Clear(); Console.WriteLine("Udvozoljuk: " + nev + "Valasz karakter osztalyt: \n\t (1)Haros: alapEletero = 15, alapSebzes = 3 \n\t (2)Ijasz: alapEletero = 12, alapSebzes = 4 \n\t (3)Magus: alapEletero = 8, alapSebzes = 5"); if (!isNumber) { Console.WriteLine("Ez nem szam!"); } else if (valasz < 1 || valasz > 3) { Console.WriteLine("Ilyen szamhoz nem tartozik karakter osztaly! "); } isNumber = Int32.TryParse(Console.ReadLine(), out valasz); } jatekos = new Harcos(nev, valasz); }
public void Megkuzd(Harcos masikHarcos) { if (this.nev.Equals(masikHarcos.nev)) { Console.WriteLine("Hiba, a két harcos megegyezik"); return; } else if (this.eletero == 0 || masikHarcos.eletero == 0) { Console.WriteLine("Az egyik harcos életereje 0, {0}: {1}, {2}: {3}", this.Nev, this.Eletero, masikHarcos.Nev, masikHarcos.Eletero); return; } else { masikHarcos.Eletero -= this.Sebzes(); if (masikHarcos.eletero > 0) { this.Eletero -= masikHarcos.Sebzes(); masikHarcos.Tapasztalat += 5; } else { this.Tapasztalat += 10; } if (this.eletero > 0) { this.Tapasztalat += 5; } else { masikHarcos.Tapasztalat += 10; } } }
public static void Start() { string name; int chosenChamp; Console.WriteLine("\t\t\t\t\t\t Add your username!"); name = Console.ReadLine(); Console.Clear(); Console.WriteLine("\t\t\t\t\t\t Welcome " + name + "\n\n\t\t\t\t\t\t Choose your Champ! \n\n\t\t\t\t(1)Warrior: \t Health: 15 \t Damage: 3 \n\t\t\t\t(2)Archer: \t Health: 12 \t Damage: 4 \n\t\t\t\t(3)Mage: \t Health: 8 \t Damage: 5"); bool isNumber = Int32.TryParse(Console.ReadLine(), out chosenChamp); while (!isNumber || chosenChamp < 1 || chosenChamp > 3) { Console.Clear(); Console.WriteLine("\t\t\t\t\t\t Welcome " + name + "\n\n\t\t\t\t\t\t Choose your Champ! \n\n\t\t\t\t(1)Warrior: \t Health: 15 \t Damage: 3 \n\t\t\t\t(2)Archer: \t Health: 12 \t Damage: 4 \n\t\t\t\t(3)Mage: \t Health: 8 \t Damage: 5"); if (!isNumber) { Console.WriteLine("\n\t\t\t\t\t\tIs not a number! "); } else if (chosenChamp < 1 || chosenChamp > 3) { Console.WriteLine("\n\t\t\t\t\tHave no champion with this number! "); } isNumber = Int32.TryParse(Console.ReadLine(), out chosenChamp); } player = new Harcos(name, chosenChamp); }
static void Main(string[] args) { Start(); Console.Clear(); bot = new Harcos("Dunny", rnd.Next(1, 4)); Scan(); Fight(); }
static void Main(string[] args) { List <Harcos> harcosLista = new List <Harcos>(); Harcos kihivo1 = new Harcos("Feri", 2); Harcos kihivo2 = new Harcos("Peti", 3); Harcos kihivo3 = new Harcos("Juli", 1); harcosLista.Add(kihivo1); harcosLista.Add(kihivo2); harcosLista.Add(kihivo3); //foreach (Harcos harcos in harcosLista) //{ // Console.WriteLine(harcos); //} Console.Write("Adja meg a harcosa nevet: "); string jatekosHarcosNev = Console.ReadLine(); Harcos jatekosHarcos = new Harcos(jatekosHarcosNev, 1); harcosLista.Add(jatekosHarcos); foreach (Harcos harcos in harcosLista) { string nev = harcos.Nev; int index = harcosLista.FindIndex(a => a.Nev == nev); Console.Write("{0}. ", index + 1); Console.WriteLine(harcos); } string mitSzeretne; do { Console.WriteLine("Mit szeretne? \n a) Megkuzdeni egy harcossal \n b) Gyogyulni \n c) Kilepni"); mitSzeretne = Console.ReadLine(); } while (mitSzeretne != "a" && mitSzeretne != "b" && mitSzeretne != "c"); if (mitSzeretne.Equals("a")) { string input; int harcosSorszam = -1; bool szamE; do { Console.WriteLine("Adja meg a harcos sorszamat: "); input = Console.ReadLine(); szamE = !int.TryParse(input, out harcosSorszam); } while (szamE && harcosSorszam < harcosLista.Count); Console.WriteLine("megadott {0}", harcosSorszam); } Console.ReadKey(); }
public static void Jatek() { Console.WriteLine("Adja meg a harcos nevet:"); string harnev = Console.ReadLine(); Console.WriteLine("Adja meg a harcos státuszát(1,2,3):"); int statusz = int.Parse(Console.ReadLine()); Harcos felhasznalo = new Harcos(harnev, statusz); Console.WriteLine("Az ön harcosainak adatai: " + felhasznalo); for (int i = 0; i < lista.Count; i++) { Console.WriteLine((i + 1) + "." + lista[i]); } Console.WriteLine("Mit szeretne tenni?"); Console.WriteLine("a.) Megküzdeni egy harcossal"); Console.WriteLine("b.) Gyógyulni"); Console.WriteLine("c.) Kilépni"); string dontes = ""; while (!dontes.Equals("c")) { dontes = Console.ReadLine(); if (dontes.Equals("a")) { Console.WriteLine("Kivel szeretne harcolni?"); int valasztott = int.Parse(Console.ReadLine()); felhasznalo.megKuzd(lista[valasztott - 1]); if (felhasznalo.Eletero <= 0) { Console.WriteLine("Meghaltál"); dontes = "c"; } else { Console.WriteLine("Győztél"); } } else if (dontes.Equals("b")) { felhasznalo.Gyogyul(); } else if (dontes.Equals("c")) { Environment.Exit(0); } Console.WriteLine("Az ön harcosainak adatai: " + felhasznalo); Console.WriteLine("Mit szeretne tenni?"); Console.WriteLine("a.) Megküzdeni egy harcossal"); Console.WriteLine("b.) Gyógyulni"); Console.WriteLine("c.) Kilépni"); } }
public static void Beolvas() { List <Harcos> lista = new List <Harcos>(); StreamReader sr = new StreamReader("harcosok.csv"); string sor = sr.ReadLine(); string[] tsor = sor.Split(';'); Harcos adatok = new Harcos(tsor[0], Convert.ToInt32(tsor[1])); lista.Add(adatok); sr.Close(); }
public static void ellensegFelvesz() { StreamReader sr = new StreamReader("harcosok.csv", Encoding.UTF8); string sor = ""; while (!sr.EndOfStream) { sor = sr.ReadLine(); string[] elemek = sor.Split(';'); ellenseg = new Harcos(elemek[0], Convert.ToInt32(elemek[1])); ellenseg.Nev = elemek[0]; ellenseg.StatuszSablon = Convert.ToInt32(elemek[1]); ellensegek.Add(ellenseg); } sr.Close(); }
public static void Scan() { Console.Clear(); Console.WriteLine(player); Console.WriteLine("\n"); Console.WriteLine(bot); if (player.Role == bot.Role) { Console.Clear(); message = "Error!"; Console.WriteLine("\t\t\t\t\t\t " + message); bot = new Harcos("Dunny", rnd.Next(1, 4)); Console.WriteLine("Press a key to find a new enenmy "); Console.ReadKey(); Scan(); } else if (player.Health == 0) { Console.Clear(); Console.WriteLine(player); message = "Your health is too low to fight..."; Console.WriteLine(message); } }
static void Main(string[] args) { //valamiért az iskolában egy másik diák nevével pusholta fel nekem //ezért inkább egy új repositoryt csináltam List <Harcos> harcosok = new List <Harcos>(); StreamReader r = new StreamReader("harcosok 1.csv"); Console.WriteLine("adja meg a harcos nevét: "); string nev = Console.ReadLine(); Console.WriteLine("adja meg a státusz sablont(1/2/3)"); int statusz = Convert.ToInt32(Console.ReadLine()); var karakter = new Harcos(nev, statusz); harcosok.Add(karakter); try { while (!r.EndOfStream) { string[] s = r.ReadLine().Split(';'); harcosok.Add(new Harcos(s[0], Convert.ToInt32(s[1]))); } } catch (Exception) { throw; } r.Close(); char valasz; int kor = 0; int hanyadik; List <int> sorszamok = new List <int>(); for (int i = 1; i < harcosok.Count + 1; i++) { sorszamok.Add(i); } do { kor++; Console.WriteLine("\n{0}.Kör\n", kor); for (int i = 0; i < harcosok.Count; i++) { Console.WriteLine("{0}. {1}", i + 1, harcosok[i]); } Console.WriteLine("\nmit szeretne csinálni? \na.) Megküzdeni egy harcossal\nb.) Gyógyulni\nc.) Kilépni"); Console.Write("menüpont: "); valasz = Convert.ToChar(Console.ReadLine()); while (valasz != 'a' && valasz != 'b' && valasz != 'c') { Console.WriteLine("\nmit szeretne csinálni? \na.) Megküzdeni egy harcossal\nb.) Gyógyulni\nc.) Kilépni"); Console.Write("menüpont: "); valasz = Convert.ToChar(Console.ReadLine()); } if (valasz == 'a') { Console.WriteLine("\nHányadik harcossal szeretne megküzdeni a listából?"); for (int i = 0; i < harcosok.Count; i++) { Console.Write("{0} ", i + 1); } Console.WriteLine(); hanyadik = Convert.ToInt32(Console.ReadLine()); while (!sorszamok.Contains(hanyadik)) { Console.WriteLine("\nHibás sorszám!\nHányadik harcossal szeretne megküzdeni a listából?"); hanyadik = Convert.ToInt32(Console.ReadLine()); } harcosok[0].Megkuzd(harcosok[hanyadik - 1]); } if (valasz == 'b') { Console.WriteLine("\ngyógyítottál!"); harcosok[0].Gyogyul(); } if (valasz == 'c') { Console.WriteLine("\nViszlát!"); } if (kor % 3 == 0) { Random rnd = new Random(); harcosok[rnd.Next(1, sorszamok.Count + 1)].Megkuzd(harcosok[0]); for (int i = 0; i < harcosok.Count; i++) { harcosok[i].Gyogyul(); } } } while (valasz != 'c'); Console.ReadLine(); }