-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
105 lines (94 loc) · 3.86 KB
/
Program.cs
File metadata and controls
105 lines (94 loc) · 3.86 KB
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace FightArena
{
class Program
{
static void Main(string[] args)
{
// Adding all the contestants to the competition.
List<SuperHero> contestants = new List<SuperHero>
{
new SuperHero("Kong-Fu Harry", 120, 5, 5, 2, 2),
new SuperHero("Dino the Super-Dog", 70, 2, 8, 8, 6),
new SuperHero("Poison Punner", 90, 5, 5, 13, 1),
new SuperHero("Mikkel the Minimouse", 40, 9, 9, 9, 9),
new SuperHero("Ivan the Rubbergoat", 70, 8, 8, 6, 6),
new SuperHero("Egon the Elk", 90, 4, 4, 11, 5)
};
contestants.Add(new SpeedyKarl());
contestants.Add(new TigerTheCat());
// Putting all the contestants into pairs. If there is an uneven number of contestants, then one will be randomly left out. Too bad.
List<FightingPair> fightingPairs = new List<FightingPair>();
while(contestants.Count > 0 && contestants.Count / 2 >= 1)
{
int H1 = 0;
int H2 = 0;
while(H1 == H2)
{
H1 = Logic.random(0, contestants.Count - 1);
H2 = Logic.random(0, contestants.Count - 1);
}
fightingPairs.Add(new FightingPair(contestants[H1], contestants[H2]));
contestants.RemoveAt(H1);
if(H1 < H2)
{
H2--;
}
contestants.RemoveAt(H2);
}
Console.WriteLine("Contestants: " + contestants.Count() + " | Fighting pairs: " + fightingPairs.Count());
Console.ReadKey();
// Kicking out the last uneven contestant, if any
contestants.Clear();
// Now the fighting!
Console.WriteLine("Welcome to the Quarter Finals!");
foreach(FightingPair pair in fightingPairs)
{
Console.WriteLine(pair.FirstFighter.Name + " Vs. " + pair.SecondFighter.Name);
Console.ReadKey();
contestants.Add(pair.Fight());
Console.Clear();
}
fightingPairs.Clear();
// Semi FInals
// randomly distributing the remaining contestants
while (contestants.Count > 0 && contestants.Count / 2 >= 1)
{
int H1 = 0;
int H2 = 0;
while (H1 == H2)
{
H1 = Logic.random(0, contestants.Count - 1);
H2 = Logic.random(0, contestants.Count - 1);
}
fightingPairs.Add(new FightingPair(contestants[H1], contestants[H2]));
contestants.RemoveAt(H1);
if (H1 < H2)
{
H2--;
}
contestants.RemoveAt(H2);
}
// Now the fighting!
Console.WriteLine("Welcome to the Semi Finals!");
foreach (FightingPair pair in fightingPairs)
{
Console.WriteLine(pair.FirstFighter.Name + " Vs. " + pair.SecondFighter.Name);
Console.ReadKey();
contestants.Add(pair.Fight());
Console.Clear();
}
fightingPairs.Clear();
// Now the final round.
Console.WriteLine("Welcome to the Final combat!");
FightingPair finalPair = new FightingPair(contestants[0], contestants[1]);
SuperHero AbsoluteWInner = finalPair.Fight();
Console.WriteLine(AbsoluteWInner.Name + " is the winner of the final round! All hail " + AbsoluteWInner + "!!!");
Console.ReadKey();
}
}
}