I got this code and I cannot get it to work.
I want it to show up with the type of attacks you can do which it does.
After each time you attack the enemy the enemy attacks you of a damage between 1-10, then its my turn etc until you or enemy < 0 then writes you win or enemy win.
Also I want to add a thing where when its your turn you can use portions to restore your health of value of 10 and another potion of value of 20.
Here is the code:
program RPG;
var
Attack : Integer;
Defense : Integer;
Health : Integer;
EnemyHealth : Integer;
Damage : Integer;
EnemyAttack : Integer;
EnemyDefense : Integer;
Whatdo : Integer;
Healz : Integer;
Death : Boolean;
EnemyDam : Integer;
Begin
Death := FALSE;
Defense := 10;
EnemyDefense := 5;
EnemyAttack := 8;
Health := 100;
EnemyHealth := 50;
Healz := 10;
Attack := 12;
Writeln ('Hero vs Enemy');
Writeln ('Hero Health : ', Health);
Writeln ('Enemy Health : ',EnemyHealth);
Writeln ('');
Writeln ('1. Attack');
Writeln ('2. Heal');
Writeln ('');
Writeln ('What do?');
Readln (Whatdo);
If whatdo = 1 then
repeat
Damage := Attack - EnemyDefense;
EnemyHealth := Enemyhealth - Damage;
if (EnemyHealth < 0) then
EnemyHealth := 0;
Enemydam := EnemyAttack - Defense;
Health := Health - EnemyDam;
Writeln ('Enemy health is now ', EnemyHealth);
Writeln ('Hero Health is now ', Health);
Readln;
until
(EnemyHealth <= 0);
If whatdo = 2 then
Health := Health + healz;
Enemydam := EnemyAttack - Defense;
Health := Health - EnemyDam;
if (EnemyHealth < 0) then
EnemyHealth := 0;
Writeln ('Enemy health is now ', EnemyHealth);
Writeln ('Hero Health is now ', Health);
Until
(Health = 100);
If Health := 100 then writeln ('Health is full');
readln;
begin
Death := TRUE;
Writeln ('Enemy is dead');
Readln;
end;
End.
Thanks in advance