示例#1
0
        /*
         * Responds to event called by client when they click UIButton:SaveBtn OR answering in the affirmitive on any UIAlert while this evaluation is true:
         * (UIGameCompDrawACardPluginEODStates:State == UIGameCompDrawACardPluginEODStates.EditSingleCard)
         * @param evt:String containing the name of the event
         * @param cardText:String containing the desired updated text of the card at Game.CurrentCardIndex
         * @note: Due to the MaxChars limit of 256 of the UITextEdit:EditCardTextEdit, cardText:String must not have a length greater than 256.
         * @note: No callback function is needed, which means the client's ability to interact with the UI is unaffected and not dependent on this handler.
         */
        void EditCurrentCardHandler(string evt, byte[] cardTextArray, VMEODClient client)
        {
            // client has to be the object owner
            bool isOwner = (((VMTSOObjectState)Server.Object.TSOState).OwnerID == UserClient.Avatar.PersistID);

            // validate the data
            bool   isValid  = false;
            string cardText = null;
            var    strings  = VMEODGameCompDrawACardData.DeserializeStrings(cardTextArray);

            if (strings != null)
            {
                cardText = strings[0];
            }
            if ((cardText != null) && (cardText.Length < 257))
            {
                isValid = true;
            }

            // If the user would like this card to be blank, replace the blank string with the name of the enum entry for custom.
            if (cardText.Length == 0)
            {
                cardText = VMEODGameCompDrawACardTypes.VMEODGameCompDrawACardCustom.ToString();
            }
            if ((isOwner) && (isValid))
            {
                if (!Game.CurrentCardText.Equals(cardText))
                {
                    DeckHasChanged = true;
                    Game.EditCurrentCard(cardText);
                    UserClient.Send("DrawCard_Update_Deck", GetDeckListBoxData());
                }
            }
        }
示例#2
0
        /*
         * Called on Event:"eod_close" ?
         * @param evt:String containing the name of the event
         * @param newCardTextAndFrequency:String containing the desired new name and description to be set as Game.GameTitle and Game.Description
         */
        void EditGameHandler(string evt, byte[] gameTitleAndDescriptionByteArray, VMEODClient client)
        {
            if (gameTitleAndDescriptionByteArray == null)
            {
                return;
            }

            // client has to be the object owner
            bool isOwner = (((VMTSOObjectState)Server.Object.TSOState).OwnerID == UserClient.Avatar.PersistID);

            // validate the data
            bool isValid = false;

            string[] gameInfo = VMEODGameCompDrawACardData.DeserializeStrings(gameTitleAndDescriptionByteArray);
            if (gameInfo.Length > 1)
            {
                if ((gameInfo[0].Length < 53) && (gameInfo[1].Length < 257))
                {
                    isValid = true;
                    // If the user would like the game title to be blank, replace the blank string with the name of the enum entry for custom.
                    if (gameInfo[0].Length == 0)
                    {
                        gameInfo[0] = VMEODGameCompDrawACardTypes.VMEODGameCompDrawACardCustom.ToString();
                    }
                    // If the user would like the game description to be blank, replace the blank string with the name of the enum entry for custom.
                    if (gameInfo[1].Length == 0)
                    {
                        gameInfo[1] = VMEODGameCompDrawACardTypes.VMEODGameCompDrawACardCustom.ToString();
                    }
                }
            }
            if ((isOwner) && (isValid))
            {
                if (!Game.GameTitle.Equals(gameInfo[0]))
                {
                    DeckHasChanged = true;
                    Game.GameTitle = gameInfo[0];
                }
                if (!Game.GameDescription.Equals(gameInfo[1]))
                {
                    DeckHasChanged       = true;
                    Game.GameDescription = gameInfo[1];
                }
            }
        }
示例#3
0
        /*
         * Responds to event called by client when they click UIButton:SaveBtn OR answering in the affirmitive on any UIAlert while this evaluation is true:
         * (UIGameCompDrawACardPluginEODStates:State == UIGameCompDrawACardPluginEODStates.EditSingleCard)
         * @param evt:String containing the name of the event
         * @param newCardTextAndFrequency:String containing the desired text and frequency of the card to be added to Game
         * @callbackEvent:"DrawCard_Update_Deck" updates the client UI's variable of UIListBox:SelectCardList - background
         * @callbackEvent:"DrawCard_Update_Card" updates the client UI's variable of String:CurrentCardText - re-enables user interactions with the UI
         * @callbackEvent:"DrawCard_Update_Deck_Numbers" updates the client UI's variables of int:TotalUniqueCards and int:GrandTotalCards - background
         * @note: Due to the MaxChars limit of 256 of the UITextEdit:NewCardTextEdit, split[0] must not have a length greater than 256.
         * @note: split[1] contains a string that represents the new frequency that the card at Game.CurrentIndex should be set to in order to affect
         * its chances of being drawn. It must be greater than 0 and less than 100. This plugin does not support the preserving of cards with 0 frequency, and
         * due to the 2 character limit of the UITextEdit:NumDrawChancesTextEdit from which the value is taken, (int)split[1] cannot be greater than 100.
         */
        void PushNewCardHandler(string evt, byte[] newCardTextAndFrequencyArray, VMEODClient client)
        {
            if (newCardTextAndFrequencyArray == null)
            {
                return;
            }

            // client has to be the object owner
            bool isOwner = (((VMTSOObjectState)Server.Object.TSOState).OwnerID == UserClient.Avatar.PersistID);

            // validate the data
            bool isValid   = false;
            var  split     = VMEODGameCompDrawACardData.DeserializeStrings(newCardTextAndFrequencyArray);
            byte frequency = 100;

            if ((split.Length > 1) && (split[0].Length < 257))
            {
                if (Byte.TryParse(split[1], out frequency))
                {
                    isValid = true;
                }
                else
                {
                    frequency = 1;
                    isValid   = true;
                }
                // If the user would like this card to be blank, replace the blank string with the name of the enum entry for custom.
                if (split[0].Length == 0)
                {
                    split[0] = VMEODGameCompDrawACardTypes.VMEODGameCompDrawACardCustom.ToString();
                }
            }
            if ((isOwner) && (isValid) && (Game.UniqueCardCount < MAXIMUM_UNIQUE_CARDS))
            {
                DeckHasChanged = true;
                Game.PushNewCard(split[0], frequency);
                UserClient.Send("DrawCard_Update_Deck", GetDeckListBoxData());
                UserClient.Send("DrawCard_Update_Deck_Numbers", GetCardNumberData());
            }
            UserClient.Send("DrawCard_Update_Card", GetCurrentCardData());
        }