Sorry for the repost, i messed up the code things. to sum it up...

Sorry for the repost, i messed up the code things. to sum it up, I'm very new to python and I'm trying to make this code work for my tabletop game. could i get some help?

A = input ('Input attacker value')
B = input ('Defenders Roll')
C = input ('Your Damage')
D = input ('Your armor' )

A_VALUE = float(A)
B_VALUE = float(B)
C_VALUE = float(C)
D_VALUE = float(D)

dif = A_VALUE - B_VALUE
Dif = float(dif)
print ('the difference is',Dif,'a')

Red = D_VALUE*15

Dmg = C_VALUE/Dif

Final = Dmg-Red

print (Final)

Get the attack value
get the defense value
get the difference
get the damage
get the armor
then figure the percentage of the damage based on difference (aka 60 difference means 60% of the damage listed in C_Value gets through)

then reduce the final number by 15 for every 1 in D_Value

I'm sure its way easier than I'm making it, but I'm very new.

uhm, i saw a thread about web development? i dont think this belongs there, but if I'm posting a topic when i should be in a thread I'm sorry.

Other urls found in this thread:

github.com/LS1088/tfw-no-gf
twitter.com/SFWRedditImages

You could post in /sqt/ but no big deal user,
You never very clearly said what you need help with, can you clarify?

I'm sorry about that.

the code i listed doesnt work haha, I'm doing very poorly at this.

if you input
Attack 180
Defense 70
dmg 65
Armor 1

The difference between attack (A) and defense (B) is 110, meaning 110% of the Damage (C) is being dealt, 71.5 Damage (rounded to 71) then reduce by 15 for every 1 Armor (D) leaving a Final of 54 Damage

i feel like I'm getting close to the final, but I'm trying to get a code that you input the first 4 and it shoots it out.

Thank you very much for your help!

OH i should probably put in a factor for if the Difference is not positive it outputs N/A or something

Did Guido ever say why he didn't include an "Option Explicit"-like option in Python, i.e. an option to require explicit variable declaration?

i think I'm messing up right here

Dmg = C_VALUE/Dif but my shitty understanding of math limits me.

i think i need to convert Dif into a Percentage somehow

>my shitty understanding of math limits me

Let's says your damage value is 65

You want to modify it by 110%

How do you do this? Certainly not by dividing 65 / 110, like you are doing there.

You multiply, 65 * 1.1

How do you convert 110% (or any other percentage) to the appropriate multiplier, like 1.1?

i think I've got it, thank you.

A = input ('Input attacker value')
B = input ('Defenders Roll')
C = input ('Your Damage')
D = input ('Your armor' )

A_VALUE = float(A)
B_VALUE = float(B)
C_VALUE = float(C)
D_VALUE = float(D)

dif = A_VALUE - B_VALUE
Dif = float(dif)
print ('the difference is',Dif,'a')

Red = D_VALUE*15
FDif = Dif/100

Dmg = C_VALUE*FDif

Final = Dmg-Red

print (Final)

Good job. BTW, you can make your program like a million times easier to reason about if you use appropriate variable names.

attack = float(input ('Input attacker value'))
defense = float(input ('Defenders Roll'))
damage = float(input ('Your Damage'))
armor = float(input ('Your armor' ))

dif = attack - defense
print ('the difference is',dif,'a')

armor_reduction = armor*15

dmg = damage * (dif/100)

final = dmg - armor_reduction

print (final)

Reminds me of the time when I spent a full day to make combat functional for my unfinished CLI game

Sooo say someone wanted to do this with all numbers one fifth of this.

Atk 36
Def 14
Dmg 13
Arm 1

Getting the final result of 12.

I'm not at my computer to test this, could it be done

Don't do this OP.

Pretty nice though, I'm surprised you could keep track of it.

Jesus fucking christ

>could it be done

Of course, but you need to change the formula somehow. I'm not sure how with you think you would wind up with 12 damage with those numbers and the existing formula.

here's the github

github.com/LS1088/tfw-no-gf

It's been on hold for a while now since I suck at writing plot

Feel free to use it for your gaem OP

that's some funky code

its beautiful

but why tho... i mean are you just trying to make the numbers look smaller? 12... if the armor reduced by 1 instead of 15 for every 1 that would work

f = lambda a, b, c, d:((a-b)*.01*c) - (15*d) + 24.14

I'm not a game designer but it works. By tweaking the constants you could come up with something a little more sensible.

>op literally doesn't even know how to name variables or do basic arithmetic with code
>better throw lambdas into the mix, that will help!

It's one of those things where you see it, say "oh, neat", and then you know how to do it. My laziness is his benefit.

horrible code.
sry

>It's one of those things where you see it, say "oh, neat", and then you know how to do it

heh. You are really doubling down on the autism. Again, this is a person who doesn't know how to do basic arithmetic in Python.

Isn't the real "autist" the one getting mad about someone doing a correct thing, but in a way that's inappropriately efficient/simple? It's one thing if I did it poorly and you pointed out the issues, but you're mad that I did it good and OP might not understand it.

> points out the glaringly obvious issue, why you did it poorly

> It's one thing if I did it poorly and you pointed out the issues

Nice meme

Nice reply

cool...does every board have trolls? hunting for (you)'s

Op, your code is too short!
Show me how you do code with passion!

It's a solo project
So fuck pylint

This is good python code, OP ... Look at how this guy have done it and learn.

You need to learn how to refactor your code. There is tons of repeating code that could easily have been different functions.
And why use CombatOn = 1 or 0 when Python has True or False? Looks like you have read the book to the left or even written it.

While I agree with you on the repeating code part I personally find fewer giant functions easier to navigate than a crapton of short functions

You should have a function every time you do any kind of repeating task. For example if you want to change the "hit $X for $y points!" message or add some extra calculations then you now have to change it in like 40 different places in the code. If it was one function you would only need to change it once.

And it's much easier to navigate with many small functions if you want to make changes. For example if someone wants to make changes to how the hero attacks then it's much easier if there is a heroAttack() function where all related code is contained even if it's only used once.

Should probably import decimal instead of using float for something like this

Who was in the right here?