generated from skills/copilot-codespaces-vscode
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcodechat_after.cs
79 lines (73 loc) · 2.46 KB
/
codechat_after.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
using System;
class Program
{
static void Main()
{
int health = 100;
int score = 0;
Console.WriteLine("Welcome to the Adventure Game!");
Console.WriteLine("You are in a dark forest.");
while (health > 0)
{
Console.WriteLine("\nOptions:");
Console.WriteLine("1. Go deeper into the forest.");
Console.WriteLine("2. Rest by the campfire.");
Console.WriteLine("3. Quit the game.");
int choice;
Console.Write("Enter your choice: ");
if (int.TryParse(Console.ReadLine(), out choice))
{
if (choice == 1)
{
Console.WriteLine("You go farther into the forest and discover a treasure chest!");
score += 10;
}
else if (choice == 2)
{
Console.WriteLine("You rest by the campfire and regain 20 health.");
health += 20;
}
else if (choice == 3)
{
Console.WriteLine($"Thanks for playing! Your score: {score}");
return;
}
else
{
Console.WriteLine("Invalid choice. Try again.");
}
health -= 10;
if (health <= 0)
{
Console.WriteLine($"Game over. Your score: {score}");
}
}
else
{
Console.WriteLine("Invalid input. Please enter a valid number.");
}
break;
case 2:
Console.WriteLine("You rest by the campfire and regain 20 health.");
health += 20;
break;
case 3:
Console.WriteLine($"Thanks for playing! Your score: {score}");
return;
default:
Console.WriteLine("Invalid choice. Try again.");
break;
}
health -= 10;
if (health <= 0)
{
Console.WriteLine($"Game over. Your score: {score}");
}
}
else
{
Console.WriteLine("Invalid input. Please enter a valid number.");
}
}
}
}