Example #1
0
        public static AmiiboList GetAllAmiibos()
        {
            var list = new AmiiboList();

            try
            {
                var json = JObject.Parse(Utils.GetFromURL(AmiiboAPIURL));
                foreach (var entry in json["amiibo"])
                {
                    var amiibo = new Amiibo
                    {
                        AmiiboName    = entry["name"].ToString().Replace('/', '_'), // Avoid amiibo names conflicting with system paths
                        SeriesName    = entry["amiiboSeries"].ToString(),
                        CharacterName = entry["character"].ToString(),
                        ImageURL      = entry["image"].ToString(),
                        AmiiboId      = entry["head"].ToString() + entry["tail"].ToString(),
                    };
                    list.Amiibos.Add(amiibo);
                }
            }
            catch (Exception ex)
            {
                Utils.LogExceptionMessage(ex);
            }
            return(list);
        }
Example #2
0
        public static AmiiboList GetAllAmiibos()
        {
            ServicePointManager.Expect100Continue = true;
            ServicePointManager.SecurityProtocol  = SecurityProtocolType.Tls12;
            var list = new AmiiboList();

            try
            {
                var json = JObject.Parse(new WebClient().DownloadString(AmiiboAPIURL));
                foreach (var entry in json["amiibo"])
                {
                    var amiibo = new Amiibo
                    {
                        AmiiboName    = entry["name"].ToString(),
                        SeriesName    = entry["amiiboSeries"].ToString(),
                        CharacterName = entry["character"].ToString(),
                        ImageURL      = entry["image"].ToString(),
                        AmiiboId      = entry["head"].ToString() + entry["tail"].ToString(),
                    };
                    list.Amiibos.Add(amiibo);
                }
            }
            catch (Exception ex)
            {
                ExceptionUtils.LogExceptionMessage(ex);
            }
            return(list);
        }
Example #3
0
        public static AmiiboList GetAllAmiibos()
        {
            AmiiboList list = new AmiiboList();

            try
            {
                var json = JObject.Parse(new WebClient().DownloadString(AmiiboAPIURL));

                foreach (var entry in json["amiibo"])
                {
                    var amiibo = new Amiibo
                    {
                        AmiiboName    = entry["name"].ToString(),
                        SeriesName    = entry["amiiboSeries"].ToString(),
                        CharacterName = entry["character"].ToString(),
                        ImageURL      = entry["image"].ToString(),
                        AmiiboId      = entry["head"].ToString() + entry["tail"].ToString(),
                    };
                    list.Amiibos.Add(amiibo);
                }
            }
            catch (Exception ex)
            {
                ExceptionUtils.LogExceptionMessage(ex);
            }
            return(list);
        }
Example #4
0
        public static Amiibo BuildAmiibo(AmiiboAPI.Amiibo api_amiibo, string name)
        {
            ExceptionUtils.Unless(api_amiibo != null, "Invalid input amiibo");

            var amiibo = new Amiibo
            {
                OriginalAmiibo = api_amiibo,
            };

            try
            {
                amiibo.Name = name;
                amiibo.MiiCharInfoFileName = "mii-charinfo.bin";

                var cur_date = DateTime.Now;
                amiibo.FirstWriteDate.Year  = (ushort)cur_date.Year;
                amiibo.FirstWriteDate.Month = (byte)cur_date.Month;
                amiibo.FirstWriteDate.Day   = (byte)cur_date.Day;
                amiibo.LastWriteDate        = amiibo.FirstWriteDate;

                var id = api_amiibo.AmiiboId;
                ExceptionUtils.Unless(id.Length == 16, "Invalid amiibo ID");

                var character_game_id_str = id.Substring(0, 4);
                var character_variant_str = id.Substring(4, 2);
                var figure_type_str       = id.Substring(6, 2);
                var model_no_str          = id.Substring(8, 4);
                var series_str            = id.Substring(12, 2);

                // Swap endianness for this number
                var character_game_id_be = ushort.Parse(character_game_id_str, System.Globalization.NumberStyles.HexNumber);
                amiibo.Id.CharacterId.GameCharacterId = NumberUtils.Reverse(character_game_id_be);

                amiibo.Id.CharacterId.CharacterVariant = byte.Parse(character_variant_str, System.Globalization.NumberStyles.HexNumber);
                amiibo.Id.FigureType  = byte.Parse(figure_type_str, System.Globalization.NumberStyles.HexNumber);
                amiibo.Id.ModelNumber = ushort.Parse(model_no_str, System.Globalization.NumberStyles.HexNumber);
                amiibo.Id.Series      = byte.Parse(series_str, System.Globalization.NumberStyles.HexNumber);

                // Generate a random UUID
                // In most UUIDs, the first 7 bytes are random, while the last three are zeroed
                // Since some games, like Splatoon 2, seem to check if these are zeroed, we'll follow this pattern and zero last 3 bytes
                Random rnd = new Random();
                rnd.NextBytes(amiibo.Uuid);
                amiibo.Uuid[7] = 0;
                amiibo.Uuid[8] = 0;
                amiibo.Uuid[9] = 0;
            }
            catch (Exception ex)
            {
                ExceptionUtils.LogExceptionMessage(ex);
            }

            return(amiibo);
        }
Example #5
0
        public static Amiibo BuildAmiibo(AmiiboAPI.Amiibo api_amiibo, string name)
        {
            ExceptionUtils.Unless(api_amiibo != null, "Invalid input amiibo");

            var amiibo = new Amiibo();

            amiibo.OriginalAmiibo = api_amiibo;

            try
            {
                amiibo.Name = name;
                amiibo.MiiCharInfoFileName = "mii-charinfo.bin";

                var cur_date = DateTime.Now;
                amiibo.FirstWriteDate.Year  = (ushort)cur_date.Year;
                amiibo.FirstWriteDate.Month = (byte)cur_date.Month;
                amiibo.FirstWriteDate.Day   = (byte)cur_date.Day;
                amiibo.LastWriteDate        = amiibo.FirstWriteDate;

                var id = api_amiibo.AmiiboId;
                ExceptionUtils.Unless(id.Length == 16, "Invalid amiibo ID");

                var character_game_id_str = id.Substring(0, 4);
                var character_variant_str = id.Substring(4, 2);
                var figure_type_str       = id.Substring(6, 2);
                var model_no_str          = id.Substring(8, 4);
                var series_str            = id.Substring(12, 2);

                // Swap endianness for this number
                var character_game_id_be = ushort.Parse(character_game_id_str, System.Globalization.NumberStyles.HexNumber);
                amiibo.Id.CharacterId.GameCharacterId = NumberUtils.Reverse(character_game_id_be);

                amiibo.Id.CharacterId.CharacterVariant = byte.Parse(character_variant_str, System.Globalization.NumberStyles.HexNumber);
                amiibo.Id.FigureType  = byte.Parse(figure_type_str, System.Globalization.NumberStyles.HexNumber);
                amiibo.Id.ModelNumber = ushort.Parse(model_no_str, System.Globalization.NumberStyles.HexNumber);
                amiibo.Id.Series      = byte.Parse(series_str, System.Globalization.NumberStyles.HexNumber);

                // Generate a random UUID
                Random rnd = new Random();
                rnd.NextBytes(amiibo.Uuid);
            }
            catch (Exception ex)
            {
                ExceptionUtils.LogExceptionMessage(ex);
            }

            return(amiibo);
        }