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();
39 this.player = new dragonblocks.Player(null, this.map);
41 this.player.setGamemode(properties.gamemode);
42 dragonblocks.mapgen.generate(properties.mapgen, this.map);
50 map: this.map.serialize(),
51 player: this.player.serialize(),
57 this.mods = data.mods;
61 this.map = new dragonblocks.Map(data.map);
62 this.player = new dragonblocks.Player(data.player, this.map);
67 if (dragonblocks.loggedin)
68 return dragonblocks.backendCall("saveWorld", true, {name: this.name, world: JSON.stringify(this.serialize())});
73 this.deserialize($.getJSON("worlds/" + this.name + "/world.json").responseJSON);
78 dragonblocks.loadMods(this.mods);
82 dragonblocks.World.Properties = class
87 this.isLoaded = isLoaded;
92 this.gamemode = dragonblocks.settings.defaultWorldOptions.gamemode;
93 this.mapgen = dragonblocks.settings.defaultWorldOptions.mapgen;
99 return this.name.match(/^[a-zA-Z0-9]+$/);