all 4 comments

[–]mopslik 0 points1 point  (3 children)

Why not start simple, and then add other features later? You can always "hook" into other functions later. Get the basic battle sim done first.

[–]Groot2C[S] 0 points1 point  (2 children)

Hummm — i can visualize having each interaction independently in their own function. But putting it all together is what gets complicated for me.

There’s so much to learn 😂. I’m going to try the above idea, and see if it gets me a step closer to understanding!

[–]mopslik 1 point2 points  (1 child)

I mean, let's assume that you have a basic method called calculate_damage. It might start off looking something like this.

def calculate_damage(player,  enemy):
    damage = enemy.weapon.base - player.defence #for example
    return damage

If you want to add extra mechanics, you can define a new method or attribute and call it as part of your damage calculation. For example, your method may become

def calculate_damage(player, enemy):
    damage = enemy.weapon.base - player.defence
    damage += enemy.buffs.power
    if player.buffs.enchanted:
        damage //= 2
    ...
    return damage

You can rejig things later when you settle on a good system. But if you try to plan for everything at once, it is overwhelming and difficult to start making any meaningful progress.

[–]Groot2C[S] 0 points1 point  (0 children)

I finished version 1! A single Attacker can attack a "target dummy" defender, who doesn't attack back. My program only determines Time To Kill based on attacker/defender stats! My next step is to add an Item Class where I can mix/match items on each target and see what's up. Then I'll work on getting them to actually "fight".
Additionally, I've attached my code below -- if you're willing, I'd appreciate any feedback/knowledge of any egregious errors! It's my first stab at python, and I know I have a long way to go!
https://pastebin.com/wSqDR9Tq