Exemple #1
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);
        }
Exemple #2
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;
            }
            }
        }
Exemple #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;
            }
        }
 /// <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);
 }
        public void AddToListCollection(string value)
        {
            this.EntryList.Items.Add(value);

            List <StringBuilder> temp = ParserTools.ParseCode((string)value, ':');

            if (temp.Count < 2)
            {
                throw new FunctionControlException("Error parsing map entries passed to AddListCollection() function of " + this.FunctionName);
            }
            Mapping.Add(temp[0].ToString(), temp[1].ToString());
        }
Exemple #6
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;
                    }
                }
            }
        }
Exemple #7
0
        private string ControlIntoORList()
        {
            List <string> array = new List <string>();

            foreach (string key in Mapping.Keys)
            {
                if (Mapping[key] == "1")
                {
                    array.Add(key);
                }
            }

            return(ParserTools.ORListIntoString(array));
        }
Exemple #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)
        {
            EntryList.Items.Clear();
            Entry.Text = "";

            if (this.ParameterType == FuncParamType.Array)
            {
                List <string> temp = ParserTools.StringIntoArray(entry, this.FunctionName);
                ListIntoControl(temp);
            }

            if (this.ParameterType == FuncParamType.ORList)
            {
                List <string> temp = ParserTools.StringIntoORList(entry, this.FunctionName);
                ListIntoControl(temp);
            }
        }
        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);
            }
        }
Exemple #10
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;
                    }
                }
            }
        }
Exemple #11
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;
            }
        }
Exemple #12
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));
            }
        }
Exemple #13
0
 private string ControlIntoArray()
 {
     return(ParserTools.ArrayIntoString(this.Array));
 }
        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;
        }
Exemple #15
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;

            //is it a gun?
            if (CheckParams(inherits, "inherit LIB_FIREARM;") != null)
            {
                //check firearm damage
                string gunDamage = CheckParams(functions, "SetGunClass");
                if (gunDamage != null)
                {
                    totalCost += 10 * Convert.ToInt32(gunDamage);
                }

                //reduced melee value
                string meleeDamage = CheckParams(functions, "SetClass");
                if (meleeDamage != null)
                {
                    totalCost += 2 * Convert.ToInt32(meleeDamage);
                }

                //tally up number of damagetypes for gun
                string damageType = CheckParams(functions, "SetGunDamageType");
                if (damageType != null)
                {
                    foreach (string value in ParserTools.StringIntoORList(damageType, agentName))
                    {
                        //adds 12 for each type of damage it does
                        totalCost += 12;
                    }
                }

                string hp = CheckParams(functions, "SetDamagePoints");
                if (hp != null)
                {
                    totalCost += (int)System.Math.Round((double)Convert.ToDouble(hp) * HpValue);
                }

                string accuracy = CheckParams(functions, "SetAccuracy");
                if (accuracy != null)
                {
                    totalCost -= 5 * (100 - Convert.ToInt32(accuracy));
                }

                string accuracyDrop = CheckParams(functions, "SetAccuracyDropoff");
                if (accuracyDrop != null)
                {
                    totalCost -= Convert.ToInt32(accuracyDrop);
                }
            }



            //else, is it ammo?
            else if (CheckParams(inherits, "inherit LIB_MAGAZINE;") != null)
            {
                string damageType = CheckParams(functions, "SetDamageTypeBonus");
                if (damageType != null)
                {
                    foreach (string value in ParserTools.StringIntoORList(damageType, agentName))
                    {
                        totalCost += 1;
                    }
                }


                //we assume that if there is more than one for max ammo, that it is a clip
                //and if there is only one, it is a round
                string maxAmmo = CheckParams(functions, "SetMaxAmmo");
                if (maxAmmo != null)
                {
                    int ammo = Convert.ToInt32(maxAmmo);
                    //round based
                    if (ammo == 1)
                    {
                        totalCost += 1;
                        double AccuracyBonusValue = 0.10;
                        double ClassBonusValue    = 0.10;

                        string classBonus = CheckParams(functions, "SetClassBonus");
                        if (classBonus != null)
                        {
                            totalCost += (int)System.Math.Floor((double)Convert.ToDouble(classBonus) * ClassBonusValue);
                        }

                        string accuracyBonus = CheckParams(functions, "SetAccuracyBonus");
                        if (accuracyBonus != null)
                        {
                            totalCost += (int)System.Math.Floor((double)Convert.ToDouble(accuracyBonus) * AccuracyBonusValue);
                        }
                    }
                    //magazine based
                    else
                    {
                        totalCost += (int)System.Math.Round((double)ammo * (double)0.4f);
                        double AccuracyBonusValue = 0.5;
                        double ClassBonusValue    = 0.5;

                        string classBonus = CheckParams(functions, "SetClassBonus");
                        if (classBonus != null)
                        {
                            totalCost += (int)System.Math.Floor((double)Convert.ToDouble(classBonus) * ClassBonusValue);
                        }

                        string accuracyBonus = CheckParams(functions, "SetAccuracyBonus");
                        if (accuracyBonus != null)
                        {
                            totalCost += (int)System.Math.Floor((double)Convert.ToDouble(accuracyBonus) * AccuracyBonusValue);
                        }
                    }
                }
            }



            //must be a regular item, maybe a weapon?
            else
            {
                //otherwise check melee at regular value
                string meleeDamage = CheckParams(functions, "SetClass");
                if (meleeDamage != null)
                {
                    totalCost += 8 * Convert.ToInt32(meleeDamage);
                }

                //tally up number of damagetypes for gun
                string damageType = CheckParams(functions, "SetDamageType");
                if (damageType != null)
                {
                    foreach (string value in ParserTools.StringIntoORList(damageType, agentName))
                    {
                        //adds 12 for each type of damage it does
                        totalCost += 12;
                    }
                }

                //is it a weapon?
                if (Convert.ToInt32(meleeDamage) > 1)
                {
                    string hp = CheckParams(functions, "SetDamagePoints");
                    if (hp != null)
                    {
                        totalCost += (int)System.Math.Round((double)Convert.ToDouble(hp) * HpValue);
                    }
                }
            }



            if (CheckParams(inherits, "inherit LIB_STORAGE;") != null)
            {
                string carry = CheckParams(functions, "SetMaxCarry");

                //divide by ten since weights are in hundreths of a pound
                if (carry != null)
                {
                    totalCost += 2 * 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;
            }



            this.SetBaseCost.EntryValue = totalCost;
            return;
        }
Exemple #16
0
 private string ControlIntoMap()
 {
     return(ParserTools.MapIntoString(Mapping));
 }
Exemple #17
0
 private string ControlIntoORList()
 {
     return(ParserTools.ORListIntoString(this.Array));
 }