4 * Copyright 2021 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,
24 dragonblocks.World = class
26 constructor(properties)
28 this.name = properties.name;
29 this.isLoaded = properties.isLoaded;
34 this.mods = properties.mods;
38 this.mapgen = properties.mapgen;
41 this.player = new dragonblocks.Player(null, this.maps["dragonblocks:map"]);
42 this.player.setGamemode(properties.gamemode);
50 player: this.player.serialize(),
55 for (let name in this.maps)
56 data.maps[name] = this.maps[name].serialize();
63 this.mods = data.mods;
67 this.mapgen = data.mapgen;
68 this.loadMaps(data.maps);
70 this.player = new dragonblocks.Player(data.player, this.maps["dragonblocks:map"]);
75 if (dragonblocks.loggedin)
76 return dragonblocks.backendCall("saveWorld", true, {name: this.name, world: JSON.stringify(this.serialize())});
81 this.deserialize($.getJSON("worlds/" + this.name + "/world.json").responseJSON);
86 dragonblocks.loadMods(this.mods);
91 for (let name in dragonblocks.mapMgr.defs)
92 this.maps[name] = dragonblocks.mapMgr.create(name, data[name], this.mapgen);
96 dragonblocks.World.Properties = class
101 this.isLoaded = isLoaded;
106 this.gamemode = dragonblocks.settings.defaultWorldOptions.gamemode;
107 this.mapgen = dragonblocks.settings.defaultWorldOptions.mapgen;
113 return this.name.match(/^[a-zA-Z0-9]+$/);