From 9b8e3559a4d7b97008ec289cfc36dd182f0ead04 Mon Sep 17 00:00:00 2001 From: DryByte <93609026+DryByte@users.noreply.github.com> Date: Tue, 14 Mar 2023 22:12:11 -0300 Subject: [PATCH] Move examples from test folder to examples, remove useless tests --- README.md | 2 +- {test => examples}/buildingBot.js | 2 +- {test => examples}/chatBot.js | 0 {test => examples}/genMapImage.js | 6 +- {test => examples}/images_to_build/.gitignore | 0 {test => examples}/maps/.gitignore | 0 {test => examples}/weaponInteraction.js | 0 test/clientConnection.js | 16 ---- test/fullClientTest.js | 89 ------------------- test/vxlTest.js | 19 ---- 10 files changed, 5 insertions(+), 129 deletions(-) rename {test => examples}/buildingBot.js (97%) rename {test => examples}/chatBot.js (100%) rename {test => examples}/genMapImage.js (91%) rename {test => examples}/images_to_build/.gitignore (100%) rename {test => examples}/maps/.gitignore (100%) rename {test => examples}/weaponInteraction.js (100%) delete mode 100644 test/clientConnection.js delete mode 100644 test/fullClientTest.js delete mode 100644 test/vxlTest.js diff --git a/README.md b/README.md index 63a3af1..62f2264 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ Execute: `npm install https://github.com/DryByte/AoS.js` ## How to use -Check _test_ folder in the repository, in there you can check some examples. Remember to change `require("../src")` to `require("aos.js")`. +Check _examples_ folder in the repository, in there you can check some examples. Remember to change `require("../src")` to `require("aos.js")`. ## Getting the docs on web #### Online docs: diff --git a/test/buildingBot.js b/examples/buildingBot.js similarity index 97% rename from test/buildingBot.js rename to examples/buildingBot.js index eafab2f..94bdf3e 100644 --- a/test/buildingBot.js +++ b/examples/buildingBot.js @@ -39,7 +39,7 @@ function sleep(ms) { } async function startBuilding() { - let image = await loadImage("./test/images_to_build/logo1.png"); + let image = await loadImage("./examples/images_to_build/logo1.png"); let canvas = createCanvas(image.width, image.height); let ctx = canvas.getContext("2d"); ctx.drawImage(image,0,0); diff --git a/test/chatBot.js b/examples/chatBot.js similarity index 100% rename from test/chatBot.js rename to examples/chatBot.js diff --git a/test/genMapImage.js b/examples/genMapImage.js similarity index 91% rename from test/genMapImage.js rename to examples/genMapImage.js index 2021362..0b4d57d 100755 --- a/test/genMapImage.js +++ b/examples/genMapImage.js @@ -37,7 +37,7 @@ function createMap() { } const b = canvas.toBuffer('image/png'); - fs.writeFileSync(`./test/maps/map_${Date.now()}.png`, b); + fs.writeFileSync(`./examples/maps/map_${Date.now()}.png`, b); console.log(`Created map: ${Date.now()}`); } @@ -71,11 +71,11 @@ client.connect("aos://16777343:32887"); process.on('SIGINT', function() { console.log("Cleaning maps directory..."); - let maps = fs.readdirSync("./test/maps"); + let maps = fs.readdirSync("./examples/maps"); for (let _map of maps) { if(_map.endsWith(".png")) { - fs.unlinkSync(`./test/maps/${_map}`); + fs.unlinkSync(`./examples/maps/${_map}`); } } diff --git a/test/images_to_build/.gitignore b/examples/images_to_build/.gitignore similarity index 100% rename from test/images_to_build/.gitignore rename to examples/images_to_build/.gitignore diff --git a/test/maps/.gitignore b/examples/maps/.gitignore similarity index 100% rename from test/maps/.gitignore rename to examples/maps/.gitignore diff --git a/test/weaponInteraction.js b/examples/weaponInteraction.js similarity index 100% rename from test/weaponInteraction.js rename to examples/weaponInteraction.js diff --git a/test/clientConnection.js b/test/clientConnection.js deleted file mode 100644 index 2b9a958..0000000 --- a/test/clientConnection.js +++ /dev/null @@ -1,16 +0,0 @@ -const AoS = require("../src"); - -describe("Client creation test", () => { - it("Connect to local server and receive state data packet.", (done) => { - let client = new AoS.Client(); - - client.on("rawPacket", (packet) => { - if(packet[0] == 15){ - done(); - process.exit(0); - } - }); - - client.connect("127.0.0.1:32887"); - }) -}); \ No newline at end of file diff --git a/test/fullClientTest.js b/test/fullClientTest.js deleted file mode 100644 index 5fee818..0000000 --- a/test/fullClientTest.js +++ /dev/null @@ -1,89 +0,0 @@ -const AoS = require("../src"); - -describe("60s client test", function () { - this.timeout(60000); - - it("This is supposed to run the client until he crashes.", () => { - let client = new AoS.Client({name: "test bot"}); - - client.on("ready", () => { - console.log("Created the client!"); - }); - - client.on("connect", () => { - console.log("Client connected to the server!"); - }); - - client.on("MapStart", (fields) => { - console.log("Map start packet:"); - console.log(fields); - }); - - client.on("MapChunk", (fields) => { - console.log("Map chunk packet:"); - console.log(fields); - }); - - client.on("StateData", (fields) => { - console.log("State data packet:"); - console.log(fields); - - client.joinGame(); - - client.sendMessage("hello, nice to meet you :D", 0); - client.sendMessage("LETS WIN THIS GAME, TEAM!!", 1); - }); - - client.on("ExistingPlayer", (fields) => { - console.log("Existing player packet:"); - console.log(fields); - }); - - client.on("CreatePlayer", (fields) => { - console.log("Create player packet:"); - console.log(fields); - }); - - client.on("PlayerLeft", (fields) => { - console.log("Player left packet:"); - console.log(fields); - }); - - client.on("ChatMessage", (fields) => { - console.log("Received a Message:"); - console.log(fields); - }); - - client.on("IntelCapture", (fields) => { - console.log("Intel capture:"); - console.log(fields); - }); - - client.on("WinCapture", (fields) => { - console.log("Capture for the win:"); - console.log(fields); - }); - - client.on("IntelPickup", (fields) => { - console.log("Intel pickup:"); - console.log(fields); - }); - - client.on("IntelDrop", (fields) => { - console.log("Intel drop:"); - console.log(fields); - }); - - /*client.on("WorldUpdate", (fields) => { - //We access client.game.players because have - //better values and will display who is playing - console.log("World update packet:"); - console.log(client.game.players); - });*/ - /*client.on("rawPacket", (p) => { - console.log(p[0]) - })*/ - - client.connect("aos://16777343:32887"); - }) -}) \ No newline at end of file diff --git a/test/vxlTest.js b/test/vxlTest.js deleted file mode 100644 index c800f89..0000000 --- a/test/vxlTest.js +++ /dev/null @@ -1,19 +0,0 @@ -const AoS = require("../src"); -let client = new AoS.Client(); -const fs = require("fs") - -client.on("connect", () => { - console.log("Client connected to the server!"); -}); - -client.on("StateData", (fields) => { - let a = Date.now(); - console.log("Lets do it"); - let c = client.game.map.saveVXL(); - console.log(`Done in: ${Date.now()-a}`) - console.log(c) - - fs.writeFileSync("test.vxl", c); -}); - -client.connect("aos://127.0.0.1:32887"); \ No newline at end of file