RPG Battle Logic
RPG Battle Logic
RPG Battle Logic
BEGIN
Import random
Battle(parameters: enemy1,enemy2,enemy3)
GLOBAL party,inventory
Create a-1
a-2 and a-3
as lists of [0,0,0,0]
create list called allies of [a,b,c]
Create e-1
e-2 and e-3
as lists of [0,0]
create list called foes of [a,b,c]
WHILE foes list still has foes:
For i IN sorted inventory:
print i and its dictionary reference
ENDFOR
get input for preparation command split up for each word
CASEWHERE the first word is :
Drink:
CASEWHERE second word =
H-tea: IF third word is shared :
FOR I IN allies:
health of party members goes up by 12/len(allies)
ENDFOR
ELSE
health of specified party member goes up by 12
ENDIF
B-Potion: IF b-potions in inventory aren t 0:
IF third word is shared :
FOR I IN allies:
first number in allies list goes up by 6/len(allies)
second number goes up by 6/len(allies)
ENDFOR
ELSE
first number in the list of the specified party member g
oes up by 6
Set second number to 6
b-potions in inventory go down by 1
ENDIF
D-Potion:
oes up by 8
Set fourth number to 6
d-potions in inventory go down by 1
ENDIF
Else:
Print you can t do that and repeat the while
ENDCASE
form : CASEWHERE second word is dagger :
IF third word is team :
FOR I IN allies:
Add 2 to the second number in I
ENDFOR
ELSE:
1 and 4
and the length of foes
1st number of chosen foe in foes
and the length of foes
2nd number of chosen foe in foes
enemy names
get input for target of ally attacks and store in a list 'allyatks'
IF target isn't in the foes list:
print you can't attack them and make the player choose another target
ENDIF
FOR each attack in allyatks:
IF target died and isn't in foes list:
print ally missed
ENDIF
dmg = unit attack in party dictionary + 1st number in ally list - half(ene
my defence in enemies dictionary - 2nd number in foes)
IF dmg is less than 0:
dmg is 0
ENDIF
enemy loses health equal to dmg
IF enemy health is equal to or less than 0:
remove enemy from foes
print enemy was slain
ENDIF
ENDFOR
for I in foes:
get random number between 1 and lenght of allies and store in list called fo
eatks
ENDFOR
FOR each attack in foesatks:
IF target died and isn't in allies list:
print enemy missed
ENDIF
dmg = unit attack in enemies dictionary + 1st number in enemy list - half(
ally defence in ally dictionary - 3rd number in allies)
IF dmg is less than 0:
dmg is 0
ENDIF
ally loses health equal to dmg