示例#1
0
        public static void Execute(string topic, string[] queues, string[] retries)
        {
            try
            {
                Console.WriteLine("Executing...");

                var args = new List <object>();
                TopicOption.Validate(topic);
                QueuesOption.Validate(queues, args);
                RetriesOption.Validate(retries, args);

                Broker.Configuration
                .AddTopology <MultipleQueuesWithRetryTopologyFactory>(
                    topic, args.ToArray());

                var broker = Broker.GetInstance();
                broker.EnsureTopology(topic);

                Console.WriteLine($"Topic {topic} with multiple queues created successfully!");
            }
            catch (Exception e)
            {
                ExceptionHandler.Handle(e);
            }
        }
示例#2
0
    /// <summary>
    /// Returns TopicOption of the specified index from listOfOptions, null if a problem
    /// </summary>
    /// <param name="optionIndex"></param>
    /// <returns></returns>
    public TopicOption GetOption(int optionIndex)
    {
        TopicOption option = null;

        if (optionIndex >= 0 && optionIndex < listOfOptions.Count)
        {
            option = listOfOptions[optionIndex];
        }
        return(option);
    }
示例#3
0
        public static Command Setup()
        {
            var cmd = new Command(nameof(CreateSimpleQueue));

            TopicOption.AddIn(cmd);
            RetriesOption.AddIn(cmd);
            cmd.Handler = CommandHandler.Create <string, string[]>(Execute);

            return(cmd);
        }
示例#4
0
 /// <summary>
 /// Export all topic Options (specific fields only) to a file
 /// </summary>
 public void ExportTopicOptions()
 {
     TopicOption[] arrayOfOptions = GameManager.i.loadScript.arrayOfTopicOptions;
     if (arrayOfOptions != null)
     {
         int count = arrayOfOptions.Length;
         //create list of data
         string[] arrayOfData = new string[count * 2];
         for (int i = 0; i < count; i++)
         {
             TopicOption option = arrayOfOptions[i];
             if (option != null)
             {
                 arrayOfData[i * 2]     = option.name;
                 arrayOfData[i * 2 + 1] = option.news;
             }
             else
             {
                 Debug.LogErrorFormat("Invalid topicOption (Null) in arrayOfOptions[{0}]", i);
             }
         }
         //export list of data
         filename = "TopicOptionData.txt";
         if (File.Exists(filename) == true)
         {
             try { File.Delete(filename); }
             catch (Exception e) { Debug.LogErrorFormat("Failed to DELETE FILE \"{0}\', error \"{1}\"", filename, e.Message); }
         }
         //create new file
         try
         {
             File.WriteAllLines(filename, arrayOfData);
             Debug.LogFormat("[Fil] TextManager.cs -> ExportTopicOptions: \"{0}\" Exported{1}", filename, "\n");
         }
         catch (Exception e) { Debug.LogErrorFormat("Failed to write TEXT TO FILE \"{0}\", error \"{1}\"", filename, e.Message); }
     }
     else
     {
         Debug.LogError("Invalid arrayOfOptions (Null)");
     }
 }
示例#5
0
    /// <summary>
    /// private SubMethod for CheckTopicPool
    /// </summary>
    /// <param name="listOfOptions"></param>
    /// <returns></returns>
    private string CheckTopicOptions(List <TopicOption> listOfOptions)
    {
        StringBuilder builder = new StringBuilder();

        if (listOfOptions != null)
        {
            int count = listOfOptions.Count;
            if (count > 0)
            {
                for (int i = 0; i < count; i++)
                {
                    TopicOption option = listOfOptions[i];
                    if (option != null)
                    {
                        builder.AppendFormat("{0}optionName: {1}{2}", "\n", option.name, "\n");
                        builder.AppendFormat("tag: {0}{1}", option.tag, "\n");
                        builder.AppendFormat("text: {0}{1}", option.text, "\n");
                        if (option.storyInfo.Length > 0)
                        {
                            builder.AppendFormat("{0}{1}{2}", "\n", option.storyInfo, "\n");
                        }
                        if (option.storyTarget != null)
                        {
                            builder.AppendFormat("{0}{1}, \"{2}\", {3}, {4}{5}", "\n",
                                                 option.storyTarget.name, option.storyTarget.targetName, option.storyTarget.descriptorResistance, option.storyTarget.nodeArc.name, "\n");
                        }
                    }
                    else
                    {
                        Debug.LogWarningFormat("Invalid topicOption (Null) for listOfOptions[{0}]", i);
                    }
                }
            }
        }
        else
        {
            Debug.LogWarning("Invalid listOfOptions (Null)");
        }
        return(builder.ToString());
    }
示例#6
0
    /// <summary>
    /// Populates and returns a data package suitable for TopicUI. Returns null if a problem.
    /// </summary>
    /// <param name="item"></param>
    /// <returns></returns>
    private TopicUIData GetTopicData(TutorialItem item)
    {
        if (item != null)
        {
            int index, limit, count;

            //data package
            TopicUIData data = new TopicUIData();
            data.topicName            = item.tag;
            data.header               = item.query.queryHeader;
            data.text                 = item.query.queryText;
            data.isBoss               = false;
            data.nodeID               = -1;
            data.uiType               = TopicDecisionType.Tutorial;
            data.spriteMain           = GameManager.i.tutorialScript.tutorial.sprite;
            data.ignoreTooltipHeader  = string.Format("<size=120%>{0}</size>", GameManager.Formatt("Disappointed", ColourType.badText));
            data.ignoreTooltipMain    = "Yes, I am. Being able to make a decision is important, what's wrong with you?";
            data.ignoreTooltipDetails = string.Format("<size=115%>{0}</size>", GameManager.Formatt("I'll have to make it for you", ColourType.neutralText));
            if (item.query.queryType != null)
            {
                //query item type
                GameManager.i.tutorialScript.queryType = item.query.queryType;
                //Topic options
                TopicOption[] arrayOfTopicOptions = GameManager.i.tutorialScript.tutorial.arrayOfOptions;
                if (arrayOfTopicOptions != null)
                {
                    //ignore option
                    TopicOption ignoreOption = GameManager.i.tutorialScript.tutorial.ignoreOption;
                    if (ignoreOption != null)
                    {
                        //check there are four options and none are null
                        if (arrayOfTopicOptions.Length == maxOptions)
                        {
                            bool isProceed = true;
                            for (int i = 0; i < arrayOfTopicOptions.Length; i++)
                            {
                                if (arrayOfTopicOptions[i] == null)
                                {
                                    Debug.LogErrorFormat("Invalid topicOption (Null) for tutorial \"{0}\" arrayOfTopicOptions[{1}]", GameManager.i.tutorialScript.tutorial.name, i);
                                    isProceed = false;
                                }
                            }
                            if (isProceed == true)
                            {
                                //Tutorial options
                                List <TutorialOption> listOfTutorialOptions       = new List <TutorialOption>();
                                List <TutorialOption> listOfTutorialIgnoreOptions = new List <TutorialOption>();
                                //special cases where an Alt set of options may be needed
                                switch (item.query.queryType.name)
                                {
                                case "Name":
                                    switch (GameManager.i.playerScript.sex)
                                    {
                                    case ActorSex.Male:
                                        listOfTutorialOptions       = item.query.listOfOptions;
                                        listOfTutorialIgnoreOptions = item.query.listOfIgnoreOptions;
                                        break;

                                    case ActorSex.Female:
                                        listOfTutorialOptions       = item.query.listOfOptionsAlt;
                                        listOfTutorialIgnoreOptions = item.query.listOfIgnoreOptionsAlt;
                                        break;

                                    default: Debug.LogWarningFormat("Unrecognised ActorSex \"{0}\"", GameManager.i.playerScript.sex); break;
                                    }
                                    break;

                                default:
                                    listOfTutorialOptions       = item.query.listOfOptions;
                                    listOfTutorialIgnoreOptions = item.query.listOfIgnoreOptions;
                                    break;
                                }
                                count = listOfTutorialOptions.Count;
                                //create temp list by Value (will be deleting
                                List <TutorialOption> listOfTempOptions = new List <TutorialOption>(listOfTutorialOptions)
                                {
                                };
                                // - - - RANDOM
                                if (item.query.isRandomOptions == true)
                                {
                                    limit = Mathf.Min(maxOptions, count);
                                    //select up to four tutorial options randomly
                                    for (int i = 0; i < limit; i++)
                                    {
                                        index = Random.Range(0, listOfTempOptions.Count);
                                        TutorialOption optionTutorial = listOfTempOptions[index];
                                        if (optionTutorial != null)
                                        {
                                            //Get Topic options
                                            TopicOption optionTopic = arrayOfTopicOptions[i];
                                            optionTopic.tag           = optionTutorial.tag;
                                            optionTopic.textToDisplay = GameManager.i.topicScript.GetOptionString(optionTutorial.text);
                                            data.listOfOptions.Add(optionTopic);
                                            listOfTempOptions.RemoveAt(index);
                                        }
                                        else
                                        {
                                            Debug.LogWarningFormat("Invalid tutorialOption (Null) for isRandom listOfTempOptions[{0}]", index);
                                        }
                                    }
                                }
                                else
                                {
                                    // - - - NOT random, take first four options
                                    limit = Mathf.Min(maxOptions, count);
                                    for (int i = 0; i < limit; i++)
                                    {
                                        TutorialOption optionTutorial = listOfTempOptions[i];
                                        if (optionTutorial != null)
                                        {
                                            TopicOption optionTopic = arrayOfTopicOptions[i];
                                            optionTopic.tag           = optionTutorial.tag;
                                            optionTopic.textToDisplay = GameManager.i.topicScript.GetOptionString(optionTutorial.text);
                                            data.listOfOptions.Add(optionTopic);
                                        }
                                        else
                                        {
                                            Debug.LogWarningFormat("Invalid topicOption (Null) for normal listOfTempOptions[{0}]", i);
                                        }
                                    }
                                }
                                //IGNORE option
                                if (listOfTutorialIgnoreOptions != null)
                                {
                                    //needs to be one option (can be more but they are ignored)
                                    if (listOfTutorialIgnoreOptions.Count >= 1)
                                    {
                                        TutorialOption optionTutorial = listOfTutorialIgnoreOptions[0];
                                        if (optionTutorial != null)
                                        {
                                            data.listOfIgnoreEffects.Add(ignoreOption.listOfGoodEffects[0]);
                                            //ignore option data
                                            GameManager.i.tutorialScript.optionIgnoreTag = optionTutorial.tag;
                                        }
                                        else
                                        {
                                            Debug.LogWarning("Invalid topicOption (Null) for IGNORE listOfTempOptions[0]");
                                        }
                                    }
                                    else
                                    {
                                        Debug.LogWarningFormat("Invalid listOfIgnoreOptions (Empty) for topicItem \"{0}\"", item.name);
                                    }
                                }
                                else
                                {
                                    Debug.LogWarningFormat("Invalid listOfIgnoreOptions (Null) for topicItem \"{0}\"", item.name);
                                }
                                //option tooltips and optionNumber (ignore option done above)
                                for (index = 0; index < data.listOfOptions.Count; index++)
                                {
                                    TopicOption option = data.listOfOptions[index];
                                    if (option != null)
                                    {
                                        option.tooltipHeader = string.Format("<size=120%>{0}</size>", GameManager.Formatt(option.tag, ColourType.neutralText));
                                        option.tooltipMain   = GameManager.i.tutorialScript.GetTutorialTooltip(item.query.queryType);
                                        //reassign option number to be the position in the listOfOptions
                                        option.optionNumber = index;
                                        //set all options as Valid
                                        option.isValid = true;
                                        //copy data across to TutorialManager.cs fields
                                        switch (index)
                                        {
                                        case 0: GameManager.i.tutorialScript.option0Tag = option.tag; break;

                                        case 1: GameManager.i.tutorialScript.option1Tag = option.tag; break;

                                        case 2: GameManager.i.tutorialScript.option2Tag = option.tag; break;

                                        case 3: GameManager.i.tutorialScript.option3Tag = option.tag; break;

                                        default: Debug.LogWarningFormat("Invalid index \"{0}\"", index); break;
                                        }
                                    }
                                    else
                                    {
                                        Debug.LogWarningFormat("Invalid topicOption (Null) for data.listOfOptions[{0}]", index);
                                    }
                                }
                            }
                            return(data);
                        }
                        else
                        {
                            Debug.LogErrorFormat("Invalid arrayOfTopicOptions (records, has {0}, needs {1}) for tutorial \"{2}\"", arrayOfTopicOptions.Length, maxOptions, GameManager.i.tutorialScript.tutorial.name);
                        }
                    }
                    else
                    {
                        Debug.LogErrorFormat("Invalid ignoreOption (Null) for tutorial \"{0}\"", GameManager.i.tutorialScript.tutorial.name);
                    }
                }
                else
                {
                    Debug.LogError("Invalid tutorial.arrayOfOptions (Null)");
                }
            }
            else
            {
                Debug.LogWarning("Invalid (Tutorial) item (Null)");
            }
        }
        else
        {
            Debug.LogErrorFormat("Invalid queryType (Null) for TutorialItem \"{0}\"", item.name);
        }
        //fault condition
        return(null);
    }