Click here to Skip to main content
15,888,033 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Here are the variables if needed:
Python
Darkvision = ("None", False)
Stonecunning = ("None", False)
Stability = ("None", False)
Poison_Resistance = ("None", False)
Spell_Resistance = ("None", False)
Goblinfoe = ("None", False)
Giantfoe = ("None", False)

And the If in statements themselves
Python
if Darkvision in special_abilites:
    Darkvision = ("You can see 60ft in the darkness", True)
else:
    pass
if Stonecunning in special_abilites:
    Stonecunning = ("You can notice unusual stonework", True)
else:
    pass
if Stability in special_abilites:
    Stability = ("You are much harder to topple", True)
else:
    pass

Any ideas would be appreciated, Thanks!

What I have tried:

This is as compact as I can get it. I am just seeing if any could do it better than I.
Posted
Comments
Richard MacCutchan 20-Oct-22 11:45am    
Remove all the else: and pass lines, as they serve no purpose.
Brennon Nevels 20-Oct-22 12:05pm    
Ok thanks
Member 15627495 21-Oct-22 0:12am    
in the 'variable needed' section of code, as all the vars have the same state when init, you can let them with 'blank values' because It's a default value, which change when the special_abilities is set.
this section is kind of useless like that.
the hardest in coding sometimes is to don't write code... you write a kind of overload for nothing.

to see useless code, looks every time at what is written , for wich goal, and at which instant in your work flow.

and instead of the "if .... in special abilities" , you can write a function :set_abilities(string abilities_text ,boolean status) to set them. you'll just have to deal with 2 vars to set when calling a function, instead of this nested if /if /if then pattern. this section of code could be a case/break written you 'll get it more readable too.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900