Esempio n. 1
0
        public override void PushEntry(string entry)
        {
            List <string> list;

            switch (this.ParamType)
            {
            case FuncParamType.Array:
            {
                list = ParserTools.StringIntoArray(entry, this.FunctionName);
                ListIntoControl(list);
                break;
            }

            case FuncParamType.ORList:
            {
                list = ParserTools.StringIntoORList(entry, this.FunctionName);
                ListIntoControl(list);
                break;
            }

            case FuncParamType.Mapping:
            {
                Dictionary <string, string> pairs = ParserTools.StringIntoMap(entry, this.FunctionName);
                PairsIntoControl(pairs);
                break;
            }
            }
        }
Esempio n. 2
0
        public List <string> CopyStaticItemsFromControl(MapBuilder itemsControl)
        {
            //list all static items
            string param = itemsControl.PullEntry();
            Dictionary <string, string> entries = ParserTools.StringIntoMap(param, "RoomEditorState.CopyStaticItemsFromControl()");
            List <string> list = new List <string>(20);

            foreach (string item in entries.Keys)
            {
                list.Add(ParserTools.ProcessInputText(item, EntryType.Mixed));
            }

            List <string> StaticInteractions = new List <string>(20);
            List <string> Exits = new List <string>(20);
            List <string> Doors = new List <string>(5);


            //copy the data to the room
            StaticInteractions.Add("default");
            StaticInteractions.AddRange(list);
            this.InteractiveStaticItems.Clear();
            this.InteractiveStaticItems.AddRange(StaticInteractions);

            this.EnterableItems.Clear();
            this.EnterableItems.AddRange(list);

            Exits.AddRange(new string[] { "north", "south", "east", "west", "northwest", "northeast", "southwest", "southeast", "up", "down", "out" });
            Exits.AddRange(list);
            this.ExitItems.Clear();
            this.ExitItems.AddRange(Exits);
            //this.ExitItems.AddRange(this.SetExits.KeyCollection);

            return(list);
        }
Esempio n. 3
0
        /// <summary>
        /// Obtains values from parsed LPC code and applies them to
        /// the room model's data.
        /// </summary>
        /// <param name="?"></param>
        private void PullDataFromCode()
        {
            //first, find main function
            Parser.Token body = this.Code.GetFunctionBody("create");
            if (body == null)
            {
                MessageBox.Show("DEBUG ERROR: Room model's code failed to load properly. The 'create' function body was not found.");
                return;
            }

            //don't assume we have children in the function body
            if (body.Children.Count < 2)
            {
                MessageBox.Show("DEBUG ERROR: Missing function body for 'create'. The Parser has mismatched token children.");
                return;
            }

            //build a list of all function calls found in the LPC object
            Dictionary <string, Parser.Token> list = this.Code.GetAllFunctionCalls(body);

            //update all function call controls if they have matching info from the aforementioned list
            foreach (string dataCall in list.Keys)
            {
                const int FUNCTION_PARAMS = 0;
                if (list.ContainsKey(dataCall))
                {
                    StringBuilder str = new StringBuilder("");

                    //can't use foreach because some children may be null
                    for (int index = 0; index < list[dataCall].Children.Count; index++)
                    {
                        if (list[dataCall].Children != null && list[dataCall].Children[FUNCTION_PARAMS] != null)
                        {
                            str.Append(list[dataCall].Children[FUNCTION_PARAMS][index].Code);
                        }
                    }
                    this.FunctionCalls.DefineCall(dataCall, str.ToString());
                }
            }

            //update exists and enters list
            if (this.FunctionCalls.CallList.ContainsKey("SetExits"))
            {
                this.EditorState.ExitsList = ParserTools.StringIntoMap(this.FunctionCalls.CallList["SetExits"], "SetExits");
            }
            if (this.FunctionCalls.CallList.ContainsKey("SetEnters"))
            {
                this.EditorState.EntersList = ParserTools.StringIntoMap(this.FunctionCalls.CallList["SetEnters"], "SetEnters");
            }

            //check for evidence that the room supports day/night settings for light or long descriptions
            if (this.FunctionCalls.CallList.ContainsKey("SetDayLong") ||
                this.FunctionCalls.CallList.ContainsKey("SetNightLong") ||
                this.FunctionCalls.CallList.ContainsKey("SetDayLight") ||
                this.FunctionCalls.CallList.ContainsKey("SetNightLight"))
            {
                this.EditorState.UseDayNight = true;
            }
        }
Esempio n. 4
0
 /// <summary>
 /// Parses a string into it's component parts for use in the control's native format.
 /// </summary>
 public override void PushEntry(string entry)
 {
     Key.Text   = "";
     Value.Text = "";
     EntryList.Items.Clear();
     Mapping.Clear();
     Mapping = ParserTools.StringIntoMap(entry, this.FunctionName);
     PairsIntoControl(Mapping);
 }
Esempio n. 5
0
        public void RemoveExitFromRoom(string targetRoom, string exitToPath)
        {
            if (targetRoom == "" || exitToPath == "")
            {
                return;
            }
            string    targetFunction = "SetExits";
            RoomModel room           = RoomNameMap[targetRoom];

            //first order of business is to see if we even have any exits defined
            if (room.FunctionCalls.CallList.ContainsKey(targetFunction))
            {
                //function is defined. now, is the exit present?
                string mapping = room.FunctionCalls.CallList[targetFunction];
                if (mapping.Contains(exitToPath))
                {
                    //ok, we know the exit is here. Now we just need to find and remove it.
                    //Note, there can be more than one.
                    try
                    {
                        Dictionary <string, string> map     = ParserTools.StringIntoMap(mapping, targetFunction);
                        Dictionary <string, string> rebuild = new Dictionary <string, string>();

                        foreach (string key in map.Keys)
                        {
                            //if(map[key] != exitToPath)
                            //    {
                            //    //only add entries that aren't to be removed
                            //    rebuild.Add(key,map[key]);
                            //    }
                            //J.C. -2/16/2010 - changed to remove entry based on exit direction rather than
                            //                  exit destination. That way we don't remove multiple entries
                            //                  when the user indented only one.
                            if (key != "\"" + exitToPath + "\"")
                            {
                                rebuild.Add(key, map[key]);
                            }
                        }

                        room.EditorState.ExitsList = rebuild;
                        room.FunctionCalls.CallList[targetFunction] = ParserTools.MapIntoString(rebuild);
                    }
                    catch (ParserException e)
                    {
                        System.Windows.Forms.MessageBox.Show(e.Message, ParserErrorTitle);
                        return;
                    }
                }
            }
        }
Esempio n. 6
0
        private void RemoveEntry_Click(object sender, EventArgs e)
        {
            if (EntryList.SelectedItem != null)
            {
                string entry = (string)EntryList.SelectedItem;
                Dictionary <string, string> temp = ParserTools.StringIntoMap("([" + entry + "])", this.FunctionName + "Control.RemoveEntry()");
                Dictionary <string, string> .KeyCollection.Enumerator iter = temp.Keys.GetEnumerator();
                iter.MoveNext();
                Mapping.Remove(iter.Current);

                EntryList.Items.Remove(EntryList.SelectedItem);
                this.PostUpdate(this, null);
            }
            else
            {
                Utility.MessageBeep(Utility.MB_OK);
            }
        }
Esempio n. 7
0
        public void RemoveEnterFromRoom(string targetRoom, string exitToPath)
        {
            if (targetRoom == "" || exitToPath == "")
            {
                return;
            }
            string    targetFunction = "SetEnters";
            RoomModel room           = RoomNameMap[targetRoom];

            //first order of business is to see if we even have any exits defined
            if (room.FunctionCalls.CallList.ContainsKey(targetFunction))
            {
                //function is defined. now, is the exit present?
                string mapping = room.FunctionCalls.CallList[targetFunction];
                if (mapping.Contains(exitToPath))
                {
                    //ok, we know the exit is here. Now we just need to find and remove it
                    //Note, there can be more than one.
                    try
                    {
                        Dictionary <string, string> map     = ParserTools.StringIntoMap(mapping, targetFunction);
                        Dictionary <string, string> rebuild = new Dictionary <string, string>();

                        foreach (string key in map.Keys)
                        {
                            if (map[key] != exitToPath)
                            {
                                //only add entries that aren't to be removed
                                rebuild.Add(key, map[key]);
                            }
                        }

                        room.EditorState.EntersList = rebuild;
                        room.FunctionCalls.CallList[targetFunction] = ParserTools.MapIntoString(rebuild);
                    }
                    catch (ParserException e)
                    {
                        System.Windows.Forms.MessageBox.Show(e.Message, ParserErrorTitle);
                        return;
                    }
                }
            }
        }
Esempio n. 8
0
        /// <summary>
        /// Parses a string into it's component parts for use in the control's native format.
        /// </summary>
        public override void PushEntry(string entry)
        {
            object[] tempCol = new object[EntryList.Items.Count];
            Dictionary <string, string> tempMap = Mapping;

            EntryList.Items.CopyTo(tempCol, 0);

            Key.Text   = "";
            Value.Text = "";
            EntryList.Items.Clear();
            Mapping.Clear();

            try{
                Mapping = ParserTools.StringIntoMap(entry, this.FunctionName);
                PairsIntoControl(Mapping);
            }
            catch (ParserException e)
            {
                EntryList.Items.AddRange(tempCol);
                throw e;
            }
        }
Esempio n. 9
0
        public void AddEnterToRoom(string targetRoom, string exitToPath, string direction)
        {
            if (targetRoom == "" || exitToPath == "" || direction == "")
            {
                return;
            }
            if (targetRoom == exitToPath)
            {
                System.Windows.Forms.MessageBox.Show("You cannot have " + targetRoom + " enter into itself.");
                return;
            }
            string    targetFunction = "SetEnters";
            RoomModel room           = RoomNameMap[targetRoom];

            //first order of business is to make sure we even have the
            //function call for an exit, otherwise we need to create it
            if (room.FunctionCalls.CallList.ContainsKey(targetFunction))
            {
                //function call exists. Do we already have an entry for this direction?
                try
                {
                    Dictionary <string, string> map = ParserTools.StringIntoMap(room.FunctionCalls.CallList[targetFunction], targetFunction);
                    if (map.ContainsKey(direction))
                    {
                        //we have to edit a pre-existing entry
                        foreach (string key in map.Keys)
                        {
                            if (key == direction)
                            {
                                map[key] = exitToPath;
                                room.EditorState.EntersList = map;
                                room.FunctionCalls.CallList[targetFunction] = ParserTools.MapIntoString(map);
                                return;
                            }
                        }
                    }
                    else
                    {
                        //entry does not exist, create it now
                        map.Add(direction, exitToPath);
                        room.EditorState.EntersList = map;
                        room.FunctionCalls.CallList[targetFunction] = ParserTools.MapIntoString(map);
                        return;
                    }
                }
                catch (ParserException e)
                {
                    System.Windows.Forms.MessageBox.Show(e.Message, ParserErrorTitle);
                }
            }
            else
            {
                //we are storing this function call for the first time
                //TODO: Implement this
                //throw new Exception("Function doesn not exist in this control. TODO: Implement Model.AddExitToRoom()");
                Dictionary <string, string> map = new Dictionary <string, string>();
                map.Add(direction, exitToPath);
                room.EditorState.EntersList = map;
                room.FunctionCalls.CallList.Add(targetFunction, ParserTools.MapIntoString(map));
            }
        }
Esempio n. 10
0
        private void CalculateCost_Click(object sender, EventArgs e)
        {
            string agentName = "CreateItemForm->CalculatCost_Click";
            List <IFunctionControl> functionControls = this.Manager.CompileFunctionControlsList(this);
            FunctionCallsCollection functions        = this.Manager.CompileFunctioCallsList(functionControls);
            FunctionCallsCollection inherits         = this.Manager.CompileIheritList(functionControls);
            double HpValue = 0.15;


            int totalCost = 0;

            string protections = CheckParams(functions, "SetProtections");

            if (protections != null)
            {
                foreach (string v in ParserTools.StringIntoMap(protections, agentName).Values)
                {
                    totalCost += 8 * Convert.ToInt32(v);
                }
            }

            //if total cost is already over 8 (due to armor costs) we know this is an armor so at that
            //point we will start charging for the armor's hp as well
            if (totalCost > 8)
            {
                string hp = CheckParams(functions, "SetDamagePoints");
                if (hp != null)
                {
                    totalCost += (int)System.Math.Round((double)Convert.ToDouble(hp) * HpValue);
                }
            }

            if (CheckParams(inherits, "inherit LIB_WORN_STORAGE;") != null)
            {
                string carry = CheckParams(functions, "SetMaxCarry");
                //divide by ten since weights are in hundreths of a pound
                if (carry != null)
                {
                    totalCost += 3 * Convert.ToInt32(carry) / 10;
                }
            }

            //divide by ten since weights are in hundreths of a pound
            string mass = CheckParams(functions, "SetMass");

            if (mass != null)
            {
                totalCost -= Convert.ToInt32(mass) / 10;
            }


            if (CheckParams(inherits, "inherit LIB_SPACESUIT;") != null)
            {
                totalCost += 5000;
            }

            if (CheckParams(inherits, "inherit LIB_ZURAKIGLOVES;") != null)
            {
                totalCost += 250;
            }


            this.SetBaseCost.EntryValue = totalCost;

            return;
        }