public void AmeisenBotStateMachineTest()
        {
            IWowDataAdapter    wowDataAdapter    = new TestWowDataAdapter();
            IWowActionExecutor wowActionExecutor = new TestWowActionExecutor();

            AmeisenBot ameisenBot = new AmeisenBot(null, wowDataAdapter, null, null);

            ameisenBot.Attach(wowActionExecutor, null, null, new BasicMeleeMovementProvider(), null);

            AmeisenBotStateMachine stateMachine = new AmeisenBotStateMachine(ameisenBot.WowDataAdapter, ameisenBot.WowActionExecutor, null, null, null);

            Assert.IsTrue(stateMachine.CurrentState is BotStateIdle);

            stateMachine.SwitchState(typeof(BotStateFollow));
            Assert.IsTrue(stateMachine.CurrentState is BotStateFollow);

            Assert.AreEqual("You suck", wowDataAdapter.LastErrorMessage);

            wowDataAdapter.StartObjectUpdates();
            wowDataAdapter.StopObjectUpdates();
        }
Beispiel #2
0
        private void SetupNewAmeisenBot(WowAccount account, WowProcess wowProcess)
        {
            WowAccounts[account] = BotStartState.BotIsAttaching;

            TrashMem                    trashMem                    = new TrashMem(wowProcess.Process);
            MemoryWowDataAdapter        memoryWowDataAdapter        = new MemoryWowDataAdapter(trashMem, OffsetList);
            MemoryWowActionExecutor     memoryWowActionExecutioner  = new MemoryWowActionExecutor(trashMem, OffsetList);
            AmeisenNavPathfindingClient ameisenNavPathfindingClient = new AmeisenNavPathfindingClient(Settings.AmeisenNavmeshServerIp, Settings.AmeisenNavmeshServerPort, wowProcess.Process.Id);
            LuaHookWowEventAdapter      luaHookWowEventAdapter      = new LuaHookWowEventAdapter(memoryWowActionExecutioner);
            BasicMeleeMovementProvider  basicMeleeMovementProvider  = new BasicMeleeMovementProvider();
            SimpleAutologinProvider     simpleAutologinProvider     = new SimpleAutologinProvider();

            AmeisenBot        ameisenBot        = new AmeisenBot(trashMem, memoryWowDataAdapter, simpleAutologinProvider, wowProcess.Process);
            ManagedAmeisenBot managedAmeisenBot = new ManagedAmeisenBot(wowProcess, account, ameisenBot);

            if (ameisenBot.AutologinProvider.DoLogin(wowProcess.Process, account, OffsetList))
            {
                ameisenBot.Attach(memoryWowActionExecutioner, ameisenNavPathfindingClient, luaHookWowEventAdapter, basicMeleeMovementProvider, null);
                if (Settings.WowPositions.ContainsKey(account.CharacterName))
                {
                    ameisenBot.SetWindowPosition(Settings.WowPositions[account.CharacterName]);
                }

                ManagedAmeisenBots.Add(managedAmeisenBot);

                IAmeisenBotViews.OfType <WowView>().ToList().RemoveAll(v => v.WowProcess.Process.Id == managedAmeisenBot.WowProcess.Process.Id);

                WowAccounts[account] = BotStartState.BotIsAttached;
            }
            else
            {
                // we failed to login, restart wow...
                if (!wowProcess.Process.HasExited)
                {
                    wowProcess.Process.Kill();
                }
                WowAccounts[account] = BotStartState.None;
            }
        }