Skip to content
Advertisement

Nextcord Fight Command Organization and Suggestions

I created an extremely basic fight command in Nextcord. The command is like so:

JavaScript

Each character and weapon is assigned their own strength, speed, and defense stats. And the stats are all added up to find their final stat. Then it does the same for the enemy and it calculates the outcome.

What I would like to do is make my code more organized, and the command more intricate. For example giving someone who has overall lower statistics a chance to win due to being faster. Currently I feel like a lot of the entering is manual so making new characters is very tedious. Does anyone have any suggestions? Also, I am planning on giving certain characters and weapons negative values for certain stats. Such as giving the katana negative defense and spork negative strength.

My current code for the fight cog:

JavaScript

Advertisement

Answer

If you would keep data in dictionaries

JavaScript

then you could write it as

JavaScript

and if you would need more characters then you would have to only add values to dictionares – without changing rest of code.

You could even read data from file. Or you could add discord command which adds character.


EVentually you could group by character and weapon

JavaScript

and then it could be simpler

JavaScript
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement