Bug Reports · Legacy archive

Encounter options

Started by Strolen Mar 2, 2003 2 posts Locked

  1. Encounter options

    #1
    http://www.strolen.com/random/encounter/index.php

    Trying to figure out how to work it. When I don't have any ideas I take a break...like now.

    I would like to offer options, but what kind of options?

    Should I make an option to view all the encounters and have check boxes and let somebody pick their own?
    I wanted the choice to choose what dice to roll. Did I get them all?

    I am having trouble trying to figure out how to make the die rolls work with a random number. Is it worth my time? That is I want to roll a 1d20 but only want 10 different encounters, trying to figure out how to make the math work for that to make each encounter get two numbers, as well as any other configuration.

    Or should I just default to a certain number. 1d4 through a 1d20 get one encounter per die roll, and have the percentage default to 50 encounters and not give an option for how many encounters to show. (limit = die roll at the moment even though the limit option is available)

    There is only 15 encounters loaded at the moment so it will stop when it gets there.

    What else do you want it to do?


    (Print option will happen, so will viewi all.)
  2. Re: Encounter options

    #2
    I am having trouble trying to figure out how to make the die rolls work with a random number. Is it worth my time? That is I want to roll a 1d20 but only want 10 different encounters, trying to figure out how to make the math work for that to make each encounter get two numbers, as well as any other configuration.


    I am not totally sure that I understand you, but here goes based on what I think you mean.

    Let the user pick a die (or don't it doesn't matter, but if you do want them to be able to chose), say the D20

    $myDie = 20


    load an array with the user selected encounter indexes, or load this array with the full text messages of the selected encoutners
    $myEncounters(2,4,5,6,7,14,22,105,29) // loaded array of encounter indexes

    create array of random encounters
    $randEncounters() length = user selected return for random encounters (e.g. return "10" random encounters from 20 pre-selected encounters)

    make array for duplicate numbers
    $myNumbers

    make Boolean for repeat encounters. There may be cases were encounter would be duplicated. Some examples might be Meet up with pack of thieves, Attacked by pack of wolves, hoard of dragons surround your party)
    $allowDuplicates

    Run a loop until $myIndex = $myDie number of times, iterate $myIndex

    $myRandNum = Rand($myDie+1)-1

    If $allowDuplicates then
    $randEncounters($myIndex) = $myEncounters($myRandNum)
    Else // Check to see if Rand() (or what ever method you use to generate random
    // numbers) returns a number that is in $myNumbers

    If no duplicates then
    Run a nested loop, check $myRandNum to see if it
    matches any pre-selected encounters from $myNumbers
    If there is a match then regenerate a random number, loop

    When a unique number is
    $randEncounters($myIndex) = $myEncounters($myRandNum)
    end if
    $myIndex ++

Bug Reports · All categories · Guildhall