RunUO Community

This is a sample guest message. Register a free account today to become a member! Once signed in, you'll be able to participate on this site by adding your own topics and posts, as well as connect with other members through your own private inbox!

[RunUO 2.0 RC1] Yahtzee!

[RunUO 2.0 RC1] Yahtzee!

Yahtzee! (1.1)


Components:


YahtzeeDice.cs
Yahtzee.cs
YahtzeeGump.cs



Installation:


- Runuo 1.0 & 2.0 Compatible. (Built on 2.0 briefly tested on 1.0)
- Place the component files in the scripts directory of your runuo installation.


Description:

Yahtzee! A fun little dice game that has been around for well over 50 years now. A picture is attached below.

If you're unfamiliar with the game the following link to the wikipedia provides a pretty good explanation:

http://en.wikipedia.org/wiki/Yahtzee#Game_Play

A set of rules can be recovered from the following site:

http://grail.sourceforge.net/demo/yahtzee/rules.html

Since a great many variations exist to these rules it should come to no surprise that I have made a few changes myself (mostly to cut down overhead code). The yahtzee throw now simply can be stacked on the Yahtzee score. So as long as you don't have a 0 under yahtzee you can stack every yahtzee on top of each other (50, 100, 150) etc. You'll notice what I mean if you have an unhealthy amount of luck in throwing yahtzees.


How to use:

A yahtzee game can be started by double clicking on the Yahtzee dice. (these can be added via [add YahtzeeDice). Once you've started the game the dice consume themselves (this is by design) and you can start playing the game of Yahtzee.

The gump should be fairly self-explanatory. Use the 'roll' button to roll the dice. The hold checkboxes to hold a die (preventing it from being re-rolled on the next roll) and the buttons next to the scores to assign a score to the category of your choice.

The yahtzee game currently gives a gold reward based on your points. If you have more than 200 points you get 10 gold per point over 200 (otherwise you get nothing).


Additional information:


You can modify the reward in the Yahtzee.cs in the GiveReward method. I am sure you can figure out how it works (it's not very complex).

Personally I'd sell the dice for about 200 gold on a vendor or something of the sorts. Since the average score on Yahtzee is between 200-300 points you allow the player to practically always win relatively small amounts of gold.


Important:

I just finished the last touches on this script about 15 minutes ago. The components were all tested in various steps but for the time being I would consider this script package in beta. If you're going to use this script be aware that it _may_ generate errors. Please report these errors so that they can be fixed.
 

Attachments

  • yahtzee.gif
    yahtzee.gif
    53 KB · Views: 492
  • Yahtzee.zip
    6 KB · Views: 398
*reserved for changes, updates*

- 09. Juli 2006 Redundant code removed
I removed a declaration of a boolean that was never used and re-uploaded the package. It can generate the following warning: The variable 'isFullHouse' is declared but never used.
This warning does not affect performance of the script or other scripts. It simply indicates a 'useless' declaration.
 
Yeah it's a nice thing to do while doing nothing isn't it? :p

Thanks for the positive feedback, it's definitely appreciated. In any event let me know if you run into any significant problems.

In the meantime happy yahtzeeing hehe
 
Glad you enjoyed the script :)

Due to lack of problems this script is now no longer in the BETA stage. I've also done several tests on runuo 1.0 and the script appears to be compatible (in case that's holding anyone back).

I will no longer continue to monitor this thread. If there are problems with this script post the problem here and send me a Private Message so that I can fix the issue.

Many thanks to those that have given me good karma for this release... What goes around will eventually come around ;)
 

Sunshine

Wanderer
I was testing this out on a run uo 1 and it went in just fine no problems...was testing it a bit before adding it to the shard and noticed if you left click to close out the gump.. your dice dissappear...

also if a player is playing will the game rember where he was or will he need to start over another time?

Thanks
 
Sunshine said:
I was testing this out on a run uo 1 and it went in just fine no problems...was testing it a bit before adding it to the shard and noticed if you left click to close out the gump.. your dice dissappear...

also if a player is playing will the game rember where he was or will he need to start over another time?

Thanks
Actually your dice dissapear when you open the gump ;). As I indicated in the installation instructions:

Once you've started the game the dice consume themselves (this is by design) and you can start playing the game of Yahtzee.

You can disable this option by commenting out the following line in the YahtzeeDice.cs script:

Code:
                this.Consume();
so that the ondouble click looks like this:

Code:
        public override void OnDoubleClick(Mobile from)
        {
            base.OnDoubleClick(from);
            if (!(IsChildOf(from.Backpack))) // Make sure its in their pack
            {
                from.SendMessage("This must be in your backpack for you to use!");
            }
            else
            {
                from.SendGump(new YahtzeeGump(from));
[COLOR=DarkRed] [B]              // this.Consume();[/B][/COLOR]
            }
        }
changed line in red.

#2The game will remember the 'game state' as long as the gump is open. If you close the gump the game information is lost and the player will have to start over.

Regards,
 

Sunshine

Wanderer
Captain The First said:
Actually your dice dissapear when you open the gump ;). As I indicated in the installation instructions:



You can disable this option by commenting out the following line in the YahtzeeDice.cs script:

Code:
                this.Consume();
so that the ondouble click looks like this:

Code:
        public override void OnDoubleClick(Mobile from)
        {
            base.OnDoubleClick(from);
            if (!(IsChildOf(from.Backpack))) // Make sure its in their pack
            {
                from.SendMessage("This must be in your backpack for you to use!");
            }
            else
            {
                from.SendGump(new YahtzeeGump(from));
[COLOR=darkred][B]            // this.Consume();[/B][/COLOR]
            }
        }
changed line in red.

#2The game will remember the 'game state' as long as the gump is open. If you close the gump the game information is lost and the player will have to start over.

Regards,

I am sorry I do not mean to be dense, though I often am, so say I am playing but have to leave and I left click to close the gump the dice are meant to be consumed? so they are like one time use items?


Sorry I am just confused but really want to use these
 
I have attached a version of the YahtzeeDice.cs script that does not consume the dice when they are used.

Simply replace your YahtzeeDice.cs script with the attached one if you do not want your dice removed when they are used.

Regards,
 

Attachments

  • YahtzeeDice.cs
    1.3 KB · Views: 72

Sunshine

Wanderer
Captain The First said:
... yes... if you use the dice the gump opens and the dice will dissapear.
I have posted instructions how to disable this in the above post.

Yes I read that thanks....

nm thanks for your time though
 
The replacement version I attached above will prevent the dice from dissapearing. I had the dice consumed because that way I can charge the players for them on a continual basis... not that they don't make the money back mind you. The returns are actually quite fair.

But as said, the replacement script will do what you want it to do.
 
Top