Beispiel #1
0
        // Makes important categories accessible directly through a property in the WorldState.
        private static void PutCategoriesIntoVariables(Dictionary <AttribsCategory, Attribs> stateVariables, WorldState state)
        {
            AttribsCategory journalist = (from x in stateVariables.Keys where x.Name == "Journalist" select x).First();

            Debug.Assert(journalist != null, "The list of attributes does not contain the Journalist category.");
            state.JournalistState = stateVariables[journalist];
        }
Beispiel #2
0
        public static WorldState CreateWorldState(string attributesDefinitionPath = Constants.AttributesDefinitionLoc)
        {
            AttributesDefinition attribsDef = XmlUtils.LoadAttributes(attributesDefinitionPath);
            Dictionary <AttribsCategory, Attribs> stateVariables = new Dictionary <AttribsCategory, Attribs>();

            Dictionary <string, Attrib> attribsByName = new Dictionary <string, Attrib>();

            foreach (var categoryDao in attribsDef.Categories)
            {
                var category   = new AttribsCategory(categoryDao.Name, categoryDao.Description);
                var attribsSet = new Attribs();
                stateVariables.Add(category, attribsSet);
                foreach (var attribDao in categoryDao.Attributes)
                {
                    var    color  = GetSliderColor(attribDao);
                    Attrib attrib = new Attrib(attribDao.Description)
                    {
                        IsDisplayed = attribDao.IsDisplayed,
                        Category    = category,
                        Color       = color
                    };

                    attribsByName.Add(attribDao.Name, attrib);
                    attribsSet[attrib] = attribDao.InitialValue;
                }
            }
            WorldState state = new WorldState {
                AllStates = stateVariables
            };

            Attribs.SetAttribsCollection(attribsByName);
            PutCategoriesIntoVariables(stateVariables, state);

            return(state);
        }
Beispiel #3
0
        private static WorldState CreateWorldState(int initialCredibility)
        {
            WorldState state           = new WorldState();
            var        journalistState = new Attribs();

            state.JournalistState = journalistState;
            var category = new AttribsCategory("journalist", "journalist states");

            Attribs.Credibility.Category = category;
            state.AllStates = new Dictionary <AttribsCategory, Attribs>()
            {
                { category, journalistState }
            };
            state.JournalistState[Attribs.Credibility] = initialCredibility;
            Attribs.SetAttribsCollection(new Dictionary <string, Attrib>()
            {
                { "Credibility", Attribs.Credibility }
            });
            return(state);
        }