declare var VERSION_WWAJS ; import { WWAConsts as Consts , WWAData as Data , Coord , Position , WWAButtonTexts , LoaderProgress , LoadStage , YesNoState , ChoiceCallInfo , Status , WWAData , Face , LoadType , Direction , SidebarButton , SystemMessage2 , LoadingMessageSize , LoadingMessagePosition , loadMessagesClassic , SystemSound , loadMessages , SystemMessage1 , sidebarButtonCellElementID , SpeedChange , PartsType , dirToKey , speedNameList , dirToPos , MoveType , AppearanceTriggerType , vx , vy , EquipmentStatus , SecondCandidateMoveType , ChangeStyleType , MacroStatusIndex , SelectorType , IDTable , UserDevice , OS_TYPE , DEVICE_TYPE , BROWSER_TYPE , ControlPanelBottomButton , MacroImgFrameIndex , DrawPartsData , speedList , StatusKind , MacroType , StatusSolutionKind } from "./wwa_data" ; import { KeyCode , KeyState , KeyStore , MouseState , MouseStore , GamePadState , GamePadStore } from "./wwa_input" ; import * as util from "./wwa_util" ; import { CGManager } from "./wwa_cgmanager" ; import { Camera } from "./wwa_camera" ; import { Parts , Player } from "./wwa_parts_player" ; import { Monster } from "./wwa_monster" ; import { ObjectMovingDataManager } from "./wwa_motion" ; import { MessageWindow , MonsterWindow , ScoreWindow , ParsedMessage , Macro , parseMacro , MessageSegments } from "./wwa_message" ; import { BattleEstimateWindow } from "./wwa_estimate_battle" ; import { PasswordWindow , Mode } from "./wwa_password_window" ; import { inject } from "./wwa_inject_html" ; import { ItemMenu } from "./wwa_item_menu" ; import { encodeSaveData , decodeSaveDataV0 , decodeSaveDataV1 , generateMD5 } from "./wwa_encryption" ; import { WWACompress , WWASave , LoadErrorCode , generateMapDataRevisionKey , WWADataWithWorldNameStatus } from "./wwa_save" ; import { WWAWebAudio , WWAAudioElement , WWAAudio } from "./wwa_audio" ; import { WWALoader , WWALoaderEventEmitter , Progress , LoaderError } from "@wwawing/loader" ; import { BrowserEventEmitter , IEventEmitter } from "@wwawing/event-emitter" ; let wwa ; param current param total param stage returns { LoaderProgress } export function getProgress ( current , total , stage ) { var progress = new LoaderProgress ( ) ; progress . current = current ; progress . total = total ; progress . stage = stage ; return progress ; } export class WWA { private _cvs : HTMLCanvasElement ; private _cvsSub : HTMLCanvasElement ; private _cvsCover : HTMLCanvasElement ; private _cgManager : CGManager ; private _wwaData : Data ; private _mainCallCounter : number ; private _animationCounter : number ; private _player : Player ; private _monster : Monster ; private _keyStore : KeyStore ; private _mouseStore : MouseStore ; private _gamePadStore : GamePadStore ; private _camera : Camera ; public _itemMenu : ItemMenu ; private _objectMovingDataManager : ObjectMovingDataManager ; public _messageWindow : MessageWindow ; private _monsterWindow : MonsterWindow ; private _scoreWindow : ScoreWindow ; private _messageQueue : ParsedMessage [ ] ; private _yesNoJudge : YesNoState ; private _yesNoJudgeInNextFrame : YesNoState ; private _yesNoChoicePartsCoord : Coord ; private _yesNoChoicePartsID : number ; private _yesNoChoiceCallInfo : ChoiceCallInfo ; private _yesNoDispCounter : number ; private _yesNoUseItemPos : number ; private _yesNoURL : string ; private _waitFrame : number ; private _usePassword : boolean ; private _bottomButtonType : number ; private _mouseControllerElement : HTMLDivElement ; private _statusPressCounter : Status ; private _battleEstimateWindow : BattleEstimateWindow ; private _passwordWindow : PasswordWindow ; private _wwaSave : WWASave ; private _stopUpdateByLoadFlag : boolean ; private _isURLGateEnable : boolean ; private _loadType : LoadType ; private _restartData : WWAData ; /**
     * 所持状態のマップデータの文字列加工をMD5化した文字列です。
     * データが壊れていないかなどの検証に使います。
     * TODO: originalMapDataHash などの名前が適切だと思うが、WWADataに同じ名前のプロパティがいるので安易に変えられない。どこかで対応する。
     */ public checkOriginalMapString : string ; private _prevFrameEventExected : boolean ; private _reservedMoveMacroTurn : number ; private _lastMessage : ParsedMessage ; private _frameCoord : Coord ; private _battleEffectCoord : Coord ; private _audioInstances : WWAAudio [ ] ; private _temporaryInputDisable : boolean ; private _isLoadedSound : boolean ; private _isSkippedSoundMessage : boolean ; private _soundLoadSkipFlag : boolean ; private _passwordLoadExecInNextFrame : boolean ; private _passwordSaveExtractData : WWAData ; private _faces : Face [ ] ; private _execMacroListInNextFrame : Macro [ ] ; private _clearFacesInNextFrame : boolean ; private _paintSkipByDoorOpen : boolean ; private _isClassicModeEnable : boolean ; private _useConsole : boolean ; private _audioDirectory : string ; private _hasTitleImg : boolean ; private _useSuspend : boolean = false ; private _useLookingAround : boolean = true ; private _isDisallowLoadOldSave : boolean = false ; private _isActive : boolean ; see _mapObjectIDTable private _mapIDTable : number [ ] [ ] ; see _mapIDTable private _mapObjectIDTable : number [ ] [ ] ; /**
     * #wwa-wrapper の DOM に対してカスタムイベントを発生させる EventEmitter.
     * 外部のアプリケーションが #wwa-wrapper に対してイベントリスナを設定することで
     * WWAと連携する機能を作ることができます。
     */ public wwaCustomEventEmitter : IEventEmitter ; /**
     * スコア表示に使うレート
     * スコアが表示されていない場合は undefined.
     */ private _scoreRates ? : { energy : number ; strength : number ; defence : number ; gold : number ; } ; public debug : boolean ; private hoge : number [ ] [ ] ; private _loadHandler : ( wwaData : WWAData ) => void ; public audioContext : AudioContext ; public audioGain : GainNode ; private audioExtension : string = "" ; public userDevice : UserDevice ; private soundLoadedCheckTimer : number | undefined = undefined ; private _startTime : number ; private _dumpElement : HTMLElement ; constructor ( mapFileName , urlgateEnabled = false , titleImgName , classicModeEnabled , itemEffectEnabled , useGoToWWA , audioDirectory = "" , disallowLoadOldSave = false , dumpElm = null ) { this . wwaCustomEventEmitter = new BrowserEventEmitter ( util . $id ( "wwa-wrapper" ) ) ; var ctxCover ; window . addEventListener ( "click" , ( e ) : void => { this . _isActive = false ; } ) ; util . $id ( "wwa-wrapper" ) . addEventListener ( "click" , ( e ) : void => { e . stopPropagation ( ) ; this . _isActive = true ; } ) ; this . _isActive = true ; if ( titleImgName === null ) { this . _hasTitleImg = false ; this . _cvsCover = < HTMLCanvasElement > util . $id ( "progress-panel" ) ; ctxCover = < CanvasRenderingContext2D > this . _cvsCover . getContext ( "2d" ) ; ctxCover . fillStyle = "rgb(0, 0, 0)" ; } else { this . _hasTitleImg = true ; } try { if ( this . _hasTitleImg ) { util . $id ( "version" ) . textContent = "WWA Wing Ver." + VERSION_WWAJS ; } else { this . _setLoadingMessage ( ctxCover , 0 ) ; } } catch ( e ) { } this . _dumpElement = dumpElm ; const _AudioContext = ( window as any ) . AudioContext || ( window as any ) . webkitAudioContext ; if ( _AudioContext ) { this . audioContext = new _AudioContext ( ) ; this . audioGain = this . audioContext . createGain ( ) ; this . audioGain . gain . setValueAtTime ( 1 , this . audioContext . currentTime ) ; } var myAudio = new Audio ( ) ; if ( ( "no" !== myAudio . canPlayType ( "audio/mpeg" ) as string ) && ( "" !== myAudio . canPlayType ( "audio/mpeg" ) ) ) { this . audioExtension = "mp3" ; } else { this . audioExtension = "m4a" ; } this . userDevice = new UserDevice ( ) ; this . _isURLGateEnable = urlgateEnabled ; this . _isClassicModeEnable = classicModeEnabled ; this . _mainCallCounter = 0 ; this . _animationCounter = 0 ; this . _statusPressCounter = new Status ( 0 , 0 , 0 , 0 ) ; if ( ! audioDirectory ) { audioDirectory = "./audio/" ; } else if ( audioDirectory [ audioDirectory . length - 1 ] !== "/" ) { audioDirectory += "/" ; } this . _audioDirectory = audioDirectory ; this . _bottomButtonType = useGoToWWA ? ControlPanelBottomButton . GOTO_WWA : ControlPanelBottomButton . BATTLE_REPORT ; var t_start = new Date ( ) . getTime ( ) ; var isLocal = ! ! location . href . match ( /^file/ ) ; if ( isLocal ) { switch ( this . userDevice . device ) { case DEVICE_TYPE . GAME : switch ( this . userDevice . os ) { case OS_TYPE . NINTENDO : Consts . BATTLE_INTERVAL_FRAME_NUM = 5 ; break ; } this . _bottomButtonType = ControlPanelBottomButton . GAME_END ; break ; default : alert ( "【警告】直接HTMLファイルを開いているようです。\n" + "このプログラムは正常に動作しない可能性があります。\n" + "マップデータの確認を行う場合には同梱の「wwa-server.exe」をご利用ください。\n" + ( this . userDevice . browser === BROWSER_TYPE . FIREFOX ? "Firefoxの場合も、バージョン68以降はローカルのHTMLファイルを直接開いた場合、通常起動できないことを確認しております。" : "" ) ) ; break ; } } switch ( this . userDevice . device ) { case DEVICE_TYPE . VR : case DEVICE_TYPE . GAME : this . _usePassword = false ; break ; default : this . _usePassword = true ; break ; } util . $id ( "cell-save" ) . textContent = WWAButtonTexts . QUICK_SAVE ; if ( ! this . _usePassword ) { util . $id ( "cell-load" ) . textContent = WWAButtonTexts . EMPTY_LOAD ; } else { util . $id ( "cell-load" ) . textContent = WWAButtonTexts . PASSWORD ; } switch ( this . _bottomButtonType ) { case ControlPanelBottomButton . GOTO_WWA : util . $id ( "cell-gotowwa" ) . textContent = WWAButtonTexts . GOTO_WWA ; break ; case ControlPanelBottomButton . BATTLE_REPORT : util . $id ( "cell-gotowwa" ) . textContent = WWAButtonTexts . BATTLE_REPORT ; break ; case ControlPanelBottomButton . GAME_END : util . $id ( "cell-gotowwa" ) . textContent = WWAButtonTexts . GAME_END ; break ; } this . _loadHandler = ( wwaData ) : void => { this . _wwaData = wwaData ; this . _wwaData . isItemEffectEnabled = itemEffectEnabled ; try { if ( this . _hasTitleImg ) { util . $id ( "version" ) . textContent += ( " (Map data Ver. " + Math . floor ( this . _wwaData . version / 10 ) + "." + + this . _wwaData . version % 10 + ")" ) ; } else { this . _setLoadingMessage ( ctxCover , 1 ) ; } } catch ( e ) { } var mapFileName = util . $id ( "wwa-wrapper" ) . getAttribute ( "data-wwa-mapdata" ) ; var pathList = mapFileName . split ( "/" ) ; pathList . pop ( ) ; pathList . push ( this . _wwaData . mapCGName ) ; this . _wwaData . mapCGName = pathList . join ( "/" ) ; this . _startTime = new Date ( ) . getTime ( ) ; this . _restartData = JSON . parse ( JSON . stringify ( this . _wwaData ) ) ; this . checkOriginalMapString = this . _generateMapDataHash ( this . _restartData ) ; this . initCSSRule ( ) ; this . _setProgressBar ( getProgress ( 0 , 4 , LoadStage . GAME_INIT ) ) ; this . _setLoadingMessage ( ctxCover , 2 ) ; var cgFile = new Image ( ) ; cgFile . src = this . _wwaData . mapCGName ; cgFile . addEventListener ( "error" , ( ) : void => { this . _setErrorMessage ( "画像ファイル「" + this . _wwaData . mapCGName + "」が見つかりませんでした。\n" + "管理者の方へ: データがアップロードされているか、\n" + "パーミッションを確かめてください。" , ctxCover ) ; } ) ; var escapedFilename = this . _wwaData . mapCGName . replace ( "(" , "\\(" ) . replace ( ")" , "\\)" ) ; param node const applyBackground = ( node ) => { node . style . backgroundImage = "url(" + escapedFilename + ")" ; } ; Array . prototype . forEach . call ( util . $qsAll ( "div.item-cell" ) , ( node ) => { node . style . backgroundPosition = `-${ this . _wwaData . imgItemboxX * Consts . CHIP_SIZE }px -${ this . _wwaData . imgItemboxY * Consts . CHIP_SIZE }px` ; node . style . backgroundImage = "url(" + escapedFilename + ")" ; } ) ; Array . prototype . forEach . call ( util . $qsAll ( "div.wide-cell-row" ) , ( node ) => { node . style . backgroundPosition = "-160px -120px" ; node . style . backgroundImage = "url(" + escapedFilename + ")" ; } ) ; Array . prototype . forEach . call ( util . $qsAll ( ".item-cell>.item-click-border" ) , ( node ) => { node . style . backgroundImage = "url('" + Consts . ITEM_BORDER_IMG_DATA_URL + "')" ; node . style . backgroundPosition = "0 0" ; node . style . display = "none" ; node . style . cursor = "pointer" ; } ) ; Array . prototype . forEach . call ( util . $qsAll ( ".item-cell>.item-disp" ) , applyBackground ) ; Array . prototype . forEach . call ( util . $qsAll ( "div.wide-cell-row>.status-icon" ) , applyBackground ) ; this . setStatusIconCoord ( MacroImgFrameIndex . ENERGY , new Coord ( this . _wwaData . imgStatusEnergyX , this . _wwaData . imgStatusEnergyY ) ) ; this . setStatusIconCoord ( MacroImgFrameIndex . STRENGTH , new Coord ( this . _wwaData . imgStatusStrengthX , this . _wwaData . imgStatusStrengthY ) ) ; this . setStatusIconCoord ( MacroImgFrameIndex . DEFENCE , new Coord ( this . _wwaData . imgStatusDefenceX , this . _wwaData . imgStatusDefenceY ) ) ; this . setStatusIconCoord ( MacroImgFrameIndex . GOLD , new Coord ( this . _wwaData . imgStatusGoldX , this . _wwaData . imgStatusGoldY ) ) ; this . _setProgressBar ( getProgress ( 1 , 4 , LoadStage . GAME_INIT ) ) ; this . _setLoadingMessage ( ctxCover , 3 ) ; this . _mapIDTableCreate ( ) ; this . _replaceAllRandomObjects ( ) ; var t_end = new Date ( ) . getTime ( ) ; console . log ( "Loading Complete!" + ( t_end - t_start ) + "ms" ) ; this . _cvs = < HTMLCanvasElement > util . $id ( "wwa-map" ) ; var ctx = < CanvasRenderingContext2D > this . _cvs . getContext ( "2d" , { alpha : false } ) ; ctx . fillStyle = "rgba( 255, 255, 255, 0.5)" ; ctx . fillRect ( 0 , 0 , 440 , 440 ) ; var playerPosition = new Position ( this , this . _wwaData . playerX , this . _wwaData . playerY ) ; this . _camera = new Camera ( playerPosition ) ; this . _itemMenu = new ItemMenu ( ) ; var status = new Status ( this . _wwaData . statusEnergy , this . _wwaData . statusStrength , this . _wwaData . statusDefence , this . _wwaData . statusGold ) ; this . _player = new Player ( this , playerPosition , this . _camera , status , this . _wwaData . statusEnergyMax , this . _wwaData . moves , this . _wwaData . gameSpeedIndex ) ; this . _objectMovingDataManager = new ObjectMovingDataManager ( this , this . _player ) ; this . _camera . setPlayer ( this . _player ) ; this . _keyStore = new KeyStore ( ) ; this . _mouseStore = new MouseStore ( ) ; this . _gamePadStore = new GamePadStore ( ) ; this . _messageQueue = [ ] ; this . _yesNoJudge = YesNoState . UNSELECTED ; this . _yesNoJudgeInNextFrame = YesNoState . UNSELECTED ; this . _yesNoChoiceCallInfo = ChoiceCallInfo . NONE ; this . _prevFrameEventExected = false ; this . _lastMessage = new ParsedMessage ( [ ] , false , false , [ ] ) ; this . _execMacroListInNextFrame = [ ] ; this . _passwordLoadExecInNextFrame = false ; this . _messageWindow = new MessageWindow ( this , 50 , 180 , 340 , 0 , this . _wwaData . mapCGName , false , true , false , util . $id ( "wwa-wrapper" ) ) ; this . _scoreWindow = new ScoreWindow ( this , new Coord ( 50 , 50 ) , false , util . $id ( "wwa-wrapper" ) ) ; this . _wwaSave = new WWASave ( wwa , wwa . _wwaData . worldName , wwa . _wwaData . worldPassNumber , this . _checkSaveDataCompatibility . bind ( this ) , failedLoadingSaveDataCauses => { if ( failedLoadingSaveDataCauses . length > 0 ) { let message = "これまでに保存されていたセーブデータは、下記の理由により消えたものがあります。" ; failedLoadingSaveDataCauses . forEach ( ( cause ) => { switch ( cause ) { case LoadErrorCode . UNMATCHED_WORLD_NAME : message += "\n・制作者によるマップデータのワールド名の変更" ; break ; case LoadErrorCode . UNMATCHED_WORLD_PASS_NUMBER : message += "\n・制作者によるマップデータの暗証番号の変更" ; break ; case LoadErrorCode . DISALLOW_OLD_REVISION_WORLD_SAVE_DATA : message += "\n・制作者によるマップデータの内容変更 (マップデータ制作者の設定により、内容が変更されるとセーブデータが消去されます)" ; break ; } } ) ; alert ( message ) ; } } ) ; this . _isDisallowLoadOldSave = disallowLoadOldSave ; this . _messageWindow . setWWASave ( this . _wwaSave ) ; WWACompress . setRestartData ( this . _restartData , this . _wwaData ) ; this . clearFaces ( ) ; const resumeSaveDataText = util . $id ( "wwa-wrapper" ) . getAttribute ( "data-wwa-resume-savedata" ) ; if ( typeof resumeSaveDataText === "string" ) { this . _useSuspend = true ; if ( resumeSaveDataText ) { var resumeData = WWACompress . getStartWWAData ( resumeSaveDataText ) ; if ( this . _restartData !== resumeData ) { this . _applyQuickLoad ( resumeData ) ; this . _wwaSave . resumeStart ( ) ; } } } const autosaveString = util . $id ( "wwa-wrapper" ) . getAttribute ( "data-wwa-autosave" ) ; if ( autosaveString !== null ) { this . _wwaSave . setAutoSaveInterval ( Number ( autosaveString ) | 0 ) ; } const lookingAroundString = util . $id ( "wwa-wrapper" ) . getAttribute ( "data-wwa-looking-around" ) ; this . _useLookingAround = ! ( ( lookingAroundString ) && ( lookingAroundString . match ( /false/i ) ) ) ; this . _setProgressBar ( getProgress ( 2 , 4 , LoadStage . GAME_INIT ) ) ; this . _setLoadingMessage ( ctxCover , 4 ) ; window . addEventListener ( "keydown" , ( e ) : void => { if ( ! this . _isActive ) { return ; } switch ( this . userDevice . os ) { case OS_TYPE . NINTENDO : e . preventDefault ( ) ; e . stopPropagation ( ) ; return ; } this . _keyStore . setPressInfo ( e . keyCode ) ; if ( e . keyCode === KeyCode . KEY_F5 ) { e . preventDefault ( ) ; return ; } if ( ! this . _player . isWaitingMessage ( ) ) { if ( ! this . _player . isWaitingPasswordWindow ( ) ) { if ( e . keyCode === KeyCode . KEY_DOWN || e . keyCode === KeyCode . KEY_LEFT || e . keyCode === KeyCode . KEY_RIGHT || e . keyCode === KeyCode . KEY_UP || e . keyCode === KeyCode . KEY_SHIFT || e . keyCode === KeyCode . KEY_ENTER || e . keyCode === KeyCode . KEY_1 || e . keyCode === KeyCode . KEY_2 || e . keyCode === KeyCode . KEY_3 || e . keyCode === KeyCode . KEY_A || e . keyCode === KeyCode . KEY_C || e . keyCode === KeyCode . KEY_D || e . keyCode === KeyCode . KEY_E || e . keyCode === KeyCode . KEY_M || e . keyCode === KeyCode . KEY_N || e . keyCode === KeyCode . KEY_Q || e . keyCode === KeyCode . KEY_S || e . keyCode === KeyCode . KEY_W || e . keyCode === KeyCode . KEY_X || e . keyCode === KeyCode . KEY_Y || e . keyCode === KeyCode . KEY_Z || e . keyCode === KeyCode . KEY_ESC || e . keyCode === KeyCode . KEY_F1 || e . keyCode === KeyCode . KEY_F2 || e . keyCode === KeyCode . KEY_F3 || e . keyCode === KeyCode . KEY_F4 || e . keyCode === KeyCode . KEY_F6 || e . keyCode === KeyCode . KEY_F7 || e . keyCode === KeyCode . KEY_F8 || e . keyCode === KeyCode . KEY_F12 || e . keyCode === KeyCode . KEY_SPACE ) { e . preventDefault ( ) ; } } } else { if ( e . keyCode === KeyCode . KEY_DOWN || e . keyCode === KeyCode . KEY_LEFT || e . keyCode === KeyCode . KEY_RIGHT || e . keyCode === KeyCode . KEY_UP || e . keyCode === KeyCode . KEY_SHIFT || e . keyCode === KeyCode . KEY_ENTER || e . keyCode === KeyCode . KEY_ESC || e . keyCode === KeyCode . KEY_SPACE ) { e . preventDefault ( ) ; } } } ) ; window . addEventListener ( "keyup" , ( e ) : void => { if ( ! this . _isActive ) { return ; } switch ( this . userDevice . os ) { case OS_TYPE . NINTENDO : e . preventDefault ( ) ; e . stopPropagation ( ) ; return ; } this . _keyStore . setReleaseInfo ( e . keyCode ) ; if ( e . keyCode === KeyCode . KEY_F5 ) { e . preventDefault ( ) ; } else if ( e . keyCode === KeyCode . KEY_DOWN || e . keyCode === KeyCode . KEY_LEFT || e . keyCode === KeyCode . KEY_RIGHT || e . keyCode === KeyCode . KEY_UP || e . keyCode === KeyCode . KEY_SHIFT || e . keyCode === KeyCode . KEY_ENTER || e . keyCode === KeyCode . KEY_1 || e . keyCode === KeyCode . KEY_2 || e . keyCode === KeyCode . KEY_3 || e . keyCode === KeyCode . KEY_A || e . keyCode === KeyCode . KEY_C || e . keyCode === KeyCode . KEY_D || e . keyCode === KeyCode . KEY_E || e . keyCode === KeyCode . KEY_M || e . keyCode === KeyCode . KEY_N || e . keyCode === KeyCode . KEY_Q || e . keyCode === KeyCode . KEY_S || e . keyCode === KeyCode . KEY_W || e . keyCode === KeyCode . KEY_X || e . keyCode === KeyCode . KEY_Y || e . keyCode === KeyCode . KEY_Z || e . keyCode === KeyCode . KEY_ESC || e . keyCode === KeyCode . KEY_F1 || e . keyCode === KeyCode . KEY_F3 || e . keyCode === KeyCode . KEY_F4 || e . keyCode === KeyCode . KEY_F6 || e . keyCode === KeyCode . KEY_F7 || e . keyCode === KeyCode . KEY_F8 || e . keyCode === KeyCode . KEY_F9 || e . keyCode === KeyCode . KEY_F12 || e . keyCode === KeyCode . KEY_SPACE ) { if ( ! this . _player . isWaitingMessage ( ) && ! this . _player . isWaitingPasswordWindow ( ) ) { e . preventDefault ( ) ; } } } ) ; window . addEventListener ( "blur" , ( e ) : void => { this . _keyStore . allClear ( ) ; this . _mouseStore . clear ( ) ; } ) ; window . addEventListener ( "contextmenu" , ( e ) : void => { this . _keyStore . allClear ( ) ; this . _mouseStore . clear ( ) ; } ) ; window . addEventListener ( "help" , ( e ) : void => { if ( ! this . _isActive ) { return ; } e . preventDefault ( ) ; } ) ; this . _mouseControllerElement = < HTMLDivElement > ( util . $id ( "wwa-controller" ) ) ; this . _mouseControllerElement . addEventListener ( "mousedown" , ( e ) : void => { if ( ! this . _isActive ) { return ; } if ( e . which === 1 ) { if ( this . _mouseStore . getMouseState ( ) !== MouseState . NONE ) { e . preventDefault ( ) ; return ; } const clickingPosition = util . $localPos ( e . clientX , e . clientY ) ; const playerPosition = this . _player . getDrawingCenterPosition ( ) ; const dist = clickingPosition . substract ( playerPosition ) ; const dx = Math . abs ( dist . x ) ; const dy = Math . abs ( dist . y ) ; let dir ; let isPlayerInScreenEdge = false ; if ( ( dx < Consts . CHIP_SIZE ) && ( dy < Consts . CHIP_SIZE ) ) { switch ( ( playerPosition . x / Consts . CHIP_SIZE | 0 ) ) { case 0 : isPlayerInScreenEdge = true ; dir = Direction . LEFT ; break ; case Consts . H_PARTS_NUM_IN_WINDOW - 1 : isPlayerInScreenEdge = true ; dir = Direction . RIGHT ; break ; } switch ( ( playerPosition . y / Consts . CHIP_SIZE | 0 ) ) { case 0 : isPlayerInScreenEdge = true ; dir = Direction . UP ; break ; case Consts . V_PARTS_NUM_IN_WINDOW - 1 : isPlayerInScreenEdge = true ; dir = Direction . DOWN ; break ; } } if ( ! isPlayerInScreenEdge ) { if ( dist . y > 0 && dy > dx ) { dir = Direction . DOWN ; } else if ( dist . y < 0 && dy > dx ) { dir = Direction . UP ; } else if ( dist . x > 0 && dy < dx ) { dir = Direction . RIGHT ; } else if ( dist . x < 0 && dy < dx ) { dir = Direction . LEFT ; } } this . _mouseStore . setPressInfo ( dir , 0 ) ; } } ) ; this . _mouseControllerElement . addEventListener ( "mouseleave" , ( e ) : void => { this . _mouseStore . clear ( ) ; } ) ; this . _mouseControllerElement . addEventListener ( "mouseup" , ( e ) : void => { if ( ! this . _isActive ) { return ; } if ( e . which === 1 ) { this . _mouseStore . setReleaseInfo ( ) ; e . preventDefault ( ) ; } } ) ; if ( window . TouchEvent ) { if ( this . audioContext ) { /**
                     * audioTest は WebAudio API の再生操作を行うだけのメソッドです。
                     *     スマートフォンでは、ユーザーからの操作なしに音声を鳴らすことは出来ません。
                     *     そのため、タッチした際にダミー音声を再生することで音声の再生を可能にしています。
                     */ let audioTest = ( ) => { this . audioContext . createBufferSource ( ) . start ( 0 ) ; this . _mouseControllerElement . removeEventListener ( "touchstart" , audioTest ) ; audioTest = null ; } ; this . _mouseControllerElement . addEventListener ( "touchstart" , audioTest ) ; } this . _mouseControllerElement . addEventListener ( "touchstart" , ( touchEvent ) : void => { if ( ! this . _isActive ) { return ; } if ( this . _mouseStore . getMouseState ( ) !== MouseState . NONE ) { touchEvent . preventDefault ( ) ; return ; } const changedTouches = touchEvent . changedTouches ; const touchLength = changedTouches . length ; for ( let touchID = 0 ; touchID < touchLength ; touchID ++ ) { const changedTouch = changedTouches [ touchID ] ; const touchedPosition = util . $localPos ( changedTouch . clientX , changedTouch . clientY ) ; const playerPosition = this . _player . getDrawingCenterPosition ( ) ; const dist = touchedPosition . substract ( playerPosition ) ; const dx = Math . abs ( dist . x ) ; const dy = Math . abs ( dist . y ) ; let dir ; let isPlayerInScreenEdge = false ; if ( ( dx < Consts . CHIP_SIZE ) && ( dy < Consts . CHIP_SIZE ) ) { switch ( ( playerPosition . x / Consts . CHIP_SIZE | 0 ) ) { case 0 : isPlayerInScreenEdge = true ; dir = Direction . LEFT ; break ; case Consts . H_PARTS_NUM_IN_WINDOW - 1 : isPlayerInScreenEdge = true ; dir = Direction . RIGHT ; break ; } switch ( ( playerPosition . y / Consts . CHIP_SIZE | 0 ) ) { case 0 : isPlayerInScreenEdge = true ; dir = Direction . UP ; break ; case Consts . V_PARTS_NUM_IN_WINDOW - 1 : isPlayerInScreenEdge = true ; dir = Direction . DOWN ; break ; } } if ( ! isPlayerInScreenEdge ) { if ( dist . y > 0 && dy > dx ) { dir = Direction . DOWN ; } else if ( dist . y < 0 && dy > dx ) { dir = Direction . UP ; } else if ( dist . x > 0 && dy < dx ) { dir = Direction . RIGHT ; } else if ( dist . x < 0 && dy < dx ) { dir = Direction . LEFT ; } } this . _mouseStore . setPressInfo ( dir , changedTouch . identifier ) ; } if ( touchEvent . cancelable ) { touchEvent . preventDefault ( ) ; } } ) ; const onTouchReleased = ( event ) : void => { if ( ! this . _isActive ) { return ; } for ( let i = 0 ; i < event . changedTouches . length ; i ++ ) { if ( this . _mouseStore . getTouchID ( ) === event . changedTouches [ i ] . identifier ) { this . _mouseStore . setReleaseInfo ( ) ; event . preventDefault ( ) ; break ; } } } ; this . _mouseControllerElement . addEventListener ( "touchend" , onTouchReleased ) ; this . _mouseControllerElement . addEventListener ( "touchcancel" , onTouchReleased ) ; } util . $id ( "button-load" ) . addEventListener ( "click" , ( ) => { if ( this . _player . isControllable ( ) || ( this . _messageWindow . isItemMenuChoice ( ) ) ) { this . onselectbutton ( SidebarButton . QUICK_LOAD ) ; } } ) ; util . $id ( "button-save" ) . addEventListener ( "click" , ( ) => { if ( this . _player . isControllable ( ) || ( this . _messageWindow . isItemMenuChoice ( ) ) ) { this . onselectbutton ( SidebarButton . QUICK_SAVE ) ; } } ) ; util . $id ( "button-restart" ) . addEventListener ( "click" , ( ) => { if ( this . _player . isControllable ( ) || ( this . _messageWindow . isItemMenuChoice ( ) ) ) { this . onselectbutton ( SidebarButton . RESTART_GAME ) ; } } ) ; util . $id ( "button-gotowwa" ) . addEventListener ( "click" , ( ) => { if ( this . _player . isControllable ( ) || ( this . _messageWindow . isItemMenuChoice ( ) ) ) { this . onselectbutton ( SidebarButton . GOTO_WWA , false , false ) ; } } ) ; Array . prototype . forEach . call ( util . $qsAll ( ".wide-cell-row" ) , ( node ) => { node . addEventListener ( "click" , ( ) => { this . _displayHelp ( ) ; } ) ; } ) ; this . _frameCoord = new Coord ( Consts . IMGPOS_DEFAULT_FRAME_X , Consts . IMGPOS_DEFAULT_YESNO_Y ) ; this . _battleEffectCoord = new Coord ( Consts . IMGPOS_DEFAULT_BATTLE_EFFECT_X , Consts . IMGPOS_DEFAULT_BATTLE_EFFECT_Y ) ; ; this . _battleEstimateWindow = new BattleEstimateWindow ( this , this . _wwaData . mapCGName , util . $id ( "wwa-wrapper" ) ) ; this . _passwordWindow = new PasswordWindow ( this , < HTMLDivElement > util . $id ( "wwa-wrapper" ) , disallowLoadOldSave ) ; this . _monsterWindow = new MonsterWindow ( this , new Coord ( 50 , 180 ) , 340 , 60 , false , util . $id ( "wwa-wrapper" ) , this . _wwaData . mapCGName ) ; this . _setProgressBar ( getProgress ( 3 , 4 , LoadStage . GAME_INIT ) ) ; this . _isLoadedSound = false ; this . _temporaryInputDisable = false ; this . _paintSkipByDoorOpen = false ; this . _clearFacesInNextFrame = false ; this . _useConsole = false ; this . wwaCustomEvent ( 'wwa_startup' ) ; this . _cgManager = new CGManager ( ctx , this . _wwaData . mapCGName , this . _frameCoord , ( ) : void => { this . _isSkippedSoundMessage = true ; const setGameStartingMessageWhenPcOrSP = ( ) => { switch ( this . userDevice . device ) { case DEVICE_TYPE . PC : this . setMessageQueue ( "ゲームを開始します。\n画面をクリックしてください。" , false , true ) ; break ; case DEVICE_TYPE . SP : this . setMessageQueue ( "ゲームを開始します。\n画面にふれてください。" , false , true ) ; break ; } } ; if ( this . _wwaData . systemMessage [ SystemMessage2 . LOAD_SE ] === "ON" ) { this . _isLoadedSound = true ; setGameStartingMessageWhenPcOrSP ( ) ; this . _setLoadingMessage ( ctxCover , LoadStage . AUDIO ) ; this . loadSound ( ) ; window . requestAnimationFrame ( this . soundCheckCaller ) ; return ; } else if ( this . _wwaData . systemMessage [ SystemMessage2 . LOAD_SE ] === "OFF" ) { this . _isLoadedSound = false ; setGameStartingMessageWhenPcOrSP ( ) ; this . openGameWindow ( ) ; return ; } this . _isSkippedSoundMessage = false ; if ( ! this . _hasTitleImg ) { ctxCover . clearRect ( 0 , 0 , Consts . SCREEN_WIDTH , Consts . SCREEN_HEIGHT ) ; } if ( this . _usePassword ) { this . _messageWindow . setParsedMessage ( new ParsedMessage ( ( this . _wwaData . systemMessage [ SystemMessage2 . LOAD_SE ] === "" ? "効果音・ＢＧＭデータをロードしますか？" : this . _wwaData . systemMessage [ SystemMessage2 . LOAD_SE ] ) , true ) ) ; this . _messageWindow . show ( ) ; this . _setProgressBar ( getProgress ( 4 , 4 , LoadStage . GAME_INIT ) ) ; var timer = setInterval ( ( ) : void => { this . _keyStore . update ( ) ; this . _gamePadStore . update ( ) ; if ( this . _yesNoJudgeInNextFrame === YesNoState . UNSELECTED ) { if ( this . _keyStore . getKeyState ( KeyCode . KEY_ENTER ) === KeyState . KEYDOWN || this . _keyStore . getKeyState ( KeyCode . KEY_Y ) === KeyState . KEYDOWN || this . _gamePadStore . buttonTrigger ( GamePadState . BUTTON_INDEX_A ) ) { this . _yesNoJudgeInNextFrame = YesNoState . YES ; } else if ( this . _keyStore . getKeyState ( KeyCode . KEY_N ) === KeyState . KEYDOWN || this . _keyStore . getKeyState ( KeyCode . KEY_ESC ) === KeyState . KEYDOWN || this . _gamePadStore . buttonTrigger ( GamePadState . BUTTON_INDEX_B ) ) { this . _yesNoJudgeInNextFrame = YesNoState . NO ; } } if ( this . _yesNoJudgeInNextFrame === YesNoState . YES ) { clearInterval ( timer ) ; this . _messageWindow . update ( ) ; this . _yesNoJudge = this . _yesNoJudgeInNextFrame ; this . _messageWindow . setInputDisable ( ) ; setTimeout ( ( ) : void => { this . _player . setDelayFrame ( ) ; this . _messageWindow . hide ( ) ; this . _yesNoJudge = YesNoState . UNSELECTED ; this . _yesNoJudgeInNextFrame = YesNoState . UNSELECTED ; this . _isLoadedSound = true ; this . _setLoadingMessage ( ctxCover , LoadStage . AUDIO ) ; this . loadSound ( ) ; window . requestAnimationFrame ( this . soundCheckCaller ) ; } , Consts . YESNO_PRESS_DISP_FRAME_NUM * Consts . DEFAULT_FRAME_INTERVAL ) ; } else if ( this . _yesNoJudgeInNextFrame === YesNoState . NO ) { clearInterval ( timer ) ; this . _messageWindow . update ( ) ; this . _yesNoJudge = this . _yesNoJudgeInNextFrame ; this . _messageWindow . setInputDisable ( ) ; setTimeout ( ( ) : void => { this . _player . setDelayFrame ( ) ; this . _messageWindow . hide ( ) ; this . _yesNoJudge = YesNoState . UNSELECTED ; this . _yesNoJudgeInNextFrame = YesNoState . UNSELECTED ; this . _isLoadedSound = false ; this . openGameWindow ( ) ; } , Consts . YESNO_PRESS_DISP_FRAME_NUM * Consts . DEFAULT_FRAME_INTERVAL ) ; } } , Consts . DEFAULT_FRAME_INTERVAL ) ; } else { clearInterval ( timer ) ; this . _player . setDelayFrame ( ) ; this . _messageWindow . hide ( ) ; this . _yesNoJudge = YesNoState . UNSELECTED ; this . _yesNoJudgeInNextFrame = YesNoState . UNSELECTED ; this . _isLoadedSound = true ; this . loadSound ( ) ; window . requestAnimationFrame ( this . soundCheckCaller ) ; } } ) ; this . wwaCustomEvent ( 'wwa_start' ) ; } ; const eventEmitter = new BrowserEventEmitter ( ) ; const mapDataHandler = ( mapData ) => this . _loadHandler ( mapData ) ; const progressHandler = ( progress ) => this . _setProgressBar ( progress ) ; const errorHandler = ( error ) => this . _setErrorMessage ( "下記のエラーが発生しました。: \n" + error . message , ctxCover ) ; eventEmitter . addListener ( "mapData" , mapDataHandler ) ; eventEmitter . addListener ( "progress" , progressHandler ) ; eventEmitter . addListener ( "error" , errorHandler ) ; const loader = new WWALoader ( mapFileName , eventEmitter ) ; loader . requestAndLoadMapData ( ) ; } private _setProgressBar ( progress ) { if ( ! this . _hasTitleImg ) { return ; } if ( progress . stage <= Consts . LOAD_STAGE_MAX_EXCEPT_AUDIO ) { ( util . $id ( "progress-message-container" ) ) . textContent = ( progress . stage === Consts . LOAD_STAGE_MAX_EXCEPT_AUDIO ? "World Name: " + this . _wwaData . worldName : loadMessages [ progress . stage ] ) ; ( util . $id ( "progress-bar" ) ) . style . width = ( 1 * progress . stage + ( progress . current / progress . total ) * 1 ) / ( Consts . LOAD_STAGE_MAX_EXCEPT_AUDIO + 1 ) * Consts . MAP_WINDOW_WIDTH + "px" ; ( util . $id ( "progress-disp" ) ) . textContent = ( ( 1 * progress . stage + ( progress . current / progress . total ) * 1 ) / ( Consts . LOAD_STAGE_MAX_EXCEPT_AUDIO + 1 ) * 100 ) . toFixed ( 2 ) + "%" ; } else { if ( this . _usePassword ) { ( util . $id ( "progress-message-container" ) ) . textContent = "効果音/BGMを読み込んでいます。(スペースキーでスキップ）" ; } else { ( util . $id ( "progress-message-container" ) ) . textContent = "ゲームデータを読み込んでいます。" ; } ( util . $id ( "progress-bar-audio" ) ) . style . width = ( progress . current * Consts . MAP_WINDOW_WIDTH / progress . total ) + "px" ; ( util . $id ( "progress-disp" ) ) . textContent = ( ( progress . current / progress . total * 100 ) . toFixed ( 2 ) ) + "%" ; } } private _setLoadingMessage ( ctx , mode ) { if ( this . _hasTitleImg ) { return ; } if ( mode <= 0 ) { ctx . font = LoadingMessageSize . TITLE + "px " + Consts . LOADING_FONT ; ctx . fillText ( loadMessagesClassic [ 0 ] , LoadingMessagePosition . TITLE_X , LoadingMessagePosition . TITLE_Y ) ; ctx . font = LoadingMessageSize . FOOTER + "px " + Consts . LOADING_FONT ; ctx . fillText ( "WWA Wing Ver." + VERSION_WWAJS , LoadingMessagePosition . FOOTER_X , LoadingMessagePosition . COPYRIGHT_Y ) ; } else if ( mode <= loadMessagesClassic . length ) { ctx . font = LoadingMessageSize . LOADING + "px " + Consts . LOADING_FONT ; if ( mode >= 2 ) { ctx . clearRect ( LoadingMessagePosition . LOADING_X , LoadingMessagePosition . LOADING_Y + ( LoadingMessagePosition . LINE * ( mode - 3 ) ) , Consts . SCREEN_WIDTH - LoadingMessagePosition . LOADING_X , LoadingMessagePosition . LINE ) ; ctx . fillText ( loadMessagesClassic [ mode - 1 ] + " Complete!" , LoadingMessagePosition . LOADING_X , LoadingMessagePosition . LOADING_Y + ( LoadingMessagePosition . LINE * ( mode - 2 ) ) ) ; } if ( mode < loadMessagesClassic . length ) { ctx . fillText ( loadMessagesClassic [ mode ] , LoadingMessagePosition . LOADING_X , LoadingMessagePosition . LOADING_Y + ( LoadingMessagePosition . LINE * ( mode - 1 ) ) ) ; } if ( mode == 1 ) { ctx . font = LoadingMessageSize . FOOTER + "px " + Consts . LOADING_FONT ; ctx . fillText ( "World Name  " + this . _wwaData . worldName , LoadingMessagePosition . FOOTER_X , LoadingMessagePosition . WORLD_Y ) ; ctx . fillText ( " (Map data Ver. " + Math . floor ( this . _wwaData . version / 10 ) + "." + this . _wwaData . version % 10 + ")" , LoadingMessagePosition . FOOTER_X , LoadingMessagePosition . WORLD_Y + LoadingMessagePosition . LINE ) ; } } else { var messageY ; if ( this . _isSkippedSoundMessage ) { messageY = LoadingMessagePosition . LOADING_Y + ( LoadingMessagePosition . LINE * ( loadMessagesClassic . length - 1 ) ) ; } else { messageY = LoadingMessagePosition . FOOTER_Y ; } if ( mode <= LoadStage . AUDIO ) { ctx . fillText ( "Now Sound data Loading ....." , LoadingMessagePosition . LOADING_X , messageY ) ; } else { ctx . clearRect ( LoadingMessagePosition . LOADING_X , messageY - LoadingMessagePosition . LINE , Consts . SCREEN_WIDTH - LoadingMessagePosition . LOADING_X , LoadingMessagePosition . LINE ) ; ctx . fillText ( "Now Sound data Loading ..... Complete!" , LoadingMessagePosition . LOADING_X , messageY ) ; } } } private _setErrorMessage ( message , ctx ) { if ( this . _hasTitleImg ) { alert ( message ) ; } else { ctx . clearRect ( 0 , 0 , Consts . SCREEN_WIDTH , Consts . SCREEN_HEIGHT ) ; ctx . font = LoadingMessageSize . ERRROR + "px " + Consts . LOADING_FONT ; var errorMessage = message . split ( '\n' ) ; errorMessage . forEach ( function ( line , i ) { ctx . fillText ( line , LoadingMessagePosition . ERROR_X , LoadingMessagePosition . ERROR_Y + ( LoadingMessagePosition . LINE * i ) ) ; } ) ; } } public createWWAAudioInstance ( idx ) { if ( idx === 0 || idx === SystemSound . NO_SOUND ) { return ; } const audioContext = this . audioContext ; if ( this . _audioInstances [ idx ] !== void 0 ) { return ; } const file = this . _audioDirectory + idx + "." + this . audioExtension ; if ( audioContext ) { this . _audioInstances [ idx ] = new WWAWebAudio ( idx , file , this . audioContext , this . audioGain ) ; } else { this . _audioInstances [ idx ] = new WWAAudioElement ( idx , file , util . $id ( "wwa-audio-wrapper" ) ) ; } } public loadSound ( ) { this . _audioInstances = new Array ( Consts . SOUND_MAX + 1 ) ; this . createWWAAudioInstance ( SystemSound . DECISION ) ; this . createWWAAudioInstance ( SystemSound . ATTACK ) ; for ( var pid = 1 ; pid < this . _wwaData . mapPartsMax ; pid ++ ) { var idx = this . _wwaData . mapAttribute [ pid ] [ Consts . ATR_SOUND ] ; this . createWWAAudioInstance ( idx ) ; } for ( var pid = 1 ; pid < this . _wwaData . objPartsMax ; pid ++ ) { if ( this . _wwaData . objectAttribute [ pid ] [ Consts . ATR_TYPE ] === Consts . OBJECT_RANDOM ) { continue ; } var idx = this . _wwaData . objectAttribute [ pid ] [ Consts . ATR_SOUND ] ; this . createWWAAudioInstance ( idx ) ; } this . _wwaData . bgm = 0 ; this . _soundLoadSkipFlag = false ; } public checkAllSoundLoaded ( ) { var loadedNum = 0 ; var total = 0 ; if ( ! this . _hasTitleImg ) { var ctxCover = < CanvasRenderingContext2D > this . _cvsCover . getContext ( "2d" ) ; } this . _keyStore . update ( ) ; if ( this . _keyStore . getKeyState ( KeyCode . KEY_SPACE ) === KeyState . KEYDOWN ) { this . _soundLoadSkipFlag = true ; } for ( var i = 1 ; i <= Consts . SOUND_MAX ; i ++ ) { const instance = this . _audioInstances [ i ] ; if ( instance === void 0 || instance . isError ( ) ) { continue ; } total ++ ; if ( ! instance . hasData ( ) ) { continue ; } loadedNum ++ ; } if ( loadedNum < total && ! this . _soundLoadSkipFlag ) { this . _setProgressBar ( getProgress ( loadedNum , total , LoadStage . AUDIO ) ) ; window . requestAnimationFrame ( this . soundCheckCaller ) ; return ; } this . _setProgressBar ( getProgress ( Consts . SOUND_MAX , Consts . SOUND_MAX , LoadStage . AUDIO ) ) ; this . _setLoadingMessage ( ctxCover , LoadStage . FINISH ) ; this . openGameWindow ( ) ; } param targetSoundId private _setSoundLoadedCheckTimer ( targetSoundId ) { const targetAudio = this . _audioInstances [ targetSoundId ] ; if ( targetAudio . isError ( ) ) { return ; } this . soundLoadedCheckTimer = window . setInterval ( ( ) : void => { if ( this . _wwaData . bgm === targetSoundId ) { if ( targetAudio . hasData ( ) ) { targetAudio . play ( ) ; this . _wwaData . bgm = targetSoundId ; this . _clearSoundLoadedCheckTimer ( ) ; } else if ( targetAudio . isError ( ) ) { this . _clearSoundLoadedCheckTimer ( ) ; } } else { this . _clearSoundLoadedCheckTimer ( ) ; } } , 100 ) ; } private _clearSoundLoadedCheckTimer ( ) { if ( this . soundLoadedCheckTimer ) { clearInterval ( this . soundLoadedCheckTimer ) ; this . soundLoadedCheckTimer = undefined ; } } public playSound ( id ) { if ( ! this . _isLoadedSound ) { if ( id === SystemSound . NO_SOUND ) { this . _wwaData . bgm = 0 ; } else if ( id >= SystemSound . BGM_LB ) { this . _wwaData . bgm = id ; } return ; } if ( id < 0 || id > Consts . SOUND_MAX ) { throw new Error ( "サウンド番号が範囲外です。" ) ; } if ( id >= SystemSound . BGM_LB && this . _wwaData . bgm === id ) { return ; } if ( ( id === SystemSound . NO_SOUND || id >= SystemSound . BGM_LB ) && this . _wwaData . bgm !== 0 ) { if ( this . _audioInstances [ this . _wwaData . bgm ] . hasData ( ) ) { this . _audioInstances [ this . _wwaData . bgm ] . pause ( ) ; } this . _wwaData . bgm = 0 ; } if ( id === 0 || id === SystemSound . NO_SOUND ) { return ; } const audioInstance = this . _audioInstances [ id ] ; if ( ! audioInstance . hasData ( ) ) { if ( id >= SystemSound . BGM_LB ) { this . _wwaData . bgm = id ; this . _setSoundLoadedCheckTimer ( id ) ; } } else { if ( id >= SystemSound . BGM_LB ) { this . _audioInstances [ id ] . play ( ) ; this . _wwaData . bgm = id ; } else { this . _audioInstances [ id ] . play ( ) ; } } } public openGameWindow ( ) { var ppos = this . _player . getPosition ( ) ; util . $id ( "wwa-cover" ) . style . opacity = "0" ; if ( this . getObjectIdByPosition ( ppos ) !== 0 ) { this . _player . setPartsAppearedFlag ( ) ; } var resumeSaveDataText = util . $id ( "wwa-wrapper" ) . getAttribute ( "data-wwa-resume-savedata" ) ; if ( typeof resumeSaveDataText === "string" ) { this . _useSuspend = true ; if ( resumeSaveDataText ) { var resumeData = WWACompress . getStartWWAData ( resumeSaveDataText ) ; if ( this . _restartData !== resumeData ) { this . _applyQuickLoad ( resumeData ) ; this . _wwaSave . resumeStart ( ) ; } } } setTimeout ( ( ) => { util . $id ( "wwa-wrapper" ) . removeChild ( util . $id ( "wwa-cover" ) ) ; this . _main ( ) ; } , Consts . SPLASH_SCREEN_DISP_MILLS ) ; } /**
    何でこんなことしてるの?
    requestAnimationFrame で関数を呼んだ時, this が window になることを防ぐため!
    */ public mainCaller = ( ( ) => this . _main ( ) ) ; public soundCheckCaller = ( ( ) => this . checkAllSoundLoaded ( ) ) ; param itemPos returns { boolean } public onselectitem ( itemPos ) { if ( this . _player . canUseItem ( itemPos ) ) { var bg = < HTMLDivElement > ( util . $id ( "item" + ( itemPos - 1 ) ) ) ; bg . classList . add ( "onpress" ) ; this . playSound ( SystemSound . DECISION ) ; if ( this . _wwaData . message [ SystemMessage1 . USE_ITEM ] === "BLANK" ) { this . _player . readyToUseItem ( itemPos ) ; var itemID = this . _player . useItem ( ) ; var mesID = this . getObjectAttributeById ( itemID , Consts . ATR_STRING ) ; this . setMessageQueue ( this . getMessageById ( mesID ) , false , false , itemID , PartsType . OBJECT , this . _player . getPosition ( ) . getPartsCoord ( ) ) ; } else { this . setMessageQueue ( this . _wwaData . message [ SystemMessage1 . USE_ITEM ] === "" ? "このアイテムを使用します。\nよろしいですか?" : this . _wwaData . message [ SystemMessage1 . USE_ITEM ] , true , true ) ; this . _yesNoChoiceCallInfo = ChoiceCallInfo . CALL_BY_ITEM_USE ; this . _yesNoUseItemPos = itemPos ; } return true ; } return false ; } public onselectbutton ( button , forcePassword = false , forceGoToWWA = false ) { var bg = < HTMLDivElement > ( util . $id ( sidebarButtonCellElementID [ button ] ) ) ; this . playSound ( SystemSound . DECISION ) ; this . _itemMenu . close ( ) ; bg . classList . add ( "onpress" ) ; if ( button === SidebarButton . QUICK_LOAD ) { this . _yesNoChoiceCallInfo = this . _wwaSave . getFirstSaveChoiceCallInfo ( forcePassword ) ; switch ( this . _yesNoChoiceCallInfo ) { case ChoiceCallInfo . CALL_BY_QUICK_LOAD : case ChoiceCallInfo . CALL_BY_LOG_QUICK_LOAD : var secondCallInfo ; var loadTest = "" ; switch ( this . _yesNoChoiceCallInfo ) { case ChoiceCallInfo . CALL_BY_QUICK_LOAD : loadTest = "読み込むデータを選んでください。" ; this . _wwaSave . selectDBSaveDataList ( ) ; break ; case ChoiceCallInfo . CALL_BY_LOG_QUICK_LOAD : loadTest = "読み込むオートセーブを選んでください。" ; this . _wwaSave . selectLogSaveDataList ( ) ; break ; } secondCallInfo = this . _wwaSave . getSecondSaveChoiceCallInfo ( this . _usePassword ) ; this . _messageWindow . createSaveDom ( ) ; switch ( secondCallInfo ) { case ChoiceCallInfo . CALL_BY_LOG_QUICK_LOAD : this . setMessageQueue ( loadTest + "\n→Ｎｏでオートセーブ復帰画面に移ります。" , true , true ) ; break ; case ChoiceCallInfo . CALL_BY_PASSWORD_LOAD : this . setMessageQueue ( loadTest + "\n→Ｎｏでデータ復帰用パスワードの\n　入力選択ができます。" , true , true ) ; break ; case ChoiceCallInfo . NONE : this . setMessageQueue ( loadTest , true , true ) ; break ; } break ; case ChoiceCallInfo . CALL_BY_PASSWORD_LOAD : this . onpasswordloadcalled ( ) ; break ; } } else if ( button === SidebarButton . QUICK_SAVE ) { if ( ! this . _wwaData . disableSaveFlag ) { this . _wwaSave . selectDBSaveDataList ( ) ; this . _messageWindow . createSaveDom ( ) ; if ( this . _usePassword ) { this . setMessageQueue ( "データの一時保存先を選んでください。\n→Ｎｏでデータ復帰用パスワードの\n　表示選択ができます。" , true , true ) ; this . _yesNoChoiceCallInfo = ChoiceCallInfo . CALL_BY_QUICK_SAVE ; } else { this . setMessageQueue ( "データの一時保存先を選んでください。" , true , true ) ; this . _yesNoChoiceCallInfo = ChoiceCallInfo . CALL_BY_QUICK_SAVE ; } } else { this . setMessageQueue ( "ここではセーブ機能は\n使用できません。" , false , true ) ; } } else if ( button === SidebarButton . RESTART_GAME ) { this . setMessageQueue ( "初めからスタートしなおしますか？" , true , true ) ; this . _yesNoChoiceCallInfo = ChoiceCallInfo . CALL_BY_RESTART_GAME ; } else if ( button === SidebarButton . GOTO_WWA ) { if ( forceGoToWWA ) { if ( this . _bottomButtonType !== ControlPanelBottomButton . GOTO_WWA ) { ( < HTMLDivElement > ( util . $id ( sidebarButtonCellElementID [ SidebarButton . GOTO_WWA ] ) ) ) . classList . remove ( "onpress" ) ; } this . setMessageQueue ( "ＷＷＡの公式サイトを開きますか？" , true , true ) ; this . _yesNoChoiceCallInfo = ChoiceCallInfo . CALL_BY_GOTO_WWA ; } else { switch ( this . _bottomButtonType ) { case ControlPanelBottomButton . GOTO_WWA : this . _yesNoChoiceCallInfo = ChoiceCallInfo . CALL_BY_GOTO_WWA ; this . setMessageQueue ( "ＷＷＡの公式サイトを開きますか？" , true , true ) ; break ; case ControlPanelBottomButton . GAME_END : this . _yesNoChoiceCallInfo = ChoiceCallInfo . CALL_BY_END_GAME ; this . setMessageQueue ( "ＷＷＡゲームを終了しますか？" , true , true ) ; break ; case ControlPanelBottomButton . BATTLE_REPORT : this . launchBattleEstimateWindow ( ) ; break ; } } } } public onpasswordloadcalled ( ) { if ( this . _usePassword ) { var bg = < HTMLDivElement > ( util . $id ( sidebarButtonCellElementID [ SidebarButton . QUICK_LOAD ] ) ) ; bg . classList . add ( "onpress" ) ; this . setMessageQueue ( "データ復帰用のパスワードを入力しますか？" , true , true ) ; this . _yesNoChoiceCallInfo = ChoiceCallInfo . CALL_BY_PASSWORD_LOAD ; } else { this . setMessageQueue ( "セーブデータがありません。" , false , true ) ; } } public onpasswordsavecalled ( ) { var bg = < HTMLDivElement > ( util . $id ( sidebarButtonCellElementID [ SidebarButton . QUICK_SAVE ] ) ) ; bg . classList . add ( "onpress" ) ; if ( ! this . _wwaData . disableSaveFlag ) { if ( this . _useSuspend ) { this . setMessageQueue ( "ゲームを中断しますか？" , true , true ) ; this . _yesNoChoiceCallInfo = ChoiceCallInfo . CALL_BY_SUSPEND ; } else if ( this . _usePassword ) { this . setMessageQueue ( "データ復帰用のパスワードを表示しますか？" , true , true ) ; this . _yesNoChoiceCallInfo = ChoiceCallInfo . CALL_BY_PASSWORD_SAVE ; } } else { this . setMessageQueue ( "ここではセーブ機能は\n使用できません。" , false , true ) ; } } public onpasssuspendsavecalled ( ) { var bg = < HTMLDivElement > ( util . $id ( sidebarButtonCellElementID [ SidebarButton . QUICK_SAVE ] ) ) ; bg . classList . add ( "onpress" ) ; if ( ! this . _wwaData . disableSaveFlag ) { this . setMessageQueue ( "ゲームを中断しますか？" , true , true ) ; this . _yesNoChoiceCallInfo = ChoiceCallInfo . CALL_BY_SUSPEND ; } else { this . setMessageQueue ( "ここではセーブ機能は\n使用できません。" , false , true ) ; } } public onitemmenucalled ( ) { this . setMessageQueue ( "右のメニューを選択してください。" , false , true ) ; this . _messageWindow . setItemMenuChoice ( true ) ; this . playSound ( SystemSound . DECISION ) ; this . _itemMenu . openView ( ) ; } public onchangespeed ( type ) { if ( ! this . _wwaData . permitChangeGameSpeed ) { this . setMessageQueue ( "ここでは移動速度を\n変更できません。" , false , true ) ; return ; } var speedIndex , speedMessage ; if ( type === SpeedChange . UP ) { speedIndex = this . _player . speedUp ( ) ; } else { speedIndex = this . _player . speedDown ( ) ; } speedMessage = "移動速度を【" + speedNameList [ speedIndex ] + "】に切り替えました。\n" + ( this . isBattleSpeedIndexForQuickBattle ( speedIndex ) ? "戦闘も速くなります。\n" : "" ) + "(" + ( Consts . MAX_SPEED_INDEX + 1 ) + "段階中" + ( speedIndex + 1 ) + "）" ; switch ( this . userDevice . os ) { case OS_TYPE . NINTENDO : speedMessage += "速度を落とすには-ボタン, 速度を上げるには+ボタンを押してください。" ; break ; default : speedMessage += "速度を落とすにはIキー, 速度を上げるにはPキーを押してください。" ; break ; } this . setMessageQueue ( speedMessage , false , true ) ; } public isBattleSpeedIndexForQuickBattle ( battleSpeedIndex ) { return Consts . QUICK_BATTLE_SPEED_INDECIES . some ( index => index === battleSpeedIndex ) ; } /**
     * 方向キーと同時押しで、移動せずにプレイヤーの向きを変更するキーの入力判定
     */ private _checkTurnKeyPressed = ( ) => ( this . _keyStore . checkHitKey ( KeyCode . KEY_ESC ) || this . _keyStore . checkHitKey ( KeyCode . KEY_SHIFT ) || this . _keyStore . checkHitKey ( KeyCode . KEY_N ) ) ; private _main ( ) { this . _temporaryInputDisable = false ; this . _stopUpdateByLoadFlag = false ; this . _keyStore . update ( ) ; this . _mouseStore . update ( ) ; this . _gamePadStore . update ( ) ; if ( this . _waitFrame -- > 0 ) { window . requestAnimationFrame ( this . mainCaller ) ; return ; } this . _waitFrame = 0 ; if ( this . _yesNoJudgeInNextFrame !== void 0 ) { this . _yesNoJudge = this . _yesNoJudgeInNextFrame ; this . _yesNoJudgeInNextFrame = void 0 ; } if ( this . _clearFacesInNextFrame ) { this . clearFaces ( ) ; this . _clearFacesInNextFrame = false ; } for ( var i = 0 ; i < this . _execMacroListInNextFrame . length ; i ++ ) { this . _execMacroListInNextFrame [ i ] . execute ( ) ; } if ( this . _lastMessage . isEmpty ( ) && this . _lastMessage . isEndOfPartsEvent && this . _reservedMoveMacroTurn !== void 0 ) { this . _player . setMoveMacroWaiting ( this . _reservedMoveMacroTurn ) ; this . _reservedMoveMacroTurn = void 0 ; } this . _execMacroListInNextFrame = [ ] ; this . _player . mainFrameCount ( ) ; var prevPosition = this . _player . getPosition ( ) ; var pdir = this . _player . getDir ( ) ; if ( this . _player . isControllable ( ) ) { if ( ! this . _wwaData . disableSaveFlag ) { if ( this . _wwaSave . isAutoSaveFrame ( this . _player ) ) { this . _quickSave ( ChoiceCallInfo . CALL_BY_LOG_QUICK_SAVE ) ; } } if ( this . _player . isDelayFrame ( ) ) { this . _player . updateDelayFrame ( ) ; } else { if ( this . _actionGamePadButtonItemMacro ( ) ) { } else if ( this . _keyStore . getKeyStateForControllPlayer ( KeyCode . KEY_LEFT ) === KeyState . KEYDOWN ) { if ( this . _checkTurnKeyPressed ( ) ) { this . _player . setDir ( Direction . LEFT ) ; } else { this . _player . controll ( Direction . LEFT ) ; this . _objectMovingDataManager . update ( ) ; } } else if ( this . _keyStore . getKeyStateForControllPlayer ( KeyCode . KEY_UP ) === KeyState . KEYDOWN ) { if ( this . _checkTurnKeyPressed ( ) ) { this . _player . setDir ( Direction . UP ) ; } else { this . _player . controll ( Direction . UP ) ; this . _objectMovingDataManager . update ( ) ; } } else if ( this . _keyStore . getKeyStateForControllPlayer ( KeyCode . KEY_RIGHT ) === KeyState . KEYDOWN ) { if ( this . _checkTurnKeyPressed ( ) ) { this . _player . setDir ( Direction . RIGHT ) ; } else { this . _player . controll ( Direction . RIGHT ) ; this . _objectMovingDataManager . update ( ) ; } } else if ( this . _keyStore . getKeyStateForControllPlayer ( KeyCode . KEY_DOWN ) === KeyState . KEYDOWN ) { if ( this . _checkTurnKeyPressed ( ) ) { this . _player . setDir ( Direction . DOWN ) ; } else { this . _player . controll ( Direction . DOWN ) ; this . _objectMovingDataManager . update ( ) ; } } else if ( this . _mouseStore . getMouseStateForControllPlayer ( Direction . LEFT ) === MouseState . MOUSEDOWN ) { if ( this . _mouseStore . touchIDIsSetDir ( ) ) { this . _player . setDir ( Direction . LEFT ) ; } else { this . _player . controll ( Direction . LEFT ) ; this . _objectMovingDataManager . update ( ) ; } } else if ( this . _mouseStore . getMouseStateForControllPlayer ( Direction . UP ) === MouseState . MOUSEDOWN ) { if ( this . _mouseStore . touchIDIsSetDir ( ) ) { this . _player . setDir ( Direction . UP ) ; } else { this . _player . controll ( Direction . UP ) ; this . _objectMovingDataManager . update ( ) ; } } else if ( this . _mouseStore . getMouseStateForControllPlayer ( Direction . RIGHT ) === MouseState . MOUSEDOWN ) { if ( this . _mouseStore . touchIDIsSetDir ( ) ) { this . _player . setDir ( Direction . RIGHT ) ; } else { this . _player . controll ( Direction . RIGHT ) ; this . _objectMovingDataManager . update ( ) ; } } else if ( this . _mouseStore . getMouseStateForControllPlayer ( Direction . DOWN ) === MouseState . MOUSEDOWN ) { if ( this . _mouseStore . touchIDIsSetDir ( ) ) { this . _player . setDir ( Direction . DOWN ) ; } else { this . _player . controll ( Direction . DOWN ) ; this . _objectMovingDataManager . update ( ) ; } } else if ( this . _keyStore . checkHitKey ( dirToKey [ pdir ] ) ) { if ( this . _checkTurnKeyPressed ( ) ) { this . _player . setDir ( pdir ) ; } else { this . _player . controll ( pdir ) ; this . _objectMovingDataManager . update ( ) ; } } else if ( this . _keyStore . checkHitKey ( KeyCode . KEY_LEFT ) ) { if ( this . _checkTurnKeyPressed ( ) ) { this . _player . setDir ( Direction . LEFT ) ; } else { this . _player . controll ( Direction . LEFT ) ; this . _objectMovingDataManager . update ( ) ; } } else if ( this . _keyStore . checkHitKey ( KeyCode . KEY_UP ) ) { if ( this . _checkTurnKeyPressed ( ) ) { this . _player . setDir ( Direction . UP ) ; } else { this . _player . controll ( Direction . UP ) ; this . _objectMovingDataManager . update ( ) ; } } else if ( this . _keyStore . checkHitKey ( KeyCode . KEY_RIGHT ) ) { if ( this . _checkTurnKeyPressed ( ) ) { this . _player . setDir ( Direction . RIGHT ) ; } else { this . _player . controll ( Direction . RIGHT ) ; this . _objectMovingDataManager . update ( ) ; } } else if ( this . _keyStore . checkHitKey ( KeyCode . KEY_DOWN ) ) { if ( this . _checkTurnKeyPressed ( ) ) { this . _player . setDir ( Direction . DOWN ) ; } else { this . _player . controll ( Direction . DOWN ) ; this . _objectMovingDataManager . update ( ) ; } } else if ( this . _mouseStore . checkClickMouse ( Direction . LEFT ) ) { if ( this . _mouseStore . touchIDIsSetDir ( ) ) { this . _player . setDir ( Direction . LEFT ) ; } else { this . _player . controll ( Direction . LEFT ) ; this . _objectMovingDataManager . update ( ) ; } } else if ( this . _mouseStore . checkClickMouse ( Direction . UP ) ) { if ( this . _mouseStore . touchIDIsSetDir ( ) ) { this . _player . setDir ( Direction . UP ) ; } else { this . _player . controll ( Direction . UP ) ; this . _objectMovingDataManager . update ( ) ; } } else if ( this . _mouseStore . checkClickMouse ( Direction . RIGHT ) ) { if ( this . _mouseStore . touchIDIsSetDir ( ) ) { this . _player . setDir ( Direction . RIGHT ) ; } else { this . _player . controll ( Direction . RIGHT ) ; this . _objectMovingDataManager . update ( ) ; } } else if ( this . _mouseStore . checkClickMouse ( Direction . DOWN ) ) { if ( this . _mouseStore . touchIDIsSetDir ( ) ) { this . _player . setDir ( Direction . DOWN ) ; } else { this . _player . controll ( Direction . DOWN ) ; this . _objectMovingDataManager . update ( ) ; } } else if ( this . _gamePadStore . crossPressed ( GamePadState . BUTTON_CROSS_KEY_LEFT ) ) { if ( this . _gamePadStore . buttonPressed ( GamePadState . BUTTON_INDEX_B ) ) { this . _player . setDir ( Direction . LEFT ) ; } else { this . _player . controll ( Direction . LEFT ) ; this . _objectMovingDataManager . update ( ) ; } } else if ( this . _gamePadStore . crossPressed ( GamePadState . BUTTON_CROSS_KEY_UP ) ) { if ( this . _gamePadStore . buttonPressed ( GamePadState . BUTTON_INDEX_B ) ) { this . _player . setDir ( Direction . UP ) ; } else { this . _player . controll ( Direction . UP ) ; this . _objectMovingDataManager . update ( ) ; } } else if ( this . _gamePadStore . crossPressed ( GamePadState . BUTTON_CROSS_KEY_RIGHT ) ) { if ( this . _gamePadStore . buttonPressed ( GamePadState . BUTTON_INDEX_B ) ) { this . _player . setDir ( Direction . RIGHT ) ; } else { this . _player . controll ( Direction . RIGHT ) ; this . _objectMovingDataManager . update ( ) ; } } else if ( this . _gamePadStore . crossPressed ( GamePadState . BUTTON_CROSS_KEY_DOWN ) ) { if ( this . _gamePadStore . buttonPressed ( GamePadState . BUTTON_INDEX_B ) ) { this . _player . setDir ( Direction . DOWN ) ; } else { this . _player . controll ( Direction . DOWN ) ; this . _objectMovingDataManager . update ( ) ; } } else if ( this . _keyStore . getKeyState ( KeyCode . KEY_1 ) === KeyState . KEYDOWN ) { this . onselectitem ( 1 ) ; } else if ( this . _keyStore . getKeyState ( KeyCode . KEY_2 ) === KeyState . KEYDOWN ) { this . onselectitem ( 2 ) ; } else if ( this . _keyStore . getKeyState ( KeyCode . KEY_3 ) === KeyState . KEYDOWN ) { this . onselectitem ( 3 ) ; } else if ( this . _keyStore . getKeyState ( KeyCode . KEY_Q ) === KeyState . KEYDOWN ) { this . onselectitem ( 4 ) ; } else if ( this . _keyStore . getKeyState ( KeyCode . KEY_W ) === KeyState . KEYDOWN ) { this . onselectitem ( 5 ) ; } else if ( this . _keyStore . getKeyState ( KeyCode . KEY_E ) === KeyState . KEYDOWN ) { this . onselectitem ( 6 ) ; } else if ( this . _keyStore . getKeyState ( KeyCode . KEY_A ) === KeyState . KEYDOWN ) { this . onselectitem ( 7 ) ; } else if ( this . _keyStore . getKeyState ( KeyCode . KEY_S ) === KeyState . KEYDOWN ) { this . onselectitem ( 8 ) ; } else if ( this . _keyStore . getKeyState ( KeyCode . KEY_D ) === KeyState . KEYDOWN ) { this . onselectitem ( 9 ) ; } else if ( this . _keyStore . getKeyState ( KeyCode . KEY_Z ) === KeyState . KEYDOWN ) { this . onselectitem ( 10 ) ; } else if ( this . _keyStore . getKeyState ( KeyCode . KEY_X ) === KeyState . KEYDOWN ) { this . onselectitem ( 11 ) ; } else if ( this . _keyStore . getKeyState ( KeyCode . KEY_C ) === KeyState . KEYDOWN ) { this . onselectitem ( 12 ) ; } else if ( this . _keyStore . getKeyState ( KeyCode . KEY_I ) || this . _gamePadStore . buttonTrigger ( GamePadState . BUTTON_INDEX_MINUS ) ) { this . onchangespeed ( SpeedChange . DOWN ) ; } else if ( this . _keyStore . checkHitKey ( KeyCode . KEY_P ) || this . _keyStore . checkHitKey ( KeyCode . KEY_F2 ) || this . _gamePadStore . buttonTrigger ( GamePadState . BUTTON_INDEX_PLUS ) ) { this . onchangespeed ( SpeedChange . UP ) ; } else if ( this . _keyStore . getKeyState ( KeyCode . KEY_F1 ) === KeyState . KEYDOWN || this . _keyStore . getKeyState ( KeyCode . KEY_M ) === KeyState . KEYDOWN || this . _gamePadStore . buttonTrigger ( GamePadState . BUTTON_INDEX_A ) ) { if ( this . launchBattleEstimateWindow ( ) ) { } } else if ( this . _keyStore . checkHitKey ( KeyCode . KEY_F3 ) ) { this . playSound ( SystemSound . DECISION ) ; this . onselectbutton ( SidebarButton . QUICK_LOAD , true ) ; } else if ( this . _keyStore . checkHitKey ( KeyCode . KEY_F4 ) ) { this . playSound ( SystemSound . DECISION ) ; if ( this . _useSuspend ) { this . onpasssuspendsavecalled ( ) ; } else if ( this . _usePassword ) { this . onpasswordsavecalled ( ) ; } } else if ( this . _keyStore . checkHitKey ( KeyCode . KEY_F5 ) || this . _gamePadStore . buttonTrigger ( GamePadState . BUTTON_INDEX_A , GamePadState . BUTTON_INDEX_ZR ) ) { this . onselectbutton ( SidebarButton . QUICK_LOAD ) ; } else if ( this . _keyStore . checkHitKey ( KeyCode . KEY_F6 ) || this . _gamePadStore . buttonTrigger ( GamePadState . BUTTON_INDEX_A , GamePadState . BUTTON_INDEX_ZL ) ) { this . onselectbutton ( SidebarButton . QUICK_SAVE ) ; } else if ( this . _keyStore . checkHitKey ( KeyCode . KEY_F7 ) || this . _gamePadStore . buttonTrigger ( GamePadState . BUTTON_INDEX_A , GamePadState . BUTTON_INDEX_R ) ) { this . onselectbutton ( SidebarButton . RESTART_GAME ) ; } else if ( this . _keyStore . checkHitKey ( KeyCode . KEY_F8 ) ) { this . onselectbutton ( SidebarButton . GOTO_WWA , false , true ) ; } else if ( this . _keyStore . checkHitKey ( KeyCode . KEY_F9 ) || this . _gamePadStore . buttonTrigger ( GamePadState . BUTTON_INDEX_X ) ) { if ( this . _player . isControllable ( ) || ( this . _messageWindow . isItemMenuChoice ( ) ) ) { this . onitemmenucalled ( ) ; } } else if ( this . _keyStore . checkHitKey ( KeyCode . KEY_F12 ) || this . _gamePadStore . buttonTrigger ( GamePadState . BUTTON_INDEX_Y ) ) { this . _displayHelp ( ) ; } } this . _keyStore . memorizeKeyStateOnControllableFrame ( ) ; this . _mouseStore . memorizeMouseStateOnControllableFrame ( ) ; } else if ( this . _player . isJumped ( ) ) { if ( ! this . _camera . isResetting ( ) ) { this . _player . processAfterJump ( ) ; } } else if ( this . _player . isMoving ( ) ) { this . _player . move ( ) ; this . _objectMovingDataManager . update ( ) ; } else if ( this . _player . isWaitingMessage ( ) ) { if ( ! this . _messageWindow . isVisible ( ) ) { this . _messageWindow . show ( ) ; } if ( this . _messageWindow . isYesNoChoice ( ) ) { if ( this . _messageWindow . isSaveChoice ( ) ) { this . _messageWindow . saveUpdate ( ) ; if ( ! this . _messageWindow . isSaveClose ( ) ) { if ( this . _keyStore . checkHitKey ( KeyCode . KEY_LEFT ) || this . _gamePadStore . crossPressed ( GamePadState . BUTTON_CROSS_KEY_LEFT ) ) { this . _messageWindow . saveControll ( Direction . LEFT ) ; } else if ( this . _keyStore . checkHitKey ( KeyCode . KEY_UP ) || this . _gamePadStore . crossPressed ( GamePadState . BUTTON_CROSS_KEY_UP ) ) { this . _messageWindow . saveControll ( Direction . UP ) ; } else if ( this . _keyStore . checkHitKey ( KeyCode . KEY_RIGHT ) || this . _gamePadStore . crossPressed ( GamePadState . BUTTON_CROSS_KEY_RIGHT ) ) { this . _messageWindow . saveControll ( Direction . RIGHT ) ; } else if ( this . _keyStore . checkHitKey ( KeyCode . KEY_DOWN ) || this . _gamePadStore . crossPressed ( GamePadState . BUTTON_CROSS_KEY_DOWN ) ) { this . _messageWindow . saveControll ( Direction . DOWN ) ; } } } if ( ! this . _messageWindow . isInputDisable ( ) ) { if ( this . _yesNoJudge === YesNoState . UNSELECTED ) { if ( this . _keyStore . getKeyState ( KeyCode . KEY_ENTER ) === KeyState . KEYDOWN || this . _keyStore . getKeyState ( KeyCode . KEY_Y ) === KeyState . KEYDOWN || this . _gamePadStore . buttonTrigger ( GamePadState . BUTTON_INDEX_A ) ) { this . _yesNoJudge = YesNoState . YES ; } else if ( this . _keyStore . getKeyState ( KeyCode . KEY_N ) === KeyState . KEYDOWN || this . _keyStore . getKeyState ( KeyCode . KEY_ESC ) === KeyState . KEYDOWN || this . _gamePadStore . buttonTrigger ( GamePadState . BUTTON_INDEX_B ) ) { this . _yesNoJudge = YesNoState . NO ; } } if ( this . _yesNoJudge === YesNoState . YES ) { this . playSound ( SystemSound . DECISION ) ; this . _yesNoDispCounter = Consts . YESNO_PRESS_DISP_FRAME_NUM ; this . _messageWindow . setInputDisable ( ) ; this . _messageWindow . update ( ) ; } else if ( this . _yesNoJudge === YesNoState . NO ) { this . playSound ( SystemSound . DECISION ) ; this . _yesNoDispCounter = Consts . YESNO_PRESS_DISP_FRAME_NUM ; this . _messageWindow . setInputDisable ( ) ; this . _messageWindow . update ( ) ; } } } else if ( this . _messageWindow . isItemMenuChoice ( ) ) { this . _itemMenu . update ( ) ; if ( this . _keyStore . checkHitKey ( KeyCode . KEY_LEFT ) || this . _gamePadStore . crossPressed ( GamePadState . BUTTON_CROSS_KEY_LEFT ) ) { this . _itemMenu . controll ( Direction . LEFT ) ; } else if ( this . _keyStore . checkHitKey ( KeyCode . KEY_UP ) || this . _gamePadStore . crossPressed ( GamePadState . BUTTON_CROSS_KEY_UP ) ) { this . _itemMenu . controll ( Direction . UP ) ; } else if ( this . _keyStore . checkHitKey ( KeyCode . KEY_RIGHT ) || this . _gamePadStore . crossPressed ( GamePadState . BUTTON_CROSS_KEY_RIGHT ) ) { this . _itemMenu . controll ( Direction . RIGHT ) ; } else if ( this . _keyStore . checkHitKey ( KeyCode . KEY_DOWN ) || this . _gamePadStore . crossPressed ( GamePadState . BUTTON_CROSS_KEY_DOWN ) ) { this . _itemMenu . controll ( Direction . DOWN ) ; } if ( this . _keyStore . getKeyState ( KeyCode . KEY_ENTER ) === KeyState . KEYDOWN || this . _keyStore . getKeyState ( KeyCode . KEY_Y ) === KeyState . KEYDOWN || this . _gamePadStore . buttonTrigger ( GamePadState . BUTTON_INDEX_A ) ) { this . _setNextMessage ( ) ; this . _messageWindow . setItemMenuChoice ( false ) ; this . _itemMenu . ok ( ) ; } else if ( this . _mouseStore . checkClickMouse ( Direction . LEFT ) || this . _mouseStore . checkClickMouse ( Direction . UP ) || this . _mouseStore . checkClickMouse ( Direction . RIGHT ) || this . _mouseStore . checkClickMouse ( Direction . DOWN ) || this . _keyStore . getKeyState ( KeyCode . KEY_N ) === KeyState . KEYDOWN || this . _keyStore . getKeyState ( KeyCode . KEY_ESC ) === KeyState . KEYDOWN || this . _gamePadStore . buttonTrigger ( GamePadState . BUTTON_INDEX_B ) ) { for ( var i = 0 ; i < sidebarButtonCellElementID . length ; i ++ ) { var elm = < HTMLDivElement > ( util . $id ( sidebarButtonCellElementID [ i ] ) ) ; if ( elm . classList . contains ( "onpress" ) ) { elm . classList . remove ( "onpress" ) ; } } this . _itemMenu . ng ( ) ; this . _setNextMessage ( ) ; this . playSound ( SystemSound . DECISION ) ; this . _messageWindow . setItemMenuChoice ( false ) ; } } else { var enter = this . _keyStore . getKeyStateForMessageCheck ( KeyCode . KEY_ENTER ) ; var space = this . _keyStore . getKeyStateForMessageCheck ( KeyCode . KEY_SPACE ) ; var esc = this . _keyStore . getKeyStateForMessageCheck ( KeyCode . KEY_ESC ) ; if ( enter === KeyState . KEYDOWN || enter === KeyState . KEYPRESS_MESSAGECHANGE || space === KeyState . KEYDOWN || space === KeyState . KEYPRESS_MESSAGECHANGE || esc === KeyState . KEYDOWN || esc === KeyState . KEYPRESS_MESSAGECHANGE || this . _mouseStore . getMouseState ( ) === MouseState . MOUSEDOWN || this . _gamePadStore . buttonTrigger ( GamePadState . BUTTON_INDEX_A , GamePadState . BUTTON_INDEX_B ) ) { for ( var i = 0 ; i < sidebarButtonCellElementID . length ; i ++ ) { var elm = < HTMLDivElement > ( util . $id ( sidebarButtonCellElementID [ i ] ) ) ; if ( elm . classList . contains ( "onpress" ) ) { elm . classList . remove ( "onpress" ) ; } } this . _setNextMessage ( ) ; } } } else if ( this . _player . isWatingEstimateWindow ( ) ) { if ( this . _keyStore . getKeyState ( KeyCode . KEY_ENTER ) === KeyState . KEYDOWN || this . _keyStore . getKeyState ( KeyCode . KEY_SPACE ) === KeyState . KEYDOWN || this . _gamePadStore . buttonTrigger ( GamePadState . BUTTON_INDEX_A , GamePadState . BUTTON_INDEX_B ) ) { this . hideBattleEstimateWindow ( ) ; } } else if ( this . _player . isFighting ( ) ) { this . _player . fight ( ) ; this . _monsterWindow . update ( this . _monster ) ; } else if ( this . _player . isWaitingMoveMacro ( ) ) { if ( this . _player . isMoveObjectAutoExecTime ( ) ) { this . moveObjects ( false ) ; this . _player . resetMoveObjectAutoExecTimer ( ) ; } this . _objectMovingDataManager . update ( ) ; } this . _prevFrameEventExected = false ; if ( this . _player . getPosition ( ) . isJustPosition ( ) && this . _camera . getPosition ( ) . isScreenTopPosition ( ) ) { if ( ! this . _player . isJumped ( ) && ! this . _player . isWaitingMessage ( ) && ! this . _player . isWatingEstimateWindow ( ) && ! this . _player . isWaitingMoveMacro ( ) && ! this . _player . isFighting ( ) ) { if ( this . _player . isPartsAppearedTime ( ) ) { this . _player . clearPartsAppearedFlag ( ) ; } this . _replaceRandomObjectsInScreen ( ) ; var eventExecuted = this . checkMap ( ) ; if ( ! eventExecuted ) { this . checkObject ( ) ; } this . _prevFrameEventExected = eventExecuted ; } if ( this . _player . isWaitingMessage ( ) && this . _messageWindow . isYesNoChoice ( ) && this . _yesNoJudge !== YesNoState . UNSELECTED && ! this . _player . isWaitingMoveMacro ( ) && ! this . _player . isFighting ( ) ) { this . _execChoiceWindowRunningEvent ( ) ; } } if ( this . _passwordLoadExecInNextFrame ) { this . _stopUpdateByLoadFlag = true ; this . _loadType = LoadType . PASSWORD ; this . _player . clearPasswordWindowWaiting ( ) ; this . _passwordLoadExecInNextFrame = false ; } this . _drawAll ( ) ; this . _mainCallCounter ++ ; this . _mainCallCounter %= 1000000000 ; if ( ! this . _player . isWaitingMessage ( ) || ! this . _isClassicModeEnable ) { this . _animationCounter = ( this . _animationCounter + 1 ) % ( Consts . ANIMATION_REP_HALF_FRAME * 2 ) ; } if ( this . _camera . isResetting ( ) ) { this . _camera . advanceTransitionStepNum ( ) ; } if ( ! this . _player . isWaitingMessage ( ) ) { this . _player . decrementLookingAroundTimer ( ) ; if ( this . _statusPressCounter . energy > 0 && -- this . _statusPressCounter . energy === 0 ) { util . $id ( "disp-energy" ) . classList . remove ( "onpress" ) ; } if ( this . _statusPressCounter . strength > 0 && -- this . _statusPressCounter . strength === 0 ) { util . $id ( "disp-strength" ) . classList . remove ( "onpress" ) ; } if ( this . _statusPressCounter . defence > 0 && -- this . _statusPressCounter . defence === 0 ) { util . $id ( "disp-defence" ) . classList . remove ( "onpress" ) ; } if ( this . _statusPressCounter . gold > 0 && -- this . _statusPressCounter . gold === 0 ) { util . $id ( "disp-gold" ) . classList . remove ( "onpress" ) ; } } if ( this . _player . isWaitingMoveMacro ( ) ) { this . _player . decrementMoveObjectAutoExecTimer ( ) ; } if ( ! this . _stopUpdateByLoadFlag ) { window . requestAnimationFrame ( this . mainCaller ) ; } else { this . _fadeout ( ( ) : void => { if ( this . _loadType === LoadType . QUICK_LOAD ) { this . _quickLoad ( ) ; this . wwaCustomEvent ( 'wwa_quickload' ) ; } else if ( this . _loadType === LoadType . RESTART_GAME ) { this . _restartGame ( ) ; this . wwaCustomEvent ( 'wwa_restert' ) ; } else if ( this . _loadType === LoadType . PASSWORD ) { this . _applyQuickLoad ( this . _passwordSaveExtractData ) ; this . _passwordSaveExtractData = void 0 ; this . wwaCustomEvent ( 'wwa_passwordload' ) ; } setTimeout ( this . mainCaller , Consts . DEFAULT_FRAME_INTERVAL , this ) ; } ) ; } if ( this . _dumpElement !== null ) { for ( var i = 0 ; i < Consts . USER_VAR_NUM ; i ++ ) { this . _dumpElement . querySelector ( ".var" + i . toString ( 10 ) ) . textContent = this . _wwaData . userVar [ i ] + "" ; } } } public vibration ( isStrong ) { this . _gamePadStore . vibration ( isStrong ) ; } private _drawAll ( ) { var cpParts = this . _camera . getPosition ( ) . getPartsCoord ( ) ; var cpOffset = this . _camera . getPosition ( ) . getOffsetCoord ( ) ; var yLimit = Consts . MAP_WINDOW_HEIGHT ; var targetX ; var targetY ; var ppos = this . _player . getPosition ( ) . getPartsCoord ( ) ; if ( this . _paintSkipByDoorOpen ) { this . _paintSkipByDoorOpen = false ; return ; } this . _cgManager . clearCanvas ( 0 , 0 , Consts . MAP_WINDOW_WIDTH , Consts . MAP_WINDOW_HEIGHT ) ; this . _cgManager . drawBase ( 0 , 0 , Consts . MAP_WINDOW_WIDTH , Consts . MAP_WINDOW_HEIGHT ) ; if ( this . _camera . isResetting ( ) ) { if ( this . _camera . getPreviousPosition ( ) !== null ) { var cpPartsPrev = this . _camera . getPreviousPosition ( ) . getPartsCoord ( ) ; var cpOffsetPrev = this . _camera . getPreviousPosition ( ) . getOffsetCoord ( ) ; } yLimit = this . _camera . getTransitionStepNum ( ) * Consts . CHIP_SIZE ; } var cacheDrawFlag = false ; if ( yLimit !== this . _cgManager . mapCacheYLimit ) { this . _cgManager . mapCacheYLimit = yLimit ; cacheDrawFlag = true ; } if ( ( cpParts . x !== this . _cgManager . cpPartsLog . x ) || ( cpParts . y !== this . _cgManager . cpPartsLog . y ) ) { this . _cgManager . cpPartsLog . x = cpParts . x ; this . _cgManager . cpPartsLog . y = cpParts . y ; cacheDrawFlag = true ; } if ( cacheDrawFlag ) { this . _cgManager . clearBackCanvas ( ) ; this . _cgManager . clearObjectCanvases ( ) ; } if ( this . _camera . isResetting ( ) ) { this . _drawMap ( cpPartsPrev , cpOffsetPrev , yLimit , true ) ; this . _drawPlayer ( cpPartsPrev , cpOffsetPrev , yLimit , true ) ; this . _drawObjects ( cpPartsPrev , cpOffsetPrev , yLimit , true ) ; if ( this . _camera . isFinalStep ( ) ) { var opacity = 255 ; var timer = setInterval ( ( ) : void => { var elm = util . $id ( "wwa-fader" ) ; opacity -= Consts . FADEOUT_SPEED * 3 ; if ( opacity <= 0 ) { clearInterval ( timer ) ; elm . style . backgroundColor = "transparent" ; elm . removeAttribute ( "style" ) ; elm . style . display = "none" ; return ; } elm . style . opacity = ( opacity / 255 ) + "" ; } , 20 ) ; } } this . _drawMap ( cpParts , cpOffset , yLimit , false , cacheDrawFlag ) ; this . _drawPlayer ( cpParts , cpOffset , yLimit ) ; this . _drawObjects ( cpParts , cpOffset , yLimit , false , cacheDrawFlag ) ; if ( this . _player . isFighting ( ) && ! this . _player . isBattleStartFrame ( ) ) { targetX = this . _player . isTurn ( ) ? this . _monster . position . x : ppos . x ; targetY = this . _player . isTurn ( ) ? this . _monster . position . y : ppos . y ; this . _cgManager . drawCanvas ( this . _battleEffectCoord . x , this . _battleEffectCoord . y , Consts . CHIP_SIZE * ( targetX - cpParts . x ) - cpOffset . x , Consts . CHIP_SIZE * ( targetY - cpParts . y ) - cpOffset . y ) ; } this . _drawEffect ( ) ; this . _drawFaces ( ) ; this . _drawFrame ( ) ; } private _drawMap ( cpParts , cpOffset , yLimit , isPrevCamera = false , cacheDrawFlag = false ) { if ( cpParts === void 0 ) { return ; } var xLeft = Math . max ( 0 , cpParts . x - 1 ) ; var xRight = Math . min ( this . _wwaData . mapWidth - 1 , cpParts . x + Consts . H_PARTS_NUM_IN_WINDOW ) ; var yTop = Math . max ( 0 , cpParts . y - 1 ) ; var yBottom = Math . min ( this . _wwaData . mapWidth - 1 , cpParts . y + Consts . V_PARTS_NUM_IN_WINDOW ) ; var count ; count = 0 ; if ( isPrevCamera ) { for ( var x = xLeft ; x <= xRight ; x ++ ) { for ( var y = yTop ; y <= yBottom ; y ++ ) { var partsID = this . _wwaData . map [ y ] [ x ] ; var ppx = this . _wwaData . mapAttribute [ partsID ] [ Consts . ATR_X ] / Consts . CHIP_SIZE ; var ppy = this . _wwaData . mapAttribute [ partsID ] [ Consts . ATR_Y ] / Consts . CHIP_SIZE ; var canvasX = Consts . CHIP_SIZE * ( x - cpParts . x ) - cpOffset . x ; var canvasY = Consts . CHIP_SIZE * ( y - cpParts . y ) - cpOffset . y ; this . _cgManager . copyBackCanvasWithLowerYLimit ( ppx , ppy , canvasX , canvasY , yLimit ) ; } } } else { for ( var x = xLeft ; x <= xRight ; x ++ ) { for ( var y = yTop ; y <= yBottom ; y ++ ) { var partsID = this . _wwaData . map [ y ] [ x ] ; if ( this . _cgManager . mapCache [ count ] !== partsID ) { this . _cgManager . mapCache [ count ] = partsID ; cacheDrawFlag = true ; } count ++ ; } } if ( cacheDrawFlag ) { this . _cgManager . clearBackCanvasWithLowerYLimit ( yLimit ) ; for ( var x = xLeft ; x <= xRight ; x ++ ) { for ( var y = yTop ; y <= yBottom ; y ++ ) { var partsID = this . _wwaData . map [ y ] [ x ] ; var ppx = this . _wwaData . mapAttribute [ partsID ] [ Consts . ATR_X ] / Consts . CHIP_SIZE ; var ppy = this . _wwaData . mapAttribute [ partsID ] [ Consts . ATR_Y ] / Consts . CHIP_SIZE ; var canvasX = Consts . CHIP_SIZE * ( x - cpParts . x ) - cpOffset . x ; var canvasY = Consts . CHIP_SIZE * ( y - cpParts . y ) - cpOffset . y ; this . _cgManager . copyBackCanvasWithUpperYLimit ( ppx , ppy , canvasX , canvasY , yLimit ) ; } } } this . _cgManager . drawBackCanvas ( ) ; } } private _drawPlayer ( cpParts , cpOffset , yLimit , isPrevCamera = false ) { if ( cpParts === void 0 || this . _wwaData . delPlayerFlag ) { return ; } var pos = this . _player . getPosition ( ) . getPartsCoord ( ) ; var poso = this . _player . getPosition ( ) . getOffsetCoord ( ) ; var relpcrop = dirToPos [ this . _player . getDir ( ) ] ; var canvasX = ( pos . x - cpParts . x ) * Consts . CHIP_SIZE + poso . x - cpOffset . x ; var canvasY = ( pos . y - cpParts . y ) * Consts . CHIP_SIZE + poso . y - cpOffset . y ; var dx = Math . abs ( poso . x ) ; var dy = Math . abs ( poso . y ) ; var dir = this . _player . getDir ( ) ; var crop ; var dirChanger = [ 2 , 3 , 4 , 5 , 0 , 1 , 6 , 7 ] ; if ( this . _useLookingAround && this . _player . isLookingAround ( ) && ! this . _player . isWaitingMessage ( ) ) { crop = this . _wwaData . playerImgPosX + dirChanger [ Math . floor ( this . _mainCallCounter % 64 / 8 ) ] ; } else if ( this . _player . isMovingImage ( ) ) { crop = this . _wwaData . playerImgPosX + relpcrop + 1 ; } else { crop = this . _wwaData . playerImgPosX + relpcrop ; } if ( isPrevCamera ) { this . _cgManager . drawCanvasWithLowerYLimit ( crop , this . _wwaData . playerImgPosY , canvasX , canvasY , yLimit ) ; } else { this . _cgManager . drawCanvasWithUpperYLimit ( crop , this . _wwaData . playerImgPosY , canvasX , canvasY , yLimit ) ; } } private _drawObjects ( cpParts , cpOffset , yLimit , isPrevCamera = false , cacheDrawFlag = false ) { if ( cpParts === void 0 ) { return ; } var xLeft = Math . max ( 0 , cpParts . x - 1 ) ; var xRight = Math . min ( this . _wwaData . mapWidth - 1 , cpParts . x + Consts . H_PARTS_NUM_IN_WINDOW ) ; var yTop = Math . max ( 0 , cpParts . y - 1 ) ; var yBottom = Math . min ( this . _wwaData . mapWidth - 1 , cpParts . y + Consts . V_PARTS_NUM_IN_WINDOW ) ; var offset ; var count = 0 ; var animationType = this . _animationCounter > Consts . ANIMATION_REP_HALF_FRAME ; var imgType , ppxo , ppyo , canvasX , canvasY , type , num , result ; var x , y , partsIDObj , savePartsIDObj , n ; var useBattleArea = this . _player . isFighting ( ) && this . _player . isTurn ( ) && this . _player . getPosition ( ) . getPartsCoord ( ) . equals ( this . _monster . position ) ; if ( isPrevCamera ) { for ( x = xLeft ; x <= xRight ; x ++ ) { for ( y = yTop ; y <= yBottom ; y ++ ) { if ( ( useBattleArea ) && new Coord ( x , y ) . equals ( this . _monster . position ) ) { continue ; } partsIDObj = this . _wwaData . mapObject [ y ] [ x ] ; offset = new Coord ( 0 , 0 ) ; if ( this . _wwaData . objectAttribute [ partsIDObj ] [ Consts . ATR_MOVE ] !== MoveType . STATIC ) { result = this . _objectMovingDataManager . getOffsetByBeforePartsCoord ( new Coord ( x , y ) ) ; if ( result !== null ) { offset = result ; } } canvasX = Consts . CHIP_SIZE * ( x - cpParts . x ) + offset . x - cpOffset . x ; canvasY = Consts . CHIP_SIZE * ( y - cpParts . y ) + offset . y - cpOffset . y ; imgType = ( animationType || this . _wwaData . objectAttribute [ partsIDObj ] [ Consts . ATR_X2 ] === 0 && this . _wwaData . objectAttribute [ partsIDObj ] [ Consts . ATR_Y2 ] === 0 ) ; ppxo = this . _wwaData . objectAttribute [ partsIDObj ] [ imgType ? Consts . ATR_X : Consts . ATR_X2 ] / Consts . CHIP_SIZE ; ppyo = this . _wwaData . objectAttribute [ partsIDObj ] [ imgType ? Consts . ATR_Y : Consts . ATR_Y2 ] / Consts . CHIP_SIZE ; type = this . _wwaData . objectAttribute [ partsIDObj ] [ Consts . ATR_TYPE ] ; num = this . _wwaData . objectAttribute [ partsIDObj ] [ Consts . ATR_NUMBER ] ; if ( partsIDObj !== 0 && ! this . _checkNoDrawObject ( new Coord ( x , y ) , type , num ) ) { this . _cgManager . copyObjectCanvasWithLowerYLimit ( animationType ? 1 : 0 , ppxo , ppyo , canvasX , canvasY , yLimit ) ; } } } } else { var drawPartsList = [ ] ; var drawStaticPartsList = [ ] ; var drawPartsData ; var isStatic , isFighting ; for ( x = xLeft ; x <= xRight ; x ++ ) { for ( y = yTop ; y <= yBottom ; y ++ ) { savePartsIDObj = partsIDObj = this . _wwaData . mapObject [ y ] [ x ] ; type = this . _wwaData . objectAttribute [ partsIDObj ] [ Consts . ATR_TYPE ] ; num = this . _wwaData . objectAttribute [ partsIDObj ] [ Consts . ATR_NUMBER ] ; if ( this . _checkNoDrawObject ( new Coord ( x , y ) , type , num ) ) { savePartsIDObj = 0 ; } isStatic = this . _wwaData . objectAttribute [ partsIDObj ] [ Consts . ATR_MOVE ] === MoveType . STATIC ; if ( savePartsIDObj !== 0 ) { if ( ( useBattleArea ) && new Coord ( x , y ) . equals ( this . _monster . position ) ) { isFighting = true ; } else { isFighting = false ; } if ( isStatic ) { drawStaticPartsList . push ( new DrawPartsData ( partsIDObj , x , y , isStatic , isFighting ) ) ; } else { drawPartsList . push ( new DrawPartsData ( partsIDObj , x , y , isStatic , isFighting ) ) ; savePartsIDObj = 0 ; } if ( isFighting ) { savePartsIDObj = 0 ; } } if ( this . _cgManager . mapObjectCache [ count ] !== savePartsIDObj ) { this . _cgManager . mapObjectCache [ count ] = savePartsIDObj ; cacheDrawFlag = true ; } count ++ ; } } if ( cacheDrawFlag ) { this . _cgManager . clearObjectCanvasesWithLowerYLimit ( yLimit ) ; Array . prototype . push . apply ( drawPartsList , drawStaticPartsList ) ; } var i , len ; len = drawPartsList . length ; for ( i = 0 ; i < len ; i ++ ) { drawPartsData = drawPartsList [ i ] ; x = drawPartsData . x ; y = drawPartsData . y ; partsIDObj = drawPartsData . partsIDObj ; isStatic = drawPartsData . isStatic ; isFighting = drawPartsData . isFighting ; canvasX = Consts . CHIP_SIZE * ( x - cpParts . x ) - cpOffset . x ; canvasY = Consts . CHIP_SIZE * ( y - cpParts . y ) - cpOffset . y ; if ( isStatic ) { if ( isFighting ) { continue ; } for ( n = 0 ; n < 2 ; n ++ ) { imgType = ( ( ! ! n ) || this . _wwaData . objectAttribute [ partsIDObj ] [ Consts . ATR_X2 ] === 0 && this . _wwaData . objectAttribute [ partsIDObj ] [ Consts . ATR_Y2 ] === 0 ) ; ppxo = this . _wwaData . objectAttribute [ partsIDObj ] [ imgType ? Consts . ATR_X : Consts . ATR_X2 ] / Consts . CHIP_SIZE ; ppyo = this . _wwaData . objectAttribute [ partsIDObj ] [ imgType ? Consts . ATR_Y : Consts . ATR_Y2 ] / Consts . CHIP_SIZE ; this . _cgManager . copyObjectCanvasWithUpperYLimit ( n , ppxo , ppyo , canvasX , canvasY , yLimit ) ; } } else { result = this . _objectMovingDataManager . getOffsetByBeforePartsCoord ( new Coord ( x , y ) ) ; if ( result !== null ) { canvasX += result . x ; canvasY += result . y ; } imgType = ( animationType || this . _wwaData . objectAttribute [ partsIDObj ] [ Consts . ATR_X2 ] === 0 && this . _wwaData . objectAttribute [ partsIDObj ] [ Consts . ATR_Y2 ] === 0 ) ; ppxo = this . _wwaData . objectAttribute [ partsIDObj ] [ imgType ? Consts . ATR_X : Consts . ATR_X2 ] / Consts . CHIP_SIZE ; ppyo = this . _wwaData . objectAttribute [ partsIDObj ] [ imgType ? Consts . ATR_Y : Consts . ATR_Y2 ] / Consts . CHIP_SIZE ; this . _cgManager . drawCanvasWithUpperYLimit ( ppxo , ppyo , canvasX , canvasY , yLimit ) ; } } this . _cgManager . drawObjectCanvas ( animationType ? 1 : 0 ) ; } } private _drawEffect ( ) { if ( this . _wwaData . effectCoords . length === 0 || this . _wwaData . effectWaits === 0 ) { return ; } var id = Math . floor ( this . _mainCallCounter % ( this . _wwaData . effectCoords . length * this . _wwaData . effectWaits ) / this . _wwaData . effectWaits ) ; this . _cgManager . drawEffect ( id ) ; } private _drawFaces ( ) { for ( var i = 0 ; i < this . _faces . length ; i ++ ) { this . _cgManager . drawCanvasWithSize ( this . _faces [ i ] . srcPos . x , this . _faces [ i ] . srcPos . y , this . _faces [ i ] . srcSize . x , this . _faces [ i ] . srcSize . y , this . _faces [ i ] . destPos . x , this . _faces [ i ] . destPos . y ) ; } } private _drawFrame ( ) { this . _cgManager . drawFrame ( ) ; } private _checkNoDrawObject ( objCoord , objType , atrNumber ) { var pPos = this . _player . getPosition ( ) ; var pCoord = pPos . getPartsCoord ( ) ; if ( ! pPos . isJustPosition ( ) || pCoord . x !== objCoord . x || pCoord . y !== objCoord . y || this . _wwaData . objectNoCollapseDefaultFlag ) { return false ; } if ( objType === Consts . OBJECT_DOOR && atrNumber === 0 ) { return true ; } return ( objType === Consts . OBJECT_STATUS || objType === Consts . OBJECT_MESSAGE || objType === Consts . OBJECT_ITEM || objType === Consts . OBJECT_SELL || objType === Consts . OBJECT_BUY || objType === Consts . OBJECT_SELL || objType === Consts . OBJECT_LOCALGATE ) ; } public getMapWidth ( ) { if ( this . _wwaData === void 0 ) { throw new Error ( "マップデータがロードされていません" ) ; } return this . _wwaData . mapWidth ; } public getMapIdByPosition ( pos ) { var pc = pos . getPartsCoord ( ) ; return this . _wwaData . map [ pc . y ] [ pc . x ] ; } public getObjectIdByPosition ( pos ) { var pc = pos . getPartsCoord ( ) ; return this . _wwaData . mapObject [ pc . y ] [ pc . x ] ; } public getMapTypeByPosition ( pos ) { var pc = pos . getPartsCoord ( ) ; var pid = this . _wwaData . map [ pc . y ] [ pc . x ] ; return this . _wwaData . mapAttribute [ pid ] [ Consts . ATR_TYPE ] ; } public getObjectTypeByPosition ( pos ) { var pc = pos . getPartsCoord ( ) ; var pid = this . _wwaData . mapObject [ pc . y ] [ pc . x ] ; return this . _wwaData . objectAttribute [ pid ] [ Consts . ATR_TYPE ] ; } public getMapAttributeByPosition ( pos , attr ) { var pc = pos . getPartsCoord ( ) ; var pid = this . _wwaData . map [ pc . y ] [ pc . x ] ; return this . _wwaData . mapAttribute [ pid ] [ attr ] ; } public isCurrentPosMapPartsIncludingMessage ( pos ) { var mesid = this . getMapAttributeByPosition ( pos , Consts . ATR_STRING ) ; return mesid !== 0 ; } public getObjectAttributeByPosition ( pos , attr ) { var pc = pos . getPartsCoord ( ) ; var pid = this . _wwaData . mapObject [ pc . y ] [ pc . x ] ; return this . _wwaData . objectAttribute [ pid ] [ attr ] ; } public getMapAttributeById ( id , attr ) { return this . _wwaData . mapAttribute [ id ] [ attr ] ; } public getObjectAttributeById ( id , attr ) { return this . _wwaData . objectAttribute [ id ] [ attr ] ; } public getObjectCropXById ( id ) { return this . _wwaData . objectAttribute [ id ] [ Consts . ATR_X ] ; } public getObjectCropYById ( id ) { return this . _wwaData . objectAttribute [ id ] [ Consts . ATR_Y ] ; } public getMessageById ( messageID ) { return this . _wwaData . message [ messageID ] ; } public getSystemMessageById ( messageID ) { return this . _wwaData . systemMessage [ messageID ] ; } public checkMap ( pos ? ) { var playerPos = this . _player . getPosition ( ) . getPartsCoord ( ) ; pos = ( pos !== void 0 && pos !== null ) ? pos : playerPos ; var partsID = this . _wwaData . map [ pos . y ] [ pos . x ] ; var mapAttr = this . _wwaData . mapAttribute [ partsID ] [ Consts . ATR_TYPE ] ; var isPlayerPositionExec = ( pos . x === playerPos . x && pos . y === playerPos . y ) ; var eventExecuted = false ; if ( isPlayerPositionExec ) { if ( this . _player . getLastExecPartsIDOnSamePosition ( PartsType . MAP ) === partsID ) { return false ; } } if ( mapAttr === Consts . MAP_STREET ) { eventExecuted = this . _execMapStreetEvent ( pos , partsID , mapAttr ) ; } else if ( mapAttr === Consts . MAP_WALL ) { eventExecuted = this . _execMapWallEvent ( pos , partsID , mapAttr ) ; } else if ( mapAttr === Consts . MAP_LOCALGATE ) { eventExecuted = this . _execMapLocalGateEvent ( pos , partsID , mapAttr ) ; } else if ( mapAttr === Consts . MAP_URLGATE ) { eventExecuted = this . _execMapUrlGateEvent ( pos , partsID , mapAttr ) ; } if ( isPlayerPositionExec && ! this . _player . isJumped ( ) ) { this . _player . setLastExecInfoOnSamePosition ( PartsType . MAP , partsID ) ; } return eventExecuted ; } public checkObject ( pos ? ) { var playerPos = this . _player . getPosition ( ) . getPartsCoord ( ) ; pos = ( pos !== void 0 && pos !== null ) ? pos : playerPos ; var partsID = this . _wwaData . mapObject [ pos . y ] [ pos . x ] ; var objAttr = this . _wwaData . objectAttribute [ partsID ] [ Consts . ATR_TYPE ] ; var isPlayerPositionExec = ( pos . x === playerPos . x && pos . y === playerPos . y ) ; if ( isPlayerPositionExec ) { if ( this . _player . getLastExecPartsIDOnSamePosition ( PartsType . OBJECT ) === partsID ) { return ; } } if ( objAttr === Consts . OBJECT_NORMAL ) { this . _execObjectNormalEvent ( pos , partsID , objAttr ) ; } else if ( objAttr === Consts . OBJECT_MESSAGE ) { this . _execObjectMessageEvent ( pos , partsID , objAttr ) ; } else if ( objAttr === Consts . OBJECT_MONSTER ) { this . _execObjectMonsterEvent ( pos , partsID , objAttr ) ; } else if ( objAttr === Consts . OBJECT_ITEM ) { this . _execObjectItemEvent ( pos , partsID , objAttr ) ; } else if ( objAttr === Consts . OBJECT_DOOR ) { this . _execObjectDoorEvent ( pos , partsID , objAttr ) ; } else if ( objAttr === Consts . OBJECT_STATUS ) { this . _execObjectStatusEvent ( pos , partsID , objAttr ) ; } else if ( objAttr === Consts . OBJECT_BUY ) { this . _execObjectBuyEvent ( pos , partsID , objAttr ) ; } else if ( objAttr === Consts . OBJECT_SELL ) { this . _execObjectSellEvent ( pos , partsID , objAttr ) ; } else if ( objAttr === Consts . OBJECT_URLGATE ) { this . _execObjectUrlGateEvent ( pos , partsID , objAttr ) ; } else if ( objAttr === Consts . OBJECT_SCORE ) { this . _execObjectScoreEvent ( pos , partsID , objAttr ) ; } else if ( objAttr === Consts . OBJECT_SELECT ) { this . _execObjectYesNoChoiceEvent ( pos , partsID , objAttr ) ; } else if ( objAttr === Consts . OBJECT_LOCALGATE ) { this . _execObjectLocalGateEvent ( pos , partsID , objAttr ) ; } if ( isPlayerPositionExec && ! this . _player . isJumped ( ) ) { this . _player . setLastExecInfoOnSamePosition ( PartsType . OBJECT , partsID ) ; } } private _execMapStreetEvent ( pos , partsID , mapAttr ) { var itemID = this . _wwaData . mapAttribute [ partsID ] [ Consts . ATR_ITEM ] ; if ( itemID !== 0 && ! this . _player . hasItem ( itemID ) ) { return false ; } this . appearParts ( pos , AppearanceTriggerType . MAP ) ; var messageID = this . _wwaData . mapAttribute [ partsID ] [ Consts . ATR_STRING ] ; var message = this . _wwaData . message [ messageID ] ; this . _waitFrame += this . _wwaData . mapAttribute [ partsID ] [ Consts . ATR_NUMBER ] * Consts . WAIT_TIME_FRAME_NUM ; this . _temporaryInputDisable = true ; var messageDisplayed = this . setMessageQueue ( message , false , false , partsID , PartsType . MAP , pos . clone ( ) ) ; this . playSound ( this . _wwaData . mapAttribute [ partsID ] [ Consts . ATR_SOUND ] ) ; return messageID !== 0 && messageDisplayed ; } private _execMapWallEvent ( pos , partsID , mapAttr ) { var objID = this . getObjectIdByPosition ( pos . convertIntoPosition ( this ) ) ; var objType = this . getObjectAttributeById ( objID , Consts . ATR_TYPE ) ; if ( objID === 0 || objType === Consts . OBJECT_NORMAL || objType === Consts . OBJECT_DOOR && ( ! this . _player . hasItem ( this . getObjectAttributeById ( objID , Consts . ATR_ITEM ) ) || this . getObjectAttributeById ( objType , Consts . ATR_MODE ) === Consts . PASSABLE_OBJECT ) ) { this . appearParts ( pos , AppearanceTriggerType . MAP ) ; var messageID = this . _wwaData . mapAttribute [ partsID ] [ Consts . ATR_STRING ] ; var message = this . _wwaData . message [ messageID ] ; this . setMessageQueue ( message , false , false , partsID , PartsType . MAP , pos . clone ( ) ) ; this . playSound ( this . _wwaData . mapAttribute [ partsID ] [ Consts . ATR_SOUND ] ) ; return false ; } return false ; } private _execMapLocalGateEvent ( pos , partsID , mapAttr ) { var playerPos = this . _player . getPosition ( ) . getPartsCoord ( ) ; var jx = this . _wwaData . mapAttribute [ partsID ] [ Consts . ATR_JUMP_X ] ; var jy = this . _wwaData . mapAttribute [ partsID ] [ Consts . ATR_JUMP_Y ] ; if ( jx > Consts . RELATIVE_COORD_LOWER ) { jx = pos . x + jx - Consts . RELATIVE_COORD_BIAS ; } if ( jy > Consts . RELATIVE_COORD_LOWER ) { jy = pos . y + jy - Consts . RELATIVE_COORD_BIAS ; } this . appearParts ( pos , AppearanceTriggerType . MAP ) ; if ( 0 <= jx && 0 <= jy && jx < this . _wwaData . mapWidth && jy < this . _wwaData . mapWidth && ( jx !== playerPos . x || jy !== playerPos . y ) ) { this . _player . jumpTo ( new Position ( this , jx , jy , 0 , 0 ) ) ; this . playSound ( this . _wwaData . mapAttribute [ partsID ] [ Consts . ATR_SOUND ] ) ; return true ; } return false ; } private _execMapUrlGateEvent ( pos , partsID , mapAttr ) { var messageID = this . _wwaData . mapAttribute [ partsID ] [ Consts . ATR_STRING ] ; if ( ! this . _isURLGateEnable ) { return true ; } if ( this . _wwaData . message [ SystemMessage1 . ASK_LINK ] === "BLANK" ) { location . href = util . $escapedURI ( this . _wwaData . message [ messageID ] . split ( /\s/g ) [ 0 ] ) ; return ; } this . setMessageQueue ( this . _wwaData . message [ SystemMessage1 . ASK_LINK ] === "" ? "他のページにリンクします。\nよろしいですか？" : this . _wwaData . message [ SystemMessage1 . ASK_LINK ] , true , true ) ; this . _yesNoChoicePartsCoord = pos ; this . _yesNoChoicePartsID = partsID ; this . _yesNoChoiceCallInfo = ChoiceCallInfo . CALL_BY_MAP_PARTS ; this . _yesNoURL = this . _wwaData . message [ messageID ] . split ( /\s/g ) [ 0 ] ; return true ; } private _execObjectNormalEvent ( pos , partsID , objAttr ) { } private _execObjectMessageEvent ( pos , partsID , objAttr ) { var messageID = this . _wwaData . objectAttribute [ partsID ] [ Consts . ATR_STRING ] ; var message = this . _wwaData . message [ messageID ] ; var playerPos = this . _player . getPosition ( ) . getPartsCoord ( ) ; var soundID = this . _wwaData . objectAttribute [ partsID ] [ Consts . ATR_SOUND ] ; if ( pos . x === playerPos . x && pos . y === playerPos . y && ! this . _wwaData . objectNoCollapseDefaultFlag ) { this . setPartsOnPosition ( PartsType . OBJECT , 0 , pos ) ; } this . setMessageQueue ( message , false , false , partsID , PartsType . OBJECT , pos ) ; this . _waitFrame += this . _wwaData . objectAttribute [ partsID ] [ Consts . ATR_NUMBER ] * Consts . WAIT_TIME_FRAME_NUM ; this . _temporaryInputDisable = true ; this . appearParts ( pos , AppearanceTriggerType . OBJECT , partsID ) ; this . playSound ( soundID ) ; } private _execObjectStatusEvent ( pos , partsID , objAttr ) { var status = new Status ( this . _wwaData . objectAttribute [ partsID ] [ Consts . ATR_ENERGY ] , this . _wwaData . objectAttribute [ partsID ] [ Consts . ATR_STRENGTH ] , this . _wwaData . objectAttribute [ partsID ] [ Consts . ATR_DEFENCE ] , this . _wwaData . objectAttribute [ partsID ] [ Consts . ATR_GOLD ] ) ; var messageID = this . _wwaData . objectAttribute [ partsID ] [ Consts . ATR_STRING ] ; var message = this . _wwaData . message [ messageID ] ; var pstatus = this . _player . getStatusWithoutEquipments ( ) ; if ( status . strength > Consts . STATUS_MINUS_BORDER && pstatus . strength < status . strength - Consts . STATUS_MINUS_BORDER || status . defence > Consts . STATUS_MINUS_BORDER && pstatus . defence < status . defence - Consts . STATUS_MINUS_BORDER || status . gold > Consts . STATUS_MINUS_BORDER && pstatus . gold < status . gold - Consts . STATUS_MINUS_BORDER ) { this . setPartsOnPosition ( PartsType . OBJECT , 0 , pos ) ; this . _keyStore . allClear ( ) ; this . _mouseStore . clear ( ) ; return ; } status . energy = status . energy > Consts . STATUS_MINUS_BORDER ? Consts . STATUS_MINUS_BORDER - status . energy : status . energy ; status . strength = status . strength > Consts . STATUS_MINUS_BORDER ? Consts . STATUS_MINUS_BORDER - status . strength : status . strength ; status . defence = status . defence > Consts . STATUS_MINUS_BORDER ? Consts . STATUS_MINUS_BORDER - status . defence : status . defence ; status . gold = status . gold > Consts . STATUS_MINUS_BORDER ? Consts . STATUS_MINUS_BORDER - status . gold : status . gold ; this . _player . addStatusAll ( status ) ; this . setStatusChangedEffect ( status ) ; if ( this . _player . isDead ( ) && this . _wwaData . objectAttribute [ partsID ] [ Consts . ATR_ENERGY ] !== 0 ) { this . gameover ( ) ; return ; } this . setMessageQueue ( message , false , false , partsID , PartsType . OBJECT , pos . clone ( ) ) ; this . setPartsOnPosition ( PartsType . OBJECT , 0 , pos ) ; this . appearParts ( pos , AppearanceTriggerType . OBJECT , partsID ) ; this . playSound ( this . _wwaData . objectAttribute [ partsID ] [ Consts . ATR_SOUND ] ) ; } private _execObjectMonsterEvent ( pos , partsID , objAttr ) { var monsterImgCoord = new Coord ( this . _wwaData . objectAttribute [ partsID ] [ Consts . ATR_X ] , this . _wwaData . objectAttribute [ partsID ] [ Consts . ATR_Y ] ) ; var monsterStatus = new Status ( this . _wwaData . objectAttribute [ partsID ] [ Consts . ATR_ENERGY ] , this . _wwaData . objectAttribute [ partsID ] [ Consts . ATR_STRENGTH ] , this . _wwaData . objectAttribute [ partsID ] [ Consts . ATR_DEFENCE ] , this . _wwaData . objectAttribute [ partsID ] [ Consts . ATR_GOLD ] ) ; var monsterMessage = this . _wwaData . message [ this . _wwaData . objectAttribute [ partsID ] [ Consts . ATR_STRING ] ] ; var monsterItemID = this . _wwaData . objectAttribute [ partsID ] [ Consts . ATR_ITEM ] ; this . _monster = new Monster ( partsID , pos , monsterImgCoord , monsterStatus , monsterMessage , monsterItemID , ( ) => { this . _monsterWindow . hide ( ) ; } ) ; this . _player . startBattleWith ( this . _monster ) ; } private _execObjectBuyEvent ( pos , partsID , objAttr ) { var messageID = this . _wwaData . objectAttribute [ partsID ] [ Consts . ATR_STRING ] ; var message = this . _wwaData . message [ messageID ] ; var playerPos = this . _player . getPosition ( ) . getPartsCoord ( ) ; if ( pos . x === playerPos . x && pos . y === playerPos . y && ! this . _wwaData . objectNoCollapseDefaultFlag ) { this . setPartsOnPosition ( PartsType . OBJECT , 0 , pos ) ; } this . setMessageQueue ( message , true , false , partsID , PartsType . OBJECT , pos . clone ( ) ) ; this . _yesNoChoicePartsCoord = pos ; this . _yesNoChoicePartsID = partsID ; this . _yesNoChoiceCallInfo = ChoiceCallInfo . CALL_BY_OBJECT_PARTS ; this . playSound ( this . _wwaData . objectAttribute [ partsID ] [ Consts . ATR_SOUND ] ) ; } private _execObjectSellEvent ( pos , partsID , objAttr ) { var messageID = this . _wwaData . objectAttribute [ partsID ] [ Consts . ATR_STRING ] ; var message = this . _wwaData . message [ messageID ] ; var playerPos = this . _player . getPosition ( ) . getPartsCoord ( ) ; if ( pos . x === playerPos . x && pos . y === playerPos . y && ! this . _wwaData . objectNoCollapseDefaultFlag ) { this . setPartsOnPosition ( PartsType . OBJECT , 0 , pos ) ; } this . setMessageQueue ( message , true , false , partsID , PartsType . OBJECT , pos . clone ( ) ) ; this . _yesNoChoicePartsCoord = pos ; this . _yesNoChoicePartsID = partsID ; this . _yesNoChoiceCallInfo = ChoiceCallInfo . CALL_BY_OBJECT_PARTS ; this . playSound ( this . _wwaData . objectAttribute [ partsID ] [ Consts . ATR_SOUND ] ) ; } private _execObjectItemEvent ( pos , partsID , objAttr ) { var messageID = this . _wwaData . objectAttribute [ partsID ] [ Consts . ATR_STRING ] ; var message = this . _wwaData . message [ messageID ] ; try { var screenTopCoord = this . _camera . getPosition ( ) . getScreenTopPosition ( ) . getPartsCoord ( ) ; var screenXPixel = ( pos . x - screenTopCoord . x ) * Consts . CHIP_SIZE ; var screenYPixel = ( pos . y - screenTopCoord . y ) * Consts . CHIP_SIZE ; this . _player . addItem ( partsID , this . _wwaData . objectAttribute [ partsID ] [ Consts . ATR_NUMBER ] , false , this . _wwaData . isItemEffectEnabled ? { screenPixelCoord : new Coord ( screenXPixel , screenYPixel ) , itemBoxBackgroundImageCoord : new Coord ( this . _wwaData . imgItemboxX * Consts . CHIP_SIZE , this . _wwaData . imgItemboxY * Consts . CHIP_SIZE ) } : undefined ) ; this . setPartsOnPosition ( PartsType . OBJECT , 0 , pos ) ; if ( this . _wwaData . objectAttribute [ partsID ] [ Consts . ATR_MODE ] !== 0 ) { } else { this . setMessageQueue ( message , false , false , partsID , PartsType . OBJECT , pos . clone ( ) ) ; this . appearParts ( pos , AppearanceTriggerType . OBJECT , partsID ) ; } } catch ( e ) { if ( this . _wwaData . systemMessage [ SystemMessage2 . FULL_ITEM ] !== "BLANK" ) { this . setMessageQueue ( this . _wwaData . systemMessage [ SystemMessage2 . FULL_ITEM ] === "" ? "これ以上、アイテムを持てません。" : this . _wwaData . systemMessage [ SystemMessage2 . FULL_ITEM ] , false , true ) ; } } this . playSound ( this . _wwaData . objectAttribute [ partsID ] [ Consts . ATR_SOUND ] ) ; } private _execObjectDoorEvent ( pos , partsID , objAttr ) { var itemID = this . _wwaData . objectAttribute [ partsID ] [ Consts . ATR_ITEM ] ; var messageID = this . _wwaData . objectAttribute [ partsID ] [ Consts . ATR_STRING ] ; var message = this . _wwaData . message [ messageID ] ; if ( this . _player . hasItem ( itemID ) ) { if ( this . _wwaData . objectAttribute [ partsID ] [ Consts . ATR_MODE ] === 0 ) { this . _player . removeItemByPartsID ( itemID ) ; } this . playSound ( this . _wwaData . objectAttribute [ partsID ] [ Consts . ATR_SOUND ] ) ; this . setMessageQueue ( message , false , false , partsID , PartsType . OBJECT , pos . clone ( ) ) ; this . setPartsOnPosition ( PartsType . OBJECT , 0 , pos ) ; this . appearParts ( pos , AppearanceTriggerType . OBJECT , partsID ) ; this . _paintSkipByDoorOpen = true ; } } private _execObjectYesNoChoiceEvent ( pos , partsID , objAttr ) { var messageID = this . _wwaData . objectAttribute [ partsID ] [ Consts . ATR_STRING ] ; var message = this . _wwaData . message [ messageID ] ; var playerPos = this . _player . getPosition ( ) . getPartsCoord ( ) ; if ( pos . x === playerPos . x && pos . y === playerPos . y && ! this . _wwaData . objectNoCollapseDefaultFlag ) { this . setPartsOnPosition ( PartsType . OBJECT , 0 , pos ) ; } this . setMessageQueue ( message , true , false , partsID , PartsType . OBJECT , pos . clone ( ) ) ; this . _yesNoChoicePartsCoord = pos ; this . _yesNoChoicePartsID = partsID ; this . _yesNoChoiceCallInfo = ChoiceCallInfo . CALL_BY_OBJECT_PARTS ; this . playSound ( this . _wwaData . objectAttribute [ partsID ] [ Consts . ATR_SOUND ] ) ; } private _execObjectLocalGateEvent ( pos , partsID , mapAttr ) { var playerPos = this . _player . getPosition ( ) . getPartsCoord ( ) ; if ( pos . x === playerPos . x && pos . y === playerPos . y && ! this . _wwaData . objectNoCollapseDefaultFlag ) { this . setPartsOnPosition ( PartsType . OBJECT , 0 , pos ) ; } var jx = this . _wwaData . objectAttribute [ partsID ] [ Consts . ATR_JUMP_X ] ; var jy = this . _wwaData . objectAttribute [ partsID ] [ Consts . ATR_JUMP_Y ] ; if ( jx > Consts . RELATIVE_COORD_LOWER ) { jx = playerPos . x + jx - Consts . RELATIVE_COORD_BIAS ; } if ( jy > Consts . RELATIVE_COORD_LOWER ) { jy = playerPos . y + jy - Consts . RELATIVE_COORD_BIAS ; } this . appearParts ( pos , AppearanceTriggerType . OBJECT , partsID ) ; if ( 0 <= jx && 0 <= jy && jx < this . _wwaData . mapWidth && jy < this . _wwaData . mapWidth && ( jx !== playerPos . x || jy !== playerPos . y ) ) { this . _player . jumpTo ( new Position ( this , jx , jy , 0 , 0 ) ) ; this . playSound ( this . _wwaData . objectAttribute [ partsID ] [ Consts . ATR_SOUND ] ) ; } } private _execObjectUrlGateEvent ( pos , partsID , mapAttr ) { var messageID = this . _wwaData . objectAttribute [ partsID ] [ Consts . ATR_STRING ] ; if ( ! this . _isURLGateEnable ) { return ; } if ( this . _wwaData . message [ SystemMessage1 . ASK_LINK ] === "BLANK" ) { location . href = util . $escapedURI ( this . _wwaData . message [ messageID ] . split ( /\s/g ) [ 0 ] ) ; return ; } this . setMessageQueue ( this . _wwaData . message [ SystemMessage1 . ASK_LINK ] === "" ? "他のページにリンクします。\nよろしいですか？" : this . _wwaData . message [ SystemMessage1 . ASK_LINK ] , true , true ) ; this . _yesNoChoicePartsCoord = pos ; this . _yesNoChoicePartsID = partsID ; this . _yesNoChoiceCallInfo = ChoiceCallInfo . CALL_BY_OBJECT_PARTS ; this . _yesNoURL = this . _wwaData . message [ messageID ] . split ( /\s/g ) [ 0 ] ; } param pos param partsID param mapAttr private _execObjectScoreEvent ( pos , partsID , mapAttr ) { var messageID = this . _wwaData . objectAttribute [ partsID ] [ Consts . ATR_STRING ] ; const rawMessage = messageID === 0 ? "スコアを表示します。" : this . _wwaData . message [ messageID ] ; const messageQueue = this . getMessageQueueByRawMessage ( rawMessage , partsID , PartsType . OBJECT , pos ) ; const existsMessage = messageQueue . reduce ( ( existsMessageBefore , messageInfo ) => existsMessageBefore || ! messageInfo . isEmpty ( ) , false ) ; if ( existsMessage ) { this . _scoreRates = { energy : this . _wwaData . objectAttribute [ partsID ] [ Consts . ATR_ENERGY ] , strength : this . _wwaData . objectAttribute [ partsID ] [ Consts . ATR_STRENGTH ] , defence : this . _wwaData . objectAttribute [ partsID ] [ Consts . ATR_DEFENCE ] , gold : this . _wwaData . objectAttribute [ partsID ] [ Consts . ATR_GOLD ] } ; this . updateScore ( ) ; this . _scoreWindow . show ( ) ; } this . setMessageQueue ( rawMessage , false , false , partsID , PartsType . OBJECT , pos ) ; this . playSound ( this . _wwaData . objectAttribute [ partsID ] [ Consts . ATR_SOUND ] ) ; } public updateScore ( ) { if ( ! this . _scoreRates ) { return ; } const score = this . _player . getStatus ( ) . calculateScore ( this . _scoreRates ) ; this . _scoreWindow . update ( score ) ; } private _execChoiceWindowRunningEvent ( ) { var partsType ; var gold ; if ( -- this . _yesNoDispCounter === 0 ) { if ( this . _yesNoJudge === YesNoState . YES ) { if ( this . _yesNoChoiceCallInfo === ChoiceCallInfo . CALL_BY_MAP_PARTS ) { partsType = this . _wwaData . mapAttribute [ this . _yesNoChoicePartsID ] [ Consts . ATR_TYPE ] ; if ( partsType === Consts . MAP_URLGATE ) { location . href = util . $escapedURI ( this . _yesNoURL ) ; } } else if ( this . _yesNoChoiceCallInfo === ChoiceCallInfo . CALL_BY_OBJECT_PARTS ) { partsType = this . _wwaData . objectAttribute [ this . _yesNoChoicePartsID ] [ Consts . ATR_TYPE ] ; if ( partsType === Consts . OBJECT_BUY ) { if ( this . _player . hasItem ( this . _wwaData . objectAttribute [ this . _yesNoChoicePartsID ] [ Consts . ATR_ITEM ] ) ) { this . _player . removeItemByPartsID ( this . _wwaData . objectAttribute [ this . _yesNoChoicePartsID ] [ Consts . ATR_ITEM ] ) ; gold = this . _wwaData . objectAttribute [ this . _yesNoChoicePartsID ] [ Consts . ATR_GOLD ] ; this . _player . earnGold ( gold ) ; this . setStatusChangedEffect ( new Status ( 0 , 0 , 0 , gold ) ) ; this . appearParts ( this . _yesNoChoicePartsCoord , AppearanceTriggerType . OBJECT , this . _yesNoChoicePartsID ) ; } else { if ( this . _wwaData . message [ SystemMessage1 . NO_ITEM ] !== "BLANK" ) { this . _messageQueue . push ( new ParsedMessage ( this . _wwaData . message [ SystemMessage1 . NO_ITEM ] === "" ? "アイテムを持っていない。" : this . _wwaData . message [ SystemMessage1 . NO_ITEM ] , true ) ) ; } ; } } else if ( partsType === Consts . OBJECT_SELL ) { if ( this . _player . hasGold ( this . _wwaData . objectAttribute [ this . _yesNoChoicePartsID ] [ Consts . ATR_GOLD ] ) ) { if ( this . _player . canHaveMoreItems ( ) || this . _wwaData . objectAttribute [ this . _yesNoChoicePartsID ] [ Consts . ATR_ITEM ] === 0 ) { if ( this . _wwaData . objectAttribute [ this . _yesNoChoicePartsID ] [ Consts . ATR_ITEM ] !== 0 ) { var pos = this . _yesNoChoicePartsCoord ; var screenTopCoord = this . _camera . getPosition ( ) . getScreenTopPosition ( ) . getPartsCoord ( ) ; var screenXPixel = ( pos . x - screenTopCoord . x ) * Consts . CHIP_SIZE ; var screenYPixel = ( pos . y - screenTopCoord . y ) * Consts . CHIP_SIZE ; this . _player . addItem ( this . _wwaData . objectAttribute [ this . _yesNoChoicePartsID ] [ Consts . ATR_ITEM ] , 0 , false , this . _wwaData . isItemEffectEnabled ? { screenPixelCoord : new Coord ( screenXPixel , screenYPixel ) , itemBoxBackgroundImageCoord : new Coord ( this . _wwaData . imgItemboxX * Consts . CHIP_SIZE , this . _wwaData . imgItemboxY * Consts . CHIP_SIZE ) } : undefined ) ; } var status = new Status ( this . _wwaData . objectAttribute [ this . _yesNoChoicePartsID ] [ Consts . ATR_ENERGY ] , this . _wwaData . objectAttribute [ this . _yesNoChoicePartsID ] [ Consts . ATR_STRENGTH ] , this . _wwaData . objectAttribute [ this . _yesNoChoicePartsID ] [ Consts . ATR_DEFENCE ] , - this . _wwaData . objectAttribute [ this . _yesNoChoicePartsID ] [ Consts . ATR_GOLD ] ) ; var pstatus = this . _player . getStatusWithoutEquipments ( ) ; status . energy = status . energy > Consts . STATUS_MINUS_BORDER ? Consts . STATUS_MINUS_BORDER - status . energy : status . energy ; this . setStatusChangedEffect ( status ) ; this . _player . addStatusAll ( status ) ; if ( this . _player . isDead ( ) && this . _wwaData . objectAttribute [ this . _yesNoChoicePartsID ] [ Consts . ATR_ENERGY ] !== 0 ) { this . gameover ( ) ; return ; } this . appearParts ( this . _yesNoChoicePartsCoord , AppearanceTriggerType . OBJECT , this . _yesNoChoicePartsID ) ; } else { if ( this . _wwaData . systemMessage [ SystemMessage2 . FULL_ITEM ] !== "BLANK" ) { this . _messageQueue . push ( new ParsedMessage ( this . _wwaData . systemMessage [ SystemMessage2 . FULL_ITEM ] === "" ? "これ以上、アイテムを持てません。" : this . _wwaData . systemMessage [ SystemMessage2 . FULL_ITEM ] , true ) ) ; } } } else { if ( this . _wwaData . message [ SystemMessage1 . NO_MONEY ] !== "BLANK" ) { this . _messageQueue . push ( new ParsedMessage ( this . _wwaData . message [ SystemMessage1 . NO_MONEY ] === "" ? "所持金がたりない。" : this . _wwaData . message [ SystemMessage1 . NO_MONEY ] , true ) ) ; } } } else if ( partsType === Consts . OBJECT_SELECT ) { this . appearParts ( this . _yesNoChoicePartsCoord , AppearanceTriggerType . CHOICE_YES , this . _yesNoChoicePartsID ) ; } else if ( partsType === Consts . OBJECT_URLGATE ) { location . href = util . $escapedURI ( this . _yesNoURL ) ; } } else if ( this . _yesNoChoiceCallInfo === ChoiceCallInfo . CALL_BY_ITEM_USE ) { this . _player . readyToUseItem ( this . _yesNoUseItemPos ) ; } else if ( ( this . _yesNoChoiceCallInfo === ChoiceCallInfo . CALL_BY_QUICK_LOAD ) || ( this . _yesNoChoiceCallInfo === ChoiceCallInfo . CALL_BY_LOG_QUICK_LOAD ) ) { this . _messageWindow . deleteSaveDom ( ) ; ( < HTMLDivElement > ( util . $id ( sidebarButtonCellElementID [ SidebarButton . QUICK_LOAD ] ) ) ) . classList . remove ( "onpress" ) ; if ( this . _messageWindow . load ( ) ) { this . _stopUpdateByLoadFlag = true ; this . _loadType = LoadType . QUICK_LOAD ; } } else if ( this . _yesNoChoiceCallInfo === ChoiceCallInfo . CALL_BY_QUICK_SAVE ) { this . _messageWindow . deleteSaveDom ( ) ; ( < HTMLDivElement > ( util . $id ( sidebarButtonCellElementID [ SidebarButton . QUICK_SAVE ] ) ) ) . classList . remove ( "onpress" ) ; this . _quickSave ( ChoiceCallInfo . CALL_BY_QUICK_SAVE ) ; } else if ( this . _yesNoChoiceCallInfo === ChoiceCallInfo . CALL_BY_RESTART_GAME ) { ( < HTMLDivElement > ( util . $id ( sidebarButtonCellElementID [ SidebarButton . RESTART_GAME ] ) ) ) . classList . remove ( "onpress" ) ; this . _stopUpdateByLoadFlag = true ; this . _loadType = LoadType . RESTART_GAME ; } else if ( this . _yesNoChoiceCallInfo === ChoiceCallInfo . CALL_BY_END_GAME ) { window . history . back ( - 1 ) ; ( < HTMLDivElement > ( util . $id ( sidebarButtonCellElementID [ SidebarButton . GOTO_WWA ] ) ) ) . classList . remove ( "onpress" ) ; } else if ( this . _yesNoChoiceCallInfo === ChoiceCallInfo . CALL_BY_GOTO_WWA ) { location . href = util . $escapedURI ( Consts . WWA_HOME ) ; ( < HTMLDivElement > ( util . $id ( sidebarButtonCellElementID [ SidebarButton . GOTO_WWA ] ) ) ) . classList . remove ( "onpress" ) ; } else if ( this . _yesNoChoiceCallInfo === ChoiceCallInfo . CALL_BY_PASSWORD_LOAD ) { ( < HTMLDivElement > ( util . $id ( sidebarButtonCellElementID [ SidebarButton . QUICK_LOAD ] ) ) ) . classList . remove ( "onpress" ) ; this . _player . setPasswordWindowWating ( ) ; this . _passwordWindow . show ( Mode . LOAD ) ; } else if ( this . _yesNoChoiceCallInfo === ChoiceCallInfo . CALL_BY_PASSWORD_SAVE ) { ( < HTMLDivElement > ( util . $id ( sidebarButtonCellElementID [ SidebarButton . QUICK_SAVE ] ) ) ) . classList . remove ( "onpress" ) ; this . _player . setPasswordWindowWating ( ) ; this . _passwordWindow . password = this . _quickSave ( ChoiceCallInfo . CALL_BY_PASSWORD_SAVE ) ; this . _passwordWindow . show ( Mode . SAVE ) ; } else if ( this . _yesNoChoiceCallInfo === ChoiceCallInfo . CALL_BY_SUSPEND ) { ( < HTMLDivElement > ( util . $id ( sidebarButtonCellElementID [ SidebarButton . QUICK_SAVE ] ) ) ) . classList . remove ( "onpress" ) ; this . _quickSave ( ChoiceCallInfo . CALL_BY_SUSPEND ) ; } this . _yesNoJudge = YesNoState . UNSELECTED ; this . _setNextMessage ( ) ; this . _yesNoChoicePartsCoord = void 0 ; this . _yesNoChoicePartsID = void 0 ; this . _yesNoUseItemPos = void 0 ; this . _yesNoChoiceCallInfo = ChoiceCallInfo . NONE ; this . _messageWindow . setYesNoChoice ( false ) ; } else if ( this . _yesNoJudge === YesNoState . NO ) { if ( this . _yesNoChoiceCallInfo === ChoiceCallInfo . CALL_BY_MAP_PARTS ) { partsType = this . _wwaData . mapAttribute [ this . _yesNoChoicePartsID ] [ Consts . ATR_TYPE ] ; if ( partsType === Consts . MAP_URLGATE ) { } } else if ( this . _yesNoChoiceCallInfo === ChoiceCallInfo . CALL_BY_OBJECT_PARTS ) { partsType = this . _wwaData . objectAttribute [ this . _yesNoChoicePartsID ] [ Consts . ATR_TYPE ] ; if ( partsType === Consts . OBJECT_BUY ) { } else if ( partsType === Consts . OBJECT_SELL ) { } else if ( partsType === Consts . OBJECT_SELECT ) { this . appearParts ( this . _yesNoChoicePartsCoord , AppearanceTriggerType . CHOICE_NO , this . _yesNoChoicePartsID ) ; } else if ( partsType === Consts . OBJECT_URLGATE ) { } } else if ( this . _yesNoChoiceCallInfo === ChoiceCallInfo . CALL_BY_ITEM_USE ) { var bg = < HTMLDivElement > ( util . $id ( "item" + ( this . _yesNoUseItemPos - 1 ) ) ) ; bg . classList . remove ( "onpress" ) ; } else if ( ( this . _yesNoChoiceCallInfo === ChoiceCallInfo . CALL_BY_QUICK_LOAD ) || ( this . _yesNoChoiceCallInfo === ChoiceCallInfo . CALL_BY_LOG_QUICK_LOAD ) ) { this . _messageWindow . deleteSaveDom ( ) ; this . _yesNoChoiceCallInfo = this . _wwaSave . getSecondSaveChoiceCallInfo ( this . _usePassword ) ; switch ( this . _yesNoChoiceCallInfo ) { case ChoiceCallInfo . NONE : ( < HTMLDivElement > ( util . $id ( sidebarButtonCellElementID [ SidebarButton . QUICK_LOAD ] ) ) ) . classList . remove ( "onpress" ) ; break ; case ChoiceCallInfo . CALL_BY_PASSWORD_LOAD : this . _yesNoJudge = YesNoState . UNSELECTED ; this . onpasswordloadcalled ( ) ; return ; case ChoiceCallInfo . CALL_BY_LOG_QUICK_LOAD : this . _wwaSave . selectLogSaveDataList ( ) ; this . _messageWindow . createSaveDom ( ) ; var secondCallInfo = this . _wwaSave . getSecondSaveChoiceCallInfo ( this . _usePassword ) ; this . _yesNoJudge = YesNoState . UNSELECTED ; switch ( secondCallInfo ) { case ChoiceCallInfo . CALL_BY_PASSWORD_LOAD : this . setMessageQueue ( "読み込むオートセーブを選んでください。\n→Ｎｏでデータ復帰用パスワードの\n　入力選択ができます。" , true , true ) ; break ; case ChoiceCallInfo . NONE : this . setMessageQueue ( "読み込むオートセーブを選んでください。" , true , true ) ; break ; } return ; } } else if ( this . _yesNoChoiceCallInfo === ChoiceCallInfo . CALL_BY_QUICK_SAVE ) { this . _messageWindow . deleteSaveDom ( ) ; if ( ( this . _usePassword ) || ( this . _useSuspend ) ) { this . _yesNoJudge = YesNoState . UNSELECTED ; if ( this . _useSuspend ) { this . onpasssuspendsavecalled ( ) ; } else if ( this . _usePassword ) { this . onpasswordsavecalled ( ) ; } return ; } else { ( < HTMLDivElement > ( util . $id ( sidebarButtonCellElementID [ SidebarButton . QUICK_SAVE ] ) ) ) . classList . remove ( "onpress" ) ; } } else if ( this . _yesNoChoiceCallInfo === ChoiceCallInfo . CALL_BY_RESTART_GAME ) { ( < HTMLDivElement > ( util . $id ( sidebarButtonCellElementID [ SidebarButton . RESTART_GAME ] ) ) ) . classList . remove ( "onpress" ) ; } else if ( this . _yesNoChoiceCallInfo === ChoiceCallInfo . CALL_BY_END_GAME ) { ( < HTMLDivElement > ( util . $id ( sidebarButtonCellElementID [ SidebarButton . GOTO_WWA ] ) ) ) . classList . remove ( "onpress" ) ; } else if ( this . _yesNoChoiceCallInfo === ChoiceCallInfo . CALL_BY_GOTO_WWA ) { ( < HTMLDivElement > ( util . $id ( sidebarButtonCellElementID [ SidebarButton . GOTO_WWA ] ) ) ) . classList . remove ( "onpress" ) ; } else if ( this . _yesNoChoiceCallInfo === ChoiceCallInfo . CALL_BY_PASSWORD_LOAD ) { ( < HTMLDivElement > ( util . $id ( sidebarButtonCellElementID [ SidebarButton . QUICK_LOAD ] ) ) ) . classList . remove ( "onpress" ) ; } else if ( this . _yesNoChoiceCallInfo === ChoiceCallInfo . CALL_BY_PASSWORD_SAVE ) { ( < HTMLDivElement > ( util . $id ( sidebarButtonCellElementID [ SidebarButton . QUICK_SAVE ] ) ) ) . classList . remove ( "onpress" ) ; } else if ( this . _yesNoChoiceCallInfo === ChoiceCallInfo . CALL_BY_SUSPEND ) { if ( this . _usePassword ) { this . _yesNoJudge = YesNoState . UNSELECTED ; this . onpasswordsavecalled ( ) ; return ; } else { ( < HTMLDivElement > ( util . $id ( sidebarButtonCellElementID [ SidebarButton . QUICK_SAVE ] ) ) ) . classList . remove ( "onpress" ) ; } } this . _yesNoJudge = YesNoState . UNSELECTED ; this . _setNextMessage ( ) ; this . _yesNoChoicePartsCoord = void 0 ; this . _yesNoChoicePartsID = void 0 ; this . _yesNoUseItemPos = void 0 ; this . _yesNoChoiceCallInfo = ChoiceCallInfo . NONE ; this . _messageWindow . setYesNoChoice ( false ) ; } } } public setMessageQueue ( message , showChoice , isSystemMessage , partsID = 0 , partsType = PartsType . OBJECT , partsPosition = new Coord ( 0 , 0 ) , messageDisplayed = false ) { this . _messageQueue = this . _messageQueue . concat ( this . getMessageQueueByRawMessage ( message , partsID , partsType , partsPosition ) ) ; if ( this . _lastMessage . isEndOfPartsEvent && this . _reservedMoveMacroTurn !== void 0 ) { this . _player . setMoveMacroWaiting ( this . _reservedMoveMacroTurn ) ; this . _reservedMoveMacroTurn = void 0 ; } if ( this . _messageQueue . length !== 0 ) { var topmes = this . _messageQueue . shift ( ) ; for ( var i = 0 ; i < topmes . macro . length ; i ++ ) { this . _execMacroListInNextFrame . push ( topmes . macro [ i ] ) ; } this . _lastMessage = topmes ; if ( ! topmes . isEmpty ( ) ) { this . _messageWindow . setParsedMessage ( topmes ) ; this . _messageWindow . setYesNoChoice ( showChoice ) ; this . _messageWindow . setPositionByPlayerPosition ( this . _faces . length !== 0 , this . _scoreWindow . isVisible ( ) , isSystemMessage , this . _player . getPosition ( ) , this . _camera . getPosition ( ) ) ; this . _player . setMessageWaiting ( ) ; return true ; } else { if ( this . _messageQueue . length === 0 ) { this . _hideMessageWindow ( messageDisplayed ) ; } else { this . _setNextMessage ( ) ; } } } return false ; } public getMessageQueueByRawMessage ( message , partsID , partsType , partsPosition , isSystemMessage = false ) { var messageMain = message . split ( /\n\<c\>/i ) [ 0 ] . split ( /\<c\>/i ) [ 0 ] . replace ( /\n\<p\>\n/ig , "<P>" ) . replace ( /\n\<p\>/ig , "<P>" ) . replace ( /\<p\>\n/ig , "<P>" ) . replace ( /\<p\>/ig , "<P>" ) ; var messageQueue = [ ] ; if ( messageMain !== "" ) { var rawQueue = messageMain . split ( /\<p\>/ig ) ; for ( var j = 0 ; j < rawQueue . length ; j ++ ) { var lines = rawQueue [ j ] . split ( "\n" ) ; var linesWithoutMacro = [ ] ; var macroQueue = [ ] ; for ( var i = 0 ; i < lines . length ; i ++ ) { var matchInfo = lines [ i ] . match ( /(\$(?:[a-zA-Z_][a-zA-Z0-9_]*)\=(?:.*))/ ) ; if ( matchInfo !== null && matchInfo . length >= 2 ) { var macro = parseMacro ( this , partsID , partsType , partsPosition , matchInfo [ 1 ] ) ; if ( macro . macroType === MacroType . SHOW_STR ) { linesWithoutMacro . push ( this . _generateUserValString ( macro . macroArgs ) ) ; } else { macroQueue . push ( macro ) ; } } else if ( ! lines [ i ] . match ( /^\$/ ) ) { linesWithoutMacro . push ( [ lines [ i ] ] ) ; } } const messageArray = linesWithoutMacro . reduce ( ( acc , line , index ) => { const newLine = index === 0 ? [ ] : [ "\n" ] ; return [ ... acc , ... newLine , ... line ] ; } , [ ] ) ; messageQueue . push ( new ParsedMessage ( messageArray , isSystemMessage , j === rawQueue . length - 1 , macroQueue ) ) ; } } return messageQueue ; } public appearParts ( pos , triggerType , triggerPartsID = 0 ) { var triggerPartsType ; var rangeMin = ( triggerType === AppearanceTriggerType . CHOICE_NO ) ? Consts . APPERANCE_PARTS_MIN_INDEX_NO : Consts . APPERANCE_PARTS_MIN_INDEX ; var rangeMax = ( triggerType === AppearanceTriggerType . CHOICE_YES ) ? Consts . APPERANCE_PARTS_MAX_INDEX_YES : Consts . APPERANCE_PARTS_MAX_INDEX ; var targetPartsID ; var targetPartsType ; var targetX ; var targetY ; var targetPos ; var i ; if ( triggerType === AppearanceTriggerType . MAP ) { triggerPartsID = ( triggerPartsID === 0 ) ? this . _wwaData . map [ pos . y ] [ pos . x ] : triggerPartsID ; triggerPartsType = PartsType . MAP ; } else { triggerPartsID = ( triggerPartsID === 0 ) ? this . _wwaData . mapObject [ pos . y ] [ pos . x ] : triggerPartsID ; triggerPartsType = PartsType . OBJECT ; } for ( i = rangeMin ; i <= rangeMax ; i ++ ) { var base = Consts . ATR_APPERANCE_BASE + i * Consts . REL_ATR_APPERANCE_UNIT_LENGTH ; var idxID = base + Consts . REL_ATR_APPERANCE_ID ; var idxX = base + Consts . REL_ATR_APPERANCE_X ; var idxY = base + Consts . REL_ATR_APPERANCE_Y ; var idxType = base + Consts . REL_ATR_APPERANCE_TYPE ; targetPartsID = ( triggerPartsType === PartsType . MAP ) ? this . _wwaData . mapAttribute [ triggerPartsID ] [ idxID ] : this . _wwaData . objectAttribute [ triggerPartsID ] [ idxID ] ; targetPartsType = ( triggerPartsType === PartsType . MAP ) ? this . _wwaData . mapAttribute [ triggerPartsID ] [ idxType ] : this . _wwaData . objectAttribute [ triggerPartsID ] [ idxType ] ; targetX = ( triggerPartsType === PartsType . MAP ) ? this . _wwaData . mapAttribute [ triggerPartsID ] [ idxX ] : this . _wwaData . objectAttribute [ triggerPartsID ] [ idxX ] ; targetY = ( triggerPartsType === PartsType . MAP ) ? this . _wwaData . mapAttribute [ triggerPartsID ] [ idxY ] : this . _wwaData . objectAttribute [ triggerPartsID ] [ idxY ] ; if ( targetX === Consts . PLAYER_COORD ) { targetX = this . _player . getPosition ( ) . getPartsCoord ( ) . x ; this . _player . resetEventExecutionInfo ( ) ; } else if ( targetX > Consts . RELATIVE_COORD_LOWER ) { targetX = pos . x + targetX - Consts . RELATIVE_COORD_BIAS ; } if ( targetY === Consts . PLAYER_COORD ) { targetY = this . _player . getPosition ( ) . getPartsCoord ( ) . y ; this . _player . resetEventExecutionInfo ( ) ; } else if ( targetY > Consts . RELATIVE_COORD_LOWER ) { targetY = pos . y + targetY - Consts . RELATIVE_COORD_BIAS ; } if ( targetX === 0 && targetY === 0 ) { continue ; } try { targetPos = new Position ( this , targetX , targetY , 0 , 0 ) ; if ( targetPartsType === PartsType . MAP ) { if ( targetPartsID >= this . _wwaData . mapPartsMax ) { throw new Error ( "背景パーツの範囲外IDが指定されました" ) ; } var cand = new Coord ( targetX , targetY ) ; this . setPartsOnPosition ( PartsType . MAP , targetPartsID , cand ) ; } else { if ( targetPartsID >= this . _wwaData . objPartsMax ) { throw new Error ( "物体パーツの範囲外IDが指定されました" ) ; } var cand = new Coord ( targetX , targetY ) ; this . setPartsOnPosition ( PartsType . OBJECT , targetPartsID , cand ) ; this . _replaceRandomObject ( new Coord ( targetX , targetY ) ) ; if ( targetX === this . _player . getPosition ( ) . getPartsCoord ( ) . x && targetY === this . _player . getPosition ( ) . getPartsCoord ( ) . y ) { this . _player . setPartsAppearedFlag ( ) ; } } } catch ( e ) { } } } public appearPartsByDirection ( distance , targetPartsID , targetPartsType ) { var ppos = this . _player . getPosition ( ) . getPartsCoord ( ) ; var pdir = this . _player . getDir ( ) ; var signX = vx [ pdir ] ; var signY = vy [ pdir ] ; this . appearPartsEval ( ppos , ( signX >= 0 ? "+" : "-" ) + ( Math . abs ( signX ) * distance ) , ( signY >= 0 ? "+" : "-" ) + ( Math . abs ( signY ) * distance ) , targetPartsID , targetPartsType ) ; } public appearPartsEval ( triggerPartsPos , xstr , ystr , targetPartsID , targetPartsType ) { var targetX ; var targetY ; var ppos = this . _player . getPosition ( ) . getPartsCoord ( ) ; if ( xstr === "P" || xstr === "p" ) { targetX = ppos . x ; } else if ( xstr [ 0 ] === "+" ) { targetX = triggerPartsPos . x + parseInt ( xstr . substr ( 1 ) ) ; } else if ( xstr [ 0 ] === "-" ) { targetX = triggerPartsPos . x - parseInt ( xstr . substr ( 1 ) ) ; } else { targetX = parseInt ( xstr ) ; if ( isNaN ( targetX ) ) { throw new Error ( "座標として解釈できない文字が含まれています。" ) ; } } if ( ystr === "P" || ystr === "p" ) { targetY = ppos . y ; } else if ( ystr [ 0 ] === "+" ) { targetY = triggerPartsPos . y + parseInt ( ystr . substr ( 1 ) ) ; } else if ( ystr [ 0 ] === "-" ) { targetY = triggerPartsPos . y - parseInt ( ystr . substr ( 1 ) ) ; } else { targetY = parseInt ( ystr ) ; if ( isNaN ( targetY ) ) { throw new Error ( "座標として解釈できない文字が含まれています。" ) ; } } try { var targetPos = new Position ( this , targetX , targetY , 0 , 0 ) ; if ( targetPartsType === PartsType . MAP ) { if ( targetPartsID >= this . _wwaData . mapPartsMax ) { throw new Error ( "背景パーツの範囲外IDが指定されました" ) ; } var cand = new Coord ( targetX , targetY ) ; this . setPartsOnPosition ( PartsType . MAP , targetPartsID , cand ) ; } else { if ( targetPartsID >= this . _wwaData . objPartsMax ) { throw new Error ( "物体パーツの範囲外IDが指定されました" ) ; } var cand = new Coord ( targetX , targetY ) ; this . setPartsOnPosition ( PartsType . OBJECT , targetPartsID , cand ) ; this . _replaceRandomObject ( new Coord ( targetX , targetY ) ) ; if ( targetX === this . _player . getPosition ( ) . getPartsCoord ( ) . x && targetY === this . _player . getPosition ( ) . getPartsCoord ( ) . y ) { this . _player . setPartsAppearedFlag ( ) ; } } } catch ( e ) { } } private _replaceRandomObject ( pos ) { var id = this . _wwaData . mapObject [ pos . y ] [ pos . x ] ; var type = this . _wwaData . objectAttribute [ id ] [ Consts . ATR_TYPE ] ; var newId ; var randv ; if ( type !== Consts . OBJECT_RANDOM ) { return ; } for ( var i = 0 ; i < Consts . RANDOM_ITERATION_MAX ; i ++ ) { randv = Math . floor ( Math . random ( ) * 10 ) ; newId = this . _wwaData . objectAttribute [ id ] [ Consts . ATR_RANDOM_BASE + randv ] ; if ( newId >= this . _wwaData . objPartsMax ) { newId = 0 ; break ; } if ( this . _wwaData . objectAttribute [ newId ] [ Consts . ATR_TYPE ] !== Consts . OBJECT_RANDOM ) { break ; } id = newId ; } this . setPartsOnPosition ( PartsType . OBJECT , newId , pos ) ; } private _replaceRandomObjectsInScreen ( ) { var camPos = this . _camera . getPosition ( ) . getPartsCoord ( ) ; var xLeft = Math . max ( 0 , camPos . x - 1 ) ; var xRight = Math . min ( this . _wwaData . mapWidth - 1 , camPos . x + Consts . H_PARTS_NUM_IN_WINDOW ) ; var yTop = Math . max ( 0 , camPos . y - 1 ) ; var yBottom = Math . min ( this . _wwaData . mapWidth - 1 , camPos . y + Consts . V_PARTS_NUM_IN_WINDOW ) ; for ( var x = xLeft ; x <= xRight ; x ++ ) { for ( var y = yTop ; y < yBottom ; y ++ ) { this . _replaceRandomObject ( new Coord ( x , y ) ) ; } } } private _replaceAllRandomObjects ( ) { for ( var x = 0 ; x < this . _wwaData . mapWidth ; x ++ ) { for ( var y = 0 ; y < this . _wwaData . mapWidth ; y ++ ) { this . _replaceRandomObject ( new Coord ( x , y ) ) ; } } } public gameover ( ) { var jx = this . _wwaData . gameoverX ; var jy = this . _wwaData . gameoverY ; if ( this . _messageWindow . isVisible ( ) ) { this . _yesNoJudge = YesNoState . UNSELECTED ; this . _messageQueue = [ ] ; this . _player . setDelayFrame ( ) ; this . _messageWindow . hide ( ) ; this . _yesNoChoicePartsCoord = void 0 ; this . _yesNoChoicePartsID = void 0 ; this . _yesNoUseItemPos = void 0 ; this . _yesNoChoiceCallInfo = ChoiceCallInfo . NONE ; this . _messageWindow . setYesNoChoice ( false ) ; } this . _waitFrame = 0 ; this . _temporaryInputDisable = true ; this . _execMacroListInNextFrame = [ ] ; this . _player . jumpTo ( new Position ( this , jx , jy , 0 , 0 ) ) ; } public setYesNoInput ( yesNo ) { this . _yesNoJudgeInNextFrame = yesNo ; } public getYesNoState ( ) { if ( this . _yesNoJudgeInNextFrame !== void 0 ) { return this . _yesNoJudgeInNextFrame ; } return this . _yesNoJudge ; } public setStatusChangedEffect ( additionalStatus ) { if ( ! this . _wwaData . isItemEffectEnabled ) { return ; } if ( additionalStatus . strength !== 0 ) { util . $id ( "disp-strength" ) . classList . add ( "onpress" ) ; this . _statusPressCounter . strength = Consts . STATUS_CHANGED_EFFECT_FRAME_NUM ; } if ( additionalStatus . defence !== 0 ) { util . $id ( "disp-defence" ) . classList . add ( "onpress" ) ; this . _statusPressCounter . defence = Consts . STATUS_CHANGED_EFFECT_FRAME_NUM ; } if ( additionalStatus instanceof Status ) { if ( ( < Status > additionalStatus ) . energy !== 0 ) { util . $id ( "disp-energy" ) . classList . add ( "onpress" ) ; this . _statusPressCounter . energy = Consts . STATUS_CHANGED_EFFECT_FRAME_NUM ; } if ( ( < Status > additionalStatus ) . gold !== 0 ) { util . $id ( "disp-gold" ) . classList . add ( "onpress" ) ; this . _statusPressCounter . gold = Consts . STATUS_CHANGED_EFFECT_FRAME_NUM ; } } } public setPartsOnPosition ( partsType , id , pos ) { var before_id , no ; var posKey = ( pos . y << IDTable . BITSHIFT ) | pos . x ; if ( partsType === PartsType . MAP ) { before_id = this . _wwaData . map [ pos . y ] [ pos . x ] ; id = this . loadMapPartsID ( id ) ; before_id = this . loadMapPartsID ( before_id ) ; this . _wwaData . map [ pos . y ] [ pos . x ] = id ; no = this . _mapIDTable [ before_id ] . indexOf ( posKey ) ; if ( no !== - 1 ) { this . _mapIDTable [ before_id ] . splice ( no , 1 ) ; } no = this . _mapIDTable [ id ] . indexOf ( posKey ) ; if ( no === - 1 ) { this . _mapIDTable [ id ] . push ( posKey ) ; } } else { before_id = this . _wwaData . mapObject [ pos . y ] [ pos . x ] ; id = this . loadMapPartsObjectID ( id ) ; before_id = this . loadMapPartsObjectID ( before_id ) ; this . _wwaData . mapObject [ pos . y ] [ pos . x ] = id ; no = this . _mapObjectIDTable [ before_id ] . indexOf ( posKey ) ; if ( no !== - 1 ) { this . _mapObjectIDTable [ before_id ] . splice ( no , 1 ) ; } no = this . _mapObjectIDTable [ id ] . indexOf ( posKey ) ; if ( no === - 1 ) { this . _mapObjectIDTable [ id ] . push ( posKey ) ; } } } private _countSamePartsLength ( data , startPos ) { var i ; for ( i = startPos + 1 ; i < data . length ; i ++ ) { if ( data [ i ] !== data [ i - 1 ] ) { break ; } } return i - startPos ; } private _compressMap ( map ) { var dest = [ ] ; for ( var y = 0 ; y < map . length ; y ++ ) { dest [ y ] = [ ] ; for ( var x = 0 ; x < map [ y ] . length ; ) { var len = this . _countSamePartsLength ( map [ y ] , x ) ; dest [ y ] . push ( [ map [ y ] [ x ] , len ] ) ; x += ( len ) ; } } return dest ; } private _decompressMap ( compressedMap ) { var dest = [ ] ; var x ; for ( var y = 0 ; y < compressedMap . length ; y ++ ) { dest [ y ] = [ ] ; x = 0 ; for ( var i = 0 ; i < compressedMap [ y ] . length ; i ++ ) { var len = compressedMap [ y ] [ i ] [ 1 ] ; for ( var j = 0 ; j < len ; j ++ ) { dest [ y ] . push ( compressedMap [ y ] [ i ] [ 0 ] ) ; } } } return dest ; } param data private _generateMapDataHash ( data ) { var text = "A" ; var len = 0 ; var x = 0 ; var y = 0 ; for ( y = 0 ; y < data . map . length ; y ++ ) { for ( x = 0 ; x < data . map [ y ] . length ; ) { len = this . _countSamePartsLength ( data . map [ y ] , x ) ; text += ( data . map [ y ] [ x ] + "|" + len + "/" ) ; x += ( len ) ; } for ( x = 0 ; x < data . mapObject [ y ] . length ; ) { len = this . _countSamePartsLength ( data . mapObject [ y ] , x ) ; text += ( data . mapObject [ y ] [ x ] + "|" + len + "/" ) ; x += ( len ) ; } } for ( var mapi = 0 ; mapi < data . mapAttribute . length ; mapi ++ ) { for ( var mapatri = 0 ; mapatri < data . mapAttribute [ mapi ] . length ; mapatri ++ ) { text += data . mapAttribute [ mapi ] [ mapatri ] + "/" ; } } for ( var obji = 0 ; obji < data . objectAttribute . length ; obji ++ ) { for ( var objatri = 0 ; objatri < data . objectAttribute [ obji ] . length ; objatri ++ ) { text += data . objectAttribute [ obji ] [ objatri ] + "/" ; } } text += "Z" ; return generateMD5 ( text ) ; } private _generateSaveDataHash ( data ) { var maphash = this . _generateMapDataHash ( data ) ; var text = maphash ; var keyArray = [ ] ; for ( var key in data ) { if ( key === "map" || key === "mapObject" || key === "mapCompressed" || key === "mapObjectCompressed" || key === "mapAttribute" || key === "objectAttribute" || key === "checkString" ) { continue ; } keyArray . push ( key ) ; } keyArray . sort ( ) ; for ( var i = 0 ; i < keyArray . length ; i ++ ) { text += util . arr2str4save ( data [ keyArray [ i ] ] ) ; } return generateMD5 ( text ) ; } private _saveDataList = [ ] ; public compressSystem ( ) { return WWACompress ; } private _quickSave ( callInfo ) { var qd = < WWAData > JSON . parse ( JSON . stringify ( this . _wwaData ) ) ; var pc = this . _player . getPosition ( ) . getPartsCoord ( ) ; var st = this . _player . getStatusWithoutEquipments ( ) ; qd . itemBox = this . _player . getCopyOfItemBox ( ) ; qd . playerX = pc . x ; qd . playerY = pc . y ; qd . statusEnergyMax = this . _player . getEnergyMax ( ) ; qd . statusEnergy = st . energy ; qd . statusStrength = st . strength ; qd . statusDefence = st . defence ; qd . statusGold = st . gold ; qd . moves = this . _player . getMoveCount ( ) ; qd . frameCount = this . _player . getFrameCount ( ) ; qd . gameSpeedIndex = this . _player . getSpeedIndex ( ) ; switch ( callInfo ) { case ChoiceCallInfo . CALL_BY_LOG_QUICK_SAVE : case ChoiceCallInfo . CALL_BY_QUICK_SAVE : case ChoiceCallInfo . CALL_BY_SUSPEND : break ; case ChoiceCallInfo . CALL_BY_PASSWORD_SAVE : qd . checkOriginalMapString = this . checkOriginalMapString ; qd . checkString = this . _generateSaveDataHash ( qd ) ; break ; } qd . message = void 0 ; qd . mapAttribute = void 0 ; qd . objectAttribute = void 0 ; switch ( callInfo ) { case ChoiceCallInfo . CALL_BY_QUICK_SAVE : this . _messageWindow . save ( this . _cvs , qd ) ; this . wwaCustomEvent ( 'wwa_quicksave' , { data : qd } ) ; return "" ; case ChoiceCallInfo . CALL_BY_PASSWORD_SAVE : const compressQD = WWACompress . compress ( qd ) ; compressQD . isCompress = 1 ; const s = JSON . stringify ( compressQD ) ; this . wwaCustomEvent ( 'wwa_passwordsave' , { data : qd , compress : compressQD } ) ; return encodeSaveData ( s , this . _wwaData . worldPassNumber ) ; case ChoiceCallInfo . CALL_BY_SUSPEND : this . wwaCustomEvent ( 'wwa_suspend' , { data : qd , compress : WWACompress . compress ( qd ) } ) ; break ; case ChoiceCallInfo . CALL_BY_LOG_QUICK_SAVE : this . wwaCustomEvent ( 'wwa_autosave' , { data : qd } ) ; this . _wwaSave . autoSave ( this . _cvs , qd ) ; break ; } } public wwaCustomEvent ( eventName , data = { } ) { this . wwaCustomEventEmitter . dispatch ( eventName , data ) ; } param pass returns private _decodePassword ( pass ) { let decodedPassword = "" ; let error = undefined ; try { decodedPassword = decodeSaveDataV1 ( pass , this . _wwaData . worldPassNumber ) ; } catch ( caught ) { error = caught ; } if ( ! decodedPassword ) { console . warn ( "新方式でのパスワード暗号化解除失敗:" , error ) ; try { decodedPassword = decodeSaveDataV0 ( pass , this . _wwaData . worldPassNumber , this . checkOriginalMapString ) ; } catch ( caught ) { error = caught ; } } if ( ! decodedPassword ) { console . warn ( "旧方式でのパスワード暗号化解除失敗:" , error ) ; const errorMessage = error && error . message ? error . message : "" ; throw new Error ( "パスワード取得時からワールド制作者によってマップの暗証番号が変更されたか、\nパスワードが壊れているために正常にセーブデータが復元できませんでした。\n" + errorMessage ) ; } var obj ; try { obj = JSON . parse ( decodedPassword ) ; } catch ( e ) { throw new Error ( "マップデータ以外のものが暗号化されたか、マップデータに何かが不足しているようです。\nJSON PARSE FAILED" ) ; } if ( obj . isCompress ) { delete obj . isCompress ; return WWACompress . decompress ( obj ) ; } else { return [ < WWAData > obj , { isWorldNameEmpty : false } ] ; } ; } private _quickLoad ( restart = false , password = null , apply = true ) { if ( ! restart && this . _wwaSave . hasSaveData ( ) === void 0 && password === null ) { throw new Error ( "セーブデータがありません。" ) ; } let newData ; let isWorldNameEmpty = false ; if ( password !== null ) { const result = this . _decodePassword ( password ) ; newData = result [ 0 ] ; isWorldNameEmpty = result [ 1 ] . isWorldNameEmpty ; } else { newData = < WWAData > JSON . parse ( JSON . stringify ( restart ? this . _restartData : this . _messageWindow . load ( ) ) ) ; } newData . message = < string [ ] > JSON . parse ( JSON . stringify ( this . _restartData . message ) ) ; newData . mapAttribute = < number [ ] [ ] > JSON . parse ( JSON . stringify ( this . _restartData . mapAttribute ) ) ; newData . objectAttribute = < number [ ] [ ] > JSON . parse ( JSON . stringify ( this . _restartData . objectAttribute ) ) ; if ( newData . map === void 0 ) { newData . map = this . _decompressMap ( newData . mapCompressed ) ; } if ( newData . mapObject === void 0 ) { newData . mapObject = this . _decompressMap ( newData . mapObjectCompressed ) ; } delete newData . mapCompressed ; delete newData . mapObjectCompressed ; if ( password !== null ) { if ( ! isWorldNameEmpty && newData . worldName !== this . _wwaData . worldName ) { console . error ( "Invalid title" , `(password)=${ newData . worldName } (current map)=${ this . _wwaData . worldName }` ) ; throw new Error ( "前回パスワード取得時から、制作者によってワールド名が変更されたためロードできませんでした。\n予めご了承ください。" ) ; } const checkOriginalMapString = this . checkOriginalMapString ; if ( this . _isDisallowLoadOldSave && newData . checkOriginalMapString !== checkOriginalMapString ) { console . error ( "Invalid hash" , `(password)=${ newData . checkOriginalMapString } (current map)=${ checkOriginalMapString }` ) ; throw new Error ( "前回パスワード取得時から、制作者によってマップが変更されたためロードできませんでした。\n(マップデータ制作者の設定により、内容が変更されると以前のパスワードは利用できなくなります。)\n予めご了承ください。" ) ; } console . log ( "Valid Password!" ) ; } if ( apply ) { this . _applyQuickLoad ( newData ) ; } return newData ; } private _applyQuickLoad ( newData ) { this . _player . setEnergyMax ( newData . statusEnergyMax ) ; this . _player . setEnergy ( newData . statusEnergy ) ; this . _player . setStrength ( newData . statusStrength ) ; this . _player . setDefence ( newData . statusDefence ) ; this . _player . setGold ( newData . statusGold ) ; this . _player . setMoveCount ( newData . moves ) ; this . _player . setFrameCount ( newData . frameCount ) ; this . _player . clearItemBox ( ) ; for ( var i = 0 ; i < newData . itemBox . length ; i ++ ) { this . _player . addItem ( newData . itemBox [ i ] , i + 1 , true ) ; } this . _player . systemJumpTo ( new Position ( this , newData . playerX , newData . playerY , 0 , 0 ) ) ; if ( newData . bgm === 0 ) { this . playSound ( SystemSound . NO_SOUND ) ; } else { this . playSound ( newData . bgm ) ; } this . setImgClick ( new Coord ( newData . imgClickX , newData . imgClickY ) ) ; if ( this . getObjectIdByPosition ( this . _player . getPosition ( ) ) !== 0 ) { this . _player . setPartsAppearedFlag ( ) ; } this . _wwaData = newData ; this . _mapIDTableCreate ( ) ; this . _replaceAllRandomObjects ( ) ; this . setStatusIconCoord ( MacroImgFrameIndex . ENERGY , new Coord ( newData . imgStatusEnergyX , newData . imgStatusEnergyY ) ) ; this . setStatusIconCoord ( MacroImgFrameIndex . STRENGTH , new Coord ( newData . imgStatusStrengthX , newData . imgStatusStrengthY ) ) ; this . setStatusIconCoord ( MacroImgFrameIndex . DEFENCE , new Coord ( newData . imgStatusDefenceX , newData . imgStatusDefenceY ) ) ; this . setStatusIconCoord ( MacroImgFrameIndex . GOLD , new Coord ( newData . imgStatusGoldX , newData . imgStatusGoldY ) ) ; this . setWideCellCoord ( new Coord ( newData . imgWideCellX , newData . imgWideCellY ) ) ; this . setItemboxBackgroundPosition ( { x : newData . imgItemboxX , y : newData . imgItemboxY } ) ; this . setFrameCoord ( new Coord ( newData . imgFrameX , newData . imgFrameY ) ) ; this . setPlayerSpeedIndex ( newData . gameSpeedIndex ) ; this . updateCSSRule ( ) ; this . updateEffect ( ) ; this . _player . updateStatusValueBox ( ) ; } private _mapIDTableCreate ( ) { var pid ; this . _mapIDTable = [ ] ; this . _mapObjectIDTable = [ ] ; for ( pid = 0 ; pid < this . _wwaData . mapPartsMax ; pid ++ ) { this . _mapIDTable [ pid ] = [ ] ; } for ( pid = 0 ; pid < this . _wwaData . objPartsMax ; pid ++ ) { this . _mapObjectIDTable [ pid ] = [ ] ; } for ( var xx = 0 ; xx < this . _wwaData . mapWidth ; xx ++ ) { for ( var yy = 0 ; yy < this . _wwaData . mapWidth ; yy ++ ) { var posKey = ( yy << IDTable . BITSHIFT ) | xx ; pid = this . _wwaData . map [ yy ] [ xx ] ; if ( ! ( this . _mapIDTable [ pid ] instanceof Array ) ) { this . _mapIDTable [ pid ] = [ ] ; } this . _mapIDTable [ pid ] . push ( posKey ) ; pid = this . _wwaData . mapObject [ yy ] [ xx ] ; if ( ! ( this . _mapObjectIDTable [ pid ] instanceof Array ) ) { this . _mapObjectIDTable [ pid ] = [ ] ; } this . _mapObjectIDTable [ pid ] . push ( posKey ) ; } } } private _restartGame ( ) { this . _quickLoad ( true ) ; } private _fadeout ( callback ) { var borderWidth = 0 ; var size = Consts . MAP_WINDOW_WIDTH ; var v = Consts . FADEOUT_SPEED ; var elm = util . $id ( "wwa-fader" ) ; elm . style . display = "block" ; var timer = setInterval ( ( ) => { borderWidth += v ; size -= v * 2 ; if ( size <= 0 || borderWidth * 2 > Consts . MAP_WINDOW_WIDTH ) { elm . removeAttribute ( "style" ) ; elm . style . display = "block" ; elm . style . borderWidth = "0" ; elm . style . width = Consts . MAP_WINDOW_WIDTH + "px" ; elm . style . height = Consts . MAP_WINDOW_HEIGHT + "px" ; elm . style . backgroundColor = "#808080" ; clearInterval ( timer ) ; callback ( ) ; return ; } elm . style . width = size + "px" ; elm . style . height = size + "px" ; elm . style . borderWidth = borderWidth + "px" ; } , 20 ) ; } public moveObjects ( playerIsMoving ) { var camPos = this . _camera . getPosition ( ) ; var pPos = this . _player . getPosition ( ) ; var camCoord = camPos . getPartsCoord ( ) ; var leftX = camPos . getPartsCoord ( ) . x ; var topY = camPos . getPartsCoord ( ) . y ; var objectsInNextFrame ; var localX , localY ; if ( this . getMapAttributeByPosition ( this . _player . getPosition ( ) , Consts . ATR_TYPE ) === Consts . MAP_LOCALGATE || this . getObjectAttributeByPosition ( this . _player . getPosition ( ) , Consts . ATR_TYPE ) === Consts . OBJECT_LOCALGATE ) { return ; } objectsInNextFrame = new Array ( Consts . V_PARTS_NUM_IN_WINDOW + 2 ) ; this . hoge = new Array ( Consts . V_PARTS_NUM_IN_WINDOW + 2 ) ; for ( localY = - 1 ; localY <= Consts . V_PARTS_NUM_IN_WINDOW ; localY ++ ) { objectsInNextFrame [ localY + 1 ] = new Array ( Consts . H_PARTS_NUM_IN_WINDOW + 2 ) ; this . hoge [ localY + 1 ] = new Array ( Consts . H_PARTS_NUM_IN_WINDOW + 2 ) ; for ( localX = - 1 ; localX <= Consts . H_PARTS_NUM_IN_WINDOW ; localX ++ ) { if ( topY + localY < 0 || topY + localY >= this . _wwaData . mapWidth || leftX + localX < 0 || leftX + localX >= this . _wwaData . mapWidth ) { objectsInNextFrame [ localY + 1 ] [ localX + 1 ] = 0 ; this . hoge [ localY + 1 ] [ localX + 1 ] = 0 ; continue ; } try { var pos = new Position ( this , leftX + localX , topY + localY , 0 , 0 ) ; var posc = pos . getPartsCoord ( ) ; } catch ( e ) { objectsInNextFrame [ localY + 1 ] [ localX + 1 ] = 0 ; this . hoge [ localY + 1 ] [ localX + 1 ] = 0 ; continue ; } var objID = this . _wwaData . mapObject [ posc . y ] [ posc . x ] ; objectsInNextFrame [ localY + 1 ] [ localX + 1 ] = this . _wwaData . mapObject [ posc . y ] [ posc . x ] ; this . hoge [ localY + 1 ] [ localX + 1 ] = - this . _wwaData . mapObject [ posc . y ] [ posc . x ] ; } } for ( localX = - 1 ; localX <= Consts . H_PARTS_NUM_IN_WINDOW ; localX ++ ) { if ( leftX + localX < 0 || leftX + localX >= this . _wwaData . mapWidth ) { continue ; } for ( localY = - 1 ; localY <= Consts . V_PARTS_NUM_IN_WINDOW ; localY ++ ) { if ( topY + localY < 0 || topY + localY >= this . _wwaData . mapWidth ) { continue ; } try { var pos = new Position ( this , leftX + localX , topY + localY , 0 , 0 ) ; var posc = pos . getPartsCoord ( ) ; } catch ( e ) { continue ; } var partsID = this . _wwaData . mapObject [ posc . y ] [ posc . x ] ; if ( partsID === 0 || this . _wwaData . objectAttribute [ partsID ] [ Consts . ATR_MOVE ] === MoveType . STATIC || this . _wwaData . objectAttribute [ partsID ] [ Consts . ATR_TYPE ] === Consts . OBJECT_LOCALGATE || this . _wwaData . objectAttribute [ partsID ] [ Consts . ATR_TYPE ] === Consts . OBJECT_RANDOM ) { continue ; } if ( this . _wwaData . objectAttribute [ partsID ] [ Consts . ATR_MOVE ] !== MoveType . CHASE_PLAYER && this . _wwaData . objectAttribute [ partsID ] [ Consts . ATR_MOVE ] !== MoveType . RUN_OUT && this . _wwaData . objectAttribute [ partsID ] [ Consts . ATR_MOVE ] !== MoveType . HANG_AROUND ) { continue ; } var moveMode = this . _wwaData . objectAttribute [ partsID ] [ Consts . ATR_MOVE ] ; if ( moveMode !== MoveType . HANG_AROUND ) { var candCoord = this . _getCandidateCoord ( playerIsMoving , pos , moveMode ) ; var xCand = new Coord ( candCoord . x , posc . y ) ; var yCand = new Coord ( posc . x , candCoord . y ) ; var thirdCand = null ; var randomCand ; if ( this . _objectCanMoveTo ( playerIsMoving , candCoord , objectsInNextFrame ) ) { this . _setObjectsInNextFrame ( posc , candCoord , leftX , topY , objectsInNextFrame , partsID ) ; } else { var mode = this . _getSecondCandidateMoveMode ( playerIsMoving , posc , candCoord , xCand , yCand , this . _wwaData . objectAttribute [ partsID ] [ Consts . ATR_TYPE ] === Consts . OBJECT_MONSTER , objectsInNextFrame ) ; if ( mode === SecondCandidateMoveType . MODE_X ) { this . _setObjectsInNextFrame ( posc , xCand , leftX , topY , objectsInNextFrame , partsID ) ; } else if ( mode === SecondCandidateMoveType . MODE_Y ) { this . _setObjectsInNextFrame ( posc , yCand , leftX , topY , objectsInNextFrame , partsID ) ; } else { thirdCand = this . _getThirdCandidate ( playerIsMoving , pos , candCoord , moveMode , objectsInNextFrame ) ; if ( thirdCand !== null && ! this . _wwaData . isOldMove ) { this . _setObjectsInNextFrame ( posc , thirdCand , leftX , topY , objectsInNextFrame , partsID ) ; } else { randomCand = this . _getRandomMoveCoord ( playerIsMoving , pos , objectsInNextFrame ) ; this . _setObjectsInNextFrame ( posc , randomCand , leftX , topY , objectsInNextFrame , partsID ) ; } } } } else { randomCand = this . _getRandomMoveCoord ( playerIsMoving , pos , objectsInNextFrame ) ; this . _setObjectsInNextFrame ( posc , randomCand , leftX , topY , objectsInNextFrame , partsID ) ; } } } } private _getCandidateCoord ( playerIsMoving , currentPos , moveType ) { var currentCoord = currentPos . getPartsCoord ( ) ; var playerOffsetCoord = this . _player . getPosition ( ) . getOffsetCoord ( ) ; var playerCoord = this . _player . getPosition ( ) . getPartsCoord ( ) ; try { var playerNextCoord = playerIsMoving ? this . _player . getPosition ( ) . getNextJustPosition ( ) . getPartsCoord ( ) : this . _player . getPosition ( ) . getPartsCoord ( ) ; } catch ( e ) { throw new Error ( "予期せぬ方向への移動のようです。" ) ; } var candidateCoord = currentCoord . clone ( ) ; var dx = 0 ; var dy = 0 ; if ( moveType === MoveType . CHASE_PLAYER ) { dx = currentCoord . x > playerNextCoord . x ? - 1 : currentCoord . x < playerNextCoord . x ? 1 : 0 ; dy = currentCoord . y > playerNextCoord . y ? - 1 : currentCoord . y < playerNextCoord . y ? 1 : 0 ; } else if ( moveType === MoveType . RUN_OUT ) { dx = currentCoord . x > playerNextCoord . x ? 1 : currentCoord . x < playerNextCoord . x ? - 1 : 0 ; dy = currentCoord . y > playerNextCoord . y ? 1 : currentCoord . y < playerNextCoord . y ? - 1 : 0 ; } candidateCoord . x += dx ; candidateCoord . y += dy ; candidateCoord . x = Math . min ( this . _wwaData . mapWidth - 1 , Math . max ( 0 , candidateCoord . x ) ) ; candidateCoord . y = Math . min ( this . _wwaData . mapWidth - 1 , Math . max ( 0 , candidateCoord . y ) ) ; return candidateCoord ; } private _getSecondCandidateMoveMode ( playerIsMoving , current , firstCandidate , xCand , yCand , isMonster , objectsInNextFrame ) { if ( playerIsMoving && ( ( this . _player . getDir ( ) === Direction . UP || this . _player . getDir ( ) === Direction . DOWN ) && isMonster || ( this . _player . getDir ( ) === Direction . LEFT || this . _player . getDir ( ) === Direction . RIGHT ) && ! isMonster ) ) { if ( this . _objectCanMoveTo ( playerIsMoving , yCand , objectsInNextFrame ) ) { return SecondCandidateMoveType . MODE_Y ; } if ( this . _objectCanMoveTo ( playerIsMoving , xCand , objectsInNextFrame ) ) { return SecondCandidateMoveType . MODE_X ; } return SecondCandidateMoveType . UNDECIDED ; } if ( this . _objectCanMoveTo ( playerIsMoving , xCand , objectsInNextFrame ) ) { return SecondCandidateMoveType . MODE_X ; } if ( this . _objectCanMoveTo ( playerIsMoving , yCand , objectsInNextFrame ) ) { return SecondCandidateMoveType . MODE_Y ; } return SecondCandidateMoveType . UNDECIDED ; } private _getThirdCandidate ( playerIsMoving , currentPos , firstCandidate , mode , objectsInNextFrame ) { var dir = mode === MoveType . CHASE_PLAYER ? 1 : mode === MoveType . RUN_OUT ? - 1 : 0 ; var npCoord = playerIsMoving ? this . _player . getPosition ( ) . getNextJustPosition ( ) . getPartsCoord ( ) : this . _player . getPosition ( ) . getPartsCoord ( ) ; var currentCoord = currentPos . getPartsCoord ( ) ; var testCoord ; if ( npCoord . x !== currentCoord . x ) { testCoord = new Coord ( firstCandidate . x , currentCoord . y + 1 * dir ) ; if ( this . _objectCanMoveTo ( playerIsMoving , testCoord , objectsInNextFrame ) ) { return testCoord ; } testCoord = new Coord ( firstCandidate . x , currentCoord . y - 1 * dir ) ; if ( this . _objectCanMoveTo ( playerIsMoving , testCoord , objectsInNextFrame ) ) { return testCoord ; } testCoord = new Coord ( currentCoord . x , currentCoord . y + 1 * dir ) ; if ( this . _objectCanMoveTo ( playerIsMoving , testCoord , objectsInNextFrame ) ) { return testCoord ; } testCoord = new Coord ( currentCoord . x , currentCoord . y - 1 * dir ) ; if ( this . _objectCanMoveTo ( playerIsMoving , testCoord , objectsInNextFrame ) ) { return testCoord ; } } if ( npCoord . y !== currentCoord . y ) { testCoord = new Coord ( currentCoord . x + 1 * dir , firstCandidate . y ) ; if ( this . _objectCanMoveTo ( playerIsMoving , testCoord , objectsInNextFrame ) ) { return testCoord ; } testCoord = new Coord ( currentCoord . x - 1 * dir , firstCandidate . y ) ; if ( this . _objectCanMoveTo ( playerIsMoving , testCoord , objectsInNextFrame ) ) { return testCoord ; } testCoord = new Coord ( currentCoord . x + 1 * dir , currentCoord . y ) ; if ( this . _objectCanMoveTo ( playerIsMoving , testCoord , objectsInNextFrame ) ) { return testCoord ; } testCoord = new Coord ( currentCoord . x - 1 * dir , currentCoord . y ) ; if ( this . _objectCanMoveTo ( playerIsMoving , testCoord , objectsInNextFrame ) ) { return testCoord ; } } return null ; } private _getRandomMoveCoord ( playerIsMoving , currentPos , objectsInNextFrame ) { var currentCoord = currentPos . getPartsCoord ( ) ; var resultCoord = currentCoord . clone ( ) ; var iterNum = this . _wwaData . isOldMove ? Consts . RANDOM_MOVE_ITERATION_NUM_BEFORE_V31 : Consts . RANDOM_MOVE_ITERATION_NUM ; for ( var i = 0 ; i < iterNum ; i ++ ) { var rand = Math . floor ( Math . random ( ) * 8 ) ; resultCoord . x = currentCoord . x + vx [ rand ] ; resultCoord . y = currentCoord . y + vy [ rand ] ; if ( this . _objectCanMoveTo ( playerIsMoving , resultCoord , objectsInNextFrame ) ) { return resultCoord ; } } return currentCoord ; } public isPrevFrameEventExecuted ( ) { return this . _prevFrameEventExected ; } private _objectCanMoveTo ( playerIsMoving , candCoord , objectsInNextFrame ) { if ( candCoord . x < 0 || candCoord . y < 0 || this . _wwaData . mapWidth <= candCoord . x || this . _wwaData . mapWidth <= candCoord . y ) { return false ; } var mapID = this . _wwaData . map [ candCoord . y ] [ candCoord . x ] ; var objID = this . _wwaData . mapObject [ candCoord . y ] [ candCoord . x ] ; var mapType = this . _wwaData . mapAttribute [ mapID ] [ Consts . ATR_TYPE ] ; var camPos = this . _camera . getPosition ( ) ; var leftX = camPos . getPartsCoord ( ) . x ; var topY = camPos . getPartsCoord ( ) . y ; if ( mapID === 0 && ! this . isOldMap ( ) || mapType === Consts . MAP_WALL ) { return false ; } var targetX = candCoord . x - leftX + 1 ; var targetY = candCoord . y - topY + 1 ; if ( 0 <= targetX && 0 <= targetY && targetX < objectsInNextFrame . length && targetY < objectsInNextFrame . length ) { if ( objectsInNextFrame [ targetY ] [ targetX ] !== 0 ) { return false ; } } else { if ( objID !== 0 ) { return false ; } } if ( playerIsMoving ) { if ( this . _player . getPosition ( ) . getNextJustPosition ( ) . getPartsCoord ( ) . equals ( candCoord ) ) { return false ; } } else { if ( this . _player . getPosition ( ) . getPartsCoord ( ) . equals ( candCoord ) ) { return false ; } } return true ; } private _setObjectsInNextFrame ( currentCoord , candCoord , leftX , topY , objectsInNextFrame , partsID ) { var targetX = candCoord . x - leftX + 1 ; var targetY = candCoord . y - topY + 1 ; if ( 0 <= candCoord . x && candCoord . x <= this . _wwaData . mapWidth && 0 <= candCoord . y && candCoord . y <= this . _wwaData . mapWidth ) { if ( 0 <= targetX && targetX < objectsInNextFrame . length && 0 <= targetY && targetY < objectsInNextFrame . length ) { objectsInNextFrame [ currentCoord . y - topY + 1 ] [ currentCoord . x - leftX + 1 ] = 0 ; objectsInNextFrame [ candCoord . y - topY + 1 ] [ candCoord . x - leftX + 1 ] = partsID ; this . hoge [ candCoord . y - topY + 1 ] [ candCoord . x - leftX + 1 ] = partsID ; } this . _objectMovingDataManager . add ( partsID , currentCoord . convertIntoPosition ( this ) , candCoord . convertIntoPosition ( this ) , currentCoord . getDirectionTo ( candCoord ) ) ; } } public launchBattleEstimateWindow ( ) { var cpParts = this . _camera . getPosition ( ) . getPartsCoord ( ) ; var xLeft = Math . max ( 0 , cpParts . x ) ; var xRight = Math . min ( this . _wwaData . mapWidth - 1 , cpParts . x + Consts . H_PARTS_NUM_IN_WINDOW - 1 ) ; var yTop = Math . max ( 0 , cpParts . y ) ; var yBottom = Math . min ( this . _wwaData . mapWidth - 1 , cpParts . y + Consts . V_PARTS_NUM_IN_WINDOW - 1 ) ; var monsterList = [ ] ; this . playSound ( SystemSound . DECISION ) ; for ( var x = xLeft ; x <= xRight ; x ++ ) { for ( var y = yTop ; y <= yBottom ; y ++ ) { var pid = this . _wwaData . mapObject [ y ] [ x ] ; if ( this . _wwaData . objectAttribute [ pid ] [ Consts . ATR_TYPE ] === Consts . OBJECT_MONSTER ) { if ( monsterList . indexOf ( pid ) === - 1 ) { monsterList . push ( pid ) ; } } } } if ( this . _bottomButtonType === ControlPanelBottomButton . BATTLE_REPORT ) { ( < HTMLDivElement > ( util . $id ( sidebarButtonCellElementID [ SidebarButton . GOTO_WWA ] ) ) ) . classList . add ( "onpress" ) ; } if ( monsterList . length === 0 ) { ( < HTMLDivElement > ( util . $id ( sidebarButtonCellElementID [ SidebarButton . GOTO_WWA ] ) ) ) . classList . remove ( "onpress" ) ; this . hideBattleEstimateWindow ( ) ; return false ; } this . _battleEstimateWindow . update ( this . _player . getStatus ( ) , monsterList ) ; this . _battleEstimateWindow . show ( ) ; this . _player . setEstimateWindowWating ( ) ; return true ; } public hideBattleEstimateWindow ( ) { this . _battleEstimateWindow . hide ( ) ; this . _player . clearEstimateWindowWaiting ( ) ; ( < HTMLDivElement > ( util . $id ( sidebarButtonCellElementID [ SidebarButton . GOTO_WWA ] ) ) ) . classList . remove ( "onpress" ) ; } public hidePasswordWindow ( isCancel = false ) { this . _passwordWindow . hide ( ) ; if ( isCancel || this . _passwordWindow . mode === Mode . SAVE ) { this . _player . clearPasswordWindowWaiting ( ) ; return ; } try { var data = this . _quickLoad ( false , this . _passwordWindow . password , false ) ; } catch ( e ) { this . _player . clearPasswordWindowWaiting ( ) ; alert ( "セーブデータの復元に失敗しました。\nエラー詳細:\n" + e . message ) ; return ; } this . _passwordLoadExecInNextFrame = true ; this . _passwordSaveExtractData = data ; } private _displayHelp ( ) { if ( this . _player . isControllable ( ) ) { this . setNowPlayTime ( ) ; var helpMessage = "" ; switch ( this . userDevice . device ) { case DEVICE_TYPE . GAME : switch ( this . userDevice . os ) { case OS_TYPE . NINTENDO : helpMessage = "　【操作方法】\n" + "Ａ：Ｙｅｓ,戦闘結果予測の表示\n" + "Ｂ：Ｎｏ\n" + "Ｘ：メニュー\n" + "Ｙ：このリストの表示\n" + "Ｒ：初めからスタート\n" + "ＺＬ：データの一時保存\n" + "ＺＲ：一時保存データの読み込み\n" + "＋: 移動速度を上げる\n" + "－: 移動速度を落とす\n" + "　WWA Wing バージョン:" + VERSION_WWAJS + "\n" + "　マップデータ バージョン: " + Math . floor ( this . _wwaData . version / 10 ) + "." + this . _wwaData . version % 10 ; break ; case OS_TYPE . PLAY_STATION : helpMessage = "　【操作方法】\n" + "〇：Ｙｅｓ,戦闘結果予測の表示\n" + "×：Ｎｏ\n" + "△：メニュー\n" + "□：このリストの表示\n" + "Ｒ１：初めからスタート\n" + "Ｌ２：データの一時保存\n" + "Ｒ２：一時保存データの読み込み\n" + "OPTIONS: 移動速度を上げる\n" + "SHARE: 移動速度を落とす\n" + "　　現在の移動回数：" + this . _player . getMoveCount ( ) + "\n" + "　　プレイ時間：" + this . _player . getPlayTimeText ( ) + "\n" + "　WWA Wing バージョン:" + VERSION_WWAJS + "\n" + "　マップデータ バージョン: " + Math . floor ( this . _wwaData . version / 10 ) + "." + this . _wwaData . version % 10 ; break ; case OS_TYPE . XBOX : helpMessage = "　【操作方法】\n" + "Ｂ：Ｙｅｓ,戦闘結果予測の表示\n" + "Ａ：Ｎｏ\n" + "Ｙ：メニュー\n" + "Ｘ：このリストの表示\n" + "ＲＢ：初めからスタート\n" + "ＬＴ：データの一時保存\n" + "ＲＴ：一時保存データの読み込み\n" + "MENU: 移動速度を上げる\n" + "WINDOW: 移動速度を落とす\n" + "　　現在の移動回数：" + this . _player . getMoveCount ( ) + "\n" + "　　プレイ時間：" + this . _player . getPlayTimeText ( ) + "\n" + "　WWA Wing バージョン:" + VERSION_WWAJS + "\n" + "　マップデータ バージョン: " + Math . floor ( this . _wwaData . version / 10 ) + "." + this . _wwaData . version % 10 ; break ; default : return ; } break ; case DEVICE_TYPE . SP : return ; case DEVICE_TYPE . VR : return ; case DEVICE_TYPE . PC : helpMessage = "　【操作方法】\n" + "Ｆ１、Ｍ：戦闘結果予測の表示\n" + "Ｆ３：復帰用パスワード入力\n" + "Ｆ４：復帰用パスワード表示\n" + "Ｆ５：一時保存データの読み込み\n" + "Ｆ６：データの一時保存\n" + "Ｆ７：初めからスタート\n" + "Ｆ８：ＷＷＡ公式ページにリンク\n" + "Ｆ１２：このリストの表示\n" + "キーボードの「１２３、ＱＷＥ、ＡＳＤ、ＺＸＣ」は右のアイテムボックスに対応。\n" + "「Ｅｎｔｅｒ、Ｙ」はＹｅｓ,\n" + "「Ｅｓｃ、Ｎ」はＮｏに対応。\n" + "　　　Ｉ: 移動速度を落とす／\n" + "Ｆ２、Ｐ: 移動速度を上げる\n" + "　　現在の移動回数：" + this . _player . getMoveCount ( ) + "\n" + "　　プレイ時間：" + this . _player . getPlayTimeText ( ) + "\n" + "　WWA Wing バージョン:" + VERSION_WWAJS + "\n" + "　マップデータ バージョン: " + Math . floor ( this . _wwaData . version / 10 ) + "." + this . _wwaData . version % 10 ; break ; default : return ; } if ( helpMessage ) { this . setMessageQueue ( helpMessage , false , true ) ; } } } public _setNextMessage ( displayCenter = false ) { this . _clearFacesInNextFrame = true ; if ( this . _scoreWindow . isVisible ( ) ) { this . _scoreWindow . hide ( ) ; this . _scoreRates = undefined ; } if ( this . _lastMessage . isEndOfPartsEvent && this . _reservedMoveMacroTurn !== void 0 ) { this . _player . setMoveMacroWaiting ( this . _reservedMoveMacroTurn ) ; this . _reservedMoveMacroTurn = void 0 ; } if ( this . _messageQueue . length === 0 ) { this . _hideMessageWindow ( ) ; } else { var message = this . _messageQueue . shift ( ) ; var macro = message . macro ; this . _lastMessage = message ; for ( var i = 0 ; i < macro . length ; i ++ ) { this . _execMacroListInNextFrame . push ( macro [ i ] ) ; } if ( ! message . isEmpty ( ) ) { this . _player . setDelayFrame ( ) ; this . _messageWindow . hide ( ) ; this . _messageWindow . setParsedMessage ( message ) ; this . _messageWindow . setPositionByPlayerPosition ( this . _faces . length !== 0 , this . _scoreWindow . isVisible ( ) , displayCenter , this . _player . getPosition ( ) , this . _camera . getPosition ( ) ) ; this . _messageWindow . show ( ) ; this . _player . setMessageWaiting ( ) ; } else { if ( this . _messageQueue . length === 0 ) { this . _hideMessageWindow ( ) ; } else { this . _setNextMessage ( ) ; } } } } private _hideMessageWindow ( messageDisplayed = true ) { var itemID = 0 ; if ( this . _player . isReadyToUseItem ( ) ) { itemID = this . _player . useItem ( ) ; } var mesID = this . getObjectAttributeById ( itemID , Consts . ATR_STRING ) ; this . clearFaces ( ) ; if ( mesID === 0 ) { if ( messageDisplayed ) { this . _player . setDelayFrame ( ) ; this . _messageWindow . hide ( ) ; this . _keyStore . allClear ( ) ; this . _mouseStore . clear ( ) ; } this . _player . clearMessageWaiting ( ) ; } else { this . setMessageQueue ( this . getMessageById ( mesID ) , false , false , itemID , PartsType . OBJECT , this . _player . getPosition ( ) . getPartsCoord ( ) , true ) ; } } public loadMapPartsObjectID ( id ) { id = id | 0 ; if ( ( id < 0 ) || ( id >= this . _wwaData . objPartsMax ) ) { return 0 ; } return id ; } public loadMapPartsID ( id ) { id = id | 0 ; if ( ( id < 0 ) || ( id >= this . _wwaData . mapPartsMax ) ) { return 0 ; } return id ; } public replaceParts ( srcID , destID , partsType = PartsType . OBJECT , onlyThisSight = false ) { var cpParts = this . _camera . getPosition ( ) . getPartsCoord ( ) ; var xLeft = onlyThisSight ? Math . max ( 0 , cpParts . x ) : 0 ; var xRight = onlyThisSight ? Math . min ( this . _wwaData . mapWidth - 1 , cpParts . x + Consts . H_PARTS_NUM_IN_WINDOW - 1 ) : this . _wwaData . mapWidth - 1 ; var yTop = onlyThisSight ? Math . max ( 0 , cpParts . y ) : 0 ; var yBottom = onlyThisSight ? Math . min ( this . _wwaData . mapWidth - 1 , cpParts . y + Consts . V_PARTS_NUM_IN_WINDOW ) - 1 : this . _wwaData . mapWidth - 1 ; onlyThisSight = ( xLeft !== 0 ) || ( xRight !== this . _wwaData . mapWidth - 1 ) || ( yTop !== 0 ) || ( yBottom !== this . _wwaData . mapWidth - 1 ) ; var posKey , len , i , list ; var xx , yy ; var srcList , destList ; if ( partsType === PartsType . OBJECT ) { srcID = this . loadMapPartsObjectID ( srcID ) ; destID = this . loadMapPartsObjectID ( destID ) ; list = this . _mapObjectIDTable [ srcID ] . concat ( ) ; srcList = this . _mapObjectIDTable [ srcID ] ; srcList . length = 0 ; destList = this . _mapObjectIDTable [ destID ] ; len = list . length ; if ( onlyThisSight ) { for ( i = 0 ; i < len ; i ++ ) { posKey = list [ i ] ; xx = ( posKey & IDTable . BITMASK ) ; yy = ( ( posKey >>> IDTable . BITSHIFT ) & IDTable . BITMASK ) ; if ( ( xLeft <= xx ) && ( xx <= xRight ) && ( yTop <= yy ) && ( yy <= yBottom ) ) { this . _wwaData . mapObject [ yy ] [ xx ] = destID ; destList . push ( posKey ) ; } else { srcList . push ( posKey ) ; } } } else { for ( i = 0 ; i < len ; i ++ ) { posKey = list [ i ] ; xx = ( posKey & IDTable . BITMASK ) ; yy = ( ( posKey >>> IDTable . BITSHIFT ) & IDTable . BITMASK ) ; this . _wwaData . mapObject [ yy ] [ xx ] = destID ; } Array . prototype . push . apply ( destList , list ) ; } } else { srcID = this . loadMapPartsID ( srcID ) ; destID = this . loadMapPartsID ( destID ) ; list = this . _mapIDTable [ srcID ] . concat ( ) ; srcList = this . _mapIDTable [ srcID ] ; srcList . length = 0 ; destList = this . _mapIDTable [ destID ] ; len = list . length ; if ( onlyThisSight ) { for ( i = 0 ; i < len ; i ++ ) { posKey = list [ i ] ; xx = ( posKey & IDTable . BITMASK ) ; yy = ( ( posKey >>> IDTable . BITSHIFT ) & IDTable . BITMASK ) ; if ( ( xLeft <= xx ) && ( xx <= xRight ) && ( yTop <= yy ) && ( yy <= yBottom ) ) { this . _wwaData . map [ yy ] [ xx ] = destID ; destList . push ( posKey ) ; } else { srcList . push ( posKey ) ; } } } else { for ( i = 0 ; i < len ; i ++ ) { posKey = list [ i ] ; xx = ( posKey & IDTable . BITMASK ) ; yy = ( ( posKey >>> IDTable . BITSHIFT ) & IDTable . BITMASK ) ; this . _wwaData . map [ yy ] [ xx ] = destID ; } Array . prototype . push . apply ( destList , list ) ; } } } public getYesNoImgCoord ( ) { return new Coord ( this . _wwaData . yesnoImgPosX , this . _wwaData . yesnoImgPosY ) ; } public setYesNoImgCoord ( coord ) { this . _wwaData . yesnoImgPosX = coord . x ; this . _wwaData . yesnoImgPosY = coord . y ; return coord ; } public getPlayerImgCoord ( ) { return new Coord ( this . _wwaData . playerImgPosX , this . _wwaData . playerImgPosY ) ; } public setPlayerImgCoord ( coord ) { this . _wwaData . playerImgPosX = coord . x ; this . _wwaData . playerImgPosY = coord . y ; return coord ; } public setPlayerEnergyMax ( eng ) { return this . _player . setEnergyMax ( eng ) ; } public getMapPartsNum ( ) { return this . _wwaData . mapPartsMax ; } public getObjectPartsNum ( ) { return this . _wwaData . objPartsMax ; } public setMoveMacroWaitingToPlayer ( moveNum ) { this . _reservedMoveMacroTurn = moveNum ; } public disableSave ( flag ) { this . _wwaData . disableSaveFlag = flag ; this . _wwaSave . quickSaveButtonUpdate ( this . _wwaData ) ; return flag ; } public isOldMap ( ) { return this . _wwaData . isOldMap ; } public setOldMap ( flag ) { return this . _wwaData . isOldMap = flag ; } public setObjectNotCollapseOnPartsOnPlayer ( flag ) { return this . _wwaData . objectNoCollapseDefaultFlag = flag ; } public setGameOverPosition ( pos ) { if ( pos . x < 0 || pos . x >= this . getMapWidth ( ) || pos . y < 0 || pos . y >= this . getMapWidth ( ) ) { throw new Error ( "マップの範囲外が指定されています!" ) ; } this . _wwaData . gameoverX = pos . x ; this . _wwaData . gameoverY = pos . y ; return pos ; } public setPlayerStatus ( type , value ) { if ( type === MacroStatusIndex . ENERGY ) { this . _player . setEnergy ( value ) ; } else if ( type === MacroStatusIndex . STRENGTH ) { this . _player . setStrength ( value ) ; } else if ( type === MacroStatusIndex . DEFENCE ) { this . _player . setDefence ( value ) ; } else if ( type === MacroStatusIndex . GOLD ) { this . _player . setGold ( value ) ; } else if ( type === MacroStatusIndex . MOVES ) { this . _player . setMoveCount ( value ) ; } else { throw new Error ( "未定義のステータスタイプです" ) ; } } public setDelPlayer ( flag ) { return this . _wwaData . delPlayerFlag = flag ; } public setPlayerGetItem ( pos , id ) { try { this . _player . addItem ( id , pos , true ) ; } catch ( e ) { } } param type param coord throws public setStatusIconCoord ( type , coord ) { const x = coord . x * Consts . CHIP_SIZE ; const y = coord . y * Consts . CHIP_SIZE ; const setBackgroundIconNode = ( elementId ) => { const iconNode = util . $qsh ( `${ elementId }>.status-icon` ) ; iconNode . style . backgroundPosition = `-${ x }px -${ y }px` ; } ; switch ( type ) { case MacroImgFrameIndex . ENERGY : this . _wwaData . imgStatusEnergyX = coord . x ; this . _wwaData . imgStatusEnergyY = coord . y ; setBackgroundIconNode ( "#disp-energy" ) ; break ; case MacroImgFrameIndex . STRENGTH : this . _wwaData . imgStatusStrengthX = coord . x ; this . _wwaData . imgStatusStrengthY = coord . y ; setBackgroundIconNode ( "#disp-strength" ) ; break ; case MacroImgFrameIndex . DEFENCE : this . _wwaData . imgStatusDefenceX = coord . x ; this . _wwaData . imgStatusDefenceY = coord . y ; setBackgroundIconNode ( "#disp-defence" ) ; break ; case MacroImgFrameIndex . GOLD : this . _wwaData . imgStatusGoldX = coord . x ; this . _wwaData . imgStatusGoldY = coord . y ; setBackgroundIconNode ( "#disp-gold" ) ; break ; default : throw new Error ( "種別が不正です。" ) ; } return coord . clone ( ) ; } param coord public setWideCellCoord ( coord ) { this . _wwaData . imgWideCellX = coord . x ; this . _wwaData . imgWideCellY = coord . y ; const x = coord . x * Consts . CHIP_SIZE ; const y = coord . y * Consts . CHIP_SIZE ; Array . prototype . forEach . call ( util . $qsAll ( "div.wide-cell-row" ) , ( node ) => { node . style . backgroundPosition = "-" + x + "px -" + y + "px" ; } ) ; return coord . clone ( ) ; } public setFrameCoord ( coord ) { this . _wwaData . imgFrameX = coord . x ; this . _wwaData . imgFrameY = coord . y ; this . _cgManager . setFrameImage ( coord ) ; return coord . clone ( ) ; } public setBattleEffectCoord ( coord ) { return this . _battleEffectCoord = coord . clone ( ) ; } public canInput ( ) { return ! this . _temporaryInputDisable ; } public setEffect ( waits , coords ) { this . _wwaData . effectWaits = waits ; this . _wwaData . effectCoords = coords ; this . updateEffect ( ) ; } public stopEffect ( ) { this . _wwaData . effectCoords = [ ] ; this . updateEffect ( ) ; } public updateEffect ( ) { this . _cgManager . updateEffects ( < Coord [ ] > this . _wwaData . effectCoords ) ; } public setImgClick ( pos ) { this . _wwaData . imgClickX = pos . x ; this . _wwaData . imgClickY = pos . y ; if ( pos . equals ( new Coord ( 0 , 0 ) ) ) { Array . prototype . forEach . call ( util . $qsAll ( ".item-cell>.item-click-border" ) , ( node ) => { node . style . backgroundImage = "url('" + Consts . ITEM_BORDER_IMG_DATA_URL + "')" ; node . style . backgroundPosition = "0 0" ; } ) ; } else { var escapedFilename = this . _wwaData . mapCGName . replace ( "(" , "\\(" ) . replace ( ")" , "\\)" ) ; Array . prototype . forEach . call ( util . $qsAll ( ".item-cell>.item-click-border" ) , ( node ) => { node . style . backgroundImage = "url('" + escapedFilename + "')" ; node . style . backgroundPosition = "-" + pos . x * Consts . CHIP_SIZE + "px -" + pos . y * Consts . CHIP_SIZE + "px" ; } ) ; } } public addFace ( face ) { this . _faces . push ( face ) ; } public clearFaces ( ) { this . _faces = [ ] ; } public updateItemEffectEnabled ( isEnabled ) { this . _wwaData . isItemEffectEnabled = isEnabled ; } public setOldMove ( flag ) { this . _wwaData . isOldMove = flag ; } private _stylePos : number [ ] ; private _styleElm : HTMLStyleElement ; private _sheet : CSSStyleSheet ; public initCSSRule ( ) { this . _styleElm = < HTMLStyleElement > util . $id ( Consts . WWA_STYLE_TAG_ID ) ; this . _sheet = < CSSStyleSheet > this . _styleElm . sheet ; this . updateCSSRule ( ) ; } public updateCSSRule ( ) { if ( this . _stylePos === void 0 ) { this . _stylePos = new Array ( 2 ) ; } else { if ( this . _sheet . addRule !== void 0 ) { for ( var i = 0 ; i < this . _stylePos . length ; i ++ ) { this . _sheet . removeRule ( this . _stylePos [ this . _styleElm [ i ] ] ) ; } } else { for ( var i = 0 ; i < this . _stylePos . length ; i ++ ) { this . _sheet . deleteRule ( this . _stylePos [ this . _styleElm [ i ] ] ) ; } } } const messageWindowStyleSelector = "div.wwa-message-window, div#wwa-text-message-window, div#wwa-battle-estimate, div#wwa-password-window" ; const messageWindowOpacity = this . _isClassicModeEnable ? 1 : 0.9 ; const messageWindowStyleRules = `
background-color: rgba(${ this . _wwaData . frameColorR },  ${ this . _wwaData . frameColorG }, ${ this . _wwaData . frameColorB }, ${ messageWindowOpacity });
border-color: rgba(${ this . _wwaData . frameOutColorR }, ${ this . _wwaData . frameOutColorG }, ${ this . _wwaData . frameOutColorB }, 1);
color: rgba(${ this . _wwaData . fontColorR }, ${ this . _wwaData . fontColorG }, ${ this . _wwaData . fontColorB }, 1);
white-space: pre-wrap;
` ; const sidebarStyleSelector = "div#wwa-sidebar" ; const sidebarStyleRules = `
color: rgba(${ this . _wwaData . statusColorR }, ${ this . _wwaData . statusColorG }, ${ this . _wwaData . statusColorB },1);
font-weight: bold;
` ; if ( this . _sheet . addRule !== void 0 ) { this . _stylePos [ SelectorType . MESSAGE_WINDOW ] = this . _sheet . addRule ( messageWindowStyleSelector , messageWindowStyleRules ) ; this . _stylePos [ SelectorType . SIDEBAR ] = this . _sheet . addRule ( sidebarStyleSelector , sidebarStyleRules ) ; } else { this . _stylePos [ SelectorType . MESSAGE_WINDOW ] = this . _sheet . insertRule ( `${ messageWindowStyleSelector } { ${ messageWindowStyleRules } }` , 0 ) ; this . _stylePos [ SelectorType . SIDEBAR ] = this . _sheet . insertRule ( `${ sidebarStyleSelector } { ${ sidebarStyleRules } }` , 1 ) ; } } public changeStyleRule ( type , r , g , b ) { if ( type === ChangeStyleType . COLOR_FRAME ) { this . _wwaData . frameColorR = r ; this . _wwaData . frameColorG = g ; this . _wwaData . frameColorB = b ; } else if ( type === ChangeStyleType . COLOR_FRAMEOUT ) { this . _wwaData . frameOutColorR = r ; this . _wwaData . frameOutColorG = g ; this . _wwaData . frameOutColorB = b ; } else if ( type === ChangeStyleType . COLOR_STR ) { this . _wwaData . fontColorR = r ; this . _wwaData . fontColorG = g ; this . _wwaData . fontColorB = b ; } else if ( type === ChangeStyleType . COLOR_STATUS_STR ) { this . _wwaData . statusColorR = r ; this . _wwaData . statusColorG = g ; this . _wwaData . statusColorB = b ; } this . updateCSSRule ( ) ; } public showMonsterWindow ( ) { this . _monsterWindow . show ( ) ; } public isClassicMode ( ) { return this . _isClassicModeEnable ; } public isConsoleOutputMode ( ) { return this . _useConsole ; } public forcedJumpGate ( jx , jy ) { this . _player . jumpTo ( new Position ( this , jx , jy , 0 , 0 ) ) ; } public setUserVar ( index , value ) { if ( this . isNotNumberTypeOrNaN ( index ) || ! this . isValidUserVarIndex ( index ) ) { throw new Error ( `代入先のユーザ変数の番号 が 0 以上 ${ Consts . USER_VAR_NUM - 1 } 以下の数値になっていません!` ) ; } this . _wwaData . userVar [ index ] = this . toAssignableValue ( value ) ; this . _messageWindow . update ( ) ; } param x private toAssignableValue ( x ) { const intValue = x | 0 ; const clampedValue = Math . max ( Math . min ( intValue , Consts . USER_VAR_NUM_MAX_VALUE ) , Consts . USET_VAR_NUM_MIN_VALUE ) ; return this . isNotNumberTypeOrNaN ( clampedValue ) ? 0 : clampedValue ; } param index private isValidUserVarIndex ( index ) { return typeof index === "number" && index >= 0 && index < Consts . USER_VAR_NUM && ( index | 0 ) === index ; } param x private isNotNumberTypeOrNaN ( x ) { return typeof x !== "number" || x !== x ; } public getUserVar ( no ) { return this . _wwaData . userVar [ no ] ; } public recUserPosition ( x , y ) { var pos = this . _player . getPosition ( ) . getPartsCoord ( ) ; this . setUserVar ( x , pos . x ) ; this . setUserVar ( y , pos . y ) ; } public jumpRecUserPosition ( x , y ) { this . forcedJumpGate ( this . _wwaData . userVar [ x ] , this . _wwaData . userVar [ y ] ) ; } public outputUserVar ( num ) { console . log ( "Var[" + num + "] = " + this . _wwaData . userVar [ num ] ) ; } public setUserVarHP ( num ) { this . setUserVar ( num , this . _player . getStatus ( ) . energy ) ; } public setUserVarHPMAX ( num ) { this . setUserVar ( num , this . _player . getEnergyMax ( ) ) ; } public setUserVarAT ( num , kind ) { switch ( kind ) { case "bare" : this . setUserVar ( num , this . _player . getStatusWithoutEquipments ( ) . strength ) ; return ; case "equipment" : this . setUserVar ( num , this . _player . getStatusOfEquipments ( ) . strength ) ; return ; case "all" : default : this . setUserVar ( num , this . _player . getStatus ( ) . strength ) ; return ; } } public setUserVarDF ( num , kind ) { switch ( kind ) { case "bare" : this . setUserVar ( num , this . _player . getStatusWithoutEquipments ( ) . defence ) ; return ; case "equipment" : this . setUserVar ( num , this . _player . getStatusOfEquipments ( ) . defence ) ; return ; case "all" : default : this . setUserVar ( num , this . _player . getStatus ( ) . defence ) ; return ; } } public setUserVarMONEY ( num ) { this . setUserVar ( num , this . _player . getStatus ( ) . gold ) ; } private toValidStatusValue ( x ) { return this . isNotNumberTypeOrNaN ( x ) || x < 0 ? 0 : ( x | 0 ) ; } public setHPUserVar ( index ) { if ( ! this . isValidUserVarIndex ( index ) ) { throw new Error ( "ユーザ変数の添字が範囲外です。" ) ; } this . _player . setEnergy ( this . toValidStatusValue ( this . _wwaData . userVar [ index ] ) ) ; if ( this . _player . isDead ( ) ) { this . gameover ( ) ; } this . _player . updateStatusValueBox ( ) ; } public setHPMAXUserVar ( index ) { if ( ! this . isValidUserVarIndex ( index ) ) { throw new Error ( "ユーザ変数の添字が範囲外です。" ) ; } this . _player . setEnergyMax ( this . toValidStatusValue ( this . _wwaData . userVar [ index ] ) ) ; this . _player . updateStatusValueBox ( ) ; } public setATUserVar ( index ) { if ( ! this . isValidUserVarIndex ( index ) ) { throw new Error ( "ユーザ変数の添字が範囲外です。" ) ; } this . _player . setStrength ( this . toValidStatusValue ( this . _wwaData . userVar [ index ] ) ) ; this . _player . updateStatusValueBox ( ) ; } public setDFUserVar ( index ) { if ( ! this . isValidUserVarIndex ( index ) ) { throw new Error ( "ユーザ変数の添字が範囲外です。" ) ; } this . _player . setDefence ( this . toValidStatusValue ( this . _wwaData . userVar [ index ] ) ) ; this . _player . updateStatusValueBox ( ) ; } public setMONEYUserVar ( index ) { if ( ! this . isValidUserVarIndex ( index ) ) { throw new Error ( "ユーザ変数の添字が範囲外です。" ) ; } this . _player . setGold ( this . toValidStatusValue ( this . _wwaData . userVar [ index ] ) ) ; this . _player . updateStatusValueBox ( ) ; } public setUserVarStep ( num ) { this . setUserVar ( num , this . _player . getMoveCount ( ) ) ; } public setUserVarVal ( x , num ) { this . setUserVar ( x , num ) ; } public setUserValOtherUserVal ( x , y ) { this . setUserVar ( x , this . _wwaData . userVar [ y ] ) ; } public setUserValAdd ( x , y ) { this . setUserVar ( x , this . _wwaData . userVar [ x ] + this . _wwaData . userVar [ y ] ) ; } public setUserValSub ( x , y ) { this . setUserVar ( x , this . _wwaData . userVar [ x ] - this . _wwaData . userVar [ y ] ) ; } public setUserValMul ( x , y ) { this . setUserVar ( x , this . _wwaData . userVar [ x ] * this . _wwaData . userVar [ y ] ) ; } public setUserValDiv ( x , y ) { this . setUserVar ( x , y === 0 ? 0 : this . _wwaData . userVar [ x ] / this . _wwaData . userVar [ y ] ) ; } public setUserValMod ( x , y ) { this . setUserVar ( x , y === 0 ? 0 : this . _wwaData . userVar [ x ] % this . _wwaData . userVar [ y ] ) ; } public setUserValRandNum ( x , num , bias ) { this . setUserVar ( x , Math . floor ( Math . random ( ) * this . toAssignableValue ( num ) ) + bias ) ; } private _generateUserValString ( macroArgs ) { return macroArgs . map ( ( macroArg ) => { const parsedArg = parseInt ( macroArg , 10 ) ; return isNaN ( parsedArg ) ? macroArg . replace ( /\\n/g , "\n" ) : ( ) => this . _wwaData . userVar [ parsedArg ] ; } ) ; } public speedChangeJudge ( speedChangeFlag ) { this . _wwaData . permitChangeGameSpeed = speedChangeFlag ; } public userVarUserIf ( _triggerPartsPosition , args ) { if ( args [ 5 ] === undefined ) { throw new Error ( "$if の引数不足 str=" + args ) ; } const userVar1Index = parseInt ( args [ 0 ] , 10 ) ; const userVar2Index = parseInt ( args [ 2 ] , 10 ) ; if ( ! this . isValidUserVarIndex ( userVar1Index ) || ! this . isValidUserVarIndex ( userVar2Index ) ) { throw new Error ( "判定対象のユーザ変数の添字が範囲外です!" ) ; } const userVar1 = this . _wwaData . userVar [ userVar1Index ] ; const opeCode = args [ 1 ] ; const userVar2 = this . _wwaData . userVar [ userVar2Index ] ; /**
         *  partsTypeArgument が 0 以外の数値として解釈できるなら 背景パーツ
         *  0 に解釈される文字列や undefined なら 物体パーツ を返す。
         */ const parsePartsType = ( partsTypeArgument ) : PartsType => parseInt ( partsTypeArgument , 10 ) ? PartsType . MAP : PartsType . OBJECT ; if ( this . compareUserVar ( userVar1 , opeCode , userVar2 ) ) { const partsId = parseInt ( args [ 3 ] , 10 ) ; const partsX = args [ 4 ] ; const partsY = args [ 5 ] ; const partsType = parsePartsType ( args [ 6 ] ) ; this . appearPartsEval ( _triggerPartsPosition , partsX , partsY , partsId , partsType ) ; return ; } if ( args [ 9 ] === undefined ) { return ; } const partsId = parseInt ( args [ 7 ] , 10 ) ; const partsX = args [ 8 ] ; const partsY = args [ 9 ] ; const partsType = parsePartsType ( args [ 10 ] ) ; this . appearPartsEval ( _triggerPartsPosition , partsX , partsY , partsId , partsType ) ; } private compareUserVar ( userVar1 , opecode , userVar2 ) { switch ( opecode ) { case "==" : return userVar1 === userVar2 ; case "!=" : return userVar1 !== userVar2 ; case ">=" : return userVar1 >= userVar2 ; case ">" : return userVar1 > userVar2 ; case "<=" : return userVar1 <= userVar2 ; case "<" : return userVar1 < userVar2 ; default : throw new Error ( `未定義の演算子です: ${ opecode }` ) ; } } public setPlayerSpeedIndex ( speedIndex ) { if ( speedIndex < Consts . MIN_SPEED_INDEX || Consts . MAX_SPEED_INDEX < speedIndex ) { throw new Error ( "#set_speed の引数が異常です:" + speedIndex ) ; } this . _wwaData . gameSpeedIndex = this . _player . setSpeedIndex ( speedIndex ) ; } public setUserVarPlayTime ( num ) { this . setNowPlayTime ( ) ; this . setUserVar ( num , this . _wwaData . playTime ) ; } private setNowPlayTime ( ) { const _nowTime = new Date ( ) ; this . _wwaData . playTime += ( _nowTime . getTime ( ) - this . _startTime ) ; this . _startTime = _nowTime . getTime ( ) ; } public hideStatus ( no , isHide ) { if ( no < 0 || no > StatusKind . length ) { throw new Error ( "隠すパラメータは０から３の間で指定してください。" ) ; } this . _changeStatusVisibility ( StatusKind [ no ] , ! isHide ) ; this . _player . updateStatusValueBox ( ) ; } public varMap ( triggerPartsPos , xstr , ystr , partsID , targetPartsType ) { if ( ! this . isValidUserVarIndex ( partsID ) ) { throw new Error ( "対象のユーザ変数の添字が範囲外です" ) ; } const targetPartsID = this . _wwaData . userVar [ partsID ] ; if ( targetPartsID < 0 ) { throw new Error ( "負のパーツ番号は指定できません" ) ; } if ( targetPartsType === PartsType . OBJECT && targetPartsID >= this . getObjectPartsNum ( ) ) { throw new Error ( "物体パーツ番号の最大値を超えるパーツ番号が指定されました" ) ; } if ( targetPartsType === PartsType . MAP && targetPartsID >= this . getMapPartsNum ( ) ) { throw new Error ( "背景パーツ番号の最大値を超えるパーツ番号が指定されました" ) ; } this . appearPartsEval ( triggerPartsPos , xstr , ystr , targetPartsID , targetPartsType ) ; } param pos public setItemboxBackgroundPosition ( pos ) { this . _wwaData . imgItemboxX = pos . x ; this . _wwaData . imgItemboxY = pos . y ; Array . prototype . forEach . call ( util . $qsAll ( "div.item-cell" ) , ( node ) => { node . style . backgroundPosition = `-${ pos . x * Consts . CHIP_SIZE }px -${ pos . y * Consts . CHIP_SIZE }px` ; } ) ; } private _actionGamePadButtonItemMacro ( ) { if ( ! this . _wwaData . gamePadButtonItemTable ) { return false ; } var len , buttonID , itemBoxNo , inputButtonFlag ; len = this . _wwaData . gamePadButtonItemTable . length ; for ( buttonID = 0 ; buttonID < len ; buttonID ++ ) { itemBoxNo = this . _wwaData . gamePadButtonItemTable [ buttonID ] ; if ( ! itemBoxNo ) { continue ; } inputButtonFlag = false ; switch ( buttonID ) { case GamePadState . BUTTON_CROSS_KEY_LEFT : if ( this . _gamePadStore . crossPressed ( GamePadState . BUTTON_CROSS_KEY_LEFT ) ) { inputButtonFlag = true ; } break ; case GamePadState . BUTTON_CROSS_KEY_RIGHT : if ( this . _gamePadStore . crossPressed ( GamePadState . BUTTON_CROSS_KEY_RIGHT ) ) { inputButtonFlag = true ; } break ; case GamePadState . BUTTON_CROSS_KEY_UP : if ( this . _gamePadStore . crossPressed ( GamePadState . BUTTON_CROSS_KEY_UP ) ) { inputButtonFlag = true ; } break ; case GamePadState . BUTTON_CROSS_KEY_DOWN : if ( this . _gamePadStore . crossPressed ( GamePadState . BUTTON_CROSS_KEY_DOWN ) ) { inputButtonFlag = true ; } break ; } if ( this . _gamePadStore . buttonTrigger ( buttonID ) ) { inputButtonFlag = true ; } if ( inputButtonFlag ) { if ( this . onselectitem ( itemBoxNo ) ) { return true ; } } } return false ; } param buttonID param itemBoxNo public setGamePadButtonItemTable ( buttonID , itemBoxNo ) { if ( ! this . _wwaData . gamePadButtonItemTable ) { var currentButtonID , currentButtonKey ; this . _wwaData . gamePadButtonItemTable = [ ] ; for ( currentButtonKey in GamePadState ) { currentButtonID = currentButtonKey ; this . _wwaData . gamePadButtonItemTable [ currentButtonID ] = 0 ; } } if ( this . _wwaData . gamePadButtonItemTable . length > buttonID ) { this . _wwaData . gamePadButtonItemTable [ buttonID ] = itemBoxNo ; } } param saveDataWorldName param saveDataHash param mapDataRevisionKey private _checkSaveDataCompatibility ( saveDataWorldName , saveDataHash , mapDataRevisionKey ) { if ( saveDataWorldName !== undefined && saveDataWorldName !== this . _wwaData . worldName ) { return LoadErrorCode . UNMATCHED_WORLD_NAME ; } else if ( mapDataRevisionKey && mapDataRevisionKey !== generateMapDataRevisionKey ( this . _wwaData . worldName , this . _wwaData . worldPassNumber ) ) { return LoadErrorCode . UNMATCHED_WORLD_PASS_NUMBER ; } else if ( this . _isDisallowLoadOldSave && saveDataHash !== this . checkOriginalMapString ) { return LoadErrorCode . DISALLOW_OLD_REVISION_WORLD_SAVE_DATA ; } return null ; } public isVisibleStatus ( statusKind ) { switch ( statusKind ) { case "energy" : return this . _wwaData . isVisibleStatusEnergy ; case "strength" : return this . _wwaData . isVisibleStatusStrength ; case "defence" : return this . _wwaData . isVisibleStatusDefence ; case "gold" : return this . _wwaData . isVisibleStatusGold ; default : throw new Error ( "存在しないステータスが与えられました" ) ; } } private _changeStatusVisibility ( statusKind , isVisible ) { switch ( statusKind ) { case "energy" : this . _wwaData . isVisibleStatusEnergy = isVisible ; return ; case "strength" : this . _wwaData . isVisibleStatusStrength = isVisible ; return ; case "defence" : this . _wwaData . isVisibleStatusDefence = isVisible ; return ; case "gold" : this . _wwaData . isVisibleStatusGold = isVisible ; return ; default : throw new Error ( "存在しないステータスが与えられました" ) ; } } } ; var isCopyRightClick = false ; function setupVarDumpElement ( dumpElmQuery ) { const dumpElm = util . $qs ( dumpElmQuery ) as HTMLElement | null ; if ( ! dumpElm ) { return null ; } dumpElm . classList . add ( "wwa-vardump-wrapper" ) ; var tableElm = document . createElement ( "table" ) ; var headerTrElm = document . createElement ( "tr" ) ; var headerThElm = document . createElement ( "th" ) ; var hideButton = document . createElement ( "button" ) ; hideButton . textContent = "隠す" ; headerThElm . textContent = "変数一覧" ; headerThElm . setAttribute ( "colspan" , "10" ) ; headerThElm . classList . add ( "varlist-header" ) ; headerThElm . appendChild ( hideButton ) ; headerTrElm . appendChild ( headerThElm ) ; tableElm . appendChild ( headerTrElm ) ; var trNumElm = null ; var trValElm = null ; for ( var i = 0 ; i < Consts . USER_VAR_NUM ; i ++ ) { if ( i % 10 === 0 ) { if ( trNumElm !== null ) { tableElm . appendChild ( trNumElm ) ; tableElm . appendChild ( trValElm ) ; } trNumElm = document . createElement ( "tr" ) ; trNumElm . classList . add ( "var-number" ) ; trValElm = document . createElement ( "tr" ) ; trValElm . classList . add ( "var-val" ) ; } var thNumElm = document . createElement ( "th" ) ; var tdValElm = document . createElement ( "td" ) ; thNumElm . textContent = i + "" ; tdValElm . classList . add ( "var" + i ) ; tdValElm . textContent = "-" ; trNumElm . appendChild ( thNumElm ) ; trValElm . appendChild ( tdValElm ) ; } if ( Consts . USER_VAR_NUM % 10 !== 0 ) { tableElm . appendChild ( trNumElm ) ; tableElm . appendChild ( trValElm ) ; } dumpElm . appendChild ( tableElm ) ; var varDispStatus = true ; hideButton . addEventListener ( "click" , function ( e ) { if ( varDispStatus ) { this . textContent = "表示" ; Array . prototype . forEach . call ( tableElm . querySelectorAll ( "tr.var-number" ) , function ( etr ) { etr . style . display = "none" ; } ) ; Array . prototype . forEach . call ( tableElm . querySelectorAll ( "tr.var-val" ) , function ( etr ) { etr . style . display = "none" ; } ) ; varDispStatus = false ; } else { this . textContent = "隠す" ; Array . prototype . forEach . call ( tableElm . querySelectorAll ( "tr.var-number" ) , function ( etr ) { etr . style . display = "table-row" ; } ) ; Array . prototype . forEach . call ( tableElm . querySelectorAll ( "tr.var-val" ) , function ( etr ) { etr . style . display = "table-row" ; } ) ; varDispStatus = true ; } } ) ; return dumpElm ; } function start ( ) { Array . prototype . forEach . call ( util . $qsAll ( "a.wwa-copyright" ) , ( node ) => { node . addEventListener ( "click" , ( ) : void => { isCopyRightClick = true ; } ) ; } ) ; window . addEventListener ( "beforeunload" , ( e ) : string => { var mes = "このページを離れますか？" ; if ( isCopyRightClick ) { isCopyRightClick = false ; e . returnValue = mes ; return mes ; } } ) ; var titleImgName = util . $id ( "wwa-wrapper" ) . getAttribute ( "data-wwa-title-img" ) ; inject ( < HTMLDivElement > util . $id ( "wwa-wrapper" ) , titleImgName ) ; var mapFileName = util . $id ( "wwa-wrapper" ) . getAttribute ( "data-wwa-mapdata" ) ; var audioDirectory = util . $id ( "wwa-wrapper" ) . getAttribute ( "data-wwa-audio-dir" ) ; var dumpElmQuery = util . $id ( "wwa-wrapper" ) . getAttribute ( "data-wwa-var-dump-elm" ) ; var dumpElm = null ; if ( util . $id ( "wwa-wrapper" ) . hasAttribute ( "data-wwa-var-dump-elm" ) ) { dumpElm = setupVarDumpElement ( dumpElmQuery ) ; } var urlgateEnabled = true ; if ( util . $id ( "wwa-wrapper" ) . getAttribute ( "data-wwa-urlgate-enable" ) . match ( /^false$/i ) ) { urlgateEnabled = false ; } var classicModeAttribute = util . $id ( "wwa-wrapper" ) . getAttribute ( "data-wwa-classic-mode-enable" ) ; var classicModeEnabled = false ; if ( classicModeAttribute !== null && classicModeAttribute . match ( /^true$/i ) ) { classicModeEnabled = true ; } var itemEffectEnabled = true ; var itemEffectAttribute = util . $id ( "wwa-wrapper" ) . getAttribute ( "data-wwa-item-effect-enable" ) ; if ( itemEffectAttribute !== null && itemEffectAttribute . match ( /^false$/i ) ) { itemEffectEnabled = false ; } let useGoToWWA = false ; const useGoToWWAAttribute = util . $id ( "wwa-wrapper" ) . getAttribute ( "data-wwa-use-go-to-wwa" ) ; if ( useGoToWWAAttribute !== null && useGoToWWAAttribute . match ( /^true$/i ) ) { useGoToWWA = true ; } const disallowLoadOldSave = ( ( ) => { const disallowLoadOldSaveAttribute = util . $id ( "wwa-wrapper" ) . getAttribute ( "data-wwa-disallow-load-old-save" ) ; if ( disallowLoadOldSaveAttribute !== null && disallowLoadOldSaveAttribute . match ( /^true$/i ) ) { return true ; } return false ; } ) ( ) ; wwa = new WWA ( mapFileName , urlgateEnabled , titleImgName , classicModeEnabled , itemEffectEnabled , useGoToWWA , audioDirectory , disallowLoadOldSave , dumpElm ) ; } if ( document . readyState === "complete" ) { setTimeout ( start ) ; } else { window . addEventListener ( "load" , function ( ) { setTimeout ( start ) ; } ) ; }