4 * Copyright 2020 Elias Fleckenstein <eliasfleckenstein@web.de>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
23 dragonblocks.getSavestring = function(){
24 dragonblocks.world.map = dragonblocks.map;
25 dragonblocks.world.mods = dragonblocks.mods;
26 dragonblocks.world.spawnedEntities = dblib.removeTmp(dragonblocks.spawnedEntities)
27 return JSON.stringify(dragonblocks.world);
29 dragonblocks.save = function(){
30 if(dragonblocks.loggedin)
33 data: {call: "saveWorld", name: dragonblocks.worldname, world: dragonblocks.getSavestring()}
36 dragonblocks.checkWorldOwnership = function(name){
37 return $.get("worlds/" + name + "/owner.txt").responseText == dragonblocks.username;
39 dragonblocks.checkWorldExistance = function(name){
40 return $.get("worlds/" + name).status == 200;
42 dragonblocks.checkWorldSpelling = function(name){
46 data: {call: "checkWorldname", name: name},
49 dragonblocks.loadWorldlist = function(){
50 dragonblocks.worlds = [];
51 let allWorlds = $.getJSON({
54 data: {call: "getWorlds"}
56 for(let world of allWorlds){
57 if(dragonblocks.checkWorldOwnership(world))
58 dragonblocks.worlds.push(world);
61 dragonblocks.getEmptyWorld = function(){
64 content: Array(dragonblocks.settings.map.width).fill(Array(dragonblocks.settings.map.width).fill(new dragonblocks.MapNode("air"))),
65 width: dragonblocks.settings.map.width,
66 height: dragonblocks.settings.map.height,
67 displayTop: dragonblocks.settings.map.height / 2,
68 displayLeft: dragonblocks.settings.map.width / 2 - 5,