How to use timer method in stryker-parent

Best JavaScript code snippet using stryker-parent

OriginalTimer.js

Source:OriginalTimer.js Github

copy

Full Screen

1//=============================================================================2// OriginalTimer.js3// ----------------------------------------------------------------------------4// Copyright (c) 2016 fftfantt5// This software is released under the MIT License.6// http://opensource.org/licenses/mit-license.php7// ----------------------------------------------------------------------------8// Version9// 0.1.0 2016/2/15 β版10// 1.0.0 2016/2/21 初版11// 1.0.1 2016/2/21 TimerSaveがYESでも再実行されない不具合修正12// 1.0.2 2016/2/21 初期化関連の処理の見直し13// 1.0.3 2016/3/26 タイマースタート時に即時でカウントしないよう変更14// 1.0.4 2016/4/03 戦闘終了後にエラーになってしまう不具合を解消15// 1.1.0 2016/4/03 タイマーの終了後に指定のスイッチをONにするコマンド追加16// 1.2.0 2016/4/03 タイマーのカウントをリセットするコマンド追加17// 1.2.1 2016/4/03 タイマー値の取得で設定値が取れない不具合修正18// 1.3.0 2016/6/09 設定時間操作、実時間操作のコマンド追加19// ----------------------------------------------------------------------------20// [HomePage]: https://googledrive.com/host/0BxiSZT-B8lvFOUFhVTF6VjNnUGc/index.html 21// [Twitter] : https://twitter.com/fftfantt/22// [GitHub] : https://github.com/fftfantt/23//=============================================================================24/*:25 * @plugindesc オリジナルタイマー26 * @author fftfantt27 *28 * @param TimerSave29 * @desc タイマーの値をセーブデータに含めるか YES or NO30 * @default NO31 * @help32 * 33 * ■説明34 * このプラグインは1日から1/100秒単位でカウントできるオリジナルタイマーを実装します。35 * カウントダウンのほか、カウントアップにも対応しています。36 * 動的テキスト表示部分のロジックについては、トリアコンタン様の「DTextPicture.js」37 * を参考にさせていただいております。この場をお借りして感謝申し上げます。38 *39 * ■利用規約40 * 当プラグインはMITライセンスのもとで公開されています。41 * https://osdn.jp/projects/opensource/wiki/licenses%2FMIT_license42 * ヘッダーのライセンス表記のみ残してください。43 * 商用利用、年齢制限のあるゲームへの使用、改変が可能です。44 * クレジットは不要です。45 * 当プラグインの不具合に損害の責任についても、MITライセンスの表記どおりです。46 *47 * ■使い方の概要48 * イベントのコマンド追加からプラグインコマンドを選択し、以下のようなプラグイン49 * コマンドでタイマーを設定後開始してください。50 * こちらにも詳しい使い方が記載されています。51 * https://github.com/fftfantt/RPGMakerMV/wiki/OriginalTimer.js52 * 53 * ■タイマーの設定54 *  ◆パラメータ55 *   引数1:タイマーの設定を行う場合の引数 [設定 or SET]56 *   引数2:タイマーの種類[アップ or ダウン or UP or DOWN] 57 *   引数3:設定時間 (1d1h1m1s1x1c のように記載)[日 or d 時間 or h 分 or m 秒 or s x(1/10秒) c(1/100秒)]58 *   引数4:ピクチャ番号[1~100]59 *   引数5:フォントサイズ60 *   引数6:画面X61 *   引数7:画面Y62 *   引数8:表示モード[表示 or 非表示 or DISPLAY or HIDE]63 *   引数9:表示形式[D日 HH時MM分SS.XC秒 や HH:MM:SS:XC で自由に]64 *  ◆コマンド例65 *   オリジナルタイマー 設定 ダウン 2d1h30m 99 24 10 10 表示 D日 HH時MM分SS.XC秒66 *   ORIGINALTIMER SET DOWN 1h30m 99 24 10 10 DISPLAY HH:MM:SS:XC67 *   オリジナルタイマー 設定 アップ 1h30m 10 24 630 10 非表示 HH:MM:SS.XC68 *   ORIGINALTIMER SET UP 1h30m 10 24 630 10 HIDE HH:MM:SS.XC69 * 70 * ■タイマーの開始71 *  ◆パラメータ72 *   引数1:タイマーを開始もしくは再開する場合の引数 [開始 or 再開 or START]73 *  ◆コマンド例74 *   オリジナルタイマー 開始75 *   ORIGINALTIMER START76 * 77 * ■タイマーの停止78 *  ◆パラメータ79 *   引数1:タイマーを停止する場合の引数 [停止 or STOP]80 *  ◆コマンド例81 *   オリジナルタイマー 停止82 *   ORIGINALTIMER STOP83 * 84 * ■タイマーの表示85 *  ◆パラメータ86 *   引数1:タイマーを表示する場合の引数 [表示 or DISPLAY]87 *  ◆コマンド例88 *   オリジナルタイマー 表示89 *   ORIGINALTIMER DISPLAY90 * 91 * ■タイマーの非表示92 *  ◆パラメータ93 *   引数1:タイマーを非表示にする場合の引数 [非表示 or HIDE]94 *  ◆コマンド例95 *   オリジナルタイマー 非表示96 *   ORIGINALTIMER HIDE97 * 98 * ■タイマーの初期化99 *   引数1:タイマーを初期化する場合の引数 [初期化 or INITIALIZE]100 *  ◆コマンド例101 *   オリジナルタイマー 初期化102 *   ORIGINALTIMER INITIALIZE103 * 104 * ■タイマー値の取得105 *   引数1:タイマーに関する値を取得する場合の引数 [取得 or GET]106 *   引数2:取得する値の種類 [状態 or STATE or 値 or VALUE etc]107 *   引数3:値を格納する変数108 *  ◆コマンド例109 *   オリジナルタイマー 取得 状態 1110 *   ORIGINALTIMER GET STATE 1111 *   オリジナルタイマー 取得 値 1112 *   ORIGINALTIMER GET VALUE 1113 *   オリジナルタイマー 取得 日 1114 *   ORIGINALTIMER GET DAY 1115 *   オリジナルタイマー 取得 時 1116 *   ORIGINALTIMER GET HR 1117 *   オリジナルタイマー 取得 分 1118 *   ORIGINALTIMER GET MIN 1119 *   オリジナルタイマー 取得 秒 1120 *   ORIGINALTIMER GET SEC 1121 *   オリジナルタイマー 取得 コンマ秒 1122 *   ORIGINALTIMER GET HSEC 1123 * 124 * ■タイマー終了後のスイッチ操作125 *   引数1:タイマー終了後にスイッチを操作する場合の引数 [スイッチ or SWITCH]126 *   引数2:操作の種類 [オン or ON or オフ or OFF or リバース or REVERSE]127 *   引数3:操作するスイッチ番号128 *  ◆コマンド例129 *   オリジナルタイマー スイッチ オン 1130 *   ORIGINALTIMER SWITCH ON 1131 *   オリジナルタイマー スイッチ オフ 2132 *   ORIGINALTIMER SWITCH OFF 2133 *   オリジナルタイマー スイッチ リバース 3134 *   ORIGINALTIMER SWITCH REVERSE 3135 * 136 * ■タイマーカウントのリセット137 *   引数1:タイマーカウントのリセットを行う場合の引数 [リセット or RESET]138 *  ◆コマンド例139 *   オリジナルタイマー リセット140 *   ORIGINALTIMER RESET141 * 142 *143 * ■タイマー設定時間の操作144 * 引数1:タイマー設定時間の操作を行う場合の引数 [設定時間操作 or LIMITCHANGE]145 * 引数2:設定時間の増減[増加 or 減少 or UP or DOWN] 146 * 引数3:設定時間 (1d1h1m1s1x1c のように記載)[日 or d 時間 or h 分 or m 秒 or s x(1/10秒) c(1/100秒)]147 *  ◆コマンド例148 * オリジナルタイマー 設定時間操作 増加 3m149 * オリジナルタイマー 設定時間操作 減少 10s150 *   ORIGINALTIMER LIMITCHANGE UP 3m151 *   ORIGINALTIMER LIMITCHANGE DOWN 3m152 * 153 * ■タイマー実時間の操作154 * 引数1:タイマー実時間の操作を行う場合の引数 [実時間操作 or TIMECHANGE]155 * 引数2:実時間の増減[進行 or 逆行 or UP or DOWN] 156 * 引数3:設定時間 (1d1h1m1s1x1c のように記載)[日 or d 時間 or h 分 or m 秒 or s x(1/10秒) c(1/100秒)]157 *  ◆コマンド例158 * オリジナルタイマー 実時間操作 進行 3m159 * オリジナルタイマー 実時間操作 逆行 10s160 *   ORIGINALTIMER TIMECHANGE UP 3m161 *   ORIGINALTIMER TIMECHANGE DOWN 3m162 * 163 */164(function () {165 166 var parameters = PluginManager.parameters('OriginalTimer');167 var TimerSave = parameters['TimerSave'].toUpperCase();168 169 var OriginalTimer = null;170 var SetFlag = false;171 var RunFlag = false;172 var DisplayMode = '';173 var Count = 0;174 var CountUnit = 0;175 var CountTime = 0;176 var CommndType = '';177 var TimerType = '';178 var TimerLimit = 0;179 var day = 0;180 var hr = 0;181 var min = 0;182 var sec = 0;183 var Hsec = 0;184 var TimerText = '';185 var ShowText = '';186 187 var pictureId = 0;188 var fontsize = 32; 189 var name = '';190 var origin = 0;191 var x = 0;192 var y = 0;193 var scaleX = 100;194 var scaleY = 100;195 var opacity = 255;196 var blendMode = 0;197 198 var SwitchState = '';199 var SwitchNumber = 0;200 var prevMsec = 0;201 function getCurrentMsec(){202 return SceneManager._currentTime || Date.now();203 }204 //=============================================================================205 // Game_Interpreter_pluginCommand206 // プラグインコマンドが実行されたときに処理されます207 //=============================================================================208 209 var _Game_Interpreter_pluginCommand = Game_Interpreter.prototype.pluginCommand;210 Game_Interpreter.prototype.pluginCommand = function(command, args) {211 _Game_Interpreter_pluginCommand.call(this, command, args);212 213 if (command === "オリジナルタイマー" || command.toUpperCase() === "ORIGINALTIMER" ) {214 if ($gameTimer !== null){215 if (!Object.prototype.hasOwnProperty.call($gameTimer, '_fftfanttOriginalTimer_Run')){216 if (TimerSave == 'YES') Game_Timer.prototype.fftfanttOriginalTimer_Initialize();217 }218 }219 CommndType = args[0];220 221 if (CommndType == '設定' || CommndType.toUpperCase() == 'SET'){222 if (RunFlag){223 console.log('オリジナルタイマーは実行中です');224 return;225 }226 SetFlag = true;227 if (TimerSave == 'YES'){228 Game_Timer.prototype.fftfanttOriginalTimer_Initialize();229 $gameTimer._fftfanttOriginalTimer_Set = true;230 }231 TimerSet(args);232 }233 if (CommndType == '開始' || CommndType == '再開' || CommndType.toUpperCase() == 'START'){234 if (RunFlag){235 if ($gameTemp.isPlaytest()) console.log('オリジナルタイマーは実行中です');236 return;237 }238 if (!SetFlag){239 if (!$gameTemp.isPlaytest()) console.log('タイマーが設定されていません');240 return;241 }242 RunFlag = true;243 if (TimerSave == 'YES') $gameTimer._fftfanttOriginalTimer_Run = true;244 prevMsec = getCurrentMsec();245 TimerRun();246 OriginalTimer = setInterval(TimerRun,CountUnit);247 }248 249 if (CommndType == '停止' || CommndType.toUpperCase() == 'STOP'){250 clearInterval(OriginalTimer);251 RunFlag = false;252 if (TimerSave == 'YES') $gameTimer._fftfanttOriginalTimer_Run = false;253 }254 255 if (CommndType == '表示' || CommndType.toUpperCase() == 'DISPLAY'){256 opacity = 255257 if (TimerSave == 'YES') $gameTimer._fftfanttOriginalTimer_DisplayMode = '表示';258 return;259 }260 261 if (CommndType == '非表示' || CommndType.toUpperCase() == 'HIDE'){262 opacity = 0;263 if (TimerSave == 'YES') $gameTimer._fftfanttOriginalTimer_DisplayMode = '非表示';264 return;265 }266 267 if (CommndType == '初期化' || CommndType.toUpperCase() == 'INITIALIZE'){268 if (TimerSave == 'YES'){269 Game_Timer.prototype.fftfanttOriginalTimer_Initialize();270 }271 TimerInitialize();272 return;273 }274 if (CommndType == '取得' || CommndType.toUpperCase() == 'GET'){275 TimerGet(args);276 }277 278 if (CommndType == 'スイッチ' || CommndType.toUpperCase() == 'SWITCH'){279 if (!SetFlag){280 if (!$gameTemp.isPlaytest()) console.log('タイマーが設定されていません');281 return;282 }283 SwitchState =args[1]284 switch (args[1]) {285 case 'オン':286 SwitchState = 'ON';287 break;288 case 'オフ':289 SwitchState = 'OFF';290 break;291 case 'リバース':292 SwitchState = 'REVERSE';293 break;294 }295 SwitchNumber = parseInt(args[2], 10);296 if (TimerSave == 'YES'){297 $gameTimer._fftfanttOriginalTimer_SwitchState = SwitchState298 $gameTimer._fftfanttOriginalTimer_SwitchNumber = SwitchNumber299 }300 }301 302 if (CommndType == 'リセット' || CommndType.toUpperCase() == 'RESET'){303 if (!SetFlag){304 if (!$gameTemp.isPlaytest()) console.log('タイマーが設定されていません');305 return;306 }307 Count = 0;308 if (!RunFlag && pictureId !== 0) $gameScreen.erasePicture(pictureId);309 }310 311 if (CommndType == '設定時間操作' || CommndType.toUpperCase() == 'LIMITCHANGE'){312 if (!SetFlag){313 if (!$gameTemp.isPlaytest()) console.log('タイマーが設定されていません');314 return;315 }316 var timer_tmp_array = args[2].match(/((\d+)(d|日))?((\d+)(h|時間))?((\d+)(m|分間?))?((\d+)(s|秒間?))?((\d+)(x))?((\d+)(c))?/);317 if (args[1] == '増加' || args[1] == 'UP'){318 if (timer_tmp_array[2]) TimerLimit = TimerLimit + parseInt(timer_tmp_array[2],10) * 8640000;319 if (timer_tmp_array[5]) TimerLimit = TimerLimit + parseInt(timer_tmp_array[5],10) * 360000;320 if (timer_tmp_array[8]) TimerLimit = TimerLimit + parseInt(timer_tmp_array[8],10) * 6000;321 if (timer_tmp_array[11]) TimerLimit = TimerLimit + parseInt(timer_tmp_array[11],10) * 100;322 if (timer_tmp_array[14]) TimerLimit = TimerLimit + parseInt(timer_tmp_array[14],10) * 10;323 if (timer_tmp_array[17]) TimerLimit = TimerLimit + parseInt(timer_tmp_array[17],10);324 }325 else if (args[1] == '減少' || args[1] == 'DOWN'){326 if (timer_tmp_array[2]) TimerLimit = TimerLimit - parseInt(timer_tmp_array[2],10) * 8640000;327 if (timer_tmp_array[5]) TimerLimit = TimerLimit - parseInt(timer_tmp_array[5],10) * 360000;328 if (timer_tmp_array[8]) TimerLimit = TimerLimit - parseInt(timer_tmp_array[8],10) * 6000;329 if (timer_tmp_array[11]) TimerLimit = TimerLimit - parseInt(timer_tmp_array[11],10) * 100;330 if (timer_tmp_array[14]) TimerLimit = TimerLimit - parseInt(timer_tmp_array[14],10) * 10;331 if (timer_tmp_array[17]) TimerLimit = TimerLimit - parseInt(timer_tmp_array[17],10);332 if (TimerLimit < 0) TimerLimit = 0;333 }334 if (!RunFlag && pictureId !== 0) $gameScreen.erasePicture(pictureId); 335 }336 337 if (CommndType == '実時間操作' || CommndType.toUpperCase() == 'TIMECHANGE'){338 if (!SetFlag){339 if (!$gameTemp.isPlaytest()) console.log('タイマーが設定されていません');340 return;341 }342 var timer_tmp_array = args[2].match(/((\d+)(d|日))?((\d+)(h|時間))?((\d+)(m|分間?))?((\d+)(s|秒間?))?((\d+)(x))?((\d+)(c))?/);343 if (args[1] == '進行' || args[1].toUpperCase() == 'UP'){344 if (timer_tmp_array[2]) Count = Count + parseInt(timer_tmp_array[2],10) * 8640000;345 if (timer_tmp_array[5]) Count = Count + parseInt(timer_tmp_array[5],10) * 360000;346 if (timer_tmp_array[8]) Count = Count + parseInt(timer_tmp_array[8],10) * 6000;347 if (timer_tmp_array[11]) Count = Count + parseInt(timer_tmp_array[11],10) * 100;348 if (timer_tmp_array[14]) Count = Count + parseInt(timer_tmp_array[14],10) * 10;349 if (timer_tmp_array[17]) Count = Count + parseInt(timer_tmp_array[17],10);350 if (Count > TimerLimit) Count = TimerLimit;351 }352 else if (args[1] == '逆行' || args[1].toUpperCase() == 'DOWN'){353 if (timer_tmp_array[2]) Count = Count - parseInt(timer_tmp_array[2],10) * 8640000;354 if (timer_tmp_array[5]) Count = Count - parseInt(timer_tmp_array[5],10) * 360000;355 if (timer_tmp_array[8]) Count = Count - parseInt(timer_tmp_array[8],10) * 6000;356 if (timer_tmp_array[11]) Count = Count - parseInt(timer_tmp_array[11],10) * 100;357 if (timer_tmp_array[14]) Count = Count - parseInt(timer_tmp_array[14],10) * 10;358 if (timer_tmp_array[17]) Count = Count - parseInt(timer_tmp_array[17],10);359 if (Count < 0) Count = 0;360 }361 if (!RunFlag && pictureId !== 0) $gameScreen.erasePicture(pictureId); 362 }363 364 }365 };366 //=============================================================================367 // TimerInitialize368 // プラグインコマンドで指定された値をセットします369 //=============================================================================370 371 function TimerInitialize(){372 OriginalTimer = null;373 SetFlag = false;374 RunFlag = false;375 DisplayMode = '';376 Count = 0;377 CountUnit = 0;378 CountTime = 0;379 CommndType = '';380 TimerType = '';381 TimerLimit = 0;382 day = 0;383 hr = 0;384 min = 0;385 sec = 0;386 Hsec = 0;387 TimerText = '';388 ShowText = '';389 pictureId = 0;390 fontsize = 32; 391 name = '';392 origin = 0;393 x = 0;394 y = 0;395 scaleX = 100;396 scaleY = 100;397 opacity = 255;398 blendMode = 0;399 SwitchState = '';400 SwitchNumber = 0;401 if (pictureId !== 0) $gameScreen.erasePicture(pictureId);402 };403 404 405 //=============================================================================406 // TimerSet407 // プラグインコマンドで指定された値をセットします408 //=============================================================================409 410 function TimerSet(args){411 if (pictureId !== 0) $gameScreen.erasePicture(pictureId);412 TimerType = args[1];413 var timer_tmp_array = args[2].match(/((\d+)(d|日))?((\d+)(h|時間))?((\d+)(m|分間?))?((\d+)(s|秒間?))?((\d+)(x))?((\d+)(c))?/);414 TimerLimit = 0;415 if (timer_tmp_array[2]) TimerLimit = TimerLimit + parseInt(timer_tmp_array[2],10) * 8640000;416 if (timer_tmp_array[5]) TimerLimit = TimerLimit + parseInt(timer_tmp_array[5],10) * 360000;417 if (timer_tmp_array[8]) TimerLimit = TimerLimit + parseInt(timer_tmp_array[8],10) * 6000;418 if (timer_tmp_array[11]) TimerLimit = TimerLimit + parseInt(timer_tmp_array[11],10) * 100;419 if (timer_tmp_array[14]) TimerLimit = TimerLimit + parseInt(timer_tmp_array[14],10) * 10;420 if (timer_tmp_array[17]) TimerLimit = TimerLimit + parseInt(timer_tmp_array[17],10);421 pictureId = parseInt(args[3],10);422 fontsize = parseInt(args[4],10);423 x = parseInt(args[5],10);424 y = parseInt(args[6],10);425 DisplayMode = args[7];426 if (DisplayMode == '非表示' || DisplayMode.toUpperCase() == 'HIDE'){427 opacity = 0;428 if (TimerSave == 'YES') $gameTimer._fftfanttOriginalTimer_DisplayMode = '非表示';429 }else{430 opacity = 255;431 if (TimerSave == 'YES') $gameTimer._fftfanttOriginalTimer_DisplayMode = '表示';432 }433 TimerText = args[8];434 if (args.length > 8){435 for (var i=9;i<args.length; i++) {436 TimerText = TimerText + ' ' + args[i];437 }438 }439 TimerText = TimerText.toUpperCase();440 Count = 0;441 CountUnit = 1000;442 if (~TimerText.indexOf('X') || ~args[2].indexOf('x')) CountUnit = 100;443 if (~TimerText.indexOf('C') || ~args[2].indexOf('x')) CountUnit = 10;444 if (TimerSave == 'YES'){445 $gameTimer._fftfanttOriginalTimer_TimerType = TimerType;446 $gameTimer._fftfanttOriginalTimer_TimerLimit = args[2];447 $gameTimer._fftfanttOriginalTimer_TimerText = TimerText;448 $gameTimer._fftfanttOriginalTimer_PctureId = pictureId;449 $gameTimer._fftfanttOriginalTimer_FontSize = fontsize;450 $gameTimer._fftfanttOriginalTimer_X = x;451 $gameTimer._fftfanttOriginalTimer_Y = y;452 $gameTimer._fftfanttOriginalTimer_DisplayMode = DisplayMode;453 $gameTimer._fftfanttOriginalTimer_TimerText = TimerText;454 $gameTimer._fftfanttOriginalTimer_Set = true;455 }456 }457 //=============================================================================458 // TimerRun459 // タイマー実行時の処理460 //=============================================================================461 462 function TimerRun(){463 if (Count >= TimerLimit) {464 RunFlag = false;465 if (SwitchNumber > 0){466 if (SwitchState = 'ON') SwitchState = true;467 if (SwitchState = 'OFF') SwitchState = false;468 if (SwitchState = 'REVERSE'){469 console.log(SwitchState)470 if ($gameSwitches._data[SwitchNumber] == null) SwitchState = false;471 SwitchState = !$gameSwitches._data[SwitchNumber]472 }473 $gameSwitches.setValue(SwitchNumber,SwitchState);474 }475 if (pictureId !== 0) $gameScreen.erasePicture(pictureId);476 if (TimerSave == 'YES') $gameTimer._fftfanttOriginalTimer_Run = false;477 }478 if (!RunFlag){479 clearInterval(OriginalTimer);480 return;481 }482 var now = getCurrentMsec();483 // NB: SceneManager.updateMain と同じ判定である事484 var fTime = (now - prevMsec) / 1000;485 if (fTime > 0.25) fTime = 0.25;486 Count = Count + Math.max(0, fTime * 100);487 prevMsec = now;488 if (TimerType == 'アップ' || TimerType.toUpperCase() == 'UP'){489 CountTime = Math.round(Count);490 }else{491 CountTime = TimerLimit - Math.round(Count);492 }493 day = parseInt(Math.floor(CountTime / 8640000),10);494 hr = parseInt((CountTime % 8640000) / 360000,10);495 min = parseInt((CountTime % 360000) / 6000,10);496 sec = parseInt((CountTime % 6000)/100,10);497 Hsec = CountTime % 100;498 ShowText = TimerText;499 ShowText = ShowText.replace("D",day);500 ShowText = ShowText.replace("HH",("0"+hr).slice(-2));501 ShowText = ShowText.replace("H",hr);502 ShowText = ShowText.replace("MM",("0"+min).slice(-2));503 ShowText = ShowText.replace("M",min);504 ShowText = ShowText.replace("SS",("0"+sec).slice(-2));505 ShowText = ShowText.replace("S",sec);506 ShowText = ShowText.replace("X",("0"+Hsec).slice(-2).substr(0,1));507 ShowText = ShowText.replace("C",("0"+Hsec).slice(-2).substr(1,1));508 name = 'OriginalTimer' + Date.now().toString();509 $gameScreen.showPicture(pictureId, name, origin, x, y, scaleX, scaleY, opacity, blendMode);510 if (TimerSave == 'YES') $gameTimer._fftfanttOriginalTimer_Count = Count;511 };512 //=============================================================================513 // TimerGet514 // プラグインコマンドで指定されたタイマーの値を取得します515 //=============================================================================516 function TimerGet(args){517 var GetType = args[1].toUpperCase518 if (args[1] == '表示値' || args[1].toUpperCase() == 'DISPLAYVALUE'){519 $gameVariables._data[parseInt(args[2],10)] = ShowText;520 return;521 }522 if (args[1] == '値' || args[1].toUpperCase() == 'VALUE'){523 $gameVariables._data[parseInt(args[2],10)] = parseInt(CountTime,10);524 return;525 }526 if (args[1] == 'セット値' || args[1].toUpperCase() == 'SETVALUE'){527 $gameVariables._data[parseInt(args[2],10)] = parseInt(TimerLimit,10);528 return;529 }530 if (args[1] == '日' || args[1].toUpperCase() == 'DAY' || args[1].toUpperCase() == 'D'){531 $gameVariables._data[parseInt(args[2],10)] = parseInt(day,10);532 return;533 }534 if (args[1] == '時' || args[1].toUpperCase() == 'HR' || args[1].toUpperCase() == 'H'){535 $gameVariables._data[parseInt(args[2],10)] = parseInt(hr,10);536 return;537 }538 if (args[1]== '分' || args[1].toUpperCase() == 'MIN' || args[1].toUpperCase() == 'M'){539 $gameVariables._data[parseInt(args[2],10)] = parseInt(min,10);540 return;541 }542 if (args[1] == '秒' || args[1].toUpperCase() == 'SEC' || args[1].toUpperCase() == 'S'){543 $gameVariables._data[parseInt(args[2],10)] = parseInt(sec,10);544 return;545 }546 if (args[1] == 'コンマ秒' || args[1].toUpperCase() == 'HSEC' || args[1].toUpperCase() == 'XC'){547 $gameVariables._data[parseInt(args[2],10)] = parseInt(Hsec,10);548 return;549 }550 if (args[1] == '状態'){551 if (RunFlag) {552 $gameVariables._data[parseInt(args[2],10)] = '実行中';553 } else {554 $gameVariables._data[parseInt(args[2],10)] = '停止中'555 }556 return;557 }558 if (args[1].toUpperCase() == 'STATE'){559 if (RunFlag) {560 $gameVariables._data[parseInt(args[2],10)] = 'RUN';561 } else {562 $gameVariables._data[parseInt(args[2],10)] = 'STOP';563 }564 return;565 }566 }567 //=============================================================================568 // Sprite_Picture569 // 画像の動的生成を追加定義します。570 //=============================================================================571 var _Sprite_Picture_loadBitmap = Sprite_Picture.prototype.loadBitmap;572 Sprite_Picture.prototype.loadBitmap = function() {573 if (this.picture()._name == name) {574 this.fftfanttOriginalTimer_UpdateShowText();575 } else {576 _Sprite_Picture_loadBitmap.call(this);577 }578 };579 Sprite_Picture.prototype.fftfanttOriginalTimer_UpdateShowText = function(bitmap) {580 this.bitmap = new Bitmap(ShowText.length * fontsize + x ,(fontsize + y) *1.0 ) ;581 this.bitmap.fontSize = fontsize;582 this.bitmap.clear();583 this.bitmap.drawText(ShowText, x, y,0 ,0, "left");584 };585 //=============================================================================586 // Scene_Save587 // TimerSaveがNOの場合、セーブ前にオリジナルタイマーのオブジェクトを削除します588 //=============================================================================589 590 var _Scene_Save_onSavefileOk = Scene_Save.prototype.onSavefileOk;591 Scene_Save.prototype.onSavefileOk = function() {592 if (pictureId !== 0) $gameScreen.erasePicture(pictureId);593 if (TimerSave !== 'YES'){594 delete $gameTimer._fftfanttOriginalTimer_Count;595 delete $gameTimer._fftfanttOriginalTimer_Set;596 delete $gameTimer._fftfanttOriginalTimer_Run;597 delete $gameTimer._fftfanttOriginalTimer_Display;598 delete $gameTimer._fftfanttOriginalTimer_TimerType;599 delete $gameTimer._fftfanttOriginalTimer_TimerLimit;600 delete $gameTimer._fftfanttOriginalTimer_PctureId;601 delete $gameTimer._fftfanttOriginalTimer_FontSize;602 delete $gameTimer._fftfanttOriginalTimer_X;603 delete $gameTimer._fftfanttOriginalTimer_Y;604 delete $gameTimer._fftfanttOriginalTimer_DisplayMode;605 delete $gameTimer._fftfanttOriginalTimer_TimerText;606 delete $gameTimer._fftfanttOriginalTimer_SwitchState;607 delete $gameTimer._fftfanttOriginalTimer_SwitchNumber;608 }609 _Scene_Save_onSavefileOk.call(this);610 };611 //=============================================================================612 // Scene_Base613 // 戦闘終了後にピクチャが呼び出せないエラーを回避します614 //=============================================================================615 var _Scene_Base_prototype_isReady = Scene_Base.prototype.isReady;616 Scene_Base.prototype.isReady = function() {617 if (pictureId !== 0) $gameScreen.erasePicture(pictureId);618 return _Scene_Base_prototype_isReady.call(this);619 };620 //=============================================================================621 // Scene_Load622 // ロード時にタイマーを再実行するための処理追加定義します623 //=============================================================================624 var _Scene_Load_onLoadSuccess = Scene_Load.prototype.onLoadSuccess;625 Scene_Load.prototype.onLoadSuccess = function() {626 _Scene_Load_onLoadSuccess.call(this);627 Game_Timer.prototype.fftfanttOriginalTimer_Reinitiation();628 };629 630 //=============================================================================631 // Game_Timer632 // オリジナルタイマー用のメソッドを追加定義します633 //=============================================================================634 635 Game_Timer.prototype.fftfanttOriginalTimer_Initialize = function() {636 if (TimerSave !== 'YES') return;637 if (pictureId !== 0) $gameScreen.erasePicture(pictureId);638 this._fftfanttOriginalTimer_Count = 0;639 this._fftfanttOriginalTimer_Set = false;640 this._fftfanttOriginalTimer_Run = false;641 this._fftfanttOriginalTimer_TimerType = '';642 this._fftfanttOriginalTimer_TimerLimit = 0;643 this._fftfanttOriginalTimer_PctureId = 0;644 this._fftfanttOriginalTimer_FontSize = 0;645 this._fftfanttOriginalTimer_X = 0;646 this._fftfanttOriginalTimer_Y = 0;647 this._fftfanttOriginalTimer_DisplayMode = '';648 this._fftfanttOriginalTimer_TimerText = '';649 this._fftfanttOriginalTimer_SwitchNumber = 0;650 this._fftfanttOriginalTimer_SwitchState = '';651 };652 653 Game_Timer.prototype.fftfanttOriginalTimer_Reinitiation = function() {654 if (TimerSave !== 'YES') return;655 if ($gameTimer == null) return;656 if (!Object.prototype.hasOwnProperty.call($gameTimer, '_fftfanttOriginalTimer_Set')) return;657 if (!$gameTimer._fftfanttOriginalTimer_Set) return;658 var args = [];659 args[0] = '設定';660 args[1] = $gameTimer._fftfanttOriginalTimer_TimerType;661 args[2] = $gameTimer._fftfanttOriginalTimer_TimerLimit;662 args[3] = $gameTimer._fftfanttOriginalTimer_PctureId;663 args[4] = $gameTimer._fftfanttOriginalTimer_FontSize;664 args[5] = $gameTimer._fftfanttOriginalTimer_X;665 args[6] = $gameTimer._fftfanttOriginalTimer_Y;666 args[7] = $gameTimer._fftfanttOriginalTimer_DisplayMode;667 args[8] = $gameTimer._fftfanttOriginalTimer_TimerText;668 SetFlag = $gameTimer._fftfanttOriginalTimer_Set669 RunFlag = $gameTimer._fftfanttOriginalTimer_Run670 SwitchState = $gameTimer._fftfanttOriginalTimer_SwitchState671 SwitchNumber = $gameTimer._fftfanttOriginalTimer_SwitchNumber672 TimerSet(args);673 Count = $gameTimer._fftfanttOriginalTimer_Count674 if (!RunFlag) return;675 clearInterval(OriginalTimer);676 prevMsec = getCurrentMsec();677 OriginalTimer = setInterval(TimerRun,CountUnit);678 };679 ...

Full Screen

Full Screen

timer.js

Source:timer.js Github

copy

Full Screen

1var today = new Date();2var timer = function() {};3timer.countdownDate = new Date();4// set date to 10 days in the future for testing purposes5timer.countdownDate.setDate( timer.countdownDate.getDate() + 10 );6/*7* Get thing started8*/9timer.init = function() {10 timer.getReferences();11 12 13 timer.getTimes();14 setInterval(function() { timer.update() }, 1000);15}16/*17* Save references of timer section18*/19timer.getReferences = function() {20 timer.timer = document.getElementById("timer");21 timer.days = timer.timer.querySelectorAll(".days .timer__number")[0];22 timer.hours = timer.timer.querySelectorAll(".hours .timer__number")[0];23 timer.minutes = timer.timer.querySelectorAll(".minutes .timer__number")[0];24 timer.seconds = timer.timer.querySelectorAll(".seconds .timer__number")[0];25}26/*27* remember time units for later use28*/29timer.getTimes = function() {30 timer.times = {};31 timer.times.second = 1000;32 timer.times.minute = timer.times.second * 60;33 timer.times.hour = timer.times.minute * 60;34 timer.times.day = timer.times.hour * 24;35}36/*37* Update the countdown38*/39timer.update = function() {40 if ( timer.timer.style.opacity !== 1 ) {41 timer.timer.style.opacity = 1;42 }43 44 timer.currentDate = new Date();45 timer.difference = timer.countdownDate - timer.currentDate;46 47 timer.days.innerHTML = timer.getTimeRemaining(timer.times.day, 1);48 timer.hours.innerHTML = timer.getTimeRemaining(timer.times.hour, 24);49 timer.minutes.innerHTML = timer.getTimeRemaining(timer.times.minute, 60);50 timer.seconds.innerHTML = timer.getTimeRemaining(timer.times.second, 60);51}52/*53* calculate remaining time based on a unit of time54*/55timer.getTimeRemaining = function( timeUnit, divisor ) {56 var n;57 if ( divisor == 1 ) {58 n = Math.floor(timer.difference / timeUnit );59 }60 else {61 n = Math.floor((timer.difference / timeUnit) % divisor );62 }63 64 if ( String(n).length < 2 ) {65 n = "0" + n;66 }67 68 return n;69}70window.addEventListener("load", function() {71 timer.init();...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var strykerParent = require('stryker-parent');2strykerParent.timer.mark('test');3var strykerParent = require('stryker-parent');4strykerParent.timer.mark('test');5var strykerParent = require('stryker-parent');6strykerParent.timer.mark('test');7var strykerParent = require('stryker-parent');8strykerParent.timer.mark('test');9var strykerParent = require('stryker-parent');10strykerParent.timer.mark('test');11var strykerParent = require('stryker-parent');12strykerParent.timer.mark('test');13var strykerParent = require('stryker-parent');14strykerParent.timer.mark('test');15var strykerParent = require('stryker-parent');16strykerParent.timer.mark('test');17var strykerParent = require('stryker-parent');18strykerParent.timer.mark('test');19var strykerParent = require('stryker-parent');20strykerParent.timer.mark('test');21var strykerParent = require('stryker-parent');22strykerParent.timer.mark('test');23var strykerParent = require('stryker-parent');24strykerParent.timer.mark('test');25var strykerParent = require('stryker-parent');26strykerParent.timer.mark('test');27var strykerParent = require('stryker-parent

Full Screen

Using AI Code Generation

copy

Full Screen

1var timer = require('stryker-parent').timer;2timer.start();3var a = 1;4var b = 2;5var c = a + b;6timer.finish();7var timer = require('stryker-parent').timer;8timer.start();9var a = 1;10var b = 2;11var c = a + b;12timer.finish();13var timer = require('stryker-parent').timer;14timer.start();15var a = 1;16var b = 2;17var c = a + b;18timer.finish();19var timer = require('stryker-parent').timer;20timer.start();21var a = 1;22var b = 2;23var c = a + b;24timer.finish();25var timer = require('stryker-parent').timer;26timer.start();27var a = 1;28var b = 2;29var c = a + b;30timer.finish();31var timer = require('stryker-parent').timer;32timer.start();33var a = 1;34var b = 2;35var c = a + b;36timer.finish();37var timer = require('stryker-parent').timer;38timer.start();39var a = 1;40var b = 2;41var c = a + b;42timer.finish();43var timer = require('stryker-parent').timer;44timer.start();45var a = 1;46var b = 2;47var c = a + b;48timer.finish();49var timer = require('stryker-parent').timer;50timer.start();51var a = 1;52var b = 2;53var c = a + b;54timer.finish();55var timer = require('stryker-parent').timer;

Full Screen

Using AI Code Generation

copy

Full Screen

1const { timer } = require('stryker-parent');2timer.startTimer();3const { timer } = require('stryker-parent');4timer.startTimer();5Your name to display (optional):6Your name to display (optional):

Full Screen

Using AI Code Generation

copy

Full Screen

1const { Timer } = require('stryker-parent');2const timer = new Timer();3timer.start();4setTimeout(() => {5 timer.stop();6 console.log(timer.elapsedTime);7}, 1000);8const { Timer } = require('stryker');9const timer = new Timer();10timer.start();11setTimeout(() => {12 timer.stop();13 console.log(timer.elapsedTime);14}, 1000);

Full Screen

Using AI Code Generation

copy

Full Screen

1var timer = require('stryker-parent').timer;2timer.start();3timer.stop();4timer.log();5module.exports = {6 timer: require('./timer')7};8var startTime;9var stopTime;10var logTime = function () {11 console.log('Time taken: ' + (stopTime - startTime) + 'ms');12};13module.exports = {14 start: function () {15 startTime = new Date().getTime();16 },17 stop: function () {18 stopTime = new Date().getTime();19 },20};21var startTime;22var stopTime;23module.exports = function () {24 var logTime = function () {25 console.log('Time taken: ' + (stopTime - startTime) + 'ms');26 };27 return {28 start: function () {29 startTime = new Date().getTime();30 },31 stop: function () {32 stopTime = new Date().getTime();33 },34 };35};36var timer = require('stryker-parent').timer();37timer.start();38timer.stop();39timer.log();40var startTime;41var stopTime;42var logTime = function () {43 console.log('

Full Screen

Using AI Code Generation

copy

Full Screen

1var timer = require('stryker-parent').timer;2var stryker = require('stryker');3timer.start('stryker');4stryker.runMutationTest({5});6timer.stop('stryker');7var timer = require('stryker-parent').timer;8var stryker = require('stryker');9timer.start('stryker');10stryker.runMutationTest({11});12timer.stop('stryker');13var timer = require('stryker-parent').timer;14var stryker = require('stryker');15timer.start('stryker');16stryker.runMutationTest({17});18timer.stop('stryker');19var timer = require('stryker-parent').timer;20var stryker = require('stryker');21timer.start('stryker');22stryker.runMutationTest({23});24timer.stop('stryker');25var timer = require('stryker-parent').timer;26var stryker = require('stryker');27timer.start('stryker');28stryker.runMutationTest({29});30timer.stop('stryker');31var timer = require('stryker-parent').timer;32var stryker = require('stryker');33timer.start('stryker');34stryker.runMutationTest({35});36timer.stop('stryker');37var timer = require('stryker-parent').timer;38var stryker = require('stryker');39timer.start('stry

Full Screen

Using AI Code Generation

copy

Full Screen

1timer.setTimer(1000);2timer.startTimer();3timer.stopTimer();4timer.resetTimer();5timer.getTimer();6timer.isTimerRunning();7timer.getTimerStartTime();8timer.getTimerStopTime();9timer.getTimerTimeElapsed();10timer.setTimer(1000);11timer.startTimer();12timer.stopTimer();13timer.resetTimer();14timer.getTimer();15timer.isTimerRunning();16timer.getTimerStartTime();17timer.getTimerStopTime();18timer.getTimerTimeElapsed();19timer.setTimer(1000);20timer.startTimer();21timer.stopTimer();22timer.resetTimer();23timer.getTimer();24timer.isTimerRunning();25timer.getTimerStartTime();26timer.getTimerStopTime();27timer.getTimerTimeElapsed();28timer.setTimer(1000);29timer.startTimer();30timer.stopTimer();31timer.resetTimer();32timer.getTimer();33timer.isTimerRunning();34timer.getTimerStartTime();35timer.getTimerStopTime();36timer.getTimerTimeElapsed();37timer.setTimer(1000);38timer.startTimer();39timer.stopTimer();40timer.resetTimer();41timer.getTimer();42timer.isTimerRunning();43timer.getTimerStartTime();44timer.getTimerStopTime();45timer.getTimerTimeElapsed();46timer.setTimer(1000);47timer.startTimer();48timer.stopTimer();49timer.resetTimer();50timer.getTimer();51timer.isTimerRunning();52timer.getTimerStartTime();53timer.getTimerStopTime();54timer.getTimerTimeElapsed();55timer.setTimer(1000);56timer.startTimer();57timer.stopTimer();58timer.resetTimer();59timer.getTimer();60timer.isTimerRunning();61timer.getTimerStartTime();62timer.getTimerStopTime();63timer.getTimerTimeElapsed();64timer.setTimer(1000);65timer.startTimer();66timer.stopTimer();67timer.resetTimer();68timer.getTimer();69timer.isTimerRunning();70timer.getTimerStartTime();71timer.getTimerStopTime();72timer.getTimerTimeElapsed();73timer.setTimer(1000);74timer.startTimer();75timer.stopTimer();76timer.resetTimer();

Full Screen

Automation Testing Tutorials

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.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run stryker-parent automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful