• The VOIDRUNNER'S CODEX is coming! Explore new worlds, fight oppressive empires, fend off fearsome aliens, and wield deadly psionics with this comprehensive boxed set expansion for 5E and A5E!

D&D 4E D&D 4e Character Builder (Made in Java)

jimmifett

Banned
Banned
I know this topic is long dead, but I've recently restarted the project using C++ instead of Java. I developed a UI, but had to trash it because for some reason, Intellisense doesn't work if you start with a Windows Forms Application project. I had to create an empty project to get it working again. I've got some simple stuff going, but mainly I'm just designing the classes right now (the programming term, not game term). So far, I've developed a method of determining ability score modifiers dynamically, rather than hard-coding them. It works like this:

As far as I know, this formula should work for any valid ability score value.

int mod = 0;
if(score > 9)
{ mod = (score - 10) / 2; } //integer division truncates decimal
else
{ mod = -1; } //PCs can't have an ability less than 8 in 4e

As far as equipment, feats, and powers go, I was thinking of parsing XML tables to make it easier, but I'll need to learn XML and how to parse it.
Thats what I have done.


I've been using swing, tho i've been slowly porting to javascript on and off. My monster builder is javascript.
 

log in or register to remove this ad

packetpirate

First Post
Why was the code necessary? I just did this.

int tempScore = ((strengthAdjustedValue % 2) == 0)?strengthAdjustedValue:(strengthAdjustedValue - 1);
strengthMod = (tempScore - 10) / 2;
And so on...

EDIT: Read above. I've moved the project to C++.
 
Last edited:

jimmifett

Banned
Banned
Why was the code necessary? I just did this.

And so on...

ever so slightly more efficient, only integer based math operations needed instead of having to deal with floats and calculating modulus.
Subtract 10, integer divide by 2, or a literal -1. I supposed I could outright shifted the bits right one place as well since it's a divide by 2, making it super efficient.

Most important of all, it's significantly easier to read, even if you use an iif:

int mod = (score > 9)?((score - 10) >> 1):-1; // score-10 div 2, or -1
 

packetpirate

First Post
What do you mean by "only integer based math operations needed instead of having to deal with floats and calculating modulus"? I never dealt with floats... my method was integer division as well.

Also, to each their own. I can read my code just fine.
 

TheClone

First Post
I second the call for a cross platform solution. But I can't provide any rea lhelp dealing with C++. I don't know it well plus I hate it ;)
 


jimmifett

Banned
Banned
Why hate C++? It's one of the most powerful low-level languages out there.

C++ is not a low level language. Sure, it is a little lower than java, a lot lower than cobol, and exceedingly lower than perl, python and ruby, but it's still a high level language, tho I'd be willing to reclassify it as mid level.

Using a modulus operation, you still take more cycles to determine the modulus from a non integer division. Sure, the result is an integer, but the processer would have had to use it's normal division logic to derive it. A simple shift one step to the right bypasses all those logic gates needed to perform the complex task of division (integer or float) by doing something it's exceedingly quick at, bit fiddling.

Does it matter in the grand scheme of things in modern computing? Not really (unless doing embedded or game programming), but I like being as quick and optimized as possible B-)

Before you work with xml, I suggest learning how to build an xsd schema. This will allow you to validate the xml you create, as well as apply type constraints to the data in the xml. I'll presume you're using visual studio, in which case you will want to look at xsd.exe. This tool takes in an xsd schema and spits out classes to manipulate an xml document based on that schema. The resulting classes are C#, but you should be able to access the managed code from c++ in visual studio. Should you wish to bypass any integration with managed code, then I recommend looking at xerces. On the java side, I like to use XMLBeans.
 

TheClone

First Post
Why hate C++? It's one of the most powerful low-level languages out there.

Exactly, you got the point. It is pretty low-level, which is not my kind of programming. And it is powerful. You can do anything and write code in a bazillion ways. You can understand one program fully and won't get a glimpse on another. Overloading operator is just one of the concepts, that kill for example maintainability. For sure, you can also write readable code and everything but since you don't have to, most people don't. I have the feeling that they're just more fond of saving 3 letters in one class than enabling others to understand what they did. The only readable C++ code I ever saw was in Qt.

Surely this is just my personal opinion and I don't want anybody to not use C++, but I avoid it wherever I can.
 

jimmifett

Banned
Banned
For sure, you can also write readable code and everything but since you don't have to, most people don't. I have the feeling that they're just more fond of saving 3 letters in one class than enabling others to understand what they did.

I used to do that back in high school, thinking I was one of the cleverest SOBs in the land. After going back to old code enough times and trying to figure out what the hell I did, that stopped. Taking the time to properly document my code was another thing I had to give in to as my projects got bigger and I got older/wiser. Now, others can look at my code and can fully understand WHY I'm one of the cleverest SOBs in the land instead of just looking at gobblygook squeezed onto one line. :devil:
 


Remove ads

Top