Jump to content
Frequently Asked Questions
  • Are you not able to open the client? Try following our getting started guide
  • Still not working? Try downloading and running JarFix
  • Help! My bot doesn't do anything! Enable fresh start in client settings and restart the client
  • How to purchase with PayPal/OSRS/Crypto gold? You can purchase vouchers from other users
  • leccles

    Members
    • Posts

      3
    • Joined

    • Last visited

    leccles's Achievements

    1. DreamBot tree branch is implemented based on this repo tbh. I was using that same repo, until I realised the baked in Treebranch in DreamBot is literally a direct implementation of this. It even calls this out in the Javadocs. You can basically forego everything in the 'Framework' directory from that repo as Dreambot has implemented it. I do keep the utils and GUI packages around though as they're still incredibly useful
    2. Some great feedback, thanks for the thoughtful answers.
    3. I previously was involved with another bot, back in the day like 2016 era. I tried my hand at bot scripting during that time but didn't achieve much. I'm a Node, Python, Flutter dev now and have been picking up the Dreambot API and trying my hand at Java which has been quite fun. Anyway, lurking in the forums long enough I've made some progress and particularly enjoy Tree scripts, OSRS is actually down right now for maintenance and I've started refactoring my current mining bot and to verify my node validity and thought it would be sweet to have unit tests. A couple of questions spring to mind; Why is it that a very large portion of the Dreambot API are static? I get most methods are utility methods, but in order to provide any kind of mocking for these in a simulated environment I have to make my own injectable singleton that is then mockable. Going this route also avoids disgusting levels of nesting `try` blocks for each static method that requires mocking. I see a lot of people also referencing "Make your class methods static, so they're callable from anywhere" but something in my brain just refuses to get on board with that, as it kinda goes against a lot of basic principles of programming. Has anyone else had success in developing bots that are actually unit testable. I haven't quite gotten as far as being able to test the `onLoop` of a Node yet but am scouring the web for how to test game loop logic. I know that unit tests alone aren't going to be fool proof in terms of testing bots, but it definitely can help verify changes to the code don't break existing functionality & to also sanity check bot logic. Throwing in a snippet of one of my tests that currently executes the MiningSetup node. If a player doesn't have a pickaxe in their inventory, or their equipped items. This node executes and goes to the closest bank to check there for one, and if found withdraw it. import com.aio_miner.config.Config; import com.aio_miner.data.Pickaxe; import org.dreambot.api.methods.skills.Skill; import org.dreambot.api.utilities.Logger; import org.dreambot.util.EquipmentService; import org.dreambot.util.InventoryService; import org.dreambot.util.SkillsService; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.mockito.MockedStatic; import org.mockito.Mockito; import static org.junit.jupiter.api.Assertions.*; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; class MiningSetupTest { private MiningSetup node; private InventoryService inventoryService; private SkillsService skillsService; private EquipmentService equipmentService; private Config config; @BeforeEach void setUp() { inventoryService = mock(InventoryService.class); skillsService = mock(SkillsService.class); equipmentService = mock(EquipmentService.class); config = Config.getConfig(); node = new MiningSetup(config, inventoryService, skillsService, equipmentService); } @Test void playerHasPickaxe() { // Mocks when(inventoryService.contains(Pickaxe.BRONZE_PICKAXE.ID)).thenReturn(true); when(skillsService.getRealLevel(any(Skill.class))).thenReturn(15); when(equipmentService.contains(anyInt())).thenReturn(false); try (MockedStatic<Logger> logMock = Mockito.mockStatic(Logger.class)) { assertTrue(inventoryService.contains(Pickaxe.BRONZE_PICKAXE.ID)); assertFalse(equipmentService.contains(anyInt())); //Node is invalid because we have a pickaxe. assertFalse(node.isValid()); } assertEquals(15, config.getCurrentLevel()); assertEquals(Pickaxe.BRONZE_PICKAXE, config.getBestOwnedPickaxe()); } @Test void playerDoesNotHavePickaxe() { // Mocks when(inventoryService.contains(anyInt())).thenReturn(false); when(skillsService.getRealLevel(any(Skill.class))).thenReturn(0); when(equipmentService.contains(anyInt())).thenReturn(false); try (MockedStatic<Logger> logMock = Mockito.mockStatic(Logger.class)) { assertFalse(inventoryService.contains(Pickaxe.RUNE_PICKAXE.ID)); assertFalse(equipmentService.contains(Pickaxe.RUNE_PICKAXE.ID)); assertTrue(node.isValid()); } assertEquals(0, config.getCurrentLevel()); assertNull(config.getBestOwnedPickaxe()); } }
    ×
    ×
    • Create New...

    Important Information

    We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.