From 85229deb0a8285904111092e512c89174b33c5f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wojciech=20=C5=81ukasik?= Date: Tue, 28 Apr 2020 12:00:21 +0200 Subject: [PATCH] porzadki --- frontend/index.html | 2 +- frontend/js/Agent.js | 87 ----------------------------- frontend/js/Board.js | 30 ---------- frontend/js/Field.js | 22 -------- frontend/js/main.js | 9 +-- frontend/js/script.js | 125 ------------------------------------------ 6 files changed, 6 insertions(+), 269 deletions(-) delete mode 100644 frontend/js/Agent.js delete mode 100644 frontend/js/Board.js delete mode 100644 frontend/js/Field.js delete mode 100644 frontend/js/script.js diff --git a/frontend/index.html b/frontend/index.html index f65b762..16e6a53 100644 --- a/frontend/index.html +++ b/frontend/index.html @@ -8,7 +8,7 @@ - +
diff --git a/frontend/js/Agent.js b/frontend/js/Agent.js deleted file mode 100644 index 1a51fc2..0000000 --- a/frontend/js/Agent.js +++ /dev/null @@ -1,87 +0,0 @@ -export default class Agent{ - constructor(positionX, positionY, turn){ - this.positionX = positionX; - this.positionY = positionY; - this.turn = turn; - } - - getParams(){ - let params = {}; - - positionX = this.positionX; - positionY = this.positionY; - turn = this.turn; - - params = {positionX, positionY, turn}; - - return params; - } - - goForward(){ - if(this.turn == 'Up'){ - this.positionY += 1; - } - else if(this.turn == 'Down'){ - this.positionY -= 1; - } - else if(this.turn == 'Left'){ - this.positionX -= 1; - } - else if(this.turn == 'Right'){ - this.positionX += 1; - } - } - - turnLeft(){ - if(this.turn == 'Up'){ - this.turn = 'Left'; - } - else if(this.turn == 'Down'){ - this.turn = 'Right'; - } - else if(this.turn == 'Left'){ - this.turn = 'Down'; - } - else if(this.turn == 'Right'){ - this.turn = 'Up' - } - } - - turnRight(){ - if(this.turn == 'Up'){ - this.turn = 'Right'; - } - else if(this.turn == 'Down'){ - this.turn = 'Left'; - } - else if(this.turn == 'Left'){ - this.turn = 'Up'; - } - else if(this.turn == 'Right'){ - this.turn = 'Down' - } - } - - showAgent(){ - console.log(this.turn) - if(this.turn === "Up"){ - document.getElementById(this.positionX + "-" + this.positionY).style.backgroundImage = "url('img/Up.png')"; - } - else if(this.turn === "Down"){ - document.getElementById(this.positionX + "-" + this.positionY).style.backgroundImage = "url('img/Down.png')"; - } - else if(this.turn === "Right"){ - document.getElementById(this.positionX + "-" + this.positionY).style.backgroundImage = "url('img/Right.png')"; - } - else if(this.turn === "Left"){ - document.getElementById(this.positionX + "-" + this.positionY).style.backgroundImage = "url('img/Left.png')"; - } - - } - - hideAgent(){ - document.getElementById(this.positionX + "-" + this.positionY).style.backgroundImage = ""; - } - - -} \ No newline at end of file diff --git a/frontend/js/Board.js b/frontend/js/Board.js deleted file mode 100644 index 178bfb1..0000000 --- a/frontend/js/Board.js +++ /dev/null @@ -1,30 +0,0 @@ -import Field from './Field.js' - -export function createBoard(rangeX, rangeY){ - const board = []; - - for(let y = 0; y < rangeY; y++){ - const row = []; - for(let x = 0; x < rangeX; x++){ - let field = new Field(x, y, false, false, 1); - row.push(field) - } - board.push(row) - } - return board -} - -export function showBoard(board){ - for(let y = board.length - 1; y >= 0 ; y--){ - document.getElementById("board").innerHTML += "
"; - - for(let x = 0; x < board[y].length; x++){ - document.getElementById("row-" + y).innerHTML += "
" - } - } -} - - - - - diff --git a/frontend/js/Field.js b/frontend/js/Field.js deleted file mode 100644 index 7e2b03b..0000000 --- a/frontend/js/Field.js +++ /dev/null @@ -1,22 +0,0 @@ -export default class Field{ - constructor(x, y, isShelf, isOccupiedByAgent, costOfTravel){ - this.xField = x; - this.yField = y; - this.isShelf = isShelf; - this.isOccupiedByAgent = isOccupiedByAgent; - this.costOfTravel = costOfTravel; - } - - getParams(){ - let params = {}; - - xField = this.xField; - yField = this.yField; - isShelf = this.isShelf; - isOccupiedByAgent = this.isOccupiedByAgent; - costOfTravel = this.costOfTravel; - params = {xField, yField, isShelf, isOccupiedByAgent, costOfTravel} - - return params; - } -} \ No newline at end of file diff --git a/frontend/js/main.js b/frontend/js/main.js index 178bb7e..8534d3a 100644 --- a/frontend/js/main.js +++ b/frontend/js/main.js @@ -110,7 +110,7 @@ class Field{ } } -//funckcje +//funkcje function createBoard(rangeX, rangeY){ const board = []; @@ -136,12 +136,13 @@ function showBoard(board){ } } -let board = createBoard(10,10); -let agent = new Agent(0,0, 'Right'); function start(){ + let board = createBoard(10,10); + let agent = new Agent(0,0, 'Right'); showBoard(board); - agent.showAgent(); + agent.showAgent() + } diff --git a/frontend/js/script.js b/frontend/js/script.js deleted file mode 100644 index 44ad711..0000000 --- a/frontend/js/script.js +++ /dev/null @@ -1,125 +0,0 @@ -// import Agent from './Agent.js' - -// //Klasy - - -// class Field { -// constructor(x, y, isEmpty) { -// this.xField = x; -// this.yField = y; -// this.isFieldEmpty = isEmpty; -// } -// getCoordinates(){ -// return this.xField + this.yField; -// } - -// getStatus(){ -// return this.isFieldEmpty; -// } -// } - -// class Product { -// constructor(name, type, farcing, price) { -// this.name = name; -// this.type = type; -// this.farcing = farcing; -// this.price = price -// } -// } - -// class Rack{ -// constructor(noOfShelf, typOfProduct) { -// this.noOfShelf = noOfShelf; -// } - -// addShelf(){ -// this.noOfShelf = this.noOfShelf + 1; -// } - -// isEmpty(){ -// if (this.noOfShelf === 0){ -// return true; -// }else { -// return false; -// } -// } -// } - -// class Shelf { -// constructor(number) { -// this.number = number; -// } -// } - - -// //Objekty i zmienne -// var regaly = ['1-1', '1-3', '1-4', '1-6', '1-7', '1-9', '2-1', '2-9', '3-3', '3-4', '3-6', '3-7', '4-1', '4-9', '5-1', '5-3', '5-4', '5-6', '5-7', '5-9'] -// const agent1 = new Agent(3, 0); - -// //Funkcja uruchamiajÄ…ca prace calego scriptu -// function start(){ -// //ponumerujPola(); -// pokolorujRegaly(); -// umiescAgenta(agent1); -// droga(agent1); -// } - -// //Funkcja kolorujaca miejsca na planszy gdzie znajduja sie regaly -// function pokolorujRegaly(){ -// let x; -// for(x = 0; x < regaly.length; x++){ -// document.getElementById(regaly[x]).className = 'regal'; -// } -// } - -// //Funkcja wyswietlajaca id pol -// function ponumerujPola(){ -// let x,y -// for(x = 0; x < 7; x++){ -// for(y = 0; y < 11; y++){ -// id = x.toString() + "-" + y.toString(); -// document.getElementById(id).innerHTML = id; -// } -// } -// } - -// //Funkcja usuwajÄ…ca agenta z pola, przed przemieszczeniem -// function usunAgenta(agent){ -// document.getElementById(agent.getId()).style.backgroundImage = "none"; -// } - - -// //Funckja wyswietlajaca agenta gdy ten zmieni polozenie -// function umiescAgenta(agent) { -// document.getElementById(agent.getId()).style.backgroundImage = "url('Agent.jpg')"; -// } - -// //Funkcja zmieniajaca polozenie agenta o 1 pole -// function przemieszczenie(side, time, agent){ -// const lastPosition = agent.getId(); -// setTimeout(function(){ -// usunAgenta(agent) -// if(side == "left") -// agent.left(); -// if(side == "right") -// agent.right(); -// if(side == "up") -// agent.up(); -// if(side == "down") -// agent.down(); -// umiescAgenta(agent); -// }, time); -// } - -// //Funkcja ktora ustala droge agenta do przebycia -// function droga(agent) { -// przemieszczenie("right", 1000, agent); -// przemieszczenie("right", 2000, agent); -// przemieszczenie("up", 3000, agent); -// przemieszczenie("right", 4000, agent); -// przemieszczenie("right", 5000, agent); -// przemieszczenie("right", 6000, agent); -// przemieszczenie("right", 7000, agent); -// przemieszczenie("right", 8000, agent); -// przemieszczenie("right", 9000, agent); -// }