Exemplo n.º 1
0
        private static int AddBanDescription(PlayerInstance ch, string arg1, string arg2, int duration, BanTypes type)
        {
            var ban = ch.DestinationBuffer.CastAs <BanData>();

            if (ban == null)
            {
                LogManager.Instance.Bug("Null DestinationBuffer for character {0}", ch.Name);
                ch.SubState = CharacterSubStates.None;
                return(0);
            }

            if (!ban.Note.IsNullOrWhitespace())
            {
                ban.Note = string.Empty;
            }

            //ban.Note = build.copy_buffer(ch);
            //build.stop_editing(ch);

            ch.SubState = EnumerationExtensions.GetEnum <CharacterSubStates>(ch.tempnum);
            BanManager.Instance.Repository.Add(ban);

            if (ban.Duration > 0)
            {
                ch.Printf("{0} is banned for {1} days.\r\n", ban.Name, ban.Duration / 86400);
            }
            else
            {
                ch.Printf("{0} is banned forever.\r\n", ban.Name);
            }

            return(1);
        }
Exemplo n.º 2
0
        public static void InitializeWeatherData(string filename)
        {
            using (var proxy = new TextReaderProxy(new StreamReader(filename)))
            {
                while (!proxy.EndOfStream)
                {
                    var line  = proxy.ReadLine().TrimEnd('~');
                    var words = line.Split(',');

                    var hemisphere = EnumerationExtensions.GetEnum <HemisphereTypes>(words[0]
                                                                                     .EqualsIgnoreCase("north") ? 0 : 1);
                    var season  = EnumerationExtensions.GetEnum <SeasonTypes>(words[1]);
                    var climate = EnumerationExtensions.GetEnum <ClimateTypes>(words[2]);

                    var data = new WeatherRangeData(hemisphere, season, climate);

                    // 3/4 = Temperature Lo/HI
                    // 5/6 = Pressure Lo/HI
                    // 7/8 = CloudCover Lo/Hi
                    // 9/10 = Humidity Lo/Hi
                    // 11/12 = Precipitation Lo/HI
                    // 13/14 = Energy Lo/HI
                    // 15/16 = WindSpeed X Lo/HI
                    // 17/18 = WindSpeed Y Lo/HI

                    WeatherConstants.WeatherData.Add(data);
                }
            }
        }
        public async Task <GetWifiEventsResult> GetEvents(RestSession session, string objectId)
        {
            var headers = SessionToHeaders(session);

            var parameters = new Dictionary <string, string>
            {
                { "where", $"{{\"device\":{{\"__type\":\"Pointer\",\"className\":\"Device\",\"objectId\":\"{objectId}\"}}}}" }
            };

            var result = await _restService.SendRestGetRequest(GetWifiEventsLink, headers, parameters);

            if (result.Status == RestResponseStatus.Ok)
            {
                var message    = JsonSerializer.Deserialize <WifiEventMessage>(result.Data);
                var wifiEvents = message.WifiEvents.Select(row => new WifiEvent(EnumerationExtensions.GetEnumValueFromDescription <WifiEventType>(row.EventType), row.CreatedAt));

                return(new GetWifiEventsResult {
                    ResponseStatus = RestResponseStatus.Ok, WifiEvents = wifiEvents
                });
            }

            return(new GetWifiEventsResult {
                ResponseStatus = RestResponseStatus.Error
            });
        }
 public TaskAssignmentProfile()
 {
     CreateMap <AssignmentViewModel, Assignment>()
     .ForMember(m => m.Type, opt => opt.MapFrom(src => EnumerationExtensions.FromString <AssignmentEntityType>(src.Type)));
     CreateMap <AssignmentViewModel, ITaskAssignment>().As <Assignment>();
     CreateMap <ITaskAssignment, AssignmentViewModel>()
     .ForMember(m => m.Type, opt => opt.MapFrom(src => src.Type.ToString()));
 }
Exemplo n.º 5
0
 public void SetFlags(string flags)
 {
     string[] words = flags.Split(' ');
     foreach (string word in words)
     {
         Flags += (int)EnumerationExtensions.GetEnumIgnoreCase <AreaFlags>(word);
     }
 }
Exemplo n.º 6
0
 public TaskDependencyMappingProfile()
 {
     CreateMap <TaskDependencyViewModel, ITaskDependency>()
     .ForMember(m => m.Type, opt => opt.MapFrom(src => EnumerationExtensions.FromString <DependencyType>(src.Type)))
     .As <TaskDependency>();
     CreateMap <ITaskDependency, TaskDependencyViewModel>()
     .ForMember(m => m.Type, opt => opt.MapFrom(src => src.Type.ToString()));
 }
        public static void SetExtraFlags(this ObjectTemplate template)
        {
            var words = template.Flags.Split(' ');

            foreach (var word in words)
            {
                template.ExtraFlags.SetBit((int)EnumerationExtensions.GetEnum <ItemExtraFlags>(word));
            }
        }
Exemplo n.º 8
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="id"></param>
        /// <param name="name"></param>
        /// <param name="data"></param>
        /// <param name="def"></param>
        public Channel(long id, string name, DictionaryAtom data, Definition def)
            : base(id, name, def)
        {
            MemberRepository = new ChannelMemberRepository();

            Data        = data;
            OwnerId     = data.GetInt("OwnerID");
            ChannelType = EnumerationExtensions.GetEnum <Globals.ChannelTypes>(data.GetInt("ChannelTypeID"));
            Bits        = data.GetInt("Bits");
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="value"></param>
        /// <returns></returns>
        public static Globals.ElementTypes GetRight(this Globals.ElementTypes value)
        {
            var vals = value.GetExtraData().Split(':', ';');

            //Validation.Validate<InvalidDataException>(vals.All(x => !string.IsNullOrWhiteSpace(x)), ErrorResources.ERR_NULL_EXTRA_DATA, value.GetName());
            //Validation.Validate<InvalidDataException>(vals.Length >= 1, ErrorResources.ERR_NULL_EXTRA_DATA,
            //                                          value.GetName());

            return(EnumerationExtensions.GetEnum <Globals.ElementTypes>(Convert.ToInt32(vals[2]) - 1));
        }
Exemplo n.º 10
0
 public void SetType(string type)
 {
     try
     {
         Type = EnumerationExtensions.GetEnum <Globals.SpawnTypes>(type);
     }
     catch (ArgumentException)
     {
         Type = Globals.SpawnTypes.None;
     }
 }
Exemplo n.º 11
0
        /// <summary>
        /// Variable $W, long name of the wear location
        /// </summary>
        private string WearLocationLongName(ReportData data)
        {
            if (data.IsNull())
            {
                throw new ArgumentNullException(nameof(data), ErrorResources.ERR_NULL_PARAMETER);
            }

            var loc = data.IndirectObject as string;

            return(EnumerationExtensions.GetEnum <Globals.WearLocations>(loc).GetExtraData());
        }
Exemplo n.º 12
0
        public static MudProgData LuaCreateMudProg(string progType)
        {
            var newMudProg = new MudProgData
            {
                Type = EnumerationExtensions.GetEnumByName <MudProgTypes>(progType)
            };

            _luaManager.Proxy.CreateTable("mprog");
            AddLastObject(newMudProg);
            return(newMudProg);
        }
        public void GetEnumTest()
        {
            var result = EnumerationExtensions.GetEnum <EnumTest>("Test");

            result.Should().Be(EnumTest.Test);

            EnumTest.Test.GetName().Should().Be("Test");
            EnumTest.Test.GetValue().Should().Be(1);
            EnumTest.Test.GetShortName().Should().Be("Testing");
            EnumTest.Test.GetName().Should().Be("Test");
        }
        public void GetValuesTest()
        {
            var expectedList = new List <EnumTest> {
                EnumTest.All, EnumTest.Test, EnumTest.Test1, EnumTest.Test2
            };

            var values = EnumerationExtensions.GetValues <EnumTest>().ToList();

            values.Count().Should().Be(4);
            values.Should().BeEquivalentTo(expectedList);
        }
        private List <TopRandomSequencePerformance> RateAllRandomSequenceMethodsOverMultipleIterations(List <TopRandomSequencePerformance> topRandomSequencePerformances)
        {
            var allMethodsEvaluated =
                (from randomSequenceMethod in EnumerationExtensions.ToEnumList <RandomSequenceMethodCodes>()
                 let totalExecutionTimeInTicks = topRandomSequencePerformances
                                                 .Where(w => w.RandomSequenceMethodCode == randomSequenceMethod)
                                                 .Sum(s => s.TotalExecutionTime)
                                                 select new TopRandomSequencePerformance(randomSequenceMethod, totalExecutionTimeInTicks)).ToList();

            return(SortedTopRandomSequencePerformances(allMethodsEvaluated));
        }
Exemplo n.º 16
0
        public static LanguageData LuaCreateLanguage(string name, string type)
        {
            var newLang = new LanguageData(_dbManager.GenerateNewId <LanguageData>(), name,
                                           EnumerationExtensions.GetEnumIgnoreCase <LanguageTypes>(type));

            _luaManager.Proxy.CreateTable("lang");
            AddLastObject(newLang);
            _dbManager.AddToRepository(newLang);

            _logManager.Boot("Language '{0}' created", name);
            return(newLang);
        }
Exemplo n.º 17
0
        public static int LoadSystemFilesFromConfig()
        {
            var section    = (SystemDataConfigurationSection)ConfigurationManager.GetSection("SystemDataSection");
            var collection = section.SystemFiles;

            foreach (SystemFileElement element in collection)
            {
                var fileType = EnumerationExtensions.GetEnum <SystemFileTypes>(element.Name);
                SystemFiles.Add(fileType, new KeyValuePair <string, bool>(element.Filename, element.UseSystemFolder));
            }

            return(SystemFiles.Count);
        }
Exemplo n.º 18
0
        public static int LoadSystemDirectoriesFromConfig(string path)
        {
            var section    = (SystemDataConfigurationSection)ConfigurationManager.GetSection("SystemDataSection");
            var collection = section.SystemDirectories;

            foreach (SystemDirectoryElement element in collection)
            {
                var dirType = EnumerationExtensions.GetEnum <SystemDirectoryTypes>(element.Name);
                SystemDirectories.Add(dirType, path + "\\" + element.Path);
            }

            return(SystemDirectories.Count);
        }
Exemplo n.º 19
0
        public void OpenTab(EditorBrowseInfo browseInfo, bool openCopy, bool makeDirty)
        {
            if (browseInfo == null)
            {
                throw new ArgumentNullException(nameof(browseInfo), Resources.NullParameterErrorMessage);
            }

            TabPage page = null;

            // If we are not opening a copy, always create a new page and do not use an already open page.
            if (!openCopy)
            {
                page = FindTab(browseInfo.SystemType, browseInfo.Id);
            }

            if (page != null)
            {
                tabContent.SelectedTab = page;
            }
            else
            {
                var builder = EditorFactory.Builders[EnumerationExtensions.GetEnum <SystemTypes>((int)browseInfo.SystemType)];
                if (!builder.HasEditor())
                {
                    return;
                }

                // Create a new edit control based on the selected node
                var editControl =
                    EditorFactory.Create(EnumerationExtensions.GetEnum <SystemTypes>((int)browseInfo.SystemType),
                                         browseInfo.ClassId);

                // Initialize the new control with the content that was dclicked
                editControl.InitContent(browseInfo.Id);
                var tabName = editControl.ControlName;
                if (openCopy)
                {
                    editControl.MakeCopy();
                    tabName = "*" + editControl.ControlName + "*";
                }
                else if (makeDirty)
                {
                    editControl.MakeDirty();
                    tabName = "*" + editControl.ControlName + "*";
                }

                tabName = $"[{editControl.Id}] {tabName}";

                CreateContentTab(tabName, editControl);
            }
        }
Exemplo n.º 20
0
        public static ClassData LuaCreateClass(string name, int type)
        {
            var newClass = new ClassData(_dbManager.GenerateNewId <ClassData>(), name)
            {
                Type = EnumerationExtensions.GetEnum <ClassTypes>(type)
            };

            _luaManager.Proxy.CreateTable("class");
            AddLastObject(newClass);
            _dbManager.AddToRepository(newClass);

            _logManager.Boot("Class '{0}' created", name);
            return(newClass);
        }
Exemplo n.º 21
0
        public static void LoadSystemDirectoriesFromDataFile(string path)
        {
            using (var proxy = new TextReaderProxy(new StreamReader(path + "\\SystemDirectories.txt")))
            {
                while (!proxy.EndOfStream)
                {
                    var line  = proxy.ReadLine().TrimEnd('~');
                    var words = line.Split(',');

                    var dirType = EnumerationExtensions.GetEnum <SystemDirectoryTypes>(words[0]);
                    SystemDirectories.Add(dirType, path + "\\" + words[1]);
                }
            }
        }
Exemplo n.º 22
0
        public static void InitializeWeatherMessages(string filename)
        {
            using (var proxy = new TextReaderProxy(new StreamReader(filename)))
            {
                IEnumerable <TextSection> sections = proxy.ReadSections(new[] { "#" }, null, null, "#END");
                foreach (var section in sections)
                {
                    var lines = new List <string>();
                    section.Lines.ToList().ForEach(x => lines.Add(x.TrimEnd('~')));

                    WeatherMessages.Add(EnumerationExtensions.GetEnum <PrecipitationTypes>(section.Header), lines);
                }
            }
        }
Exemplo n.º 23
0
        public static RaceData LuaCreateRace(string name, int type)
        {
            var newRace = new RaceData(_dbManager.GenerateNewId <RaceData>(), name)
            {
                Type = EnumerationExtensions.GetEnum <RaceTypes>(type)
            };

            _luaManager.Proxy.CreateTable("race");
            AddLastObject(newRace);
            _dbManager.AddToRepository(newRace);

            _logManager.Boot("Race '{0}' created", name);
            return(newRace);
        }
Exemplo n.º 24
0
 public static ExitData EXIT(Instance instance, int door)
 {
     if (instance is ObjectInstance)
     {
         var obj = instance as ObjectInstance;
         return(obj.InRoom.GetExit(EnumerationExtensions.GetEnum <DirectionTypes>(door)));
     }
     if (instance is CharacterInstance)
     {
         var ch = instance as CharacterInstance;
         return(ch.CurrentRoom.GetExit(EnumerationExtensions.GetEnum <DirectionTypes>(door)));
     }
     return(null);
 }
Exemplo n.º 25
0
        public bool DrawChord(string chord, out string svg, int cursorWidth = 0, int cursorHeight = 0)
        {
            SVGContent = string.Empty;
            svg        = string.Empty;

            if (Options.DisplayLabel)
            {
                // Nom accord
                SVGContent += "<text x=\"" + (cursorWidth + (Options.Width / 2)) + "\" y=\"" + (cursorHeight + 5) + "\" font-family=\"" + Options.Typeface + "\" font-size=\"17\" fill=\"black\" text-anchor=\"middle\">" + chord + "</text>";
            }

            // ligne haut

            SVGContent += "<line x1=\"" + (cursorWidth + 5) + "\" y1=\"" + (cursorHeight + 25) + "\" x2=\"" + (cursorWidth + 105) + "\" y2=\"" + (cursorHeight + 25) + "\" stroke=\"" + Options.StringColor + "\" stroke-width=\"3\" fill=\"" + Options.StringColor + "\"></line>";

            // lignes guitare

            for (int i = 0; i < 6; i++)
            {
                SVGContent += "<line x1=\"" + (cursorWidth + 5 + i * 20) + "\" y1=\"" + (cursorHeight + 25) + "\" x2=\"" + (cursorWidth + 5 + i * 20) + "\" y2=\"" + (cursorHeight + 145) + "\" stroke=\"" + Options.StringColor + "\" stroke-width=\"1\" fill=\"" + Options.StringColor + "\"></line>";
            }

            // Frets

            for (int i = 0; i < 4; i++)
            {
                SVGContent += "<line x1=\"" + (cursorWidth + 5) + "\" y1=\"" + (cursorHeight + 55 + i * 30) + "\" x2=\"" + (cursorWidth + 105) + "\" y2=\"" + (cursorHeight + 55 + i * 30) + "\" stroke=\"" + Options.StringColor + "\" stroke-width=\"1\" fill=\"" + Options.StringColor + "\"></line>";
            }

            try
            {
                AddFingersPositions(EnumerationExtensions.GetValueFromDisplayShortName <GuitarChordEnum>(chord).GetDisplayDescription(), cursorWidth, cursorHeight);
                //TODO here: remove the enum to a file system


                svg = SVGContent;
                return(true);
            }
            catch (Exception)
            {
            }
            finally
            {
                SVGContent = string.Empty;
            }

            return(false);
        }
Exemplo n.º 26
0
        public static ResetData LuaCreateReset(string resetType, int extra, int arg1, int arg2, int arg3)
        {
            var newReset = new ResetData
            {
                Type  = EnumerationExtensions.GetEnumIgnoreCase <ResetTypes>(resetType),
                Extra = extra
            };

            newReset.SetArgs(arg1, arg2, arg3);

            _luaManager.Proxy.CreateTable("reset");
            AddLastObject(newReset);

            _logManager.Boot("Reset '{0}' created", resetType);
            return(newReset);
        }
Exemplo n.º 27
0
        public static void LoadSystemFilesFromDataFile(string path)
        {
            using (var proxy = new TextReaderProxy(new StreamReader(path + "\\SystemFiles.txt")))
            {
                while (!proxy.EndOfStream)
                {
                    var line  = proxy.ReadLine().TrimEnd('~');
                    var words = line.Split(',');

                    var fileType           = EnumerationExtensions.GetEnum <SystemFileTypes>(words[0]);
                    var useSystemDirectory = Convert.ToBoolean(BooleanConstants.ContainsIgnoreCase(words[2]));

                    SystemFiles.Add(fileType, new KeyValuePair <string, bool>(words[1], useSystemDirectory));
                }
            }
        }
Exemplo n.º 28
0
        public static ExitData LuaCreateExit(string direction, long destination, string name)
        {
            var dir     = EnumerationExtensions.GetEnumIgnoreCase <DirectionTypes>(direction);
            var newExit = new ExitData((int)dir, name)
            {
                Destination = destination,
                Direction   = dir,
                Keywords    = direction
            };

            _luaManager.Proxy.CreateTable("exit");
            AddLastObject(newExit);

            _logManager.Boot("Exit '{0}' created in direction {1} to room {2}", name, direction, destination);
            return(newExit);
        }
Exemplo n.º 29
0
        private static void RaiseVictimLevel(CharacterInstance ch, CharacterInstance victim, int level)
        {
            ch.Printf("Raising %s from level %d to level %d!", victim.Name, victim.Level, level);
            if (victim.Level >= LevelConstants.AvatarLevel)
            {
                victim.SetColor(ATTypes.AT_WHITE);
                comm.act(ATTypes.AT_IMMORT, "$n makes some arcane gestures with $s hands, then points $s finger at you!",
                         ch, null, victim, ToTypes.Victim);
                comm.act(ATTypes.AT_IMMORT, "$n makes some arcane gestures with $s hands, then points $s finger at $N!",
                         ch, null, victim, ToTypes.NotVictim);
                victim.SetColor(ATTypes.AT_WHITE);
                victim.SendTo("You suddenly feel very strange...");
                victim.SetColor(ATTypes.AT_LBLUE);
            }

            try
            {
                var immortalType = EnumerationExtensions.GetEnum <ImmortalTypes>(level);

                var attrib = Common.EnumerationExtensions.GetAttribute <ImmortalHelpCategoryAttribute>(immortalType);
                if (attrib != null)
                {
                    Help.do_help(victim, attrib.Value);
                }
                else
                {
                    victim.SendTo("The gods feel fit to raise your level!");
                }

                if (immortalType != ImmortalTypes.Immortal)
                {
                    return;
                }

                victim.SetColor(ATTypes.AT_WHITE);
                victim.SendTo("You awake... all your possessions are gone.");
                while (victim.Carrying.Any())
                {
                    var objInstance = victim.Carrying.FirstOrDefault();
                    objInstance?.Extract();
                }
            }
            catch (ArgumentException)
            {
                victim.SendTo("The gods feel fit to raise your level!");
            }
        }
Exemplo n.º 30
0
        public static SpellComponent LuaCreateSpellComponent(string requiredType, string data, string operatorType)
        {
            var newComponent = new SpellComponent
            {
                RequiredType = EnumerationExtensions.GetEnumByName <ComponentRequiredTypes>(requiredType),
                RequiredData = data
            };

            if (!operatorType.IsNullOrEmpty())
            {
                newComponent.OperatorType = EnumerationExtensions.GetEnumByName <ComponentOperatorTypes>(operatorType);
            }

            _luaManager.Proxy.CreateTable("component");
            AddLastObject(newComponent);
            return(newComponent);
        }