0

I'm still in college and I'm trying my hand at designing my own applications, for practice and also for funsies, but I'm having some big questions.

Currently, I'm attempting to design an application that uses a relational database backend to store records related to a pen-and-paper RPG that a friend and I have been designing. It will need to store characters, weapons, items, etc. Since it's based off of a sci-fi universe, there are guns, etc.

Now, I'm stuck in the conceptual stages here because I'm not sure how I would store some of the weirder to grasp types of information here. Since it's a tabletop RPG, there are dice involved, typically referred to as D4, D6, D10, D20, etc. and a lot of these weapons, for example, have several kinds of attacks each (they're guns, so it's like firing modes, etc.) and a typical attack would be something like "D20 + 20."

Now, I know that I could just store it as a string variable, but I was hoping to design this in such a way that I could actually add some dice-rolling/etc. functionality to it. Is there a simple or effective way of storing a Math.random variable (not the result, mind you, but the actual range number) in a SQL record so that I could just grab it and use it real quick?

For extra context, I was hoping to have one table of the actual weapon templates & stats and another table of just actual instances of those weapons, so I could keep track of ammo in each gun, who owns it, etc.

I'm using Netbeans and a Derby database. Thanks for any help you guys.

Roknikus
  • 13
  • 4

2 Answers2

0

Your question is very broad, but I would not store a descriptive characteristic like "D20 + 20" in your database only yo parse it out in the app. Instead store that as two or three (depending on what it represents) attributes (columns) in your database, and let the app display it appropriately.

I don't know exactly what you mean by storing "equations" and "RNGs" in your database, but those belong in the application, not the database. You can store inputs or parameters that guide those equations, but not the equations themselves.

D Stanley
  • 149,601
  • 11
  • 178
  • 240
  • I figured, but did not want to assume. Essentially, each weapon has multiple attacks, dependent on the range of the weapon to its target, (e.g. short distance, medium distance, long distance) and each attack has an equation basically that typically involves some combination of dice and numbers to yield a final number that is the damage. (e.g. A weapon has "D12 + 10" damage, so it can do anywhere from 11-22 damage.) So I just wanted to see how I would go about storing such data. I'll probably end up storing that specifically in the application side of it. – Roknikus Jun 22 '16 at 13:42
  • In general, use the application layers to store the _rules_ and _objects_ for your system, and use the database to store just the _data_ necessary to make the system work. In that specific case I would have columns for "range" and "offset" that would store "12" and "10", respectively, and let the app to the random number generation. – D Stanley Jun 22 '16 at 14:19
  • I understand. Ironically, comments by another person on this question led me to a face-palming moment of revelation regarding the notion that I should use columns for "range" and "offset." Thank you, regardless. – Roknikus Jun 22 '16 at 14:37
0

As stated above, I don't know why you just wouldn't create a java/C#/any programming language application that can simulate the dice rolls for you. I mean, you could integrate the database into the application to retrieve information. Otherwise just simply make the ability to input information on weapons/Armour into the application in the form of popup dialog boxes (Or something along those lines).

A database is primarily used to store information in a structured way and automatically updates this information as needed. What you are suggesting to do is more dynamic and has nothing to do with storing information and more so with actually playing the game. Not wanting to change your idea about creating it. Just creating an actual application that utilizes a database can be written in a language other than SQL. (And much easier to do it this way as well.)

  • Well, the plan is to create an actual application that utilizes the database. Right now, I'm still just trying to figure out exactly what I'm going to store in the database and how I'm going to organize it before I get crazy. – Roknikus Jun 22 '16 at 13:46
  • Well if you wanted to look at how to generate and store random values using SQL here is a stack that answers that. http://stackoverflow.com/questions/7878287/generate-random-int-value-from-3-to-6 However, if your talking about simply storing the "random ranges" then why not just have that as a field in your database? I'm confused as to what your actually asking. You may want to look into Database diagramming in order to draw out a picture of how you want the database to look. – AndrewGetsome Jun 22 '16 at 13:49
  • You know, I just had a face-palming moment here. Why wouldn't I just store the range? *SMACKS FACE* I'm such a dork sometimes. So now I'm bouncing around in my head how to reorganize everything. (I actually have a big whiteboard that I've been drawing everything out on.) So I'm thinking that I should either store the range as a simple number along with the lowest amount of damage, or just store the lowest possible damage and highest possible damage, and then, in the app, just reference those (i.e. subtract lowest number from highest number) to get the range and use that to RNG in app. THANKS! – Roknikus Jun 22 '16 at 13:56
  • To further help you think this through. If many things (Weapons, Armour, Class, Player level, and Monster level) help determine the actual range. Then perhaps have a range set for each of these individual things. Then when you draw that information into your application you could preform the mathematics there in order to determine the REAL range of the battle. Referring back to my original comment. Do all the math inside the program application so that the database is just updating/retrieving/storing information as needed. – AndrewGetsome Jun 22 '16 at 14:03
  • 1
    That is the plan, store info in database, retrieve and use it to perform computations in the application itself. – Roknikus Jun 22 '16 at 14:29