-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBattle.cs
39 lines (36 loc) · 1.35 KB
/
Battle.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
using System;
namespace MonsterRPG
{
public class Battle
{
private bool wonloss=true;
public Monster[] monsters;
public Battle (Monster[] getmonsters)
{
monsters = getmonsters;
}
public bool isWonloss() {
return wonloss;
}
public void battle() {
Random chooser=new Random();
int chosenmonster=chooser.Next(5);
double defeated=(chooser.NextDouble()*(monsters[chosenmonster].returnHealth())+1);
Console.WriteLine("The monster you are fighting is "+monsters[chosenmonster].returnName()+" and has "+monsters[chosenmonster].returnHealth()+" HP.");
GUISystem.displaybar.Text="The monster you are fighting is "+monsters[chosenmonster].returnName()+" and has "+monsters[chosenmonster].returnHealth()+" HP.";
GUISystem.displaybar.Refresh();
if (defeated>=(monsters[chosenmonster].returnHealth()/2)){
Console.WriteLine("You beat "+monsters[chosenmonster].returnName()+"!");
GUISystem.wonloss_status.Text=("You beat "+(monsters[chosenmonster].returnName())+"!");
GUISystem.wonloss_status.Refresh();
wonloss=true;
}
else if(defeated<(monsters[chosenmonster].returnHealth()/2)){
Console.WriteLine("You lost to "+monsters[chosenmonster].returnName()+"!");
GUISystem.wonloss_status.Text="You lost to "+monsters[chosenmonster].returnName()+"!";
GUISystem.wonloss_status.Refresh();
wonloss=false;
}
}
}
}