So I want to make a simple JRPG with 1on1 turn-based battles, a “party” of 4 players (next player after current players HP<1), monsters and items.
So I got some noob questions about how to do this stuff.
For example turns.
pseudocode:
# after all the assets are loaded...
def chooseTurns():
if playerSpeed > enemySpeed:
playerTurn()
elif playerSpeed < enemySpeed:
enemyTurn()
else: #if equal
random.randint(0,1)
if random == 0:
playerTurn()
elif random == 1:
enemyTurn()
else:
playerTurn() #error or somethin
Its bad is it?
And this is the turn (pseudo) functions
def playerTurn():
def chooseMove():
# add buttons for attacks and stuff
# atttack function
if enemyHP < 1:
victory()
else:
enemyTurn()
chooseMove()
def enemyTurn():
# AI chooses a move (actually with random numbers)
# and attacks
if yourHp < 1:
if playerTeam < 1:
youLoose()
else:
nextTeamMember()
else:
playerTurn()
Well thats the best way I could think of (dont laugh).
Another question I got: how would you store item information. Im thinking of potions that heal HP, MP, status, and key items.
And also the players team (humans) and monsters are different, but they all have the same characteristics: all have names, hp, mp, attack power, defence power and speed power. Should I use classes for these?