Ejemplo n.º 1
0
        public static ZWaveDefinition Load(string path)
        {
            DefinitionConverter conv = new DefinitionConverter(path, null);

            conv.UpgradeConvert(false);
            var ret = conv.ZWaveDefinition;

            return(ret);
        }
Ejemplo n.º 2
0
        public void DefinitionConverter_Convert()
        {
            string definition = File.ReadAllText("Interop/Json/Files/TestDefinition.json");
            LanguageMatcherDefinition languageMatcherDefinition = JsonConvert.DeserializeObject <LanguageMatcherDefinition>(definition);

            LanguageMatcher           languageMatcher       = DefinitionConverter.Convert(languageMatcherDefinition);
            LanguageMatcherDefinition newLanguageDefinition = DefinitionConverter.Convert(languageMatcher);

            Assert.Equal(languageMatcherDefinition, newLanguageDefinition, new LanguageMatcherDefinitionComparer());
        }
Ejemplo n.º 3
0
        public static void Save(ZWaveDefinition zWaveDefinition, string path)
        {
            DefinitionConverter conv = new DefinitionConverter(null, null)
            {
                ZWaveDefinition = zWaveDefinition
            };

            conv.DowngradeConvert();
            conv.SaveZXmlDefinition(path);
        }
Ejemplo n.º 4
0
        private static void Main(string[] args)
        {
            Dictionary <string, List <string> > parsedArgs = GetCommandLineParameters(string.Join(" ", args));

            if (parsedArgs.Count == 0)
            {
                PrintHelpText();
                return;
            }

            string     definitionFile = GetDefinitionFile(parsedArgs);
            string     outputFolder   = GetOutputFolder(parsedArgs);
            OutputType outputType     = GetOutputType(parsedArgs);

            string definitionFileText;

            if (!string.IsNullOrEmpty(definitionFile))
            {
                definitionFileText = File.ReadAllText(definitionFile);
            }
            else
            {
                definitionFileText = Console.In.ReadToEnd();
                if (string.IsNullOrWhiteSpace(definitionFileText))
                {
                    throw new ArgumentException("A language defintion file is required.");
                }
            }

            try
            {
                LanguageMatcherDefinition languageMatcherModel = JsonConvert.DeserializeObject <LanguageMatcherDefinition>(definitionFileText);
                LanguageMatcher           languageMatcher      = DefinitionConverter.Convert(languageMatcherModel);

                MatcherClassGenerator generator = new MatcherClassGenerator(languageMatcher);

                if (outputType == OutputType.Assembly)
                {
                    generator.OutputAssembly(outputFolder);
                }
                else if (outputFolder == "stdout")
                {
                    Console.WriteLine(generator.GetClass());
                }
                else
                {
                    generator.OutputClass(outputFolder);
                }
            }
            catch (Exception)
            {
                throw new ArgumentException("A matcher could not be generated using the given definition file.");
            }
        }
Ejemplo n.º 5
0
 public static LanguageMatcher GetStaxeTestComplexLangMatcher()
 {
     lock (_matcherMap)
     {
         if (!_matcherMap.TryGetValue(Language.StaxeTestComplexLang.ToString(), out LanguageMatcher languageMatcher))
         {
             string definition = File.ReadAllText("TestComplexLang/Files/StaxeTestComplexLangDefinition.json");
             LanguageMatcherDefinition languageMatcherModel = JsonConvert.DeserializeObject <LanguageMatcherDefinition>(definition);
             languageMatcher = DefinitionConverter.Convert(languageMatcherModel);
             _matcherMap[Language.StaxeTestComplexLang.ToString()] = languageMatcher;
         }
         return(languageMatcher);
     }
 }
Ejemplo n.º 6
0
        public static void Initialize()
        {
            AuthLogic.Login     = Login;
            AuthLogic.Logout    = Networking.SignOut;
            AuthLogic.Play      = Play;
            AuthLogic.AddFriend = (type, name, characterName) =>
            {
                switch (Networking.RestApi.AddFriend(name))
                {
                case AddFriendResult.Success:
                    Networking.UpdateFriends();
                    return(true);

                default:
                    return(false);
                }
            };
            AuthLogic.MoveFriend = (name, target) =>
            {
                if (target != FriendList.Type.None)
                {
                    return(false);
                }
                if (!Networking.RestApi.RemoveFriend(name))
                {
                    return(false);
                }

                Networking.UpdateFriends();
                return(true);
            };
            AuthLogic.DeleteCharacter = (character) =>
            {
                Networking.RestApi.RemoveCharacter(character.Name);
                return(true);
            };

            GameLogic.ChatMessage            = ChatMessage;
            GameLogic.PartyInvite            = invitee => Networking.Channels.Group.Merge(invitee);
            GameLogic.PartyKickInvite        = party => Networking.Channels.Group.Kick(party.Leader);
            GameLogic.PartyAcceptJoinRequest = party => Networking.Channels.Group.Merge(party.Leader);
            GameLogic.PartyKickJoinRequest   = party => Networking.Channels.Group.Kick(party.Leader);
            GameLogic.PartyKickMember        = member => Networking.Channels.Group.Kick(member);
            GameLogic.PartyLeave             = () => Networking.Channels.Group.Kick(Game.Player.Character);
            GameLogic.ExitToCharacterScreen  = () => { if (Game.Zone.Loaded)
                                                       {
                                                           Networking.Channels.All.ForEach(c => c.Leave());
                                                       }
            };
            GameLogic.ExitToLoginScreen            = Networking.SignOut;
            GameLogic.ChangeMap                    = map => Networking.Channels.Entity.MapChange(DefinitionConverter.ToArea(map));
            GameLogic.SkillBarEquipSkill           = (slot, skill) => Networking.Channels.Skill.SkillbarSet(slot, skill);
            GameLogic.SkillBarMoveSkillToEmptySlot = (@from, to) =>
            {
                Skill skillTo = Game.Player.Character.SkillBar.GetSkill(@from);
                Networking.Channels.Skill.SkillbarSet(@from, Skill.None);
                Networking.Channels.Skill.SkillbarSet(to, skillTo);
            };
            GameLogic.SkillBarSwapSkills = (slot1, slot2) =>
            {
                Skill skill1 = Game.Player.Character.SkillBar.GetSkill(slot1);
                Skill skill2 = Game.Player.Character.SkillBar.GetSkill(slot2);

                Networking.Channels.Skill.SkillbarSet(slot2, skill1);
                Networking.Channels.Skill.SkillbarSet(slot1, skill2);
            };
            GameLogic.CastSkill            = (slot, target) => Networking.Channels.Skill.Cast(slot, target);
            GameLogic.ValidateNewCharacter = (name, apperance) => Networking.RestApi.CreateCharacter(name, apperance);
            GameLogic.ItemPickup           = (droppedItem) => Networking.Channels.Entity.ItemPickup(droppedItem);
        }
Ejemplo n.º 7
0
        private static void Play(Map map)
        {
            Area area = DefinitionConverter.ToArea(map);

            Networking.ChangeArea(area, Game.Player.Character.Name);
        }
Ejemplo n.º 8
0
        public override void HandleMessage(Message message)
        {
            switch (message.Event)
            {
            case "phx_reply":
            {
                if (!message.Payload["status"].ToString().Equals("ok"))
                {
                    return;
                }

                switch (message.Ref)
                {
                case MAP_CHANGE_REF:
                {
                    var area = (Area)Enum.Parse(typeof(Area), message.Payload["response"].map.ToString());
                    var map  = DefinitionConverter.ToMap(area);

                    // Already say that no spawning can happen
                    if (Game.State == GameState.Playing)
                    {
                        Game.StartMapChange();
                    }

                    Networking.ChangeArea(area, Game.Player.Character.Name);

                    /*Game.ChangeMap(map, zone =>
                     * {
                     *  zone.IsExplorable = !IsOutpost;
                     *
                     *  Entity.Players.ForEach(p => zone.AddAgent(p.Character));
                     * });*/
                    Game.Player.Character.Transformation.Position = MapData.GetDefaultSpawnPoint(map);
                }
                break;
                }
            }
            break;

            case "initial":
            {
                //Guid myId = Entity.Entities.Values.OfType<Player>().First(p => p.Character == Game.Player.Character).Id;

                /*if (Game.State == GameState.CharacterScreen)
                 * {*/
                Game.ChangeMap(DefinitionConverter.ToMap(Area), zone =>
                    {
                        zone.IsExplorable = !IsOutpost;

                        Entity.Players.ForEach(p => zone.AddAgent(p.Character));
                    });
                //}

                foreach (JProperty a in message.Payload["attributes"].Values <JProperty>())
                {
                    Entity.UpdateEntity(PlayerEntityId, a.Name, a.Value);
                }
            }
            break;

            case "add":
            {
                Guid id = Guid.Parse(message.Payload["entity"].ToString());

                foreach (JProperty a in message.Payload["attributes"].Values <JProperty>())
                {
                    Entity.UpdateEntity(id, a.Name, a.Value);
                }
            }
            break;

            case "change":
            {
                Guid id = Guid.Parse(message.Payload["entity"].ToString());

                foreach (JProperty a in message.Payload["added"].Values <JProperty>())
                {
                    Entity.UpdateEntity(id, a.Name, a.Value);
                }

                foreach (JProperty a in message.Payload["changed"].Values <JProperty>())
                {
                    Entity.UpdateEntity(id, a.Name, a.Value);
                }
            }
            break;

            case "remove":
            {
                Entity.RemoveEntity(Guid.Parse(message.Payload["entity"].ToString()));
            }
            break;
            }
        }
Ejemplo n.º 9
0
        public override void HandleMessage(Message message)
        {
            switch (message.Event)
            {
            case "phx_reply":
            {
                if (!message.Payload.status.ToString().Equals("ok"))
                {
                    return;
                }

                switch (message.Ref)
                {
                case MAP_CHANGE_REF:
                {
                    var area = (Area)Enum.Parse(typeof(Area), message.Payload.response.map.ToString());

                    Networking.ChangeArea(area, Game.Player.Character.Name);
                }
                break;
                }
            }
            break;

            case "initial":
            {
                Guid myId = Entity.Entities.Values.OfType <Player>().First(p => p.Character == Game.Player.Character).Id;

                foreach (JProperty a in message.Payload.attributes.Values <JProperty>())
                {
                    Entity.UpdateEntity(myId, a.Name, a.Value);
                }

                Game.ChangeMap(DefinitionConverter.ToMap(Area), zone =>
                    {
                        zone.IsExplorable = !IsOutpost;

                        Entity.Players.ForEach(p => zone.AddAgent(p.Character));
                    });
            }
            break;

            case "add":
            {
                Guid id = Guid.Parse(message.Payload.entity.ToString());

                foreach (JProperty a in message.Payload.attributes.Values <JProperty>())
                {
                    Entity.UpdateEntity(id, a.Name, a.Value);
                }
            }
            break;

            case "change":
            {
                Guid id = Guid.Parse(message.Payload.entity.ToString());

                foreach (JProperty a in message.Payload.added.Values <JProperty>())
                {
                    Entity.UpdateEntity(id, a.Name, a.Value);
                }

                foreach (JProperty a in message.Payload.changed.Values <JProperty>())
                {
                    Entity.UpdateEntity(id, a.Name, a.Value);
                }
            }
            break;

            case "remove":
            {
                Entity.RemoveEntity(Guid.Parse(message.Payload.entity.ToString()));
            }
            break;
            }
        }
Ejemplo n.º 10
0
        public static cmd_class DowngradeCommandClass(CommandClass cmdClass)
        {
            DefinitionConverter conv = new DefinitionConverter(null, null);

            return((cmd_class)conv.DowngradeCommandClass(cmdClass, null));
        }