Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- render() {
- const loadingProgress = 100/5 * (this.props.connected + this.props.loaded + (this.props.playersReady !== -1));
- let loadingCounter = this.props.loadingCounter || 1;
- if (loadingProgress < 100) {
- loadingCounter = (loadingCounter === 3 ? 1 : loadingCounter + 1);
- setTimeout(() => {
- this.props.dispatch({type: 'LOADING_STRING', loadingCounter});
- }, 1000);
- };
- const loadingString = (loadingProgress > 0 ? 'Loading' + '.'.repeat(loadingCounter) : 'Connecting' + '.'.repeat(loadingCounter));
- const mainMenu = (<div>
- <div className='startButtons'>
- <div className='flex'>
- <button className={`rpgui-button startButton ${(!this.props.ready ? 'growAnimation' : '')} ${(loadingProgress >= 100 ? '' : 'hidden')}`}
- onClick={this.toggleReady}>{(this.props.ready ? 'Unready' : 'Ready')}</button>
- <button style={{marginLeft: '5px'}} className={`rpgui-button ${(this.props.playersReady === this.props.connectedPlayers ? 'growAnimation' : '')}`}
- onClick={() => this.startGameEvent()}>
- {(loadingProgress >= 100 ? `Start Game (${this.props.playersReady}/${this.props.connectedPlayers})`
- : <div className='rpgui-progress rpgui-disabled red'><div className='text_shadow loadingBarContainer rpgui-progress-track'>
- {(loadingProgress > 0 ? <div className='rpgui-progress-fill green' style={{width: loadingProgress + '%'}}></div> : '')}
- <p className={`loadingBarText ${loadingProgress > 0 ? '' : 'loadingBarConnecting'}`}>
- {loadingString}
- </p>
- </div></div>)}
- </button>
- <button style={{marginLeft: '5px'}} className={`rpgui-button ${(this.props.playersReady >= 2 && this.props.playersReady !== this.props.connectedPlayers && this.props.ready ? '' : 'hidden')}`}
- onClick={() => this.startGameEvent(true)}>
- Force Start Game{(this.props.connected ? ` (${this.props.playersReady}/${this.props.connectedPlayers})` : ' Connecting ...')}
- </button>
- </div>
- </div>
- <div className='mainMenuNameChange'>
- <form onSubmit={this.handleNameChange}>
- <label className='text_shadow'>Name:</label>
- <label>
- <input maxLength='20' placeholder={this.props.playerName} className='textInputSmaller' type="text" value={this.state.nameChangeInput}
- onChange={(event) => this.setState({...this.state, nameChangeInput: event.target.value})} />
- </label>
- <input className='rpgui-button golden' type="submit" value="Submit" />
- </form>
- </div>
- <div className='mainMenuSoundDiv marginTop5'>
- <div>
- <img className='musicImgMainMenu' src={(this.props.musicEnabled ? getImage('music') : getImage('musicMuted'))}
- alt={(this.props.musicEnabled ? 'Mute Music': 'Turn on Music')} onClick={() => this.props.dispatch({type: 'TOGGLE_MUSIC'})}/>
- </div>
- <div>
- <img className='soundImgMainMenu' src={(this.props.soundEnabled ? getImage('sound') : getImage('soundMuted'))}
- alt={(this.props.soundEnabled ? 'Mute Sound': 'Turn on Sound')} onClick={() => this.props.dispatch({type: 'TOGGLE_SOUND'})}/>
- </div>
- {(this.props.musicEnabled ? this.playMusic() : '')}
- </div>
- </div>);
- if (!this.props.gameIsLive) {
- return <div className="rpgui-content rpgui-cursor-default"><div id="container"><div class="inner rpgui-container framed">{mainMenu}</div></div></div>;
- }
- const topBar = <div className='flex topBarDiv'>
- <div className='flex topBarPlayerName'>
- <div className='marginTop5 biggerText text_shadow paddingLeft5'>
- {(this.props.visiting === this.props.index ? this.props.playerName :
- <span><span className='goldFont'>{'Visit: '}</span><span>{this.props.players[this.props.visiting].name}</span></span>)}
- </div>
- </div>
- <div className='marginTop5 biggerText text_shadow topBarRound'>
- {'Round: ' + this.props.round}
- </div>
- {this.getAmountOfUnitsOnBoard()}
- <div className='flex topBarPadding'>
- <img className='goldImage' src={getImage('goldCoin')} alt='goldCoin'/>
- <div className='marginTop5 biggerText'>
- <span className='text_shadow paddingLeft5'>{JSON.stringify(this.props.gold, null, 2)}</span>
- </div>
- </div>
- <div className='marginTop5 biggerText text_shadow topBarPadding'>
- {(this.props.onGoingBattle ? <div className='redFont'>
- {(this.props.enemyIndex ? <span className='nextUpText'>
- {(this.props.players[this.props.enemyIndex] && (this.props.roundType === 'pvp' || this.props.roundType === 'shop') ?
- this.props.players[this.props.enemyIndex].name : this.props.enemyIndex) }
- </span>: '')}
- {(this.props.roundType === 'gym' ? <img className='gymLeader' src={getGymImage(this.props.enemyIndex)} alt={this.props.enemyIndex}/> : '')}
- </div> : <div>
- {(this.props.enemyIndex !== -1 ? <span className='nextUpText'>{'Up next: ' + (this.props.enemyIndex !== '' ? '' :
- (this.props.roundType === 'npc' ? 'Npc Battle' : (this.props.roundType === 'pvp' ? 'PvP Battle' : '')))}
- </span>: '')}
- {(this.props.roundType === 'gym' ? <img className='gymLeader upNext' src={getGymImage(this.props.enemyIndex)} alt={this.props.enemyIndex}/>: '')}
- </div>)}
- </div>
- </div>;
- const leftBar = <div className='leftBar'>
- {this.props.gameIsLive ? <Timer startTime={this.props.timerDuration} key={this.props.round} startTimer={this.props.startTimer}
- storedState={this.props.storedState} dispatch={this.props.dispatch} gameEnded={this.props.gameEnded}></Timer> : ''}
- <div>
- {this.selectedUnitInformation()}
- {this.unitSound()}
- {this.soundEffects()}
- </div>
- <div className='boardBuffs text_shadow'>
- {(this.props.boardBuffs && this.props.boardBuffs.buffMap && Object.keys(this.props.boardBuffs.buffMap).length > 0 ?
- this.displayBuffs() : '')}
- </div>
- <div className='battleEnemyBuffs text_shadow'>
- {(this.props.onGoingBattle && !Number.isNaN(this.props.enemyIndex) ?
- this.displayEnemyBuffs() : '')}
- </div>
- <div className='flex musicDiv'>
- <div onClick={() => this.props.dispatch({type: 'TOGGLE_MUSIC'})}>
- <img className='musicImg' src={(this.props.musicEnabled ? getImage('music') : getImage('musicMuted'))} alt={(this.props.musicEnabled ? 'Mute Music': 'Turn on Music')}/>
- </div>
- <div onClick={() => this.props.dispatch({type: 'TOGGLE_SOUND'})}>
- <img className='soundImg' src={(this.props.soundEnabled ? getImage('sound') : getImage('soundMuted'))} alt={(this.props.soundEnabled ? 'Mute Sound': 'Turn on Sound')}/>
- </div>
- <img className='chatSoundImg' src={(this.props.chatSoundEnabled ? getImage('chatSound') : getImage('chatSoundMuted'))}
- onClick={() => this.props.dispatch({type: 'TOGGLE_CHAT_SOUND'})} alt='chatSoundToggle'/>
- {(this.props.musicEnabled && this.props.gameIsLive ? this.playMusic() : '')}
- </div>
- <div className='paddingLeft5 marginTop5 text_shadow'>
- <input
- type="range"
- className="volume-bar"
- value={this.props.volume * 100}
- min="0"
- max="100"
- step="0.01"
- onChange={this.handleVolumeChange}
- />
- </div>
- {<div>Selected Unit: {JSON.stringify(this.props.selectedUnit, null, 2)}</div>}
- </div>;
- const boardDiv = <div className={(!this.props.onGoingBattle ? 'boardDiv' : 'boardDivBattle')}>
- <div>
- <Board height={8} width={8} map={this.props.myBoard} isBoard={true} newProps={this.props}/>
- </div>
- <div className='levelDiv'>
- <div className={`levelBar overlap ${(this.props.exp === 0 ? 'hidden' : '')}`}
- style={{width: (this.props.expToReach !== 0 ? String(this.props.exp/this.props.expToReach * 100) : '100') + '%'}}/>
- <div className='biggerText centerWith50 overlap levelText'>
- <span className='text_shadow paddingLeft5 paddingRight5'>{'Level ' + JSON.stringify(this.props.level, null, 2)}</span>
- {<span className='text_shadow paddingLeft5 paddingRight5'>{'( ' + (this.props.expToReach === 'max' ? 'max' : this.props.exp + '/' + this.props.expToReach) + ' )'}</span>}
- </div>
- <div className='overlap text_shadow marginTop5 paddingLeft5 levelTextExp'>
- {'Exp: ' + this.props.exp + '/' + this.props.expToReach}
- </div>
- </div>
- <div className={`flex center ${(this.props.index === this.props.visiting ? 'handDiv' : 'handDivVisiting')}`}>
- <Board height={1} width={8} map={this.props.myHand} isBoard={false} newProps={this.props}/>
- </div>
- </div>;
- const rightSide = <div className='flex'>
- <div>
- <div>
- <div className='paddingLeft5'>
- <div>
- <div>
- <div className='flex'>
- <ShopPokemon shopPokemon={this.props.myShop[this.pos(0)]} index={0} newProps={this.props}/>
- <ShopPokemon shopPokemon={this.props.myShop[this.pos(1)]} index={1} newProps={this.props}/>
- <ShopPokemon shopPokemon={this.props.myShop[this.pos(2)]} index={2} newProps={this.props}/>
- </div>
- <div className='flex'>
- <div className='shopInteractDiv'>
- <div>
- <img className={`lockImage ${(this.props.lock ? 'shineLock' : '')}`} onClick={() => toggleLockEvent(this.props)}
- src={this.props.lock ? getImage('lockedLock') : getImage('openLock')} alt='lock'/>
- </div>
- <div className='refreshShopDiv'>
- <img className='refreshShopImage' onClick={() => refreshShopEvent(this.props)} src={getImage('refreshShop')} alt='refreshShop'/>
- </div>
- <div className='flex goldImageRefreshDiv'>
- <img className='goldImageSmall' src={getImage('goldCoin')} alt='goldCoin'/>
- <div className={`text_shadow goldImageTextSmall ${(this.props.gold < 2 ? 'redFont' : '')}`}>2</div>
- </div>
- </div>
- <ShopPokemon shopPokemon={this.props.myShop[this.pos(3)]} index={3} newProps={this.props} className='pokemonShopHalf'/>
- <ShopPokemon shopPokemon={this.props.myShop[this.pos(4)]} index={4} newProps={this.props} className='paddingLeft30'/>
- </div>
- </div>
- </div>
- </div>
- </div>
- <div className='marginTop5 paddingLeft5 belowShopDiv'>
- <div className='flex'>
- <div>
- <button style={{marginLeft: '5px'}} className='rpgui-button' onClick={() => buyExpEvent(this.props)}>Buy Exp</button>
- <div className='flex marginTop5 goldImageBuyExp'>
- <img className='goldImageSmall' src={getImage('goldCoin')} style={{marginLeft: '18px'}} alt='goldCoin'/>
- <div className={`text_shadow goldImageTextSmall ${(this.props.gold < 5 ? 'redFont' : '')}`}>5</div>
- </div>
- </div>
- <div className='toggleHelpDiv'>
- <img className='toggleHelpImg' src={(this.props.help ? getImage('collapse') : getImage('collapseNot'))}
- onClick={() => this.props.dispatch({type: 'TOGGLE_HELP'})} alt='toggleHelp'/>
- </div>
- {(this.props.debugMode ? <div className='text_shadow hoveringDiv'>Hovering: {JSON.stringify(this.props.mouseOverId, null, 2)}</div> : '')}
- <div className={'text_shadow messageUpdate'} style={{padding: '5px'}} >
- <div className={`updateMessage ${(this.props.messageMode === 'big' ? 'goldFont' : (this.props.messageMode === 'error' ? 'redFont' : ''))}`}>
- {'Message: ' + this.props.message}
- </div>
- </div>
- {/*<div style={{marginLeft: '5px'}}>
- <button className='rpgui-button test_animation' onClick={() => battleReady(this.props.storedState)}>Battle ready</button>
- </div>*/}
- </div>
- </div>
- <div>
- {(this.props.help ? <div className='text_shadow marginTop5'>
- <input className='check' type='radio' name='helpRadio' onChange={() => this.props.dispatch({type: 'SET_HELP_MODE', chatHelpMode: 'chat'})}/>
- <label className='labels'>Chat</label>
- <input className='check' type='radio' name='helpRadio' onChange={() => this.props.dispatch({type: 'SET_HELP_MODE', chatHelpMode: 'hotkeys'})}/>
- <label className='labels'>Hotkeys</label>
- <input className='check' type='radio' name='helpRadio' onChange={() => this.props.dispatch({type: 'SET_HELP_MODE', chatHelpMode: 'types'})}/>
- <label className='labels'>Types</label>
- <input className='check' type='radio' name='helpRadio' onChange={() => this.props.dispatch({type: 'SET_HELP_MODE', chatHelpMode: 'typeBonuses'})}/>
- <label className='labels'>Buffs</label>
- <input className='check' type='radio' name='helpRadio' onChange={() => this.props.dispatch({type: 'SET_HELP_MODE', chatHelpMode: 'damageBoard'})}/>
- <label className='labels'>Damage</label>
- </div>: '')}
- {(!this.props.onGoingBattle && this.props.dmgBoard && Object.keys(this.props.dmgBoard).length > 0 && (this.props.showDmgBoard
- || this.props.chatHelpMode === 'damageBoard') ? <div className='dmgBoardDiv helpText text_shadow'>
- <span className='bold'>Damage Dealt:</span>{this.getDmgBoard(this.props.dmgBoard)}
- </div> : (this.props.onGoingBattle && this.props.prevDmgBoard && Object.keys(this.props.prevDmgBoard).length > 0 && (this.props.showDmgBoard
- || this.props.chatHelpMode === 'damageBoard') ? <div className='dmgBoardDiv helpText text_shadow'>
- <span className='bold'>Damage Dealt Previous Round:</span>{this.getDmgBoard(this.props.prevDmgBoard)}
- </div> : (this.props.help ? this.buildHelp() : '')))}
- </div>
- </div>
- {this.playerStatsDiv()}
- </div>;
- return (<div className='gameDiv'>
- {topBar}
- <div className='flex wholeBody' onKeyDown={(event) => this.handleKeyPress(event)} tabIndex='0'>
- {leftBar}
- {boardDiv}
- {rightSide}
- </div>
- <input className='hidden' type='checkbox' checked={this.props.startBattle} onChange={(this.props.startBattle ? this.startBattleEvent.bind(this)() : () => '')}/>
- </div>);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement