// DragonCombatSimulator static void DragonCombatSimalator(int round, int swordPower, int magicPower, int healthPower, int healPower) { Player player = new Player(80+healthPower*20, swordPower, magicPower, healthPower, healPower); Player dragon = new Player(180+round*15, 1,1,1,1); string info = ""; string Dragoninfo = ""; int numFirstAidKit = 2+healPower; while ( player.health > 0 && dragon.health > 0) { Console.Clear(); DrawScene(player.health, dragon.health, round); Console.WriteLine(info); Console.WriteLine(Dragoninfo); Console.WriteLine(); Console.WriteLine("Enter 1 if you want to hit dragon with a SWORD"); Console.WriteLine("Enter 2 if you want to attack dragon with a MAGIC FIREBALL"); if (numFirstAidKit > 0) Console.WriteLine("Enter 3 if you want to heal yourself. You have "+numFirstAidKit+" First Aid Kit(s) left"); else Console.WriteLine("You have no Fisrt Aid Kits left"); //Console.WriteLine("Esc to exit the game"); Console.WriteLine("Choose what your wanna do next:"); string s = ""; bool rightkey = false; while (!rightkey) { s = Console.ReadLine(); rightkey = (s == "1") || (s == "2") || (s == "3"); if (s == "3" && numFirstAidKit == 0) { rightkey = false; } //rightkey = !rightkey; } // if Sword if (s == "1") { int damage = HitWithSword(player); if (damage > 0) { info = "You hit the Dragon with a sword, Dragon lose " + damage + "HP"; dragon.health -= damage; } else { info = "You've tried to hit the Dragon with a SWORD but Dragon block your hit"; } } else if (s == "2") // if Magic { int damage = HitWithMagic(player); info = "You've attacked the Dragon with a FIREBALL, Dragon lose " + damage + "HP"; dragon.health -= damage; } else if (s == "3") // if heal { info = Heal(player, dragon); numFirstAidKit--; } //DRAGON's attack time!! if (dragon.health > 0) { int dragondamage = DragonAttack(round); if (dragondamage > 0) { string[] bodyPart = new string[] { "head", "right arm", "left arm", "right leg", "left leg", "ass" }; Random rnd = new Random(); Dragoninfo = "Dragon bite your " + bodyPart[rnd.Next(1, bodyPart.Length)] + ". It hurts and takes " + dragondamage + "HP"; player.health -= dragondamage; } else { Dragoninfo = "Dragon roared and missed, but you pee in your pants. It depress you, minus 1HP"; player.health -= 1; } } } // End of battle - show picture, ask if user want to continue Console.Clear(); DrawScene(player.health, dragon.health, round); if (player.health <= 0) { Console.WriteLine("YOU LOSE. Do you want to try one more time? Y/N"); if (Console.ReadLine().ToLower() == "y" || Console.ReadLine().ToLower() == "yes") DragonCombatSimalator(round, swordPower, magicPower, healthPower, healPower); } else { Console.WriteLine("YOU WIN! Want to try figth more powerful Dragon? Y/N"); string sti = Console.ReadLine(); if (sti == "y" || sti == "yes") { Console.WriteLine("What you want to improve for the next round?"); Console.WriteLine("Enter 1 - for SWORD, 2 for MAGIC, 3 for AID Kit, 4 for HP"); string st = Console.ReadLine(); if (st == "1") swordPower++; else if (st == "2") magicPower++; else if (st == "3") healPower++; else if (st == "4") healthPower++; DragonCombatSimalator(round + 1, swordPower, magicPower, healthPower, healPower); } else { KonstantinEntities db = new KonstantinEntities(); HighScores hs = new HighScores(); hs.Date = DateTime.Now; hs.Score = (player.health) + round * 100; hs.Game = "Dragon Slayer 1"; Console.WriteLine("Enter your name:"); string name = Console.ReadLine(); if (name == "") name = "Anonymous"; hs.Name = name; db.HighScores.Add(hs); db.SaveChanges(); var list = db.HighScores.Where(x => x.Game == "Dragon Slayer 1"); Console.WriteLine("********** High Scores *************"); foreach (var item in list) { Console.WriteLine(item.Name + " - " + item.Score); } Console.ReadLine(); } } }
// Use Magic FIREBALL!! static int HitWithMagic(Player pl) { Random rnd = new Random(); return rnd.Next(10+pl.magicPower,16+pl.magicPower*3); }
//some helpers for DCS // Calculate damage from sword hitting static int HitWithSword(Player pl) { int damage = 0; Random rnd = new Random(); if (rnd.Next(1, 101) > 30) { damage = rnd.Next(20+pl.swordPower, 36+pl.swordPower*5); } return damage; }
// Heal yourself....or dragon static string Heal(Player pl, Player dr) { string info = ""; Random rnd = new Random(); int value = rnd.Next(10, 20+pl.healPower*5); if (rnd.Next(1, 101) < 20) { info = "DAMN! You have to be more accurate, you've just cured the Dragon for "+value/2 + "HP"; dr.health += value/2; if (dr.health > 200) dr.health = 200; } else { info = "Excellent! You've got " + value + "HP more"; pl.health += value; if (pl.health > 100) pl.health = 100; } return info; }