public WarRallyMessage(JsonMessage message)
            : base(message)
        {
            this.Id   = message.Id;
            this.Type = MessageType.Rally;

            try
            {
                if (this.Json is JObject)
                {
                    foreach (KeyValuePair <string, JToken> war in (JObject)this.Json)
                    {
                        switch (war.Key)
                        {
                        case "war_key": this.war_key = war.Value.ToString(); break;

                        case "alliance_id": this.alliance_id = (int)war.Value; break;

                        case "war_id": this.war_id = (int)war.Value; break;

                        case "war_type": this.war_type = (int)war.Value; break;

                        case "role": this.role = (int)war.Value; break;

                        case "state": this.state = (int)war.Value; break;

                        case "defeat_emoji": this.defeat_emoji = (int)war.Value; break;

                        case "timer_length": this.timer_length = (int)war.Value; break;

                        case "timer": this.timer = (int)war.Value; break;

                        case "timer_start": this.timer_start = ((int)war.Value).ToDateTime(); break;

                        case "timer_end": this.timer_end = ((int)war.Value).ToDateTime(); break;

                        case "troop_count": this.troop_count = (int)war.Value; break;

                        case "hero_composite_id":
                            if (war.Value.Type == JTokenType.Null)
                            {
                                this.hero_composite_id = null;
                            }
                            else
                            {
                                if (war.Value is JObject)
                                {
                                    this.hero_composite_id = new Objects.Rally.HeroComposite();

                                    foreach (KeyValuePair <string, JToken> hero in (JObject)war.Value)
                                    {
                                        switch (hero.Key)
                                        {
                                        case "user_id": this.hero_composite_id.user_id = (int)hero.Value; break;

                                        case "city_id": this.hero_composite_id.city_id = (int)hero.Value; break;

                                        default: this.Error = true; break;
                                        }
                                    }
                                }
                            }
                            break;

                        case "troop_max": this.troop_max = (int)war.Value; break;

                        case "super_troop_count": this.super_troop_count = (int)war.Value; break;

                        case "super_troop_max": this.super_troop_max = (int)war.Value; break;

                        case "total_super_troop_count": this.total_super_troop_count = (int)war.Value; break;

                        case "total_super_troop_max": this.total_super_troop_max = (int)war.Value; break;

                        case "rallied_troop_count": this.rallied_troop_count = (int)war.Value; break;

                        case "trap_max": this.trap_max = (int)war.Value; break;

                        case "trap_count": this.troop_count = (int)war.Value; break;

                        case "monster_count": this.monster_count = (int)war.Value; break;

                        case "copy_leader_ratio_enabled": this.copy_leader_ratio_enabled = (bool)war.Value; break;

                        case "bypass_final_confirmation": this.bypass_final_confirmation = (bool)war.Value; break;

                        case "war_comission_required": this.war_commission_required = (bool)war.Value; break;

                        case "war_group_type": this.war_group_type = war.Value.ToString(); break;

                        case "attacker":
                            this.attacker = new Objects.Rally.Attacker();

                            foreach (KeyValuePair <string, JToken> att in (JObject)war.Value)
                            {
                                switch (att.Key)
                                {
                                case "alliance": this.attacker.AllianceFullName = att.Value.ToString(); break;

                                case "alliance_tag": this.attacker.AllianceTag = att.Value.ToString(); break;

                                case "empire": this.attacker.UserName = att.Value.ToString(); break;

                                case "home_province_id": this.attacker.HomeProvinceId = (int)att.Value; break;

                                case "city": this.attacker.CityName = att.Value.ToString(); break;

                                case "city_id": this.attacker.CityId = (int)att.Value; break;

                                case "province_id": break;

                                case "tile":
                                    this.attacker.Tile = new Point3D();
                                    foreach (KeyValuePair <string, JToken> tile in (JObject)att.Value)
                                    {
                                        switch (tile.Key)
                                        {
                                        case "province_id": this.attacker.Tile.Z = (int)tile.Value; break;

                                        case "chunk_id":
                                            this.attacker.Tile.X += Utilities.ChunkId2XCoordinate((int)tile.Value);
                                            this.attacker.Tile.Y += Utilities.ChunkId2YCoordinate((int)tile.Value);
                                            break;

                                        case "tile_id":
                                            this.attacker.Tile.X += Utilities.TileId2XCoordinate((int)tile.Value);
                                            this.attacker.Tile.Y += Utilities.TileId2YCoordinate((int)tile.Value);
                                            break;

                                        case "overlay": this.attacker.TileOverlay = (int)tile.Value; break;

                                        case "rank": this.attacker.TileRank = (int)tile.Value; break;

                                        default: this.Error = true; break;
                                        }
                                    }
                                    break;

                                case "rank": this.attacker.Rank = (int)att.Value; break;

                                case "vip": this.attacker.VIPLevel = (int)att.Value; break;

                                case "user_id": this.attacker.UserId = (int)att.Value; break;

                                case "empire_id": this.attacker.EmpireId = (int)att.Value; break;

                                case "army_id": this.attacker.ArmyId = (int)att.Value; break;

                                default: this.Error = true; break;
                                }
                            }
                            break;

                        case "defender":
                            this.defender = new Objects.Rally.Defender();

                            foreach (KeyValuePair <string, JToken> def in (JObject)war.Value)
                            {
                                switch (def.Key)
                                {
                                case "alliance": this.defender.AllianceFullName = def.Value.ToString(); break;

                                case "alliance_tag": this.defender.AllianceTag = def.Value.ToString(); break;

                                case "rank": this.defender.Rank = (int)def.Value; break;

                                case "vip": this.defender.VIPLevel = (int)def.Value; break;

                                case "empire": this.defender.UserName = def.Value.ToString(); break;

                                case "user_id": this.defender.UserId = (int)def.Value; break;

                                case "empire_id": this.defender.EmpireId = (int)def.Value; break;

                                case "city": this.defender.CityName = def.Value.ToString(); break;

                                case "city_id": this.defender.CityId = (int)def.Value; break;

                                case "province_id": break;

                                case "tile":
                                    this.defender.Tile = new Point3D();
                                    foreach (KeyValuePair <string, JToken> tile in (JObject)def.Value)
                                    {
                                        switch (tile.Key)
                                        {
                                        case "province_id": this.defender.Tile.Z = (int)tile.Value; break;

                                        case "chunk_id":
                                            this.defender.Tile.X += Utilities.ChunkId2XCoordinate((int)tile.Value);
                                            this.defender.Tile.Y += Utilities.ChunkId2YCoordinate((int)tile.Value);
                                            break;

                                        case "tile_id":
                                            this.defender.Tile.X += Utilities.TileId2XCoordinate((int)tile.Value);
                                            this.defender.Tile.Y += Utilities.TileId2YCoordinate((int)tile.Value);
                                            break;

                                        case "wonder_id": this.defender.TileControlPointId = (int)tile.Value; break;

                                        case "overlay": this.defender.TileOverlay = (int)tile.Value; break;

                                        default: this.Error = true; break;
                                        }
                                    }
                                    break;

                                case "wonder_id": this.defender.ControlPointId = (int)def.Value; break;

                                case "wonder_alliance_id": this.defender.ControlPointAllianceId = (int)def.Value; break;

                                default: this.Error = true; break;
                                }
                            }
                            break;

                        case "slots":
                            this.slots = new List <Objects.Rally.RallySlot>();

                            foreach (JObject s in war.Value)
                            {
                                Objects.Rally.RallySlot slot = new Objects.Rally.RallySlot();

                                foreach (KeyValuePair <string, JToken> kvp in s)
                                {
                                    switch (kvp.Key)
                                    {
                                    case "war_key": slot.RallyKey = kvp.Value.ToString(); break;

                                    case "alliance_id": slot.AllianceId = (int)kvp.Value; break;

                                    case "war_id": slot.RallyId = (int)kvp.Value; break;

                                    case "slot_id": slot.SlotId = (int)kvp.Value; break;

                                    case "status": slot.Status = (Objects.Rally.RallySlot.SlotStatus)(int) kvp.Value; break;

                                    case "empire": slot.UserName = kvp.Value.ToString(); break;

                                    case "user_id": slot.UserId = (int)kvp.Value; break;

                                    case "empire_id": slot.EmpireId = (int)kvp.Value; break;

                                    case "city_id": slot.CityId = (int)kvp.Value; break;

                                    case "army_id": slot.ArmyId = (int)kvp.Value; break;

                                    case "rank": slot.Rank = (int)kvp.Value; break;

                                    case "vip": slot.VIPLevel = (int)kvp.Value; break;

                                    case "alliance_tag": slot.AllianceTag = kvp.Value.ToString(); break;

                                    case "timer_length": slot.TimerLength = (int)kvp.Value; break;

                                    case "timer": slot.Timer = (int)kvp.Value; break;

                                    case "timer_start": slot.TimerStart = ((int)kvp.Value).ToDateTime(); break;

                                    case "timer_end": slot.TimerEnd = ((int)kvp.Value).ToDateTime(); break;

                                    case "troop_count": slot.TroopCount = (int)kvp.Value; break;

                                    case "gathered_troops":
                                        if (kvp.Value is JObject)
                                        {
                                            slot.Troops = new List <KeyValuePair <string, int> >();
                                            foreach (KeyValuePair <string, JToken> t in (JObject)kvp.Value)
                                            {
                                                slot.Troops.Add(new KeyValuePair <string, int>(t.Key, (int)t.Value));
                                            }
                                        }
                                        break;

                                    case "gathered_units":
                                        if (kvp.Value is JObject)
                                        {
                                            slot.TroopUnits = new List <KeyValuePair <string, int> >();
                                            foreach (KeyValuePair <string, JToken> t in (JObject)kvp.Value)
                                            {
                                                slot.TroopUnits.Add(new KeyValuePair <string, int>(t.Key, (int)t.Value));
                                            }
                                        }
                                        break;

                                    case "total_troop_count": slot.TotalTroopCount = (int)kvp.Value; break;

                                    case "total_troop_max": slot.TotalTroopMax = (int)kvp.Value; break;

                                    case "super_troop_count": slot.SuperTroopCount = (int)kvp.Value; break;

                                    case "super_troop_max": slot.SuperTroopMax = (int)kvp.Value; break;

                                    case "total_super_troop_count": slot.TotalSuperTroopCount = (int)kvp.Value; break;

                                    case "total_super_troop_max": slot.TotalSuperTroopMax = (int)kvp.Value; break;

                                    case "trap_count": slot.TrapCount = (int)kvp.Value; break;

                                    case "total_trap_count": slot.TotalTrapCount = (int)kvp.Value; break;

                                    case "total_trap_max": slot.TotalTrapMax = (int)kvp.Value; break;

                                    case "gathered_unittroops": this.Error = true; break;         //TODO: figure out what this is

                                    default: this.Error = true; break;
                                    }
                                }

                                this.slots.Add(slot);
                            }
                            break;

                        case "shared_counts":
                            this.shared_counts = new Objects.Rally.SharedCounts();

                            foreach (KeyValuePair <string, JToken> kvp in (JObject)war.Value)
                            {
                                switch (kvp.Key)
                                {
                                case "alliance_incoming_invites": this.shared_counts.AllianceIncomingInvites = (int)kvp.Value; break;

                                case "alliance_war_attack": this.shared_counts.AllianceWarAttacks = (int)kvp.Value; break;

                                case "alliance_war_defense": this.shared_counts.AllianceWarDefenses = (int)kvp.Value; break;

                                case "alliance_ac_war_attack": this.shared_counts.AllianceACWarAttacks = (int)kvp.Value; break;

                                case "alliance_ac_war_defense": this.shared_counts.AllianceACWarDefenses = (int)kvp.Value; break;

                                case "alliance_group_war_attack": this.shared_counts.AllianceGroupWarAttacks = (int)kvp.Value; break;

                                case "alliance_group_war_defense": this.shared_counts.AllianceGroupWarDefenses = (int)kvp.Value; break;

                                default: this.Error = true; break;
                                }
                            }
                            break;

                        default: this.Error = true; break;
                        }
                    }
                }
            }
            catch (FormatException ex)
            {
                this.Error = true;
            }
            catch (ArgumentOutOfRangeException ex)
            {
                this.Error = true;
            }
        }
        public WarRallyEndedMessage(JsonMessage message)
            : base(message)
        {
            this.Id   = message.Id;
            this.Type = MessageType.Rally;

            try
            {
                if (this.Json is JObject)
                {
                    foreach (KeyValuePair <string, JToken> war in (JObject)this.Json)
                    {
                        switch (war.Key)
                        {
                        case "war_key": this.war_key = war.Value.ToString(); break;

                        case "alliance_id": this.alliance_id = (int)war.Value; break;

                        case "war_id": this.war_id = (int)war.Value; break;

                        case "role": this.role = (int)war.Value; break;

                        case "state": this.state = (int)war.Value; break;

                        case "war": this.war = (int)war.Value; break;

                        case "shared_counts":
                            this.shared_counts = new Objects.Rally.SharedCounts();

                            foreach (KeyValuePair <string, JToken> kvp in (JObject)war.Value)
                            {
                                switch (kvp.Key)
                                {
                                case "alliance_incoming_invites": this.shared_counts.AllianceIncomingInvites = (int)kvp.Value; break;

                                case "alliance_war_attack": this.shared_counts.AllianceWarAttacks = (int)kvp.Value; break;

                                case "alliance_war_defense": this.shared_counts.AllianceWarDefenses = (int)kvp.Value; break;

                                case "alliance_ac_war_attack": this.shared_counts.AllianceACWarAttacks = (int)kvp.Value; break;

                                case "alliance_ac_war_defense": this.shared_counts.AllianceACWarDefenses = (int)kvp.Value; break;

                                case "alliance_group_war_attack": this.shared_counts.AllianceGroupWarAttacks = (int)kvp.Value; break;

                                case "alliance_group_war_defense": this.shared_counts.AllianceGroupWarDefenses = (int)kvp.Value; break;

                                default: this.Error = true; break;
                                }
                            }
                            break;

                        default: this.Error = true; break;
                        }
                    }
                }
            }
            catch (FormatException ex)
            {
                this.Error = true;
            }
            catch (ArgumentOutOfRangeException ex)
            {
                this.Error = true;
            }
        }
        public AllianceHelpRequestedMessage(JsonMessage message)
            : base(message)
        {
            this.Id   = message.Id;
            this.Type = MessageType.AllianceUpdate;

            try
            {
                if (this.Json is JObject)
                {
                    foreach (KeyValuePair <string, JToken> stat in (JObject)this.Json)
                    {
                        switch (stat.Key)
                        {
                        case "event": this._event = stat.Value.ToString(); break;

                        case "help_id": this.help_id = stat.Value.ToString(); break;

                        case "help_name": this.help_name = stat.Value.ToString(); break;

                        case "description":
                            this.description = new Description();
                            foreach (KeyValuePair <string, JToken> desc in (JObject)stat.Value)
                            {
                                switch (desc.Key)
                                {
                                case "key": this.description.key = desc.Value.ToString(); break;

                                case "dict":
                                    this.description.dict = new Dict();
                                    foreach (KeyValuePair <string, JToken> dict in (JObject)desc.Value)
                                    {
                                        switch (dict.Key)
                                        {
                                        case "level": this.description.dict.level = (int)dict.Value; break;

                                        case "building_name":
                                            this.description.dict.building_name = new List <string>();
                                            foreach (string name in (JArray)dict.Value)
                                            {
                                                this.description.dict.building_name.Add(name);
                                            }
                                            break;

                                        case "research_name":
                                            this.description.dict.research_name = new List <string>();
                                            foreach (string name in (JArray)dict.Value)
                                            {
                                                this.description.dict.research_name.Add(name);
                                            }
                                            break;

                                        default: this.Error = true; break;
                                        }
                                    }
                                    break;

                                default: this.Error = true; break;
                                }
                            }
                            break;

                        case "rank": this.rank = (int)stat.Value; break;

                        case "help_count": this.help_count = (int)stat.Value; break;

                        case "help_category": this.help_category = (int)stat.Value; break;

                        case "help_max": this.help_max = (int)stat.Value; break;

                        default: this.Error = true; break;
                        }
                    }
                }
            }
            catch (FormatException ex)
            {
                this.Error = true;
            }
            catch (ArgumentOutOfRangeException ex)
            {
                this.Error = true;
            }
        }
Exemple #4
0
        public MarchMessage(JsonMessage message)
            : base(message)
        {
            this.Type = MessageType.March;

            try
            {
                if (this.Json is JObject)
                {
                    foreach (KeyValuePair <string, JToken> root in (JObject)this.Json)
                    {
                        march_id = root.Key;

                        foreach (KeyValuePair <string, JToken> m in (JObject)root.Value)
                        {
                            switch (m.Key)
                            {
                            case "user_id": this.user_id = (int)m.Value; break;

                            case "empire_id": this.empire_id = (int)m.Value; break;

                            case "id": this.id = (int)m.Value; break;

                            case "city_id": this.city_id = (int)m.Value; break;

                            case "army_id": this.army_id = (int)m.Value; break;

                            case "home_id": this.home_id = (int)m.Value; break;

                            case "dest_province_id": this.dest_province_id = (int)m.Value; break;

                            case "dest_chunk_id": this.dest_chunk_id = (int)m.Value; break;

                            case "dest_tile_id": this.dest_tile_id = (int)m.Value; break;

                            case "from_province_id": this.from_province_id = (int)m.Value; break;

                            case "from_chunk_id": this.from_chunk_id = (int)m.Value; break;

                            case "from_tile_id": this.from_tile_id = (int)m.Value; break;

                            case "state":
                                switch (m.Value.ToString())
                                {
                                case "advancing": this.state = Objects.March.MarchState.Advancing; break;

                                case "returning": this.state = Objects.March.MarchState.Returning; break;

                                case "busy": this.state = Objects.March.MarchState.Busy; break;

                                default:
                                    this.state = Objects.March.MarchState.Unknown;
                                    this.Error = true;
                                    break;
                                }
                                break;

                            case "start_time": this.start_time = ((int)m.Value).ToDateTime(); break;

                            case "dest_time": this.dest_time = ((int)m.Value).ToDateTime(); break;

                            case "type":
                                switch (m.Value.ToString())
                                {
                                case "attack": this.type = Objects.March.MarchType.Attack; break;

                                case "hero_attack": this.type = Objects.March.MarchType.RebelAttack; break;

                                case "hero_escape": this.type = Objects.March.MarchType.HeroEscape; break;

                                case "rally": this.type = Objects.March.MarchType.Rally; break;

                                case "scout": this.type = Objects.March.MarchType.Scout; break;

                                case "reinforce": this.type = Objects.March.MarchType.Reinforcement; break;

                                case "war": this.type = Objects.March.MarchType.War; break;

                                case "trade": this.type = Objects.March.MarchType.Trade; break;

                                case "encamp": this.type = Objects.March.MarchType.Tile; break;

                                case "digging": this.type = Objects.March.MarchType.Digging; break;

                                default:
                                    this.type  = Objects.March.MarchType.Unknown;
                                    this.Error = true;
                                    break;
                                }
                                break;

                            case "alliance_id": this.alliance_id = (int)m.Value; break;

                            case "alliance_tag": this.alliance_tag = m.Value.ToString(); break;

                            case "emoji":
                                switch (m.Value.ToString())
                                {
                                case "EMOJI_MARCH_DEFAULT": this.emoji = Objects.March.MarchEmoji.Default; break;

                                default: this.emoji = Objects.March.MarchEmoji.Unknown; break;
                                }
                                break;

                            case "emoji_starttime": this.emoji_starttime = ((int)m.Value).ToDateTime(); break;

                            case "type_data": this.type_data = m.Value.ToString(); break;

                            case "update_ts": this.update_ts = ((int)m.Value).ToDateTime(); break;

                            case "anim_attrib": this.anim_attrib = (int)m.Value; break;

                            case "truce_type": this.truce_type = (int)m.Value; break;

                            case "color": this.color = (int)m.Value; break;

                            case "king": this.king = (bool)m.Value; break;

                            case "hero_gender": this.hero_gender = m.Value.ToString(); break;

                            case "hero_name": this.hero_name = m.Value.ToString(); break;

                            case "dest_name": this.dest_name = m.Value.ToString(); break;

                            case "dest_name_need_localize": this.dest_name_need_localize = (bool)m.Value; break;

                            case "from_name": this.from_name = m.Value.ToString(); break;

                            case "companion_anims":
                                if (((JValue)m.Value).Type == JTokenType.Null)
                                {
                                    this.companion_anims = null;
                                }
                                else if (((JValue)m.Value).Type == JTokenType.String)
                                {
                                    this.companion_anims = m.Value.ToString();
                                }
                                else
                                {
                                    this.Error = true;
                                }
                                break;

                            default: this.Error = true; break;
                            }
                        }
                    }
                }
            }
            catch (FormatException ex)
            {
                this.Error = true;
            }
            catch (ArgumentOutOfRangeException ex)
            {
                this.Error = true;
            }
        }
        public AllianceHelpedMessage(JsonMessage message)
            : base(message)
        {
            this.Id   = message.Id;
            this.Type = MessageType.AllianceUpdate;

            try
            {
                if (this.Json is JObject)
                {
                    foreach (KeyValuePair <string, JToken> root in (JObject)this.Json)
                    {
                        switch (root.Key)
                        {
                        case "event": this._event = root.Value.ToString(); break;

                        case "help_data":

                            JObject helpDataStart;

                            if (root.Value is JArray)
                            {
                                if (((JArray)root.Value).Count > 1)
                                {
                                    this.Error = true;
                                    return;
                                }
                                else
                                {
                                    helpDataStart = (JObject)((JArray)root.Value)[0];
                                }
                            }
                            else
                            {
                                helpDataStart = (JObject)root.Value;
                            }

                            this.help_data = new List <HelpData>();
                            foreach (KeyValuePair <string, JToken> help in helpDataStart)
                            {
                                HelpData data = new HelpData();
                                data.help_id = help.Key;

                                foreach (KeyValuePair <string, JToken> d in (JObject)help.Value)
                                {
                                    switch (d.Key)
                                    {
                                    case "help_count": data.help_count = (int)d.Value; break;

                                    case "helper_user_id": data.helper_userid = (int)d.Value; break;

                                    default: this.Error = true; break;
                                    }
                                }

                                this.help_data.Add(data);
                            }
                            break;

                        default: this.Error = true; break;
                        }
                    }
                }
            }
            catch (FormatException ex)
            {
                this.Error = true;
            }
            catch (ArgumentOutOfRangeException ex)
            {
                this.Error = true;
            }
            catch (InvalidCastException ex)
            {
                this.Error = true;
            }
        }
Exemple #6
0
        public static JsonMessage Parse(XmlMessage message)
        {
            JsonMessage ret = new JsonMessage(message);

            try
            {
                ret.LoadXml();
                System.Xml.XmlNode node = ret.Document.DocumentElement.FirstChild.FirstChild;

                if (node != null && node.Name == "items")
                {
                    ret.Id        = node.FirstChild.Attributes["id"].Value;
                    ret.Timestamp = Int32.Parse(node.FirstChild.Attributes["timestamp"].Value).ToDateTime();

                    ret.LoadXml();
                    node = ret.Document.DocumentElement.FirstChild.FirstChild;

                    ret.RawJson = ret.Document.DocumentElement.SelectSingleNode("//*[local-name()='payload']").InnerText;

                    try
                    {
                        ret.Json = JToken.Parse(ret.RawJson);

                        switch (node.Attributes["node"].Value)
                        {
                        case "EVENT_WAR_RALLY_BEGAN":     //rally
                            ret = new WarRallyMessage(ret);
                            break;

                        case "EVENT_WAR_RALLY_ENDED":     //rally end
                            ret = new WarRallyEndedMessage(ret);
                            break;

                        case "EVENT_MARCH":     //march
                            ret = new MarchMessage(ret);
                            break;

                        case "EVENT_SYNCEDDATA":     //various data
                            ret = new SyncedDataMessage(ret);

                            //TODO: Remove debug output eventually
                            if (((SyncedDataMessage)ret).Watchtowers.Count > 0)
                            {
                                System.IO.Directory.CreateDirectory(String.Format(".\\output\\debug\\synceddata\\_watchtower"));
                                System.IO.File.WriteAllText(String.Format(".\\output\\debug\\synceddata\\_watchtower\\{0}.txt", (ret.Error ? "ERROR_" : "") + ret.Id), Utilities.FormatJSON(ret.RawJson));
                            }
                            else if (((SyncedDataMessage)ret).empireinappsale)
                            {
                                System.IO.Directory.CreateDirectory(String.Format(".\\output\\debug\\synceddata\\_empireinappsale"));
                                System.IO.File.WriteAllText(String.Format(".\\output\\debug\\synceddata\\_empireinappsale\\{0}.txt", (ret.Error ? "ERROR_" : "") + ret.Id), Utilities.FormatJSON(ret.RawJson));
                            }
                            else
                            {
                                //System.IO.Directory.CreateDirectory(String.Format(".\\output\\debug\\synceddata"));
                                //System.IO.File.WriteAllText(String.Format(".\\output\\debug\\synceddata\\{0}.txt", ret.Id), Utilities.FormatJSON(ret.RawJson));
                            }
                            break;

                        case "EVENT_ALLIANCE_UPDATE":
                            ret = new AllianceUpdateMessage(ret);
                            break;

                        case "EVENT_ALLIANCE_FUNDS_UPDATE":
                            ret = new AllianceFundsUpdateMessage(ret);
                            break;

                        case "EVENT_ALLIANCE_GIFT_CREATED":
                            ret = new AllianceGiftCreatedMessage(ret);
                            break;

                        case "EVENT_ALLIANCE_GIFT_READY":
                            break;

                        case "EVENT_ALLIANCE_HELP_FINISHED":
                            ret = new AllianceHelpFinishedMessage(ret);
                            break;

                        case "EVENT_ALLIANCE_HELP_REQUESTED":
                            ret = new AllianceHelpRequestedMessage(ret);
                            break;

                        case "EVENT_ALLIANCE_HELPED":
                            ret = new AllianceHelpedMessage(ret);
                            break;

                        case "EVENT_ALLIANCE_STORE_HISTORY_UPDATE":
                            ret = new AllianceStoreHistoryUpdateMessage(ret);
                            break;

                        case "EVENT_TILE_UPDATED":
                            ret = new TileUpdatedMessage(ret);
                            break;

                        case "EVENT_GAMEEVENT_ANNOUNCEMENT":
                            System.IO.Directory.CreateDirectory(String.Format(".\\output\\debug\\unknownJson\\{0}", node.Attributes["node"].Value));
                            System.IO.File.WriteAllText(String.Format(".\\output\\debug\\unknownJson\\{0}\\{0}-{1}.txt", node.Attributes["node"].Value, ret.Id), Utilities.FormatJSON(ret.RawJson));
                            break;

                        case "EVENT_INVENTORY_CHEST_SCHEDULE_CHANGED":
                        case "EVENT_ALLIANCE_RANSOM_MEMBERS":
                        case "EVENT_BLOG_UPDATED":
                        case "EVENT_PROVINCE_TITLE_ISSUED":
                        case "EVENT_ALLIANCE_HELP_OWNER_COMPLETE":
                        case "EVENT_ALLIANCE_HELP_OWNER_REQUEST_HELP":
                        case "EVENT_FORMING_RESOLVED":
                        case "EVENT_LOGIN_OTHER_DEVICE":
                        case "EVENT_BONUS_CUSTOM_TEXT_READY":
                        case "GAME_EVENT_STARTED":
                        case "GAME_EVENT_ENDED":
                        case "RATE_US_ACTIVATE":
                            //TODO: Revisit, but too many of these are being outputted
                            break;

                        default:
                            System.IO.Directory.CreateDirectory(String.Format(".\\output\\debug\\unknownJson\\{0}", node.Attributes["node"].Value));
                            System.IO.File.WriteAllText(String.Format(".\\output\\debug\\unknownJson\\{0}\\{0}-{1}.txt", node.Attributes["node"].Value, ret.Id), Utilities.FormatJSON(ret.RawJson));
                            break;
                        }

                        //TODO: Remove this debugging eventually
                        if (!(ret is SyncedDataMessage) && ret.Error)
                        {
                            System.IO.Directory.CreateDirectory(String.Format(".\\output\\debug\\error"));
                            System.IO.File.WriteAllText(String.Format(".\\output\\debug\\error\\{0}-{1}.txt", node.Attributes["node"].Value, ret.Id), Utilities.FormatJSON(ret.RawJson));
                        }
                    }
                    catch (Newtonsoft.Json.JsonReaderException ex)
                    {
                        System.IO.Directory.CreateDirectory(String.Format(".\\output\\debug\\unknownJson"));
                        string json = ret.RawJson;
                        try
                        {
                            json = Utilities.FormatJSON(ret.RawJson);
                        }
                        catch (ArgumentOutOfRangeException e) { }
                        System.IO.File.WriteAllText(String.Format(".\\output\\debug\\unknownJson\\-ERROR-{0}-{1}.txt", node.Attributes["node"].Value, ret.Id), json);
                    }
                }
            }
            catch (System.Xml.XmlException ex) { }

            return(ret);
        }