コード例 #1
0
        /// <summary>
        /// Creates a new instance of all objects that are null
        /// </summary>
        public void InitNullObjects()
        {
            if (Trainers == null)
            {
                Trainers = new List <BattleManager.Entity.Trainer.EntityTrainerData>();
            }
            if (Pokemon == null)
            {
                Pokemon = new List <BattleManager.Entity.Pokemon.EntityPokemonData>();
            }
            if (EntityGroups == null)
            {
                EntityGroups = new List <BattleManager.Entity.EntityGroup>();
            }

            //MapFiles = new List<Resources.MapFileData>();
            //Maps = new List<Resources.MapData>();

            if (AudioResources == null)
            {
                AudioResources = new List <SoundSystem.SaveData.AudioData>();
            }
            ImageResources = new List <Resource_Data.Resources>();

            PokedexData.InitNullObjects();
        }
コード例 #2
0
 public void recognizes_all_special_characters_omitted()
 {
     Assert.That(PokedexData.NormalizeName("MrMime"), Is.EqualTo("Mr. Mime"));
     Assert.That(PokedexData.NormalizeName("MrRime"), Is.EqualTo("Mr. Rime"));
     Assert.That(PokedexData.NormalizeName("MimeJr"), Is.EqualTo("Mime Jr."));
     Assert.That(PokedexData.NormalizeName("TypeNull"), Is.EqualTo("Type: Null"));
 }
コード例 #3
0
 public void recognizes_omitted_dashes()
 {
     Assert.That(PokedexData.NormalizeName("HoOh"), Is.EqualTo("Ho-Oh"));
     Assert.That(PokedexData.NormalizeName("PorygonZ"), Is.EqualTo("Porygon-Z"));
     Assert.That(PokedexData.NormalizeName("Jangmoo"), Is.EqualTo("Jangmo-o"));
     Assert.That(PokedexData.NormalizeName("Hakamoo"), Is.EqualTo("Hakamo-o"));
     Assert.That(PokedexData.NormalizeName("Kommoo"), Is.EqualTo("Kommo-o"));
 }
コード例 #4
0
 public void recognizes_replaced_unicode()
 {
     Assert.That(PokedexData.NormalizeName("Nidoranf"), Is.EqualTo("Nidoran♀"));
     Assert.That(PokedexData.NormalizeName("Nidoran-f"), Is.EqualTo("Nidoran♀"));
     Assert.That(PokedexData.NormalizeName("Nidoranm"), Is.EqualTo("Nidoran♂"));
     Assert.That(PokedexData.NormalizeName("Nidoran-m"), Is.EqualTo("Nidoran♂"));
     Assert.That(PokedexData.NormalizeName("Flabebe"), Is.EqualTo("Flabébé"));
 }
コード例 #5
0
ファイル: PokedexDataTest.cs プロジェクト: Yoso2/tpp-core
 public void ignores_names_that_do_not_need_normalization()
 {
     Assert.AreEqual("Pidgey", PokedexData.NormalizeName("Pidgey"));
     Assert.AreNotEqual("Pidgey", PokedexData.NormalizeName("Pid'gey"));
     Assert.AreNotEqual("Pidgey", PokedexData.NormalizeName("Pid gey"));
     Assert.AreNotEqual("Pidgey", PokedexData.NormalizeName("Pid-gey"));
     Assert.AreNotEqual("Pidgey", PokedexData.NormalizeName("Pidgey."));
 }
コード例 #6
0
 public void ignores_names_that_do_not_need_normalization()
 {
     Assert.That(PokedexData.NormalizeName("Pidgey"), Is.EqualTo("Pidgey"));
     Assert.That(PokedexData.NormalizeName("Pid'gey"), Is.Not.EqualTo("Pidgey"));
     Assert.That(PokedexData.NormalizeName("Pid gey"), Is.Not.EqualTo("Pidgey"));
     Assert.That(PokedexData.NormalizeName("Pid-gey"), Is.Not.EqualTo("Pidgey"));
     Assert.That(PokedexData.NormalizeName("Pidgey."), Is.Not.EqualTo("Pidgey"));
 }
コード例 #7
0
ファイル: PokedexDataTest.cs プロジェクト: Yoso2/tpp-core
 public void recognizes_replaced_unicode()
 {
     Assert.AreEqual("Nidoran♀", PokedexData.NormalizeName("Nidoranf"));
     Assert.AreEqual("Nidoran♀", PokedexData.NormalizeName("Nidoran-f"));
     Assert.AreEqual("Nidoran♂", PokedexData.NormalizeName("Nidoranm"));
     Assert.AreEqual("Nidoran♂", PokedexData.NormalizeName("Nidoran-m"));
     Assert.AreEqual("Flabébé", PokedexData.NormalizeName("Flabebe"));
 }
コード例 #8
0
 private void createPokeDex()
 {
     Stopwatch sw = new Stopwatch();
     sw.Start();
     json = JsonUtility.FromJson<PokedexData>(jsonFile.text);
     sw.Stop();
     print("time to create json in ms: " + sw.ElapsedMilliseconds);
 }
コード例 #9
0
    private void createPokeDex()
    {
        Stopwatch sw = new Stopwatch();

        sw.Start();
        json = JsonUtility.FromJson <PokedexData>(jsonFile.text);
        sw.Stop();
        print("time to create json in ms: " + sw.ElapsedMilliseconds);
    }
コード例 #10
0
 public void recognizes_omitted_punctuation()
 {
     Assert.That(PokedexData.NormalizeName("Mr Mime"), Is.EqualTo("Mr. Mime"));
     Assert.That(PokedexData.NormalizeName("Mr Rime"), Is.EqualTo("Mr. Rime"));
     Assert.That(PokedexData.NormalizeName("Mime Jr"), Is.EqualTo("Mime Jr."));
     Assert.That(PokedexData.NormalizeName("Type Null"), Is.EqualTo("Type: Null"));
     Assert.That(PokedexData.NormalizeName("MissingNo"), Is.EqualTo("MissingNo."));
     Assert.That(PokedexData.NormalizeName("Farfetchd"), Is.EqualTo("Farfetch'd"));
     Assert.That(PokedexData.NormalizeName("Sirfetchd"), Is.EqualTo("Sirfetch'd"));
 }
コード例 #11
0
 public void recognizes_dashes_for_spaces()
 {
     Assert.That(PokedexData.NormalizeName("Mr.-Mime"), Is.EqualTo("Mr. Mime"));
     Assert.That(PokedexData.NormalizeName("Mr.-Rime"), Is.EqualTo("Mr. Rime"));
     Assert.That(PokedexData.NormalizeName("Mime-Jr."), Is.EqualTo("Mime Jr."));
     Assert.That(PokedexData.NormalizeName("Type:-Null"), Is.EqualTo("Type: Null"));
     Assert.That(PokedexData.NormalizeName("Tapu-Koko"), Is.EqualTo("Tapu Koko"));
     Assert.That(PokedexData.NormalizeName("Tapu-Lele"), Is.EqualTo("Tapu Lele"));
     Assert.That(PokedexData.NormalizeName("Tapu-Bulu"), Is.EqualTo("Tapu Bulu"));
     Assert.That(PokedexData.NormalizeName("Tapu-Fini"), Is.EqualTo("Tapu Fini"));
 }
コード例 #12
0
 public void recognizes_omitted_spaces()
 {
     Assert.That(PokedexData.NormalizeName("Mr.Mime"), Is.EqualTo("Mr. Mime"));
     Assert.That(PokedexData.NormalizeName("Mr.Rime"), Is.EqualTo("Mr. Rime"));
     Assert.That(PokedexData.NormalizeName("MimeJr."), Is.EqualTo("Mime Jr."));
     Assert.That(PokedexData.NormalizeName("Type:Null"), Is.EqualTo("Type: Null"));
     Assert.That(PokedexData.NormalizeName("TapuKoko"), Is.EqualTo("Tapu Koko"));
     Assert.That(PokedexData.NormalizeName("TapuLele"), Is.EqualTo("Tapu Lele"));
     Assert.That(PokedexData.NormalizeName("TapuBulu"), Is.EqualTo("Tapu Bulu"));
     Assert.That(PokedexData.NormalizeName("TapuFini"), Is.EqualTo("Tapu Fini"));
 }
コード例 #13
0
        /// <summary>
        /// Creates a new instance of all objects that are null
        /// </summary>
        public void InitNullObjects()
        {
            //MapFiles = new List<Resources.MapFileData>();
            //Maps = new List<Resources.MapData>();

            if (AudioResources == null)
            {
                AudioResources = new List <SoundSystem.SaveData.AudioData>();
            }
            if (ImageResources == null)
            {
                ImageResources = new List <Resource_Data.Resources>();
            }

            PokedexData.InitNullObjects();
        }
コード例 #14
0
 public void passes_through_exact_name()
 {
     string[] names =
     {
         "Nidoran♀",   "Nidoran♂",
         "Farfetch'd", "Sirfetch'd",
         "Mr. Mime",   "Mr. Rime",  "Mime Jr.",
         "Jangmo-o",   "Hakamo-o",  "Kommo-o",
         "Tapu Koko",  "Tapu Lele", "Tapu Bulu", "Tapu Fini",
         "Ho-Oh",
         "Porygon-Z",
         "Flabébé",
         "Type: Null",
         "MissingNo."
     };
     foreach (string name in names)
     {
         Assert.That(PokedexData.NormalizeName(name), Is.EqualTo(name));
     }
 }
コード例 #15
0
ファイル: ModeBase.cs プロジェクト: Dnantz/tpp-core
        public ModeBase(ILoggerFactory loggerFactory, BaseConfig baseConfig, StopToken stopToken)
        {
            PokedexData pokedexData = PokedexData.Load();

            Setups.Databases repos      = Setups.SetUpRepositories(baseConfig);
            ArgsParser       argsParser = Setups.SetUpArgsParser(repos.UserRepo, pokedexData);

            var chats       = new Dictionary <string, IChat>();
            var chatFactory = new ChatFactory(loggerFactory, SystemClock.Instance, repos.UserRepo);

            foreach (ConnectionConfig connectorConfig in baseConfig.Chat.Connections)
            {
                IChat chat = chatFactory.Create(connectorConfig);
                if (chats.ContainsKey(chat.Name))
                {
                    throw new ArgumentException($"chat name '{chat.Name}' was used multiple times. It must be unique.");
                }
                chats[chat.Name] = chat;
            }
            _chats = chats.ToImmutableDictionary();
            foreach (IChat chat in _chats.Values)
            {
                chat.IncomingMessage += MessageReceived;
            }
            _commandResponders = _chats.Values.ToImmutableDictionary(
                c => c.Name,
                c => (ICommandResponder) new CommandResponder(c));
            _commandProcessors = _chats.Values.ToImmutableDictionary(
                c => c.Name,
                c => Setups.SetUpCommandProcessor(loggerFactory, argsParser, repos, stopToken, baseConfig.Chat, c, c, pokedexData.KnownSpecies));

            _messagequeueRepo           = repos.MessagequeueRepo;
            _messagelogRepo             = repos.MessagelogRepo;
            _forwardUnprocessedMessages = baseConfig.Chat.ForwardUnprocessedMessages;
            _clock = SystemClock.Instance;
        }
コード例 #16
0
ファイル: PokedexDataTest.cs プロジェクト: Yoso2/tpp-core
 public void is_case_insensitive()
 {
     Assert.AreEqual("Porygon-Z", PokedexData.NormalizeName("porygon-z"));
     Assert.AreEqual("Ho-Oh", PokedexData.NormalizeName("HO-OH"));
 }
コード例 #17
0
        public void successfully_loads_known_species()
        {
            PokedexData pokedexData = PokedexData.Load();

            Assert.IsTrue(pokedexData.KnownSpecies.Any(), "pokemon name data missing or empty");
        }
コード例 #18
0
ファイル: PokedexDataTest.cs プロジェクト: Yoso2/tpp-core
 public void requires_full_match()
 {
     Assert.AreEqual("Porygon-Z", PokedexData.NormalizeName("Porygon-Z"));
     Assert.AreNotEqual("Porygon-Z", PokedexData.NormalizeName("~Porygon-Z"));
     Assert.AreNotEqual("Porygon-Z", PokedexData.NormalizeName("Porygon-Z~"));
 }
コード例 #19
0
 public void requires_full_match()
 {
     Assert.That(PokedexData.NormalizeName("Porygon-Z"), Is.EqualTo("Porygon-Z"));
     Assert.That(PokedexData.NormalizeName("~Porygon-Z"), Is.Not.EqualTo("Porygon-Z"));
     Assert.That(PokedexData.NormalizeName("Porygon-Z~"), Is.Not.EqualTo("Porygon-Z"));
 }
コード例 #20
0
 public void is_case_insensitive()
 {
     Assert.That(PokedexData.NormalizeName("porygon-z"), Is.EqualTo("Porygon-Z"));
     Assert.That(PokedexData.NormalizeName("HO-OH"), Is.EqualTo("Ho-Oh"));
 }
コード例 #21
0
        public ModeBase(
            ILoggerFactory loggerFactory,
            Setups.Databases repos,
            BaseConfig baseConfig,
            StopToken stopToken,
            OverlayConnection overlayConnection,
            ProcessMessage?processMessage = null)
        {
            IClock clock = SystemClock.Instance;

            _logger = loggerFactory.CreateLogger <ModeBase>();
            PokedexData pokedexData = PokedexData.Load();
            ArgsParser  argsParser  = Setups.SetUpArgsParser(repos.UserRepo, pokedexData);

            _processMessage = processMessage ?? (_ => Task.FromResult(false));

            var chats       = new Dictionary <string, IChat>();
            var chatFactory = new ChatFactory(loggerFactory, clock,
                                              repos.UserRepo, repos.TokensBank, repos.SubscriptionLogRepo, repos.LinkedAccountRepo,
                                              overlayConnection);

            foreach (ConnectionConfig connectorConfig in baseConfig.Chat.Connections)
            {
                IChat chat = chatFactory.Create(connectorConfig);
                if (chats.ContainsKey(chat.Name))
                {
                    throw new ArgumentException($"chat name '{chat.Name}' was used multiple times. It must be unique.");
                }
                chats[chat.Name] = chat;
            }
            _chats = chats.ToImmutableDictionary();
            foreach (IChat chat in _chats.Values)
            {
                chat.IncomingMessage += MessageReceived;
            }
            _commandResponders = _chats.Values.ToImmutableDictionary(
                c => c.Name,
                c => (ICommandResponder) new CommandResponder(c));
            _commandProcessors = _chats.Values.ToImmutableDictionary(
                c => c.Name,
                c => Setups.SetUpCommandProcessor(loggerFactory, argsParser, repos, stopToken, c, c,
                                                  pokedexData.KnownSpecies));

            _messagequeueRepo           = repos.MessagequeueRepo;
            _messagelogRepo             = repos.MessagelogRepo;
            _forwardUnprocessedMessages = baseConfig.Chat.ForwardUnprocessedMessages;
            _clock = SystemClock.Instance;

            ILogger <Moderator> moderatorLogger = loggerFactory.CreateLogger <Moderator>();

            IImmutableList <IModerationRule> availableRules = ImmutableList.Create <IModerationRule>(
                new BannedUrlsRule(),
                new SpambotRule(),
                new EmoteRule(),
                new CopypastaRule(clock),
                new UnicodeCharacterCategoryRule()
                );

            foreach (string unknown in baseConfig.DisabledModbotRules.Except(availableRules.Select(rule => rule.Id)))
            {
                moderatorLogger.LogWarning("unknown modbot rule '{UnknownRule}' marked as disabled", unknown);
            }
            IImmutableList <IModerationRule> rules = availableRules
                                                     .Where(rule => !baseConfig.DisabledModbotRules.Contains(rule.Id))
                                                     .ToImmutableList();

            _moderators = _chats.Values.ToImmutableDictionary(
                c => c.Name,
                c => (IModerator) new Moderator(moderatorLogger, c, rules, repos.ModLogRepo, clock));
        }