|
-
Mar 27th, 2013, 02:55 PM
#1
Thread Starter
Addicted Member
Need suggestion/advice on what method to use in my app.
OK, first, sorry for the title, but I couldn't say much there as I want to explain things better here.
I have made this application called Dota Stats Simulator. You may or may not know, Dota is a game that was created as a Warcraft III Map where you control a hero that has a bunch of 'stats or properties' like damage, armor, move speed etc.
What my program does is that you select a hero from a combobox and it will show you the default hero stats, and update those stats whenever you add an item to your hero. Anyway, these stats are reflected into labels/textboxes in my program. The problem is, there are 100+ heroes in the game for which I have to show the stats, so my code went a bit long (9K+ Lines of repeated code). I'm posting a SS to have a general idea of what the program looks like.
I basically repeat the code like below.
AttackLabel.Text = HeroXAttack
ArmorLabel.Text = HeroXArmor
MoveSpeedLabel.Text = HeroXArmor
and so on for all the properties.
So my question is, What would be the best way to drammatically reduce the length of my code (I think I should be able to make the code a few thousand lines shorter, using maybe a function, adding the values for each hero stat to arrays, using enumerations, structures or anything like that, I just need a general suggestion, if I don't know how to do what you advise me to, I'll look it up in google myself, don't want to bother you with the details, just general suggestions on how to deal with a problem like this, to achieve efficiency code-wise, and if possible, performance-wise.
-
Mar 27th, 2013, 03:00 PM
#2
Re: Need suggestion/advice on what method to use in my app.
100s of records consisting of a unique value (Hero Name) with associated values (stats) and the word database never occurred to you?
As the 6-dimensional mathematics professor said to the brain surgeon, "It ain't Rocket Science!"
Reviews: "dunfiddlin likes his DataTables" - jmcilhinney
Please be aware that whilst I will read private messages (one day!) I am unlikely to reply to anything that does not contain offers of cash, fame or marriage!
-
Mar 27th, 2013, 04:22 PM
#3
Re: Need suggestion/advice on what method to use in my app.
Also a Hero class to hold all the stats for a hero. Then you throw different Hero objects at the form and it doesn't care which hero you give it, it just shows the stats for that hero.
-
Mar 27th, 2013, 04:52 PM
#4
Thread Starter
Addicted Member
Re: Need suggestion/advice on what method to use in my app.
lol, I guess as stupid as it sounds, it never crossed my mind to use a db @ dunfiddlin :P
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|