Ejemplo n.º 1
0
        public override void Initialize(DiabloInterface di)
        {
            Logger.Info("Creating character stat file writer service.");

            SetConfig(di.configService.CurrentConfig.PluginConf(Name));
            di.game.DataRead += Game_DataRead;
        }
Ejemplo n.º 2
0
        public PluginService(DiabloInterface di, string pluginDir)
        {
            this.di = di;

            if (!Directory.Exists(pluginDir))
            {
                Directory.CreateDirectory(pluginDir);
            }
            List <Type> types = new List <Type>();

            foreach (FileInfo file in new DirectoryInfo(pluginDir).GetFiles("*.dll"))
            {
                try
                {
                    var assembly = Assembly.LoadFile(file.FullName);
                    types.AddRange(assembly.GetTypes());
                } catch (Exception e)
                {
                    Logger.Error($"Plugin not loaded {file.FullName} {e.Message}");
                }
            }
            plugins = types
                      .FindAll((Type t) => new List <Type>(t.GetInterfaces())
                               .Contains(typeof(IPlugin)))
                      .ConvertAll((Type t) => Activator.CreateInstance(t) as IPlugin);
        }
Ejemplo n.º 3
0
        public override void Initialize(DiabloInterface di)
        {
            Logger.Info("Creating auto split service.");

            SetConfig(di.configService.CurrentConfig.PluginConf(Name));
            di.game.CharacterCreated += Game_CharacterCreated;
            di.game.DataRead         += Game_DataRead;
        }
Ejemplo n.º 4
0
        public MainWindow(DiabloInterface di)
        {
            this.di = di;

            Logger.Info("Creating main window.");

            RegisterServiceEventHandlers();
            InitializeComponent();
            PopulateConfigFileListContextMenu(this.di.configService.ConfigFileCollection);
            ApplyConfig(this.di.configService.CurrentConfig);
        }
Ejemplo n.º 5
0
        public VerticalLayout(DiabloInterface di)
        {
            this.di = di;
            RegisterServiceEventHandlers();
            InitializeComponent();

            Load += (sender, e) => UpdateConfig(di.configService.CurrentConfig);

            // Clean up events when disposed because services outlive us.
            Disposed += (sender, e) => UnregisterServiceEventHandlers();
            Logger.Info("Creating vertical layout.");
        }
Ejemplo n.º 6
0
        public DebugWindow(DiabloInterface di)
        {
            Logger.Info("Creating debug window.");

            this.di = di;

            RegisterServiceEventHandlers();

            // Unregister event handlers when we are done.
            Disposed += (sender, args) =>
            {
                Logger.Info("Disposing debug window.");
                UnregisterServiceEventHandlers();
            };

            InitializeComponent();
        }
Ejemplo n.º 7
0
 public PluginService(DiabloInterface di, string pluginDir)
 {
     this.di = di;
     plugins = PluginsByTypes(ReadTypesInDir(pluginDir));
 }
Ejemplo n.º 8
0
 public PluginService(DiabloInterface di, List <Type> pluginTypes)
 {
     this.di = di;
     plugins = PluginsByTypes(pluginTypes);
 }
Ejemplo n.º 9
0
 public override void Initialize(DiabloInterface di)
 {
     SetConfig(di.configService.CurrentConfig.PluginConf(Name));
     AutomaticallyCheckVersion();
 }
Ejemplo n.º 10
0
 public GameService(DiabloInterface di)
 {
     this.di = di;
 }
Ejemplo n.º 11
0
 public override void Initialize(DiabloInterface di)
 {
     this.di = di;
     SetConfig(di.configService.CurrentConfig.PluginConf(Name));
 }
Ejemplo n.º 12
0
 public override void Initialize(DiabloInterface di)
 {
     SetConfig(di.configService.CurrentConfig.PluginConf(Name));
     di.game.DataRead += Game_DataRead;
 }
Ejemplo n.º 13
0
        public void ShouldReachAutosplits()
        {
            var splitOnGameStart = new AutoSplit(
                "game start",
                AutoSplit.SplitType.Special,
                1,
                (short)GameDifficulty.Normal
                );
            var splitOnGameClear = new AutoSplit(
                "100% done",
                AutoSplit.SplitType.Special,
                2,
                (short)GameDifficulty.Normal
                );
            var splitOnGameClearAllDifficulties = new AutoSplit(
                "100% done all difficulties",
                AutoSplit.SplitType.Special,
                3,
                (short)GameDifficulty.Normal
                );
            var splitOnCharLevel10 = new AutoSplit(
                "char level 10",
                AutoSplit.SplitType.CharLevel,
                10,
                (short)GameDifficulty.Normal
                );
            var splitOnArea1 = new AutoSplit(
                "area 1",
                AutoSplit.SplitType.Area,
                (int)Area.ROGUE_ENCAMPMENT,
                (short)GameDifficulty.Normal
                );
            var splitOnItem1 = new AutoSplit(
                "item 1",
                AutoSplit.SplitType.Item,
                1,
                (short)GameDifficulty.Normal
                );
            var splitOnGem1 = new AutoSplit(
                "gem 1",
                AutoSplit.SplitType.Gems,
                1,
                (short)GameDifficulty.Normal
                );
            var splitOnQuest81 = new AutoSplit(
                "quest 81 (den of evil)",
                AutoSplit.SplitType.Quest,
                81,
                (short)GameDifficulty.Normal
                );

            var cfg = new Config();

            cfg.Enabled = true;
            cfg.Splits  = new List <AutoSplit>();
            cfg.Splits.Add(splitOnGameStart);
            cfg.Splits.Add(splitOnGameClear);
            cfg.Splits.Add(splitOnGameClearAllDifficulties);
            cfg.Splits.Add(splitOnCharLevel10);
            cfg.Splits.Add(splitOnArea1);
            cfg.Splits.Add(splitOnItem1);
            cfg.Splits.Add(splitOnGem1);
            cfg.Splits.Add(splitOnQuest81);

            var config = new Mock <ApplicationConfig>();

            config.Setup(x => x.PluginConf(It.IsAny <string>())).Returns(cfg);
            var configService = new Mock <IConfigService>();

            configService.SetupGet(x => x.CurrentConfig).Returns(config.Object);

            var gameService = new GameServiceMock();

            var diabloInterface = new DiabloInterface();

            diabloInterface.configService = configService.Object;
            diabloInterface.game          = gameService;

            var autoSplitService = new Plugin();

            autoSplitService.Initialize(diabloInterface);

            var normalQuests = new List <Quest>()
            {
                QuestFactory.Create(QuestId.DenOfEvil, 0),
                QuestFactory.Create(QuestId.Andariel, 0),
            };

            var nightmareQuests = new List <Quest>()
            {
                QuestFactory.Create(QuestId.DenOfEvil, 0),
                QuestFactory.Create(QuestId.Andariel, 0),
            };

            var hellQuests = new List <Quest>()
            {
                QuestFactory.Create(QuestId.DenOfEvil, 0),
                QuestFactory.Create(QuestId.Andariel, 0),
            };

            var quests = new Quests(new List <List <Quest> >
            {
                normalQuests,
                nightmareQuests,
                hellQuests,
            });

            var itemStrings = new Dictionary <BodyLocation, string>();
            var itemsIds    = new List <int>();

            var characterMock = new Mock <Character>();

            characterMock.SetupGet(x => x.Level).Returns(9);
            characterMock.SetupGet(x => x.IsNewChar).Returns(true);
            characterMock.SetupGet(x => x.InventoryItemIds).Returns(itemsIds);

            var game = new Game();

            game.Area       = 0;
            game.Difficulty = GameDifficulty.Normal;
            game.PlayersX   = 1;
            game.GameCount  = 0;
            game.CharCount  = 0;
            game.Character  = characterMock.Object;
            game.Quests     = quests;

            var args = new DataReadEventArgs(game);

            // test autosplit by game start
            Assert.AreEqual(false, splitOnGameStart.IsReached);
            gameService.triggerDataRead(null, args);
            Assert.AreEqual(true, splitOnGameStart.IsReached);

            // test autosplit by level
            Assert.AreEqual(false, splitOnCharLevel10.IsReached);
            gameService.triggerDataRead(null, args);
            Assert.AreEqual(false, splitOnCharLevel10.IsReached);

            characterMock.SetupGet(x => x.Level).Returns(10);
            gameService.triggerDataRead(null, args);
            Assert.AreEqual(true, splitOnCharLevel10.IsReached);

            // test autosplit by area
            Assert.AreEqual(false, splitOnArea1.IsReached);
            game.Area = (int)Area.ROGUE_ENCAMPMENT;
            gameService.triggerDataRead(null, args);
            game.Area = (int)Area.ROGUE_ENCAMPMENT + 1;
            Assert.AreEqual(true, splitOnArea1.IsReached);

            // test autosplit by item
            Assert.AreEqual(false, splitOnItem1.IsReached);
            Assert.AreEqual(false, splitOnGem1.IsReached);
            itemsIds.Add(1);
            gameService.triggerDataRead(null, args);
            Assert.AreEqual(true, splitOnItem1.IsReached);
            Assert.AreEqual(true, splitOnGem1.IsReached);

            // test autosplit by quest
            Assert.AreEqual(false, splitOnQuest81.IsReached);
            normalQuests.Clear();
            normalQuests.Add(QuestFactory.Create(QuestId.DenOfEvil, 1 << 0));
            normalQuests.Add(QuestFactory.Create(QuestId.Andariel, 0));
            gameService.triggerDataRead(null, args);
            Assert.AreEqual(true, splitOnQuest81.IsReached);

            // test autosplit on game clear
            Assert.AreEqual(false, splitOnGameClear.IsReached);
            normalQuests.Clear();
            normalQuests.Add(QuestFactory.Create(QuestId.DenOfEvil, 1 << 0));
            normalQuests.Add(QuestFactory.Create(QuestId.Andariel, 1 << 0));
            gameService.triggerDataRead(null, args);
            Assert.AreEqual(true, splitOnGameClear.IsReached);

            // test autosplit on game clear all difficulties
            Assert.AreEqual(false, splitOnGameClearAllDifficulties.IsReached);
            nightmareQuests.Clear();
            nightmareQuests.Add(QuestFactory.Create(QuestId.DenOfEvil, 1 << 0));
            nightmareQuests.Add(QuestFactory.Create(QuestId.Andariel, 1 << 0));
            gameService.triggerDataRead(null, args);
            Assert.AreEqual(false, splitOnGameClearAllDifficulties.IsReached);
            hellQuests.Clear();
            hellQuests.Add(QuestFactory.Create(QuestId.DenOfEvil, 1 << 0));
            hellQuests.Add(QuestFactory.Create(QuestId.Andariel, 1 << 0));
            gameService.triggerDataRead(null, args);
            Assert.AreEqual(true, splitOnGameClearAllDifficulties.IsReached);
        }
Ejemplo n.º 14
0
        public void ShouldNotSplitIfDisabled()
        {
            var split = new AutoSplit(
                "one",
                AutoSplit.SplitType.CharLevel,
                10,
                (short)GameDifficulty.Normal
                );

            var cfg = new Config();

            cfg.Enabled = false;
            cfg.Splits  = new List <AutoSplit>();
            cfg.Splits.Add(split);

            var config = new Mock <ApplicationConfig>();

            config.Setup(x => x.PluginConf(It.IsAny <string>())).Returns(cfg);
            var configService = new Mock <IConfigService>();

            configService.SetupGet(x => x.CurrentConfig).Returns(config.Object);

            var gameService = new GameServiceMock();

            var diabloInterface = new DiabloInterface();

            diabloInterface.configService = configService.Object;
            diabloInterface.game          = gameService;

            var autoSplitService = new Plugin();

            autoSplitService.Initialize(diabloInterface);

            var quests = new Quests(new List <List <Quest> >
            {
                new List <Quest>(), // NORMAL
                new List <Quest>(), // NM
                new List <Quest>(), // HELL
            });

            var characterMock = new Mock <Character>();

            characterMock.SetupGet(x => x.Level).Returns(9);
            characterMock.SetupGet(x => x.IsNewChar).Returns(true);
            characterMock.SetupGet(x => x.InventoryItemIds).Returns(new List <int>());

            var game = new Game();

            game.Area       = 0;
            game.Difficulty = GameDifficulty.Normal;
            game.PlayersX   = 1;
            game.GameCount  = 0;
            game.CharCount  = 0;
            game.Character  = characterMock.Object;
            game.Quests     = quests;

            var args = new DataReadEventArgs(game);

            // test autosplit by level
            gameService.triggerDataRead(null, args);
            Assert.AreEqual(false, split.IsReached);

            characterMock.SetupGet(x => x.Level).Returns(10);
            gameService.triggerDataRead(null, args);
            Assert.AreEqual(false, split.IsReached);
        }
Ejemplo n.º 15
0
 public abstract void Initialize(DiabloInterface di);