diff --git a/index.html b/game.html similarity index 100% rename from index.html rename to game.html diff --git a/images/items/briquettes.png b/images/items/briquettes.png new file mode 100644 index 0000000..cdae365 Binary files /dev/null and b/images/items/briquettes.png differ diff --git a/images/tiles/filterleft10.png b/images/tiles/filterleft10.png new file mode 100644 index 0000000..30ffb3b Binary files /dev/null and b/images/tiles/filterleft10.png differ diff --git a/images/tiles/filterright10.png b/images/tiles/filterright10.png new file mode 100644 index 0000000..b84c0d5 Binary files /dev/null and b/images/tiles/filterright10.png differ diff --git a/images/tiles/papermanufactory10.png b/images/tiles/papermanufactory10.png new file mode 100644 index 0000000..e9865e0 Binary files /dev/null and b/images/tiles/papermanufactory10.png differ diff --git a/images/tiles/weaver10.png b/images/tiles/weaver10.png new file mode 100644 index 0000000..b020fce Binary files /dev/null and b/images/tiles/weaver10.png differ diff --git a/js/game.js b/js/game.js index 989ae0e..5400bf1 100644 --- a/js/game.js +++ b/js/game.js @@ -289,7 +289,7 @@ function render() { } else { drawInventory(inventory, lang["player"]) } - $('#money').text(money + " " + lang.money) + $('#money').text(formatCount(money) + " " + lang.money) if (mode == "showmore") { drawBigInventory(inventory) } diff --git a/js/items.json b/js/items.json index 1e9f659..5692d32 100644 --- a/js/items.json +++ b/js/items.json @@ -19,5 +19,37 @@ "id": 4, "name": "charcoal", "value": 14 + },{ + "id": 5, + "name": "sawdust", + "value": 1 + },{ + "id": 6, + "name": "charcoaldust", + "value": 3 + },{ + "id": 7, + "name": "rawpaper", + "value": 30 + },{ + "id": 8, + "name": "paper", + "value": 200 + },{ + "id": 9, + "name": "siev", + "value": 33 + },{ + "id": 10, + "name": "paperfilter", + "value": 100 + },{ + "id": 11, + "name": "koks", + "value": 14 + },{ + "id": 12, + "name": "briquettes", + "value": 14 }] } diff --git a/js/tiles.js b/js/tiles.js index 586d3e2..794a86f 100644 --- a/js/tiles.js +++ b/js/tiles.js @@ -75,11 +75,18 @@ class Saw extends Tile { work() { //Items für ein Pank var requieredCount = 5 - if (this.input.countOf(1) >= requieredCount) { + if (this.input.countOf(1) >= requieredCount || this.input.countOf(2) >= 1) { if (this.currentwork == this.maxwork) { - this.input.take(1, requieredCount, this.factory) - for (var i = 0; i < 4; i++) { - var item = new Item(2, this.x * 48, this.y * 48) + if (this.input.countOf(1) >= requieredCount) { + this.input.take(1, requieredCount, this.factory) + for (var i = 0; i < 4; i++) { + var item = new Item(2, this.x * 48, this.y * 48) + this.factory.items.push(item) + item.setDFromDirection(this.direction) + } + } else { + this.input.take(2, 1, this.factory) + var item = new Item(5, this.x * 48, this.y * 48) this.factory.items.push(item) item.setDFromDirection(this.direction) } @@ -93,6 +100,98 @@ class Saw extends Tile { } } +class Weaver extends Tile { + constructor(x, y, factory) { + super(x, y, factory) + this.maxwork = 48 * 3 + this.currentwork = 0 + this.name = "weaver" + this.i = 10 + this.cost = [{ + "id": 2, + "count": 200 + }, + { + "id": 3, + "count": 100 + }, + { + "id": 0, + "count": 25000 + } + ] + this.texture = { + "0": [], + "1": ["weaver10"] + } + this.loadImages() + } + + work() { + //Items für ein Pank + var requieredCount = 5 + if (this.input.countOf(2) >= requieredCount) { + if (this.currentwork == this.maxwork) { + this.currentwork = 0 + var item = new Item(9, this.x * 48, this.y * 48) + this.factory.items.push(item) + item.setDFromDirection(this.direction) + } else { + this.currentwork++ + } + } else { + this.currentwork = 0 + } + } +} + +class Papermanufactory extends Tile { + constructor(x, y, factory) { + super(x, y, factory) + this.maxwork = 48 * 10 + this.currentwork = 0 + this.name = "papermanufactory" + this.i = 11 + this.cost = [{ + "id": 2, + "count": 200 + }, + { + "id": 3, + "count": 500 + }, + { + "id": 0, + "count": 10000 + } + ] + this.texture = { + "0": [], + "1": ["papermanufactory10"] + } + this.loadImages() + } + + work() { + //Items für ein Pank + var requieredCount = 5 + if (this.input.countOf(9) >= 10 && this.input.countOf(5) >= 100) { + if (this.currentwork == this.maxwork) { + this.currentwork = 0 + for (var i = 0; i < 10; i++) { + var item = new Item(7, this.x * 48, this.y * 48) + this.factory.items.push(item) + item.setDFromDirection(this.direction) + } + } else { + this.currentwork++ + } + } else { + this.currentwork = 0 + } + } +} + class Charcoalmeiler extends Tile { constructor(x, y, factory) { super(x, y, factory) @@ -117,7 +216,7 @@ class Charcoalmeiler extends Tile { } getImage(fulltime, layer) { - fulltime = Math.round(fulltime/4) + fulltime = Math.round(fulltime / 4) if (this.images[layer].length == 0) return "0" return this.images[layer][(fulltime % this.images[layer].length)] @@ -261,6 +360,104 @@ class Spliter extends Tile { } } +class FilterRight extends Tile { + constructor(x, y, factory) { + super(x, y, factory) + this.name = "filterright" + this.hasNoInventory = true + this.i = 9 + this.filter = 0 + this.cost = [{ + "id": 0, + "count": 50000 + }, { + "id": 2, + "count": 200 + }] + this.options = [{ + "type": "item", + "var": "filter" + }] + this.texture = { + "0": ["conveyorbelt00", "conveyorbelt01", "conveyorbelt02", "conveyorbelt03", "conveyorbelt04", "conveyorbelt05", "conveyorbelt06"], + "1": ["filterright10"] + } + this.loadImages() + } + + work() { + while (this.input.items.length > 0) { + var item = this.input.items.pop() + var d = this.direction + if (item.id == this.filter) + switch (this.direction) { + case "right": + d = "down" + break; + case "down": + d = "left" + break; + case "left": + d = "up" + break; + case "up": + d = "right" + break; + } + item.setDFromDirection(d) + } + } +} + +class FilterLeft extends Tile { + constructor(x, y, factory) { + super(x, y, factory) + this.name = "filterleft" + this.hasNoInventory = true + this.i = 8 + this.filter = 0 + this.cost = [{ + "id": 0, + "count": 50000 + }, { + "id": 2, + "count": 200 + }] + this.options = [{ + "type": "item", + "var": "filter" + }] + this.texture = { + "0": ["conveyorbelt00", "conveyorbelt01", "conveyorbelt02", "conveyorbelt03", "conveyorbelt04", "conveyorbelt05", "conveyorbelt06"], + "1": ["filterleft10"] + } + this.loadImages() + } + + work() { + while (this.input.items.length > 0) { + var item = this.input.items.pop() + var d = this.direction + if (item.id == this.filter) + switch (this.direction) { + case "right": + d = "up" + break; + case "down": + d = "right" + break; + case "left": + d = "down" + break; + case "up": + d = "left" + break; + } + item.setDFromDirection(d) + } + } +} + class Warehouse extends Tile { constructor(x, y, factory) { super(x, y, factory) @@ -274,7 +471,7 @@ class Warehouse extends Tile { "count": 20000 }] this.pivot = 0 - this.toSell = 1 + this.toSell = 0 this.options = [{ "type": "item", "var": "toSell" @@ -311,3 +508,7 @@ tileClasses.push(Quarry) tileClasses.push(Collector) tileClasses.push(Spliter) tileClasses.push(Warehouse) +tileClasses.push(FilterLeft) +tileClasses.push(FilterRight) +tileClasses.push(Weaver) +tileClasses.push(Papermanufactory) diff --git a/js/util.js b/js/util.js index 21cb052..450c1d6 100644 --- a/js/util.js +++ b/js/util.js @@ -25,7 +25,7 @@ var directions = { } } -var d = ["right","down","left","up"] +var d = ["right", "down", "left", "up"] //Umrechnung von Grad zu Bogenmaß var TO_RADIANS = Math.PI / 180; @@ -46,6 +46,16 @@ function infoDrawRotatedImage(image, x, y, angle) { infoCtx.restore(); } -function formatCount(c){ - return c +function formatCount(c) { + for (var pow = 0; pow < lang.numbers.length; pow++) { + if (c / Math.pow(10, pow * 3) >= 1 && c / Math.pow(10, pow * 3) < 1000) { + return round(c / Math.pow(10, pow * 3), 3) + lang.numbers[pow] + } + } + return round(c / Math.pow(10, (lang.numbers.length - 1) * 3), 3) + lang.numbers[(lang.numbers.length - 1)] +} + +function round(n, p) { + var factor = Math.pow(10, p); + return Math.round(n * factor) / factor; } diff --git a/lang/en.json b/lang/en.json index c258279..f71e185 100644 --- a/lang/en.json +++ b/lang/en.json @@ -14,7 +14,7 @@ }, "saw": { "name": "Saw", - "description": "Cuts 5 Logs in to 4 Planks. Works only if it contains 5 Log. It works fast!" + "description": "Cuts 5 Logs in to 4 Planks. Works only if it contains 5 Log. Can also cut Planks into Sawdust. It works fast!" }, "spliter": { "name": "Spliter", @@ -39,14 +39,37 @@ "charcoalmeiler": { "name": "Charcoal Meiler", "description": "Requieres 10 Planks to burn them down to 5 Charcoal." + }, + "papermanufactory": { + "name": "Paper Manufactory", + "description": "Uses 10 Sive and 100 Sawdust to create 10 Rawpaper" + }, + "weaver": { + "name": "Weaver", + "description": "Makes a Siev out of 5 Planks." + }, + "filterleft": { + "name": "Item Filter (left)", + "description": "Puts a selected Item to the left and all other straight.", + "options": { + "filter": "Filtered Item" + } + }, + "filterright": { + "name": "Item Filter (right)", + "description": "Puts a selected Item to the right and all other straight.", + "options": { + "filter": "Filtered Item" + } } }, - "items": ["None", "Log", "Planks", "Stone","Charcoal"], + "items": ["None", "Log", "Planks", "Stone", "Charcoal", "Sawdust", "Charcoal Dust", "Raw Paper", "Paper", "Siev", "Filter", "Koks", "Briquettes"], "more": "Show Inventory / Sell Items", "inventory": "Inventory", "player": "Player", "infotooltips": ["Build", "Move", "Rotate", "Delete!", "", "Upgrade", "Information", "", "Go To Space!!"], "cost": "Cost", "clickToSell": "Click on items to sell them.", - "money": "Dollars" + "money": "Dollars", + "numbers": ["", " Thousand", " Million", " Billion", " Trillion", " Quadrillion", " Quintillion", " Sextillion", " Septillion", " Octillion", " Nonillion", " Decillion", " Undecillion", " Duodecillion", " Tredecillion", " Quattuordecillion", " Quindecillion", " Sexdecillion", " Septendecillion", " Octodecillion", " Novemdecillion", " Vigintillion"] } diff --git a/php/login.php b/php/login.php new file mode 100644 index 0000000..5e343c2 --- /dev/null +++ b/php/login.php @@ -0,0 +1,7 @@ + + + diff --git a/php/mysqldata.php b/php/mysqldata.php new file mode 100644 index 0000000..cac7b96 --- /dev/null +++ b/php/mysqldata.php @@ -0,0 +1,8 @@ +