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' )
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.
You could post in /sqt/ but no big deal user, You never very clearly said what you need help with, can you clarify?
Jaxson Anderson
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!
Jason Howard
OH i should probably put in a factor for if the Difference is not positive it outputs N/A or something
Josiah Anderson
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?
Xavier Sullivan
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
Sebastian Peterson
>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?
Gabriel Nguyen
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' )
Reminds me of the time when I spent a full day to make combat functional for my unfinished CLI game
Nathan Moore
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
Kevin Wright
Don't do this OP.
Pretty nice though, I'm surprised you could keep track of it.
Cameron Gray
Jesus fucking christ
Carson Russell
>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.
It's been on hold for a while now since I suck at writing plot
Feel free to use it for your gaem OP
Ryan Rodriguez
that's some funky code
Henry Young
its beautiful
Brody Morgan
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
Zachary Ross
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.
Jonathan Lewis
>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!
Hudson Nelson
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.
Nathaniel Moore
horrible code. sry
Evan Flores
>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.
Nicholas Russell
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.
Liam Carter
> 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
Austin Martin
Nice meme
Brayden Davis
Nice reply
Thomas Price
cool...does every board have trolls? hunting for (you)'s
Aiden Cruz
Op, your code is too short! Show me how you do code with passion!
Cameron Cox
It's a solo project So fuck pylint
Adam Jackson
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.
Jason Adams
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
Joseph Bailey
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.
Jose Diaz
Should probably import decimal instead of using float for something like this