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.map = new dragonblocks.Map();
40 this.player = new dragonblocks.Player(null, this.map);
41 this.player.setGamemode(properties.gamemode);
43 dragonblocks.mapgen.generate(properties.mapgen, this.map);
51 map: this.map.serialize(),
52 player: this.player.serialize(),
58 this.mods = data.mods;
62 this.map = new dragonblocks.Map(data.map);
63 this.player = new dragonblocks.Player(data.player, this.map);
68 if (dragonblocks.loggedin)
69 return dragonblocks.backendCall("saveWorld", true, {name: this.name, world: JSON.stringify(this.serialize())});
74 this.deserialize($.getJSON("worlds/" + this.name + "/world.json").responseJSON);
79 dragonblocks.loadMods(this.mods);
83 dragonblocks.World.Properties = class
88 this.isLoaded = isLoaded;
93 this.gamemode = dragonblocks.settings.defaultWorldOptions.gamemode;
94 this.mapgen = dragonblocks.settings.defaultWorldOptions.mapgen;
100 return this.name.match(/^[a-zA-Z0-9]+$/);