src/gamestate.js
// there is no saved game.
there is no saved game.
there is no saved game .
function loadSavedGame() {
	if (typeof saveData == 'undefined') {
		if (persist.hasLocalStorage) {
			saveData = window.localStorage.getItem('save');
			loadCount = window.localStorage.getItem('loadCount');
			if (loadCount) {
				loadCount = parseInt(loadCount);
			} else {
				loadCount = 0;
			}
		} else {
			saveData = null;
			loadCount = 0;
		}
	}
	if (!saveData) {
		return null;
	}
	var save;
	try {
		save = JSON.parse(saveData);
	} catch (e) {
		console.warn('Corrupted save game');
		return false;
	}
	if (!save || typeof save != 'object') {
		console.warn('Corrupted save game');
		return false;
	}
	if (typeof save.version == 'undefined') {
		save.version = 1;
	}
	if (save.version < 2) {
		save.chests = [];
		save.cheat = false;
		save.gameKey = null;
		save.saveCount = 1;
		save.loadCount = 0;
		save.levelIndex = 0;
	}
	if (save.version > 2) {
		console.warn('Unknown save game version');
		return null;
	}
	var st = new GameState(save.gameKey);
	st.hearts = save.hearts;
	st.chests = save.chests;
	st.weapons = save.weapons;
	st.currentWeapon = save.currentWeapon;
	st.health = st.hearts * 2;
	st.weaponOrder = save.weaponOrder;
	st.doubleJump = !!save.doubleJump;
	st.cheat = !!save.cheat;
	st.gameKey = save.gameKey;
	st.saveCount = save.saveCount;
	st.loadCount = loadCount;
	st.levelIndex = save.levelIndex;
	st.levelTime = 0;
	st.level = save.level;
	st.source = 'save';
	st.sourceId = save.savePointId;
	return st;
}
function loadSavedGame ( ) { if ( typeof saveData == 'undefined' ) { if ( persist . hasLocalStorage ) { saveData = window . localStorage . getItem ( 'save' ) ; loadCount = window . localStorage . getItem ( 'loadCount' ) ; if ( loadCount ) { loadCount = parseInt ( loadCount ) ; } else { loadCount = 0 ; } } else { saveData = null ; loadCount = 0 ; } } if ( ! saveData ) { return null ; } var save ; try { save = JSON . parse ( saveData ) ; } catch ( e ) { console . warn ( 'Corrupted save game' ) ; return false ; } if ( ! save || typeof save != 'object' ) { console . warn ( 'Corrupted save game' ) ; return false ; } if ( typeof save . version == 'undefined' ) { save . version = 1 ; } if ( save . version < 2 ) { save . chests = [ ] ; save . cheat = false ; save . gameKey = null ; save . saveCount = 1 ; save . loadCount = 0 ; save . levelIndex = 0 ; } if ( save . version > 2 ) { console . warn ( 'Unknown save game version' ) ; return null ; } var st = new GameState ( save . gameKey ) ; st . hearts = save . hearts ; st . chests = save . chests ; st . weapons = save . weapons ; st . currentWeapon = save . currentWeapon ; st . health = st . hearts * 2 ; st . weaponOrder = save . weaponOrder ; st . doubleJump = ! ! save . doubleJump ; st . cheat = ! ! save . cheat ; st . gameKey = save . gameKey ; st . saveCount = save . saveCount ; st . loadCount = loadCount ; st . levelIndex = save . levelIndex ; st . levelTime = 0 ; st . level = save . level ; st . source = 'save' ; st . sourceId = save . savePointId ; return st ; }
there is no saved game.
there is no saved game .
// invincible is not loaded