Best JavaScript code snippet using qawolf
PushScenes.js
Source:PushScenes.js
1phina.globalize();2//æåå
¥åç»é¢ï¼ãªã¼ãã¼ã¬ã¤ããéã«ããã¯ããï¼3phina.define('InputScene', {4 superClass: 'DisplayScene',5 init: function(opt) {6 //see app-globalobjects7 //TfAp.OverLayMessage = ''; //ã¡ãã»ã¼ã¸8 //TfAp.OverLayInput = ''; //å
¥åçµæ9 //see phina-main.tag.html10 //listenUserVoice11 //see SquereBlessingScene //å©ç¨ä¾12 //this.on(opt.cbname13 14 // 親ã¯ã©ã¹åæå15 this.superInit();16 // èæ¯ãåéæå17 this.backgroundColor = 'rgba(0, 0, 0, 0.7)';18 this.beforeInput = TfAp.OverLayInput;19 this.cbname = opt.cbname;20 },21 update:function(app){22 //çä¼¼é£ä¿ãªã®ã§å
¥åå¤å¤æ´ã¨ãã£ã³ã»ã«ã¯å¥ã
ã«å¦ç23 //æ´æ°ï¼ï¼å
¥åå¤å¤æ´æãã³ã¼ã«ããã¯ã¤ãã³ãçºç«ãã¦æ»ãã24 if(this.beforeInput != TfAp.OverLayInput){25 this.beforeInput = TfAp.OverLayInput;26 app.flare(this.cbname);27 app.popScene();28 }29 //æ´æ°ï¼ï¼ãã£ã³ã»ã«ãã¿ã³æ¼ä¸æãä½ãããæ»ãã30 if(TfAp.OverLayCancel == true){31 TfAp.OverLayCancel = false;32 app.popScene();33 }34 },35});36//åæ©çãªã¡ãã»ã¼ã¸è¡¨ç¤ºã·ã¼ã³37phina.define('PrimitiveMessageScene', {38 superClass: 'DisplayScene',39 init: function(options) {40 this.superInit(options);41 //ä¸ä½ã¯ã©ã¹ã§ä½¿ãoptionsã§ã¯ãªãã®ã§ããã§ç©ºç½å¯¾ç42 options = ({}).$safe(options, {43 Messages :['',],44 x :320,45 y :450,46 width :600,47 height :500,48 nextLabel :'',49 });50 app.backgroundColor = appBackGroundColor;51 //ã¡ãã»ã¼ã¸ã¦ã¤ã³ãã¦52 this.MessageWindow = MessageWindow({53 texts :options.Messages,54 x :options.x,55 y :options.y,56 width :options.width,57 height :options.height,58 buttonAName :i18n.OK,59 buttonWidth: 300,60 }).addChildTo(this);61 var self = this;62 this.MessageWindow.ButtonA.on('push', function(e) {63 self.exit(options.nextLabel);64 });65 },66});67//åã¹ã¯ã¨ã¢ã®åºæ¬å®ç¾©68phina.define('SquereScene', {69 superClass: 'DisplayScene',70 init: function(options) {71 this.superInit(options);72 app.backgroundColor = appBackGroundColor;73 //ã¹ã¯ã¨ã¢ãã¼ã¯74 var imageSquere = SquareMark({75 name : 'mark_' + options.SquereMark,76 x : 50,77 y : 50,78 width : 90,79 height : 90,80 rotation: 0,81 }).addChildTo(this);82 //ã¹ã¯ã¨ã¢å83 var labelSquereName = Label({text:options.SquereMark + ' Squere',84 x : 100,85 y : 30,86 width : 200,87 height : 50,88 align: 'left',89 baseline: 'middle',90 fontSize:32,91 fontColor :'black',92 fontWeight:'bold',}).addChildTo(this);93 var labelSquereMeaning = Label({text:options.SquereMeaning + i18n.Squere,94 x : 150,95 y : 60,96 width : 200,97 height : 50,98 align: 'left',99 baseline: 'middle',100 fontSize:20,101 fontColor :'black',}).addChildTo(this);102 this._label = function(opt){ return Label({103 text: opt.text,104 align: opt.align||'left',105 baseline: 'top',106 fontSize:opt.fontSize||20,107 fontColor :opt.fontColor||'black',108 x:opt.x|| 50,109 y:opt.y||250,110 });}111 this._selectButton = function(opt){ return Button({112 text :opt.text,113 id :opt.id,114 x :opt.x||320,115 y :(opt.y||400)+opt.id*50,116 height :opt.height||40,117 width :opt.width||600,118 align: 'left',119 fontColor :'black',120 fontWeight:'bold',121 fill :'#E8CFE8',122 stroke :'purple',123 strokeWidth : 3,124 fontFamily:'monospace',125 fontSize :20})};126 },127});128//ã¨ã³ã¸ã§ã«ãããé¸ætoç¡æèã®å°ç129phina.define('SelectDeckToEnvelopeAngelScene', {130 superClass: 'SelectDeckToEnvelopeScene',131 init: function(options) {132 options = ({}).$safe(options, {133 CardClass : AngelCard,134 Master : i18n.CardAngels,135 });136 if (CurrentGameData.DeckAngel == void 0 || CurrentGameData.DeckAngel.length == 0) {137 var _deck = [];138 for (i in options.Master) {139 _deck.push(options.Master[i].id);140 }141 CurrentGameData.DeckAngel = _deck.shuffle();142 }143 options.Deck = CurrentGameData.DeckAngel;144 if (CurrentGameData.UnconsciousAngel == void 0 ) {145 CurrentGameData.UnconsciousAngel = [];146 }147 options.UnconsciousEnvelope = CurrentGameData.UnconsciousAngel;148 var _inPlayCard = [].concat(CurrentGameData.UnconsciousAngel);149 options.InPlayCard = _inPlayCard;150 this.superInit(options);151 },152});153//ã¤ã³ãµã¤ããããé¸æ154phina.define('SelectDeckToEnvelopeInsightScene', {155 superClass: 'SelectDeckToEnvelopeScene',156 init: function(options) {157 options = ({}).$safe(options, {158 CardClass : InsightCard,159 Master : i18n.CardInsights,160 });161 if (CurrentGameData.DeckInsight == void 0 || CurrentGameData.DeckInsight.length == 0) {162 var _deck = [];163 for (i in options.Master) {164 _deck.push(options.Master[i].id);165 }166 CurrentGameData.DeckInsight = _deck.shuffle();167 }168 options.Deck = CurrentGameData.DeckInsight;169 if (CurrentGameData.UnconsciousInsight == void 0 ) {170 CurrentGameData.UnconsciousInsight = [];171 }172 options.UnconsciousEnvelope = CurrentGameData.UnconsciousInsight;173 var _inPlayCard = [].concat(CurrentGameData.UnconsciousInsight);174 options.InPlayCard = _inPlayCard;175 this.superInit(options);176 },177});178//ã»ããããã¯ãããé¸æ179phina.define('SelectDeckToEnvelopeSetbackScene', {180 superClass: 'SelectDeckToEnvelopeScene',181 init: function(options) {182 options = ({}).$safe(options, {183 CardClass : SetbackCard,184 Master : i18n.CardSetbacks,185 });186 if (CurrentGameData.DeckSetback == void 0 || CurrentGameData.DeckSetback.length == 0) {187 var _deck = [];188 for (i in options.Master) {189 _deck.push(options.Master[i].id);190 }191 CurrentGameData.DeckSetback = _deck.shuffle();192 }193 options.Deck = CurrentGameData.DeckSetback;194 if (CurrentGameData.UnconsciousSetback == void 0 ) {195 CurrentGameData.UnconsciousSetback = [];196 }197 options.UnconsciousEnvelope = CurrentGameData.UnconsciousSetback;198 var _inPlayCard = [].concat(CurrentGameData.UnconsciousSetback);199 options.InPlayCard = _inPlayCard;200 this.superInit(options);201 },202});203//天使fromç¡æèã®å°ç204phina.define('SelectEnvelopeToScoreAngelScene', {205 superClass: 'SelectEnvelopeToScoreScene',206 init: function(options) {207 options = ({}).$safe(options, {208 CardClass : AngelCard,209 Master : i18n.CardAngels,210 OpenMessage : true,211 Deck : CurrentGameData.UnconsciousAngel,212 Message : i18n.SelectedAngelMessage + i18n.SelectedAngelAfterMessage,213 Log : i18n.SelectedAngelLog,214 });215 if (CurrentGameData.ScoreCardLevel == void 0 || CurrentGameData.ScoreCardLevel < 0) {216 CurrentGameData.ScoreCardLevel = 0;217 }218 if (CurrentGameData.Angel[CurrentGameData.ScoreCardLevel] == void 0) {219 CurrentGameData.Angel[CurrentGameData.ScoreCardLevel] = [];220 }221 //ã¹ã³ã¢ã«ã¼ãã«å
¥ãã222 options.SelectedCard = CurrentGameData.Angel[CurrentGameData.ScoreCardLevel];223 this.superInit(options);224 },225});226//ã¤ã³ãµã¤ãã«ã¼ãfromç¡æèã®å°ç227phina.define('SelectEnvelopeToScoreInsightScene', {228 superClass: 'SelectEnvelopeToScoreScene',229 init: function(options) {230 options = ({}).$safe(options, {231 CardClass : InsightCard,232 Master : i18n.CardInsights,233 OpenMessage : true,234 Deck : CurrentGameData.UnconsciousInsight,235 Message : i18n.SelectedInsightMessage,236 Log : i18n.SelectedInsightLog,237 });238 if (CurrentGameData.ScoreCardLevel == void 0 || CurrentGameData.ScoreCardLevel < 0) {239 CurrentGameData.ScoreCardLevel = 0;240 }241 if (CurrentGameData.TransformInsight[CurrentGameData.ScoreCardLevel] == void 0) {242 CurrentGameData.TransformInsight[CurrentGameData.ScoreCardLevel] = [];243 }244 //ã¹ã³ã¢ã«ã¼ãã«å
¥ãã245 options.SelectedCard = CurrentGameData.TransformInsight[CurrentGameData.ScoreCardLevel];246 this.superInit(options);247 },248});249//ã»ããããã¯ã«ã¼ãfromç¡æèã®å°ç250phina.define('SelectEnvelopeToScoreSetbackScene', {251 superClass: 'SelectEnvelopeToScoreScene',252 init: function(options) {253 options = ({}).$safe(options, {254 CardClass : SetbackCard,255 Master : i18n.CardSetbacks,256 OpenMessage : true,257 Deck : CurrentGameData.UnconsciousSetback,258 Message : i18n.SelectedSetbackMessage,259 Log : i18n.SelectedSetbackLog,260 isNoPain : false,261 });262 if (CurrentGameData.ScoreCardLevel == void 0 || CurrentGameData.ScoreCardLevel < 0) {263 CurrentGameData.ScoreCardLevel = 0;264 }265 if (CurrentGameData.TransformSetback[CurrentGameData.ScoreCardLevel] == void 0 ) {266 CurrentGameData.TransformSetback[CurrentGameData.ScoreCardLevel] = [];267 }268 //ã¹ã³ã¢ã«ã¼ãã«å
¥ãã269 options.SelectedCard = CurrentGameData.TransformSetback[CurrentGameData.ScoreCardLevel];270 this.superInit(options);271 },272});273//ãããé¸æâç¡æèã®å°çã¸274phina.define('SelectDeckToEnvelopeScene', {275 superClass: 'DisplayScene',276 init: function(options) {277 options = ({}).$safe(options, {278 selectNumberOfCards : 1,279 CardClass : '', //ã«ã¼ãã¯ã©ã¹å280 Master: [], //ã«ã¼ãã®ãã¹ã¿å®ç¾©281 Deck: [], //ããã282 UnconsciousEnvelope : [], //é¸æããã«ã¼ããå
¥ãã283 InPlayCard: [], //ãªã¼ãã³ãããã«ã¼ã284 });285 this.superInit(options);286 app.backgroundColor = appBackGroundColor;287 this.selectNumberOfCards = options.selectNumberOfCards;288 var self = this;289 //ã¡ãã»ã¼ã¸ã¦ã¤ã³ãã¦290 var _selectDeckMessage = [];291 _selectDeckMessage[0] = i18n.SelectDeckMessage[0];292 _selectDeckMessage[0] = _selectDeckMessage[0].replace(/α/g,this.selectNumberOfCards);293 this.SelectDeckMessage = MessageWindow({294 texts :_selectDeckMessage,295 x :500,296 y :300,297 width :200,298 height :500,299 buttonAName :i18n.ButtonEndOfSelect,300 buttonWidth: 150,301 }).addChildTo(this);302 this.SelectDeckMessage.ButtonA.setInteractive(false);303 //ãããã®ã«ã¼ãå
¨é¨è¡¨ç¤º304 this._openDeck = DisplayElement().addChildTo(this);305 for (i in options.Deck) {306 options.CardClass({layer:i,id:options.Deck[i]}).setPosition(200,100+i*10).addChildTo(this._openDeck);307 }308 this.SelectDeckMessage.ButtonA.on('push', function(e) {309 self._openDeck.children.each(function(child) {310 if (child.isSelected == true) {311 //é¸ã°ããã«ã¼ããç¡æèã®å°çã¸312 options.UnconsciousEnvelope.push(child.id);313 //é¸ã°ããã«ã¼ãããããããåé¤314 var _delId = options.Deck.indexOf(child.id);315 options.Deck.splice(_delId,1);316 }317 }, self);318 self.app.popScene();319 });320 },321 update: function(e){322 selectCard({deck: this._openDeck,323 selectNumberOfCards:this.selectNumberOfCards,324 interActiveButton:this.SelectDeckMessage.ButtonA,325 delta_x:50,326 });327 },328});329//æ°ã¥ãã®ãã¼ã¯ã³é¸æ330phina.define('SelectTokenAwarenessBoxToScoreScene', {331 superClass: 'SelectTokenBoxToScoreScene',332 init: function(options) {333 //æ°ã¥ãã®ãã¼ã¯ã³ä»¥å¤ãé¸æãããã¨ããã£ãå ´åãèæ
®ãã334 //å®éã«ããããªï¼335 this.superInit(options);336 },337});338//ãã¼ã¯ã³é¸æ339phina.define('SelectTokenBoxToScoreScene', {340 superClass: 'DisplayScene',341 init: function(options) {342 options = ({}).$safe(options, {343 selectNumberOfAwarenessTokens : 1,344 TokenClass : TokenAwareness, //ãã¼ã¯ã³ã¯ã©ã¹å345 Target : '', //èªåã®å ´åã¯''ã¨ããã346 ScoreLevel : CurrentGameData.ScoreCardLevel,347 });348 var _scoreLevel = options.ScoreLevel;349 this.superInit(options);350 //åéæãé¢ç½ãã351// this.backgroundColor = 'rgba(0, 0, 0, 0.7)';352 this.backgroundColor = appBackGroundColor;353 this.selectNumberOfAwarenessTokens = options.selectNumberOfAwarenessTokens;354 if (CurrentGameData.InboxAwareness[_scoreLevel] == void 0) {355 CurrentGameData.InboxAwareness[_scoreLevel] = [];356 }357 this.Inbox = CurrentGameData.InboxAwareness[_scoreLevel];358 this.NowSelectAwareness = []; //ä»åé¸ãã ãã¼ã¯ã³359 this.Target = options.Target;360 this.cbname = options.cbname;361 this._selectedToken = [];362 this.openNumberOfTokens = 0;363 var _Master = TfAp.TokenAwareness[_scoreLevel];364 if (this.Inbox == void 0 || this.Inbox.length == 0) {365 var _Inbox = [];366 for (i in _Master) {367 _Inbox.push(_Master[i].id);368 }369 CurrentGameData.InboxAwareness[_scoreLevel] = _Inbox.shuffle();370 this.Inbox = CurrentGameData.InboxAwareness[_scoreLevel];371 }372 //ãã¨ããã¢ãã¡ã¼ã·ã§ã³ããããã«é¸ã°ãã¦ãªããªãã¸ã§ã¯ããã°ã«ã¼ãåãã373 var nonSelectObjects = DisplayElement().addChildTo(this);374 var self = this;375 //ã¡ãã»ã¼ã¸ã¦ã¤ã³ãã¦376 var _selectTokenMessage = i18n.SelectTokenAndPushButtonMessage;377 _selectTokenMessage = _selectTokenMessage.replace(/α/g,this.selectNumberOfAwarenessTokens);378 this.SelectTokenMessage = MessageWindow({379 texts :[_selectTokenMessage],380 x :320,381 y :100,382 width :500,383 height :100,384 buttonAName :i18n.ButtonEndOfSelect,385 buttonWidth: 150,386 }).addChildTo(this);387 this.SelectTokenMessage.ButtonA.setInteractive(true);388 //é¸æã¨ãªã¢è¡¨ç¤º389 this.AreaSelectedTokens = AreaSelectedTokens().addChildTo(nonSelectObjects);390 //ãã³ã®ãã¼ã¯ã³å
¨é¨è¡¨ç¤º391 this._openToken = DisplayElement().addChildTo(this);392 //ãã¼ã¯ã³é
åå®ç¾©393 this._Token = [];394 for (i in this.Inbox) {395 this._Token.push(396 options.TokenClass({layer:i,id:this.Inbox[i],ratio:0.55,397 x : Random.randint(100,600),398 y : Random.randint(400,900),399 rotation : Random.randint(0,359),400 level : _scoreLevel,401 })402 );403 this._Token[i].addChildTo(this._openToken);404 }405 this.SelectTokenMessage.ButtonA.on('push', function(e) {406 var _tempNonSelectToken = []; //éé¸æãã¼ã¯ã³407 //ã¾ãã¯ææ°ãå¤å®408 var _checkSelectedCards = 0;409 self._Token.each(function(child) {410 if(self.AreaSelectedTokens.hitTestElement(child)){411 _checkSelectedCards = _checkSelectedCards + 1;412 }413 });414 //ææ°ä¸ä¸è´ãªã以ä¸ã®å¦çã¯è¡ããªã415 if (_checkSelectedCards != self.selectNumberOfAwarenessTokens) return;416 //ããããæ¬æ ¼çãªå¦ç417 self.SelectTokenMessage.ButtonA.setInteractive(false);418 var _selectedCards = 0;419 self._Token.each(function(child) {420 if(self.AreaSelectedTokens.hitTestElement(child)){421 _selectedCards = _selectedCards + 1;422 //é¸ã°ãããã¼ã¯ã³ã®IDãç»é²423 self.NowSelectAwareness.push(child.id);424 //ã¿ã¼ã²ããã空ç½(èªå)ãªãé¸æçµæãCurrentGameDataã«åæ 425 if (CurrentGameData.Awareness[_scoreLevel] == void 0) {426 CurrentGameData.Awareness[_scoreLevel] = [];427 }428 if (options.Target == void 0 || options.Target == '') {429 CurrentGameData.Awareness[_scoreLevel].push(child.id);430 }431 //é¸ã°ãããã¼ã¯ã³ãªãã¸ã§ã¯ããç»é²432 self._selectedToken.push(child);433 //表示ã§æ®ãããåå®ç¾©434 child.addChildTo(self);435 //è£è¿ãåã«ä½ç½®ã移å436 child.tweener.to({437 rotation:0,438 x : 220+120*((_selectedCards-1)%3),439 y : 100+150*((_selectedCards-1)<3?0:1),440 width : 100,441 height : 140,442 ratio : 0.8,443 },1000,"swing");444 } else {445 _tempNonSelectToken.push(child.id);446 }447 });448 //ä»ã®ãã¼ã¯ã³ãã¹ã¦éé¸æãªãã¸ã§ã¯ãã«449 self._openToken.addChildTo(nonSelectObjects);450 //é¸æçµæãCurrentGameDataã«åæ 451 CurrentGameData.InboxAwareness[_scoreLevel] = _tempNonSelectToken;452 //ã¡ãã»ã¼ã¸ã¨ãªã¢ãé表示ã¸453 self.SelectTokenMessage.hide();454 //é¸æãã¦ãªããã¼ã¯ã³ã¯ä¸ã¸ã¹ã¯ãã¼ã«455 nonSelectObjects.tweener.by({456 y:1000,457 },1000,"swing")458 .wait(1000)459 .call(function(){460 self.SelectTokenMessage = MessageWindow({461 texts :[i18n.ClickCardAndTurnOverMessage,],462 x :350,463 y :600,464 width :400,465 height :200,466 buttonWidth :150,467 }).addChildTo(self);468 //ããã§ã¤ãã³ãã¯ã¨ãã469 for (var _id = 0;_id < self._selectedToken.length;_id++) {470 self._selectedToken[_id].one('pointend', function(e) {471 this.openFace(e);472 self.flare('visibleButton',{message:this.getMessage(),meaning:this.getMeaning()});473 });474 }475 });476 });477 this.on('visibleButton', function(options) {478 self.openNumberOfTokens = self.openNumberOfTokens + 1;479 self.SelectTokenMessage.texts = [options.message+'\n'+options.meaning];480 self.SelectTokenMessage.showAllText();481 if (self.openNumberOfTokens >= self.selectNumberOfAwarenessTokens) {482 this.buttonEnd.show();483 if (self.Target == void 0 || self.Target == '') {484 self.SelectTokenMessage.texts = [options.message+'\n'+options.meaning+'\n\n'+i18n.MoveTokenToScoreCard];485 } else {486 self.SelectTokenMessage.texts = [options.message+'\n'+options.meaning+'\n\n'+self.Target + i18n.MoveTokenToTarget];487 }488 self.SelectTokenMessage.showAllText();489 }490 });491 this.buttonEnd = Button({492 text: i18n.ButtonBack,493 x: 350,494 y: 350,495 fill: 'purple',496 width: 100,497 height: 45,498 }).addChildTo(this).hide();499 this.buttonEnd.on('push' , function(options) {500 //ãã°ã«æ¸ãè¾¼ã501 var _tempLogging = '';502 if (self.Target == void 0 || self.Target == '') {503 _tempLogging = ScoreCardNames[_scoreLevel] + i18n.OnLevel + i18n.GetToken + ':';504 } else {505 _tempLogging = ScoreCardNames[_scoreLevel] + i18n.GivenToken +self.Target + ']:';506 };507 self._selectedToken.forEach(function(val,_id,array) {508 if (_id>0) {_tempLogging = _tempLogging + ','};509 _tempLogging = _tempLogging + val.getMessage();510 if (CurrentGameData.Language!='EN') {_tempLogging = _tempLogging + 'ï¼' +val.getMeaning() + 'ï¼';};511 });512 513 CurrentGameData.Scene = 'MainBoard';514 TfAp.WriteGameLog(_tempLogging);515 TfAp.saveGameData();516 app.flare(self.cbname);517 app.popScene();518 });519 },520 update: function(e){521 moveToken({Token: this._openToken,});522 },523});524phina.define('AreaSelectedTokens', {525 superClass: 'RectangleShape',526 init: function(options) {527 options = ({}).$safe(options, {528 x :320,529 y :240,530 width: 540,531 height: 120,532 backgroundColor: '#E8CFE8',533 stroke: '#E8CFE8',534 fill: 'white',535 strokeWidth: 4,536 cornerRadius: 4,537 });538 this.superInit(options);539 var label = Label({540 text :i18n.SelectArea,541 align :'Left',542 fontColor :'black',543 fontSize :16,544 x :-255,545 y :-40,546 }).addChildTo(this);547 },548});549//è¦ãç®ãä¸çªä¸ã®ãã¼ã¯ã³ã移åããå¦ç550var moveToken = function(options) {551 options = ({}).$safe(options, {552 Token: [],553 });554 //ä¸çªæåï¼ã«è¦ããï¼ã«ã¼ããå¤å®ããããã®å¤æ°555 var _maxlayer = -1;556 //åãªãã¸ã§ã¯ãã®pointoverãåå¾ããã¨éãªã£ããªãã¸ã§ã¯ããã¹ã¦åå¿ãããã557 //selectedãã¦ããobjectã®ãã¡idã®æ大ãåå¾558 options.Token.children.each(function(child) {559 if (child.isMoving == true && _maxlayer < child.layer) {560 _maxlayer = child.layer;561 }562 }, this);563 if (_maxlayer != -1) {564 //ä¸çªæåï¼ã«è¦ããï¼ã«ã¼ãã®ã¿å¦çãã565 options.Token.children[_maxlayer].moveSelected(options);566 }567 for (var k = 0;k < options.Token.children.length; k++) {568 //ä¸éãå¦çãçµããã®ã§ãã¹ã¦ã®é¸æä¸ç¶æ
ã¯è§£é¤569 options.Token.children[k].isMoving = false570 }571}572//ã¦ããã¼ãµã«ãã£ã¼ãããã¯ãããé¸æï¼toã¹ã³ã¢ã«ã¼ãï¼573phina.define('SelectDeckToScoreUniversalFeedbackScene', {574 superClass: 'SelectDeckToScoreScene',575 init: function(options) {576 options = ({}).$safe(options, {577 CardClass : UniversalFeedbackCard,578 Master : i18n.CardUniversalFeedbacks,579 Transform : 'Feedback',580 Log : i18n.SelectedDeckUniversalFeedbackLog,581 Message : i18n.SelectedDeckUniversalFeedbackMessage,582 OpenMessage : true,583 });584 //ã¦ããã¼ãµã«ãã£ã¼ãããã¯ã ãã¯å¸¸ã«ãããã«å
¨æ°ãã常ã«ã·ã£ããã«585 var _deck = [];586 for (i in options.Master) {587 _deck.push(options.Master[i].id);588 }589 options.Deck = _deck.shuffle();590 if (CurrentGameData.ScoreCardLevel == void 0 || CurrentGameData.ScoreCardLevel < 0) {591 CurrentGameData.ScoreCardLevel = 0;592 }593 if (CurrentGameData.TransformFeedback[CurrentGameData.ScoreCardLevel] == void 0) {594 CurrentGameData.TransformFeedback[CurrentGameData.ScoreCardLevel] = [];595 }596 //ã¹ã³ã¢ã«ã¼ãã«å
¥ãã597 options.SelectedCard = CurrentGameData.TransformFeedback[CurrentGameData.ScoreCardLevel];598 this.superInit(options);599 },600});601//ã¤ã³ãµã¤ããããé¸ætoã¹ã³ã¢ã«ã¼ã602phina.define('SelectDeckToScoreInsightScene', {603 superClass: 'SelectDeckToScoreScene',604 init: function(options) {605 options = ({}).$safe(options, {606 Transform : 'Insight',607 CardClass : InsightCard,608 Master : i18n.CardInsights,609 OpenMessage : true,610 Message : i18n.SelectedInsightMessage,611 Log : i18n.SelectedInsightLog,612 });613 if (CurrentGameData.DeckInsight == void 0 || CurrentGameData.DeckInsight.length == 0) {614 var _deck = [];615 for (i in options.Master) {616 _deck.push(options.Master[i].id);617 }618 CurrentGameData.DeckInsight = _deck.shuffle();619 }620 options.Deck = CurrentGameData.DeckInsight;621 if (CurrentGameData.ScoreCardLevel == void 0 || CurrentGameData.ScoreCardLevel < 0) {622 CurrentGameData.ScoreCardLevel = 0;623 }624 if (CurrentGameData.TransformInsight[CurrentGameData.ScoreCardLevel] == void 0 ) {625 CurrentGameData.TransformInsight[CurrentGameData.ScoreCardLevel] = [];626 }627 //ã¹ã³ã¢ã«ã¼ãã«å
¥ãã628 options.SelectedCard = CurrentGameData.TransformInsight[CurrentGameData.ScoreCardLevel];629 this.superInit(options);630 },631});632//ã»ããããã¯ãããé¸ætoã¹ã³ã¢ã«ã¼ã633phina.define('SelectDeckToScoreSetbackScene', {634 superClass: 'SelectDeckToScoreScene',635 init: function(options) {636 options = ({}).$safe(options, {637 Transform : 'Setback',638 CardClass : SetbackCard,639 Master : i18n.CardSetbacks,640 OpenMessage : true,641 Message : i18n.SelectedSetbackMessage,642 Log : i18n.SelectedSetbackLog,643 isNoPain : false,644 });645 if (CurrentGameData.DeckSetback == void 0 || CurrentGameData.DeckSetback.length == 0) {646 var _deck = [];647 for (i in options.Master) {648 _deck.push(options.Master[i].id);649 }650 CurrentGameData.DeckSetback = _deck.shuffle();651 }652 options.Deck = CurrentGameData.DeckSetback;653 if (CurrentGameData.ScoreCardLevel == void 0 || CurrentGameData.ScoreCardLevel < 0) {654 CurrentGameData.ScoreCardLevel = 0;655 }656 if (CurrentGameData.Setback[CurrentGameData.ScoreCardLevel] == void 0) {657 CurrentGameData.Setback[CurrentGameData.ScoreCardLevel] = [];658 }659 //ã¹ã³ã¢ã«ã¼ãã«å
¥ãã660 options.SelectedCard = CurrentGameData.Setback[CurrentGameData.ScoreCardLevel];661 this.superInit(options);662 },663});664//天使ãããé¸ætoã¹ã³ã¢ã«ã¼ã665phina.define('SelectDeckToScoreAngelScene', {666 superClass: 'SelectDeckToScoreScene',667 init: function(options) {668 options = ({}).$safe(options, {669 Transform : 'Angel',670 CardClass : AngelCard,671 Master : i18n.CardAngels,672 OpenMessage : true,673 Message : i18n.SelectedAngelMessage + i18n.SelectedAngelAfterMessage,674 Log : i18n.SelectedAngelLog,675 });676 if (CurrentGameData.DeckAngel == void 0 || CurrentGameData.DeckAngel.length == 0) {677 var _deck = [];678 for (i in options.Master) {679 _deck.push(options.Master[i].id);680 }681 CurrentGameData.DeckAngel = _deck.shuffle();682 }683 options.Deck = CurrentGameData.DeckAngel;684 if (CurrentGameData.ScoreCardLevel == void 0 || CurrentGameData.ScoreCardLevel < 0) {685 CurrentGameData.ScoreCardLevel = 0;686 }687 if (CurrentGameData.Angel[CurrentGameData.ScoreCardLevel] == void 0) {688 CurrentGameData.Angel[CurrentGameData.ScoreCardLevel] = [];689 }690 //ã¹ã³ã¢ã«ã¼ãã«å
¥ãã691 options.SelectedCard = CurrentGameData.Angel[CurrentGameData.ScoreCardLevel];692 this.superInit(options);693 },694});695//é¸æå
ããã¹ã³ã¢ã«ã¼ãã¸è¨é²ããã·ã¼ã³ï¼æ½è±¡ã¯ã©ã¹ï¼696phina.define('SelectToScoreScene', {697 superClass: 'DisplayScene',698 init: function(options) {699 options = ({}).$safe(options, {700 selectNumberOfCards : 1,701 CardClass : '', //ã«ã¼ãã¯ã©ã¹å702 Master: [], //ã«ã¼ãã®ãã¹ã¿å®ç¾©703 Deck: [], //ããã704 SelectedCard: [], //ã«ã¼ãæ ¼ç´å ´æï¼LvXAngel,LvXSetback,LvXTransformInsight,LvXTransformFeedbackï¼705 OpenMessage : false, //é¸æå¾ãã¡ãã»ã¼ã¸ãã«ã¼ãã«è¡¨ç¤ºãããã©ãã706 SelectFrom : 'Deck', //ã©ãããé¸æããã(Deck or Envelope)707 isNoPain: false, //åºæ¬çã«çã¿ããï¼falseï¼708 cbname : '', //æ»ãå
ã®ã¤ãã³ãå709 });710 this.superInit(options);711 var self = this;712 this.backgroundColor = appBackGroundColor;713 this.selectNumberOfCards = options.selectNumberOfCards;714 this.CardClass = options.CardClass;715 this.SelectedCard = options.SelectedCard;716 this.cardSelected = false;717 this.Log = options.Log;718 this.selectedMessage = options.Message;719 this.causeEvents = [];720 this.OpenMessage = options.OpenMessage;721 this.activeUpdate = true;722 this.selectId = -1;723 this.SelectFrom = options.SelectFrom=='Deck'?'Deck':'Envelope';724 this.Transform = options.Transform;725 this.isNoPain = options.isNoPain;726 this.cbname = options.cbname;727 this._lockCard = false;728 this.openNumberOfCards = 0;729 //ãã¨ããã¢ãã¡ã¼ã·ã§ã³ããããã«é¸ã°ãã¦ãªããªãã¸ã§ã¯ããã°ã«ã¼ãåãã730 var nonSelectObjects = DisplayElement().addChildTo(this);731 //å°çããã®é¸æã®å ´åãèæ¯ã«å°çã表示ãã732 if (this.SelectFrom == 'Envelope') {733 var ImageEnvelope = Sprite('envelope').setSize(550,600).setPosition(320,400).addChildTo(nonSelectObjects);734 }735 //ã¡ãã»ã¼ã¸ã¦ã¤ã³ãã¦736 var _selectDeckMessage = [];737 _selectDeckMessage[0] = i18n.SelectDeckMessage[0];738 _selectDeckMessage[0] = _selectDeckMessage[0].replace(/α/g,this.selectNumberOfCards);739 if (this.SelectFrom == 'Envelope') {740 this.SelectDeckMessage = MessageWindow({741 texts :_selectDeckMessage,742 x :320,743 y :750,744 width :600,745 height :350,746 buttonAName :i18n.ButtonEndOfSelect,747 buttonWidth :150,748 }).addChildTo(this);749 } else {750 this.SelectDeckMessage = MessageWindow({751 texts :_selectDeckMessage,752 x :500,753 y :500,754 width :200,755 height :500,756 buttonAName :i18n.ButtonEndOfSelect,757 buttonWidth :150,758 }).addChildTo(this);759 }760 this.SelectDeckMessage.ButtonA.setInteractive(false);761 //this.SelectFromã®ã«ã¼ããã¹ã¦è¡¨ç¤º762 this._openDeck = DisplayElement().addChildTo(this);763 //å¦çé½åä¸é¸ã°ããã«ã¼ããã©ãããææ¡ããå¿
è¦ãããããé
å_deckCardãå®ç¾©764 this._deckCard = [];765 for (i in options.Deck) {766 if (this.SelectFrom == 'Envelope') {767 this._deckCard[i] = options.CardClass({layer:i,id:options.Deck[i],isFace:false,Master:options.Master}).setPosition((350-(options.Deck.length/2)*50)+i*50,(400-(options.Deck.length/2)*30)+i*30).addChildTo(this._openDeck);768 } else {769 this._deckCard[i] = options.CardClass({layer:i,id:options.Deck[i],isFace:false,Master:options.Master}).setPosition(200,100+i*10).addChildTo(this._openDeck);770 }771 }772 this.SelectDeckMessage.ButtonA.on('push', function(e) {773 var _selectedCard = [];774 //ã«ã¼ããé¸ã³çµãã£ãã®ã§updateã®å¦çã¯æ¢ãã775 self.activeUpdate = false;776 //é¸æãããã«ã¼ããå¤å®777 for (var _id = 0;_id < self._deckCard.length;_id++) {778 if (self._deckCard[_id].isSelected == true) {779 //ã¦ããã¼ãµã«ãã£ã¼ãããã¯ä»¥å¤ã¯ãããããæã780 if (options.Transform != 'Feedback') {781 options.Deck.splice(_id,1);782 }783 //é¸æããã«ã¼ãã«å
¥ãã784 self.SelectedCard.push(self._deckCard[_id].id);785 self.selectId = _id;786 _selectedCard.push(self._deckCard[_id]);787 } else {788 //é¸æãããªãã£ããªãã¸ã§ã¯ãã«ç»é²789 self._deckCard[_id].addChildTo(nonSelectObjects);790 }791 }792 //é¸æããææ°ã«ããé
ç½®ãå¤ãã793 var _selectedCards = 0;794 _selectedCard.each(function(child) {795 var _px = 0;796 _selectedCards = _selectedCards + 1;797 switch (self.selectNumberOfCards) {798 case 3:799 _px = 180+130*((_selectedCards-1)%3);800 break;801 case 2:802 _px = 240+130*((_selectedCards-1)%2);803 break;804 default :805 _px = 320;806 }807 child.tweener.to({808 x : _px,809 y : 250,810 },1000,"swing");811 });812 self.SelectDeckMessage.remove();813 //é¸æãã¦ãªãã«ã¼ãã¨å°çã¯ä¸ã¸ã¹ã¯ãã¼ã«814 nonSelectObjects.tweener.by({815 y:1000,816 },1000,"swing")817 .wait(1000)818 .call(function(){819 self.cardSelected = true;820 self.SelectDeckMessage = MessageWindow({821 texts :[i18n.ClickCardAndTurnOverMessage,],822 x :320,823 y :700,824 width :600,825 height :500,826 buttonWidth: 150,827 }).addChildTo(self);828 for (var _id = 0;_id < _selectedCard.length;_id++) {829 _selectedCard[_id].on('pointend', function(e) {830 if (self._lockCard == false && this.isOpen == false) {831 this.openFace(e);832 self.openSelectCard(this);833 self._lockCard = true;834 }835 });836 }837 }); //call838 });839 this.on('doneSelectCard', function(options) {840 self.exit();841 //ã«ã¼ããé¸ãã å¾ã®ã¤ãã³ããããã·ã¼ã³ç¨ï¼ä¾ï¼SquereFreewillSceneï¼842 app.flare(self.cbname);843 });844 },845 openSelectCard : function(opt) {846 var _selCard = opt;847 var _log = this.Log;848 849 this.causeEvents = [];850 //éããã«ã¼ãæ°ï¼ï¼851 this.openNumberOfCards++;852 _log = _log853 .replace(/α/g,_selCard.getMessage())854 .replace(/β/g,_selCard.getMeaning())855 .replace(/γ/g,(this.SelectFrom=='Deck'?i18n.Deck:i18n.Envelope));856 CurrentGameData.Scene = 'MainBoard';857 TfAp.WriteGameLog(_log);858 TfAp.saveGameData();859 var _selectDeckMessage = [];860 _selectDeckMessage[0] = this.selectedMessage861 .replace(/α/g,_selCard.getMessage())862 .replace(/β/g,_selCard.getMeaning())863 .replace(/γ/g,(this.SelectFrom=='Deck'?i18n.Deck:i18n.Envelope));864 //æ°ã¥ãã®ãã¼ã¯ã³ææ°è¡¨ç¤º865 var _getTokenAwareness = _selCard.getTokenAwareness();866 if (_getTokenAwareness > 0) {867 _selectDeckMessage[0] = _selectDeckMessage[0] + i18n.SelectedInsightGetTokenMessage.replace(/#Awareness#/g,_getTokenAwareness);868 this.causeEvents.push({Event:'AwarenessBoxToScore',selectNumberOfCards : _getTokenAwareness}); }869 //失ããã¼ã¯ã³870 if (_getTokenAwareness < 0) {871 _selectDeckMessage[0] = _selectDeckMessage[0] + i18n.SelectedInsightLostTokenMessage.replace(/#Awareness#/g,_getTokenAwareness*-1);872 this.causeEvents.push({Event:'AwarenessScoreToBox',selectNumberOfCards : _getTokenAwareness*-1});873 }874 //ããã¿ã®ãã¼ã¯ã³ææ°è¡¨ç¤º875 var _getTokenPain = _selCard.getTokenPain();876 if (_getTokenPain > 0) {877 if(this.isNoPain) {878 _selectDeckMessage[0] = _selectDeckMessage[0] + i18n.SelectedSetbackButNoPainMessage.replace(/#Pain#/g,_getTokenPain);879 } else {880 _selectDeckMessage[0] = _selectDeckMessage[0] + i18n.SelectedSetbackGetTokenMessage.replace(/#Pain#/g,_getTokenPain);881 this.causeEvents.push({Event:'PainBoxToScore',selectNumberOfCards : _getTokenPain, CardId:_selCard.id,});882 }883 } else if (_getTokenPain > 0) {884 _selectDeckMessage[0] = _selectDeckMessage[0] + i18n.ChanceClearPainMessage.replace(/#Pain#/g,_getTokenPain*-1);885 this.causeEvents.push({Event:'PainScoreToBox',selectNumberOfCards : _getTokenPain*-1,});886 } else {887 }888 //ãµã¼ãã¹ãã¼ã¯ã³ææ°è¡¨ç¤º889 var _getTokenService = _selCard.getTokenService();890 if (_getTokenService != 0) {891 _selectDeckMessage[0] = _selectDeckMessage[0].replace(/#Service#/g,_getTokenService);892 this.causeEvents.push({Event:'ServiceToScore',selectNumberOfCards : _getTokenService});893 }894 //天使ææ°è¡¨ç¤º895 var _getCardAngel = _selCard.getCardAngel();896 if (_getCardAngel != 0) {897 _selectDeckMessage[0] = _selectDeckMessage[0].replace(/#Angel#/g,_getCardAngel);898 this.causeEvents.push({Event:'Angel',selectNumberOfCards : _getCardAngel});899 }900 //ã¤ã³ãµã¤ãææ°è¡¨ç¤º901 var _getCardInsight = _selCard.getCardInsight();902 if (_getCardInsight != 0) {903 _selectDeckMessage[0] = _selectDeckMessage[0].replace(/#Insight#/g,_getCardInsight);904 this.causeEvents.push({Event:'Insight',selectNumberOfCards : _getCardInsight});905 }906 //ã»ããããã¯ææ°è¡¨ç¤º907 var _getCardSetback = _selCard.getCardSetback();908 if (_getCardSetback != 0) {909 _selectDeckMessage[0] = _selectDeckMessage[0].replace(/#Setback#/g,_getCardSetback);910 this.causeEvents.push({Event:'Setback',selectNumberOfCards : _getCardSetback});911 }912 //ã¬ãã«913 var _getLevel = _selCard.getLevel();914 if (_getLevel > 0) {915 _selectDeckMessage[0] = _selectDeckMessage[0].replace(/#_Level#/g,_getLevel);916 this.causeEvents.push({Event:'LevelUp', NumberOfLevels: _getLevel});917 } else if (_getLevel < 0) {918 _selectDeckMessage[0] = _selectDeckMessage[0].replace(/#_Level#/g,_getLevel*-1);919 this.causeEvents.push({Event:'LevelDown', NumberOfLevels: _getLevel*-1});920 }921 //移å922 var _getMove = _selCard.getMove();923 if (_getMove != '') {924 _selectDeckMessage[0] = _selectDeckMessage[0].replace(/#Move#/g,_getMove);925 this.causeEvents.push({Event:'Move', MoveSquere: _getMove});926 }927 if (this.OpenMessage) {928 this.SelectDeckMessage = MessageWindow({929 texts :_selectDeckMessage,930 x :320,931 y :700,932 width :600,933 height :500,934 buttonAName :i18n.ButtonNext,935 buttonWidth : 300,936 }).addChildTo(this);937 }938 var self = this;939 var _causeEvents = self.causeEvents;940 _causeEvents.reverse();941 this.SelectDeckMessage.ButtonA.on('push', function(e) {942 this.hide();943 this.setInteractive(false);944 //ã«ã¼ãããªã¼ãã³ãã¦ã追å ã¤ãã³ãããªãã¨ãã¯ããã§çµäº945 //ä¾ï¼ã¨ã³ã¸ã§ã«ã«ã¼ããå¼ãï¼ãããã次ã®ã¤ãã³ãã¯ãªãï¼946 if (_causeEvents.length == 0) {947 if (self.selectNumberOfCards <= self.openNumberOfCards) {948 self.flare('doneSelectCard');949 } else {950 self._lockCard = false;951 }952 return;953 }954 var flows = [];955 _causeEvents.forEach (function(value,index,array) {956 var _cbname = TfAp.doneFlareName();957 flows.push(958 Flow(function(resolve) {959 switch (array[index].Event) {960 case 'AwarenessBoxToScore':961 self.app.pushScene(SelectTokenAwarenessBoxToScoreScene({selectNumberOfAwarenessTokens: array[index].selectNumberOfCards,cbname:_cbname,}));962 break;963 case 'AwarenessScoreToBox':964 self.app.pushScene(SelectTokenAwarenessScoreToBoxScene({selectNumberOfAwarenessTokens: array[index].selectNumberOfCards,cbname:_cbname,}));965 break;966 case 'PainScoreToBox':967 self.app.pushScene(AmimateClearPainScene({numberOfDepressionTokens:array[index].selectNumberOfCards,cbname:_cbname,}));968 break;969 case 'PainBoxToScore':970 self.app.pushScene(AmimateDepressionScene({numberOfDepressionTokens:array[index].selectNumberOfCards,cbname:_cbname,CardId:array[index].CardId,PutPainScene:'Setback',}));971 break;972 case 'LevelUp':973 self.app.pushScene(LevelUpSceneSequence({isExit: true, cbname:_cbname,}));974 break;975 case 'LevelDown':976 self.app.pushScene(LevelDownSceneSequence({isExit: true, cbname:_cbname,}));977 break;978 case 'Move':979 self.app.pushScene(MoveSquereSceneSequence({conditions: array[index].MoveSquere, cbname:_cbname,}));980 break;981 case 'ServiceToScore':982 self.app.pushScene(AmimateGetServiceTokenScene({Reason: 'From Card', cbname:_cbname,}));983 break;984 default:985 self.app.pushScene(SelectCardScene({selectCard:array[index].Event,selectNumberOfCards:array[index].selectNumberOfCards,cbname:_cbname}));986 }987 self.app.on(_cbname, function(e) {988 if (self.selectNumberOfCards <= self.openNumberOfCards) {989 resolve(array[index].Event + ' done');990 } else {991 self._lockCard = false;992 self.SelectDeckMessage.texts = [i18n.TurnOverNextCardMessage];993 }994 }); //self.on995 }) //Flow996 ); //push997 }); //_cause998 Flow.all(flows).then(function(messages) {999 self.app.one('poped', function(e) {1000 self.flare('doneSelectCard');1001 });1002 });1003 });1004 },1005 update: function(e){1006 if (this.activeUpdate == true && this.cardSelected == false) {1007 selectCard({deck: this._openDeck,1008 selectNumberOfCards:this.selectNumberOfCards,1009 interActiveButton:this.SelectDeckMessage.ButtonA,1010 delta_x:this.SelectFrom=='Envelope'?0:50,1011 delta_y:this.SelectFrom=='Envelope'?-200:0,1012 });1013 } else {1014 }1015 },1016});1017//å°çé¸æâã¹ã³ã¢ã«ã¼ãã¸ï¼æ大3æï¼1018phina.define('SelectEnvelopeToScoreScene', {1019 superClass: 'SelectToScoreScene',1020 init: function(options) {1021 options = ({}).$safe(options, {1022 selectNumberOfCards : 1,1023 CardClass : '', //ã«ã¼ãã¯ã©ã¹å1024 Master: [], //ã«ã¼ãã®ãã¹ã¿å®ç¾©1025 Deck: [], //ããã1026 OpenMessage : false, //é¸æå¾ãã¡ãã»ã¼ã¸ãã«ã¼ãã«è¡¨ç¤ºãããã©ãã1027 SelectedCard: [], //é¸æããã«ã¼ããå
¥ãã1028 SelectFrom : 'Envelope' //ã©ãããé¸æããã(Deck or Envelope)1029 });1030 this.superInit(options);1031 },1032});1033//ãããé¸æâã¹ã³ã¢ã«ã¼ãã¸ï¼æ大3æï¼1034phina.define('SelectDeckToScoreScene', {1035 superClass: 'SelectToScoreScene',1036 init: function(options) {1037 options = ({}).$safe(options, {1038 selectNumberOfCards : 1,1039 CardClass : '', //ã«ã¼ãã¯ã©ã¹å1040 Master: [], //ã«ã¼ãã®ãã¹ã¿å®ç¾©1041 Deck: [], //ããã1042 SelectedCard: [], //ã«ã¼ãæ ¼ç´å ´æï¼LvXAngel,LvXSetback,LvXTransformInsight,LvXTransformFeedbackï¼1043 OpenMessage : false, //é¸æå¾ãã¡ãã»ã¼ã¸ãã«ã¼ãã«è¡¨ç¤ºãããã©ãã1044 SelectFrom : 'Deck' //ã©ãããé¸æããã(Deck or Envelope)1045 });1046 this.superInit(options);1047 },1048});1049//é¸æè¢é¸æ1050phina.define('SelectOptionScene', {1051 superClass: 'DisplayScene',1052 init: function(options) {1053 options = ({}).$safe(options, {1054 messages : [i18n.AfterSelectionAndDecision,],1055 buttonLabel:i18n.Decision,1056 opts : [{id:0,value:i18n.Envelope+i18n.From},{id:1,value:i18n.Deck+i18n.From}],1057 });1058 this.superInit(options);1059 this.backgroundColor = appBackGroundColor;1060 var self = this;1061 var _buttonOptions = {height :40,1062 width :580,1063 align: 'left',1064 fontColor :'black',1065 fontWeight:'bold',1066 fill :'#E8CFE8',1067 stroke :'purple',1068 strokeWidth : 3,1069 fontFamily:'monospace',1070 fontSize :20};1071 //ã¡ãã»ã¼ã¸ã¦ã¤ã³ãã¦1072 this.MessageWindow = MessageWindow({1073 texts :options.messages,1074 x :320,1075 y :100,1076 width :560,1077 height :160,1078 buttonAName :options.buttonLabel,1079 showButtonA :true,1080 }).addChildTo(this);1081 this.MessageWindow.ButtonA.setInteractive(false);1082 this.MessageWindow.ButtonA.on('push', function(e) {1083 TfAp.SelectedOptId = self.selected;1084// self.app.flare('SelectedOption');1085 self.exit();1086 });1087 this.button = [];1088 var buttonId = 0;1089 this.selected = -1;1090 options.opts.forEach (function(val,idx,array) {1091 self.button[buttonId] = Button(({}).$safe(_buttonOptions, {text:val.value})).setPosition(320,250+buttonId*50).addChildTo(self);1092 if (val.enable == false) {1093 self.button[buttonId].fill = 'gray';1094 self.button[buttonId].fontColor = 'darkgray';1095 self.button[buttonId].setInteractive(false);1096 }1097 self.button[buttonId].on('push', function(e) {1098 self.selected = val.id;1099 self.flare('selectButton');1100 });1101 buttonId = buttonId + 1;1102 });1103 this.on('selectButton', function(e) {1104 for (var buttonId=0; buttonId< options.opts.length;buttonId++) {1105 if (self.selected == buttonId && self.button[buttonId].fontColor == 'black') {1106 self.button[buttonId].fill = 'purple';1107 self.button[buttonId].fontColor = 'white';1108 self.MessageWindow.ButtonA.setInteractive(true);1109 } else if (self.selected == buttonId) {1110 self.button[buttonId].fill = '#E8CFE8';1111 self.button[buttonId].fontColor = 'black';1112 self.MessageWindow.ButtonA.setInteractive(false);1113 self.selected = -1;1114 } else if (self.button[buttonId].fontColor == 'darkgray') {1115 //ä½ãããªã1116 } else {1117 self.button[buttonId].fill = '#E8CFE8';1118 self.button[buttonId].fontColor = 'black';1119 }1120 };1121 });1122 },1123});1124//ã«ã¼ããå¼ãï¼ããããå°çããé¸æï¼1125phina.define('SelectCardScene', {1126 superClass: 'DisplayScene',1127 init: function(options) {1128 options = ({}).$safe(options, {1129 selectNumberOfCards : 5,1130 selectCard : 'Angel',1131 });1132 this.superInit(options);1133 this.backgroundColor = appBackGroundColor;1134 this.cbname = options.cbname;1135 this.Transform = options.selectCard;1136 switch (options.selectCard) {1137 case 'Angel':1138 this.SceneDeck = SelectDeckToScoreAngelScene;1139 this.SceneEnvelope =SelectEnvelopeToScoreAngelScene;1140 break;1141 case 'Insight':1142 this.SceneDeck = SelectDeckToScoreInsightScene;1143 this.SceneEnvelope =SelectEnvelopeToScoreInsightScene;1144 break;1145 case 'Setback':1146 default :1147 this.SceneDeck = SelectDeckToScoreSetbackScene;1148 this.SceneEnvelope =SelectEnvelopeToScoreSetbackScene;1149 }1150 this.selectNumberOfCards = options.selectNumberOfCards;1151 var self = this;1152 var _tmp = 'Unconscious' + options.selectCard;1153 if (CurrentGameData[_tmp] == void 0 ) {1154 //ç¡æèã®å°çããã§ã«ç©ºç½ã®å¯è½æ§ãããã1155 CurrentGameData[_tmp] = [];1156 }1157 var _unconsciousInEnvelope = i18n.UnconsciousInEnvelope;1158 _unconsciousInEnvelope = _unconsciousInEnvelope.replace(/α/g,options.selectCard);1159 options.messages = [i18n.AfterSelectionAndDecision + '\n' + _unconsciousInEnvelope + CurrentGameData[_tmp].length,];1160 //é¸æè¢ã®ä½æ1161 options.opts = [];1162 var _enable = false;1163 for (var i=0;i<this.selectNumberOfCards+1;i++) {1164 _preFix = this.selectNumberOfCards==1?'':i18n.All1165 _enable = this.selectNumberOfCards-1-i<CurrentGameData[_tmp].length?true:false;1166 switch (i) {1167 case 0:1168 //ãã¹ã¦å°çãã1169 options.opts.push({id:i,value:_preFix+i18n.Envelope+i18n.From,enable:_enable});1170 break;1171 case this.selectNumberOfCards:1172 //ãã¹ã¦ããããã1173 options.opts.push({id:i,value:_preFix+i18n.Deck+i18n.From,enable:true});1174 break;1175 default:1176 //å°çããxæããããããyæ(i18n.From take x unit)1177 options.opts.push({id:i,value:i18n.Envelope+i18n.From+(this.selectNumberOfCards-i)+i18n.UnitOfCard+'ã'+i18n.Deck+i18n.From+i+i18n.UnitOfCard,enable:_enable});1178 }1179 }1180 //ã¡ãã»ã¼ã¸ã¦ã¤ã³ãã¦1181 this.MessageWindow = MessageWindow({1182 texts :[i18n.SelectDeckOrEnvelope,],1183 x :320,1184 y :100,1185 width :560,1186 height :160,1187 buttonAName :i18n.Decision,1188 showButtonA :true,1189 }).addChildTo(this);1190 this.MessageWindow.ButtonA.setInteractive(true);1191 this.MessageWindow.ButtonA.one('push', function(e) {1192 self.app.one('poped',function () {1193 self.afterPoped();1194 });1195 self.MessageWindow.hide();1196 this.setInteractive(false);1197 self.app.pushScene(SelectOptionScene(options));1198 });1199 },1200 afterPoped : function() {1201 var self = this;1202 switch (TfAp.SelectedOptId) {1203 case 0:1204 //ãã¹ã¦å°çãã1205 this.selectEnvelope({selectNumberOfCards:this.selectNumberOfCards,Transform:this.Transform});1206 break;1207 case this.selectNumberOfCards:1208 //ãã¹ã¦ããããã1209 this.selectDeck({selectNumberOfCards:this.selectNumberOfCards,Transform:this.Transform});1210 break;1211 default:1212 //å°çããxæããããããyæ(i18n.From take x unit)1213 this.selectDeck({selectNumberOfCards:TfAp.SelectedOptId,Transform:this.Transform});1214 this.selectEnvelope({selectNumberOfCards:this.selectNumberOfCards-TfAp.SelectedOptId,Transform:this.Transform});1215 }1216 //çµäºã®ã¡ãã»ã¼ã¸1217 this.AfterMessage = MessageWindow({1218 texts :[i18n.EndOfSelectCard,],1219 x :320,1220 y :400,1221 width :560,1222 height :160,1223 buttonAName :i18n.ButtonNext,1224 showButtonA :true,1225 }).addChildTo(this);1226 this.AfterMessage.ButtonA.setInteractive(true);1227 this.AfterMessage.ButtonA.on('push', function(e) {1228 self.app.flare(self.cbname);1229 self.app.popScene();1230 });1231 },1232 selectDeck : function(opt) {1233 this.app.pushScene(this.SceneDeck(opt));1234 },1235 selectEnvelope : function(opt) {1236 this.app.pushScene(this.SceneEnvelope(opt));1237 },1238});1239//失ãæ°ã¥ãã®ãã¼ã¯ã³é¸æ1240phina.define('SelectTokenAwarenessScoreToBoxScene', {1241 superClass: 'SelectTokenScoreToBoxScene',1242 init: function(options) {1243 //æ°ã¥ãã®ãã¼ã¯ã³ä»¥å¤ãé¸æãããã¨ããã£ãå ´åãèæ
®ãã1244 //å®éã«ããããªï¼1245 this.superInit(options);1246 },1247});1248//失ããã¼ã¯ã³é¸æ1249phina.define('SelectTokenScoreToBoxScene', {1250 superClass: 'DisplayScene',1251 init: function(options) {1252 options = ({}).$safe(options, {1253 selectNumberOfAwarenessTokens : 1,1254 TokenClass : TokenAwareness, //ãã¼ã¯ã³ã¯ã©ã¹å1255 });1256 var _scoreLevel = CurrentGameData.ScoreCardLevel;1257 this.superInit(options);1258 this.backgroundColor = appBackGroundColor;1259 this.selectNumberOfAwarenessTokens = options.selectNumberOfAwarenessTokens;1260 this.Inbox = CurrentGameData.InboxAwareness[_scoreLevel];1261 this.SelectedAwareness = CurrentGameData.Awareness[_scoreLevel];1262 this.NowSelectAwareness = []; //ä»åé¸ãã ãã¼ã¯ã³1263 this.Target = options.Target;1264 this.openNumberOfTokens = 0;1265 var _Master = TfAp.TokenAwareness[_scoreLevel];1266 if (this.Inbox == void 0 || this.Inbox.length == 0) {1267 var _Inbox = [];1268 for (i in _Master) {1269 _Inbox.push(_Master[i].id);1270 }1271 CurrentGameData.InboxAwareness[_scoreLevel] = _Inbox.shuffle();1272 this.Inbox = CurrentGameData.InboxAwareness[_scoreLevel];1273 }1274 if (this.SelectedAwareness == void 0) {1275 CurrentGameData.Awareness[_scoreLevel] = [];1276 this.SelectedAwareness = CurrentGameData.Awareness[_scoreLevel];1277 }1278 var self = this;1279 //ã¡ãã»ã¼ã¸ã¦ã¤ã³ãã¦1280 var _selectLostTokenMessage = '';1281 _selectLostTokenMessage = i18n.SelectLostTokenAndPushButtonMessage;1282 _selectLostTokenMessage = _selectLostTokenMessage.replace(/α/g,this.selectNumberOfAwarenessTokens);1283 this.SelectLostTokenMessage = MessageWindow({1284 texts :[_selectLostTokenMessage],1285 x :320,1286 y :100,1287 width :500,1288 height :100,1289 buttonAName :i18n.ButtonEndOfSelect,1290 buttonWidth: 150,1291 }).addChildTo(this);1292 this.SelectLostTokenMessage.ButtonA.setInteractive(true);1293 //é¸æå¾ã®ã¡ãã»ã¼ã¸ã¦ã¤ã³ãã¦1294 var _SelectedLostTokenMessage = [i18n.GoToBoxSelectedToken];1295 this.SelectedLostTokenMessage = MessageWindow({1296 texts :_SelectedLostTokenMessage,1297 x :320,1298 y :400,1299 width :500,1300 height :100,1301 buttonAName :i18n.ButtonEnd,1302 buttonWidth: 150,1303 }).addChildTo(this).hide();1304 this.SelectedLostTokenMessage.ButtonA.setInteractive(false);1305 //ã¹ã³ã¢ã®ãã¼ã¯ã³å
¨é¨è¡¨ç¤º1306 this._openToken = DisplayElement().addChildTo(this);1307 //ãã¨ããã¢ãã¡ã¼ã·ã§ã³ããããã«é¸ã°ãã¦ãªããªãã¸ã§ã¯ããã°ã«ã¼ãåãã1308 var nonSelectObjects = DisplayElement().addChildTo(this);1309 var SelectObjects = DisplayElement().addChildTo(this);1310 //ãã¼ã¯ã³é
åå®ç¾©1311 this._Token = [];1312 this._SelectedToken = [];1313 var _selectedNumberOfTokens = 0;1314 for (i in this.SelectedAwareness) {1315 this._Token.push(1316 options.TokenClass({layer:i,id:this.SelectedAwareness[i],ratio:0.7,1317 isFace :true,1318 }).setPosition(120+(100*(i%5)),250+(140*Math.floor(i/5)))1319 );1320 this._Token[i].addChildTo(this);1321 this._Token[i].on('pointend', function(e) {1322 if (this.fill == 'gray') {1323 _selectedNumberOfTokens = _selectedNumberOfTokens - 1;1324 this.fill = 'white';1325 this.isSelected = false;1326 var _delId = self._SelectedToken.indexOf(this);1327 self._SelectedToken.splice(_delId, 1);1328 } else if (_selectedNumberOfTokens < self.selectNumberOfAwarenessTokens) {1329 _selectedNumberOfTokens = _selectedNumberOfTokens + 1;1330 this.fill = 'gray';1331 this.isSelected = true;1332 self._SelectedToken.push(this);1333 }1334 });1335 }1336 this.SelectLostTokenMessage.ButtonA.on('push', function(e) {1337 //æ¶ããã¼ã¯ã³æ°ããã§ãã¯1338 if (_selectedNumberOfTokens == self.selectNumberOfAwarenessTokens) {1339 //é¸æããã¡ãã»ã¼ã¸ã¯æ¶ã1340 self.SelectLostTokenMessage.hide();1341 self.SelectLostTokenMessage.ButtonA.setInteractive(false);1342 //é¸æãããã«ã¼ããå¤å®1343 for (var i = self._Token.length -1; i>=0; i--) {1344 if (self._Token[i].isSelected == true) {1345 //é¸æãããã«ã¼ã1346 self._Token[i].addChildTo(SelectObjects);1347 //ãã³ã«ãã©ã1348 self.Inbox.push(self._Token[i].id);1349 //ã¹ã³ã¢ã«ã¼ãããåé¤1350 var _SelId = self.SelectedAwareness.indexOf(self._Token[i].id);1351 self.SelectedAwareness.splice(_SelId, 1);1352 } else {1353 self._Token[i].addChildTo(nonSelectObjects);1354 }1355 }1356 //é¸æãããªãã£ããã¼ã¯ã³ã¯ã¹ã³ã¢ã«ã¼ãã«æ»ãï¼ä¸ã¸ï¼1357 nonSelectObjects.tweener.by({1358 y:1000,1359 },1000,"swing")1360 .wait(1000)1361 .call(function(){1362 });1363 //é¸æãããã«ã¼ãã¯ãã³ã«æ»ãï¼æ¶æ»
ï¼1364 SelectObjects.tweener1365 .wait(1000)1366 .fadeOut(2000)1367 .call(function(){1368 self.SelectedLostTokenMessage.show();1369 self.SelectedLostTokenMessage.ButtonA.setInteractive(true);1370 });1371 }1372 });1373 this.SelectedLostTokenMessage.ButtonA.on('push', function(e) {1374 self.app.flare(options.cbname);1375 self.app.popScene();1376 });1377 },1378});1379//ãªã¿ã ã®ã¢ãã¡ã¼ã·ã§ã³ã·ã¼ã³1380phina.define('AmimateDepressionScene', {1381 superClass: 'DisplayScene',1382 init: function(options) {1383 options = ({}).$safe(options, {1384 numberOfDepressionTokens : 4,1385 CardType : 'Setback',1386 CardId : 0,1387 PutPainScene : '',1388 });1389 if (options.PutPainScene == '') {1390 var _step = CurrentGameData.PathSteps%Squares.length + (CurrentGameData.PathSteps%Squares.length<0?Squares.length:0);1391 PutPainScene = Squares[_step].mark;1392 }1393 this.superInit(options);1394 this.backgroundColor = 'rgba(0, 0, 0, 0.5)';1395 this.cbname = options.cbname;1396 this.numberOfTokens = options.numberOfDepressionTokens;1397 this.PutPainScene = options.PutPainScene; //ã©ã®ç¶æ³ã§ï¼Depression,Dice,â¦ï¼1398 this.CardType = options.CardType; //ã©ã®ã«ã¼ãï¼åºæ¬Setbackï¼1399 this.CardId = options.CardId;1400 var self = this;1401 var _tokens = DisplayElement().addChildTo(this);1402 var _Token = [];1403 for (var i=0;i<options.numberOfDepressionTokens;i++) {1404 _Token.push(TokenDepression().setPosition(260+80*(i%2),0));1405 _Token[i].addChildTo(_tokens);1406 _Token[i].tweener.by({1407 y:280+60*(i%4),1408 },1000,"swing");1409 this.insertPain(i);1410 }1411 TfAp.WriteGameLog(i18n.Pain+'('+ options.numberOfDepressionTokens + i18n.UnitOfCard + '):'+ this.PutPainScene);1412 this.on('pointend',function(){1413 _tokens.tweener.by({y:1000},600,"swing").call(function(){1414 self.app.flare(self.cbname);1415 self.app.popScene();1416 });1417 });1418 },1419 insertPain : function(i) {1420 var _pain = {}1421 //åæã«2æ以ä¸çã¿ãã§ããå ´åãdateã ãã ã¨ã¦ãã¼ã¯ãã¼ã«ã§ããªãæ§å1422 _pain.PainId = (new Date()).getTime().toString() + i.toString();1423 _pain.ScoreCardLevel = CurrentGameData.ScoreCardLevel;1424 _pain.GetTotalThrowDice = CurrentGameData.TotalThrowDice;1425 _pain.GetPathSteps = CurrentGameData.PathSteps;1426 _pain.PutPainScene = this.PutPainScene;1427 _pain.CardType = this.CardType;1428 _pain.CardId = this.CardId;1429 1430 if (CurrentGameData.Pains == void 0) {1431 CurrentGameData.Pains = [];1432 }1433 CurrentGameData.Pains.push(_pain);1434 }1435});1436//çã¿ã解æ¶ããã·ã¼ã³1437phina.define('ClaerPainScene', {1438 superClass: 'DisplayScene',1439 init: function(options) {1440 options = ({}).$safe(options, {1441 selectNumberOfAwarenessTokens : 1,1442 TokenClass : TokenAwareness, //ãã¼ã¯ã³ã¯ã©ã¹å1443 });1444 this.superInit(options);1445 var self = this;1446 var pain = options.pain;1447 var _ButtonBack = TFGMiniButton({text:i18n.ButtonBack,x:50,width:90}).addChildTo(this);1448 _ButtonBack.on('push', function() {1449 app.replaceScene(MainBoardScene());1450 });1451 pain.addChildTo(this).setInteractive(false);1452 var _scoreLevel = CurrentGameData.ScoreCardLevel;1453 var _cbname = TfAp.doneFlareName();1454 this.backgroundColor = appBackGroundColor;1455 this.selectNumberOfAwarenessTokens = options.selectNumberOfAwarenessTokens;1456 if (CurrentGameData.InboxAwareness == void 0) {1457 CurrentGameData.InboxAwareness = [];1458 }1459 if (CurrentGameData.InboxAwareness[_scoreLevel] == void 0) {1460 CurrentGameData.InboxAwareness[_scoreLevel] = [];1461 }1462 this.Inbox = CurrentGameData.InboxAwareness[_scoreLevel];1463 if (CurrentGameData.Awareness == void 0) {1464 CurrentGameData.Awareness =[];1465 }1466 if (CurrentGameData.Awareness[_scoreLevel] == void 0) {1467 CurrentGameData.Awareness[_scoreLevel] =[];1468 }1469 this.SelectedAwareness = CurrentGameData.Awareness[_scoreLevel];1470 if (CurrentGameData.TransformPain == void 0) {1471 CurrentGameData.TransformPain = [];1472 }1473 if (CurrentGameData.TransformPain[_scoreLevel] == void 0) {1474 CurrentGameData.TransformPain[_scoreLevel] = [];1475 }1476 this.NowSelectAwareness = []; //ä»åé¸ãã ãã¼ã¯ã³1477 this.Target = options.Target;1478 this.openNumberOfTokens = 0;1479 var _Master = TfAp.TokenAwareness[_scoreLevel];1480 if (this.Inbox == void 0 || this.Inbox.length == 0) {1481 var _Inbox = [];1482 for (i in _Master) {1483 _Inbox.push(_Master[i].id);1484 }1485 CurrentGameData.InboxAwareness[_scoreLevel] = _Inbox.shuffle();1486 this.Inbox = CurrentGameData.InboxAwareness[_scoreLevel];1487 }1488 var self = this;1489 //ã¡ãã»ã¼ã¸ã¦ã¤ã³ãã¦1490 var _selectLostTokenMessage = [];1491 var _painmessage = pain.CardType;1492 var _steps = pain.GetPathSteps%Squares.length + (pain.GetPathSteps%Squares.length<0?Squares.length:0);1493 var _ret = i18n.SelectedPainContents + '\n' + 1494 i18n.Dice + 'ï¼' + pain.GetTotalThrowDice + '/' +1495 i18n.Squere + 'ï¼' + Squares[_steps].mark + '\n';1496 //ãã¿ã¼ã³ãå¢ããã¨ãã®ããã«switchã«ããã1497 var _objCard = '';1498 switch (pain.PutPainScene) {1499 case 'Setback':1500 _objCard = TfAp.MasterDecks(pain.CardType);1501 _ret = _ret + '\n' + i18n.Detail + 'ï¼\n' + ((CurrentGameData.Language=='EN')?(_objCard[pain.CardId].message):(_objCard[pain.CardId].meaning));1502 _painmessage = _painmessage + ':' + ((CurrentGameData.Language=='EN')?(_objCard[pain.CardId].message):(_objCard[pain.CardId].meaning));1503 break;1504 case 'Depression':1505 _ret = _ret + i18n.Pain + 'ï¼' + i18n.PutDepressionMessage;1506 _painmessage = i18n.PutDepressionMessage;1507 break;1508 case 'Dice':1509 _ret = _ret + i18n.Pain + 'ï¼' + i18n.FailGambleDiceMessage;1510 _painmessage = i18n.FailGambleDiceMessage;1511 break;1512 case 'Flash':1513 _ret = _ret + i18n.Pain + 'ï¼' + i18n.FailGambleFlashMessage;1514 _painmessage = i18n.FailGambleFlashMessage;1515 break;1516 default:1517 _ret = _ret + i18n.Pain + 'ï¼' + pain.PutPainScene;1518 _painmessage = pain.PutPainScene;1519 }1520 if (this.SelectedAwareness.length > 0) {1521 _selectLostTokenMessage[0] = _ret + '\n\n' + i18n.CanYouClearPain;1522 } else {1523 _selectLostTokenMessage[0] = _ret + '\n\n' + i18n.CannotYouClearPainBecauseNoToken;1524 }1525 this.SelectLostTokenMessage = MessageWindow({1526 texts :_selectLostTokenMessage,1527 x :340,1528 y :180,1529 width :440,1530 height :320,1531 buttonAName :i18n.OK,1532 buttonWidth: 150,1533 }).addChildTo(this);1534 this.SelectLostTokenMessage.ButtonA.setInteractive(true);1535 var _okButton = {1536 text: i18n.OK,1537 fill: 'purple',1538 width: 190,1539 height: 45,1540 x: 240,1541 y: 310,1542 }1543 var _ngButton = {1544 text: i18n.NG,1545 fill: 'purple',1546 width: 190,1547 height: 45,1548 x: 440,1549 y: 310,1550 }1551 this.ConfirmClearPainButton = Button(_okButton).addChildTo(this).hide().setInteractive(false);1552 this.CancelClearPainButton = Button(_ngButton).addChildTo(this).hide().setInteractive(false);1553 //ã¹ã³ã¢ã®ãã¼ã¯ã³å
¨é¨è¡¨ç¤º1554 this._openToken = DisplayElement().addChildTo(this);1555 //ãã¨ããã¢ãã¡ã¼ã·ã§ã³ããããã«é¸ã°ãã¦ãªããªãã¸ã§ã¯ããã°ã«ã¼ãåãã1556 var nonSelectObjects = DisplayElement().addChildTo(this);1557 var SelectObjects = DisplayElement().addChildTo(this);1558 pain.addChildTo(SelectObjects);1559 //ãã¼ã¯ã³é
åå®ç¾©1560 this._Token = [];1561 this._SelectedToken = [];1562 var _selectedNumberOfTokens = 0;1563 for (i in this.SelectedAwareness) {1564 this._Token.push(1565 options.TokenClass({layer:i,id:this.SelectedAwareness[i],ratio:0.7,1566 isFace :true,1567 level : _scoreLevel,1568 }).setPosition(120+(100*(i%5)),450+(140*Math.floor(i/5)))1569 );1570 this._Token[i].addChildTo(this);1571 this._Token[i].on('pointend', function(e) {1572 if (this.fill == 'gray') {1573 _selectedNumberOfTokens = _selectedNumberOfTokens - 1;1574 this.fill = 'white';1575 this.isSelected = false;1576 var _delId = self._SelectedToken.indexOf(this);1577 self._SelectedToken.splice(_delId, 1);1578 } else if (_selectedNumberOfTokens < self.selectNumberOfAwarenessTokens) {1579 _selectedNumberOfTokens = _selectedNumberOfTokens + 1;1580 this.fill = 'gray';1581 this.isSelected = true;1582 self._SelectedToken.push(this);1583 }1584 });1585 }1586 var _keyword = ''; //é¸æãããã¼ã¯ã³ã®ãã¼ã¯ã¼ã1587 1588 this.SelectLostTokenMessage.ButtonA.on('push', function(e) {1589 //æ¶ããã¼ã¯ã³æ°ããã§ãã¯1590 if (_selectedNumberOfTokens == self.selectNumberOfAwarenessTokens) {1591 //é¸æãããã«ã¼ããå¤å®1592 for (var i = self._Token.length -1; i>=0; i--) {1593 if (self._Token[i].isSelected == true) {1594 //é¸æãããã«ã¼ã1595 self._Token[i].addChildTo(SelectObjects);1596 _keyword = (CurrentGameData.Language=='EN')?_Master[self._Token[i].id].message:_Master[self._Token[i].id].meaning;1597 } else {1598 self._Token[i].addChildTo(nonSelectObjects);1599 }1600 }1601 document.getElementById("overlay").style.display='block';1602 TfAp.OverLayMessage = i18n.HowDoYouRespondToPain;1603 TfAp.OverLayMessage = TfAp.OverLayMessage1604 .replace(/α/g,_keyword)1605 .replace(/γ/g,_painmessage);1606 TfAp.OverLayPlaceHolder = i18n.Within85characters;1607 TfAp.OverLayPlaceHolder = TfAp.OverLayPlaceHolder.replace(/α/g,_keyword);1608 self.app.pushScene(InputScene({cbname:_cbname}));1609 }1610 });1611 app.on(_cbname, function(e) {1612 if(~TfAp.OverLayInput.indexOf(_keyword)) {1613 var _gatherWordOnceMore = i18n.GatherWordOnceMore;1614 _gatherWordOnceMore = _gatherWordOnceMore.replace(/α/g,_painmessage);1615 var _tmp = TfAp.OverLayInput + '\n' + i18n.YouSays + '\n' + _gatherWordOnceMore + self.askClearPainQuestion();1616 self.SelectLostTokenMessage.ButtonA.text = '';1617 self.SelectLostTokenMessage.ButtonA.hide().setInteractive(false);1618 self.SelectLostTokenMessage.resetText({texts:[_tmp]});1619 self.ConfirmClearPainButton.show().setInteractive(true);1620 self.CancelClearPainButton.show().setInteractive(true);1621 } else {1622 //ãã¼ã¯ã¼ããå«ãã§ããªã1623 self.SelectLostTokenMessage.resetText({texts:[i18n.NoKeywordAndTryAgain,_selectLostTokenMessage[0]]});1624 self.ConfirmClearPainButton.hide().setInteractive(false);1625 self.CancelClearPainButton.hide().setInteractive(false);1626 self.SelectLostTokenMessage.ButtonA.text = i18n.OK;1627 self.SelectLostTokenMessage.ButtonA.show().setInteractive(true);1628 }1629 });1630 this.CancelClearPainButton.on('push', function(e) {1631 self.SelectLostTokenMessage.resetText({texts:[_selectLostTokenMessage[0],]});1632 self.ConfirmClearPainButton.hide().setInteractive(false);1633 self.CancelClearPainButton.hide().setInteractive(false);1634 self.SelectLostTokenMessage.ButtonA.text = i18n.OK;1635 self.SelectLostTokenMessage.ButtonA.show().setInteractive(true);1636 });1637 this.ConfirmClearPainButton.on('push', function(e) {1638 self.ConfirmClearPainButton.hide().setInteractive(false);1639 self.CancelClearPainButton.hide().setInteractive(false);1640 self.SelectLostTokenMessage.hide();1641 self.SelectLostTokenMessage.resetText({texts:['']});1642 //é¸æãããã«ã¼ããå¤å®1643 for (var i = self._Token.length -1; i>=0; i--) {1644 if (self._Token[i].isSelected == true) {1645 //解æ¾å
容ãpainã«æ¸ãè¾¼ã1646 pain.ReleaseTotalThrowDice = CurrentGameData.TotalThrowDice;1647 pain.ReleasePathSteps = CurrentGameData.PathSteps;1648 pain.UsedTokenAwarenessId = self._Token[i].id;1649 pain.UserAwareness = TfAp.OverLayInput;1650 //ã¹ã³ã¢ã«ã¼ãããåé¤1651 var _SelId = self.SelectedAwareness.indexOf(self._Token[i].id);1652 self.SelectedAwareness.splice(_SelId, 1);1653 }1654 }1655 //çã¿ã解æ¾1656 CurrentGameData.Pains = CurrentGameData.Pains.filter(function(v) {1657 return v.PainId != pain.PainId;1658 });1659 //é¸ãã çã¿ããã©ã³ã¹ãã©ã¼ã ã¸1660 CurrentGameData.TransformPain[_scoreLevel].push(pain);1661 //ãã°ã¸1662 var _logOpenPain = i18n.LogOpenPain;1663 _logOpenPain = _logOpenPain.replace(/α/g,_painmessage)1664 .replace(/γ/g,pain.ReleaseTotalThrowDice)1665 .replace(/δ/g,pain.UserAwareness);1666 CurrentGameData.Scene = 'MainBoard';1667 TfAp.WriteGameLog(_logOpenPain);1668 TfAp.saveGameData();1669 //é¸æãããªãã£ããã¼ã¯ã³ã¯ã¹ã³ã¢ã«ã¼ãã«æ»ãï¼ä¸ã¸ï¼1670 nonSelectObjects.tweener.by({1671 y:1000,1672 },1000,"swing")1673 .wait(1000)1674 .call(function(){1675 });1676 //é¸æãããã«ã¼ãã¯ãã©ã³ã¹ãã©ã¼ã¡ã¼ã·ã§ã³ã¨ãªã¢ã¸ï¼æ¶æ»
ï¼1677 SelectObjects.tweener1678 .wait(1000)1679 .fadeOut(2000)1680 .call(function(){1681 self.SelectLostTokenMessage.resetText({texts:[i18n.ClearedPain]});1682 self.SelectLostTokenMessage.show();1683 })1684 .call(function(){1685 self.on('pointend',function(e){1686 app.replaceScene(MainBoardScene());1687 });1688 });1689 });1690 },1691 askClearPainQuestion : function() {1692 var clearPainQuestion = i18n.ClearPainQuestion;1693 var _selectQuestion = Random.randint(0,clearPainQuestion.length-1);1694 return clearPainQuestion[_selectQuestion];1695 }1696});1697//ãªã¿ã 解æ¶ã®ã¢ãã¡ã¼ã·ã§ã³ã·ã¼ã³1698phina.define('AmimateClearPainScene', {1699 superClass: 'DisplayScene',1700 init: function(options) {1701 options = ({}).$safe(options, {1702 numberOfDepressionTokens : 4,1703 });1704 this.superInit(options);1705 this.backgroundColor = 'rgba(0, 0, 0, 0.5)';1706 this.cbname = options.cbname;1707 this.numberOfTokens = options.numberOfDepressionTokens;1708 var self = this;1709 var _tokens = DisplayElement().addChildTo(this);1710 var _Token = [];1711 for (var i=0;i<Math.min(options.numberOfDepressionTokens,CurrentGameData.Pains.length);i++) {1712 _Token.push(TokenDepression().setPosition(260+80*(i%2),0));1713 _Token[i].addChildTo(_tokens);1714 _Token[i].tweener.by({1715 y:280+60*(i%4),1716 },1000,"swing");1717 this.clearPain();1718 }1719 this.on('pointend',function(){1720 _tokens.tweener.fadeOut(600).call(function(){1721 self.app.flare(self.cbname);1722 self.app.popScene();1723 });1724 });1725 },1726 clearPain : function() {1727 //ããã§è§£æ¾1728 }1729});1730//ãªã¿ã å
¨è§£æ¶ã®ã¢ãã¡ã¼ã·ã§ã³ã·ã¼ã³1731phina.define('AmimateClearAllPainScene', {1732 superClass: 'DisplayScene',1733 init: function(options) {1734 options = ({}).$safe(options, {1735 numberOfDepressionTokens : 9,1736 Reason : 'Miracle',1737 });1738 var _scoreLevel = CurrentGameData.ScoreCardLevel;1739 this.superInit(options);1740 this.backgroundColor = 'rgba(0, 0, 0, 0.5)';1741 this.cbname = options.cbname;1742 this.numberOfTokens = options.numberOfDepressionTokens;1743 this.UserAwareness = options.Reason;1744 this.TransformPain = CurrentGameData.TransformPain[_scoreLevel];1745 if (this.TransformPain == void 0) {1746 CurrentGameData.TransformPain[_scoreLevel] = [];1747 this.TransformPain = CurrentGameData.TransformPain[_scoreLevel];1748 }1749 var self = this;1750 this.setInteractive(false);1751 this._label = function(opt){ return Label({1752 text: opt.text + '\n(Touch to next)',1753 align: 'center',1754 baseline: 'top',1755 fontSize:40,1756 fontColor :'black',1757 x:320,1758 y:480,1759 });}1760 this._tokens = DisplayElement().addChildTo(this);1761 this._Token = [];1762 if (CurrentGameData.Pains.length == 0) {1763 this._msg = this._label({text:i18n.NoPainForClear}).addChildTo(this);1764 this.setInteractive(true);1765 } else {1766 CurrentGameData.Pains.forEach(function(val,i,array) {1767 self._Token.push(TokenDepression(val).setPosition(260+80*(i%5),0));1768 self._Token[i].addChildTo(self._tokens);1769 self._Token[i].tweener1770 .to({y:320+160*(i<5?0:1)},1000,'swing')1771 .set({alpha:0.7})1772 .wait(1000)1773 .fadeOut(2000)1774 .call(function(){1775 self.clearAllPain();1776 self.setInteractive(true);1777 self._msg = self._label({text:i18n.AllPainCleard}).addChildTo(self);1778 });1779 });1780 }1781 this.one('pointend',function(){1782 self.app.flare(self.cbname);1783 self.exit();1784 });1785 },1786 clearAllPain : function() {1787 var self = this;1788 CurrentGameData.Pains.forEach(function(val,i,array) {1789 //解æ¾å
容ãpainã«æ¸ãè¾¼ã1790 val.ReleaseTotalThrowDice = CurrentGameData.TotalThrowDice;1791 val.ReleasePathSteps = CurrentGameData.PathSteps;1792 val.UsedTokenAwarenessId = 0;1793 val.UserAwareness = self.UserAwareness;1794 //çã¿ã解æ¾1795 CurrentGameData.Pains = CurrentGameData.Pains.filter(function(v) {1796 return v.PainId != val.PainId;1797 });1798 //é¸ãã çã¿ããã©ã³ã¹ãã©ã¼ã ã¸1799 self.TransformPain.push(val);1800 });1801 1802 var _tmp = i18n.LogOpenAllPain;1803 _tmp = _tmp.replace(/α/g,self.UserAwareness);1804 TfAp.WriteGameLog(_tmp);1805 }1806});1807//ãµã¼ãã¹ãã¼ã¯ã³ã®ã¢ãã¡ã¼ã·ã§ã³ã·ã¼ã³1808phina.define('AmimateGetServiceTokenScene', {1809 superClass: 'DisplayScene',1810 init: function(options) {1811 options = ({}).$safe(options, {1812 Reason : 'Miracle',1813 });1814 var _scoreLevel = CurrentGameData.ScoreCardLevel;1815 this.superInit(options);1816 this.backgroundColor = 'rgba(0, 0, 0, 0.5)';1817 this.cbname = options.cbname;1818 this.Reason = options.Reason;1819 var self = this;1820 this.setInteractive(false);1821 if (CurrentGameData.Service == void 0) {1822 CurrentGameData.Service = [];1823 }1824 if (CurrentGameData.Service[_scoreLevel] == void 0) {1825 CurrentGameData.Service[_scoreLevel] = 0;1826 }1827 var _TokenService = TokenService({isBrank:false,isDisplayCards:false,}).setPosition(320,0).addChildTo(this);1828 _TokenService.setInteractive(false);1829 _TokenService.tweener1830 .to({y:400},1000,'swing')1831 .fadeIn(1000)1832 .call(function(){1833 self._msg = self._label().addChildTo(self);1834 self.setInteractive(true);1835 var _logGetServiceToken = i18n.LogGetServiceToken;1836 _logGetServiceToken = _logGetServiceToken.replace(/α/g,self.Reason);1837 TfAp.WriteGameLog(_logGetServiceToken);1838 CurrentGameData.Service[_scoreLevel] = CurrentGameData.Service[_scoreLevel] + 1;1839 });1840 this._label = function(opt){ return Label({1841 text: i18n.GetServiceToken+'\n(Touch to next)',1842 align: 'center',1843 baseline: 'top',1844 fontSize:40,1845 fontColor :'black',1846 x:320,1847 y:600,1848 });}1849 this.one('pointend',function(){1850 self.app.flare(self.cbname);1851 app.popScene();1852 });1853 },1854});1855//èæ¯è²ã®ã¿ã¬ã¤ã³ãã¼1856phina.define('BackgroundRainbowScene', {1857 superClass: 'DisplayScene',1858 init: function(options) {1859 options = ({}).$safe(options, {1860 text : '(tap to next)',1861 x : 320,1862 y : 480,1863 });1864 this.superInit(options);1865 this.cbname = options.cbname||'';1866 this.i = 1;1867 this.x = options.x;1868 this.y = options.y;1869 var _lav = Label({text:options.text,x:320,y:400}).addChildTo(this);1870 var self = this;1871 this.on('pointend',function(){1872 self.app.flare(self.cbname);1873 self.app.popScene();1874 });1875 },1876 update :function(){1877 this.i = this.i + 1;1878 if (this.i > 30) this.i = 1; 1879 this.grad = Canvas.createRadialGradient(this.x,this.y, 1, this.x, this.y, this.i*100);1880 //赤ã ãªã¬ã³ã¸ã é»è²ã ç·ã æ°´è²ã éã ç´«1881 this.grad.addColorStop(1, 'red');1882 this.grad.addColorStop(0.85, 'orange');1883 this.grad.addColorStop(0.65, 'yellow');1884 this.grad.addColorStop(0.5, 'green');1885 this.grad.addColorStop(0.35, 'blue');1886 this.grad.addColorStop(0.15, 'indigo');1887 this.grad.addColorStop(0, 'violet');1888 // èæ¯è²1889 this.backgroundColor = this.grad;1890 },1891});1892//æªå®è£
ããã¼ã·ã¼ã³1893//ã®ã¡ã«ã¤ãã³ããå®ç¾©ããã¾ã§ã®ã·ã¼ã³1894phina.define('DummyScene', {1895 superClass: 'DisplayScene',1896 init: function(options) {1897 options = ({}).$safe(options, {1898 Event : 'Dummy',1899 });1900 this.superInit(options);1901 this.backgroundColor = 'rgba(0, 0, 0, 0.5)';1902 this.cbname = options.cbname;1903 this.numberOfTokens = options.numberOfDepressionTokens;1904 var _lav = Label({text:options.Event,x:320,y:400}).addChildTo(this);1905 var self = this;1906 this.on('pointend',function(){1907 self.app.flare(self.cbname);1908 self.app.popScene();1909 });1910 },...
monacoBinding.ts
Source:monacoBinding.ts
1import { getColorForUserId } from 'Client/slices/room/types';2import { styletronEngine } from 'Client/styletronEngine';3import * as error from 'lib0/error.js';4import { createMutex } from 'lib0/mutex.js';5import * as monaco from 'monaco-editor';6import { Observable } from 'rxjs/internal/Observable';7import { fromArray } from 'rxjs/internal/observable/fromArray';8import { concatMap } from 'rxjs/internal/operators/concatMap';9import { map } from 'rxjs/internal/operators/map';10import { startWith } from 'rxjs/internal/operators/startWith';11import { withLatestFrom } from 'rxjs/internal/operators/withLatestFrom';12import { Subscription } from 'rxjs/internal/Subscription';13import { clientAwareness, globalAwareness } from 'Shared/types/roomMemberAwarenessTypes';14import { Awareness } from 'y-protocols/awareness.js';15import * as Y from 'yjs';16import { lighterColors } from './awarenessColors';17class RelativeSelection {18 /**19 * @param {Y.RelativePosition} start20 * @param {Y.RelativePosition} end21 * @param {monaco.SelectionDirection} direction22 */23 constructor(24 public start: Y.RelativePosition,25 public end: Y.RelativePosition,26 public direction: monaco.SelectionDirection,27 ) {}28}29/**30 * @param {monaco.editor.IStandaloneCodeEditor} editor31 * @param {monaco.editor.ITextModel} monacoModel32 * @param {Y.Text} yText33 */34const createRelativeSelection = (35 editor: monaco.editor.IStandaloneCodeEditor,36 monacoModel: monaco.editor.ITextModel,37 yText: Y.Text,38) => {39 const sel = editor.getSelection();40 if (sel !== null) {41 const startPos = sel.getStartPosition();42 const endPos = sel.getEndPosition();43 const start = Y.createRelativePositionFromTypeIndex(yText, monacoModel.getOffsetAt(startPos));44 const end = Y.createRelativePositionFromTypeIndex(yText, monacoModel.getOffsetAt(endPos));45 return new RelativeSelection(start, end, sel.getDirection());46 }47 return null;48};49/**50 * @param {monaco.editor.IEditor} editor51 * @param {Y.Text} type52 * @param {RelativeSelection} relSel53 * @param {Y.Doc} doc54 * @return {null|monaco.Selection}55 */56const createMonacoSelectionFromRelativeSelection = (57 editor: monaco.editor.IStandaloneCodeEditor,58 type: Y.Text,59 relSel: RelativeSelection,60 doc: Y.Doc,61) => {62 const start = Y.createAbsolutePositionFromRelativePosition(relSel.start, doc);63 const end = Y.createAbsolutePositionFromRelativePosition(relSel.end, doc);64 if (start !== null && end !== null && start.type === type && end.type === type) {65 const model = editor.getModel();66 if (!model) {67 return null;68 }69 const startPos = model.getPositionAt(start.index);70 const endPos = model.getPositionAt(end.index);71 return monaco.Selection.createWithDirection(72 startPos.lineNumber,73 startPos.column,74 endPos.lineNumber,75 endPos.column,76 relSel.direction,77 );78 }79 return null;80};81export class MonacoBinding {82 mux: any;83 private _savedSelections: Map<any, any>;84 private _beforeTransaction: () => void;85 private doc: Y.Doc;86 private _decorations: Map<any, any>;87 private _rerenderDecorations: () => void;88 private _ytextObserver: (event: any) => void;89 private _monacoChangeHandler: monaco.IDisposable;90 private isDestroyed = false;91 awareness: Awareness;92 awarenessCursorStyles: RemoteCursorStyleManager;93 /**94 * @param {Y.Text} ytext95 * @param {monaco.editor.ITextModel} monacoModel96 * @param {Set<monaco.editor.IStandaloneCodeEditor>} [editors]97 * @param {Awareness?} [awareness]98 */99 constructor(100 private ytext: Y.Text,101 public monacoModel: monaco.editor.ITextModel,102 public editors: Set<monaco.editor.IStandaloneCodeEditor> = new Set(),103 awarenessCursorStyles: RemoteCursorStyleManager,104 awareness: Awareness,105 awareness$: Observable<globalAwareness>,106 ) {107 if (!ytext.doc) {108 throw 'no doc set on ytext';109 }110 this.doc = /** @type {Y.Doc} */ ytext.doc;111 this.mux = createMutex();112 /**113 * @type {Map<monaco.editor.IStandaloneCodeEditor, RelativeSelection>}114 */115 this._savedSelections = new Map();116 this._beforeTransaction = () => {117 this.mux(() => {118 this._savedSelections = new Map();119 editors.forEach((editor) => {120 if (editor.getModel() === monacoModel) {121 const rsel = createRelativeSelection(editor, monacoModel, ytext);122 if (rsel !== null) {123 this._savedSelections.set(editor, rsel);124 }125 }126 });127 });128 };129 this.doc.on('beforeAllTransactions', this._beforeTransaction);130 this._decorations = new Map();131 // this.awarenessCursorStyles = new AwarenessCursorStyleManager(awareness, awareness$, this.doc.clientID);132 this._rerenderDecorations = () => {133 editors.forEach((editor) => {134 if (awareness && editor.getModel() === monacoModel) {135 // render decorations136 const currentDecorations = this._decorations.get(editor) || [];137 const newDecorations: monaco.editor.IModelDeltaDecoration[] = [];138 // const decoration: monaco.editor.IModelDecoration = {options: {}}139 awareness.getStates().forEach((state: clientAwareness, clientID: number) => {140 if (141 clientID !== this.doc.clientID &&142 state.selection != null &&143 state.selection.anchor != null &&144 state.selection.head != null &&145 state.roomMemberDetails146 ) {147 const anchorAbs = Y.createAbsolutePositionFromRelativePosition(state.selection.anchor, this.doc);148 const headAbs = Y.createAbsolutePositionFromRelativePosition(state.selection.head, this.doc);149 const classNames = awarenessCursorStyles.includedClientStyles.get(clientID);150 if (151 anchorAbs !== null &&152 headAbs !== null &&153 anchorAbs.type === ytext &&154 headAbs.type === ytext &&155 classNames156 ) {157 let start, end, afterContentClassName, beforeContentClassName;158 if (anchorAbs.index < headAbs.index) {159 start = monacoModel.getPositionAt(anchorAbs.index);160 end = monacoModel.getPositionAt(headAbs.index);161 afterContentClassName = classNames.selectionHead;162 beforeContentClassName = null;163 } else {164 start = monacoModel.getPositionAt(headAbs.index);165 end = monacoModel.getPositionAt(anchorAbs.index);166 afterContentClassName = null;167 beforeContentClassName = classNames.selectionHead;168 }169 newDecorations.push({170 range: new monaco.Range(start.lineNumber, start.column, end.lineNumber, end.column),171 options: {172 className: classNames.selectionBody,173 afterContentClassName,174 beforeContentClassName,175 },176 });177 }178 }179 });180 this._decorations.set(editor, editor.deltaDecorations(currentDecorations, newDecorations));181 } else {182 // ignore decorations183 this._decorations.delete(editor);184 }185 });186 };187 this._ytextObserver = (event) => {188 this.mux(() => {189 let index = 0;190 event.delta.forEach((op: any) => {191 if (op.retain !== undefined) {192 index += op.retain;193 } else if (op.insert !== undefined) {194 const pos = monacoModel.getPositionAt(index);195 const range = new monaco.Selection(pos.lineNumber, pos.column, pos.lineNumber, pos.column);196 monacoModel.pushEditOperations([], [{ range, text: op.insert }], () => null);197 index += op.insert.length;198 } else if (op.delete !== undefined) {199 const pos = monacoModel.getPositionAt(index);200 const endPos = monacoModel.getPositionAt(index + op.delete);201 const range = new monaco.Selection(pos.lineNumber, pos.column, endPos.lineNumber, endPos.column);202 monacoModel.pushEditOperations([], [{ range, text: '' }], () => null);203 } else {204 throw error.unexpectedCase();205 }206 });207 monacoModel.pushStackElement();208 this._savedSelections.forEach((rsel, editor) => {209 const sel = createMonacoSelectionFromRelativeSelection(editor, ytext, rsel, this.doc);210 if (sel !== null) {211 editor.setSelection(sel);212 }213 });214 });215 this._rerenderDecorations();216 };217 ytext.observe(this._ytextObserver);218 monacoModel.setValue(ytext.toString());219 this._monacoChangeHandler = monacoModel.onDidChangeContent((event) => {220 // apply changes from right to left221 this.mux(() => {222 this.doc.transact(() => {223 event.changes224 .sort((change1, change2) => change2.rangeOffset - change1.rangeOffset)225 .forEach((change) => {226 ytext.delete(change.rangeOffset, change.rangeLength);227 ytext.insert(change.rangeOffset, change.text);228 });229 }, this);230 });231 });232 monacoModel.onWillDispose(() => {233 if (!this.isDestroyed) {234 this.destroy();235 }236 });237 if (awareness) {238 editors.forEach((editor) => {239 editor.onDidChangeCursorSelection(() => {240 if (editor.getModel() === monacoModel) {241 const sel = editor.getSelection();242 if (sel === null) {243 return;244 }245 let anchor = monacoModel.getOffsetAt(sel.getStartPosition());246 let head = monacoModel.getOffsetAt(sel.getEndPosition());247 if (sel.getDirection() === monaco.SelectionDirection.RTL) {248 const tmp = anchor;249 anchor = head;250 head = tmp;251 }252 awareness.setLocalStateField('selection', {253 anchor: Y.createRelativePositionFromTypeIndex(ytext, anchor),254 head: Y.createRelativePositionFromTypeIndex(ytext, head),255 });256 }257 });258 awareness.on('change', this._rerenderDecorations);259 });260 this.awareness = awareness;261 }262 }263 getEditor() {264 return [...this.editors.values()][0];265 }266 destroy() {267 this._monacoChangeHandler.dispose();268 this.ytext.unobserve(this._ytextObserver);269 this.doc.off('beforeAllTransactions', this._beforeTransaction);270 this.editors.forEach((editor) => {271 editor.dispose();272 });273 if (this.awareness !== null) {274 this.awareness.off('change', this._rerenderDecorations);275 }276 this.isDestroyed = true;277 }278}279/**280 * This exists to style remote cursors/selection with styletroon, as well as manage a dynamic stylesheet for some css properties for the editor that we can't style directly with styletron.281 */282export class RemoteCursorStyleManager {283 element: HTMLStyleElement;284 stylesheet: CSSStyleSheet;285 includedClientStyles: Map<number, { selectionHead: string; selectionBody: string }>;286 awarenessSubscription: Subscription;287 constructor(288 awareness: Awareness,289 awareness$: Observable<globalAwareness>,290 clientID: number,291 assignedColor$: Observable<Map<string, string>>,292 ) {293 this.element = document.createElement('style');294 this.element.id = 'extra-selection-styles';295 this.includedClientStyles = new Map();296 document.head.appendChild(this.element);297 this.stylesheet = this.element.sheet as CSSStyleSheet;298 const globalAwareness: globalAwareness = {};299 for (let [i, v] of awareness.getStates().entries()) {300 globalAwareness[i.toString()] = {301 currentTab: v.currentTab,302 roomMemberDetails: v.user,303 timeJoined: v.timeJoined,304 };305 }306 this.awarenessSubscription = awareness$307 .pipe(308 startWith(globalAwareness),309 concatMap((globalAwareness) => {310 const newEntries = Object.entries(globalAwareness)311 .map(([clientID, userAwareness]): [number, clientAwareness] => [parseInt(clientID), userAwareness])312 .filter(313 ([clientID, userAwareness]) =>314 !this.includedClientStyles.has(clientID) && userAwareness.roomMemberDetails,315 );316 return fromArray(newEntries);317 }),318 withLatestFrom(assignedColor$),319 map(([args, assignedColors]): [number, clientAwareness, string] => {320 const awareness = args[1];321 const color = getColorForUserId(awareness.roomMemberDetails?.userIdOrAnonID as string, assignedColors);322 return [...args, color];323 }),324 )325 .subscribe(([clientID, userAwareness, assignedColor]) => {326 this.setAwarenessStyle(clientID, userAwareness, assignedColor);327 });328 }329 setAwarenessStyle(clientID: number, userAwareness: clientAwareness, userColor: string) {330 if (this.includedClientStyles.has(clientID) || !userAwareness.roomMemberDetails) {331 return;332 }333 const selectionHeadClass = styletronEngine.renderStyle({334 position: 'absolute',335 borderLeft: `${userColor} solid 2px`,336 borderTop: `${userColor} solid 2px`,337 borderBottom: `${userColor} solid 2px`,338 height: '100%',339 boxSizing: 'border-box',340 });341 const selectionBodyClass = styletronEngine.renderStyle({342 backgroundColor: lighterColors[userColor],343 });344 const selectionHeadClassForClientID = `selection-head-${clientID}`;345 const selectionBodyClassForClientID = `selection-body-${clientID}`;346 const style = `347 .${selectionHeadClassForClientID}:after {348 position: absolute;349 height: min-content;350 width: min-content;351 background-color: ${userColor};352 padding: 1px;353 top: -22px;354 content: '${userAwareness.roomMemberDetails.name}';355 color: white;356 font-weight: bold;357 }358 `;359 // put the tag on the bottom on the first line360 const firstChildStyle = `361 .view-line[style*='top:0px'] .${selectionHeadClassForClientID}:after {362 top: 22px;363 }364 `;365 this.stylesheet.insertRule(style);366 this.stylesheet.insertRule(firstChildStyle);367 this.includedClientStyles.set(clientID, {368 selectionHead: [selectionHeadClass, selectionHeadClassForClientID].join(' '),369 selectionBody: [selectionBodyClass, selectionBodyClassForClientID].join(' '),370 });371 return selectionHeadClass;372 }373 destroy() {374 this.element.remove();375 this.awarenessSubscription.unsubscribe();376 }...
app-globalobject.js
Source:app-globalobject.js
1//ã²ã¼ã å
å
±æã®å®ç¾©(ã¡ã¤ã³ãã¼ãéå®ã¯phina-dataã¸)2TfAp.OverLayMessage = ''; //ã¡ãã»ã¼ã¸3TfAp.OverLayPlaceHolder = ''; //ãã¬ã¤ã¹ãã«ã4TfAp.OverLayInput = ''; //å
¥åçµæ5TfAp.OverLayCancel = false; //ãªã¼ãã¬ã¤çµäº6TfAp.SelectedOptId = -1; //SelectOptionScene(é¸æè¢é¸æ)ã®çµæ7var isSaveGame = true; //ã²ã¼ã ä¿å //ã¨ãããã=false8TfAp.SavePoint = 1;9//äºç´å®ç¾©ï¼ã°ãã¼ãã«ç¦æ¢ï¼10//causeEventsï¼åã«ã¼ããå¼ããå¾ã®ã¤ãã³ããå®ç¾©ï¼åã«ã¼ãã®ã¯ã©ã¹ãã¨ã«å®ç¾©ãããï¼11//ä¾ï¼[{Event:'Awareness',selectNumberOfCards : 1}]12//globalå¤æ°å®ç¾©13var CurrentGameData = {14 UserName : '', //Partition Key)ã¦ã¼ã¶å from AWSCognito15 StartTime : 0, //Sort Key)ãã¤å§ããã(Date.getTime())16 LastSave : 0, //æå¾ã®ã»ã¼ã(Date.getTime())17 CloseTime : 0, //çµäºæå»ï¼Date.getTime()ï¼18// Language : '',19 Language : 'JP', //ã¨ãããã20 Scene : 'MainBoard', //ã¹ã¯ã¨ã¢ã®å¤ãæ¸ãè¾¼ãã21 PlayingFocus : '',22 PlayingKeyWords : [],23 PlayNotes : [],24 PlayLogs : [],25 DeckAngel : [],26 DeckInsight : [],27 DeckSetback : [],28 UnconsciousAngel : [],29 UnconsciousInsight : [],30 UnconsciousSetback : [],31 GuardianAngel: [],32 ScoreCardLevel: 0,33 PathSteps : 0,34 LastDiceNumber: 1,35 Pains: [],36 TotalThrowDice: 0,37 Direction : 1, //1:å³åã,-1:å·¦åã38 Service : [],39 Awareness : [], //é¸ãã ãã¼ã¯ã³40 Angel : [],41 Setback : [],42 TransformSetback : [],43 TransformInsight : [],44 TransformFeedback : [],45 TransformPain : [],46 InboxAwareness : [], //ãã³ã®ãã¼ã¯ã³ï¼ï¼é¸ã°ãã¦ãªããã¼ã¯ã³ï¼47};48//ã¹ã³ã¢ã«ã¼ãã®å®ç¾©ã«ã¤ãã¦49// Service : [[lv1],[lv2],[lv3],[lv4],],50// Awareness : [[lv1],[lv2],[lv3],[lv4],],51// Angel : [[lv1],[lv2],[lv3],[lv4],],52// Setback : [[lv1],[lv2],[lv3],[lv4],],53// TransformSetback : [[lv1],[lv2],[lv3],[lv4],],54// TransformInsight : [[lv1],[lv2],[lv3],[lv4],],55// TransformFeedback : [[lv1],[lv2],[lv3],[lv4],],56// TransformPain : [[lv1],[lv2],[lv3],[lv4],],57// InboxAwareness : [[lv1],[lv2],[lv3],[lv4],],58//Pains59//PainId:ï¼ç»é²æã®æ¥æï¼(new Date()).getTime().toString()60//ScoreCardLevel:1,ï¼ç»é²æã®CurrentGameData.ScoreCardLevelã0ï½ï¼61//GetTotalThrowDice:4,ï¼ç»é²æã®CurrentGameData.TotalThrowDiceï¼62//GetPathSteps:6,ï¼ç»é²æã®CurrentGameData.PathStepsï¼63//PutPainScene 'Depression', //ã©ã®ç¶æ³ã§ï¼Depression,Dice,â¦ï¼64//CardType:'Setback'ï¼ç»é²æã®ã«ã¼ããåºæ¬Setbackï¼,65//CardId : 54,ï¼ç»é²æã®CardTypeã®IDãã¹ã¯ã¨ã¢ã®å ´åã¯0ï¼66//ReleaseTotalThrowDice:4,ï¼è§£æ¾æã®CurrentGameData.TotalThrowDiceï¼67//ReleasePathSteps:7,ï¼è§£æ¾æã®CurrentGameData.PathStepsï¼68//UsedTokenAwarenessId: 10,ï¼è§£æ¾æã«å©ç¨ããæ°ã¥ãã®ãã¼ã¯ã³ã®IDï¼69//UserAwareness: 'ãããªéã§ãOK',ï¼è§£æ¾æã«ã¦ã¼ã¶ãä½æããå
容ï¼70TfAp.SetLanguage = function (lang) {71 _lang = lang||CurrentGameData.Language;72 switch (_lang) {73 case 'JP':74 TfAp.setMessagesJP();75 break;76 default :77 TfAp.setMessagesEN();78 }79 TfAp.ArrayAssets();80}81//ãã°ãªã©ã«å©ç¨82TfAp.FormatDate = function(_dt) {83 return (new Date(_dt)).format("yyyy/MM/dd HH:mm:ss");84}85//FlareName86TfAp.doneFlareName = function() {87 return 'tfgFlare' + (new Date()).format("yyyyMMddHHmmss") + Math.randint(0, 99);88}89//ãã°ãæ¸ãè¾¼ãå¦ç90TfAp.WriteGameLog = function(log) {91 var d = new Date();92 _log = log + ' (' + TfAp.FormatDate(d.getTime()) +')'93 //代å
¥94 CurrentGameData.PlayLogs.unshift(_log);95 //ãã°ã¿ããæ¹ãã¦ãã¦ã³ããã¦ä»£å
¥ãããã°ä¸è¦§ã表示ããã96 riot.mount('app-log');97}98//DynamoDBç»é²99TfAp.saveGameData = function(isSav) {100 var _isSav = isSav||isSaveGame;101 if (_isSav) {102 return new Promise(function(resolve,reject) {103 var dynamodb = new AWS.DynamoDB({dynamoDbCrc32: false,apiVersion: '2012-08-10'});104 var _CurrentGameData = {};105 var convStringList = function(array,prifix){106 var _tmpData = [];107 if (array == void 0) {return null;}108 _tmpData = [];109 for (var _arrayId in array) {110 //array[_arrayId] != ''ã ã¨å¤0ã®ã¨ãã«ãã¹ãããããï¼ãªãã§ï¼ï¼111 if (array[_arrayId].toString() != '') {112 if (prifix == 'N') {113 _tmpData.push({N : array[_arrayId].toString()})114 } else {115 _tmpData.push({S : array[_arrayId]})116 }117 }118 }119 return {L : _tmpData};120 };121 var convStringListInLevel = function(array,prifix){122 var _tmpData = [];123 if (array == void 0) {return null;}124 _tmpData = [];125 for (var _arrayId in array) {126 if (array[_arrayId] == void 0) return;127 //array[_arrayId] != ''ã ã¨å¤0ã®ã¨ãã«ãã¹ãããããï¼ãªãã§ï¼ï¼128 if (array[_arrayId].toString() != '') {129 switch (prifix) {130 case 'S':131 _tmpData.push({N : array[_arrayId].toString()});132 break;133 case 'P':134 _tmpData.push(convPain(array[_arrayId]));135 break;136 default:137 _tmpData.push(convStringList(array[_arrayId],'N'));138 }139 }140 }141 return {L : _tmpData};142 };143 var convPain = function(array){144 var _tmpPains = [];145 if (array == void 0) {return null;}146 for (var _array of array) {147 var _tmpPain = {};148 _tmpPain.PainId = {N : _array.PainId.toString()};149 _tmpPain.ScoreCardLevel = {N : _array.ScoreCardLevel.toString()};150 _tmpPain.GetTotalThrowDice = {N : _array.GetTotalThrowDice.toString()};151 _tmpPain.GetPathSteps = {N : _array.GetPathSteps.toString()};152 _tmpPain.PutPainScene = {S : _array.PutPainScene};153 _tmpPain.CardType = {S : _array.CardType};154 _tmpPain.CardId = {N : _array.CardId.toString()};155 if (_array.ReleaseTotalThrowDice == void 0) {156 //ç»é²ãªã157 } else {158 _tmpPain.ReleaseTotalThrowDice = {N : _array.ReleaseTotalThrowDice.toString()};159 _tmpPain.ReleasePathSteps = {N : _array.ReleasePathSteps.toString()};160 _tmpPain.UsedTokenAwarenessId = {N : _array.UsedTokenAwarenessId.toString()};161 _tmpPain.UserAwareness = {S : _array.UserAwareness};162 }163 _tmpPains.push({M : _tmpPain});164 }165 return {L : _tmpPains};166 };167 //JSONå½¢å¼ããDynamoDBå½¢å¼ã¸168 //å±æ§ã¤ããã®ã¨ãnull対ç169 //dynamodbMarshalerã使ãã¨æå¾
ã¨ã¯éãåã«ãªããã¨ããããã使ããªãã170 _CurrentGameData.UserName = {S : CurrentGameData.UserName};171 _CurrentGameData.StartTime = {N : CurrentGameData.StartTime.toString()};172 _CurrentGameData.LastSave = {N : (new Date()).getTime().toString()};173 _CurrentGameData.CloseTime = {N : CurrentGameData.CloseTime.toString()};174 _CurrentGameData.Language = {S : CurrentGameData.Language};175 _CurrentGameData.Scene = {S : CurrentGameData.Scene};176 if (CurrentGameData.PlayingFocus != '') {177 _CurrentGameData.PlayingFocus = {S : CurrentGameData.PlayingFocus};178 }179 _CurrentGameData.PlayingKeyWords = convStringList(CurrentGameData.PlayingKeyWords ,'S');180 _CurrentGameData.PlayNotes = convStringList(CurrentGameData.PlayNotes ,'S');181 _CurrentGameData.PlayLogs = convStringList(CurrentGameData.PlayLogs ,'S');182 _CurrentGameData.DeckAngel = convStringList(CurrentGameData.DeckAngel ,'N');183 _CurrentGameData.UnconsciousAngel = convStringList(CurrentGameData.UnconsciousAngel ,'N');184 _CurrentGameData.DeckInsight = convStringList(CurrentGameData.DeckInsight ,'N');185 _CurrentGameData.UnconsciousInsight= convStringList(CurrentGameData.UnconsciousInsight,'N');186 _CurrentGameData.DeckSetback = convStringList(CurrentGameData.DeckSetback ,'N');187 _CurrentGameData.UnconsciousSetback= convStringList(CurrentGameData.UnconsciousSetback,'N');188 _CurrentGameData.GuardianAngel = convStringList(CurrentGameData.GuardianAngel, 'N');189 _CurrentGameData.ScoreCardLevel = {N : CurrentGameData.ScoreCardLevel.toString()};190 _CurrentGameData.PathSteps = {N : CurrentGameData.PathSteps.toString()};191 _CurrentGameData.LastDiceNumber = {N : CurrentGameData.LastDiceNumber.toString()};192 _CurrentGameData.Pains = convPain(CurrentGameData.Pains);193 _CurrentGameData.TotalThrowDice = {N : CurrentGameData.TotalThrowDice.toString()};194 _CurrentGameData.Direction = {N : CurrentGameData.Direction.toString()};195 _CurrentGameData.Service = convStringListInLevel(CurrentGameData.Service,'S');196 _CurrentGameData.Awareness = convStringListInLevel(CurrentGameData.Awareness,'N');197 _CurrentGameData.Angel = convStringListInLevel(CurrentGameData.Angel,'N');198 _CurrentGameData.Setback = convStringListInLevel(CurrentGameData.Setback,'N');199 _CurrentGameData.TransformSetback = convStringListInLevel(CurrentGameData.TransformSetback,'N');200 _CurrentGameData.TransformInsight = convStringListInLevel(CurrentGameData.TransformInsight,'N');201 _CurrentGameData.TransformFeedback = convStringListInLevel(CurrentGameData.TransformFeedback,'N');202 _CurrentGameData.TransformPain = convStringListInLevel(CurrentGameData.TransformPain,'P');203 _CurrentGameData.InboxAwareness = convStringListInLevel(CurrentGameData.InboxAwareness,'N');204 var params = {205 Item : _CurrentGameData,206 TableName: 'TFGPlayData'207 };208 dynamodb.putItem(params,function(err,data){209 if (err) {210 console.log(err, err.stack); // an error occurred211 return;212 } else {213 //console.log(data); // successful response214 }215 })216 });217 }218}219//DynamoDBLoad on Promise220TfAp.loadGameData = function(paramUserName) {221 return new Promise(function(resolve,reject) {222 var dynamodb = new AWS.DynamoDB({dynamoDbCrc32: false,apiVersion: '2012-08-10'});223 var _tmpData = [];224 var params = {225 ExpressionAttributeValues: {226 ":uname": {S: paramUserName},227 ":ust": {N: '-1'},228 },229 KeyConditionExpression: "UserName = :uname AND StartTime > :ust",230 ScanIndexForward : false,231 Limit: TfAp.SavePoint, 232 TableName: 'TFGPlayData',233 };234 dynamodb.query(params,function(err,data){235 //callback236 if (err) {237 console.log(err, err.stack); // an error occurred238 reject(err);239 return;240 } else {241 var _gameDatas = [];242 //ã¬ã³ã¼ãã§ã«ã¼ã243 for (_dt in data.Items) {244 _gameDatas[_dt] = JSON.parse(dynamodbMarshaler.unmarshalJson(data.Items[_dt]));245 //JSONå½¢å¼ã«å¤æããã¬ã³ã¼ã246 //console.log(_gameDatas[_dt]);247 }248 //JSONã®é
å249 //console.log(_gameDatas);250 //ã½ã¼ã251 _gameDatas.sort(function(val1,val2){252 //sort by LastSave(integer) desc253 return ( val1.LastSave < val2.LastSave ? 1 : -1);254 });255 resolve(_gameDatas);256 }257 });258 });...
collab-extension.js
Source:collab-extension.js
1import { yProvider } from '../yjs-setup.js';2import { RubberBandSelection } from './RubberBandSelection';3import { html, render } from 'lit-html';4import { collabTemplate, uiCoords } from './templates.js';5import { multiSelectTemplate } from '../templates/multiSelect';6import {7 singleSelectTemplate,8 userAwarenessTemplate,9} from '../templates/userAwareness';10import { userListTemplate } from '../templates/userList.js';11import {12 highlightLayerTemplate,13 highlightTemplate,14} from '../templates/highlights.js';15import { setState, state } from '../state/comments.js';16import { layoutService } from '../state/layoutStateMachine.js';17import { featureIsEnabled } from '../boostrap.js';18import { global_cursor } from '../vhv-scripts/global-variables.js';19import { get } from 'lib0/indexeddb';20let DEBUG = false;21function log(text) {22 if (DEBUG) {23 console.log(`[${new Date().toLocaleTimeString()}] ${text}`);24 }25}26export function formatUserElem(elem) {27 const [, qOn, qOff, pitchName, accidental, octave] = elem.classList;28 const formattedElem = {};29 // prettier-ignore30 formattedElem.attrs = formatAttributes({ qOn, qOff, pitchName, accidental, octave });31 // formattedElem.clientIds = Array.from(elem.clientIds);32 return JSON.stringify(formattedElem, null, 2);33}34function formatAttributes(attrs) {35 let qOn = parseQuarterTime(attrs.qOn);36 let qOff = parseQuarterTime(attrs.qOff);37 let duration = qOff - qOn;38 switch (duration) {39 case 0.25:40 duration = '1/4';41 break;42 case 0.5:43 duration = '1/2';44 break;45 case 1:46 case 2:47 case 4:48 duration = duration.toString();49 break;50 default:51 log('Uknown time duration value', duration);52 break;53 }54 let accidental = attrs.accidental.split('-')[1];55 switch (accidental) {56 case 'n':57 accidental = 'natural';58 break;59 case 's':60 accidental = 'sharp';61 break;62 case 'f':63 accidental = 'flat';64 break;65 case 'ff':66 accidental = 'double flat';67 break;68 case 'ss':69 accidental = 'double sharp';70 break;71 default:72 log('Uknown accidental value', accidental);73 break;74 }75 return {76 duration,77 pitch: attrs.pitchName.split('-')[1],78 accidental,79 octave: attrs.octave.split('-')[1],80 };81}82function parseQuarterTime(quarterTime) {83 let [qTimeValue, divisor] = quarterTime.split(/\D/).filter(Boolean);84 qTimeValue = parseInt(qTimeValue, 10);85 return quarterTime.includes('_') ? qTimeValue / divisor : qTimeValue;86}87function defaultClients() {88 return {89 added: [],90 updated: [],91 removed: [],92 };93}94export function updateHandler(clients = defaultClients()) {95 const awStates = Array.from(yProvider.awareness.getStates().entries());96 // console.log(yProvider.awareness.getStates());97 const f = () => {98 let collabContainer = document.querySelector('#output #collab');99 if (!collabContainer) {100 console.log(101 'Element div#collab is not found. Cannot render collaboration elements.'102 );103 collabContainer = document.createElement('div');104 collabContainer.id = 'collab';105 document.querySelector('#output')?.prepend(collabContainer);106 }107 let multiSelects = html`${awStates108 .filter(109 ([_, state]) => state.multiSelect != null && state?.user?.color != null110 )111 .map(([clientId, state]) =>112 multiSelectTemplate(113 clientId,114 clientId === yProvider.awareness.clientID,115 state.multiSelect,116 state.user.color117 )118 )}`;119 let singleSelects = html`${awStates120 .filter(121 ([_, state]) =>122 state?.singleSelect?.elemId != null && state?.user?.color != null123 )124 .map(([clientId, state]) =>125 singleSelectTemplate(126 clientId,127 state.singleSelect.elemId,128 state.user.color129 )130 )}`;131 let userAwareness = html`${awStates132 .filter(133 ([_, state]) =>134 state?.singleSelect?.elemId != null && state?.user?.name != null135 )136 .map(([clientId, state]) =>137 userAwarenessTemplate(138 clientId,139 state.singleSelect.elemId,140 state.user.name141 )142 )}`;143 let commentsVisible = layoutService.state144 .toStrings()145 .some((name) => name.toLowerCase().includes('comment'));146 let highlights = html`${commentsVisible ? 147 html`${state.comments148 ?.filter((c) => c?.highlight != null)149 .map((c) => highlightTemplate(c.id, c.highlight))}`150 : null151 }`152 render(153 html`154 ${collabLayer(multiSelects, singleSelects, userAwareness)}155 ${renderHighlightLayer(highlights)}156 `,157 collabContainer158 );159 // Display connection status (online/offline) for the users sharing the current document160 let onlineElem = document.querySelector('#online-users');161 if (onlineElem) {162 let connectedIds = [...yProvider.awareness.getStates().values()].map(163 (s) => s.user.id164 );165 let copy = [...state.users];166 setState({167 users: copy168 .map((u) => ({ ...u, online: connectedIds.includes(u.id) }))169 .sort((a, b) => b.online - a.online),170 });171 render(html`${userListTemplate(state.users)}`, onlineElem);172 // Initialize bootstrap tooltips173 $('[data-toggle="tooltip"]').tooltip();174 } else {175 console.log(176 'Element div#online-users is not found. Cannot display online user info.'177 );178 }179 };180 clients?.added?.forEach(f);181 clients?.updated?.forEach(f);182 clients?.removed?.forEach(f);183}184// window.addEventListener('DOMContentLoaded', () => {185// if (featureIsEnabled('collaboration')) {186// // Use a MutationObserver to find out when the score output SVG187// // is added to the DOM and attach mouse event listeners to it.188// // Then, disconnect the observer.189// const mutationObserver = new MutationObserver((mutationsList, observer) => {190// for (const mutation of mutationsList) {191// if (mutation.type === 'childList') {192// if (mutation.target.id === 'output') {193// if (194// !mutation.target.onmousedown &&195// !mutation.target.onmousemove &&196// !mutation.target.onmouseup197// ) {198// addListenersToOutput(mutation.target);199// observer.disconnect();200// }201// }202// }203// }204// });205// mutationObserver.observe(document.body, { childList: true, subtree: true });206// }207// });208function collabLayer(...children) {209 let output = document.querySelector('#output');210 let renderBefore = document.querySelector('#output > svg');211 uiCoords.svgHeight = renderBefore?.height.baseVal.value ?? window.innerHeight;212 return collabTemplate(uiCoords.svgHeight, ...children);213}214export function renderHighlightLayer(...children) {215 let output = document.querySelector('#output');216 let svg = document.querySelector('#output > svg');217 let collab = output.querySelector('#collab-container');218 let svgHeight = svg?.height.baseVal.value ?? window.innerHeight;219 return highlightLayerTemplate(svgHeight, ...children);220}221export function addListenersToOutput(outputTarget) {222 let startTime, endTime;223 let shouldMultiSelect = false;224 const rbSelection = new RubberBandSelection();225 console.log('>>>Adding listeners to output')226 document.addEventListener('mousedown', (event) => {227 // Start selecting only when there isn't a note element on the cursor228 if (event.target.nodeName != 'svg') return;229 startTime = performance.now();230 rbSelection.isSelecting = true;231 rbSelection.setUpperCoords(event);232 const selectedAreas = document.querySelectorAll('.multi-select-area');233 const selectToRemove = [...selectedAreas].find(234 (elem) => elem.dataset.clientId == yProvider.awareness.clientID235 );236 if (selectToRemove) {237 yProvider.awareness.setLocalStateField('multiSelect', null);238 }239 });240 // TODO: Use requestAnimationFrame241 document.addEventListener('mousemove', (event) => {242 if (rbSelection.isSelecting) {243 endTime = performance.now();244 let timePassed = endTime - startTime;245 if (timePassed >= 300) {246 rbSelection.setLowerCoords(event);247 rbSelection.show();248 shouldMultiSelect = true;249 }250 }251 });252 document.addEventListener('mouseup', handleMouseUp(yProvider.awareness));253 function handleMouseUp(awareness) {254 return () => {255 rbSelection.reCalculateCoords();256 rbSelection.isSelecting = false;257 if (shouldMultiSelect) {258 // TODO: extremely inefficient, selecting every single note element259 const notes = Array.from(document.querySelectorAll('.note, .beam'));260 const selectedElements = rbSelection.selectNoteElements(notes);261 setNoteBounds(selectedElements);262 const multiSelectedNotes = selectedElements263 .map((note) => note.id)264 .filter((id) => /^note/g.test(id));265 if (multiSelectedNotes.length > 0) {266 awareness?.setLocalStateField('multiSelect', multiSelectedNotes);267 }268 shouldMultiSelect = false;269 }270 rbSelection.resetCoords();271 // rbSelection.selectAreaElem.hidden = true;272 rbSelection.hide();273 startTime = endTime = undefined;274 };275 }276}277function createNoteBounds() {278 /** @type {HTMLElement | null} */ let leftMost = null;279 /** @type {HTMLElement | null} */ let rightMost = null;280 return {281 /**282 * 283 * @param {HTMLElement | null} left 284 * @param {HTMLElement | null} right 285 */286 setBounds(left, right) {287 if (left) {288 leftMost = left;289 }290 if (right) {291 rightMost = right;292 }293 },294 /**295 * 296 * @returns {{ leftMost: HTMLElement | null, rightMost: HTMLElement | null}}297 */298 getBounds() { return { leftMost, rightMost }}299 }300}301export let noteBounds = createNoteBounds();302/**303 * 304 * @param {HTMLElement[]} selectedElements 305 */306function setNoteBounds(selectedElements) {307 if (selectedElements.length > 0) {308 let selectedNotes = [...selectedElements].map(elem => {309 return elem.classList.contains('beam') ? elem.querySelector('.note') : elem310 });311 let { leftMost, rightMost } = findLeftMostAndRightMost(selectedNotes);312 if (leftMost && rightMost) {313 noteBounds.setBounds(leftMost, rightMost);314 }315 console.log({ leftMost, rightMost });316 if (leftMost) {317 global_cursor.CursorNote = leftMost;318 }319 }320}321function findLeftMostAndRightMost(selectedNotes) {322 let leftMost = selectedNotes[0];323 let rightMost = selectedNotes[0];324 for (let note of selectedNotes.slice(1)) {325 let noteBox = note.getBoundingClientRect();326 if (noteBox.left < leftMost?.getBoundingClientRect().left) {327 leftMost = note;328 }329 if (noteBox.left > rightMost?.getBoundingClientRect().left) {330 rightMost = note;331 }332 }333 return { leftMost, rightMost };...
config.ts
Source:config.ts
1import { DisplayProcessor, SpecReporter } from 'jasmine-spec-reporter';2import { Config } from 'protractor';3import SuiteInfo = jasmine.SuiteInfo;4export const config: Config = {5 seleniumAddress: 'http://localhost:4444/wd/hub',6 baseUrl: 'https://login-qan.mimecast.com/u/login/?gta=administration#/login',7 capabilities: {8 //browserName: 'chrome',9 'browserName': 'internet explorer',10 'platform': 'ANY',11 'version': '11',12 'ignoreProtectedModeSettings': true,13 "javascriptEnabled": true,14 "acceptSslCerts": true,15 "allowBlockedContent": true,16 'nativeEvents': false, // have to set false to click on elements17 'unexpectedAlertBehaviour': 'accept',18 'enablePersistentHover': true,19 'disable-popup-blocking': true,20 // chromeOptions: {21 // // args: ['--headless']22 // },23 exclude: ['./tests/**/Lockbox-009.js', './tests/loginqa/Login-014.js', './tests/loginqa/Login-011.js'],24 },25 framework: 'jasmine',26 //directConnect: true,// IE doesnt work with direct connection27 specs: ['./tests/**/Login-001.js'],28 jasmineNodeOpts: {29 defaultTimeoutInterval: 2000000,30 showColors: true,31 },32 // noGlobals: true,33 onPrepare: () => {34 const globals = require('protractor');35 const browser = globals.browser;36 //browser.manage().window().maximize();37 browser.manage().timeouts().setScriptTimeout(11000);38 browser.manage().timeouts().implicitlyWait(10000);39 const Jasmine2HtmlReporter = require('protractor-jasmine2-html-reporter');40 const JasmineReporters = require('jasmine-reporters');41 jasmine.getEnv().addReporter(42 new SpecReporter({43 customProcessors: [CustomProcessor],44 prefixes: { successful: ' ð» -> ', failed: ' ð¥ -> ' }45 }),46 );47 jasmine.getEnv().addReporter(48 new Jasmine2HtmlReporter({49 savePath: 'TResults',50 screenshotsFolder: 'images',51 fileNameDateSuffix: true,52 cleanDestination: true,53 takeScreenshots: true,54 takeScreenshotsOnlyOnFailures: true,55 consolidate: true,56 consolidateAll: true,57 }),58 );59 jasmine.getEnv().addReporter(60 new JasmineReporters.JUnitXmlReporter({61 // JUnit62 savePath: 'TResults/junit',63 consolidateAll: false,64 }),65 );66 },67 afterLaunch: (exitCode) => {68 console.log('exit code is' + exitCode);69 },70 suites: {71 UA: [72 'tests/userAwareness/UserAwareness-001.js',73 'tests/userAwareness/UserAwareness-002.js',74 'tests/userAwareness/UserAwareness-003.js',75 'tests/userAwareness/UserAwareness-004.js',76 'tests/userAwareness/UserAwareness-005.js',77 'tests/userAwareness/UserAwareness-006.js',78 'tests/userAwareness/UserAwareness-007.js',79 'tests/userAwareness/UserAwareness-008.js',80 'tests/userAwareness/UserAwareness-009.js',81 'tests/userAwareness/UserAwareness-010.js',82 ],83 LOGIN: 'tests/login/*.js',84 },85};86class CustomProcessor extends DisplayProcessor {87 public displayJasmineStarted(info: SuiteInfo, log: string): string {88 return `TypeScript ${log}`;89 }...
Using AI Code Generation
1const { launch } = require("qawolf");2const selectors = require("../selectors/test");3describe('test', () => {4 let browser;5 let page;6 beforeAll(async () => {7 browser = await launch({8 viewport: { width: 1440, height: 900 },9 });10 page = await browser.newPage();11 });12 afterAll(async () => {13 await browser.close();14 });15 it('test', async () => {16 await page.click(selectors["#login"]);17 await page.fill(selectors["#email"], "
Using AI Code Generation
1const { UserAwareness } = require('qawolf');2const { launch } = require('qawolf');3const { firefox } = require('playwright');4const { chromium } = require('playwright');5const { webkit } = require('playwright');6const { devices } = require('playwright');7const { devices } = require('playwright');8(async () => {9 const browser = await launch({ launchOptions: { headless: false } });10 const context = await browser.newContext({11 viewport: { width: 1280, height: 800 },12 userAgent: "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.182 Safari/537.36"13 });14 const page = await context.newPage();15 await page.click('input[name="q"]');16 await page.fill('input[name="q"]', 'qawolf');17 await page.press('input[name="q"]', 'Enter');18 await page.click('text=QA Wolf: Automated End-to-End Testing for Web Apps | QA Wolf');19 await page.close();20 await browser.close();21})();22const { UserAwareness } = require('qawolf');23const { launch } = require('qawolf');24const { firefox } = require('playwright');25const { chromium } = require('playwright');26const { webkit } = require('playwright');27const { devices } = require('playwright');28const { devices } = require('playwright');29(async () => {30 const browser = await launch({ launchOptions: { headless: false } });31 const context = await browser.newContext({32 viewport: { width: 1280, height: 800 },
Using AI Code Generation
1const { UserAwareness } = require('qawolf');2const { launch } = require('qawolf');3const { test } = require('qawolf');4const userAwareness = new UserAwareness();5userAwareness.start();6describe('test', () => {7 let browser;8 let page;9 beforeAll(async () => {10 browser = await launch();11 });12 afterAll(async () => {13 await userAwareness.stop();14 await browser.close();15 });16 beforeEach(async () => {17 page = await browser.newPage();18 });19 afterEach(async () => {20 await page.close();21 });22 test('test', async () => {23 await page.type('[name="q"]', 'qawolf');24 await page.click('[name="btnK"]');25 });26});
Using AI Code Generation
1const { UserAwareness } = require("qawolf");2const { userAwareness } = require("qawolf");3const { Browser } = require("qawolf");4const { browser } = require("qawolf");5const { launch } = require("qawolf");6const { create } = require("qawolf");7const { create } = require("qawolf");8const { create } = require("qawolf");9const { create } = require("qawolf");10const { create } = require("qawolf");11const { create } = require("qawolf");12const { create } = require("qawolf");13const { create } = require("qawolf");14const { create } = require("qawolf");15const { create } = require("qawolf");16const { create } = require("qawolf");17const { create } = require("qawolf");18const { create } = require("qawolf");19const { create } = require("qawolf");20const { create } = require("qawolf");21const { create } = require("qawolf");22const { create } = require("qawolf");23const { create } = require("qawolf");24const { create } = require("qawolf");
Using AI Code Generation
1const { UserAwareness } = require('qawolf');2const userAwareness = new UserAwareness();3const { create } = require('qawolf');4const { launch } = require('qawolf');5const browser = await launch();6const { launch } = require('qawolf');7const browser = await launch();8const { create } = require('qawolf');9const { launch } = require('qawolf');10const browser = await launch();11const { create } = require('qawolf');12const { launch } = require('qawolf');13const browser = await launch();14const { create } = require('qawolf');15const { launch } = require('qawolf');16const browser = await launch();17const { create } = require('qawolf');18const { launch } = require('qawolf');19const browser = await launch();20const { create } = require('qawolf');21const { launch } = require('qawolf');22const browser = await launch();23const { create } = require('qawolf');24const { launch
Using AI Code Generation
1const { UserAwareness } = require("qawolf");2const qawolf = require("qawolf");3const browser = await qawolf.launch();4const context = await browser.newContext();5const page = await context.newPage();6const userAwareness = new UserAwareness(page);7await userAwareness.run();8await browser.close();9await qawolf.stopVideos();10await qawolf.stopVideos();11const qawolf = require("qawolf");12const browser = await qawolf.launch();13const context = await browser.newContext();14const page = await context.newPage();15await qawolf.startVideos(page);16await qawolf.userAwareness(page);17await qawolf.stopVideos();18await browser.close();
Using AI Code Generation
1const { UserAwareness } = require('qawolf');2const { run } = require('qawolf');3const assert = require('assert');4const { create } = require('qawolf');5const { launch } = require('qawolf');6const { create } = require('qawolf');7const { launch } = require('qawolf');8const { create } = require('qawolf');9const { launch } = require('qawolf');10const { create } = require('qawolf');11const { launch } = require('qawolf');12const { create } = require('qawolf');13const { launch } = require('qawolf');14const { create } = require('qawolf');15const { launch } = require('qawolf');16const { create } = require('qawolf');17const { launch } = require('qawolf');18const { create } = require('qawolf');19const { launch } = require('qawolf');20const { create } = require('qawolf');21const { launch } = require('qawolf');22const { create } = require('qawolf');23const { launch } = require('qawolf');24const { create } = require
Using AI Code Generation
1const { UserAwareness } = require("qawolf");2const { launch } = require("qawolf");3const { firefox } = require("playwright");4const browser = await launch({ browser: "firefox" });5const context = await browser.newContext();6const page = await context.newPage();7const userAwareness = new UserAwareness(page);8await userAwareness.start();9await userAwareness.stop();10await userAwareness.save("test.mp4");11await browser.close();12const { launch } = require("qawolf");13const { firefox } = require("playwright");14const browser = await launch({ browser: "firefox" });15const context = await browser.newContext();16const page = await context.newPage();17await page.click("text=Get started");18await browser.close();
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!