View unanswered posts | View active topics It is currently Sat Apr 27, 2024 5:37 am



Post new topic Reply to topic  [ 12 posts ]  Go to page 1, 2  Next
 Trying to modify a die roller. 
Author Message

Joined: Fri May 28, 2010 7:47 am
Posts: 5
Post Trying to modify a die roller.
Hello, new to Open RPG....

I am trying to modify the wod die roller. Anyone who know's the new world of darkness LARP rules will know what I'm talking.

I want to be able to take 1d10+n. Add the total. The first success is at 10, and another success for every increment of 5. That's the default mechanic.

This is what i have so far;

Code:
    def sum(self):
        rolls = []
        retValue = 0
        s = 0
        s1 = self.targetthr
        for a in self.data:
            setValue = reduce( lambda x, y : int(x)+int(y), a.history )
            retValue += setValue
            if retValue < self.target:
                s == 0
            else: s == 1 + ( int( retValue - 10 ) / 5 )
            if s1 >0:
                s1 -= 1
                s -= 1
        return s

    def __str__(self):
        if len(self.data) > 0:
            myStr = "[" + str(self.data[0])
            for a in self.data[1:]:
                myStr += ","
                myStr += str(a)
            if self.sum() == 0: myStr += "] result of a failure"
            elif self.sum() == 1: myStr += "] result of (" + str(self.sum()) + ") success"
            else: myStr += "] result of (" + str(self.sum()) + ") successes"
        return myStr


But all I get output is;

Quote:
(0) No Name: [1d10+8] => [1,8] result of a failure
(0) No Name: [1d10+8] => [6,8] result of a failure
(0) No Name: [1d10+8] => [6,8] result of a failure
(0) No Name: [1d10+8] => [8,8] result of a failure
(0) No Name: [1d10+8] => [1,8] result of a failure
(0) No Name: [1d10+8] => [1,8] result of a failure
(0) No Name: [1d10+8] => [8,8] result of a failure
(0) No Name: [1d10+8] => [10,8] result of a failure
(0) No Name: [1d10+8] => [8,8] result of a failure
(0) No Name: [1d10+8] => [1,8] result of a failure
(0) No Name: [1d10+8] => [8,8] result of a failure
(0) No Name: [1d10+8] => [7,8] result of a failure
(0) No Name: [1d10+8] => [1,8] result of a failure


So what I need is the addition of the two numbers to happen and then to show how many successes.

Any help I can get here??


Fri May 28, 2010 7:55 am
Profile

Joined: Thu Dec 10, 2009 6:37 am
Posts: 335
Post Re: Trying to modify a die roller.
Alrighty then..... can't see anything right now but I can look in detail tonight.

One hint that you might find useful is to insert print statements at various places so you can keep an eye on variables at key points to determine better where exactly things are not going right. eg print retValue


Fri May 28, 2010 10:59 pm
Profile

Joined: Thu Dec 10, 2009 6:37 am
Posts: 335
Post Re: Trying to modify a die roller.
What is in the rest of the class? Perhaps you should post the whole thing.

You have a couple of places where you have "s ==" where you probably mean "s ="

I am not sure what you are trying to do with the dice roll. I don't know what the rules are for rolling Wod dice with this LARP system and I couldn't find the rules on line anywhere.


Sat May 29, 2010 12:59 am
Profile
User avatar

Joined: Wed Dec 09, 2009 9:39 pm
Posts: 712
Post Re: Trying to modify a die roller.
I think you are going about it the wrong way. What I understand is you want to add 5 to the difficulty.

You will want to iterate all of the die rolls with a function like this
Code:
s = 0
for roll in rolls:
    if roll > 10 + s*5: s += 1


Then every time you have a success your s object is increased by 1 and your difficulty is increased by s * 5

_________________
I ate your Death Knell.
The Traipse Movement
Please show your support for Traipse OpenRPG http://www.facebook.com/MadMathLabs
Send me Traipse OpenRPG Ideas, Bugs, Complaints, Praises here: https://getsatisfaction.com/mml


Sat May 29, 2010 3:33 am
Profile YIM WWW

Joined: Fri May 28, 2010 7:47 am
Posts: 5
Post Re: Trying to modify a die roller.
Ok....this is the actual LARP (minds eye theatre) rules.....the mechanic is

Draw a card (Ace-10) and add to your test pool (the number of dots you have in an Attribute + Skill) then add them up.

Example: Dex 5 Firearms 3 = test pool of 8

Ace - 10 can equal a 1d10 dieroll

so 1d10+8

That would be the roll.

Successes are counted as follows...

@ 10 = 1 success
@ 15 = 2
@ 20 = 3
@ 25 = 4

and this goes on every increment of 5

there isn't a target difficulty so i set the target at 10 since we're technically only going to do one die roll and if it isn't higher than 10, it counts as a fail.

I want it to output something like this:

1d10+8 = 5, 8 = 13 = 1 success
or
1d10+8 = 8, 8 = 16 = 2 successes
or
1d10+8 = 1, 8 = 9 = 0 successes or faliure

so i figured taking the total value of the rolled dice (Say 16 with the two successes) and doing some basic math, we could get the number off successes.

if retValue < self.target:
s == 0
else: s == 1 + ( int( retValue - 10 ) / 5 )

retValue = the total of the dice+modifier
self.target = the target (default 10)

so with 16 total, s would equal 1+(16-10)/5)

s = 1+(16-10)/5
s = 1+(6)/5
s = 1+1.2
s = 2.2

with the Int, it should drp the .2 making it;

s = 2

and return the s

now in the next class, my understanding is that if self.sum() being the value returned by the sum class, which it should return s is 0, it will fail. I added in a thing for if it equaled 1 to say success, and any more say successes.

What i did to start was take the wod.py script, and modified that. These are the only two classes I have edited. I am not at that PC atm so i can't post the whole thing but you can see it there. I will try to get it posted tomorrow though if it would help.

To get to where I wanted, i have pretty much taken a part of the sum() class from the std.py roller and this is where I'm at.

I will try the print thing....i had thought about it but was unsure how python did it. I'm a little familiar with C# but that's about it.

And thank you for the help guys....I'm impressed to get a response and now look forward to using OpenRPG once I can get this bit figured out.

EDIT: the s=0 from what I understood in the original wod.py is that is the number of successes. I have added in some math to show what I am trying for and how I'm figuring the code "should" work.


Sat May 29, 2010 6:20 am
Profile
User avatar

Joined: Wed Dec 09, 2009 9:39 pm
Posts: 712
Post Re: Trying to modify a die roller.
Like I said, you are going about it the wrong way. You want to find the sum and try and decipher the number of success that way, go ahead. But with the iteration I made you would have a successive addition to your target.

s = 0; sets the successes to 0
if roll >= 10 + s*5; starts off at 10, and every new success adds 5.

But if you take the sum you are going to cause a lot of confusion. Of course I have no idea how
Quote:
1d10+8 = 8, 8 = 16 = 2 successes
equates to you. That part loses me.

EDIT: Oh wait .. I think I am getting the idea.. Hold on.. give me a moment.

_________________
I ate your Death Knell.
The Traipse Movement
Please show your support for Traipse OpenRPG http://www.facebook.com/MadMathLabs
Send me Traipse OpenRPG Ideas, Bugs, Complaints, Praises here: https://getsatisfaction.com/mml


Sat May 29, 2010 6:42 am
Profile YIM WWW
User avatar

Joined: Wed Dec 09, 2009 9:39 pm
Posts: 712
Post Re: Trying to modify a die roller.
Where did you get your dieroller?

Code:
    def sum(self):
        rolls = []
        s = 0
        s1 = self.targetthr
        botch = 0
        for a in self.data:
            rolls.extend(a.gethistory())
        for r in rolls:
            if r >= self.target or r == 10:
                s += 1
                if s1 >0:
                    s1 -= 1
                    s -= 1
                else: botch = 1
            elif r == 1: s -= 1
            if botch == 1 and s < 0: s = 0
        return s

    def __str__(self):
        if len(self.data) > 0:
            myStr = "[" + str(self.data[0])
            for a in self.data[1:]:
                myStr += ","
                myStr += str(a)
            if self.sum() < 0: myStr += "] vs " +str(self.target)+" result of a botch"
            elif self.sum() == 0: myStr += "] vs " +str(self.target)+" result of a failure"
            else: myStr += "] vs " +str(self.target)+" result of (" + str(self.sum()) + ")"
        return myStr


That is what I have. I can write something up for you, but it won't fit in yours

_________________
I ate your Death Knell.
The Traipse Movement
Please show your support for Traipse OpenRPG http://www.facebook.com/MadMathLabs
Send me Traipse OpenRPG Ideas, Bugs, Complaints, Praises here: https://getsatisfaction.com/mml


Sat May 29, 2010 6:53 am
Profile YIM WWW
User avatar

Joined: Wed Dec 09, 2009 9:39 pm
Posts: 712
Post Re: Trying to modify a die roller.
Here you go
Code:
    def sum(self):
        rolls = []
        s = 0
        d = 0
        for a in self.data:
            rolls.extend(a.gethistory())
        for r in rolls:
            d += r
        s = int((d-10)/5); print s
        if s >= 0: return s+1
        else: return 0


That sum function will work. How you present the text depends on the myStr text that you can modify however you want.

_________________
I ate your Death Knell.
The Traipse Movement
Please show your support for Traipse OpenRPG http://www.facebook.com/MadMathLabs
Send me Traipse OpenRPG Ideas, Bugs, Complaints, Praises here: https://getsatisfaction.com/mml


Sat May 29, 2010 7:10 am
Profile YIM WWW

Joined: Thu Dec 10, 2009 6:37 am
Posts: 335
Post Re: Trying to modify a die roller.
The code you are borrowing from does a lot more complex a calculation than you need. First ofall it is totalling the history of each roll. This is because (I think) wod normally has some rule about if you roll a 10 then roll it again and add the results and if that is a ten roll again and etc. This is handled in the code as,

Code:
setValue = reduce( lambda x, y : int(x)+int(y), a.history )


translated to English: add up all the rolls you might have had to make because of re-rolling and adding on a natural 10.

Note that is inside an iteration over the number of actual rolls:
Code:
for a in self.data:


But you are only interested in one die roll. You don't want to roll eg 5d10 and check for how many successes over each of the five dice all with possible natural 10s re-rolling and adding.

If you don't care about any of those complex cases you can simply get the die roll as,
Code:
self.data[0]


which makes your entire sum() function equal to,
Code:
return int(self.data[0]/5)-1


At least if you don't mind a -1 or a 0 indicating failure. Note that you don't need self.target because self.target is (I beleive) used by wod for when something less than a 10 on a d10 is a success. So self.target could be an 8 for example. I am not sure what self.targetthr does or did in that commented out wod code. It looks very odd as a concept to me and I can't figure out what it is supposed to be doing. The commented out code is probably wrong. But anyway you don't need it I guess.

Really you need so little changed that you could just change the build_extra function. I believe that is the intention of that function. It's a way to minimally alter a die roller to just add a bit of extra text on the end. Your build_extra function just needs to assign a value to self.extra_string. You can see that happening in the original wod.py code (uncommented out).

So you could just have:
Code:
def build_extra(self):
   sucesses = int(self.data[0]/5)-1
   if sucesses == 1:
      self.extra_string = "1 sucess."
   elif sucess > 1:
      self.extra_string = "%s sucesses." % sucess
   else:
      self.extra_string = "failure."


This wouldn't work for complex cases where you are rolling several d10s but it seems like you don't want that.

Don't know if that code works at all -- it's more a model of what you might do.


Sat May 29, 2010 10:10 pm
Profile

Joined: Fri May 28, 2010 7:47 am
Posts: 5
Post Re: Trying to modify a die roller.
wow....thanks for the code guys!

@Prof.Eberal: I will try plugging that in and see how it goes. If it works ok, then I THINK (keyword) the myStr will output it just fine. I'll let you know.

@davidbyron: Well....I'm not that far yet....trying to get the base mechanic to work right first lol.

The next step (which I haven't tried yet) is to re-roll 10's....and possibly other numbers.

In the LARP rule's, you re-draw/re-roll 10 on the first time, add the 10 to your total, re-roll again, add the second value. If it's another 10 you DO NOT re-roll it on the 2nd time.

same goes for 9-again or 8-again

The part i see being difficult, is the only once thing. If say I am doing something that get's 8-again, then 8's, 9's, and 10's all can be drawn the 1st time.....then re-rolled and if drawn a second time, just added.

Example:

test pool of 8 (to kinda go with my top version) but with 8 again

1d10+8 is what we're working with.

On the first roll, we get an 8 giving us 16 (8+8). Thanks to 8-again, we get to re-roll

On the second roll, we get a 10 giving us 26 (8+8+10). Since 10's are usually re-rolled anyways, we get another roll.

We're lucky and get a 9 giving us 35 (8+8+10+9) and due to the task was 8-again, 9's will then fall into this category. So another roll.

On our third we get another 9 giving us 44 (8+8+10+9+9) and since we have already drawn a 9, our roll stops here.

now with a 44, that would be 6 successes. First success at 10, and then another at 15, 20, 25, 30, 35, and 40.


Sun May 30, 2010 12:09 am
Profile
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 12 posts ]  Go to page 1, 2  Next


Who is online

Users browsing this forum: No registered users and 155 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by Vjacheslav Trushkin for Free Forums/DivisionCore.