Results 1 to 8 of 8
  1. #1
    shvigity is offline Member
    Join Date
    Sep 2013
    Location
    'Merica
    Posts
    4
    Rep Power
    0

    Default D&D simple program help

    Hi all,

    I am new to java and programming in general and I am at somewhat of a loss because of the amount of information on the internet, and the specific questions I want the answers to is like a needle in a haystack almost.

    A background on what I am trying to do, and what I have so far.

    SO, I recently started to play D&D and as I am the only person in my group that has played before, I elected myself to be the Dungeon Master. As the DM I was hoping at first to be able to make a program right now that would 'randomly' generate numbers and return names.
    BUT NOW I am going to make a program where I type (for example) something like

    :weapon, enchant, drawback

    into the program and it would return something like

    Greataxe, +1 damage, makes you fart constantly

    At first I was going to create separate programs for each thing (common weps, uncommon weps, minor enchant, uncommon enchant, major enchant, common wondrous items, uncommon wondrous items, major wandrous items, uncommon ranged, common ranged, etc. you get the idea) but I want to combine all those into once so i can type in key terms and get random rolls and output text as to what those random things are.

    TL;DR
    So what I am looking for is help creating the basics (not to type all the information in such as the types of weapons and such) so I can type in multiple things separated by something (preferably a comma) and then roll separately on each thing I type so I can generate items faster then rolling a d% for each item and looking up what they are in a book (very time consuming). Thanks very much for the help in advance.

    here is what I have so far

    public class RandomCommonWep {

    public static void main(String[] argv) {

    x = Math.floor(Math.random() * (99+1)
    //random common weapon
    Switch(x) {

    case 1: System.out.println('Dagger'); break;
    case 2: System.out.println('Dagger'); break;
    case 3: System.out.println('Dagger'); break;
    case 4: System.out.println('Dagger'); break;
    case 5: System.out.println('Greataxe'); break;
    //etc. i have them from 1-100 repeated for percentile so a 4% chance to get a dagger.

    I was planning on making a switch for each thing I can roll on. Thanks again for taking the time to read this and for the help.
    -Shvigity

  2. #2
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    4,365
    Rep Power
    6

    Default Re: D&D simple program help

    But you're not asking a question. What are you having trouble with? This is your project you know, going to a forum to ask for help building it is not the way to do it. If you're stuck then ask a specific question so you can get going again to build this fun little project of yours.

    You do consider it fun right? Otherwise there is little point in continuing.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  3. #3
    shvigity is offline Member
    Join Date
    Sep 2013
    Location
    'Merica
    Posts
    4
    Rep Power
    0

    Default Re: D&D simple program help

    Quote Originally Posted by gimbal2 View Post
    But you're not asking a question. What are you having trouble with? This is your project you know, going to a forum to ask for help building it is not the way to do it. If you're stuck then ask a specific question so you can get going again to build this fun little project of yours.

    You do consider it fun right? Otherwise there is little point in continuing.
    I thought my questions were there in my opening but here is number based questions so popular in many forums;

    1) how can I input keywords into terminal?

    2) upon entering the keyword, how would i get terminal to respond by doing a random roll?

    3) how to I label each random roll so that it is correlated to each keyword?

    4) how can I assign big groups of things like that a label?

  4. #4
    shvigity is offline Member
    Join Date
    Sep 2013
    Location
    'Merica
    Posts
    4
    Rep Power
    0

    Default Re: D&D simple program help

    also
    5) does my current code look okay in terms of getting a random roll to spit out words?

  5. #5
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    4,365
    Rep Power
    6

    Default Re: D&D simple program help

    Now you're asking something that can be answered, somewhat.

    1) through System.in. Investigate I/O streams: Lesson: Basic I/O (The Java™ Tutorials > Essential Classes)
    2) ... "respond" is very vague. Using System.out you can print out messages, but you already knew that
    3) I'd expect you need to have a class which holds the label and the keyword at least, plus some way to store multiple object instances of that class (for example: an ArrayList) http://docs.oracle.com/javase/tutorial/collections/
    4) that is 100% meaningless
    5) The answer is the answer to this question: does it do what you need it to do?
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  6. #6
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,224
    Rep Power
    20

    Default Re: D&D simple program help

    1) Use a Scanner.
    2) Split the entered string into its components, since you want to enter several at once. For each one determine what it is, and hence what "table" to roll against.
    3) Map the keyword String to a Table. That table will itself possibly be a Map of roll vs result.
    4) "label"?
    5) You're going to need a model, and not hard code all this stuff. See (3).

    At least this is what I'd do if I was to convert something like the Ultimate Toolbox into a piece of software.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  7. #7
    shvigity is offline Member
    Join Date
    Sep 2013
    Location
    'Merica
    Posts
    4
    Rep Power
    0

    Default Re: D&D simple program help

    Quote Originally Posted by Tolls View Post
    5) You're going to need a model, and not hard code all this stuff. See (3).

    At least this is what I'd do if I was to convert something like the Ultimate Toolbox into a piece of software.
    so what you are saying is that I should make tables for each thing and use the model to retrieve the table and the information then have it spit out the weapon/item/enchant?

  8. #8
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,224
    Rep Power
    20

    Default Re: D&D simple program help

    From your original post I can see a Mapping between a String and something that will give you a random result related to that String. This would be representative of a table in whatever book you're using.

    Now, this thing that gives you a random result (a Table class) would probably have a method to generate a result. How it generates that result is up to you, but it might simply refer to some List of results which you randomly pick one. The exact structure is up to you.

    Ultimately the ideal would be to have a single Table class, where each instance is constructed using a single file containing the values in the table. That way you can add new tables easily, and change values without having to recompile.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

Similar Threads

  1. Help with simple program
    By Davda in forum Forum Lobby
    Replies: 3
    Last Post: 05-08-2012, 01:27 PM
  2. Simple program, simple problem
    By taymilll in forum New To Java
    Replies: 12
    Last Post: 06-20-2011, 06:12 AM
  3. simple program
    By kayln in forum Eclipse
    Replies: 0
    Last Post: 05-01-2011, 11:03 PM
  4. Please help with simple program.. Very simple.
    By jonytek in forum New To Java
    Replies: 7
    Last Post: 02-14-2011, 01:44 AM
  5. Simple Program
    By TheRocket in forum Advanced Java
    Replies: 15
    Last Post: 12-30-2008, 03:35 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •