Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- "use strict";
- function getUserId() {
- return {user_id: SG.core.user.id}
- }
- function getStageId() {
- return {stage_id: SG.tracker.current_stage_id}
- }
- function getScores() {
- return SG.tracker.score
- }
- function addPointsToCriterion(criterion) {
- console.log(addPointsToCriterion), SG.tracker.setCriterionValue(criterion)
- }
- function getPreviousStages() {
- return SG.tracker.stages
- }
- function getPreviousPropositions() {
- return SG.tracker.paths
- }
- function getCharacters() {
- return {player: SG.game.player.id, not_player: SG.game.not_player.id}
- }
- function setWMWindow(url, userid, lang, conn_key, type) {
- window.open(url + "/game/results.php?user=" + userid + "&lang=" + lang + "&key=" + conn_key, type)
- }
- function goToStage(stage_id) {
- console.log("GO TO STAGE from method in serious games communication api"), SG.game.event_controller.nextPhase(stage_id)
- }
- function goToNextStep() {
- goToNextPhase()
- }
- function goToNextPhase() {
- SG.game.event_controller.nextPhase()
- }
- function addQuizzInfo(key, value) {
- SG.player_prefs.setStringByKey(key, value)
- }
- function enableCommunicationAPI(url) {
- createEventListenerOnMessage()
- }
- function disableCommunicationAPI() {
- deleteEventListenerOnMessage()
- }
- function createEventListenerOnMessage() {
- $(window).on("message", listenToMessages)
- }
- function deleteEventListenerOnMessage() {
- $(window).unbind("message")
- }
- function listenToMessages(e) {
- checkOrigin(e) ? messageDecompiler(e.originalEvent.data, e.originalEvent.source) : alert("Error : not the same domain.")
- }
- function checkOrigin(url) {
- return !0
- }
- function getRootUrl(url) {
- var regex = /^(https?:\/\/)?([\da-z\.-]+)\.([\da-z\.]{2,6})/g, result = regex.exec(url);
- return result[0]
- }
- function parseMessage(message) {
- var msg = {}, separator_index = message.indexOf("_");
- if (separator_index == -1) return msg.instruction = message, msg;
- msg.instruction = message.substring(0, separator_index), msg.args = [], msg.args[0] = message.substring(separator_index + 1);
- var args = msg.args[0].split("-");
- for (var i in args) msg.args[i] = args[i];
- return msg
- }
- function messageDecompiler(raw_message, source) {
- var regex = /\[([a-z0-9\_,-]+)\]/g, message = regex.exec(raw_message);
- if (null == message) return void alert("Error : the message is not valid");
- switch (message = message[1], message = parseMessage(message), message.instruction) {
- case"gts":
- var target = message.args[0];
- goToStage(target);
- break;
- case"apt":
- var datas = message.args[0].split(","), criterion_id = parseInt(datas[0], 10), cval = [];
- cval[0] = {level: "0", value: parseInt(datas[1], 10)};
- var criterionResult = new SG.Model.CriterionResults({id: criterion_id, cval: cval});
- addPointsToCriterion(criterionResult);
- break;
- case"setcriterion":
- console.log("setcriterion", message);
- var criterion_id = message.args[0], criterion_value = message.args[1];
- addPointsToCriterion({id: criterion_id, value: criterion_value});
- break;
- case"getscore":
- var score = getScores();
- source.postMessage(score, "*");
- break;
- case"getlaststageid":
- source.postMessage(SG.tracker.getLastStageId(), "*");
- break;
- case"gettracker":
- source.postMessage(SG.tracker.toJsonString().toString(), "*");
- break;
- case"getplayerprefsint":
- var key = message.args[0];
- source.postMessage(SG.player_prefs.getIntByKey(key), "*");
- break;
- case"getplayerprefsfloat":
- var key = message.args[0];
- source.postMessage(SG.player_prefs.getFloatByKey(key), "*");
- break;
- case"getplayerprefsstring":
- var key = message.args[0];
- source.postMessage(SG.player_prefs.getStringByKey(key), "*");
- break;
- case"getplayerprefsbool":
- var key = message.args[0];
- source.postMessage(SG.player_prefs.getBooleanByKey(key), "*");
- break;
- case"setplayerprefsint":
- var player_pref_key = message.args[0], player_pref_value = message.args[1];
- SG.player_prefs.setIntByKey(player_pref_key, player_pref_value);
- break;
- case"setplayerprefsfloat":
- var player_pref_key = message.args[0], player_pref_value = message.args[1];
- SG.player_prefs.setFloatByKey(player_pref_key, player_pref_value);
- break;
- case"setplayerprefsstring":
- var player_pref_key = message.args[0], player_pref_value = message.args[1];
- SG.player_prefs.setStringByKey(player_pref_key, player_pref_value);
- break;
- case"addquizzinfo":
- var player_pref_key = message.args[0], player_pref_value = message.args[1];
- addQuizzInfo(player_pref_key, player_pref_value);
- break;
- case"setplayerprefsbool":
- var player_pref_key = message.args[0], player_pref_value = message.args[1];
- SG.player_prefs.setBooleanByKey(player_pref_key, player_pref_value);
- break;
- case"getuserid":
- source.postMessage(getUserId(), "*");
- break;
- case"getstageid":
- source.postMessage(getStageId(), "*");
- break;
- case"getpreviousstages":
- source.postMessage(getPreviousStages(), "*");
- break;
- case"getpreviouspropositions":
- source.postMessage(getPreviousPropositions(), "*");
- break;
- case"gotonextstep":
- source.postMessage(goToNextStep(), "*");
- break;
- case"gotonextphase":
- source.postMessage(goToNextPhase(), "*");
- break;
- case"getcharacters":
- source.postMessage(getCharacters(), "*");
- break;
- default:
- alert("Error : no function linked to this message.")
- }
- disableCommunicationAPI()
- }
- var pipwerks = {};
- pipwerks.UTILS = {}, pipwerks.debug = {isActive: !1}, pipwerks.SCORM = {
- version: null,
- handleCompletionStatus: !0,
- handleExitMode: !0,
- API: {handle: null, isFound: !1},
- connection: {isActive: !1},
- data: {completionStatus: null, exitStatus: null},
- debug: {}
- }, pipwerks.SCORM.isAvailable = function () {
- return !0
- }, pipwerks.SCORM.API.find = function (win) {
- for (var API = null, findAttempts = 0, findAttemptLimit = 500, traceMsgPrefix = "SCORM.API.find", trace = pipwerks.UTILS.trace, scorm = pipwerks.SCORM; !win.API && !win.API_1484_11 && win.parent && win.parent != win && findAttempts <= findAttemptLimit;) findAttempts++, win = win.parent;
- if (scorm.version) switch (scorm.version) {
- case"2004":
- win.API_1484_11 ? API = win.API_1484_11 : trace(traceMsgPrefix + ": SCORM version 2004 was specified by user, but API_1484_11 cannot be found.");
- break;
- case"1.2":
- win.API ? API = win.API : trace(traceMsgPrefix + ": SCORM version 1.2 was specified by user, but API cannot be found.")
- } else win.API_1484_11 ? (scorm.version = "2004", API = win.API_1484_11) : win.API && (scorm.version = "1.2", API = win.API);
- return API ? (trace(traceMsgPrefix + ": API found. Version: " + scorm.version), trace("API: " + API)) : trace(traceMsgPrefix + ": Error finding API. \nFind attempts: " + findAttempts + ". \nFind attempt limit: " + findAttemptLimit), API
- }, pipwerks.SCORM.API.get = function () {
- var API = null, win = window, find = pipwerks.SCORM.API.find, trace = pipwerks.UTILS.trace;
- return win.parent && win.parent != win && (API = find(win.parent)), !API && win.top.opener && (API = find(win.top.opener)), API ? pipwerks.SCORM.API.isFound = !0 : trace("API.get failed: Can't find the API!"), API
- }, pipwerks.SCORM.API.getHandle = function () {
- var API = pipwerks.SCORM.API;
- return API.handle || API.isFound || (API.handle = API.get()), API.handle
- }, pipwerks.SCORM.connection.initialize = function () {
- var success = !1, scorm = pipwerks.SCORM, completionStatus = pipwerks.SCORM.data.completionStatus, trace = pipwerks.UTILS.trace,
- makeBoolean = pipwerks.UTILS.StringToBoolean, debug = pipwerks.SCORM.debug, traceMsgPrefix = "SCORM.connection.initialize ";
- if (trace("connection.initialize called."), scorm.connection.isActive) trace(traceMsgPrefix + "aborted: Connection already active."); else {
- var API = scorm.API.getHandle(), errorCode = 0;
- if (API) {
- switch (scorm.version) {
- case"1.2":
- success = makeBoolean(API.LMSInitialize(""));
- break;
- case"2004":
- success = makeBoolean(API.Initialize(""))
- }
- if (success) if (errorCode = debug.getCode(), null !== errorCode && 0 === errorCode) {
- if (scorm.connection.isActive = !0, scorm.handleCompletionStatus && (completionStatus = pipwerks.SCORM.status("get"))) switch (completionStatus) {
- case"not attempted":
- pipwerks.SCORM.status("set", "incomplete");
- break;
- case"unknown":
- pipwerks.SCORM.status("set", "incomplete")
- }
- } else success = !1, trace(traceMsgPrefix + "failed. \nError code: " + errorCode + " \nError info: " + debug.getInfo(errorCode)); else errorCode = debug.getCode(), trace(null !== errorCode && 0 !== errorCode ? traceMsgPrefix + "failed. \nError code: " + errorCode + " \nError info: " + debug.getInfo(errorCode) : traceMsgPrefix + "failed: No response from server.")
- } else trace(traceMsgPrefix + "failed: API is null.")
- }
- return success
- }, pipwerks.SCORM.connection.terminate = function () {
- var success = !1, scorm = pipwerks.SCORM, exitStatus = pipwerks.SCORM.data.exitStatus,
- completionStatus = pipwerks.SCORM.data.completionStatus, trace = pipwerks.UTILS.trace, makeBoolean = pipwerks.UTILS.StringToBoolean,
- debug = pipwerks.SCORM.debug, traceMsgPrefix = "SCORM.connection.terminate ";
- if (scorm.connection.isActive) {
- var API = scorm.API.getHandle(), errorCode = 0;
- if (API) {
- if (scorm.handleExitMode && !exitStatus) if ("completed" !== completionStatus && "passed" !== completionStatus) switch (scorm.version) {
- case"1.2":
- success = scorm.set("cmi.core.exit", "suspend");
- break;
- case"2004":
- success = scorm.set("cmi.exit", "suspend")
- } else switch (scorm.version) {
- case"1.2":
- success = scorm.set("cmi.core.exit", "logout");
- break;
- case"2004":
- success = scorm.set("cmi.exit", "normal")
- }
- switch (scorm.version) {
- case"1.2":
- success = makeBoolean(API.LMSFinish(""));
- break;
- case"2004":
- success = makeBoolean(API.Terminate(""))
- }
- success ? scorm.connection.isActive = !1 : (errorCode = debug.getCode(), trace(traceMsgPrefix + "failed. \nError code: " + errorCode + " \nError info: " + debug.getInfo(errorCode)))
- } else trace(traceMsgPrefix + "failed: API is null.")
- } else trace(traceMsgPrefix + "aborted: Connection already terminated.");
- return success
- }, pipwerks.SCORM.data.get = function (parameter) {
- var value = null, scorm = pipwerks.SCORM, trace = pipwerks.UTILS.trace, debug = pipwerks.SCORM.debug,
- traceMsgPrefix = "SCORM.data.get(" + parameter + ") ";
- if (scorm.connection.isActive) {
- var API = scorm.API.getHandle(), errorCode = 0;
- if (API) {
- switch (scorm.version) {
- case"1.2":
- value = API.LMSGetValue(parameter);
- break;
- case"2004":
- value = API.GetValue(parameter)
- }
- if (errorCode = debug.getCode(), "" !== value && 0 === errorCode) switch (parameter) {
- case"cmi.core.lesson_status":
- case"cmi.completion_status":
- scorm.data.completionStatus = value;
- break;
- case"cmi.core.exit":
- case"cmi.exit":
- scorm.data.exitStatus = value
- } else trace(traceMsgPrefix + "failed. \nError code: " + errorCode + "\nError info: " + debug.getInfo(errorCode))
- } else trace(traceMsgPrefix + "failed: API is null.")
- } else trace(traceMsgPrefix + "failed: API connection is inactive.");
- return trace(traceMsgPrefix + " value: " + value), String(value)
- }, pipwerks.SCORM.data.set = function (parameter, value) {
- var success = !1, scorm = pipwerks.SCORM, trace = pipwerks.UTILS.trace, makeBoolean = pipwerks.UTILS.StringToBoolean,
- debug = pipwerks.SCORM.debug, traceMsgPrefix = "SCORM.data.set(" + parameter + ") ";
- if (scorm.connection.isActive) {
- var API = scorm.API.getHandle(), errorCode = 0;
- if (API) {
- switch (scorm.version) {
- case"1.2":
- success = makeBoolean(API.LMSSetValue(parameter, value));
- break;
- case"2004":
- success = makeBoolean(API.SetValue(parameter, value))
- }
- success ? "cmi.core.lesson_status" !== parameter && "cmi.completion_status" !== parameter || (scorm.data.completionStatus = value) : trace(traceMsgPrefix + "failed. \nError code: " + errorCode + ". \nError info: " + debug.getInfo(errorCode))
- } else trace(traceMsgPrefix + "failed: API is null.")
- } else trace(traceMsgPrefix + "failed: API connection is inactive.");
- return success
- }, pipwerks.SCORM.data.save = function () {
- var success = !1, scorm = pipwerks.SCORM, trace = pipwerks.UTILS.trace, makeBoolean = pipwerks.UTILS.StringToBoolean,
- traceMsgPrefix = "SCORM.data.save failed";
- if (scorm.connection.isActive) {
- var API = scorm.API.getHandle();
- if (API) switch (scorm.version) {
- case"1.2":
- success = makeBoolean(API.LMSCommit(""));
- break;
- case"2004":
- success = makeBoolean(API.Commit(""))
- } else trace(traceMsgPrefix + ": API is null.")
- } else trace(traceMsgPrefix + ": API connection is inactive.");
- return success
- }, pipwerks.SCORM.status = function (action, status) {
- var success = !1, scorm = pipwerks.SCORM, trace = pipwerks.UTILS.trace, traceMsgPrefix = "SCORM.getStatus failed", cmi = "";
- if (null !== action) {
- switch (scorm.version) {
- case"1.2":
- cmi = "cmi.core.lesson_status";
- break;
- case"2004":
- cmi = "cmi.completion_status"
- }
- switch (action) {
- case"get":
- success = pipwerks.SCORM.data.get(cmi);
- break;
- case"set":
- null !== status ? success = pipwerks.SCORM.data.set(cmi, status) : (success = !1, trace(traceMsgPrefix + ": status was not specified."));
- break;
- default:
- success = !1, trace(traceMsgPrefix + ": no valid action was specified.")
- }
- } else trace(traceMsgPrefix + ": action was not specified.");
- return success
- }, pipwerks.SCORM.debug.getCode = function () {
- var API = pipwerks.SCORM.API.getHandle(), scorm = pipwerks.SCORM, trace = pipwerks.UTILS.trace, code = 0;
- if (API) switch (scorm.version) {
- case"1.2":
- code = parseInt(API.LMSGetLastError(), 10);
- break;
- case"2004":
- code = parseInt(API.GetLastError(), 10)
- } else trace("SCORM.debug.getCode failed: API is null.");
- return code
- }, pipwerks.SCORM.debug.getInfo = function (errorCode) {
- var API = pipwerks.SCORM.API.getHandle(), scorm = pipwerks.SCORM, trace = pipwerks.UTILS.trace, result = "";
- if (API) switch (scorm.version) {
- case"1.2":
- result = API.LMSGetErrorString(errorCode.toString());
- break;
- case"2004":
- result = API.GetErrorString(errorCode.toString())
- } else trace("SCORM.debug.getInfo failed: API is null.");
- return String(result)
- }, pipwerks.SCORM.debug.getDiagnosticInfo = function (errorCode) {
- var API = pipwerks.SCORM.API.getHandle(), scorm = pipwerks.SCORM, trace = pipwerks.UTILS.trace, result = "";
- if (API) switch (scorm.version) {
- case"1.2":
- result = API.LMSGetDiagnostic(errorCode);
- break;
- case"2004":
- result = API.GetDiagnostic(errorCode)
- } else trace("SCORM.debug.getDiagnosticInfo failed: API is null.");
- return String(result)
- }, pipwerks.SCORM.init = pipwerks.SCORM.connection.initialize, pipwerks.SCORM.get = pipwerks.SCORM.data.get, pipwerks.SCORM.set = pipwerks.SCORM.data.set, pipwerks.SCORM.save = pipwerks.SCORM.data.save, pipwerks.SCORM.quit = pipwerks.SCORM.connection.terminate, pipwerks.UTILS.StringToBoolean = function (string) {
- switch (string.toLowerCase()) {
- case"true":
- case"yes":
- case"1":
- return !0;
- case"false":
- case"no":
- case"0":
- case null:
- return !1;
- default:
- return Boolean(string)
- }
- }, pipwerks.UTILS.trace = function (msg) {
- if (pipwerks.debug.isActive) if (window.console && window.console.firebug) console.log(msg); else {
- var myTextField = document.getElementById("jsDebug");
- myTextField.innerHTML += "<br/>" + msg
- }
- };
- var SG = SG || {
- Model: {},
- Game: {},
- Utils: {},
- core: null,
- game: null,
- tracker: null,
- phase_manager: null,
- player_prefs: null,
- scorm: null
- };
- SG.Model.GlobalScenario = function (datas) {
- var _this = this;
- if (this._global_scenario_json = datas.globalscenario || {}, this._sceneries_json = datas.sceneries || {}, this._criterions_json = datas.criterions || {}, this._id = this._global_scenario_json.id || 0, this._auth = this._global_scenario_json.auth || !1, this._show_in_sg = this._global_scenario_json.show_in_sg || !1, this._subtitle = this._global_scenario_json.subtitle || !0, this._show_criterion_panel = this._global_scenario_json.show_criterion_panel || !1, this._names = {}, this._conceptor_names = [], this._specific_stettings = [], this._sceneries = {}, this._criterions = {}, datas.globalscenario.corner_logo ? this._corner_logo = SG.core._medias_url + "/" + datas.globalscenario.corner_logo : this._corner_logo = !1, this._global_scenario_json.lang && this._global_scenario_json.lang.forEach(function (lang) {
- _this._names[lang.value] = lang.name, _this._conceptor_names[lang.value] = lang.credit
- }), this._criterions_json && this._criterions_json.forEach(function (criterion) {
- _this._criterions[criterion.id] = new SG.Model.Criterion(criterion)
- }), this._sceneries_json) for (var scenery_id in this._sceneries_json) _this._sceneries[scenery_id] = new SG.Model.Scenery(this._sceneries_json[scenery_id][0]);
- if (this._global_scenario_json.phases) {
- var phase_to_set = {};
- this._global_scenario_json.phases.forEach(function (phase) {
- phase.Scenario ? (phase_to_set = new SG.Model.Scenario(phase.Scenario), phase_to_set.name = "Scenario", SG.phase_manager.addPhase(phase_to_set)) : phase.BobSpeech || phase.Context ? (phase_to_set = new SG.Model.BobSpeech(phase.BobSpeech ? phase.BobSpeech : phase.Context), phase_to_set.name = "BobSpeech", SG.phase_manager.addPhase(phase_to_set)) : phase.WebPhase ? (phase_to_set = new SG.Model.WebPhase(phase.WebPhase), phase_to_set.name = "WebPhase", SG.phase_manager.addPhase(phase_to_set)) : phase.KinematicPhase ? (phase_to_set = new SG.Model.KinematicPhase(phase.KinematicPhase), phase_to_set.name = "KinematicPhase", SG.phase_manager.addPhase(phase_to_set)) : phase.Quizz ? (phase_to_set = new SG.Model.Quizz(phase.Quizz), phase_to_set.name = "Quizz", SG.phase_manager.addPhase(phase_to_set)) : phase.EndGame && (phase_to_set = new SG.Model.EndGame(phase.EndGame), phase_to_set.name = "EndGame", SG.phase_manager.addPhase(phase_to_set))
- })
- }
- }, SG.Model.GlobalScenario.prototype = {
- getNameByLanguage: function (lang) {
- return this.names[lang] ? this.names[lang] : this.names.French
- }, getSceneryById: function (id) {
- var scenery_to_return = null;
- return this.sceneries.forEach(function (scenery) {
- scenery.id == id && (scenery_to_return = scenery)
- }), scenery_to_return
- }
- }, Object.defineProperties(SG.Model.GlobalScenario.prototype, {
- id: {
- get: function () {
- return this._id
- }, set: function (id) {
- this._id = id
- }
- }, auth: {
- get: function () {
- return this._auth
- }, set: function (auth) {
- this._id = auth
- }
- }, show_in_sg: {
- get: function () {
- return this._show_in_sg
- }, set: function (show_in_sg) {
- this._show_in_sg = show_in_sg
- }
- }, show_criterion_panel: {
- get: function () {
- return this._show_criterion_panel
- }, set: function (isDisplayed) {
- this._show_criterion_panel = isDisplayed
- }
- }, subtitle: {
- get: function () {
- return this._subtitle
- }, set: function (subtitle) {
- this._subtitle = subtitle
- }
- }, names: {
- get: function () {
- return this._names
- }, set: function (names) {
- this._names = names
- }
- }, conceptor_names: {
- get: function () {
- return this._conceptor_names
- }, set: function (conceptor_names) {
- this._conceptor_names = conceptor_names
- }
- }, specific_settings: {
- get: function () {
- return this._specific_stettings
- }, set: function (specific_stettings) {
- this._specific_stettings = specific_stettings
- }
- }, sceneries: {
- get: function () {
- return this._sceneries
- }, set: function (sceneries) {
- this._sceneries = sceneries
- }
- }, criterions: {
- get: function () {
- return this._criterions
- }, set: function (criterions) {
- this._criterions = criterions
- }
- }, corner_logo: {
- get: function () {
- return this._corner_logo
- }, set: function (value) {
- this._corner_logo = value
- }
- }
- }), SG.Model.User = function (id, key, customer_id, access) {
- this._id = id || 0, this._key = key || "", this._customer_id = customer_id || 0, this._access = access || []
- }, Object.defineProperties(SG.Model.User.prototype, {
- id: {
- get: function () {
- return this._id
- }, set: function (id) {
- this._id = id
- }
- }, key: {
- get: function () {
- return this._key
- }, set: function (key) {
- this._key = key
- }
- }, customer_id: {
- get: function () {
- return this._customer_id
- }, set: function (customer_id) {
- this._customer_id = customer_id
- }
- }, access: {
- get: function () {
- return this._access
- }, set: function (access) {
- this._access = access
- }
- }
- }), SG.Model.Character = function (character, scenario_id) {
- var _this = this;
- this._id = character.id || 0, this._descriptions = [], this._names = [], this._names_to_display = [], this._playables = [], this._not_playables = [], this.cloth_ids = [], this._moves = [], character.lang.forEach(function (lang) {
- _this._names[lang.value] = lang.name, _this._descriptions[lang.value] = lang.description, lang.name_to_display.forEach(function (name) {
- _this._names_to_display[lang.value] = name.value
- }), lang.playable.forEach(function (playable) {
- _this._playables[lang.value] = playable
- }), lang.npcs.forEach(function (not_playable) {
- _this._not_playables[lang.value] = not_playable.scenario_binomial[0]
- })
- })
- }, SG.Model.Character.prototype = {
- getMoveByReference: function (reference) {
- var moveToReturn = null;
- return this._moves.forEach(function (move) {
- move.reference == reference && (moveToReturn = move)
- }), moveToReturn
- }, getMovesByAttitudeId: function (attitude_id, active) {
- var moves_to_return = [], type = active ? "active" : "passive";
- return this._moves.forEach(function (move) {
- move.attitude_id == attitude_id && move.type == type && moves_to_return.push(move)
- }), moves_to_return
- }
- }, Object.defineProperties(SG.Model.Character.prototype, {
- id: {
- get: function () {
- return this._id
- }
- }, descriptions: {
- get: function () {
- return this._descriptions
- }
- }, names: {
- get: function () {
- return this._names
- }
- }, names_to_display: {
- get: function () {
- return this._names_to_display
- }, set: function (name) {
- this._names_to_display = name
- }
- }, playables: {
- get: function () {
- return this._playables
- }
- }, not_playables: {
- get: function () {
- return this._not_playables
- }
- }, moves: {
- get: function () {
- return this._moves
- }, set: function (moves) {
- this._moves = moves
- }
- }
- }), SG.Model.Phase = function (phase) {
- this._id = phase.id || 0, this._order = phase.order || 0, this._name = phase.name, this._is_loaded = !1
- }, SG.Model.Phase.prototype = {
- loadAssets: function (callback) {
- this.is_loaded = !0, callback()
- }
- }, Object.defineProperties(SG.Model.Phase.prototype, {
- id: {
- get: function () {
- return this._id
- }, set: function (id) {
- this._id = id
- }
- }, order: {
- get: function () {
- return this._order
- }, set: function (order) {
- this._order = order
- }
- }, name: {
- get: function () {
- return this._name
- }, set: function (name) {
- this._name = name
- }
- }, is_loaded: {
- get: function () {
- return this._is_loaded
- }, set: function (is_loaded) {
- this._is_loaded = is_loaded
- }
- }
- }), SG.Model.KinematicPhase = function (kinematic) {
- if (SG.Model.Phase.call(this, kinematic), this._image, this._urlMP4, console.log(kinematic), "video" == kinematic.mediatype) {
- var urlBase = SG.core.base_url + "/", urlSpecific = kinematic.url.substring(0, kinematic.url.lastIndexOf(".")),
- url = urlBase.concat(urlSpecific);
- this._urlMP4 = url.concat(".mp4")
- } else {
- var urlBase = SG.core.base_url + "/", url = urlBase.concat(kinematic.url);
- this._image = url
- }
- }, SG.Model.KinematicPhase.prototype = Object.create(SG.Model.Phase.prototype), SG.Model.KinematicPhase.prototype.constructor = SG.Model.KinematicPhase, Object.defineProperties(SG.Model.KinematicPhase.prototype, {
- urlMP4: {
- get: function () {
- return this._urlMP4
- }, set: function (url) {
- this._urlMP4 = url
- }
- }, image: {
- get: function () {
- return this._image
- }, set: function (url) {
- this._image = url
- }
- }
- }), SG.Model.Scenario = function (scenario) {
- var _this = this;
- SG.Model.Phase.call(this, scenario), this._first_stage = scenario.firststage || 0, params.stage_to_test > 0 && (this._first_stage = params.stage_to_test), this._dialog_theme = scenario.dialogTheme || null, this._bob_url = scenario.bobUrl || "", this._scopes = [], this._names = [], this._backgrounds = [], this._stages = [], this._acts = [], scenario.bg && scenario.bg.forEach(function (background) {
- _this._backgrounds.push(new SG.Model.Background(background))
- }), scenario.stages && scenario.stages.forEach(function (stage) {
- _this._stages.push(new SG.Model.Stage(stage))
- }), scenario.acts && scenario.acts.forEach(function (act) {
- _this._acts.push(new SG.Model.Act(act))
- }), scenario.lang && scenario.lang.forEach(function (lang) {
- _this._names[lang.value] = lang.name, _this._scopes[lang.value] = lang.scope
- })
- }, SG.Model.Scenario.prototype = Object.create(SG.Model.Phase.prototype), SG.Model.Scenario.prototype.constructor = SG.Model.Scenario, SG.Model.Scenario.prototype.loadAssets = function (callback) {
- this.is_loaded = !0, callback()
- }, SG.Model.Scenario.prototype.getStageById = function (id) {
- var stageToReturn = null;
- return this.stages.forEach(function (stage) {
- stage.id == id && (stageToReturn = stage)
- }), stageToReturn
- }, SG.Model.Scenario.prototype.getActById = function (id) {
- var actToReturn = null;
- return this.acts.forEach(function (act) {
- act.id == id && (actToReturn = act)
- }), actToReturn
- }, Object.defineProperties(SG.Model.Scenario.prototype, {
- first_stage: {
- get: function () {
- return this._first_stage
- }, set: function (first_stage) {
- this._first_stage = first_stage
- }
- }, dialog_theme: {
- get: function () {
- return this._dialog_theme
- }
- }, bob_url: {
- get: function () {
- return this._bob_url
- }
- }, scopes: {
- get: function () {
- return this._scopes
- }
- }, names: {
- get: function () {
- return this._scopes
- }
- }, backgrounds: {
- get: function () {
- return this._backgrounds
- }, set: function (backgrounds) {
- this._backgrounds = backgrounds
- }
- }, stages: {
- get: function () {
- return this._stages
- }
- }, acts: {
- get: function () {
- return this._acts
- }
- }
- }), SG.Model.BobSpeech = function (bobspeech) {
- SG.Model.Phase.call(this, bobspeech);
- var _this = this;
- this._speech_path = {}, this._text = {}, this._picture = bobspeech.picture, this._sound, this._type = bobspeech.type, bobspeech.speechpath.forEach(function (speech_path) {
- _this._speech_path[speech_path.lang] = speech_path.path
- }), bobspeech.text.forEach(function (text) {
- _this._text[text.lang] = {}, _this._text[text.lang].value = text.value, _this._text[text.lang].display = text.display, _this._text[text.lang].user_sens = text.user_sens
- })
- }, SG.Model.BobSpeech.prototype = Object.create(SG.Model.Phase.prototype), SG.Model.BobSpeech.prototype.constructor = SG.Model.BobSpeech, SG.Model.BobSpeech.prototype.loadAssets = function (callback) {
- var audio, url, _this = this;
- this.speech_path[SG.core.lang] ? (url = SG.core.medias_url + "" + this.speech_path[SG.core.lang], audio = new Audio, audio.src = url, audio.load(), audio.addEventListener("canplaythrough", function () {
- _this.is_loaded = !0, callback()
- }, !1), this.sound = audio) : callback()
- }, Object.defineProperties(SG.Model.BobSpeech.prototype, {
- speech_path: {
- get: function () {
- return this._speech_path
- }, set: function (value) {
- this._speech_path = value
- }
- }, text: {
- get: function () {
- return this._text
- }, set: function (value) {
- this._text = value
- }
- }, picture: {
- get: function () {
- return this._picture
- }, set: function (value) {
- this._picture = value
- }
- }, sound: {
- get: function () {
- return this._sound
- }, set: function (value) {
- this._sound = value
- }
- }, type: {
- get: function () {
- return this._type
- }, set: function (value) {
- this._type = value
- }
- }
- }), SG.Model.WebPhase = function (web_phase) {
- SG.Model.Phase.call(this, web_phase), this._label = web_phase.label, this._close_visible = web_phase.close_visible, this._fullscreen = web_phase.fullscreen, this._gamesettings = web_phase.gamesettings, this._height = web_phase.height, this._width = web_phase.width, this._horizontal_align = web_phase.horizontal_align, this._vertical_align = web_phase.vertical_align, this._offset_package = web_phase.offset_package, this._pause_game = web_phase.pause_game, this._position = web_phase.position, this._type = web_phase.type, this._url = web_phase.url, this._url_valid = web_phase.url_valid, this._iframe = {}, this.position_enum = {
- 0: "left",
- 1: "center",
- 2: "right"
- }, this.type_enum = {0: "web", 1: "", 2: "zip", 3: ""}, this.loadAssets()
- }, SG.Model.WebPhase.prototype = Object.create(SG.Model.Phase.prototype), SG.Model.WebPhase.prototype.constructor = SG.Model.WebPhase, SG.Model.WebPhase.prototype.loadAssets = function (callback) {
- }, Object.defineProperties(SG.Model.WebPhase.prototype, {
- label: {
- get: function () {
- return this._label
- }, set: function (label) {
- this._label = label
- }
- }, close_visible: {
- get: function () {
- return this._close_visible
- }, set: function (close_visible) {
- this._close_visible = close_visible
- }
- }, fullscreen: {
- get: function () {
- return this._fullscreen
- }, set: function (fullscreen) {
- this._fullscreen = fullscreen
- }
- }, gamesettings: {
- get: function () {
- return this._gamesettings
- }, set: function (gamesettings) {
- this._gamesettings = gamesettings
- }
- }, height: {
- get: function () {
- return this._height
- }, set: function (height) {
- this._heightl = height
- }
- }, width: {
- get: function () {
- return this._width
- }, set: function (width) {
- this._width = width
- }
- }, horizontal_align: {
- get: function () {
- return this._horizontal_align
- }, set: function (horizontal_align) {
- this._horizontal_align = horizontal_align
- }
- }, vertical_align: {
- get: function () {
- return this._vertical_align
- }, set: function (vertical_align) {
- this._vertical_align = vertical_align
- }
- }, offset_package: {
- get: function () {
- return this._offset_package
- }, set: function (offset_package) {
- this._offset_package = offset_package
- }
- }, pause_game: {
- get: function () {
- return this._pause_game
- }, set: function (pause_game) {
- this._pause_game = pause_game
- }
- }, position: {
- get: function () {
- return this._position
- }, set: function (position) {
- this._position = position
- }
- }, type: {
- get: function () {
- return this._type
- }, set: function (type) {
- this._type = type
- }
- }, url: {
- get: function () {
- return this._url
- }, set: function (url) {
- this._url = url
- }
- }, url_valid: {
- get: function () {
- return this._url_valid
- }, set: function (url_valid) {
- this._url_valid = url_valid
- }
- }, iframe: {
- get: function () {
- return this._iframe
- }, set: function (iframe) {
- this._iframe = iframe
- }
- }
- }), SG.Model.Quizz = function (quizz) {
- SG.Model.Phase.call(this, quizz);
- this._free = quizz.free_movement, this._correction = quizz.show_correction, this._quizzname = quizz.name, this._questions = {};
- for (var i in quizz.questions) this._questions[i] = new SG.Model.Question(quizz.questions[i]);
- this._index = 0
- }, SG.Model.Quizz.prototype = Object.create(SG.Model.Phase.prototype), SG.Model.Quizz.prototype.constructor = SG.Model.Quizz, Object.defineProperties(SG.Model.Quizz.prototype, {
- free: {
- get: function () {
- return this._free
- }
- }, correction: {
- get: function () {
- return this._correction
- }
- }, quizzname: {
- get: function () {
- return this._quizzname
- }
- }, questions: {
- get: function () {
- return this._questions
- }
- }, index: {
- get: function () {
- return this._index
- }, set: function () {
- this._index = value
- }
- }
- }), SG.Model.Question = function (question) {
- var _this = this;
- this._type = question.type, this._text = question.label, this._right_criterions = [], this._wrong_criterions = [], this._answers = {};
- for (var i in question.answers) this._answers[i] = new SG.Model.Answer(question.answers[i]);
- for (var i in question.right_criterions) {
- var criterion_data = _this._getCriterionData(question.right_criterions[i]);
- this._right_criterions.push(new SG.Model.CriterionResults(criterion_data))
- }
- for (var i in question.wrong_criterions) {
- var criterion_data = _this._getCriterionData(question.wrong_criterions[i]);
- this._wrong_criterions.push(new SG.Model.CriterionResults(criterion_data))
- }
- }, SG.Model.Question.prototype._getCriterionData = function (criterion) {
- var criterion_data = {id: criterion.criterion_id, name: criterion.name, cval: [{level: 0, value: criterion.points}]};
- return criterion_data
- }, Object.defineProperties(SG.Model.Question.prototype, {
- type: {
- get: function () {
- return this._type
- }
- }, text: {
- get: function () {
- return this._text
- }
- }, answers: {
- get: function () {
- return this._answers
- }
- }, right_criterions: {
- get: function () {
- return this._right_criterions
- }
- }, wrong_criterions: {
- get: function () {
- return this._wrong_criterions
- }
- }
- }), SG.Model.Answer = function (answer) {
- this._correct = answer.is_correct, this._text = answer.label, this._id = answer.id, this._user_check = !1, this._user_value = ""
- }, Object.defineProperties(SG.Model.Answer.prototype, {
- correct: {
- get: function () {
- return this._correct
- }
- }, text: {
- get: function () {
- return this._text
- }
- }, id: {
- get: function () {
- return this._id
- }
- }, user_check: {
- get: function () {
- return this._user_check
- }, set: function (value) {
- this._user_check = value
- }
- }, user_value: {
- get: function () {
- return this._user_value
- }, set: function (value) {
- this._user_value = value
- }
- }
- }), SG.Model.EndGame = function (endgame) {
- SG.Model.Phase.call(this, endgame), this._param = endgame.param || "", this._custom_message = endgame.custom_message || ""
- }, SG.Model.EndGame.prototype = Object.create(SG.Model.Phase.prototype), SG.Model.EndGame.prototype.constructor = SG.Model.EndGame, Object.defineProperties(SG.Model.EndGame.prototype, {
- param: {
- get: function () {
- return this._param
- }, set: function (param) {
- this._param = param
- }
- }, custom_message: {
- get: function () {
- return this._custom_message
- }, set: function (custom_message) {
- this._custom_message = custom_message
- }
- }
- }), SG.Model.Act = function (act) {
- this._id = act.id || 0, this._scenery_id = act.scenery_id || 0, this._playable_characters_ids = act.actpcs || [], this._not_playable_characters_ids = act.actnpcs || []
- }, Object.defineProperties(SG.Model.Act.prototype, {
- id: {
- get: function () {
- return this._id
- }, set: function (id) {
- this._id = id
- }
- }, scenery_id: {
- get: function () {
- return this._scenery_id
- }, set: function (id) {
- this._scenery_id = id
- }
- }, playable_character_ids: {
- get: function () {
- return this._playable_characters_ids
- }, set: function (ids) {
- this._playable_characters_ids = ids
- }
- }, not_playable_characters_ids: {
- get: function () {
- return this._not_playable_characters_ids
- }, set: function (ids) {
- this._not_playable_characters_ids = ids
- }
- }
- }), SG.Model.Item = function (item) {
- var _this = this;
- this._id = item.id || 0, this._position = [], item.pos.forEach(function (pos) {
- _this._position[pos.cam] = pos
- })
- }, Object.defineProperties(SG.Model.Item.prototype, {
- id: {
- get: function () {
- return this._id
- }
- }, position: {
- get: function () {
- return this._position
- }
- }
- }), SG.Model.Camera = function (camera) {
- this._id = camera.id || 0, this._background_id = camera.id || 0, this._path = camera.value || "/"
- }, Object.defineProperties(SG.Model.Camera.prototype, {
- id: {
- get: function () {
- return this._id
- }
- }, background_id: {
- get: function () {
- return this._background_id
- }
- }, path: {
- get: function () {
- return this._path
- }
- }
- }), SG.Model.Stage = function (stage) {
- var _this = this;
- switch (this._id = stage.id || 0, this._act_id = stage.act || 0, this._preload = stage.preload || {}, this._back_later_enabled = stage.backlaterenabled || !1, this._scenario_id = stage.scenarioid || 0, this._condition = stage.cond || "", this._cam_auto = stage.camauto || !0, this._phase_id = stage.phase_id || 0, this._type = stage.stage_type || "", this._phase_description = stage.phase_description || "", this._short_descriptions = {}, this._comments = [], this._transition_content = [], this._stage_bob_pictures = [], this._sounds = [], this._criterions_results = [], this._paths = [], stage.criterions && stage.criterions.forEach(function (criterion) {
- _this._criterions_results.push(new SG.Model.CriterionResults(criterion))
- }), stage.paths && stage.paths.forEach(function (path) {
- _this._paths.push(new SG.Model.StagePath(path.path))
- }), stage.lang && stage.lang.forEach(function (lang) {
- _this._short_descriptions[lang.value] = lang.short_description, _this._transition_content[lang.value] = lang.transition_content, _this._comments[lang.value] = lang.comment, _this._stage_bob_pictures[lang.value] = lang.stage_bob_picture, _this._sounds[lang.value] = [], lang.sounds.user.forEach(function (sound) {
- _this._sounds[lang.value].push(new SG.Model.Sound(sound))
- })
- }), stage.stage_type) {
- case"WebPhase":
- this._phase_description = new SG.Model.WebPhase(stage.phase_description);
- break;
- case"Quizz":
- this._phase_description = new SG.Model.Quizz(stage.phase_description);
- break;
- case"KinematicPhase":
- this._phase_description = new SG.Model.KinematicPhase(stage.phase_description);
- break;
- case"AnimationPhase":
- this._phase_description = new SG.Model.KinematicPhase(stage.phase_description);
- break;
- case"Bobspeech":
- this._phase_description = new SG.Model.Bobspeech(stage.phase_description)
- }
- }, Object.defineProperties(SG.Model.Stage.prototype, {
- id: {
- get: function () {
- return this._id
- }, set: function (id) {
- this._id = id
- }
- }, act_id: {
- get: function () {
- return this._act_id
- }, set: function (act_id) {
- this._act_id = act_id
- }
- }, preload: {
- get: function () {
- return this._preload
- }, set: function (preload) {
- this._preload = preload
- }
- }, back_later_enabled: {
- get: function () {
- return this._back_later_enabled
- }, set: function (isEnabled) {
- this._back_later_enabled = isEnabled
- }
- }, scenario_id: {
- get: function () {
- return this._scenario_id
- }, set: function (scenario_id) {
- this._scenario_id = scenario_id
- }
- }, condition: {
- get: function () {
- return this._condition
- }, set: function (condition) {
- this._condition = condition
- }
- }, cam_auto: {
- get: function () {
- return this._cam_auto
- }, set: function (cam_auto) {
- this._cam_auto = cam_auto
- }
- }, phase_id: {
- get: function () {
- return this._phase_id
- }, set: function (phase_id) {
- this._phase_id = phase_id
- }
- }, type: {
- get: function () {
- return this._type
- }, set: function (type) {
- this._type = type
- }
- }, phase_description: {
- get: function () {
- return this._phase_description
- }, set: function (phase_description) {
- this._phase_description = phase_description
- }
- }, short_descriptions: {
- get: function () {
- return this._short_descriptions
- }, set: function (short_description) {
- this._short_descriptions = short_description
- }
- }, comments: {
- get: function () {
- return this._comments
- }, set: function (comments) {
- this._comments = comments
- }
- }, transition_content: {
- get: function () {
- return this._transition_content
- }, set: function (transition_content) {
- this._transition_content = transition_content
- }
- }, stage_bob_pictures: {
- get: function () {
- return this._stage_bob_pictures
- }, set: function (stage_bob_pictures) {
- this._stage_bob_pictures = stage_bob_pictures
- }
- }, sounds: {
- get: function () {
- return this._sounds
- }, set: function (sounds) {
- this._sounds = sounds
- }
- }, criterions_results: {
- get: function () {
- return this._criterions_results
- }, set: function (criterions_results) {
- this._criterions_results = criterions_results
- }
- }, paths: {
- get: function () {
- return this._paths
- }, set: function (paths) {
- this._paths = paths
- }
- }
- }), SG.Model.StagePath = function (path) {
- var _this = this;
- this._id = path.id, this._order = path.o, this._sp = path.sp, this._parent_id = path.parent_id, this._source = path.source, this._target = path.target, this._condition = path.cond, this._type = path.type, this._short_descriptions = [], this._long_descriptions = [], this._sounds = [], this._criterions_results = [], this._is_display = !0, path.criterions && path.criterions.forEach(function (criterion) {
- _this._criterions_results.push(new SG.Model.CriterionResults(criterion))
- }), path.lang && path.lang.forEach(function (lang) {
- _this._short_descriptions[lang.value] = lang.shortD, _this._long_descriptions[lang.value] = lang.longD, _this._sounds[lang.value] = [], lang.sounds && lang.sounds.forEach(function (sound) {
- _this._sounds[lang.value][sound.id] = sound.file_size
- })
- })
- }, Object.defineProperties(SG.Model.StagePath.prototype, {
- id: {
- get: function () {
- return this._id
- }, set: function (id) {
- this._id = id
- }
- }, order: {
- get: function () {
- return this._order
- }, set: function (order) {
- this._order = order
- }
- }, sp: {
- get: function () {
- return this._sp
- }, set: function (sp) {
- this._sp = sp
- }
- }, parent_id: {
- get: function () {
- return this._parent_id
- }
- }, source: {
- get: function () {
- return this._source
- }, set: function (source) {
- this._source = source
- }
- }, target: {
- get: function () {
- return this._target
- }, set: function (target) {
- this._target = target
- }
- }, condition: {
- get: function () {
- return this._condition
- }, set: function (condition) {
- this._condition = condition
- }
- }, type: {
- get: function () {
- return this._type
- }, set: function (type) {
- this._type = type
- }
- }, short_descriptions: {
- get: function () {
- return this._short_descriptions
- }, set: function (short_descriptions) {
- this._short_descriptions = short_descriptions
- }
- }, long_descriptions: {
- get: function () {
- return this._long_descriptions
- }, set: function (long_descriptions) {
- this._long_descriptions = long_descriptions
- }
- }, sounds: {
- get: function () {
- return this._sounds
- }, set: function (sounds) {
- this._sounds = sounds
- }
- }, criterions_results: {
- get: function () {
- return this._criterions_results
- }, set: function (criterions_results) {
- this._criterions_results = criterions_results
- }
- }, is_display: {
- get: function () {
- return this._is_display
- }, set: function (is_display) {
- this._is_display = is_display
- }
- }
- }), SG.Model.Sound = function (sound) {
- this._character_id = sound.id || 0, this._part = sound.part || 0, this._role_id = sound.r || 0, this._file_size = sound.files_size || 0, this._file_path = sound.file_name || 0
- }, Object.defineProperties(SG.Model.Sound.prototype, {
- character_id: {
- get: function () {
- return this._character_id
- }, set: function (character_id) {
- this._character_id = character_id
- }
- }, part: {
- get: function () {
- return this._part
- }, set: function (part) {
- this._part = part
- }
- }, role_id: {
- get: function () {
- return this._role_id
- }, set: function (role_id) {
- this._role_id = role_id
- }
- }, file_size: {
- get: function () {
- return this._file_size
- }
- }, file_path: {
- get: function () {
- return this._file_path
- }, set: function (file_path) {
- this._file_path = file_path
- }
- }
- }), SG.Model.Scenery = function (scenery) {
- var _this = this;
- this._id = scenery.id, this._nb_cams = scenery.nbcam, this._scenarios_ids = scenery.scenarios, this._bg_urls = [], this._bg_urls_filesizes = [], this._users_urls = [], this._users_urls_filesize = [], this._users_urls_filescount = [], this._users_urls_coordinates = [], this._users_moves = [], this._items = {}, this._cameras = [], scenery.media.cam.forEach(function (cam) {
- _this._bg_urls[cam.id] = cam.value, _this._bg_urls_filesizes[cam.id] = cam.filesize
- }), scenery.media.cam.forEach(function (cam) {
- _this._cameras.push(new SG.Model.Camera(cam))
- }), scenery.media.items.forEach(function (item) {
- _this._items[item.id] = new SG.Model.Item(item)
- }), scenery.media.users.forEach(function (character) {
- _this._users_urls[character.id] = {}, _this._users_urls_filesize[character.id] = {}, _this._users_urls_filescount[character.id] = {}, _this._users_urls_coordinates[character.id] = {}, _this._users_moves[character.id] = {}, character.views.forEach(function (view) {
- _this._users_urls[character.id][view.position + "_" + view.cam] = view.folder, _this._users_urls_filesize[character.id][view.position + "_" + view.cam] = view.filesize, _this._users_urls_filescount[character.id][view.position + "_" + view.cam] = view.filescount, _this._users_urls_coordinates[character.id][view.position + "_" + view.cam] = view, _this._users_moves[character.id][character.id + "_" + view.position + "_" + view.cam] = {}, view.movements_references.forEach(function (movement) {
- movement.nbpics > 0 && (_this._users_moves[character.id][character.id + "_" + view.position + "_" + view.cam][movement.id] = new SG.Model.Movement(movement, view.cam))
- })
- })
- })
- }, SG.Model.Scenery.prototype = {
- getBasicMovesForUser: function (user_id, role) {
- var key, user_moves_front = this.users_moves[user_id][user_id + "_" + role + "_1"],
- user_moves_back = this.users_moves[user_id][user_id + "_" + role + "_2"], moves_to_return = [];
- for (key in user_moves_front) 1 != user_moves_front[key].attitude_id && 3 != user_moves_front[key].attitude_id || moves_to_return.push(user_moves_front[key]);
- for (key in user_moves_back) 1 != user_moves_back[key].attitude_id && 3 != user_moves_back[key].attitude_id || moves_to_return.push(user_moves_back[key]);
- return moves_to_return
- }, getSpecificMovesForUser: function (user_id, role, reference) {
- role = 1 == role ? 2 : 1;
- var speak_id, pause_id, key, moves_to_return = [], user_moves = this.users_moves[user_id][user_id + "_" + role + "_" + role];
- for (key in user_moves) user_moves[key].reference == reference && (moves_to_return.push(user_moves[key]), speak_id = user_moves[key].speak_id, pause_id = user_moves[key].pause_id);
- for (key in user_moves) user_moves[key].attitude_id != speak_id && user_moves[key].attitude_id != pause_id || 1 == user_moves[key].attitude_id || 3 == user_moves[key].attitude_id || moves_to_return.push(user_moves[key]);
- return moves_to_return
- }, getUrlForUser: function (user_id, role, cam_position) {
- return this.users_urls[user_id][role + "_" + cam_position]
- }
- }, Object.defineProperties(SG.Model.Scenery.prototype, {
- id: {
- get: function () {
- return this._id
- }
- }, nb_cams: {
- get: function () {
- return this._nb_cams
- }
- }, scenarios_ids: {
- get: function () {
- return this._scenarios_ids
- }
- }, bg_urls: {
- get: function () {
- return this._bg_urls
- }
- }, bg_urls_filesizes: {
- get: function () {
- return this._bg_urls_filesizes
- }
- }, users_urls: {
- get: function () {
- return this._users_urls
- }
- }, users_urls_filesize: {
- get: function () {
- return this._users_urls_filesize
- }
- }, users_urls_filescount: {
- get: function () {
- return this._users_urls_filescount
- }
- }, users_urls_coordinates: {
- get: function () {
- return this._users_urls_coordinates
- }
- }, users_moves: {
- get: function () {
- return this._users_moves
- }
- }, items: {
- get: function () {
- return this._items
- }
- }, cameras: {
- get: function () {
- return this._cameras
- }
- }
- }), SG.Model.Criterion = function (criterion) {
- var _this = this;
- this._id = criterion.id, this._name = criterion.name, this._color = criterion.color, this._checked_in_tree = criterion.checkedInTree, this._min = {}, this._max = {}, criterion.levels_list && criterion.levels_list.forEach(function (value) {
- _this._min[value.val] = value.min, _this._max[value.val] = value.max
- })
- }, SG.Model.Criterion.prototype = {
- getMinForLevel: function (level) {
- return this.min[level]
- }, getMaxForLevel: function (level) {
- return this.max[level]
- }
- }, Object.defineProperties(SG.Model.Criterion.prototype, {
- id: {
- get: function () {
- return this._id
- }, set: function (id) {
- this._id = id
- }
- }, name: {
- get: function () {
- return this._name
- }, set: function (name) {
- this._name = name
- }
- }, color: {
- get: function () {
- return this._color
- }, set: function (value) {
- this._color = value
- }
- }, checked_in_tree: {
- get: function () {
- return this._checked_in_tree
- }, set: function (check_in_tree) {
- this._checked_in_tree = check_in_tree
- }
- }, min: {
- get: function () {
- return this._min
- }, set: function (min) {
- this._min = min
- }
- }, max: {
- get: function () {
- return this._max
- }, set: function (max) {
- this._max = max
- }
- }
- }), SG.Model.CriterionResults = function (criterion_data) {
- var _this = this;
- this._id = criterion_data.id || -1, this._value = [], criterion_data.cval && criterion_data.cval.forEach(function (crit) {
- _this._value[crit.level] = crit.value
- })
- }, Object.defineProperties(SG.Model.CriterionResults.prototype, {
- id: {
- get: function () {
- return this._id
- }, set: function (id) {
- this._id = id
- }
- }, value: {
- get: function () {
- return this._value
- }, set: function (value) {
- this._value = value
- }
- }
- }), SG.Model.Background = function (bg) {
- this._id = bg.id || 0, this._name = bg.name || "", this._path = bg.path || ""
- }, Object.defineProperties(SG.Model.Background.prototype, {
- id: {
- get: function () {
- return this._id
- }, set: function (id) {
- this._id = id
- }
- }, name: {
- get: function () {
- return this._name
- }, set: function (name) {
- this._name = name
- }
- }, path: {
- get: function () {
- return this._path
- }, set: function (path) {
- this._path = path
- }
- }
- }), SG.Model.Movement = function (movement, cam) {
- this._id = movement.id || 0, this._speak_move = movement.sm || null, this._proba = movement.p || 0, this._x = movement.x || 0, this._y = movement.y || 0, this._position = movement.pos || null, this._reverse = movement.rv || !1, this._attitude_id = movement.attitude_id, this._type = movement.type, this._reference = movement.ref, this._speak_id = movement.speak_aid, this._pause_id = movement.pause_aid, this._nb_pics = movement.nbpics, this._size = movement.size, this._cam = cam
- }, SG.Model.Movement.ACTIVE = "active", SG.Model.Movement.PASSIVE = "passive", Object.defineProperties(SG.Model.Movement.prototype, {
- id: {
- get: function () {
- return this._id
- }, set: function (id) {
- this._id = id
- }
- }, speak_move: {
- get: function () {
- return this._speak_move
- }, set: function (speak_move) {
- this._speak_move = speak_move
- }
- }, proba: {
- get: function () {
- return this._proba
- }, set: function (proba) {
- this._proba = proba
- }
- }, x: {
- get: function () {
- return this._x
- }, set: function (x) {
- this._x = x
- }
- }, y: {
- get: function () {
- return this._y
- }, set: function (y) {
- this._y = y
- }
- }, position: {
- get: function () {
- return this._position
- }, set: function (position) {
- this._position = position
- }
- }, reverse: {
- get: function () {
- return this._reverse
- }, set: function (reverse) {
- this._reverse = reverse
- }
- }, attitude_id: {
- get: function () {
- return this._attitude_id
- }, set: function (attitude_id) {
- this._attitude_id = attitude_id
- }
- }, type: {
- get: function () {
- return this._type
- }, set: function (type) {
- this._type = type
- }
- }, reference: {
- get: function () {
- return this._reference
- }, set: function (reference) {
- this._reference = reference
- }
- }, speak_id: {
- get: function () {
- return this._speak_id
- }, set: function (speak_id) {
- this._speak_id = speak_id
- }
- }, pause_id: {
- get: function () {
- return this._pause_id
- }, set: function (pause_id) {
- this._pause_id = pause_id
- }
- }, nb_pics: {
- get: function () {
- return this._nb_pics
- }, set: function (nb_pics) {
- this._nb_pics = nb_pics
- }
- }, size: {
- get: function () {
- return this._size
- }, set: function (size) {
- this._size = size
- }
- }, cam: {
- get: function () {
- return this._cam
- }, set: function (cam) {
- this._cam = cam
- }
- }
- }), SG.Model.DialogPart = function (type, datas) {
- this._type = type, this._datas = datas
- }, Object.defineProperties(SG.Model.DialogPart.prototype, {
- type: {
- get: function () {
- return this._type
- }, set: function (type) {
- this._type = type
- }
- }, datas: {
- get: function () {
- return this._datas
- }, set: function (datas) {
- this._datas = datas
- }
- }
- }), SG.Model.DialogPart.TYPE_SPEECH = "type_speech", SG.Model.DialogPart.TYPE_CINEMATIC = "type_cinematic", SG.Model.DialogPart.TYPE_PICTURE = "type_picture", SG.Model.DialogPart.TYPE_SWF = "type_swf", SG.Model.DialogPart.TYPE_BGS = "type_bgs", SG.Model.DialogPart.TYPE_MOVE = "type_move", SG.Model.DialogPart.TYPE_DOC = "type_doc", SG.Model.DialogPart.TYPE_BLUR = "type_blur", SG.Model.DialogPart.TYPE_ITEM = "type_item", SG.Model.DialogPart.TYPE_CAMERA = "type_camera", SG.Model.DialogPart.NONE = "type_none";
- var i18n = i18n || [];
- i18n.French = {
- loading: "Chargement",
- error: "Erreur",
- contact_support: "Pour plus d'information contacter le support",
- yes: "oui",
- no: "non",
- pause: "Pause",
- quizz_placeholder: "Saisissez votre réponse",
- choose_avatar: "Veuillez choisir votre avatar",
- choose_meet: "Qui voudriez-vous rencontrer ?",
- connexion: {
- connexion: "Connexion",
- connexion_failed: "Echec de la connexion. Verifiez votre identifiant et votre mot de passe et réessayez",
- login: "Pseudo",
- password: "Mot de passe",
- no_information_gb: "Aucun numéro de scénario n'est spécifié"
- },
- endgame: {
- scenario_end_reached: "Vous avez atteint la fin du module !",
- end_reached: "Vous avez atteint la fin du module !",
- no_criterions: "Aucun axe d'analyse n'est défini. Vous ne pouvez donc pas avoir accès aux résultats.",
- access_result: "Vos résultats vont s'afficher d'ici quelques secondes...",
- please_save_results: "Veuillez enregistrer vos résultats"
- },
- menu: {
- settings: "Paramètres",
- sound: "son",
- subtitle: "sous-titres",
- info: "information sur le module",
- result: "accéder aux résultats",
- logout: "Déconnexion",
- tutorial: "Tutoriel",
- go_to_map: "Retour à la carte",
- go_to_map_msg: "Êtes vous sûr de vouloir retourner à la carte? Votre progression dans cette mission sera perdue.",
- observation: "une remarque ?",
- replay: "Rejouer la scène",
- conceptor_name: "Nom du/des concepteur(s)"
- },
- results: {
- title: "resultats",
- warning: "Attention, en accédant aux résultats, vous quittez la partie en cours, cette dernière ne sera pas sauvegardée."
- }
- };
- var i18n = i18n || [];
- i18n.English = {
- loading: "Loading",
- error: "Error",
- contact_support: "For more informations, contact support",
- yes: "yes",
- no: "no",
- pause: "Pause",
- quizz_placeholder: "Enter your answer",
- choose_avatar: "Choose your avatar",
- choose_meet: "Who would you meet ?",
- connexion: {
- connexion: "Connection",
- connexion_failed: "Connection failed. Check your email and password and try again",
- login: "Login",
- password: "Password",
- no_information_gb: "None scene number specified"
- },
- endgame: {
- scenario_end_reached: "You have reached the end of the module !",
- end_reached: "You have reached the end of the module !",
- no_criterions: "No analysis axis is defined. You do not have access to the results.",
- access_result: "Your results will be displayed in a few seconds",
- please_save_results: "Please, register your results"
- },
- menu: {
- settings: "Settings",
- sound: "sound",
- subtitle: "subtitles",
- info: "information on the module",
- result: "Access to results",
- logout: "Sign Out",
- tutorial: "Tutorial",
- go_to_map: "Back to the map",
- go_to_map_msg: "Are you sure you want to return to the map? Your progress in this mission will be lost.",
- observation: "an observation ?",
- replay: "Replay scene",
- conceptor_name: "Designer name(s)"
- },
- results: {title: "results", warning: "Attention by accessing results, you leave the current game, it will not be saved."}
- }, SG.Core = function () {
- var Core = function () {
- this._export_results = null, this._offline = !1, this._lang = "French", this._version = null, this._debug_mode = !1, this._base_url = "", this._medias_url = "", this._global_scenario_id = -1, this._global_scenario = {}, this._user = {}, this._i18n = {}, this._characters = [], this.init = function () {
- switch (this._i18n = i18n[this._lang] || i18n.English, this._version) {
- case"manual":
- break;
- case"prod":
- this._base_url = "http://sg.itysoft.com", this._medias_url = "http://sgdatas.itysoft.com";
- break;
- case"beta":
- this._base_url = "http://sgbeta.itysoft.com", this._medias_url = "http://sgdatasbeta.itysoft.com";
- break;
- case"standalone":
- this._offline = !0, this._base_url = ".", this._medias_url = "sgdatas";
- break;
- case"html":
- this._offline = !0, this._base_url = ".", this._medias_url = "sgdatas";
- break;
- case"test":
- this._base_url = "http://192.168.1.16/SeriousGamesBeta", this._medias_url = "http://192.168.1.16/SgDatas";
- break;
- case"julien_localhost":
- this._base_url = "http://127.0.0.1/SeriousGamesBeta", this._medias_url = "http://127.0.0.1/SgDatas";
- break;
- case"julien":
- this._base_url = "http://192.168.0.42/SeriousGamesBeta", this._medias_url = "http://192.168.0.42/SgDatas";
- break;
- case"esteban":
- this._base_url = "http://192.168.0.80:8081/itystudiobeta", this._medias_url = "http://192.168.0.80:8081/SgDatas";
- break;
- case"quention_local":
- this._base_url = "http://127.0.0.1/SeriousGamesBeta", this._medias_url = "http://127.0.0.1/sgdatas";
- break;
- case"quention_externe":
- this._base_url = "http://192.168.0.31/SeriousGamesBeta", this._medias_url = "http://192.168.0.31/sgdatas";
- break;
- case"olivier":
- this._base_url = "http://192.168.0.72/seriousgames", this._medias_url = "http://192.168.0.72/sgdatas";
- break;
- case"greg":
- this._base_url = "http://127.0.0.1/seriousgamesbeta", this._medias_url = "http://127.0.0.1/sgdatas";
- break;
- case"benjamin":
- this._base_url = "http://192.168.0.202:8081/itystudiobeta", this._medias_url = "http://192.168.0.202:8081/sgdatas";
- break;
- default:
- this._base_url = "http://sg.itysoft.com", this._medias_url = "http://sgdatas.itysoft.com"
- }
- amfphp.entryPointUrl = this._base_url + "/gateway.php?contentType=application/json", !this._debug_mode
- }
- };
- Core.prototype = {
- getCharacterById: function (id) {
- var characterToReturn = null;
- return this.characters.forEach(function (character) {
- character.id == id && (characterToReturn = character)
- }), characterToReturn
- }
- }, Object.defineProperties(Core.prototype, {
- user: {
- get: function () {
- return this._user
- }, set: function (user) {
- this._user = user
- }
- }, global_scenario: {
- get: function () {
- return this._global_scenario
- }, set: function (global_scenario) {
- this._global_scenario = global_scenario
- }
- }, global_scenario_id: {
- get: function () {
- return this._global_scenario_id
- }, set: function (id) {
- this._global_scenario_id = id
- }
- }, lang: {
- get: function () {
- return this._lang
- }, set: function (lang) {
- this._lang = lang
- }
- }, version: {
- get: function () {
- return this._version
- }, set: function (version) {
- this._version = version
- }
- }, export_results: {
- get: function () {
- return this._export_results
- }, set: function (export_results) {
- this._export_results = export_results
- }
- }, base_url: {
- get: function () {
- return this._base_url
- }, set: function (base_url) {
- this._base_url = base_url
- }
- }, medias_url: {
- get: function () {
- return this._medias_url
- }, set: function (medias_url) {
- this._medias_url = medias_url
- }
- }, offline: {
- get: function () {
- return this._offline
- }, set: function (offline) {
- this._offline = offline
- }
- }, debug_mode: {
- get: function () {
- return this._debug_mode
- }, set: function (debug_mode) {
- this._debug_mode = debug_mode
- }
- }, i18n: {
- get: function () {
- return this._i18n
- }, set: function (i18n) {
- this._i18n = i18n
- }
- }, characters: {
- get: function () {
- return this._characters
- }, set: function (characters) {
- this._characters = characters
- }
- }
- });
- var instance = null;
- return new function () {
- this.getInstance = function () {
- return null === instance && (instance = new Core), instance
- }
- }
- }(), SG.core = SG.Core.getInstance(), SG.PlayerPrefs = function () {
- var PlayerPrefs = function () {
- this._boolean_list = {}, this._string_list = {}, this._float_list = {}, this._int_list = {}
- };
- PlayerPrefs.prototype = {
- getBooleanByKey: function (key) {
- return null != this._boolean_list[key] ? this._boolean_list[key] : "undefined"
- }, setBooleanByKey: function (key, value) {
- this._boolean_list[key] = value
- }, getStringByKey: function (key) {
- return null != this._string_list[key] ? this._string_list[key] : "undefined"
- }, setStringByKey: function (key, value) {
- this._string_list[key] = value
- }, getFloatByKey: function (key) {
- return null != this._float_list[key] ? this._float_list[key] : "undefined"
- }, setFloatByKey: function (key, value) {
- this._float_list[key] = value
- }, getIntByKey: function (key) {
- return null != this._int_list[key] ? this._int_list[key] : "undefined"
- }, setIntByKey: function (key, value) {
- this._int_list[key] = value
- }
- };
- var instance = null;
- return new function () {
- this.getInstance = function () {
- return null === instance && (instance = new PlayerPrefs), instance
- }
- }
- }(), SG.player_prefs = SG.PlayerPrefs.getInstance(), SG.PhaseManager = function () {
- var PhaseManager = function () {
- this._phases = [], this._phase_index = 0, this._loading_phase_index = 0, this._is_in_stage_phase = !1, this._phase_are_loaded = null
- };
- PhaseManager.prototype = {
- addPhase: function (phase) {
- this.phases.push(phase)
- }, start: function () {
- var lastPhaseIndex = SG.tracker.lastPhaseIndex;
- this._loading_phase_index = lastPhaseIndex, this._phase_index = lastPhaseIndex, "Scenario" === this.phases[lastPhaseIndex].name && (this.phases[lastPhaseIndex].first_stage = SG.tracker.getLastStageId() >= 0 ? SG.tracker.getLastStageId() : this.phases[lastPhaseIndex].first_stage)
- }, preloadPhases: function (callback_phase_are_loaded) {
- var _this = this;
- return this._phase_are_loaded = callback_phase_are_loaded || this._phase_are_loaded, this._loading_phase_index == this.phases.length ? (SG.tracker.startGame(), void this._phase_are_loaded()) : void this.phases[this._loading_phase_index].loadAssets(function () {
- _this._loading_phase_index++, _this.preloadPhases(null)
- })
- }, nextPhase: function () {
- this.phase_index++, SG.tracker.lastPhaseIndex = this.phase_index
- }, lastPhase: function () {
- this.phase_index = this._phases.length - 1, SG.tracker.lastPhaseIndex = this.phase_index
- }, getCurrentPhase: function () {
- return this.phase_index < this.phases.length && this.phases[this.phase_index]
- }, getNextScenarioPhase: function () {
- for (var i = this.phase_index; i < this.phases.length; i++) if ("Scenario" === this.phases[i].name) return this.phases[i];
- return null
- }, getPhaseByOrder: function (order) {
- var phase_to_return = null;
- return this.phases.forEach(function (phase) {
- phase._order == order && (phase_to_return = phase)
- }), phase_to_return
- }
- }, Object.defineProperties(PhaseManager.prototype, {
- phases: {
- get: function () {
- return this._phases
- }, set: function (phases) {
- this._phases = phases
- }
- }, phase_index: {
- get: function () {
- return this._phase_index
- }, set: function (phase_index) {
- this._phase_index = phase_index
- }
- }, phase_are_loaded: {
- get: function () {
- return this._phase_are_loaded
- }, set: function (phase_are_loaded) {
- this._phase_are_loaded = phase_are_loaded
- }
- }, is_in_stage_phase: {
- get: function () {
- return this._is_in_stage_phase
- }, set: function (is_in_stage_phase) {
- this._is_in_stage_phase = is_in_stage_phase
- }
- }
- });
- var instance = null;
- return new function () {
- this.getInstance = function () {
- return null === instance && (instance = new PhaseManager), instance
- }
- }
- }(), SG.phase_manager = SG.PhaseManager.getInstance(), SG.Tracker = function (criterions) {
- this.SEPARATOR = "[ ヅ ]", this._criterions = criterions, this._lastPhaseIndex = 0, this._difficulty = 0, this._stages = [], this._paths = [], this._score = {}, this._timeSinceStartUp = 0, this._current_stage_id = -1
- }, SG.Tracker.prototype = {
- init: function () {
- if (SG.scorm.api_available) {
- var track = SG.scorm.getTrack();
- "" != track && this.stringToTrack(track)
- }
- return this.lastPhaseIndex
- }, startGame: function () {
- this.timeSinceStartUp = new Date
- }, endGame: function () {
- SG.scorm.api_available && (SG.scorm.storeScore(this.getGeneralScore()), "2004" == SG.scorm.scorm_version && SG.scorm.storeObjectives(), SG.scorm.storePlayTime(this.getTimeSinceStartGame(SG.scorm.scorm_version)), SG.scorm.storeGameCompleted(), SG.scorm.save(), SG.scorm.quit())
- }, addStage: function (stage) {
- var _this = this;
- this.stages.push(stage.id), stage.criterions_results.forEach(function (criterion) {
- _this.setCriterionValue(criterion)
- }), SG.game.event_controller.onCriterionsChange(stage.criterions_results), this.saveTracking()
- }, addPath: function (path) {
- var _this = this;
- this.paths.push(path.id), path.criterions_results.forEach(function (criterion) {
- _this.setCriterionValue(criterion)
- }), SG.game.event_controller.onCriterionsChange(path.criterions_results)
- }, saveTracking: function () {
- SG.scorm.api_available && (SG.scorm.storeScore(this.getGeneralScore()), SG.scorm.storeTrack(this.trackToString()), SG.scorm.storePlayTime(this.getTimeSinceStartGame(SG.scorm.scorm_version)), SG.scorm.save())
- }, setCriterionValue: function (criterion) {
- if (this.criterionExist(criterion.id)) {
- this.score[criterion.id] = this.score[criterion.id] || {};
- var current_score = this.score[criterion.id].value || 0;
- this.score[criterion.id] = {
- id: criterion.id,
- value: parseInt(current_score) + parseInt(criterion.value[this.difficulty])
- }, SG.core.debug_mode
- } else this.score[criterion.id] = {id: criterion.id, value: parseInt(criterion.points)}
- }, resetCriterionValue: function (criterion) {
- this.criterionExist(criterion.id) && (this.score[criterion.id] = {id: criterion.id, value: 0})
- }, criterionExist: function (criterion_id) {
- var criterion_exists = !1;
- return $.each(this.criterions, function (key, criterion) {
- criterion.id == criterion_id && (criterion_exists = !0)
- }), criterion_exists
- }, getLastStageId: function () {
- var stage_id_to_return;
- return stage_id_to_return = this.getPreviousStageId(1)
- }, getPreviousStageId: function (previous_index) {
- var stage_id_to_return;
- return stage_id_to_return = this.stages[this.stages.length - previous_index] ? this.stages[this.stages.length - previous_index - 1] : -1
- }, trackToString: function () {
- var _this = this, track_string = "";
- track_string += "i" + SG.phase_manager.phase_index + this.SEPARATOR, track_string += "u0|0" + this.SEPARATOR, track_string += "d" + this.difficulty + this.SEPARATOR, this.stages.forEach(function (stage_id) {
- track_string += "s" + stage_id + _this.SEPARATOR
- }), this.paths.forEach(function (path_id) {
- track_string += "p" + path_id + _this.SEPARATOR
- });
- var key;
- for (key in this.score) track_string += "c" + this.score[key].id + "|" + this.score[key].value + this.SEPARATOR;
- return track_string
- }, stringToTrack: function (track_string) {
- var type, value, _this = this, track_array = track_string.split(this.SEPARATOR);
- track_array.forEach(function (part) {
- switch (type = part.substr(0, 1), value = part.substr(1), type) {
- case"i":
- _this.lastPhaseIndex = parseInt(value);
- case"d":
- _this.difficulty = parseInt(value);
- break;
- case"s":
- _this.stages.push(parseInt(value));
- break;
- case"p":
- _this.paths.push(parseInt(value));
- break;
- case"c":
- var criterion = value.split("|"), score = {id: criterion[0], value: criterion[1]};
- _this.score[score.id] = score
- }
- })
- }, getCurrentPercentageForCriterionId: function (criterion_id) {
- var min, max, score = this.getScoreByCriterionId(criterion_id), percentage = 0;
- return "undefined" == typeof this.criterions[criterion_id] ? 0 : (this.criterions[criterion_id].min[this.difficulty] && this.criterions[criterion_id].max[this.difficulty] ? (min = this.criterions[criterion_id].min[this.difficulty], max = this.criterions[criterion_id].max[this.difficulty]) : (min = this.criterions[criterion_id][0].min[this.difficulty], max = this.criterions[criterion_id][0].max[this.difficulty]), score -= min, max -= min, max > 0 && (percentage = Math.round(parseInt(score) / parseInt(max) * 100)), percentage < 0 ? percentage = 0 : percentage > 100 && (percentage = 100), percentage)
- }, getGeneralScore: function () {
- var general_score, _this = this, score = 0, nb_criterion = 0;
- return $.each(this.criterions, function (key, criterion) {
- score += _this.getCurrentPercentageForCriterionId(criterion.id), nb_criterion++
- }), general_score = parseInt(score / nb_criterion)
- }, getScoreByCriterionId: function (criterion_id) {
- var score_value = -1;
- return void 0 !== this.score[criterion_id] && null !== this.score[criterion_id] && (score_value = this.score[criterion_id].value), score_value
- }, getNumberOfCriterion: function () {
- var nb;
- return nb = this.criterions.length
- }, getTimeSinceStartGame: function (scorm_version) {
- var currentTime = new Date, diff = currentTime - this.timeSinceStartUp, msec = diff, hh = Math.floor(msec / 1e3 / 60 / 60);
- msec -= 1e3 * hh * 60 * 60;
- var mm = Math.floor(msec / 1e3 / 60);
- msec -= 1e3 * mm * 60;
- var ss = Math.floor(msec / 1e3);
- return msec -= 1e3 * ss, "1.2" == scorm_version ? (hh < 10 ? "0" : "") + hh + ":" + (mm < 10 ? "0" : "") + mm + ":" + (ss < 10 ? "0" : "") + ss : "PT" + hh + "H" + mm + "M" + ss + "S"
- }, toJsonString: function () {
- var score, _this = this, json = "{";
- json += '"lastStageId":"' + this.getLastStageId() + '",', json += '"criterions":[';
- var bFirst = !0;
- return $.each(this.criterions, function (key, criterion) {
- bFirst ? bFirst = !1 : json += ",", score = _this.score[criterion.id] ? _this.score[criterion.id].value : 0, json += '{"id":' + criterion.id + ', "name": "' + criterion.name + '", "score":' + _this.getCurrentPercentageForCriterionId(criterion.id) + "}"
- }), json += "]", json += "}"
- }
- }, Object.defineProperties(SG.Tracker.prototype, {
- criterions: {
- get: function () {
- return this._criterions
- }, set: function (criterions) {
- this._criterions = criterions
- }
- }, lastPhaseIndex: {
- get: function () {
- return this._lastPhaseIndex
- }, set: function (lastPhaseIndex) {
- this.saveTracking(), this._lastPhaseIndex = lastPhaseIndex
- }
- }, difficulty: {
- get: function () {
- return this._difficulty
- }, set: function (difficulty) {
- this._difficulty = difficulty
- }
- }, stages: {
- get: function () {
- return this._stages
- }, set: function (stages) {
- this._stages = stages
- }
- }, paths: {
- get: function () {
- return this._paths
- }, set: function (paths) {
- this._paths = paths
- }
- }, score: {
- get: function () {
- return this._score
- }, set: function (score) {
- this._score = score
- }
- }, current_stage_id: {
- get: function () {
- return this._current_stage_id
- }, set: function (score) {
- this._current_stage_id = score
- }
- }, timeSinceStartUp: {
- get: function () {
- return this._timeSinceStartUp
- }, set: function (time) {
- this._timeSinceStartUp = time
- }
- }
- }), SG.CheatCodeController = {
- addCheatCode: function (combination, callback) {
- var egg = new Egg;
- egg.addCode(combination, function () {
- callback()
- }).addHook(function () {
- console.log("Hook called for: " + this.activeEgg.keys), console.log(this.activeEgg.metadata)
- }).listen()
- }
- }, SG.Scorm = function () {
- var Scorm = function () {
- this._is_scorm = !1, this._api_available = !1, this._scorm_version = "1.2"
- };
- Scorm.prototype = {
- init: function () {
- pipwerks.SCORM.version = this._scorm_version;
- var success = pipwerks.SCORM.init();
- success ? (console.log("Scorm init success: v" + pipwerks.SCORM.version), this._api_available = !0) : (console.log("Scorm init fail"), this._api_available = !1)
- }, storeScore: function (score) {
- "1.2" == this.scorm_version ? (pipwerks.SCORM.set("cmi.core.score.min", 0), pipwerks.SCORM.set("cmi.core.score.max", 100), pipwerks.SCORM.set("cmi.core.score.raw", score), pipwerks.SCORM.set("cmi.core.score.scaled", score / 100)) : (pipwerks.SCORM.set("cmi.score.min", 0), pipwerks.SCORM.set("cmi.score.max", 100), pipwerks.SCORM.set("cmi.score.raw", score), pipwerks.SCORM.set("cmi.score.scaled", score / 100)), console.log("Scorm store score : " + score)
- }, storeObjectives: function () {
- var criterions = SG.tracker.criterions, i = 0;
- for (var criterion_id in criterions) {
- var score = SG.tracker.getCurrentPercentageForCriterionId(criterion_id);
- pipwerks.SCORM.set("cmi.objectives." + i + ".id", "obj_loc_" + criterion_id), pipwerks.SCORM.set("cmi.objectives." + i + ".score.min", 0), pipwerks.SCORM.set("cmi.objectives." + i + ".score.max", 100), pipwerks.SCORM.set("cmi.objectives." + i + ".score.raw", score), "2004" == this.scorm_version && pipwerks.SCORM.set("cmi.objectives." + i + ".score.scaled", score / 100), i++
- }
- }, storeTrack: function (track) {
- pipwerks.SCORM.set("cmi.suspend_data", track), console.log("Scorm store track : " + track)
- }, storePlayTime: function (time) {
- "1.2" == this.scorm_version ? pipwerks.SCORM.set("cmi.core.session_time", time) : pipwerks.SCORM.set("cmi.session_time", time), console.log("Scorm store play time : " + time)
- }, storeGameCompleted: function () {
- "1.2" == this.scorm_version ? pipwerks.SCORM.set("cmi.core.lesson_status", "completed") : pipwerks.SCORM.set("cmi.completion_status", "completed"), console.log("Scorm storeGameCompleted : completed")
- }, getTrack: function (track) {
- var track = pipwerks.SCORM.get("cmi.suspend_data", track);
- return console.log("Scorm get track" + track), track
- }, save: function () {
- pipwerks.SCORM.save(), console.log("Scorm save in database.")
- }, quit: function () {
- pipwerks.SCORM.quit(), console.log("Scorm quit.")
- }
- }, Object.defineProperties(Scorm.prototype, {
- is_scorm: {
- get: function () {
- return this._is_scorm
- }, set: function (is_scorm) {
- this._is_scorm = is_scorm
- }
- }, api_available: {
- get: function () {
- return this._api_available
- }, set: function (api_available) {
- this._api_available = api_available
- }
- }, scorm_version: {
- get: function () {
- return this._scorm_version
- }, set: function (scorm_version) {
- this._scorm_version = scorm_version
- }
- }
- });
- var instance = null;
- return new function () {
- this.getInstance = function () {
- return null === instance && (instance = new Scorm), instance;
- }
- }
- }(), SG.scorm = SG.Scorm.getInstance();
- var amfphp;
- amfphp || (amfphp = {}), amfphp.services = {}, amfphp.entryPointUrl = SG.core.base_url + "/gateway.php?contentType=application/json", amfphp.services.itysg__Echanges = {}, amfphp.services.itysg__Echanges.connexionJson = function (onSuccess, onError, login, password, key, uid, user_lang, from, client, globalscenario) {
- var callData = JSON.stringify({
- serviceName: "itysg__Echanges",
- methodName: "connexionJson",
- parameters: [login, password, key, uid, user_lang, from, client, globalscenario]
- });
- $.post(amfphp.entryPointUrl, callData, onSuccess).error(onError)
- }, amfphp.services.itysg__Echanges.loadGlobalScenarioJSON = function (onSuccess, onError, global_scenario_id, login, password, user_lang, conn_key, character_id, uid, client) {
- var callData = JSON.stringify({
- serviceName: "itysg__Echanges",
- methodName: "loadGlobalScenarioJson",
- parameters: [global_scenario_id, login, password, user_lang, conn_key, character_id, uid, client]
- });
- $.post(amfphp.entryPointUrl, callData, onSuccess).error(onError)
- }, amfphp.services.itysg__Echanges.Echanges = function (onSuccess, onError) {
- var callData = JSON.stringify({serviceName: "itysg__Echanges", methodName: "Echanges", parameters: []});
- $.post(amfphp.entryPointUrl, callData, onSuccess).error(onError)
- }, amfphp.services.itysg__Echanges.getPermissionXmlDescription = function (onSuccess, onError, user_id) {
- var callData = JSON.stringify({serviceName: "itysg__Echanges", methodName: "getPermissionXmlDescription", parameters: [user_id]});
- $.post(amfphp.entryPointUrl, callData, onSuccess).error(onError)
- }, amfphp.services.itysg__Echanges.connexion = function (onSuccess, onError, login, password, user_lang) {
- var callData = JSON.stringify({serviceName: "itysg__Echanges", methodName: "connexion", parameters: [login, password, user_lang]});
- $.post(amfphp.entryPointUrl, callData, onSuccess).error(onError)
- }, amfphp.services.itysg__Echanges.loadGlobaldatas = function (onSuccess, onError, global_scenario_id, login, password, user_lang, conn_key, character_id, uid, client) {
- var callData = JSON.stringify({
- serviceName: "itysg__Echanges",
- methodName: "loadGlobaldatas",
- parameters: [global_scenario_id, login, password, user_lang, conn_key, character_id, uid, client]
- });
- $.post(amfphp.entryPointUrl, callData, onSuccess).error(onError)
- }, amfphp.services.itysg__Echanges.loadScenario = function (onSuccess, onError, global_scenario_id, login, password, user_lang, conn_key, character_id, uid, client) {
- var callData = JSON.stringify({
- serviceName: "itysg__Echanges",
- methodName: "loadScenario",
- parameters: [global_scenario_id, login, password, user_lang, conn_key, character_id, uid, client]
- });
- $.post(amfphp.entryPointUrl, callData, onSuccess).error(onError)
- }, amfphp.services.itysg__Echanges.loadSceneryFromActScenario = function (onSuccess, onError, act_id, globalscenario_id, login, password, user_lang, conn_key, character_id, uid, client) {
- var callData = JSON.stringify({
- serviceName: "itysg__Echanges",
- methodName: "loadSceneryFromActScenarioJson",
- parameters: [act_id, globalscenario_id, login, password, user_lang, conn_key, character_id, uid, client]
- });
- $.post(amfphp.entryPointUrl, callData, onSuccess).error(onError)
- }, amfphp.services.itysg__Echanges.saveGameProgression = function (onSuccess, onError, global_scenario_id, user_id, phase_index, track) {
- var callData = JSON.stringify({
- serviceName: "itysg__Echanges",
- methodName: "saveGameProgression",
- parameters: [global_scenario_id, user_id, phase_index, track]
- });
- $.post(amfphp.entryPointUrl, callData, onSuccess).error(onError)
- }, amfphp.services.itysg__Echanges.resetGameProgression = function (onSuccess, onError, global_scenario_id, user_id) {
- var callData = JSON.stringify({
- serviceName: "itysg__Echanges",
- methodName: "resetGameProgression",
- parameters: [global_scenario_id, user_id]
- });
- $.post(amfphp.entryPointUrl, callData, onSuccess).error(onError)
- }, amfphp.services.itysg__Echanges.sendTrack = function (onSuccess, onError, track, login, pwd, scenario_id, conn_key, uid) {
- var callData = JSON.stringify({
- serviceName: "itysg__Echanges",
- methodName: "sendTrack",
- parameters: [track, login, pwd, scenario_id, conn_key, uid]
- });
- $.post(amfphp.entryPointUrl, callData, onSuccess).error(onError)
- }, amfphp.services.itysg__Echanges.sendQuizzInfo = function (onSuccess, onError, stringInfo, login, pwd, scenario_id, conn_key, uid) {
- var callData = JSON.stringify({
- serviceName: "itysg__Echanges",
- methodName: "sendQuizzInfo",
- parameters: [stringInfo, login, pwd, scenario_id, conn_key, uid]
- });
- $.post(amfphp.entryPointUrl, callData, onSuccess).error(onError)
- }, amfphp.services.itysg__Echanges.sendVariousQuestionnaireEntry = function (onSuccess, onError, userlogi, userid, gsenarioid, questionnaire_id, label, value) {
- var callData = JSON.stringify({
- serviceName: "itysg__Echanges",
- methodName: "sendVariousQuestionnaireEntry",
- parameters: [userlogi, userid, gsenarioid, questionnaire_id, label, value]
- });
- $.post(amfphp.entryPointUrl, callData, onSuccess).error(onError)
- }, amfphp.services.itysg__Echanges.saveGenericDatas = function (onSuccess, onError, login, pwd, lang, datas) {
- var callData = JSON.stringify({serviceName: "itysg__Echanges", methodName: "saveGenericDatas", parameters: [login, pwd, lang, datas]});
- $.post(amfphp.entryPointUrl, callData, onSuccess).error(onError)
- }, amfphp.services.itysg__Echanges.sendDemographicQuestionnaire = function (onSuccess, onError, userlogin, lang, age, sex, education_level, managerial_experience, country, nationality) {
- var callData = JSON.stringify({
- serviceName: "itysg__Echanges",
- methodName: "sendDemographicQuestionnaire",
- parameters: [userlogin, lang, age, sex, education_level, managerial_experience, country, nationality]
- });
- $.post(amfphp.entryPointUrl, callData, onSuccess).error(onError)
- }, amfphp.services.itysg__Echanges.sendSurfaceQuestionnaire = function (onSuccess, onError, userlogin, lang, enjoyable, remind_situation, go_futher_in_learning, look_realistic, too_long, change_vision_of_behaviour, enjoy_replay, discover_new_concept, choice_appropriate, seem_artificial) {
- var callData = JSON.stringify({
- serviceName: "itysg__Echanges",
- methodName: "sendSurfaceQuestionnaire",
- parameters: [userlogin, lang, enjoyable, remind_situation, go_futher_in_learning, look_realistic, too_long, change_vision_of_behaviour, enjoy_replay, discover_new_concept, choice_appropriate, seem_artificial]
- });
- $.post(amfphp.entryPointUrl, callData, onSuccess).error(onError)
- }, amfphp.services.itysg__Echanges.sendContactForm = function (onSuccess, onError, userlogin, type_id, text) {
- var callData = JSON.stringify({serviceName: "itysg__Echanges", methodName: "sendContactForm", parameters: [userlogin, type_id, text]});
- $.post(amfphp.entryPointUrl, callData, onSuccess).error(onError)
- }, amfphp.services.itysg__Echanges.updateProposition = function (onSuccess, onError, proposition_id, lang, new_string_value) {
- var callData = JSON.stringify({
- serviceName: "itysg__Echanges",
- methodName: "updateProposition",
- parameters: [proposition_id, lang, new_string_value]
- });
- $.post(amfphp.entryPointUrl, callData, onSuccess).error(onError)
- }, amfphp.services.itysg__Echanges.addStage = function (onSuccess, onError, scenarioid, lang, stage_type) {
- var callData = JSON.stringify({serviceName: "itysg__Echanges", methodName: "addStage", parameters: [scenarioid, lang, stage_type]});
- $.post(amfphp.entryPointUrl, callData, onSuccess).error(onError)
- }, amfphp.services.itysg__Echanges.updateStage = function (onSuccess, onError, id_stage, scenarioid, lang, label, description, color, size, x, y, act_id, stage_type, phase_id) {
- var callData = JSON.stringify({
- serviceName: "itysg__Echanges",
- methodName: "updateStage",
- parameters: [id_stage, scenarioid, lang, label, description, color, size, x, y, act_id, stage_type, phase_id]
- });
- $.post(amfphp.entryPointUrl, callData, onSuccess).error(onError)
- }, amfphp.services.itysg__Echanges.updatePropostionVerbose = function (onSuccess, onError, target, type, parent, active, short, lang, id, scenarioid, binMF, binFM, binFF, binMM, color, size) {
- var callData = JSON.stringify({
- serviceName: "itysg__Echanges",
- methodName: "updatePropostionVerbose",
- parameters: [target, type, parent, active, short, lang, id, scenarioid, binMF, binFM, binFF, binMM, color, size]
- });
- $.post(amfphp.entryPointUrl, callData, onSuccess).error(onError)
- }, amfphp.services.itysg__Echanges.removeStage = function (onSuccess, onError, stageid) {
- var callData = JSON.stringify({serviceName: "itysg__Echanges", methodName: "removeStage", parameters: [stageid]});
- $.post(amfphp.entryPointUrl, callData, onSuccess).error(onError)
- }, amfphp.services.itysg__Echanges.addProposition = function (onSuccess, onError, source, target, lang, scenarioid) {
- var callData = JSON.stringify({
- serviceName: "itysg__Echanges",
- methodName: "addProposition",
- parameters: [source, target, lang, scenarioid]
- });
- $.post(amfphp.entryPointUrl, callData, onSuccess).error(onError)
- }, amfphp.services.itysg__Echanges.removeProposition = function (onSuccess, onError, propositionid) {
- var callData = JSON.stringify({serviceName: "itysg__Echanges", methodName: "removeProposition", parameters: [propositionid]});
- $.post(amfphp.entryPointUrl, callData, onSuccess).error(onError)
- }, amfphp.services.itysg__Echanges.getScenarioTreeXML = function (onSuccess, onError, scenarioid, lang) {
- var callData = JSON.stringify({serviceName: "itysg__Echanges", methodName: "getScenarioTreeXML", parameters: [scenarioid, lang]});
- $.post(amfphp.entryPointUrl, callData, onSuccess).error(onError)
- }, amfphp.services.itysg__Echanges.saveTreePosition = function (onSuccess, onError, scenarioid, x, y, zoom) {
- var callData = JSON.stringify({serviceName: "itysg__Echanges", methodName: "saveTreePosition", parameters: [scenarioid, x, y, zoom]});
- $.post(amfphp.entryPointUrl, callData, onSuccess).error(onError)
- }, amfphp.services.itysg__Echanges.setAndSaveFirstStageId = function (onSuccess, onError, scenarioid, stageid) {
- var callData = JSON.stringify({
- serviceName: "itysg__Echanges",
- methodName: "setAndSaveFirstStageId",
- parameters: [scenarioid, stageid]
- });
- $.post(amfphp.entryPointUrl, callData, onSuccess).error(onError)
- }, amfphp.services.itysg__Echanges.getDifficultiesData = function (onSuccess, onError, lang, scenario_id) {
- var callData = JSON.stringify({serviceName: "itysg__Echanges", methodName: "getDifficultiesData", parameters: [lang, scenario_id]});
- $.post(amfphp.entryPointUrl, callData, onSuccess).error(onError)
- }, amfphp.services.itysg__Echanges.getCriterionsForScenario = function (onSuccess, onError, lang, scenario_id) {
- var callData = JSON.stringify({
- serviceName: "itysg__Echanges",
- methodName: "getCriterionsForScenario",
- parameters: [lang, scenario_id]
- });
- $.post(amfphp.entryPointUrl, callData, onSuccess).error(onError)
- }, amfphp.services.itysg__Echanges.getTextsForFlashApp = function (onSuccess, onError, lang) {
- var callData = JSON.stringify({serviceName: "itysg__Echanges", methodName: "getTextsForFlashApp", parameters: [lang]});
- $.post(amfphp.entryPointUrl, callData, onSuccess).error(onError)
- }, amfphp.services.itysg__Echanges.saveAttributionPoint = function (onSuccess, onError, stageid, criterionid, value, level) {
- var callData = JSON.stringify({
- serviceName: "itysg__Echanges",
- methodName: "saveAttributionPoint",
- parameters: [stageid, criterionid, value, level]
- });
- $.post(amfphp.entryPointUrl, callData, onSuccess).error(onError)
- }, amfphp.services.itysg__Echanges.saveMultipleAttributionPointForStages = function (onSuccess, onError, stages, criterions, values, levels) {
- var callData = JSON.stringify({
- serviceName: "itysg__Echanges",
- methodName: "saveMultipleAttributionPointForStages",
- parameters: [stages, criterions, values, levels]
- });
- $.post(amfphp.entryPointUrl, callData, onSuccess).error(onError)
- }, amfphp.services.itysg__Echanges.saveMultipleAttributionPointForPropositions = function (onSuccess, onError, propositions, criterions, values, levels) {
- var callData = JSON.stringify({
- serviceName: "itysg__Echanges",
- methodName: "saveMultipleAttributionPointForPropositions",
- parameters: [propositions, criterions, values, levels]
- });
- $.post(amfphp.entryPointUrl, callData, onSuccess).error(onError)
- }, amfphp.services.itysg__Echanges.reloadPointsForStages = function (onSuccess, onError, stages) {
- var callData = JSON.stringify({serviceName: "itysg__Echanges", methodName: "reloadPointsForStages", parameters: [stages]});
- $.post(amfphp.entryPointUrl, callData, onSuccess).error(onError)
- }, amfphp.services.itysg__Echanges.reloadPointsForPropositions = function (onSuccess, onError, propositions) {
- var callData = JSON.stringify({serviceName: "itysg__Echanges", methodName: "reloadPointsForPropositions", parameters: [propositions]});
- $.post(amfphp.entryPointUrl, callData, onSuccess).error(onError)
- }, amfphp.services.itysg__Echanges.deleteAttributionPointForStage = function (onSuccess, onError, stageid, criterionid) {
- var callData = JSON.stringify({
- serviceName: "itysg__Echanges",
- methodName: "deleteAttributionPointForStage",
- parameters: [stageid, criterionid]
- });
- $.post(amfphp.entryPointUrl, callData, onSuccess).error(onError)
- }, amfphp.services.itysg__Echanges.deleteAttributionPointForProposition = function (onSuccess, onError, propositionid, criterionid) {
- var callData = JSON.stringify({
- serviceName: "itysg__Echanges",
- methodName: "deleteAttributionPointForProposition",
- parameters: [propositionid, criterionid]
- });
- $.post(amfphp.entryPointUrl, callData, onSuccess).error(onError)
- }, amfphp.services.itysg__Echanges.saveCriterionsChecked = function (onSuccess, onError, scenario_id, criterionsChecked) {
- var callData = JSON.stringify({
- serviceName: "itysg__Echanges",
- methodName: "saveCriterionsChecked",
- parameters: [scenario_id, criterionsChecked]
- });
- $.post(amfphp.entryPointUrl, callData, onSuccess).error(onError)
- }, amfphp.services.itysg__Echanges.onConnectToSGResults = function (onSuccess, onError, user_id) {
- var callData = JSON.stringify({serviceName: "itysg__Echanges", methodName: "onConnectToSGResults", parameters: [user_id]});
- $.post(amfphp.entryPointUrl, callData, onSuccess).error(onError)
- }, amfphp.services.itysg__Echanges.getGlobalAccessFor = function (onSuccess, onError, user_id, role_id) {
- var callData = JSON.stringify({serviceName: "itysg__Echanges", methodName: "getGlobalAccessFor", parameters: [user_id, role_id]});
- $.post(amfphp.entryPointUrl, callData, onSuccess).error(onError)
- }, amfphp.services.itysg__Echanges.getScenarioAvailable = function (onSuccess, onError, user_id, lang) {
- var callData = JSON.stringify({serviceName: "itysg__Echanges", methodName: "getScenarioAvailable", parameters: [user_id, lang]});
- $.post(amfphp.entryPointUrl, callData, onSuccess).error(onError)
- }, amfphp.services.itysg__Echanges.getCriterionsDesc = function (onSuccess, onError, gscenario_id, lang) {
- var callData = JSON.stringify({serviceName: "itysg__Echanges", methodName: "getCriterionsDesc", parameters: [gscenario_id, lang]});
- $.post(amfphp.entryPointUrl, callData, onSuccess).error(onError)
- }, amfphp.services.itysg__Echanges.getAvailableDates = function (onSuccess, onError, scenario_id, user_id) {
- var callData = JSON.stringify({serviceName: "itysg__Echanges", methodName: "getAvailableDates", parameters: [scenario_id, user_id]});
- $.post(amfphp.entryPointUrl, callData, onSuccess).error(onError)
- }, amfphp.services.itysg__Echanges.getAvailableTracksForManager = function (onSuccess, onError, scenario_id, user_id) {
- var callData = JSON.stringify({
- serviceName: "itysg__Echanges",
- methodName: "getAvailableTracksForManager",
- parameters: [scenario_id, user_id]
- });
- $.post(amfphp.entryPointUrl, callData, onSuccess).error(onError)
- }, amfphp.services.itysg__Echanges.getTracks = function (onSuccess, onError, strTracksIds) {
- var callData = JSON.stringify({serviceName: "itysg__Echanges", methodName: "getTracks", parameters: [strTracksIds]});
- $.post(amfphp.entryPointUrl, callData, onSuccess).error(onError)
- }, amfphp.services.itysg__Echanges.checkChangeActForStage = function (onSuccess, onError, scenarioId, stageId, newActId, lang) {
- var callData = JSON.stringify({
- serviceName: "itysg__Echanges",
- methodName: "checkChangeActForStage",
- parameters: [scenarioId, stageId, newActId, lang]
- });
- $.post(amfphp.entryPointUrl, callData, onSuccess).error(onError)
- }, amfphp.services.itysg__Echanges.ChangeStageDifferenceForNewAct = function (onSuccess, onError, scenarioId, stageId, newActId, lang, string_reassign) {
- var callData = JSON.stringify({
- serviceName: "itysg__Echanges",
- methodName: "ChangeStageDifferenceForNewAct",
- parameters: [scenarioId, stageId, newActId, lang, string_reassign]
- });
- $.post(amfphp.entryPointUrl, callData, onSuccess).error(onError)
- }, amfphp.services.itysg__Echanges.getStageMediaName = function (onSuccess, onError, phase_id, animation_type) {
- var callData = JSON.stringify({
- serviceName: "itysg__Echanges",
- methodName: "getStageMediaName",
- parameters: [phase_id, animation_type]
- });
- $.post(amfphp.entryPointUrl, callData, onSuccess).error(onError)
- }, amfphp.services.itysg__Echanges.log_entry = function (onSuccess, onError, message, uid, type) {
- var callData = JSON.stringify({serviceName: "itysg__Echanges", methodName: "log_entry", parameters: [message, uid, type]});
- $.post(amfphp.entryPointUrl, callData, onSuccess).error(onError)
- }, amfphp.services.itysg__Echanges.SaveReassignSound = function (onSuccess, onError, string_reassign, stage_id) {
- var callData = JSON.stringify({
- serviceName: "itysg__Echanges",
- methodName: "SaveReassignSound",
- parameters: [string_reassign, stage_id]
- });
- $.post(amfphp.entryPointUrl, callData, onSuccess).error(onError)
- }, amfphp.services.itysg__Echanges.SaveReassignSound = function (onSuccess, onError, string_reassign, stage_id) {
- var callData = JSON.stringify({
- serviceName: "itysg__Echanges",
- methodName: "SaveReassignSound",
- parameters: [string_reassign, stage_id]
- });
- $.post(amfphp.entryPointUrl, callData, onSuccess).error(onError)
- }, angular.module("itysg", ["ui.router", "ui.bootstrap", "ngDialog", "ngAnimate", "ngSanitize", "ngAria", "ngMaterial", "itysg.directives", "itysg.config", "itysg.controllers", "itysg.services"]).run(["Core", "BASE_URL", "MEDIAS_URL", "GLOBAL_SCENARIO_ID", "USER_ID", "KEY", "VERSION", "LANG", "CUSTOMER_ID", "EXPORT_RESULTS", "IS_SCORM", "SCORM_VERSION", "NUMBER_VERSION", "OFFLINE", "DEBUG", function (Core, BASE_URL, MEDIAS_URL, GLOBAL_SCENARIO_ID, USER_ID, KEY, VERSION, LANG, CUSTOMER_ID, EXPORT_RESULTS, IS_SCORM, SCORM_VERSION, NUMBER_VERSION, OFFLINE, DEBUG) {
- console.log("ITycom Serious Games"), Core.offline = OFFLINE, IS_SCORM && (SG.scorm.is_scorm = IS_SCORM, SG.scorm.scorm_version = SCORM_VERSION), Core.export_results = EXPORT_RESULTS, Core.lang = LANG, Core.version = VERSION, Core.num_version = NUMBER_VERSION, Core.user = new SG.Model.User(USER_ID, KEY, CUSTOMER_ID, null), Core.global_scenario_id = GLOBAL_SCENARIO_ID, Core.base_url = BASE_URL, Core._medias_url = MEDIAS_URL, Core.debug_mode = DEBUG, SG.core.init(), SG.scorm.is_scorm && SG.scorm.init()
- }]);
- var params = params || {};
- angular.module("itysg.config", []).constant("BASE_URL", params.base_url || "").constant("MEDIAS_URL", params.medias_url || "").constant("GLOBAL_SCENARIO_ID", params.scenario_id || -1).constant("USER_ID", params.user_id || -1).constant("KEY", params.key || -1).constant("VERSION", params.version || "").constant("LANG", params.language).constant("CUSTOMER_ID", params.customer_id || 0).constant("EXPORT_RESULTS", "boolean" != typeof params.export_results || params.export_results).constant("OFFLINE", params.offline || !1).constant("IS_SCORM", params.is_scorm || !1).constant("SCORM_VERSION", params.scorm_version || !1).constant("DEBUG", params.debug || !1).constant("NUMBER_VERSION", 1).constant("SUBTITLE_ENABLE", "boolean" != typeof params.subtitle_enable || params.subtitle_enable), angular.module("itysg.controllers", ["cgBusy"]), angular.module("itysg.services", []), angular.module("itysg.routes", []), angular.module("itysg.directives", []), angular.module("itysg").config(["$stateProvider", "$urlRouterProvider", "$locationProvider", "$mdThemingProvider", function ($stateProvider, $urlRouterProvider, $locationProvider, $mdThemingProvider) {
- var customPrimary = {
- 50: "#ffffff",
- 100: "#ffffff",
- 200: "#ffffff",
- 300: "#ffffff",
- 400: "#ffffff",
- 500: "#ffffff",
- 600: "#f2f2f2",
- 700: "#e6e6e6",
- 800: "#d9d9d9",
- 900: "#cccccc",
- A100: "#ffffff",
- A200: "#ffffff",
- A400: "#ffffff",
- A700: "#bfbfbf"
- };
- $mdThemingProvider.definePalette("customPrimary", customPrimary);
- var customAccent = {
- 50: "#205378",
- 100: "#25618c",
- 200: "#2b6fa0",
- 300: "#307db5",
- 400: "#358bc9",
- 500: "#4996cf",
- 600: "#71aed9",
- 700: "#85b9df",
- 800: "#99c5e4",
- 900: "#aed0e9",
- A100: "#71aed9",
- A200: "#5da2d4",
- A400: "#4996cf",
- A700: "#c2dcef"
- };
- $mdThemingProvider.definePalette("customAccent", customAccent);
- var customWarn = {
- 50: "#fbce99",
- 100: "#fac280",
- 200: "#fab668",
- 300: "#f9ab4f",
- 400: "#f89f37",
- 500: "#F7931E",
- 600: "#f38709",
- 700: "#da7908",
- 800: "#c26c07",
- 900: "#a95e06",
- A100: "#fcdab2",
- A200: "#fde6ca",
- A400: "#fef2e3",
- A700: "#905005"
- };
- $mdThemingProvider.definePalette("customWarn", customWarn);
- var customBackground = {
- 50: "#737373",
- 100: "#666666",
- 200: "#595959",
- 300: "#4d4d4d",
- 400: "#404040",
- 500: "#333",
- 600: "#262626",
- 700: "#1a1a1a",
- 800: "#0d0d0d",
- 900: "#000000",
- A100: "#808080",
- A200: "#8c8c8c",
- A400: "#999999",
- A700: "#000000"
- };
- $mdThemingProvider.definePalette("customBackground", customBackground), $mdThemingProvider.theme("default").primaryPalette("customPrimary").accentPalette("customAccent").warnPalette("customWarn").backgroundPalette("customBackground"), $stateProvider.state("index", {
- url: "/",
- templateUrl: "templates/views/index.html",
- controller: "IndexCtrl"
- }).state("connection", {
- templateUrl: "templates/views/connection.html",
- controller: "ConnectionCtrl"
- }).state("message", {
- templateUrl: "templates/views/message.html",
- controller: "MessageCtrl"
- }).state("chooseCharacter", {
- templateUrl: "templates/views/chooseCharacter.html",
- controller: "ChooseCharacterCtrl"
- }).state("loadingData", {controller: "LoadingDatasCtrl"}).state("phase", {
- templateUrl: "templates/views/phase/phase.html",
- controller: "PhaseCtrl"
- }).state("phase.BobSpeech", {template: '<ity-phase ity-bobspeech phase="current_phase" sceneries="sceneries" class="phase-content"></ity-phase>'}).state("phase.WebPhase", {template: '<ity-phase ity-webphase phase="current_phase" sceneries="sceneries"></ity-phase>'}).state("phase.Scenario", {template: ""}).state("phase.KinematicPhase", {template: '<ity-phase ity-kinematicphase phase="current_phase"></ity-phase>'}).state("phase.AnimationPhase", {template: '<ity-phase ity-kinematicphase phase="current_phase"></ity-phase>'}).state("phase.Quizz", {template: '<ity-phase ity-quizz-base phase="current_phase"></ity-phase>'}).state("phase.CharacterSelection", {template: '<ity-phase ity-character-selection phase="current_phase"></ity-phase>'}).state("phase.EndGame", {template: '<ity-phase ity-end-game class="phase-content"></ity-phase>'}), $urlRouterProvider.otherwise("/");
- var customPrimary = {
- 50: "#ffffff",
- 100: "#ffffff",
- 200: "#ffffff",
- 300: "#ffffff",
- 400: "#ffffff",
- 500: "#ffffff",
- 600: "#f2f2f2",
- 700: "#e6e6e6",
- 800: "#d9d9d9",
- 900: "#cccccc",
- A100: "#ffffff",
- A200: "#ffffff",
- A400: "#ffffff",
- A700: "#bfbfbf"
- }
- }]), SG.Utils.mouse = {}, SG.Utils.mouse.origin = {x: 0, y: 0}, SG.Utils.mouse.position = {
- x: 0,
- y: 0
- }, SG.Utils.mouse.down = !1, SG.Utils.mouse.mousedown = "mousedown", SG.Utils.mouse.mouseup = "mouseup", SG.Utils.mouse.mousemove = "mousemove", SG.Utils.mouse.supportsTouch = "ontouchstart" in document.documentElement, SG.Utils.mouse.supportsTouch ? (SG.Utils.mouse.mousedown = "touchstart", SG.Utils.mouse.mouseup = "touchend", SG.Utils.mouse.mousemove = "touchmove", $("body").on("touchstart", function (e) {
- SG.Utils.mouse.onMouseDown(e)
- }), $("body").on("touchend", function (e) {
- SG.Utils.mouse.onMouseUp(e)
- }), $("body").on("touchmove", function (e) {
- SG.Utils.mouse.onMouseMove(e)
- })) : ($("body").mousedown(function (e) {
- SG.Utils.mouse.onMouseDown(e)
- }), $("body").mouseup(function (e) {
- SG.Utils.mouse.onMouseUp(e)
- }), $("body").mousemove(function (e) {
- SG.Utils.mouse.onMouseMove(e)
- })), SG.Utils.mouse.getEvent = function (e) {
- return e.originalEvent.touches ? e.originalEvent.touches[0] : e.originalEvent.changedTouches ? e.originalEvent.changedTouches[0] : e
- }, SG.Utils.mouse.onMouseDown = function (e) {
- var event = SG.Utils.mouse.getEvent(e);
- SG.Utils.mouse.origin.x = event.pageX, SG.Utils.mouse.origin.y = event.pageY, SG.Utils.mouse.down = !0
- }, SG.Utils.mouse.onMouseUp = function () {
- SG.Utils.mouse.down = !1
- }, SG.Utils.mouse.onMouseMove = function (e) {
- var event = SG.Utils.mouse.getEvent(e);
- SG.Utils.mouse.position.x = event.pageX, SG.Utils.mouse.position.y = event.pageY
- }, SG.Utils.Scrollbar = function () {
- this._clicking = !1, this._oldTop = 0, this._element, this._speed = 20, this._padding = 10, this._invert = !1, this._ratio = 1, this._scrollable = {}, this._scrollable.element, this._scrollable.realHeight = 0, this._scrollable.height = 0, this._container = {}, this._container.element, this._visible = !1
- }, SG.Utils.Scrollbar.prototype.setScrollSystem = function (scrollbarEl, scrollableEl) {
- var _this = this;
- this.element = scrollbarEl, this.container.element = this.element.parent(), this.scrollable.element = scrollableEl, this.element.css("top", this.padding + "px"), this.scrollable.element.scrollTop(0), this.updateHeight(), this.element.parent().on(SG.Utils.mouse.mousedown, function (e) {
- SG.Utils.mouse.supportsTouch && (SG.Utils.mouse.origin.y = e.originalEvent.changedTouches[0].pageY), _this.scroll(SG.Utils.mouse.position.y - _this.element.parent().offset().top - _this.element.height() / 2), _this.startScroll()
- }), this.element.parent().on(SG.Utils.mouse.mousemove, function (e) {
- e.preventDefault()
- }), this.setScrollControl(this.scrollable.element), $("body").on(SG.Utils.mouse.mouseup, function () {
- _this.stopScroll()
- }), $("body").on(SG.Utils.mouse.mousemove, function () {
- if (_this.clicking) {
- var newTop = 0;
- newTop = _this.invert ? _this.oldTop + (SG.Utils.mouse.origin.y - SG.Utils.mouse.position.y) * _this.ratio : _this.oldTop + (SG.Utils.mouse.position.y - SG.Utils.mouse.origin.y), _this.scroll(newTop)
- }
- }), $(window).resize(function () {
- _this.updateHeight()
- })
- }, SG.Utils.Scrollbar.prototype.setScrollControl = function (element) {
- var _this = this;
- element.on(SG.Utils.mouse.mousemove, function (e) {
- _this.visible && e.preventDefault()
- }), element.bind("DOMMouseScroll", function (e) {
- return _this.visible && (_this.oldTop = parseFloat(_this.element.css("top")), e.originalEvent.detail > 0 ? _this.scroll(_this.oldTop + _this.speed * _this.ratio) : _this.scroll(_this.oldTop - _this.speed * _this.ratio)), !_this.visible
- }), element.bind("mousewheel", function (e) {
- return _this.visible && (_this.oldTop = parseFloat(_this.element.css("top")), e.originalEvent.wheelDelta < 0 ? _this.scroll(_this.oldTop + _this.speed * _this.ratio) : _this.scroll(_this.oldTop - _this.speed * _this.ratio)), !_this.visible
- }), element.on(SG.Utils.mouse.mousedown, function () {
- _this.startScroll(), _this.invert = !0
- })
- }, SG.Utils.Scrollbar.prototype.stopScroll = function () {
- this._clicking = !1, this.invert = !1
- }, SG.Utils.Scrollbar.prototype.startScroll = function () {
- this.oldTop = parseInt(this.element.css("top")), this._clicking = !0
- }, SG.Utils.Scrollbar.prototype.updateHeight = function () {
- this.scrollable.realHeight = this.scrollable.element[0].scrollHeight, this.scrollable.height = this.scrollable.element.height(), this._ratio = this.scrollable.height / this.scrollable.realHeight, this.ratio < 1 ? (this.container.element.show(), this._visible = !0, this.element.css("height", 100 * this.ratio + "%")) : (this.container.element.hide(), this._visible = !1), this.scroll(this.scrollable.element.scrollTop())
- }, SG.Utils.Scrollbar.prototype.scroll = function (newTop) {
- var barHeight = this.element.height(), newBottom = newTop + barHeight, containerHeigth = this.container.element.outerHeight();
- if (newTop > 0 + this.padding && newBottom < containerHeigth - this.padding) {
- this.element.css("top", newTop + "px");
- var percent = (newTop - this.padding) / (containerHeigth - 2 * this.padding - barHeight);
- this.scrollable.element.scrollTop(percent * (this.scrollable.realHeight - this.scrollable.element.height()))
- } else newTop <= this.padding ? (this.element.css("top", this.padding + "px"), this.scrollable.element.scrollTop(0)) : newBottom >= containerHeigth - this.padding && (this.element.css("top", containerHeigth - barHeight - this.padding + "px"), this.scrollable.element.scrollTop(this.scrollable.realHeight))
- }, Object.defineProperties(SG.Utils.Scrollbar.prototype, {
- clicking: {
- get: function () {
- return this._clicking
- }
- }, oldTop: {
- get: function () {
- return this._oldTop
- }, set: function (value) {
- this._oldTop = value
- }
- }, element: {
- get: function () {
- return this._element
- }, set: function (value) {
- this._element = value
- }
- }, speed: {
- get: function () {
- return this._speed
- }, set: function (value) {
- this._speed = value
- }
- }, padding: {
- get: function () {
- return this._padding
- }, set: function (value) {
- this._padding = value
- }
- }, scrollable: {
- get: function () {
- return this._scrollable
- }
- }, invert: {
- get: function () {
- return this._invert
- }, set: function (value) {
- this._invert = value
- }
- }, ratio: {
- get: function () {
- return this._ratio
- }
- }, visible: {
- get: function () {
- return this._visible
- }
- }, container: {
- get: function () {
- return this._container
- }
- }
- }), SG.Utils.AudioPlayer = function () {
- this._audio, this._player, this._playButton, this._stopButton, this._bar, this._barwrap, this._updateRate = 20, this._updateThread, this._old_pos = {}, this._clicking = !1, this._percent
- }, SG.Utils.AudioPlayer.prototype.createPlayer = function (audio, player) {
- var _this = this;
- this._audio = audio, this._player = player, this._playButton = player.children(".play"), this._stopButton = player.children(".rewind"), this._muteButton = player.children(".sound"), this._barwrap = player.children(".bar-wrap"), this._bar = this._barwrap.children(".bar"), this._playButton.click(function () {
- _this.play()
- }), this._stopButton.click(function () {
- _this.rewind()
- }), this._muteButton.click(function () {
- _this.mute()
- }), this._barwrap.on(SG.Utils.mouse.mousedown, function (e) {
- e.preventDefault(), SG.Utils.mouse.onMouseDown(e), _this._clicking = !0, _this._old_pos = _this._barwrap.offset().left;
- var pos = SG.Utils.mouse.origin.x - _this._barwrap.offset().left, percent = pos / _this._barwrap.width();
- _this._percent = percent, _this._bar.css("width", 100 * percent + "%"), _this._audio.currentTime = _this._audio.duration * percent
- }), this._barwrap.on(SG.Utils.mouse.mousemove, function () {
- if (_this._clicking) {
- var pos = SG.Utils.mouse.position.x - _this._old_pos, percent = pos / _this._barwrap.width();
- _this._percent = percent, _this._bar.css("width", 100 * percent + "%")
- }
- }), $("body").on(SG.Utils.mouse.mouseup, function () {
- _this._clicking && (_this._clicking = !1, _this._audio.currentTime = _this._audio.duration * _this._percent)
- })
- }, SG.Utils.AudioPlayer.prototype.play = function () {
- var _this = this;
- this._audio.paused ? (this._audio.play(), this._playButton.addClass("pause"), this._updateThread = setInterval(function () {
- _this.updatePlayer()
- }, this._updateRate)) : this.pause()
- }, SG.Utils.AudioPlayer.prototype.pause = function () {
- var _this = this;
- this._audio.pause(), this._playButton.removeClass("pause"), clearInterval(_this._updateThread)
- }, SG.Utils.AudioPlayer.prototype.stop = function () {
- var _this = this;
- this._audio.pause(_this), this._audio.currentTime = 0, this._bar.css("width", "0%"), this._playButton.removeClass("pause"), clearInterval(_this._updateThread)
- }, SG.Utils.AudioPlayer.prototype.rewind = function () {
- this._audio.currentTime = 0, this._bar.css("width", "0%")
- }, SG.Utils.AudioPlayer.prototype.updatePlayer = function () {
- if (this._audio.paused) this._audio.currentTime == this._audio.duration && (this._bar.css("width", "100%"), this.pause(), this._audio.currentTime = 0); else {
- if (this._clicking) return;
- this._bar.css("width", this._audio.currentTime / this._audio.duration * 100 + "%")
- }
- }, Object.defineProperties(SG.Utils.AudioPlayer.prototype, {
- audio: {
- get: function () {
- return this._audio
- }, set: function (value) {
- this._audio = value
- }
- }, updateThread: {
- get: function () {
- return this._updateThread
- }
- }, player: {
- get: function () {
- return this._player
- }, set: function (value) {
- this._player = value
- }
- }, playButton: {
- get: function () {
- return this._playButton
- }, set: function (value) {
- this._playButton = value
- }
- }, stopButton: {
- get: function () {
- return this._stopButton
- }, set: function (value) {
- this._stopButton = value
- }
- }, bar: {
- get: function () {
- return this._bar
- }, set: function (value) {
- this._bar = value
- }
- }, barwrap: {
- get: function () {
- return this._barwrap
- }, set: function (value) {
- this._barwrap = value
- }
- }, updateRate: {
- get: function () {
- return this._updateRate
- }, set: function (value) {
- this._updateRate = value
- }
- }
- }), angular.module("itysg.controllers").controller("MainCtrl", ["$scope", "$state", "$timeout", "SUBTITLE_ENABLE", function ($scope, $state, $timeout, SUBTITLE_ENABLE) {
- var DEFAULT_LOGO = "assets/images/default_logo.png";
- $scope.menu_is_display = !1, $scope.is_pause = !1, $scope.sound_is_mute = !1, $scope.subtitle_are_enable = SUBTITLE_ENABLE, $scope.displayScenario = !1, $scope.blurScenario = !1, $scope.ready_to_show = !1, $scope.first_ready_to_show = !1, $scope.msg_content = "", $scope.msg_title = "", $scope.msg_buttons = [], $scope.module_name = "", $scope.module_logo = DEFAULT_LOGO, $scope.main_overlay = !1, $scope.total_tasks = 2, $scope.task_count = 0, $scope.show_loading = !1, $scope.loading_text = "0%", $scope.$on("showOverlay", function (e, value) {
- $scope.main_overlay = value, $scope.main_overlay ? $(".main-overlay").addClass("visible") : $(".main-overlay").removeClass("visible")
- }), $scope.$on("setModuleName", function (e, value) {
- $scope.module_name = value
- }), $scope.$on("setModuleLogo", function (e, value) {
- $scope.module_logo = value
- }), $scope.$on("setDefaultLogo", function () {
- $scope.module_logo = DEFAULT_LOGO
- }), $scope.$on("setTaskCount", function (e, task_count) {
- $scope.task_count = task_count
- }), $scope.$on("setTotalTasks", function (e, total_tasks) {
- $scope.total_tasks = total_tasks
- }), $scope.$on("reportProgress", function (e, value) {
- $scope.loading_text = Math.floor(value / $scope.total_tasks + 100 / $scope.total_tasks * $scope.task_count) + "%"
- }), $scope.$on("showLoading", function (e, value) {
- $scope.show_loading = value
- }), $scope.$on("showMessage", function (e, title, message, buttons) {
- $scope.show_loading = !1, $scope.msg_content = message,
- $scope.msg_title = title, $scope.msg_buttons = buttons, $scope.goTo("message")
- }), $scope.$on("readyToShow", function (e, value) {
- $scope.ready_to_show = value, !$scope.first_ready_to_show && value && ($timeout(resizeIntroBg), $scope.first_ready_to_show = !0)
- });
- var current_state = "";
- $scope.i18n = SG.core.i18n, $scope.goTo = function (path) {
- path == current_state ? $state.reload(path) : $state.go(path), current_state = path
- };
- var getGameOffset = function () {
- var gameWidth = 980, gameHeight = 518, offset = {x: 0, y: 0, height: 0, width: 0}, width = $(document).width(),
- height = $(document).height(), ratio_game = gameWidth / gameHeight, ratio_window = width / height;
- return ratio_window < ratio_game ? (offset.height = width / ratio_game, offset.width = width, offset.y = (height - width / ratio_game) / 2) : (offset.width = height * ratio_game, offset.height = height, offset.x = (width - height * ratio_game) / 2), offset
- }, resizeIntroBg = function () {
- if ($scope.first_ready_to_show) {
- var el = $(".intro-background"), bounds = getGameOffset();
- el.width(bounds.width), el.height(bounds.height), el.offset({left: bounds.x, top: bounds.y})
- }
- };
- $(window).resize(resizeIntroBg), $scope.spinnerTpl = "templates/loadingSpinner.html", $scope.delayBusy = 200
- }]), angular.module("itysg.controllers").controller("IndexCtrl", ["$scope", "$rootScope", function ($scope, $rootScope) {
- $scope.goTo("connection")
- }]), angular.module("itysg.controllers").controller("ConnectionCtrl", ["$scope", "Core", "Echange", "$timeout", function ($scope, Core, Echange, $timeout) {
- console.log("CONNEXION"), $(".engine-loading").attr("style", "");
- var keep_progress_faker = !0, progress_faker_percent = 0, progress_faker = function () {
- progress_faker_percent += 2, $scope.$emit("reportProgress", progress_faker_percent);
- var rnd_delay = 10 * (Math.floor(50 * Math.random()) + 10);
- keep_progress_faker && progress_faker_percent < 98 && $timeout(progress_faker, rnd_delay)
- };
- $scope.password = SG.password, $scope.login = SG.login;
- var connect = function () {
- if ($scope.$emit("setTotalTasks", 2), $scope.$emit("setTaskCount", 0), $scope.$emit("showLoading", !0), $scope.$emit("reportProgress", 0), $timeout(progress_faker, 200), Core.user.id > 0 && Core.user.key.length > 0) $scope.connection("", "", Core.user.id, Core.user.key); else if (Core.user.login && Core.user.password) $scope.connection(Core.user.login, Core.user.password); else if (Core.offline) {
- var connectionPromise = Echange.connectionOffline();
- connectionPromise.then(function (datas) {
- $scope.checkAuthenticationDatas(datas)
- }), $scope.busy.promise = connectionPromise
- } else $scope.displayForm = !0
- };
- $scope.connection = function (login, password, user_id, key) {
- var connectionPromise = Echange.connection(login, password, key, user_id, Core.lang, "client", "html5", Core.global_scenario_id);
- connectionPromise.then(function (datas) {
- $scope.checkAuthenticationDatas(datas)
- }, function (error) {
- console.log("error")
- }), $scope.busy.promise = connectionPromise
- }, $scope.checkAuthenticationDatas = function (datas) {
- keep_progress_faker = !1;
- try {
- var jsonData;
- jsonData = Core.offline ? datas : JSON.parse(datas), console.log(jsonData), 0 === jsonData.authentification ? (console.log("Authentication failed"), $scope.displayForm = !0) : (console.log("Authentication success"), Core.user = new SG.Model.User(jsonData.uid, jsonData.authentification.value, jsonData.authentification.cid, jsonData.access), jsonData.users.forEach(function (user) {
- Core.characters.push(new SG.Model.Character(user, Core.global_scenario_id))
- }), $scope.displayForm = !1, $scope.goTo("loadingData"))
- } catch (e) {
- var buttons = [];
- buttons.push({
- text: "Retour à ITyStudio", callback: function () {
- window.location.href = SG.core.base_url
- }
- }), $scope.$emit("showMessage", "Erreur", "Vous n'êtes pas connecté.<br/><br/>Détails : " + e.message, buttons)
- }
- }, $scope.onConnectionError = function (error) {
- $scope.displayForm = !0, console.log("Fatal error : Connection failed"), console.log(error)
- }, $scope.busy = {message: Core.i18n.loading + " - 1/2", delay: $scope.delayBusy, templateUrl: $scope.spinnerTpl}, connect()
- }]), angular.module("itysg.controllers").controller("LoadingDatasCtrl", ["$scope", "$http", "Core", "Echange", "$timeout", function ($scope, $http, Core, Echange, $timeout) {
- var keep_progress_faker = !0, progress_faker_percent = 0, progress_faker = function () {
- progress_faker_percent += 2, $scope.$emit("reportProgress", progress_faker_percent);
- var rnd_delay = 10 * (Math.floor(50 * Math.random()) + 10);
- keep_progress_faker && progress_faker_percent < 98 && $timeout(progress_faker, rnd_delay)
- }, loadData = function () {
- $scope.$emit("setTaskCount", 1), $scope.$emit("reportProgress", 0), $timeout(progress_faker, 200);
- var loadGlobalScenarioPromise;
- loadGlobalScenarioPromise = Core.offline ? Echange.loadGlobalScenarioOffline(Core.global_scenario_id) : Echange.loadGlobalScenario(Core.global_scenario_id, "", "", Core.lang, Core.user.key, "", Core.user.id, "html5"), loadGlobalScenarioPromise.then(function (datas) {
- $scope.onLoadSuccess(datas)
- }), $scope.busy.promise = loadGlobalScenarioPromise
- };
- $scope.onLoadSuccess = function (datas) {
- $scope.$emit("reportProgress", 100), keep_progress_faker = !1;
- try {
- console.log("load global scenario success");
- var datas_json;
- datas_json = Core.offline ? datas : JSON.parse(datas), Core.global_scenario = new SG.Model.GlobalScenario(datas_json.datas), $scope.$emit("setMenuEnabled", !0), $scope.$emit("showLoading", !1), $scope.goTo("phase")
- } catch (e) {
- var buttons = [];
- buttons.push({
- text: "Retour à ITyStudio", callback: function () {
- window.location.href = SG.core.base_url
- }
- }), $scope.$emit("showMessage", "Erreur", "Impossible de récupérer les données du jeu.<br/><br/>Détails : " + e.message, buttons)
- }
- }, $scope.onLoadError = function (error) {
- $scope.goTo("connection")
- }, $scope.busy = {message: Core.i18n.loading + " - 2/2", delay: $scope.delayBusy, templateUrl: $scope.spinnerTpl}, loadData()
- }]), angular.module("itysg.controllers").controller("PhaseCtrl", ["$rootScope", "$scope", "Core", "$interval", "$timeout", function ($rootScope, $scope, Core, $interval, $timeout) {
- var ROOT_STATE = "phase.";
- $scope.ROOT_STATE = ROOT_STATE, $scope.menu_is_display = !0, $scope.phase_name = "", $scope.act_stage_id, $scope.scenario_directive_ready = !1;
- var init = function () {
- $scope.$emit("setModuleName", Core.global_scenario.names[SG.core.lang]), Core.global_scenario.corner_logo ? $scope.$emit("setModuleLogo", Core.global_scenario.corner_logo) : $scope.$emit("setDefaultLogo"), $scope.copyLogoInPhase(), $scope.$emit("showOverlay", !0), $scope.current_phase = SG.phase_manager.getCurrentPhase(), $scope.sceneries = Core.global_scenario.sceneries;
- var phase_name = SG.phase_manager.getCurrentPhase().name, phase_is_scenario = "Scenario" === phase_name,
- scenario_directive_checker = $interval(function () {
- $scope.scenario_directive_ready && ($interval.cancel(scenario_directive_checker), $scope.$emit("scenarioIsReady", phase_is_scenario), "Scenario" == phase_name ? (displayScenario(!1, !1), $scope.goTo(ROOT_STATE + "CharacterSelection")) : (displayScenario(!1), $scope.$emit("setGamePaused", !0), $scope.goTo(ROOT_STATE + phase_name)))
- }, 250)
- };
- $scope.logoInPhase = !1, $scope.copyLogoInPhase = function () {
- $timeout(function () {
- if (0 == $scope.logoInPhase) {
- var phase_content = angular.element(document.getElementsByClassName("phase-content")),
- module_logo = angular.element(document.getElementsByClassName("module-logo"));
- phase_content.append(module_logo), $scope.logoInPhase = !0
- }
- })
- }, $scope.$on("characterSelection", function (e, stage_id) {
- displayScenario(!1, !1), $scope.act_stage_id = stage_id, $scope.goTo("phase.CharacterSelection")
- });
- var endGame = function () {
- SG.phase_manager.is_in_stage_phase = !1, SG.phase_manager.lastPhase(), $scope.current_phase = SG.phase_manager.getCurrentPhase(), displayScenario(!1), $scope.goTo(ROOT_STATE + "EndGame")
- }, nextPhase = function (stage_id, state) {
- var phase_name;
- SG.phase_manager.is_in_stage_phase = !1, void 0 == stage_id ? (SG.tracker.current_stage_id = -1, SG.phase_manager.nextPhase(), $scope.current_phase = SG.phase_manager.getCurrentPhase(), phase_name = SG.phase_manager.getCurrentPhase().name) : (SG.tracker.current_stage_id = stage_id, SG.phase_manager.is_in_stage_phase = !0, SG.game.nextStep(stage_id, state)), "undefined" == typeof phase_name || SG.phase_manager.is_in_stage_phase || ($scope.phase_name = phase_name, "Scenario" == phase_name ? ($scope.$emit("showOverlay", !1), displayScenario(!1, !1), $scope.goTo(ROOT_STATE + "CharacterSelection")) : (displayScenario(!1), $scope.$emit("setGamePaused", !0), $scope.goTo(ROOT_STATE + phase_name)))
- };
- $scope.$on("nextPhase", function (e, stage_id, state) {
- nextPhase(stage_id, state)
- }), $scope.$on("endGame", function (e) {
- endGame()
- }), $scope.$on("goToStagePhase", function (event, stage) {
- 1 == stage.paths.length && "" == stage.paths[0].short_descriptions[SG.core.lang] ? ($rootScope.target_stage_for_next_step = stage.paths[0].target, $rootScope.state_for_next_step = "default") : stage.paths.length > 0 ? ($rootScope.target_stage_for_next_step = -1, $rootScope.state_for_next_step = "display_proposition") : $rootScope.target_stage_for_next_step = void 0, $scope.current_phase = stage.phase_description, $scope.current_stage = stage;
- var phase_name = stage.type;
- $scope.$emit("setPauseEnabled", !("WebPhase" == phase_name)), $scope.goTo(ROOT_STATE + phase_name)
- }), $scope.$on("displayScenario", function (event, display, blur) {
- displayScenario(display, blur)
- });
- var displayScenario = function (scenario_is_display, blur) {
- $scope.displayScenario = scenario_is_display, void 0 !== blur ? $scope.blurScenario = blur : $scope.blurScenario = !scenario_is_display, scenario_is_display && $scope.$emit("startScenario")
- };
- $(document).keydown(function (e) {
- 80 == e.keyCode && e.altKey && e.ctrlKey && (e.preventDefault(), SG.game.phaser_game.paused = !SG.game.phaser_game.paused)
- }), $scope.scenario = {}, SG.tracker = new SG.Tracker(Core.global_scenario.criterions), SG.tracker.init(), $scope.scenario = SG.phase_manager.getNextScenarioPhase(), SG.phase_manager.start(), SG.phase_manager.preloadPhases(init)
- }]), angular.module("itysg.controllers").controller("popupCancelNextCtrl", ["$scope", "close", function ($scope, close) {
- $scope.close = function (result) {
- close(result, 500)
- }
- }]), angular.module("itysg.controllers").controller("MessageCtrl", ["$scope", "$rootScope", function ($scope, $rootScope) {
- }]), angular.module("itysg.services").service("Core", function () {
- return SG.core
- }), angular.module("itysg.services").service("Echange", function ($http, $q, $rootScope) {
- return {
- connection: function (login, password, key, uid, user_lang, from, client, globalscenario) {
- var deferred = $q.defer(), callData = JSON.stringify({
- serviceName: "itysg__Echanges",
- methodName: "connexionJson",
- parameters: [login, password, key, uid, user_lang, from, client, globalscenario]
- });
- return $.post(amfphp.entryPointUrl, callData, function (datas) {
- $rootScope.$apply(function () {
- deferred.resolve(datas)
- })
- }), deferred.promise
- }, connectionOffline: function () {
- var deferred = $q.defer();
- return $http.get("assets/script/connexion.json").success(function (datas) {
- console.log("CONNEXION OFFLINE SUCCESS"), deferred.resolve(datas)
- }).error(function (error) {
- console.log("CONNEXION OFFLINE ERROR"), deferred.reject(error)
- }), deferred.promise
- }, loadGlobalScenario: function (global_scenario_id, login, password, user_lang, conn_key, character_id, uid, client) {
- var deferred = $q.defer(), callData = JSON.stringify({
- serviceName: "itysg__Echanges",
- methodName: "loadGlobalScenarioJson",
- parameters: [global_scenario_id, login, password, user_lang, conn_key, character_id, uid, client]
- });
- return $.post(amfphp.entryPointUrl, callData, function (datas) {
- $rootScope.$apply(function () {
- deferred.resolve(datas)
- })
- }), deferred.promise
- }, loadGlobalScenarioOffline: function (global_scenario_id) {
- var deferred = $q.defer();
- return $http.get("assets/script/gb_scenario_" + global_scenario_id + ".json").success(function (datas) {
- deferred.resolve(datas)
- }).error(function (error) {
- deferred.reject(error)
- }), deferred.promise
- }
- }
- }), angular.module("itysg.services").service("CharacterSelectionService", function () {
- this.saved_characters = [], this.multipleCharactersAreDifferents = function (available_characters, type) {
- if (!this.saved_characters[type]) return this.saved_characters[type] = [], !0;
- if (0 == this.saved_characters[type].length) return !0;
- var different = !1;
- return angular.forEach(this.saved_characters[type], function (saved_characters_object) {
- "boolean" == typeof different && (different = !1, available_characters.ids.length != saved_characters_object.ids.length ? different = !0 : angular.forEach(saved_characters_object.ids, function (saved_character_id) {
- available_characters.ids.indexOf(saved_character_id) == -1 && (different = !0)
- }), 0 == different && (different = saved_characters_object))
- }), different
- }, this.addNewMultipleCharacterSelection = function (available_characters, selected_id, type) {
- var char_selected_object = {ids: [], selected_id: null};
- angular.forEach(available_characters.ids, function (char_id) {
- char_selected_object.ids.push(char_id)
- }), char_selected_object.selected_id = selected_id, this.saved_characters[type].push(char_selected_object)
- }
- }), angular.module("itysg.directives").directive("ityCriterionsPanel", ["Core", function (Core) {
- return {
- restrict: "E", controller: function ($scope, $timeout) {
- $scope.criterionsPanel = [], $scope.$on("onCriterionsChange", function (e, criterions_results) {
- Core.global_scenario.show_criterion_panel && criterions_results.length && ($scope.criterionsToDisplay = [], criterions_results.forEach(function (criterion_result) {
- var scoreToDisplay, criterion = SG.core.global_scenario.criterions[criterion_result.id];
- scoreToDisplay = criterion_result.value[0] > 0 ? "+" + criterion_result.value[0] : criterion_result.value[0];
- var textColor = $scope.determineColorText(criterion.color),
- critToDisplay = {name: criterion.name, score: scoreToDisplay, color: criterion.color, textColor: textColor};
- 0 != criterion_result.value[0] && $scope.criterionsToDisplay.push(critToDisplay)
- }), $scope.criterionsPanel.push($scope.criterionsToDisplay), $timeout(function () {
- $scope.criterionsPanel.splice(0, 1)
- }, 4e3))
- }), $scope.determineColorText = function (hex) {
- var black = "000000", white = "FFFFFF";
- if ("" == hex) return black;
- var color = {red: 0, green: 0, blue: 0}, bigint = parseInt(hex, 16);
- color.red = bigint >> 16 & 255, color.green = bigint >> 8 & 255, color.blue = 255 & bigint;
- for (var composantColor in color) color[composantColor] /= 255, color[composantColor] <= .03928 ? color[composantColor] /= 12.92 : color[composantColor] = Math.pow((color[composantColor] + .055) / 1.055, 2.4);
- var luminance = .2126 * color.red + .7152 * color.green + .0722 * color.blue, colorText = black;
- return luminance <= .179 && (colorText = white), colorText
- }
- }, link: function (scope, ele, attrs) {
- }, templateUrl: "templates/views/criterionsPanel.html"
- }
- }]), angular.module("itysg.directives").directive("ityMenu", ["$rootScope", "$animate", "ngDialog", function ($rootScope, $animate, ngDialog) {
- return {
- restrict: "E", controller: function ($scope) {
- $scope.menu_is_open = !1, $scope.menu_enable = !1, $scope.pause_enabled = !0, $scope.$on("setPauseEnabled", function (e, value) {
- $scope.pause_enabled = value
- }), $scope.$on("setMenuEnabled", function (e, value) {
- $scope.menu_enable = value
- })
- }, link: function (scope, ele, attrs) {
- scope.toggleMenu = function () {
- if (scope.title = SG.core.global_scenario.names.French, scope.menu_is_open = !scope.menu_is_open, $("ity-menu").toggleClass("big"), $("ity-menu").hasClass("big")) if (scope.$broadcast("setGamePaused", !0), scope.isIpad()) {
- var items = $("#menu-content .item");
- items.css({"margin-left": "0px"})
- } else {
- var items = ele.find("#menu-content .item");
- items.each(function (index) {
- var element = $(this);
- setTimeout(function () {
- element.animate({"margin-left": 0}, {
- duration: 200,
- specialEasing: {width: "easeInOutCubic", height: "easeInOutCubic"}
- })
- }, 200 / items.length * index)
- })
- } else {
- var items = $("#menu-content .item");
- items.css({"margin-left": "-250px"}), scope.$broadcast("setGamePaused", !1)
- }
- }, scope.toggleSubtitle = function () {
- scope.subtitle_are_enable = !scope.subtitle_are_enable
- }, scope.toggleSound = function () {
- scope.sound_is_mute = !scope.sound_is_mute, $rootScope.$broadcast("toggleSound", scope.sound_is_mute)
- }, scope.showInfo = function () {
- var scenarioInfo = SG.Core.getInstance()._global_scenario._global_scenario_json.lang[0];
- ngDialog.open({
- template: "templates/views/modals/module-information.html",
- data: {text: scope.i18n.menu.info, scenarioInfo: scenarioInfo, conceptor_name: scope.i18n.menu.conceptor_name},
- showClose: !1,
- className: "popup-module-info",
- closeByDocument: !1
- })
- }, scope.showTuto = function () {
- }, scope.goToMap = function () {
- var dialog = ngDialog.open({
- template: "templates/views/modals/popup-cancel-next.html",
- data: {text: scope.i18n.menu.go_to_map_msg},
- showClose: !1,
- closeByDocument: !1
- });
- dialog.closePromise.then(function (data) {
- if (data.value === !0) {
- var stage_map_id = 19426002;
- $rootScope.$broadcast("goToStage", stage_map_id), scope.menu_is_open = !scope.menu_is_open, scope.is_pause = scope.menu_is_open
- }
- })
- }, scope.logout = function () {
- }, scope.showResult = function () {
- ngDialog.open({
- template: "templates/views/modals/popup-confirm.html",
- data: {text: scope.i18n.results.warning},
- showClose: !1,
- className: "popup-confirm-resultat",
- closeByDocument: !1
- })
- }, scope.feedBack = function () {
- alert("a faire : fonction feedback")
- }, scope.isIpad = function () {
- var isiPad = null != navigator.userAgent.match(/iPad/i);
- return isiPad
- }
- }, templateUrl: "templates/views/menu.html"
- }
- }]), angular.module("itysg.directives").directive("ityScenario", function ($timeout) {
- return {
- restrict: "A", require: "ityPhase", link: function (scope, ele, attrs) {
- scope.scenario_directive_ready = !0, scope.$on("scenarioIsReady", function (event, start) {
- var sceneries = scope.$eval(attrs.sceneries);
- void 0 !== sceneries && null !== sceneries && void 0 !== scope.scenario && (SG.game = new SG.Game.GameController, $timeout(function () {
- SG.game.start(scope.scenario, sceneries, scope, start)
- }))
- }), scope.hasEndPopup = !1, scope.path = "", scope.gameIsFinished = !1, scope.hasPicture = !1, scope.hasText = !1, scope.$on("displayEndPopup", function (event, stage) {
- scope.hasEndPopup = !0, scope.hasProposition = 1 == stage.paths.length && "" === stage.paths[0].short_descriptions[SG.core.lang] || 0 == stage.paths.length, scope.gameIsFinished = 0 == stage.paths.length, scope.hasProposition && (scope.path = stage.paths[0]), stage._stage_bob_pictures[SG.core.lang] && (scope.hasPicture = !0, scope.picture = SG.core.medias_url + stage._stage_bob_pictures[SG.core.lang]), stage._transition_content[SG.core.lang] && (scope.hasText = !0, scope.text = stage._transition_content[SG.core.lang]), scope.$apply()
- }), scope.goToNextPhase = function () {
- 1 == scope.gameIsFinished ? SG.game.event_controller.endGame() : "" != scope.path && (SG.tracker.addPath(scope.path), scope.$emit("onCriterionsChange", scope.path.criterions_results), scope.$emit("nextPhase", scope.path.target, "default"), scope.$emit("hideEndPopup"))
- }, scope.$on("hideEndPopup", function (event) {
- scope.hasEndPopup = !1, scope.hasPicture = !1, scope.picture = "", scope.hasText = !1, scope.text = "", scope.path = "", scope.gameIsFinished = !1
- })
- }, templateUrl: "templates/views/phase/scenario.html"
- }
- }), angular.module("itysg.directives").directive("ityPhase", function () {
- return {
- restrict: "E", scope: {phase: "="}, controller: function ($scope) {
- $scope.current_phase = {}
- }, link: function (scope, elem, attr) {
- }
- }
- }), angular.module("itysg.directives").directive("ityBobspeech", function ($timeout) {
- var _scope, setPopupHeight = function () {
- $(".popup-context").removeClass("slide-left");
- var img = $(".bobspeech-img img"), globalHeight = $(window).height() - 140, popup = $(".popup-context"),
- imgContainer = $(".bobspeech-img"), textPadding = $(".row-wrap .content-wrap .top").height(),
- textHeight = $(".row-wrap .content-wrap .text")[0].scrollHeight + 2 * textPadding, row = $(".popup-context .row-wrap"),
- text = $(".popup-context .text"), player = $(".popup-context .audio-player");
- _scope.hasAudio && applyFlex(player, 65), img.height() + player.height() + textHeight <= globalHeight ? (applyFlex(imgContainer, img.height()), applyFlex(row, textHeight), applyFlex(text, textHeight), popup.height(img.height() + player.height() + textHeight)) : (img.height() <= globalHeight / 2 - player.height() / 2 ? (applyFlex(imgContainer, img.height()), applyFlex(row, globalHeight - img.height() - player.height()), applyFlex(text, globalHeight - img.height() - player.height())) : (applyFlex(imgContainer, globalHeight / 2 - player.height() / 2), applyFlex(row, globalHeight / 2 - player.height() / 2), applyFlex(text, globalHeight / 2 - player.height() / 2)), applyFlex($(".row-wrap .content-wrap .top"), 0), applyFlex($(".row-wrap .content-wrap .bottom"), 0), popup.height(globalHeight)), popup.height() % 2 == 1 && popup.height(popup.height() + 1)
- }, applyFlex = function (ele, value) {
- ele.css("flex", "0 0 " + value + "px")
- };
- return {
- restrict: "A", require: "ityPhase", controller: function ($rootScope, $scope, $element) {
- $scope.DEFAULT_PICTURE = "assets/images/bobfacesmall.png", $scope.text = "", $scope.sound = null, $scope.hasAudio = !1, $scope.notifyAudio = !1, $scope.canNext = !0, $scope.nextPhase = function () {
- $scope.canNext && ($(".popup-context").removeClass("slide-right"), $scope.sound && ($scope.sound.pause(), $scope.sound = null), $scope.canNext = !1, $(".popup-context").addClass("slide-left"), $timeout(function () {
- $(window).unbind("resize", setPopupHeight), $scope.$emit("nextPhase", $rootScope.target_stage_for_next_step, $rootScope.state_for_next_step)
- }, 300))
- }
- }, link: function (scope, ele, attrs) {
- if (_scope = scope, scope.text = scope.current_phase.text[SG.core.lang].value, "undefined" != typeof scope.current_phase.picture && (scope.picture = SG.core.medias_url + scope.current_phase.picture), scope.sound = scope.current_phase.sound, scope.sound) {
- scope.hasAudio = !0;
- var audioPlayer = new SG.Utils.AudioPlayer;
- audioPlayer.createPlayer(scope.sound, ele.find(".audio-player")), SG.Utils.mouse.supportsTouch ? scope.notifyAudio = !0 : audioPlayer.play(), scope.$on("toggleSound", function (e, muted) {
- scope.sound.muted = muted
- }), scope.$on("setGamePaused", function () {
- SG.game.phaser_game.paused ? audioPlayer.pause() : audioPlayer.play()
- })
- }
- var img = $(".bobspeech-img img");
- img.on("load", function () {
- setPopupHeight()
- }), $timeout(function () {
- scope.current_phase.picture || setPopupHeight(), scope.sound && (scope.sound.muted = SG.game.sound_muted), $(".popup-context").addClass("slide-right")
- }), $(window).resize(setPopupHeight)
- }, templateUrl: "templates/views/phase/bobspeech.html"
- }
- }), angular.module("itysg.directives").directive("ityKinematicphase", function ($rootScope, $timeout) {
- return {
- restrict: "A", require: "ityPhase", controller: function ($scope) {
- $scope.urlMP4 = $scope.current_phase.urlMP4, $scope.image = $scope.current_phase.image, console.log($scope.current_phase), $scope.nextPhase = function () {
- $scope.$emit("nextPhase", $rootScope.target_stage_for_next_step, $rootScope.state_for_next_step)
- }
- }, link: function (scope, ele, attrs) {
- var myVideo = null;
- $(document).on("mozfullscreenchange", function () {
- ele.find("#video-content").toggleClass("mozFullscreenFix")
- }), $timeout(function () {
- scope.urlMP4 && (myVideo = document.getElementById("video-content"), myVideo.muted = SG.game.sound_muted)
- }), scope.$on("nextPhase", function () {
- null != myVideo && (myVideo.remove(), myVideo = null)
- }), scope.$on("toggleSound", function (e, muted) {
- null != myVideo && (myVideo.muted = muted)
- }), scope.$on("setGamePaused", function () {
- null != myVideo && (SG.game.phaser_game.paused ? myVideo.pause() : myVideo.play())
- })
- }, templateUrl: "templates/views/phase/kinematicphase.html"
- }
- }), angular.module("itysg.directives").directive("ityWebphase", function ($sce) {
- return {
- restrict: "A", require: "ityPhase", controller: function ($rootScope, $scope, $sce, $timeout) {
- var FLASH_WIDTH = 980, FLASH_HEIGHT = 520;
- $scope.current_phase.type >= 0 && $scope.current_phase.type <= 1 ? $scope.url = $sce.trustAsResourceUrl($scope.current_phase.url) : $scope.current_phase.type >= 2 && $scope.current_phase.type <= 4 && ($scope.url = SG.core.base_url + $sce.trustAsResourceUrl($scope.current_phase.url)), $scope.style = "", $scope.current_phase.fullscreen ? ($scope.style += "left:0;", $scope.style += "top:0;", $scope.style += "width:100%;", $scope.style += "height:100%;") : ("left" == $scope.current_phase.position_enum[$scope.current_phase.position] ? $scope.style += "left:" + Math.floor($scope.current_phase.horizontal_align / FLASH_WIDTH * 100) + "%;" : "center" == $scope.current_phase.position_enum[$scope.current_phase.position] ? $scope.style += "left:50%;transform:translate(-50%);margin-left:" + Math.floor($scope.current_phase.horizontal_align / FLASH_WIDTH * 100) + "%;" : $scope.style += "right:" + Math.floor($scope.current_phase.horizontal_align / FLASH_WIDTH * 100) + "%;", $scope.style += "top:" + Math.floor($scope.current_phase.vertical_align / FLASH_HEIGHT * 100) + "%;", $scope.style += "width:" + Math.floor($scope.current_phase.width / FLASH_WIDTH * 100) + "%;", $scope.style += "height:" + Math.floor($scope.current_phase.height / FLASH_HEIGHT * 100) + "%;"), $scope.nextPhase = function () {
- $scope.url = null, disableCommunicationAPI(), $scope.$emit("nextPhase", $rootScope.target_stage_for_next_step, $rootScope.state_for_next_step)
- }, $timeout(function () {
- $(".web-wrap .close-wrap").attr("style", $scope.style)
- })
- }, link: function (scope, ele, attrs) {
- enableCommunicationAPI(scope.current_phase.url), $(".close").click(function () {
- $(".close").fadeOut()
- })
- }, templateUrl: "templates/views/phase/webphase.html"
- }
- }), angular.module("itysg.directives").directive("ityCharacterSelection", ["CharacterSelectionService", "$timeout", "$interval", function (CharacterSelectionService, $timeout, $interval) {
- return {
- restrict: "A", require: "ityPhase", controller: function ($scope, $element) {
- var scenary_checker, act_checker, checker_rate = 250;
- $scope.type = "", $scope.characters = [], $scope.character_types = {}, $scope.$emit("setGamePaused", !1), $scope.$emit("setTotalTasks", 2), $scope.$emit("setTaskCount", 0), $scope.$emit("showLoading", !0), $scope.$emit("reportProgress", 0), $scope.getCharacters = function (type) {
- if ($scope.type = type, $scope.character_types[type].ids.length > 1) {
- var already_selected = CharacterSelectionService.multipleCharactersAreDifferents($scope.character_types[type], type);
- if ("object" == typeof already_selected) return void $scope.selectCharacter(already_selected.selected_id, type);
- $scope.$emit("readyToShow", !0), $scope.resize(), SG.game.phaser_game.state.states.ScenarioEngine.drawCustomBg("character_selection"), console.log("-- Multiple characters available");
- for (var i in $scope.character_types[type].ids) {
- var character = SG.core.getCharacterById($scope.character_types[type].ids[i]);
- $scope.characters[i] = {}, $scope.characters[i].id = character.id, "npc" == type ? character.not_playables[SG.core.lang] ? $scope.characters[i].img = SG.core.base_url + "/ressources/medias/users_preview/preview_u" + character.id + "_h" + character.not_playables[SG.core.lang].char.cloth_id + ".png" : $scope.characters[i].img = SG.core.base_url + "/ressources/medias/users_preview/preview_u6_h0.png" : character.playables[SG.core.lang] ? $scope.characters[i].img = SG.core.base_url + "/ressources/medias/users_preview/preview_u" + character.id + "_h" + character.playables[SG.core.lang].cloth_id + ".png" : $scope.characters[i].img = SG.core.base_url + "/ressources/medias/users_preview/preview_u6_h0.png"
- }
- } else $scope.selectCharacter($scope.character_types[type].ids[0], type)
- }, $scope.selectCharacter = function (id, type) {
- $scope.character_types[type].ids.length > 1 && (0 != CharacterSelectionService.saved_characters[type].length && 1 != CharacterSelectionService.multipleCharactersAreDifferents($scope.character_types[type], type) || CharacterSelectionService.addNewMultipleCharacterSelection($scope.character_types[type], id, type));
- var type_not_set;
- $scope.character_types[type].is_set = !0, SG.game[$scope.character_types[type].key] = SG.core.getCharacterById(id);
- for (var char_type in $scope.character_types) if (!$scope.character_types[char_type].is_set) {
- type_not_set = char_type;
- break
- }
- type_not_set ? $scope.getCharacters(type_not_set) : ($scope.$emit("setGamePaused", !1), $scope.$emit("showLoading", !0), SG.game.phaser_game.state.start("PreloadAct"), act_checker = $interval(function () {
- SG.game.act_loaded && (SG.game.game_ready = !0, $interval.cancel(act_checker), $scope.$emit("readyToShow", !0), $scope.$emit("showLoading", !1), $scope.act_stage_id ? $scope.$emit("nextPhase", $scope.act_stage_id) : ($scope.$emit("displayScenario", !0), $scope.goTo($scope.ROOT_STATE + "Scenario")))
- }, checker_rate))
- }, SG.game.player.moves = [], SG.game.not_player.moves = [], scenary_checker = $interval(function () {
- if (SG.game.scenary_loaded) {
- $scope.$emit("setTaskCount", 1), $scope.$emit("reportProgress", 0), $scope.$emit("showLoading", !1);
- var act = SG.game.act;
- $scope.character_types = {
- pc: {
- is_set: !1,
- ids: act.playable_character_ids,
- key: "player",
- title: SG.core.i18n.choose_avatar
- }, npc: {is_set: !1, ids: act.not_playable_characters_ids, key: "not_player", title: SG.core.i18n.choose_meet}
- };
- for (var i in $scope.character_types) {
- var temp = $scope.character_types[i].ids.slice();
- $scope.character_types[i].ids = temp.filter(function (item, pos, self) {
- return self.indexOf(item) == pos
- })
- }
- $interval.cancel(scenary_checker), $scope.$emit("setGamePaused", !0), $scope.getCharacters("pc")
- }
- }, checker_rate), $scope.resize = function () {
- console.log("resize");
- var offset = SG.game.getGameOffset(), el = $element.find(".character-screen");
- el.offset({left: offset.x}), el.width(offset.width), el.height(offset.height)
- }, $(window).resize($scope.resize)
- }, link: function (scope, ele, attrs) {
- }, templateUrl: "templates/views/phase/characterSelection.html"
- }
- }]), angular.module("itysg.directives").directive("ityQuizzBase", function ($timeout, $compile) {
- var detectIE = function () {
- var ua = window.navigator.userAgent, msie = ua.indexOf("MSIE "), trident = ua.indexOf("Trident/"), edge = ua.indexOf("Edge/");
- return msie > 0 || trident > 0 || edge > 0
- }, isChromium = window.chrome, winNav = window.navigator, vendorName = winNav.vendor, isOpera = winNav.userAgent.indexOf("OPR") > -1,
- isIEedge = winNav.userAgent.indexOf("Edge") > -1, setPopupHeight = (winNav.userAgent.match("CriOS"), function () {
- var globalHeight = $(window).height() - 140, extra = 2, min = 150, popup = $(".quizz-wrapper"), reponse_wrap = $(".reponse-wrap"),
- question_wrap = $(".question"), question_wrap_height = question_wrap[0].scrollHeight, top_wrap = $(".top"),
- top_wrap_height = top_wrap[0].scrollHeight, reponse_content = $(".reponse-content"),
- reponse_content_height = reponse_content[0].scrollHeight;
- detectIE() && (question_wrap_height = question_wrap.height(), top_wrap_height = top_wrap.height());
- var question_wrap_outer_height = question_wrap.outerHeight(), top_wrap_outer_height = top_wrap.outerHeight();
- if (null !== isChromium && void 0 !== isChromium && "Google Inc." === vendorName && 0 == isOpera && 0 == isIEedge) var reponse_content_outer_height = reponse_content.outerHeight(!0); else var reponse_content_outer_height = reponse_content_height + 50;
- question_wrap_outer_height + top_wrap_outer_height + reponse_content_outer_height < min ? (applyFlex(reponse_wrap, min - question_wrap_outer_height - top_wrap_outer_height), popup.height(min)) : question_wrap_outer_height + top_wrap_outer_height + reponse_content_outer_height < globalHeight ? (applyFlex(reponse_wrap, reponse_content_outer_height + extra), popup.height(question_wrap_outer_height + top_wrap_outer_height + reponse_content_outer_height + extra)) : (applyFlex(reponse_wrap, globalHeight - question_wrap_outer_height - top_wrap_outer_height), popup.height(globalHeight)), applyFlex(question_wrap, question_wrap_height), applyFlex(top_wrap, top_wrap_height)
- }), applyFlex = function (ele, value) {
- ele.css("flex", "0 1 " + value + "px")
- };
- return {
- restrict: "A", require: "ityPhase", controller: function ($rootScope, $scope, $element) {
- $scope.name = "", $scope.index = -1, $scope.question = {}, $scope.previousAvailable = !1, $scope.nextAvailable = !0, $scope.count = Object.keys($scope.current_phase.questions).length, $scope.canSwitch = !0, $scope.canUpdate = !0, $scope.types = {
- 1: "ity-quizz-input-answer-directive",
- 2: "ity-quizz-single-choice-directive",
- 4: "ity-quizz-drop-down-directive",
- 5: "ity-quizz-multi-choice-directive",
- 6: "ity-quizz-slider-directive"
- }, $scope.$on("setPopupHeight", function () {
- setPopupHeight()
- }), $scope.nextQuestion = function () {
- if ($scope.nextAvailable) if ($scope.canSwitch) {
- $scope.index++, $scope.updateQuestion();
- var ele = $compile("<" + $scope.types[$scope.question.type.id] + "></" + $scope.types[$scope.question.type.id] + ">")($scope);
- $element.find(".reponse-content").html("").append(ele)
- } else $scope.$broadcast("showCorrection"), $scope.canUpdate = !1, $scope.canSwitch = !0; else $scope.nextPhase()
- }, $scope.previousQuestion = function () {
- $scope.index--, $scope.updateQuestion()
- }, $scope.updateQuestion = function () {
- $scope.nextAvailable = $scope.index + 1 in $scope.current_phase.questions, $scope.previousAvailable = $scope.index - 1 in $scope.current_phase.questions && $scope.current_phase.free && !$scope.current_phase.correction, $scope.question = $scope.current_phase.questions[$scope.index], $scope.canUpdate = !0, $scope.current_phase.correction && ($scope.canSwitch = !1)
- }, $scope.checkIsGoodAnswer = function (question) {
- var isCorrect = !0;
- for (var j in question.answers) if (question.answers[j].correct != question.answers[j].user_check) {
- isCorrect = !1;
- break
- }
- return isCorrect
- }, $scope.nextPhase = function () {
- if ($scope.canSwitch) {
- var correctAnswer = !1;
- angular.forEach($scope.current_phase.questions, function (question) {
- if (correctAnswer = $scope.checkIsGoodAnswer(question)) {
- for (var k in question.right_criterions) SG.tracker.setCriterionValue(question.right_criterions[k]);
- $scope.$emit("onCriterionsChange", question.right_criterions)
- } else {
- for (var k in question.wrong_criterions) SG.tracker.setCriterionValue(question.wrong_criterions[k]);
- $scope.$emit("onCriterionsChange", question.wrong_criterions);
- }
- }), $timeout(function () {
- $scope.canUpdate = !0, $(".quizz-wrapper").removeClass("slide-right"), $(".quizz-wrapper").addClass("slide-left"), $(window).unbind("resize", setPopupHeight), $scope.$emit("nextPhase", $rootScope.target_stage_for_next_step, $rootScope.state_for_next_step)
- }, 300)
- } else $scope.$broadcast("showCorrection"), $scope.canSwitch = !0, $scope.canUpdate = !1
- };
- var correctAnswer = !1;
- angular.forEach($scope.current_phase._questions, function (question) {
- correctAnswer = $scope.checkIsGoodAnswer(question), correctAnswer && angular.forEach(question.right_criterions, function (criterion) {
- var right_criterion = angular.copy(criterion);
- right_criterion._value[0] = right_criterion._value[0] * -1, SG.tracker.setCriterionValue(right_criterion)
- }), angular.forEach(question._answers, function (answer) {
- console.log(answer), answer._user_check = !1, answer._user_value = ""
- })
- }), 0 == $scope.count ? ($(window).unbind("resize", setPopupHeight), $scope.$emit("nextPhase", $rootScope.target_stage_for_next_step, $rootScope.state_for_next_step)) : $scope.nextQuestion()
- }, link: function (scope, ele, attrs) {
- scope.name = scope.current_phase.quizzname, $timeout(function () {
- $(window).resize(setPopupHeight), $(".quizz-wrapper").addClass("slide-right")
- })
- }, templateUrl: "templates/views/phase/quizz/quizzBase.html"
- }
- }), angular.module("itysg.directives").directive("ityQuizzInputAnswerDirective", function ($timeout) {
- var detectIE = function () {
- var ua = window.navigator.userAgent, msie = ua.indexOf("MSIE "), trident = ua.indexOf("Trident/"), edge = ua.indexOf("Edge/");
- return msie > 0 || trident > 0 || edge > 0
- }, isChromium = window.chrome, winNav = window.navigator, vendorName = winNav.vendor, isOpera = winNav.userAgent.indexOf("OPR") > -1,
- isIEedge = winNav.userAgent.indexOf("Edge") > -1, setPopupHeight = (winNav.userAgent.match("CriOS"), function () {
- var globalHeight = $(window).height() - 140, extra = 2, min = 150, popup = $(".quizz-wrapper"), reponse_wrap = $(".reponse-wrap"),
- question_wrap = $(".question"), question_wrap_height = question_wrap[0].scrollHeight, top_wrap = $(".top"),
- top_wrap_height = top_wrap[0].scrollHeight, reponse_content = $(".reponse-content"),
- reponse_content_height = reponse_content[0].scrollHeight;
- detectIE() && (question_wrap_height = question_wrap.height(), top_wrap_height = top_wrap.height());
- var question_wrap_outer_height = question_wrap.outerHeight(), top_wrap_outer_height = top_wrap.outerHeight();
- if (null !== isChromium && void 0 !== isChromium && "Google Inc." === vendorName && 0 == isOpera && 0 == isIEedge) var reponse_content_outer_height = reponse_content.outerHeight(!0); else var reponse_content_outer_height = reponse_content_height + 50;
- question_wrap_outer_height + top_wrap_outer_height + reponse_content_outer_height < min ? (applyFlex(reponse_wrap, min - question_wrap_outer_height - top_wrap_outer_height), popup.height(min)) : question_wrap_outer_height + top_wrap_outer_height + reponse_content_outer_height < globalHeight ? (applyFlex(reponse_wrap, reponse_content_outer_height + extra), popup.height(question_wrap_outer_height + top_wrap_outer_height + reponse_content_outer_height + extra)) : (applyFlex(reponse_wrap, globalHeight - question_wrap_outer_height - top_wrap_outer_height), popup.height(globalHeight)), applyFlex(question_wrap, question_wrap_height), applyFlex(top_wrap, top_wrap_height)
- }), applyFlex = function (ele, value) {
- ele.css("flex", "0 1 " + value + "px")
- };
- return {
- restrict: "E", controller: function ($scope, $element) {
- var right_icon = '<img src="assets/images/done.svg" class="icon-check" alt="icon"/>',
- wrong_icon = '<img src="assets/images/clear.svg" class="icon-clear" alt="icon"/>',
- corrector = new RegExp("\\b" + $scope.question.answers[0].text + "\\b", "i");
- $scope.isCorrect = function () {
- $scope.canUpdate && ($scope.question.answers[0].user_check = corrector.test($scope.question.answers[0].user_value))
- }, $scope.$on("showCorrection", function () {
- $element.find("#user-input").hide(), $scope.question.answers[0].user_check != $scope.question.answers[0].correct ? "" == $scope.question.answers[0].user_value ? $scope.correction = "<p>" + wrong_icon + "aucune réponse</p><p>" + right_icon + $scope.question.answers[0].text + "</p>" : $scope.correction = "<p class='wrong'>" + wrong_icon + $scope.question.answers[0].user_value + "</p><p>" + right_icon + $scope.question.answers[0].text + "</p>" : $scope.correction = "<p class='right'>" + right_icon + $scope.question.answers[0].user_value + "</p>", $timeout(setPopupHeight)
- })
- }, link: function (scope, ele, attrs) {
- $timeout(function () {
- scope.$emit("setPopupHeight")
- })
- }, templateUrl: "templates/views/phase/quizz/quizzInputAnswer.html"
- }
- }), angular.module("itysg.directives").directive("ityQuizzMultiChoiceDirective", function ($timeout) {
- return {
- restrict: "E", controller: function ($scope, $element) {
- $scope.idList = {}, $scope.check = function () {
- if ($scope.canUpdate) for (var i in $scope.question.answers) $scope.question.answers[i].id in $scope.idList && ($scope.question.answers[i].user_check = $scope.idList[$scope.question.answers[i].id])
- }, $scope.$on("showCorrection", function () {
- for (var i in $scope.question.answers) 1 == $scope.question.answers[i].user_check ? 1 == $scope.question.answers[i].correct ? $element.find("#answer" + $scope.question.answers[i].id).addClass("right") : $element.find("#answer" + $scope.question.answers[i].id).addClass("wrong") : 1 == $scope.question.answers[i].correct ? $element.find("#answer" + $scope.question.answers[i].id).addClass("missRight") : $element.find("#answer" + $scope.question.answers[i].id).remove();
- $(".reponse-wrap md-checkbox.right .icon-check").css("display", "inline-block"), $(".reponse-wrap md-checkbox.wrong .icon-clear").css("display", "inline-block"), $(".reponse-wrap md-checkbox.missRight .icon-check").css("display", "inline-block"), $scope.$emit("setPopupHeight")
- });
- var init = function () {
- for (var i in $scope.question.answers) $scope.idList[$scope.question.answers[i].id] = $scope.question.answers[i].user_check
- };
- init()
- }, link: function (scope, ele, attrs) {
- $timeout(function () {
- scope.$emit("setPopupHeight")
- })
- }, templateUrl: "templates/views/phase/quizz/quizzMultiChoice.html"
- }
- }), angular.module("itysg.directives").directive("ityQuizzSingleChoiceDirective", function ($timeout) {
- return {
- restrict: "E", controller: function ($scope, $element) {
- $scope.selectedId = -1, $scope.check = function () {
- if ($scope.canUpdate) for (var i in $scope.question.answers) $scope.question.answers[i].user_check = $scope.selectedId == $scope.question.answers[i].id
- }, $scope.$on("showCorrection", function () {
- for (var i in $scope.question.answers) 1 == $scope.question.answers[i].user_check ? 1 == $scope.question.answers[i].correct ? $element.find("#answer" + $scope.question.answers[i].id).addClass("right") : $element.find("#answer" + $scope.question.answers[i].id).addClass("wrong") : 1 == $scope.question.answers[i].correct ? $element.find("#answer" + $scope.question.answers[i].id).addClass("missRight") : $element.find("#answer" + $scope.question.answers[i].id).remove();
- $(".reponse-wrap md-radio-button.right .icon-check").css("display", "inline-block"), $(".reponse-wrap md-radio-button.wrong .icon-clear").css("display", "inline-block"), $(".reponse-wrap md-radio-button.missRight .icon-check").css("display", "inline-block"), $scope.$emit("setPopupHeight")
- });
- var init = function () {
- for (var i in $scope.question.answers) $scope.question.answers[i].user_check && ($scope.selectedId = $scope.question.answers[i].id)
- };
- init()
- }, link: function (scope, ele, attrs) {
- $timeout(function () {
- scope.$emit("setPopupHeight")
- })
- }, templateUrl: "templates/views/phase/quizz/quizzSingleChoice.html"
- }
- }), angular.module("itysg.directives").directive("ityQuizzDropDownDirective", function ($timeout) {
- var detectIE = function () {
- var ua = window.navigator.userAgent, msie = ua.indexOf("MSIE "), trident = ua.indexOf("Trident/"), edge = ua.indexOf("Edge/");
- return msie > 0 || trident > 0 || edge > 0
- }, isChromium = window.chrome, winNav = window.navigator, vendorName = winNav.vendor, isOpera = winNav.userAgent.indexOf("OPR") > -1,
- isIEedge = winNav.userAgent.indexOf("Edge") > -1, setPopupHeight = (winNav.userAgent.match("CriOS"), function () {
- var globalHeight = $(window).height() - 140, extra = 2, min = 150, popup = $(".quizz-wrapper"), reponse_wrap = $(".reponse-wrap"),
- question_wrap = $(".question"), question_wrap_height = question_wrap[0].scrollHeight, top_wrap = $(".top"),
- top_wrap_height = top_wrap[0].scrollHeight, reponse_content = $(".reponse-content"),
- reponse_content_height = reponse_content[0].scrollHeight;
- detectIE() && (question_wrap_height = question_wrap.height(), top_wrap_height = top_wrap.height());
- var question_wrap_outer_height = question_wrap.outerHeight(), top_wrap_outer_height = top_wrap.outerHeight();
- if (null !== isChromium && void 0 !== isChromium && "Google Inc." === vendorName && 0 == isOpera && 0 == isIEedge) var reponse_content_outer_height = reponse_content.outerHeight(!0); else var reponse_content_outer_height = reponse_content_height + 50;
- question_wrap_outer_height + top_wrap_outer_height + reponse_content_outer_height < min ? (applyFlex(reponse_wrap, min - question_wrap_outer_height - top_wrap_outer_height), popup.height(min)) : question_wrap_outer_height + top_wrap_outer_height + reponse_content_outer_height < globalHeight ? (applyFlex(reponse_wrap, reponse_content_outer_height + extra), popup.height(question_wrap_outer_height + top_wrap_outer_height + reponse_content_outer_height + extra)) : (applyFlex(reponse_wrap, globalHeight - question_wrap_outer_height - top_wrap_outer_height), popup.height(globalHeight)), applyFlex(question_wrap, question_wrap_height), applyFlex(top_wrap, top_wrap_height)
- }), applyFlex = function (ele, value) {
- ele.css("flex", "0 1 " + value + "px")
- };
- return {
- restrict: "E", controller: function ($scope, $element) {
- $scope.selectedId = -1, $scope.correct = !0;
- var right_icon = '<img src="assets/images/done.svg" class="icon-check" alt="icon"/>',
- wrong_icon = '<img src="assets/images/clear.svg" class="icon-clear" alt="icon"/>';
- $scope.check = function () {
- if ($scope.canUpdate) for (var i in $scope.question.answers) $scope.question.answers[i].user_check = $scope.selectedId == $scope.question.answers[i].id
- }, $scope.$on("showCorrection", function () {
- var correction = "";
- for (var i in $scope.question.answers) $scope.question.answers[i].user_check != $scope.question.answers[i].correct && ($scope.correct = !1), $scope.question.answers[i].correct && (correction = $scope.question.answers[i].text);
- if ($element.find("#drop-down").hide(), $scope.correct) $scope.correction = "<p class='right'>" + right_icon + correction + "</p>"; else if ($scope.selectedId < 0) $scope.correction = "<p>" + wrong_icon + "aucune réponse</p><p>" + right_icon + correction + "</p>"; else for (var i in $scope.question.answers) if ($scope.question.answers[i].id == $scope.selectedId) {
- $scope.correction = "<p class='wrong'>" + wrong_icon + $scope.question.answers[i].text + "</p><p>" + right_icon + correction + "</p>";
- break
- }
- $timeout(setPopupHeight)
- });
- var init = function () {
- for (var i in $scope.question.answers) $scope.question.answers[i].user_check && ($scope.selectedId = $scope.question.answers[i].id)
- };
- init()
- }, link: function (scope, ele, attrs) {
- $timeout(function () {
- scope.$emit("setPopupHeight")
- })
- }, templateUrl: "templates/views/phase/quizz/quizzDropDown.html"
- }
- }), angular.module("itysg.directives").directive("ityQuizzSliderDirective", function ($timeout) {
- return {
- restrict: "E", controller: function ($scope, $element) {
- $scope.max = 0, $scope.min = 0, $scope.ok = 0;
- var props = $scope.question.answers[0].text.split(",");
- for (var i in props) {
- var prop = props[i].split(":");
- $scope[prop[0].toLowerCase()] = parseInt(prop[1])
- }
- $scope.isCorrect = function () {
- $scope.canUpdate && ($scope.question.answers[0].user_check = $scope.ok == $scope.question.answers[0].user_value)
- }, $scope.$on("showCorrection", function () {
- $element.find("._md-slider-wrapper").unbind("mousedown").unbind("keydown").unbind("focus").unbind("blur").unbind("$md"), $element.find("md-slider").addClass("_md-active"), $scope.question.answers[0].user_check != $scope.question.answers[0].correct && ($scope.question.answers[0].user_value = $scope.ok, $element.find("._md-slider-content").append($element.find("._md-thumb-container").clone().attr("id", "wrongBubble")))
- })
- }, link: function (scope, ele, attrs) {
- $timeout(function () {
- scope.$emit("setPopupHeight")
- })
- }, templateUrl: "templates/views/phase/quizz/quizzSlider.html"
- }
- }), angular.module("itysg.directives").directive("ityEndGame", function ($timeout) {
- return {
- restrict: "A", require: "ityPhase", controller: function ($scope, $modal) {
- $scope.criterionLength = SG.core.global_scenario._criterions_json.length
- }, link: function (scope, ele, attrs) {
- scope.messages = {
- end_game_message: SG.core.i18n.endgame.scenario_end_reached,
- access_result: SG.core.i18n.endgame.access_result,
- display_access_result: !0
- }, 0 == SG.tracker.getNumberOfCriterion() && (scope.messages.display_access_result = !1, scope.current_phase.param && scope.current_phase.param.hideMessageIfNoCriterions && (scope.messages.end_game_message += "<br/>" + SG.core.i18n.endgame.no_criterions));
- var general_score = isNaN(SG.tracker.getGeneralScore()) || void 0 === SG.tracker.getGeneralScore() ? 0 : SG.tracker.getGeneralScore();
- "undefined" != typeof scope.current_phase.custom_message && null !== scope.current_phase.custom_message && "" !== scope.current_phase.custom_message && (scope.current_phase.custom_message.replace("{score}", general_score), scope.messages.end_game_message = scope.current_phase.custom_message), SG.tracker.endGame(), scope.showResults = function () {
- var global_scenario = SG.core.global_scenario, tracker = SG.tracker, criterions = SG.tracker.criterions, datas = {},
- index = 0, scores = SG.tracker.score;
- for (var i in criterions) datas[i] = {}, datas[i].id = criterions[i].id, datas[i].name = criterions[i].name, datas[i].criterionDescription = global_scenario._criterions_json[index].descriptions[0].description, datas[i].criterionComments = global_scenario._criterions_json[index].comments_by_score, void 0 != scores[i] ? datas[i].score = tracker.getCurrentPercentageForCriterionId(datas[i].id) : datas[i].score = 0, index++;
- sessionStorage.setItem("datas", JSON.stringify(datas)), sessionStorage.setItem("tracker", JSON.stringify(SG.tracker)), sessionStorage.setItem("global_scenario", JSON.stringify(SG.core.global_scenario)), sessionStorage.setItem("engine", "html5"), sessionStorage.setItem("lang", SG.core.lang), sessionStorage.setItem("scenarioName", JSON.stringify(SG.core.global_scenario.names[SG.core.lang])), sessionStorage.setItem("criterionLength", JSON.stringify(scope.criterionLength)), window.location.href = "results/resultat.html"
- }, $timeout(function () {
- scope.criterionLength >= 1 && 1 == SG.core.export_results ? $timeout(scope.showResults, 1e3) : $(".endgame p").text("")
- })
- }, templateUrl: "templates/views/phase/endgame.html"
- }
- }), angular.module("itysg.directives").directive("ityProposition", function () {
- return {
- restrict: "E", controller: function ($scope, $timeout, $element) {
- $scope.displayProposition = !0, $scope.paths = [], $scope.stage_type_base = "", $scope.isCallByNextStep = !1, $scope.replay = function () {
- "" != $scope.stage_type_base && (SG.game.current_stage.type = $scope.stage_type_base), $scope.$emit("nextPhase", $scope.current_stage.id, "replay"), $scope.$emit("hideEndPopup"), $scope.paths = [], $scope.hideList()
- }, $scope.expand = function (e) {
- console.log($scope.current_stage);
- var more = $(e.currentTarget), item = more.parent().parent(), less = item.find(".less"), text = item.find(".text");
- more.addClass("closed"), less.addClass("opened"), more.data("expanded", "true"), item.animate({height: text[0].scrollHeight + 50}, 200)
- }, $scope.collapse = function (e) {
- var less = $(e.currentTarget), item = less.parent(), more = item.find(".more");
- item.find(".text");
- more.removeClass("closed"), less.removeClass("opened"), more.data("expanded", "false"), item.animate({height: 100}, 200)
- }, $scope.showList = function () {
- $element.stop(!0, !1).animate({left: "0"}, {
- duration: 300,
- specialEasing: {width: "easeInOutCubic", height: "easeInOutCubic"}
- })
- }, $scope.hideList = function () {
- $element.animate({left: "50%"}, {duration: 300, specialEasing: {width: "easeInOutCubic", height: "easeInOutCubic"}})
- }, $scope.$on("displayProposition", function (event, stage, hide, isNextStep, stage_type) {
- isNextStep && ($scope.isCallByNextStep = !0, $scope.stage_type_base = stage_type);
- var propositions_list;
- return stage.paths ? ($scope.current_stage = stage, propositions_list = stage.paths) : propositions_list = [], hide === !0 ? ($scope.paths = [], $scope.hideList(), null) : ($scope.showList(), void $scope.$apply(function () {
- var memory_effect = new SG.Game.MemoryEffect, propositions_to_display = propositions_list.slice(0),
- proposition_to_remove = [];
- propositions_to_display.forEach(function (proposition, index, object) {
- checkStageIsAlreadyPlayed(proposition), memory_effect.executePropositionMemoryEffect(proposition), proposition.is_display && "interactive_link_to" != proposition.type || proposition_to_remove.push(proposition)
- }), propositions_to_display = $(propositions_to_display).not(proposition_to_remove).get(), propositions_to_display.length > 0 ? (propositions_to_display[0].order > 0 ? propositions_to_display.sort(function (p1, p2) {
- return p1.order - p2.order
- }) : propositions_to_display.sort(function (p1, p2) {
- return .5 - Math.random()
- }), $scope.paths = propositions_to_display, $scope.lang = SG.core.lang, console.log(propositions_to_display), SG.core.debug_mode && propositions_to_display.forEach(function (path) {
- var message_to_concat = "[ ";
- path.criterions_results.forEach(function (criterion_result) {
- message_to_concat += " c : " + criterion_result.id + " value : " + criterion_result.value[0]
- }), message_to_concat += " ]", console.log(path), path.short_descriptions[SG.core.lang] += message_to_concat
- }), $scope.animation = !0, $timeout(function () {
- var items = $element.find(".list .item");
- items.each(function (index) {
- var element = $(this);
- setTimeout(function () {
- element.animate({"margin-left": 0, opacity: 1}, {
- duration: 200,
- specialEasing: {width: "easeInOutCubic", height: "easeInOutCubic"}
- })
- }, 40 * index)
- })
- })) : $scope.$emit("goToStage", -1)
- }))
- }), $scope.goToStage = function (path) {
- $scope.isCallByNextStep && (SG.game.current_stage.type = $scope.stage_type_base, $scope.stage_type_base = "", $scope.isCallByNextStep = !1), SG.tracker.addPath(path), $scope.$emit("nextPhase", path.target, "default"), $scope.$emit("hideEndPopup"), $scope.paths = [], $scope.hideList()
- };
- var checkStageIsAlreadyPlayed = function (stage_path) {
- var stage_id = stage_path.target, display_path = !0;
- if (SG.tracker.stages.indexOf(stage_id) >= 0) {
- var stage = SG.game.scenario.getStageById(stage_id);
- display_path = stage.back_later_enabled
- }
- stage_path.is_display = display_path
- }
- }, link: function (scope, ele, attrs) {
- }, templateUrl: "templates/views/phase/proposition.html"
- }
- }), angular.module("itysg.directives").directive("itySubtitle", function () {
- return {
- restrict: "E", controller: function ($scope) {
- $scope.subtitle_text = "", $scope.subtitle_displayed = !1, $scope.margin = 100, $scope.realWidth = 0, $scope.fontRatio = 1, $scope.fontSize = 1.5, $scope.minRatio = .8, $scope.$on("displaySubtitle", function (event, subtitle, name) {
- $scope.$apply(function () {
- subtitle ? (0 == SG.core.global_scenario.display_name_in_subtitle ? name = "" : name += " : ", $scope.subtitle_text = name + '" ' + subtitle + ' "') : $scope.subtitle_text = "", $scope.subtitle_displayed = "" !== $scope.subtitle_text
- });
- var resize = function () {
- var offset = SG.game.getGameOffset(), subtitle = $(".subtitle");
- subtitle.css("bottom", offset.y + "px"), subtitle.css("white-space", "nowrap"), subtitle.css("width", "auto"), subtitle.css("font-size", $scope.fontSize + "em"), $scope.realWidth = subtitle.outerWidth(), $scope.realWidth > offset.width - 2 * $scope.margin && ($scope.fontRatio = (offset.width - 2 * $scope.margin) / $scope.realWidth, $scope.fontRatio >= $scope.minRatio ? subtitle.css("font-size", $scope.fontSize * $scope.fontRatio + "em") : subtitle.css("font-size", $scope.fontSize * $scope.minRatio + "em"), subtitle.css("white-space", "normal"), subtitle.css("width", offset.width - 2 * $scope.margin + "px"))
- };
- resize(), $(window).resize(resize)
- })
- }, link: function (scope, ele, attrs) {
- }, templateUrl: "templates/views/phase/scenario/subtitle.html"
- }
- }), angular.module("itysg.directives").directive("ityNotification", function () {
- return {
- restrict: "E", controller: function ($scope) {
- $scope.notification_title = "", $scope.notification_text = "", $scope.notification_displayed = !1, $scope.$on("displayNotification", function (event, title, text) {
- $scope.notification_displayed = !0, title && text ? ($scope.notification_title = title, $scope.notification_text = text) : ($scope.notification_title = "", $scope.notification_text = ""), $scope.subtitle_displayed = "" !== $scope.subtitle_text, setTimeout(function () {
- $scope.notification_displayed = !1
- }, 5e3)
- })
- }, link: function (scope, ele, attrs) {
- }, templateUrl: "templates/views/notification.html"
- }
- }), SG.Game.GameController = function () {
- this._player = {}, this._not_player = {}, this._scenario = {}, this._current_stage = {}, this._scenery = {}, this._sceneries = {}, this._act = null, this.event_controller = {}, this.scenario_is_ready = !1, this.phaser_game = {}, this.scenary_loaded = !1, this.act_loaded = !1, this.game_ready = !1, this.sound_muted = !1, this.custom_backgrounds = {}
- }, SG.Game.GameController.prototype = {
- start: function (scenario, sceneries, scope, start) {
- var _this = this;
- this.width = 980, this.height = 518;
- var game = new Phaser.Game(this.width, this.height, Phaser.CANVAS, "gameCanvas");
- return game.resolution = 2, game.transparent = !0, game.antialias = !0, game.state.add("Boot", SG.Game.Boot), game.state.add("PreloadScenery", SG.Game.PreloadScenery), game.state.add("ChooseCharacter", SG.Game.ChooseCharacter), game.state.add("PreloadAct", SG.Game.PreloadAct), game.state.add("ScenarioEngine", SG.Game.ScenarioEngine), game.state.start("Boot"), this.scenario = scenario, this.scenario.first_stage > 0 ? this.current_stage = this.scenario.getStageById(this.scenario.first_stage) : this.current_stage = this.scenario.stages[0], this.act = this.scenario.getActById(SG.game.current_stage.act_id), this.sceneries = sceneries, this.scenery = this.sceneries[this.act.scenery_id], this.event_controller = new SG.Game.EventController(scope), game.state.states.ScenarioEngine.ready_for_next_dialog_part = start, scope.$on("startScenario", function () {
- game.state.states.ScenarioEngine.ready_for_next_dialog_part = !0
- }), scope.$on("goToStage", function (event, stage_id) {
- var target_stage = _this.scenario.getStageById(stage_id);
- stage_id > 0 && null !== target_stage ? _this.event_controller.nextPhase(stage_id) : _this.event_controller.nextPhase()
- }), scope.$on("toggleSound", function (e, muted) {
- game.sound.mute = muted, SG.game.sound_muted = muted
- }), scope.$on("togglePause", function () {
- SG.phase_manager.is_in_stage_phase || (game.paused = scope.is_pause)
- }), scope.$on("setGamePaused", function (e, value) {
- game.paused = value, game.sound.mute = SG.game.sound_muted, game.paused ? game.sound.pauseAll() : game.sound.resumeAll()
- }), scope.$on("$destroy", function () {
- _this.phaser_game.destroy()
- }), this.phaser_game = game, SG.tracker.addStage(this.current_stage), game
- }, nextStep: function (stage_id, state) {
- this.phaser_game.paused = !0, stage_id != -1 ? SG.game.event_controller.displayProposition([], !0, !1) : SG.game.event_controller.displayProposition([], !0, !0, SG.game.current_stage.type);
- var target_stage = this.scenario.getStageById(stage_id);
- "display_proposition" == state ? (SG.game.current_stage.type = "default", this.phaser_game.state.start("ScenarioEngine"), this.phaser_game.paused = !1, this.event_controller.displayScenario(!0)) : ("replay" != state && SG.tracker.addStage(target_stage), this.current_stage.act_id !== target_stage.act_id && target_stage != -1 ? (this.scenary_loaded = !1, this.act_loaded = !1, this.game_ready = !1, SG.game.event_controller.readyToShow(!1), this.current_stage = target_stage, this.act = this.scenario.getActById(target_stage.act_id), this.scenery = this.sceneries[this.act.scenery_id], this.phaser_game.stage.removeChildren(), this.phaser_game.state.states.ScenarioEngine.reset(), this.phaser_game.state.start("PreloadScenery"), this.phaser_game.state.states.ScenarioEngine.ready_for_next_dialog_part = !0, this.event_controller.displayScenario(!1, !1), this.event_controller.characterSelection(stage_id)) : (this.current_stage = target_stage, "default" === target_stage.type ? this.phaser_game.state.start("ScenarioEngine") : this.event_controller.goToStagePhase(target_stage), this.phaser_game.paused = "default" != SG.game.current_stage.type, this.event_controller.displayScenario("default" == SG.game.current_stage.type)))
- }, selectCharacter: function (mode, id) {
- SG.game.act;
- "pc" == mode ? SG.game.player = SG.core.getCharacterById(id) : SG.game.not_player = SG.core.getCharacterById(id), this.phaser_game.paused = !1, this.phaser_game.state.start("PreloadAct")
- }, getOppositeCharacter: function (id) {
- var character_to_return = null;
- return this.player.id == id ? character_to_return = this.not_player : this.not_player.id == id && (character_to_return = this.player), character_to_return
- }, getGameOffset: function () {
- var offset = {x: 0, y: 0, height: 0, width: 0}, width = $(document).width(), height = $(document).height(),
- ratio_game = this.width / this.height, ratio_window = width / height;
- return ratio_window < ratio_game ? (offset.height = width / ratio_game, offset.width = width, offset.y = (height - width / ratio_game) / 2) : (offset.width = height * ratio_game, offset.height = height, offset.x = (width - height * ratio_game) / 2), offset
- }
- }, Object.defineProperties(SG.Game.GameController.prototype, {
- player: {
- get: function () {
- return this._player
- }, set: function (player) {
- this._player = player
- }
- }, not_player: {
- get: function () {
- return this._not_player
- }, set: function (not_player) {
- this._not_player = not_player
- }
- }, scenario: {
- get: function () {
- return this._scenario
- }, set: function (scenario) {
- this._scenario = scenario
- }
- }, current_stage: {
- get: function () {
- return this._current_stage
- }, set: function (current_stage) {
- this._current_stage = current_stage
- }
- }, scenery: {
- get: function () {
- return this._scenery
- }, set: function (scenery) {
- this._scenery = scenery
- }
- }, sceneries: {
- get: function () {
- return this._sceneries
- }, set: function (seneries) {
- this._sceneries = seneries
- }
- }, act: {
- get: function () {
- return this._act
- }, set: function (act) {
- this._act = act
- }
- }, scenario_is_ready: {
- get: function () {
- return this._scenario_is_ready
- }, set: function (scenario_is_ready) {
- this._scenario_is_ready = scenario_is_ready
- }
- }
- }), SG.Game.Boot = function (game) {
- this.game = game, this.isReady = !1
- }, SG.Game.Boot.prototype = {
- init: function () {
- this.setScaleMode()
- }, create: function () {
- this.game.stage.backgroundColor = "#000000", SG.CheatCodeController.addCheatCode(["up", "right", "down", "left", "up", "right", "down", "left", "enter"], function () {
- SG.game.event_controller.goToStage(-1)
- }), SG.CheatCodeController.addCheatCode(["g", "t", "s", "b", "i", "enter"], function () {
- var id = prompt("Saisissez l'id de la scène cible");
- SG.game.scenario.getStageById(parseInt(id)) && SG.game.event_controller.goToStage(id)
- }), SG.CheatCodeController.addCheatCode(["up", "up", "down", "down", "left", "right", "left", "right", "b", "a"], function () {
- alert("KONAMI CODE TODO IMPLEMENT")
- }), this.game.state.start("PreloadScenery")
- }, setScaleMode: function () {
- this.scale.parentIsWindow = !0, this.game.time.advancedTiming = !0, this.game.device.desktop ? (this.scale.scaleMode = Phaser.ScaleManager.SHOW_ALL, this.scale.pageAlignHorizontally = !0, this.scale.pageAlignVertically = !0) : (this.scale.scaleMode = Phaser.ScaleManager.SHOW_ALL, this.scale.pageAlignHorizontally = !0, this.scale.pageAlignVertically = !0), console.log("%cSCALE MODE SETTED", "color : purple; font-size : 20px")
- }
- }, SG.Game.PreloadScenery = function (game) {
- this.game = game
- }, SG.Game.PreloadScenery.prototype = {
- init: function () {
- this.scenario = SG.game.scenario
- }, preload: function () {
- this.game.load.onFileComplete.add(function (progress, cacheKey, success, totalLoaded, totalFiles) {
- SG.game.event_controller.reportProgress(progress)
- }, this);
- var loadManager = new SG.Game.LoadManager(this.game.load);
- loadManager.loadScenery(SG.game.act, SG.game.scenery), loadManager.preloadCustomBackground("character_selection", "assets/images/character_select.png"), loadManager.preloadCustomBackground("bg_neutre", "assets/images/bg_neutre.jpg")
- }, create: function () {
- var loadManager = new SG.Game.LoadManager(this.game.load);
- loadManager.loadCustomBackgrounds(), SG.game.scenary_loaded = !0, SG.game.phaser_game.state.states.ScenarioEngine.drawCustomBg("bg_neutre")
- }
- }, SG.Game.PreloadAct = function (game) {
- this.game = game
- }, SG.Game.PreloadAct.prototype = {
- init: function () {
- this.scenario = SG.game.scenario
- }, preload: function () {
- this.game.load.onFileComplete.add(function (progress, cacheKey, success, totalLoaded, totalFiles) {
- SG.game.event_controller.reportProgress(progress)
- }, this);
- var loadManager = new SG.Game.LoadManager(this.game.load);
- loadManager.preloadScenario()
- }, create: function () {
- SG.game.act_loaded = !0, this.game.state.start("ScenarioEngine")
- }
- }, SG.Game.ScenarioEngine = function (game) {
- this.game = game, this.dialog_list = [], this.camera_controller = null, this.subtitle_controller = new SG.Game.SubtitleController, this.loadManager = null, this.current_stage = {}, this.group_characters = null, this.player = null, this.not_player = null, this.current_character = null, this.force_camera = "undefined", this.index_dial_part = 0, this.ready_for_next_dialog_part = !1, this.wait_proposition = !1
- }, SG.Game.ScenarioEngine.prototype = {
- init: function () {
- this.game.sound.stopAll(), this.current_stage = SG.game.current_stage, this.wait_proposition = !1, this.force_camera = "undefined", this.index_dial_part = 0, this.subtitle_controller.setSubtitle("", "");
- var dialog_parser = new SG.Game.DialogParserController;
- this.dialog_list = dialog_parser.parseStageContent(this.current_stage), null === this.loadManager && (this.loadManager = new SG.Game.LoadManager(this.game.load)), null === this.camera_controller && (this.camera_controller = new SG.Game.CameraController(this.game, 2)), null === this.group_characters && (this.group_characters = this.add.group(null, "characters", !0), this.player = new SG.Game.CharacterPrefab(this.game, SG.game.player), this.player.onSpecificAnimation.add(this.camera_controller.displayItemById, this), this.not_player = new SG.Game.CharacterPrefab(this.game, SG.game.not_player), this.player.onSpecificAnimation.add(this.camera_controller.displayItemById, this), this.group_characters.add(this.player), this.group_characters.add(this.not_player), this.current_character = this.player)
- }, preload: function () {
- this.loadManager.removeUnusedAssets(), this.loadManager.loadStage(this.current_stage, this.dialog_list), this.resizeGame()
- }, create: function () {
- this.nb = 0
- }, drawCustomBg: function (name) {
- var children_count = SG.game.phaser_game.stage.children.length, index_to_top = children_count - 1;
- SG.game.phaser_game.stage.setChildIndex(SG.game.custom_backgrounds[name], index_to_top)
- }, update: function () {
- if (SG.game.game_ready) if (this.current_stage = SG.game.current_stage, this.ready_for_next_dialog_part && !this.wait_proposition && (this.subtitle_controller.setSubtitle("", ""), this.current_character.character.id != this.player.character.id || this.player.is_animated ? this.current_character.character.id != this.not_player.character.id || this.not_player.is_animated || (this.player.animations.stop(), this.player.is_animated = !1) : (this.not_player.animations.stop(), this.not_player.is_animated = !1)), this.ready_for_next_dialog_part && this.index_dial_part < this.dialog_list.length && !this.player.is_animated && !this.not_player.is_animated) this.player.wait = !1, this.not_player.wait = !1, this._nextDialogPart(this.index_dial_part); else if (this.ready_for_next_dialog_part && this.index_dial_part >= this.dialog_list.length && (0 === this.index_dial_part && (this.switchCurrentCharacter(1, 2), this.player.is_speaking = !1, this.not_player.is_speaking = !1, this.index_dial_part = 1), !this.wait_proposition)) if (this.current_character.is_speaking = !1, this.player.wait = !1, this.not_player.wait = !1, "default" != this.current_stage.type) SG.phase_manager.is_in_stage_phase || SG.game.event_controller.nextPhase(this.current_stage.id); else if (1 == this.current_stage.paths.length && "" === this.current_stage.paths[0].short_descriptions[SG.core.lang]) {
- var stage_id = this.current_stage.paths[0].target;
- this.stageHasEndPopup(this.current_stage) ? (SG.game.event_controller.displayEndPopup(this.current_stage), $(".popup-context").removeClass("slide-left"), this.wait_proposition = !0) : SG.game.event_controller.nextPhase(stage_id)
- } else this.current_stage.paths.length > 0 ? (this.wait_proposition = !0, this.stageHasEndPopup(this.current_stage) && (SG.game.event_controller.displayEndPopup(this.current_stage), $(".popup-context").removeClass("slide-left")), SG.game.event_controller.displayProposition(this.current_stage, !1, !1)) : (this.ready_for_next_dialog_part = !1, this.stageHasEndPopup(this.current_stage) ? (SG.game.event_controller.displayEndPopup(this.current_stage), $(".popup-context").removeClass("slide-left")) : SG.game.event_controller.endGame())
- }, reset: function () {
- this.cache.destroy(), this.dialog_list = [], this.camera_controller = null, this.subtitle_controller = new SG.Game.SubtitleController, this.loadManager = null, this.current_stage = {}, this.group_characters = null, this.player = null, this.not_player = null, this.current_character = null, this.force_camera = "undefined", this.index_dial_part = 0, this.ready_for_next_dialog_part = !1, this.load_status = null, this.wait_proposition = !1, this.current_sound = {}
- }, _nextDialogPart: function (index) {
- this.ready_for_next_dialog_part = !1;
- var data, datatype, role, character, data_types_list = ["role", "move_ref", "text", "sound", "force_camera"];
- for (var key in data_types_list) if (datatype = data_types_list[key], this.dialog_list[index].datas.hasOwnProperty(datatype)) switch (data = this.dialog_list[index].datas[datatype],
- datatype) {
- case"force_camera":
- this.force_camera = 0 == this.current_stage.cam_auto ? data : "undefined", this.player.wait = !0, this.not_player.wait = !0, this.ready_for_next_dialog_part = !0;
- break;
- case"sound":
- var sound = data;
- this.playSound(sound);
- break;
- case"text":
- var subtitle_text = data,
- name = this.current_character.character.names_to_display[SG.core.lang] ? this.current_character.character.names_to_display[SG.core.lang] : this.current_character.character.names[SG.core.lang];
- this.subtitle_controller.setSubtitle(subtitle_text, name);
- break;
- case"move_ref":
- this.current_character.wait = !0;
- var move_string = data;
- this.current_character.movement_controller.setMove(move_string), this.ready_for_next_dialog_part = !0;
- break;
- case"role":
- role = data, character = this.dialog_list[index].datas.character, this.switchCurrentCharacter(role, character.id, this.force_camera)
- }
- this.index_dial_part = index + 1
- }, switchCurrentCharacter: function (role, character_id, force_cam) {
- var pos;
- return 1 == role ? (this.current_character = this.not_player, pos = 2) : 2 == role && (this.current_character = this.player, pos = 1), 1 == this.current_stage.cam_auto && (6 == this.player.character.id ? force_cam = 2 : 6 == this.not_player.character.id && (force_cam = 1)), 1 == force_cam ? (this.player.is_filmed = !0, this.not_player.is_filmed = !1, this.player.attitude_id = this.player.attitude_id || 1, this.player.is_speaking = 2 == role, pos = 1) : 2 == force_cam ? (this.player.is_filmed = !1, this.not_player.is_filmed = !0, this.not_player.attitude_id = this.not_player.attitude_id || 3, this.not_player.is_speaking = 1 == role, pos = 2) : 1 == role ? (this.player.is_filmed = !1, this.not_player.is_filmed = !0, this.not_player.is_speaking = !0, this.not_player._attitude_id = this.not_player._attitude_id < 1 || 3 == this.not_player.attitude_id ? 1 : this.not_player._attitude_id) : 2 == role ? (this.not_player.is_filmed = !1, this.player.is_filmed = !0, this.player.is_speaking = !0, this.player._attitude_id = this.player._attitude_id < 1 || 3 == this.player.attitude_id ? 1 : this.player._attitude_id) : console.log("Le role id n'éxiste pas"), this.camera_controller.switchCamera(pos), null
- }, playSound: function (sound_string) {
- var _this = this;
- if (this.cache.checkSoundKey(sound_string)) {
- var soundToPlay = this.current_sound = this.game.add.audio(sound_string);
- null !== soundToPlay ? (this.game.sound.setDecodedCallback([soundToPlay], function () {
- soundToPlay.play()
- }, this), soundToPlay.onStop.add(function (sound) {
- _this.ready_for_next_dialog_part = !0, null != _this.player && null != _this.not_player ? (_this.player.wait = !0, _this.not_player.wait = !0) : this.waitIfNotSound(this.subtitle_controller.temporisation)
- }, this)) : this.waitIfNotSound(this.subtitle_controller.temporisation)
- } else this.waitIfNotSound(this.subtitle_controller.temporisation)
- }, waitIfNotSound: function (temporisation) {
- var _this = this;
- setTimeout(function () {
- _this.ready_for_next_dialog_part = !0, _this.player.wait = !0, _this.not_player.wait = !0
- }, temporisation)
- }, resizeGame: function () {
- var width = SG.game.width, height = SG.game.height, offset_x = -((1650 - width) / 2);
- this.group_characters.x = offset_x, this.camera_controller.cams[1].x = offset_x, this.camera_controller.cams[2].x = offset_x, this.camera_controller.cams[1].items.x = offset_x, this.camera_controller.cams[2].items.x = offset_x;
- var offset_y = -((1050 - height) / 2);
- this.group_characters.y = offset_y, this.camera_controller.cams[1].y = offset_y, this.camera_controller.cams[2].y = offset_y, this.camera_controller.cams[1].items.y = offset_y, this.camera_controller.cams[2].items.y = offset_y, this.scale.refresh()
- }, render: function () {
- SG.core.debug_mode && this.game.debug.text("FPS : " + this.game.time.fps || "--", 30, 100)
- }, stageHasEndPopup: function (stage) {
- return "" != stage._transition_content[SG.core.lang] && null != stage._transition_content[SG.core.lang] || "" != stage._stage_bob_pictures[SG.core.lang] && null != stage._stage_bob_pictures[SG.core.lang]
- }
- }, SG.Game.CharacterPrefab = function (game, character) {
- Phaser.Sprite.call(this, game), this.movement_controller = new SG.Game.MovementController(this), this._character = character, this._current_move = {}, this._is_speaking = !0, this._is_filmed = !1, this._is_animated = !1, this._wait = !0, this._attitude_id = 0, this._pause_attitude_id = 0, this.onSpecificAnimation = new Phaser.Signal;
- var _this = this;
- this.events.onAnimationComplete.add(function () {
- this._is_animated = !1, 130 == _this.current_move.id && _this.onSpecificAnimation.dispatch(this, 7, !0)
- }, this), this.events.onAnimationStart.add(function () {
- this._is_animated = !0, 133 == _this.current_move.id && _this.onSpecificAnimation.dispatch(this, 7, !1)
- }, this)
- }, SG.Game.CharacterPrefab.prototype = Object.create(Phaser.Sprite.prototype), SG.Game.CharacterPrefab.prototype.constructor = SG.Game.CharacterPrefab, SG.Game.CharacterPrefab.prototype.update = function () {
- 6 != this.character.id && (this.is_animated || this.wait || this.movement_controller.playMovement())
- }, Object.defineProperties(SG.Game.CharacterPrefab.prototype, {
- character: {
- get: function () {
- return this._character
- }, set: function (character) {
- this._character = character
- }
- }, current_move: {
- get: function () {
- return this._current_move
- }, set: function (current_move) {
- this._current_move = current_move
- }
- }, is_filmed: {
- get: function () {
- return this._is_filmed
- }, set: function (is_filmed) {
- this._is_filmed = is_filmed
- }
- }, attitude_id: {
- get: function () {
- return this._attitude_id
- }, set: function (attitude_id) {
- this._attitude_id = attitude_id
- }
- }, pause_attitude_id: {
- get: function () {
- return this._pause_attitude_id
- }, set: function (pause_attitude_id) {
- this._pause_attitude_id = pause_attitude_id
- }
- }, is_animated: {
- get: function () {
- return this._is_animated
- }, set: function (is_animated) {
- this._is_animated = is_animated
- }
- }, is_speaking: {
- get: function () {
- return this._is_speaking
- }, set: function (is_speaking) {
- this._is_speaking = is_speaking
- }
- }, wait: {
- get: function () {
- return this._wait
- }, set: function (wait) {
- this._wait = wait
- }
- }
- }), SG.Game.CameraPrefab = function (game, parent, name, addToStage, background, items, cam_id) {
- Phaser.Group.call(this, game, parent, name, addToStage);
- var _this = this;
- this.items = new Phaser.Group(_this.game, null, "", !0), this.create(0, 0, background);
- var item_name;
- for (var item_id in items) if (void 0 !== items[item_id].position[cam_id]) {
- var position = items[item_id].position[cam_id], item_id = items[item_id].id;
- _this.items.name = "items_cam" + position.cam, item_name = "itm" + item_id + "_bgn" + position.bgn + "_cam" + cam_id;
- var item_inserted = _this.items.create(parseInt(position.x), parseInt(position.y), item_name);
- item_inserted.id = item_id
- }
- }, SG.Game.CameraPrefab.prototype = Object.create(Phaser.Group.prototype), SG.Game.CameraPrefab.prototype.constructor = SG.Game.CameraPrefab, SG.Game.CameraController = function (game, position) {
- var _this = this;
- this.game = game, this.cam_position = position, this.cams = [];
- var i = 1;
- SG.game.scenery.cameras.forEach(function (camera) {
- var backgroundToSet = "cam_" + camera.id;
- _this.cams[i] = new SG.Game.CameraPrefab(game, null, backgroundToSet, !0, backgroundToSet, SG.game.scenery.items, camera.id), i++
- }), this.switchCamera(position, !0)
- }, SG.Game.CameraController.prototype.switchCamera = function (position, force) {
- force = force || !1;
- var _this = this, turned = !1;
- if (position != this.cam_position || force) {
- this.cam_position = position;
- var children_count = this.game.stage.children.length, index_to_top = children_count - 1;
- this.game.stage.setChildIndex(this.cams[position], index_to_top), this.game.stage.children.forEach(function (child) {
- "characters" == child.name && _this.game.stage.setChildIndex(child, index_to_top)
- }), this.game.stage.setChildIndex(this.cams[position].items, index_to_top), this.game.stage.children.forEach(function (child) {
- "__world" == child.name && _this.game.stage.setChildIndex(child, index_to_top)
- }), turned = !0
- }
- return turned
- }, SG.Game.CameraController.prototype._getItemsByCamId = function (cam_id) {
- var items_to_return = [];
- return this._items_list.forEach(function (item) {
- item.pos.cam == cam_id && items_to_return.push(item)
- }), items_to_return
- }, SG.Game.CameraController.prototype.displayItemById = function (event, id, is_display) {
- var item_to_set, _this = SG.game.phaser_game.state.callbackContext.camera_controller;
- _this.cams[_this.cam_position].items.children.forEach(function (item) {
- item.id == id && (item_to_set = item)
- }), void 0 !== item_to_set && (item_to_set.visible = is_display, console.log("the item : " + item_to_set.id + " is display ? " + is_display + " - " + item_to_set.visible))
- }, SG.Game.LoadManager = function (loader) {
- this.loader = loader, this.sounds_list = [], this.nb_sounds_loaded = 0, this.nb_sounds_loading = 0, this.loading_lvl = 1, this.limit_of_sounds_to_preload = 20
- }, SG.Game.LoadManager.prototype = {
- loadScenery: function (act, scenery) {
- var cam_name, _this = this;
- scenery.cameras.forEach(function (camera) {
- cam_name = "cam_" + camera.id, _this.loader.image(cam_name, SG.core.base_url + "" + camera.path)
- });
- var item_name;
- for (var item in scenery.items) {
- var item_id = scenery.items[item].id;
- scenery.items[item].position.forEach(function (position) {
- item_name = "itm" + item_id + "_bgn" + position.bgn + "_cam" + position.cam, _this.loader.image(item_name, SG.core.base_url + "/ressources/medias/items/" + item_name + ".png")
- })
- }
- }, preloadCustomBackground: function (name, url) {
- this.loader.image(name, url), SG.game.custom_backgrounds[name] = new Phaser.Group(SG.game.phaser_game, null, name, !0)
- }, loadCustomBackgrounds: function () {
- for (var name in SG.game.custom_backgrounds) SG.game.custom_backgrounds[name].create(0, 0, name)
- }, preloadScenario: function () {
- var url, animation_name, sprite_url, sprite_json_url, _this = this,
- player_moves = SG.game.scenery.getBasicMovesForUser(SG.game.player.id, 1),
- not_player_moves = SG.game.scenery.getBasicMovesForUser(SG.game.not_player.id, 2);
- player_moves.forEach(function (move) {
- SG.game.player.moves.push(move), url = SG.game.scenery.getUrlForUser(SG.game.player.id, move.position, move.cam), animation_name = "s" + SG.game.scenery.id + "_u" + SG.game.player.id + "_" + move.reference, sprite_url = SG.core.base_url + url + "/" + move.reference + ".png", sprite_json_url = SG.core.base_url + url + "/" + move.reference + ".json", _this.loader.atlasJSONArray(animation_name, sprite_url, sprite_json_url)
- }), not_player_moves.forEach(function (move) {
- SG.game.not_player.moves.push(move), url = SG.game.scenery.getUrlForUser(SG.game.not_player.id, move.position, move.cam), animation_name = "s" + SG.game.scenery.id + "_u" + SG.game.not_player.id + "_" + move.reference, sprite_url = SG.core.base_url + url + "/" + move.reference + ".png", sprite_json_url = SG.core.base_url + url + "/" + move.reference + ".json", _this.loader.atlasJSONArray(animation_name, sprite_url, sprite_json_url)
- })
- }, loadStage: function (stage, dialog_list) {
- var sound_name, sound_url, move_name, url, moves, sprite_url, sprite_json_url, _this = this;
- dialog_list.forEach(function (dialog) {
- dialog.type == SG.Model.DialogPart.TYPE_MOVE && (moves = SG.game.scenery.getSpecificMovesForUser(dialog.datas.character.id, dialog.datas.role, dialog.datas.move_ref), moves.forEach(function (move) {
- dialog.datas.character.moves.push(move), url = SG.game.scenery.getUrlForUser(dialog.datas.character.id, move.position, move.cam), move_name = "s" + SG.game.scenery.id + "_u" + dialog.datas.character.id + "_" + move.reference, sprite_url = SG.core.base_url + url + "/" + move.reference + ".png", sprite_json_url = SG.core.base_url + url + "/" + move.reference + ".json", _this.loader.atlasJSONArray(move_name, sprite_url, sprite_json_url)
- }))
- }), stage.sounds[SG.core.lang].forEach(function (sound) {
- sound.character_id != SG.game.player.id && sound.character_id != SG.game.not_player.id || (sound_name = "stage" + stage.id + "_u" + sound.character_id + "_p" + sound.part, sound_url = SG.core.medias_url + "" + sound.file_path, _this.loader.audio(sound_name, sound_url), _this.sounds_list.push(sound_name))
- })
- }, loadNextStage: function () {
- }, removeUnusedAssets: function () {
- this.loader.game.sound.destroy()
- }
- }, SG.Game.DialogParserController = function () {
- this.START_DIALOG_DELIMITER1 = "(--", this.START_DIALOG_DELIMITER2 = ")", this.START_MOVE_DELIMITER1 = "(MV-", this.START_MOVE_DELIMITER2 = "[", this.PARAM_MOVE_DELIMITER = ",", this.END_MOVE_DELIMITER = "])", this.START_CINEMATIC_DELIMITER1 = "[C", this.START_CINEMATIC_DELIMITER2 = "]", this.START_BGS_DELIMITER1 = "[BGS:", this.START_BGS_DELIMITER2 = "]", this.START_DOC_DELIMITER1 = "[DOC-", this.START_DOC_DELIMITER2 = "]", this.START_BLUR_DELIMITER1 = "[BLUR:", this.START_BLUR_DELIMITER2 = "]", this.SHOW_ITEM_DELIMITER1 = "[SHOWITEM:", this.SHOW_ITEM_DELIMITER2 = "]", this.START_PICTURE_DELIMITER1 = "[IMG:", this.START_PICTURE_DELIMITER2 = "]", this.START_SWF_DELIMITER1 = "[SWF:", this.START_SWF_DELIMITER2 = "]", this.SWITCHCAM_DELIMITER1 = "[SwitchCam:", this.SWITCHCAM_DELIMITER2 = "]"
- }, SG.Game.DialogParserController.prototype = {
- parseStageContent: function (stage) {
- for (var skip_this_part, DialogPart = SG.Model.DialogPart, stage_id = (SG.core.lang, stage.scenario_id, stage.id), description = stage.short_descriptions[SG.core.lang], list_of_part = [], delimiter_positions = {}, delimiters_length = this._getDelimitersLength(), part_number = 1, security_cpt = 0; description.length > 0;) {
- skip_this_part = !1, delimiter_positions = {}, delimiter_positions = this._getDelimitersPositionsFromDescription(description);
- var current_type = DialogPart.NONE;
- for (var key in delimiter_positions) (delimiter_positions[current_type] == -1 || delimiter_positions[key] < delimiter_positions[current_type] && delimiter_positions[key] > -1) && (current_type = key);
- var tmp_length, string_role_id, role_id, current_character, cam_id, sound_name, text_speech, datas = {};
- switch (current_type) {
- case DialogPart.TYPE_CAMERA:
- description = description.substring(delimiter_positions[current_type] + delimiters_length[current_type]), tmp_length = description.indexOf(this.SWITCHCAM_DELIMITER2), cam_id = description.substring(0, tmp_length), description = description.substring(tmp_length + 1), datas.force_camera = cam_id;
- break;
- case DialogPart.TYPE_SPEECH:
- description = description.substring(delimiter_positions[current_type] + delimiters_length[current_type]), tmp_length = description.indexOf(this.START_DIALOG_DELIMITER2), string_role_id = description.substring(0, tmp_length), description = description.substring(string_role_id.length), role_id = parseInt(string_role_id), delimiter_positions = {}, delimiter_positions = this._getDelimitersPositionsFromDescription(description);
- var next_type = DialogPart.NONE;
- tmp_length = -1;
- for (key in delimiter_positions) (delimiter_positions[next_type] == -1 || delimiter_positions[key] < delimiter_positions[next_type] && delimiter_positions[key] > -1) && (next_type = key);
- tmp_length = delimiter_positions[next_type] - 1, tmp_length >= 0 ? text_speech = description.substring(this.START_DIALOG_DELIMITER2.length, tmp_length) : (text_speech = description.substring(this.START_DIALOG_DELIMITER2.length), description = ""), current_character = this._findUserIdFromRoleId(role_id), datas.role = role_id, datas.character = current_character, datas.text = text_speech, sound_name = "stage" + stage_id + "_u" + current_character.id + "_p" + part_number, datas.sound = sound_name, part_number++;
- break;
- case DialogPart.TYPE_MOVE:
- description = description.substring(delimiter_positions[current_type] + delimiters_length[current_type]), tmp_length = description.indexOf("["), string_role_id = description.substring(0, tmp_length), description = description.substring(string_role_id.length + 1), role_id = parseInt(string_role_id), tmp_length = description.indexOf(this.END_MOVE_DELIMITER);
- var move_info = description.substring(0, tmp_length);
- description = description.substring(tmp_length + 1);
- var move_info_array = move_info.split(this.PARAM_MOVE_DELIMITER), move_ref = move_info_array[0],
- force_speeking_move = "undefined";
- move_info_array.length > 1 && (force_speeking_move = move_info_array[1]), current_character = this._findUserIdFromRoleId(role_id), datas.role = role_id, datas.character = current_character, datas.move_ref = move_ref, datas.override_speeking = force_speeking_move;
- break;
- case DialogPart.NONE:
- console.log("No More Tag"), description = "", skip_this_part = !0;
- break;
- default:
- description = description.substring(delimiter_positions[current_type] + delimiters_length[current_type]), skip_this_part = !0, console.log("tag not yet supported : " + current_type)
- }
- if (!skip_this_part) {
- var part = new DialogPart(current_type, datas);
- list_of_part.push(part)
- }
- if (security_cpt++, security_cpt > 100) return console.log("Boucle supérieur à " + security_cpt + " itérations"), list_of_part
- }
- return list_of_part
- }, _findUserIdFromRoleId: function (role_id) {
- return 2 == role_id ? SG.game.player : SG.game.not_player
- }, _getDelimitersPositionsFromDescription: function (currentDescription) {
- var delimiters = {}, DialogPart = SG.Model.DialogPart;
- return delimiters[DialogPart.TYPE_SPEECH] = currentDescription.indexOf(this.START_DIALOG_DELIMITER1), delimiters[DialogPart.TYPE_CINEMATIC] = currentDescription.indexOf(this.START_CINEMATIC_DELIMITER1), delimiters[DialogPart.TYPE_PICTURE] = currentDescription.indexOf(this.START_PICTURE_DELIMITER1), delimiters[DialogPart.TYPE_SWF] = currentDescription.indexOf(this.START_SWF_DELIMITER1), delimiters[DialogPart.TYPE_BGS] = currentDescription.indexOf(this.START_BGS_DELIMITER1), delimiters[DialogPart.TYPE_MOVE] = currentDescription.indexOf(this.START_MOVE_DELIMITER1), delimiters[DialogPart.TYPE_DOC] = currentDescription.indexOf(this.START_DOC_DELIMITER1), delimiters[DialogPart.TYPE_BLUR] = currentDescription.indexOf(this.START_BLUR_DELIMITER1), delimiters[DialogPart.TYPE_ITEM] = currentDescription.indexOf(this.SHOW_ITEM_DELIMITER1), delimiters[DialogPart.TYPE_CAMERA] = currentDescription.indexOf(this.SWITCHCAM_DELIMITER1), delimiters[DialogPart.NONE] = -1, delimiters
- }, _getDelimitersLength: function () {
- var delimiters = {}, DialogPart = SG.Model.DialogPart;
- return delimiters[DialogPart.TYPE_SPEECH] = this.START_DIALOG_DELIMITER1.length, delimiters[DialogPart.TYPE_CINEMATIC] = this.START_CINEMATIC_DELIMITER1.length, delimiters[DialogPart.TYPE_PICTURE] = this.START_PICTURE_DELIMITER1.length, delimiters[DialogPart.TYPE_SWF] = this.START_SWF_DELIMITER1.length, delimiters[DialogPart.TYPE_BGS] = this.START_BGS_DELIMITER1.length, delimiters[DialogPart.TYPE_MOVE] = this.START_MOVE_DELIMITER1.length, delimiters[DialogPart.TYPE_DOC] = this.START_DOC_DELIMITER1.length, delimiters[DialogPart.TYPE_BLUR] = this.START_BLUR_DELIMITER1.length, delimiters[DialogPart.TYPE_ITEM] = this.SHOW_ITEM_DELIMITER1.length, delimiters[DialogPart.TYPE_CAMERA] = this.SWITCHCAM_DELIMITER1.length, delimiters[DialogPart.NONE] = 2, delimiters
- }
- }, SG.Game.SubtitleController = function () {
- this._temporisation = 0
- }, SG.Game.SubtitleController.prototype = {
- setSubtitle: function (text, name) {
- SG.game.event_controller.setSubtitle(text, name);
- var longueur = text.length;
- this.temporisation = longueur / 25, this.temporisation < 1.5 && (this.temporisation = 1.5), this.temporisation = 1e3 * this.temporisation
- }
- }, Object.defineProperties(SG.Game.SubtitleController.prototype, {
- temporisation: {
- get: function () {
- return this._temporisation
- }, set: function (time) {
- this._temporisation = time
- }
- }
- }), SG.Game.EventController = function (scope) {
- this.scope = scope, this.displayProposition = function (stage, hide, isByNextStep, stage_type) {
- this.scope.$emit("displayProposition", stage, hide, isByNextStep, stage_type)
- }, this.displayEndPopup = function (stage) {
- this.scope.$emit("displayEndPopup", stage)
- }, this.displayNotification = function (title, text) {
- this.scope.$emit("displayNotification", title, text)
- }, this.displayScenario = function (display) {
- this.scope.$emit("displayScenario", display)
- }, this.setSubtitle = function (subtitle, name, is_displayed) {
- this.scope.$emit("displaySubtitle", subtitle, name)
- }, this.goToStagePhase = function (stage) {
- this.scope.$emit("goToStagePhase", stage)
- }, this.goToStage = function (stage_id) {
- this.scope.$emit("goToStage", stage_id)
- }, this.nextPhase = function (stage_id) {
- this.scope.$emit("nextPhase", stage_id, "default")
- }, this.endGame = function (stage_id) {
- this.scope.$emit("endGame")
- }, this.characterSelection = function (stage_id) {
- this.scope.$emit("characterSelection", stage_id)
- }, this.reportProgress = function (value) {
- this.scope.$emit("reportProgress", value)
- }, this.readyToShow = function (value) {
- this.scope.$emit("readyToShow", value)
- }, this.onCriterionsChange = function (value) {
- this.scope.$emit("onCriterionsChange", value)
- }
- }, SG.Game.MovementController = function (character) {
- this.character = character, this.FRAME_PER_SECOND = 24, this.DEFAULT_SPEAK_ATTITUDE_ID = 1, this.DEFAULT_PAUSE_ATTITUDE_ID = 3
- }, SG.Game.MovementController.prototype = {
- playMovement: function () {
- var moves, attitude_id;
- this.character.is_filmed ? ("backview_breath_front" == this.character.current_move.reference && (this.character.attitude_id = this.saved_attitude_id, this.character.pause_attitude_id = this.saved_pause_attitude_id, this.saved_attitude_id = this.DEFAULT_SPEAK_ATTITUDE_ID, this.saved_pause_attitude_id = this.DEFAULT_PAUSE_ATTITUDE_ID), attitude_id = this.character.is_speaking ? this.character.attitude_id : this.character.pause_attitude_id, moves = this.character.character.getMovesByAttitudeId(attitude_id, this.character.is_filmed), 0 === moves.length && (attitude_id = this.character.is_speaking ? this.DEFAULT_SPEAK_ATTITUDE_ID : this.DEFAULT_PAUSE_ATTITUDE_ID, moves = this.character.character.getMovesByAttitudeId(attitude_id, this.character.is_filmed))) : moves = this.character.character.getMovesByAttitudeId(this.DEFAULT_PAUSE_ATTITUDE_ID, this.character.is_filmed);
- var movesToSelect = [];
- moves.forEach(function (move) {
- for (var i = 0; i < move.proba; i++) movesToSelect.push(move)
- });
- var index;
- index = movesToSelect.length > 0 ? (Math.random() * (movesToSelect.length - 1)).toFixed() : 0;
- var move = movesToSelect[index];
- 0 != movesToSelect.length && (this.character.current_move.reference ? ("backview_breath_front" == move.reference && this.character.current_move.reference != move.reference && (this.saved_attitude_id = this.character.attitude_id, this.saved_pause_attitude_id = this.character.pause_attitude_id), this._playAnimation(move)) : move && this._playAnimation(move))
- }, setMove: function (move_reference) {
- var move = this.character.character.getMoveByReference(move_reference);
- null !== move && this.character.is_filmed && (console.log("set specific movement for character : " + this.character.character.id + " animation : " + move.reference), this._playAnimation(move))
- }, _playAnimation: function (move) {
- this.character.current_move = move, this.character.attitude_id = move.speak_id ? move.speak_id : this.DEFAULT_SPEAK_ATTITUDE_ID, this.character.pause_attitude_id = move.pause_id ? move.pause_id : this.DEFAULT_PAUSE_ATTITUDE_ID, this.character.loadTexture("s" + SG.game.scenery.id + "_u" + this.character.character.id + "_" + move.reference, 0), this.character.animations.add(move.reference), this.character.animations.play(move.reference, this.FRAME_PER_SECOND, !1), this.character.x = move.x, this.character.y = move.y, this.character.is_animated = !0
- }
- }, SG.Game.MemoryEffect = function (stage) {
- this.stage = stage || {}
- }, SG.Game.MemoryEffect.prototype = {
- executeStageMemoryEffect: function (stage) {
- }, executePropositionMemoryEffect: function (stage_path) {
- var condition = stage_path.condition;
- "" !== condition && (condition = condition.replace("displayPathIf(", "this.displayPathIf( stage_path,"), condition = condition.replace("criterionEqualTo", "this.criterionEqualTo"), condition = condition.replace("criterionInfOrEqTo", "this.criterionInfOrEqTo"), condition = condition.replace("criterionSuperiorTo", "this.criterionSuperiorTo"), condition = condition.replace("goneThrew", "this.goneThrew"), condition = condition.replace("goneThrewIn", "this.goneThrewIn"), console.log("Memory effect - condition ---> "), console.log(condition), eval(condition))
- }, _executeMemoryEffect: function (conditions, path_id, parent, target) {
- }, runCmd: function (cmd) {
- }, criterionEqualTo: function (criterion_id, value) {
- var is_equal, score;
- return score = SG.tracker.getScoreByCriterionId(criterion_id), is_equal = score == value
- }, criterionInfOrEqTo: function (criterion_id, value) {
- var is_inferior_or_equal, score;
- return score = SG.tracker.getScoreByCriterionId(criterion_id), is_inferior_or_equal = score <= value
- }, criterionSuperiorTo: function (criterion_id, value) {
- var is_superior, score;
- return score = SG.tracker.getScoreByCriterionId(criterion_id), is_superior = score > value
- }, goneThrew: function (stage_id) {
- var is_gone_threw;
- return is_gone_threw = void 0 !== SG.tracker.stages[stage_id] && null !== SG.tracker.stages[stage_id]
- }, goneThrewIn: function (stage_ids_list, number_done) {
- var is_gone_threw, cpt = 0;
- return stage_ids_list.forEach(function (stage_id) {
- this.goneThrew(stage_id) && cpt++
- }), is_gone_threw = cpt >= number_done
- }, displayPathIf: function (stage_path, is_display) {
- stage_path.is_display = is_display
- }, addPointIf: function () {
- }, gotoPreviousStage: function () {
- }, goToStage: function () {
- }, isInArray: function () {
- }, goToIf: function () {
- }, enablePathIf: function () {
- }, getCriterionPercentage: function () {
- }, getPreviousStage: function () {
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement