Ejemplo n.º 1
0
        public override void OnResponse(RelayInfo info)
        {
            if (Game == null)
            {
                return;
            }

            Mobile from = User;

            int buttonID = info.ButtonID;
            int roll     = Game.RollIndex;

            if (IsRolling && buttonID == 1 && roll >= 0 && roll < 3)
            {
                Game.RollDice(User);
                return;
            }

            if (!Complete && buttonID >= 2 && buttonID <= 6)
            {
                PlayerEntry entry = Game.Players[buttonID - 2];
                Entry = Game.Players[buttonID - 2];
                Refresh();

                User.SendSound(0x55);

                from.SendMessage("You are now viewing {0} score card.", entry.Player == from ? "your" : entry.Player.Name + "'s");
            }

            if (IsRolling && buttonID >= 100 && buttonID <= 104 && roll < 3 && !Game.UsingJoker)
            {
                if (roll > 0)
                {
                    switch (buttonID - 100)
                    {
                    case 0: Game.CurrentRoll.One.Set = Game.CurrentRoll.One.Set ? false : true; break;

                    case 1: Game.CurrentRoll.Two.Set = Game.CurrentRoll.Two.Set ? false : true; break;

                    case 2: Game.CurrentRoll.Three.Set = Game.CurrentRoll.Three.Set ? false : true; break;

                    case 3: Game.CurrentRoll.Four.Set = Game.CurrentRoll.Four.Set ? false : true; break;

                    case 4: Game.CurrentRoll.Five.Set = Game.CurrentRoll.Five.Set ? false : true; break;
                    }
                }

                Game.SendGumps();
                return;
            }

            if (IsRolling && buttonID >= 200)
            {
                ScoreType type  = (ScoreType)buttonID - 200;
                int       score = Entry.CalculateScore(type, Game.CurrentRoll, Game.UsingJoker);

                string body;

                if (type == ScoreType.Yahtzee && Entry.HasScored(ScoreType.Yahtzee) && Entry.Yahtzee > 0)
                {
                    body = "If you choose a yahtzee bonus, 100 points per bonus will be added at the end of the game. You will then choose a joker for any unchosen box.";
                }
                else
                {
                    body = String.Format("Apply {0} points to {1}?", score.ToString(), PlayerEntry.GetScoreForType(type));

                    if (roll < 3 && type != ScoreType.Yahtzee)
                    {
                        body += String.Format("<basefont color=red> You still have {0} roll(s) left!", 3 - roll);
                    }
                }

                BaseGump.SendGump(new YahtzeeConfirmGump(User, "Apply Score", body, () =>
                {
                    Entry.ApplyScore(type, score);
                }));
            }
        }