Sie sind auf Seite 1von 3

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:

IF d-potions in inventory aren t 0:


IF third word is shared :
FOR I IN allies:
third number in allies list goes up by 8/len(allies)
fourth number goes up by 6/len(allies)
ENDFOR
ELSE
third number in the list of the specified party member g

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:

Add 2*len(allies) to specified party member 2nd number


shield :
IF third word is team :
FOR I IN allies:
Add 3 to the 4th number in I
ENDFOR
ELSE:
Add 3*len(allies) to specified party member 4th number
ENDCASE
ENDCASE
Get random number between
CASEWHERE number is
0: get number between 1
Add 2*len(allies) to
1: FOR i in foes:
add 2 to 1st number
2: get number between 1
Add 3*len(allies) to
3: FOR i in foes:
add 3 to 2nd number
ENDCASE
FOR name in foes:
print 'enemies' and the
ENDFOR

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

IF ally health is equal to or less than 0:


remove ally from allies
print ally was KOed
ENDIF
ENDFOR
IF length of allies is 0:
print you were defeated
RETUEN FALSE
FOR i in allies:
first number equals second number and third number equals fourth number
IF second number isn't 0:
subtract 1 from first and second number
ENDIF
IF fourth number isn't 0:
subtract 1 from third and fourth number
ENDIF
FOR i in foes:
first two numbers become 0
ENDFOR
ENDWHILE
Print the enemy was defeated!
v-exp = average of enemy stats
FOR character in party:
add v-exp to character exp stat
IF exp is => exp-cap:
print character levelled up: level -> level+1
subtract expcap from exp
add 10 to exp-cap
print exp
FOR stat in stats:
add a random number between 1 and 3 to stat
print stat
ENDFOR
ELSE:
print exp
ENDIF
create loot as a random number between 1 and 5
IF boss in enemies:
double loot
ENDIF
print aluminium coins: loot
add loot to money
RETURN

Das könnte Ihnen auch gefallen