Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- tradeMenuCrossBrowser = false
- inOnlineGame
- inOfflineGame
- inAnyGamePlay = false
- legalLog : any =[]
- // board needs to set up correctly
- // by loading our saved classic board.
- classicGamePlayOn
- searchingClassicLobby
- vsHumanClassic(){
- this.gameType = 1
- if(this.lobbyHumanAI.length > 0){
- for(let i=0; i<this.lobbyHumanAI.length; i++){
- if(this.lobbyHumanAI[i].type=1){
- console.log('type = 1 ')
- console.log('run found match routine')
- this.joinSeek(this.lobbyHumanAI[i], i)
- return;
- }
- // check if its a classic seek, and player score.
- }
- }
- this.searchingClassicLobby = true
- this.classicGamePlayOn = true
- this.newOnlineGamePlayers(0,2)
- // let browser know to set up classic board,
- }
- vsHumanClassic4(){
- this.gameType = 1
- if(this.lobbyHumanAI.length > 0){
- for(let i=0; i<this.lobbyHumanAI.length; i++){
- if(this.lobbyHumanAI[i].type=1){
- console.log('type = 1 ')
- console.log('run found match routine')
- this.joinSeek(this.lobbyHumanAI[i], i)
- return;
- }
- // check if its a classic seek, and player score.
- }
- }
- this.searchingClassicLobby = true
- this.classicGamePlayOn = true
- this.newOnlineGamePlayers(0,4)
- // let browser know to set up classic board,
- }
- instantMatch(){
- // later we will match based on ranking just like chess.
- }
- classicVS(){
- console.log('made it to classic vs ! ')
- }
- classicVSAI
- vsAIClassic(){
- console.log('made it to vs ai')
- this.newOnlineGamePlayers(1,1)
- this.classicGamePlayOn = true
- this.classicVSAI = true
- this.loadBoardClassicOfficial()
- this.databaseService.overlappingPeacesCheck()
- }
- vsAIClassic4(){
- this.newOnlineGamePlayers(3,1)
- this.classicGamePlayOn = true
- this.classicVSAI = true
- this.loadBoardClassicOfficial()
- this.databaseService.overlappingPeacesCheck()
- }
- beginExperiencingClassicHumanGamePlay(){
- this.inOnlineGame = true
- this.inAnyGamePlay = true
- this.loadBoardClassicOfficial()
- }
- beginExperiencingClassicAIGamePlay(){
- this.inOfflineGame = true
- this.inAnyGamePlay = true
- this.loadBoardClassicOfficial()
- }
- beginExperiencingStoryGamePlay(){
- this.inOfflineGame = false
- this.inAnyGamePlay = true
- }
- beginExperiencingOfflineGamePlay(){
- this.turnsBlockChainService.newGame = true
- //this.skillsService.boardDBAtStartSnapShot = JSON.parse(JSON.stringify(this.boardDBList))
- this.genericPlayer = false // for development
- this.testTube = false
- this.inGamePlay = true ;
- this.inOfflineGame = true
- this.inAnyGamePlay = true
- this.deleteAISeek()
- console.log('offline gameplay has begun')
- console.log('this.gameMatchKey')
- console.log(this.tsotsGameMatchKey)
- /// why would this have anything in it ? ?
- // bring back
- let boardListTemp = this.databaseService.boardDBList
- this.loadBoardClassicOfficial()
- this.databaseService.boardDBList$ = this.af.database.list('BOTSGlobalData/tsots/gameManagerDatabase/'+ this.tsotsGameMatchKey + '/boardDBList',
- {
- query: {
- orderByChild : '/peace/layer'
- //limitToFirst : 1
- // orderByKey : true
- // orderByChild: 'size',
- // equalTo: this.sizeSubject
- }
- })
- this.databaseService.boardDBObject$ = this.af.database.object(
- 'BOTSGlobalData/tsots/gameManagerDatabase/'+ this.tsotsGameMatchKey + '/boardDBList')
- this.boardDBList$ = this.databaseService.boardDBList$
- this.boardDBObject$ = this.databaseService.boardDBObject$
- console.log(boardListTemp)
- //console.log(this.tsotsGameMatchKey)
- this.databaseService.gameSideDataList$ = this.af.database.list(
- 'BOTSGlobalData/tsots/gameManagerDatabase/'+ this.tsotsGameMatchKey + '/gameSideDataList')
- this.databaseService.legalLogList$ = this.af.database.list(
- 'BOTSGlobalData/tsots/gameManagerDatabase/'+ this.tsotsGameMatchKey + '/gameSideDataList/legalLogList')
- this.databaseService.subLegalLog = this.legalLogList$.subscribe($ =>
- {
- this.databaseService.legalLogList = $
- ;}
- )
- this.databaseService.gameSideDataObject$ = this.af.database.object(
- 'BOTSGlobalData/tsots/gameManagerDatabase/'+ this.tsotsGameMatchKey + '/gameSideDataList')
- this.databaseService.boardDBList$ = this.af.database.list(
- 'BOTSGlobalData/tsots/gameManagerDatabase/'+ this.tsotsGameMatchKey + '/boardDBList',
- {
- query: {
- orderByChild : '/peace/layer'
- //limitToFirst : 1
- // orderByKey : true
- // orderByChild: 'size',
- // equalTo: this.sizeSubject
- }
- })
- this.databaseService.reSub()
- // load the board you would like to use here depending on the number of players in game.
- // this.gameManagerDatabase$.update(this.tsotsGameMatchKey,{board: this.boardDBList})
- for(let i = 0 ; i < boardListTemp.length ;i ++){
- let key = boardListTemp[i].$key
- boardListTemp[i].peace.key = key
- this.databaseService.boardDBList$.update(key , {peace : boardListTemp[i].peace})
- }
- this.gameManagerDatabase$ = this.af.database.list('BOTSGlobalData/tsots/gameManagerDatabase/')
- this.gameManagerDatabaseObject$ = this.af.database.object('BOTSGlobalData/tsots/gameManagerDatabase/'+ this.tsotsGameMatchKey)
- this.subOX = this.gameManagerDatabaseObject$.subscribe($ =>{
- this.gameManagerDatabaseObject = $
- //console.log($)
- this.playersInGame = this.gameManagerDatabaseObject.playersObject.length
- this.currentTurn = this.gameManagerDatabaseObject.turn
- ///
- if(this.classicVSAI){
- this.gameManagerDatabaseObject.playersObject[0].player = 2
- this.player2name = this.gameManagerDatabaseObject.playersObject[0].email
- this.gameManagerDatabaseObject.playersObject[1].player = 1
- this.player1name = this.gameManagerDatabaseObject.playersObject[1].email
- this.aiArray.push(this.gameManagerDatabaseObject.playersObject[0])
- if(this.gameManagerDatabaseObject.turn == this.gameManagerDatabaseObject.playersObject[0].player){
- console.log('its ais turn right now')
- console.log(this.gameManagerDatabaseObject.playersObject[0])
- this.aiTurnManager(this.gameManagerDatabaseObject.playersObject[0])
- }
- if(this.userService.uid == this.gameManagerDatabaseObject.playersObject[1].uid){
- this.me = this.gameManagerDatabaseObject.playersObject[1]
- }
- }else{
- for(let i = 0 ; i < this.gameManagerDatabaseObject.playersObject.length ; i++ )
- {
- if(this.gameManagerDatabaseObject.playersObject[i].player ==1 ){
- this.player1name = this.gameManagerDatabaseObject.playersObject[i].email
- }
- if(this.gameManagerDatabaseObject.playersObject[i].player ==2 ){
- this.player2name = this.gameManagerDatabaseObject.playersObject[i].email
- }
- if(this.gameManagerDatabaseObject.playersObject[i].player ==3 ){
- this.player3name = this.gameManagerDatabaseObject.playersObject[i].email
- }
- if(this.gameManagerDatabaseObject.playersObject[i].player ==4 ){
- this.player4name = this.gameManagerDatabaseObject.playersObject[i].email
- }
- if(this.gameManagerDatabaseObject.playersObject[i].type ==1 ){
- this.aiArray.push(this.gameManagerDatabaseObject.playersObject[i])
- if(this.gameManagerDatabaseObject.turn == this.gameManagerDatabaseObject.playersObject[i].player){
- console.log('its ais turn right now')
- this.aiTurnManager(this.gameManagerDatabaseObject.playersObject[i])
- }
- }
- if(this.userService.uid == this.gameManagerDatabaseObject.playersObject[i].uid){
- this.me = this.gameManagerDatabaseObject.playersObject[i]
- }
- }
- }
- if(this.gameManagerDatabaseObject.turn == this.me.player){
- //console.log('its my turn right now + this.me ')
- // console.log(this.me)
- this.myTurn = true
- // console.log(this.myTurn)
- }else{
- this.myTurn = false
- }
- })
- this.identifyPeaceControl()
- }
- aiPeaces
- ////
- identifyPeaceControl(){
- console.log('what')
- if(this.gameManagerDatabaseObject){
- if(this.gameManagerDatabaseObject.matchKey === this.userService.uid){
- // run this function anytime a peace is spawned or captured in game?
- // or just inherit from placer at placement!! ;)
- console.log('identifyPeaceControl')
- // console.log(this.gameManagerDatabaseObject)
- for(let o = 0 ; o < this.gameManagerDatabaseObject.playersObject.length ; o++ ) {
- for(let p = 0 ; p< this.databaseService.boardDBList.length ;p ++){
- var spirit = this.databaseService.boardDBList[p].peace;
- if(this.gameManagerDatabaseObject.playersObject[o].type ==1 ){
- if(this.gameManagerDatabaseObject.playersObject[o].player == this.databaseService.boardDBList[p].peace.player ){
- // single player doesn't have game match key
- console.log('ai matches')
- spirit.type = 1
- //console.log(spirit)
- this.databaseService.boardDBList$.update(spirit.key , {peace : spirit})
- }else{
- console.log('no ai matches!')
- spirit.type = 2
- ///console.log(spirit)
- this.databaseService.boardDBList$.update(spirit.key , {peace : spirit})
- }
- //
- }
- }
- }
- }else{
- console.log('not the party instigator ')
- }
- }else{
- console.log('relooping id p c ')
- setTimeout(()=>{ this.identifyPeaceControl() }, 1000);}
- }
- beginExperiencingOnlineGamePlay(){
- this.turnsBlockChainService.newGame = true
- this.genericPlayer = false
- //this.identifyPeaceControl()
- this.inGamePlay = true ;
- this.cancelMenu2softLobby2()
- this.testTube = false
- this.searchingClassicLobby = false
- this.inOnlineGame = true
- this.inAnyGamePlay = true
- console.log('online exp')
- console.log('this.gameMatchKey')
- console.log(this.tsotsGameMatchKey)
- this.skillsService.boardDBAtStartSnapShot = JSON.parse(JSON.stringify(this.boardDBList))
- // currently loads w/e board is already up , but can be made to load w/e based on w/e
- // this.playersInGame =
- let boardListTemp = this.databaseService.boardDBList
- //console.log(boardListTemp)
- //console.log(this.tsotsGameMatchKey)
- /*
- this.databaseService.gameSideDataList$ = this.af.database.list('BOTSGlobalData/tsots/gameManagerDatabase/'+ this.tsotsGameMatchKey + '/gameSideDataList')
- this.databaseService.legalLogList$ = this.af.database.list('BOTSGlobalData/tsots/gameManagerDatabase/'+ this.tsotsGameMatchKey + '/gameSideDataList/legalLogList')
- this.databaseService.subLegalLog = this.legalLogList$.subscribe($ =>
- {
- this.databaseService.legalLogList = $
- ;}
- )
- this.databaseService.gameSideDataObject$ = this.af.database.object('BOTSGlobalData/tsots/gameManagerDatabase/'+ this.tsotsGameMatchKey + '/gameSideDataList')
- */
- this.loadBoardClassicOfficial()
- this.databaseService.boardDBList$ = this.af.database.list('BOTSGlobalData/tsots/gameManagerDatabase/'+ this.tsotsGameMatchKey + '/boardDBList',
- {
- query: {
- orderByChild : '/peace/layer'
- //limitToFirst : 1
- // orderByKey : true
- // orderByChild: 'size',
- // equalTo: this.sizeSubject
- }
- })
- this.databaseService.boardDBObject$ = this.af.database.object(
- 'BOTSGlobalData/tsots/gameManagerDatabase/'+ this.tsotsGameMatchKey + '/boardDBList')
- this.boardDBList$ = this.databaseService.boardDBList$
- this.boardDBObject$ = this.databaseService.boardDBObject$
- this.databaseService.reSub()
- // load the board you would like to use here depending on the number of players in game.
- // this.gameManagerDatabase$.update(this.tsotsGameMatchKey,{board: this.boardDBList})
- for(let i = 0 ; i < boardListTemp.length ;i ++){
- let key = boardListTemp[i].$key
- boardListTemp[i].peace.key = key
- this.databaseService.boardDBList$.update(key , {peace : boardListTemp[i].peace})
- }
- this.experiencingOnlineGamePlay = true
- this.menu2softLobby2 = false
- console.log(' experiencing online gameplay ')
- this.gameManagerDatabase$ = this.af.database.list('BOTSGlobalData/tsots/gameManagerDatabase/')
- this.gameManagerDatabaseObject$ = this.af.database.object('BOTSGlobalData/tsots/gameManagerDatabase/'+ this.tsotsGameMatchKey)
- this.gameManagerDatabaseCrossBrowser$ = this.af.database.list('BOTSGlobalData/tsots/gameManagerDatabase/'+ this.tsotsGameMatchKey)
- this.gameManagerDatabaseCrossBrowserObject$ = this.af.database.object('BOTSGlobalData/tsots/gameManagerDatabase/'+ this.tsotsGameMatchKey + '/crossBrowser')
- this.subCross = this.gameManagerDatabaseCrossBrowserObject$.subscribe($ =>{
- this.gameManagerDatabaseCrossBrowserObject = $
- })
- // this.gameManagerDatabase$.update(item.name,{object: arrOb})
- this.subOX = this.gameManagerDatabaseObject$.subscribe($ =>{
- this.gameManagerDatabaseObject = $
- //console.log($)
- this.playersInGame = this.gameManagerDatabaseObject.playersObject.length
- this.currentTurn = this.gameManagerDatabaseObject.turn
- if(this.gameManagerDatabaseObject.crossBrowser){
- if( this.gameManagerDatabaseObject.crossBrowser.trading == false){
- this.dealPending = false
- this.monopolyTradeMenu = false
- this.counterTradeMenu = false
- //this.tradeRejectedCardTrigger()
- console.log('not trading , cutting trade menus')
- }
- if(this.myTurn == true){
- if(this.gameManagerDatabaseObject.crossBrowser.counterDeal == true){
- if(this.gameManagerDatabaseObject.crossBrowser.counterDeal2 == false){
- console.log('first cross menu trigger click')
- this.dealPending= false
- this.tradeMenuCrossBrowserTriggerClick()
- this.monopolyTradeMenu = false
- this.counterTradeMenu = false
- }}
- }
- // VV this was opening erroneously for player 2 during counter trade wait.
- // now we need all these crazy if conditions to prevent the menu from opening lol.
- // but at least its locked down tight and works now WEW LAD!!!?!
- if(this.myTurn !== true){
- if(this.gameManagerDatabaseObject.crossBrowser.counterDeal2 !== false){
- if(this.gameManagerDatabaseObject.crossBrowser.counterDeal !== true){
- if(this.gameManagerDatabaseObject.crossBrowser.counterDeal2 == true){
- this.gameManagerDatabaseCrossBrowser$.update('crossBrowser',{trading: true })
- console.log('final counter deal tried')
- this.tradeMenuCrossBrowserTriggerClick()
- this.dealPending= false
- this.counterTradeMenu = false
- }
- }
- }}
- if(this.gameManagerDatabaseObject.crossBrowser.trading == true){
- if(this.gameManagerDatabaseObject.crossBrowser.tradeMenu ==! undefined){
- if(this.myTurn !== true){
- // for counter menu do the opposite ...
- if(this.gameManagerDatabaseObject.crossBrowser.tradeMenu == true){
- if(this.tradeMenuCrossBrowser == false ){
- this.gameManagerDatabaseCrossBrowser$.update('crossBrowser',{trading: true })
- // this is to try to stop that menu from opening !!! argggh
- this.gameManagerDatabaseCrossBrowser$.update('crossBrowser',{counterDeal2: false })
- console.log(' we should execute trade menu NOW ')
- if(this.gameManagerDatabaseObject.crossBrowser.trader2){
- this.tradeMenuCrossBrowserTriggerClick()
- this.counterTradeMenu = false
- }
- }
- }
- }
- }
- }
- }
- for(let i = 0 ; i < this.gameManagerDatabaseObject.playersObject.length ; i++ ) {
- // console.log(this.gameManagerDatabaseObject.playersObject[i])
- /// this is something that should continually run , and lets be honest, copared to animation, doesn't
- // take significiant resource and the browser handles our 2d turn based animation extremely well so....
- // anyways. ..
- // this is the html menu cross browser checker.
- /// this doesn't not need to continually run , inside this subscrption, if u need time for it to load
- // just program a simple setTimeout subroutine , thats way more efficient that this nonsense
- if(this.gameManagerDatabaseObject.playersObject[i].player ==1 ){
- this.player1name = this.gameManagerDatabaseObject.playersObject[i].name
- }
- if(this.gameManagerDatabaseObject.playersObject[i].player ==2 ){
- this.player2name = this.gameManagerDatabaseObject.playersObject[i].name
- }
- if(this.gameManagerDatabaseObject.playersObject[i].player ==3 ){
- this.player3name = this.gameManagerDatabaseObject.playersObject[i].name
- }
- if(this.gameManagerDatabaseObject.playersObject[i].player ==4 ){
- this.player4name = this.gameManagerDatabaseObject.playersObject[i].name
- }
- /// sets marker between human and ai peace control
- // this is fine for online, but we need the same thing for offline....
- if(this.gameManagerDatabaseObject.playersObject[i].type ==1 ){
- this.aiArray.push(this.gameManagerDatabaseObject.playersObject[i])
- if(this.gameManagerDatabaseObject.turn == this.gameManagerDatabaseObject.playersObject[i].player){
- console.log('its ais turn right now')
- this.aiTurnManager(this.gameManagerDatabaseObject.playersObject[i])
- }
- }else{
- // pushed is bad do players in game - ai .
- if(this.pushCount < this.playersInGame - this.aiArray.length ){
- console.log('did human array')
- this.humanArray.push(this.gameManagerDatabaseObject.playersObject[i])
- console.log(this.humanArray)
- //this.pushed = true
- this.pushCount += 1
- }
- //come back to this code
- }
- if(this.userService.uid == this.gameManagerDatabaseObject.playersObject[i].uid){
- this.me = this.gameManagerDatabaseObject.playersObject[i]
- }
- }
- if(this.gameManagerDatabaseObject.turn == this.me.player){
- //console.log('its my turn right now + this.me ')
- // console.log(this.me)
- this.myTurn = true
- // console.log(this.myTurn)
- }else{
- this.myTurn = false
- }
- })
- //this.postGameStartArrayFiller()
- }
- pushed = false
- pushCount = 0
- ///turn based, and peace move based logic
- checkBoardPeaceStates(){
- console.log(" pre skelly")
- for(let i= 0; this.boardDBList; i++){
- let sprite = this.boardDBList[i].peace
- if(sprite.hp <= 0){
- console.log(" dead skeleton peace")
- // this.boardDBList$.remove(this.boardDBList[i].peace.key)
- sprite.imageSrc = sprite.otherStates.skeleton.image
- sprite.sourceX = sprite.otherStates.skeleton.sourceX
- sprite.sourceY = sprite.otherStates.skeleton.sourceY
- sprite.player = 0
- // later maybe make un movable?
- // a skeleton with no player affiliation? whoever revives
- // it joins their team?
- // or skeleton can be disposed of destroyed to remove peace completely
- this.boardDBList$.update(sprite.key, {peace : sprite})
- }
- }
- }
- endMyTurn(){
- console.log('current turn')
- if(this.playersInGame){
- this.tsotsAIService.aiOverRun = 0 ;
- this.turnsTaken += 1
- this.databaseService.overlappingPeacesCheck()
- this.turnsBlockChainService.turnsBlockChainIntercept(
- JSON.stringify(this.gameManagerDatabaseObject)
- )
- this.timeBasedEvents()
- if(this.currentTurn < this.playersInGame){
- console.log('current turn')
- console.log(this.currentTurn)
- this.currentTurn += 1
- this.gameManagerDatabase$.update(this.tsotsGameMatchKey,{turn: this.currentTurn})
- }else{
- this.currentTurn = 1
- console.log('current turn')
- console.log(this.currentTurn)
- this.gameManagerDatabase$.update(this.tsotsGameMatchKey,{turn: this.currentTurn})
- }
- }else{
- console.log('players in game not read yet')
- }
- }
- aiEval(){
- this.cancelMonopolyTradeMenu
- }
- aiTurnManager(ai){
- //console.log('managing ARTIFICIAL INTELLIGENCE turn' + ai)
- // someone has to manage ai turns, but not everyone.
- if(this.gameManagerBrowser == true ){
- console.log(' i am the game manager BROWSER ')
- if(this.boardDBList$){
- this.tsotsAIService.mmoAIonlineServiceStart(ai, this.gameManagerDatabase$,
- this.gameManagerDatabaseObject, this.boardDBList$ , this.boardDBList , this.gameWorld, this.playersInGame,
- this.tsotsGameMatchKey , this.currentTurn )
- this.databaseService.overlappingPeacesCheck()
- }else{
- console.log('this observable wasnt ready')
- }
- }else{
- console.log('nacho turn. ')
- }
- }
- myTurnManager(){
- }
- turnManager(){
- // this sees how many players are in game , and manages turn privedges for each
- }
- onlineMatch(){
- this.tsotsLobbyService.joinLobby()
- }
- counterOffer1
- tsotsGameMatchKey
- player
- gameManagerDatabase$
- gameManagerDatabaseMatch$
- gameManagerDatabaseMatch
- gameManagerDatabaseMatchObject$
- gameManagerDatabaseMatchObject
- subGMDO
- subGG
- gameObject
- mmo = false
- aiPlayers
- humanPlayers
- toySwitch
- mmoMatchUp(){
- this.mmo = true
- //console.log('mmoMatchUp')
- //console.log(this.gameManagerDatabaseMatchObject)
- //console.log(this.gameManagerDatabaseMatchObject.object)
- for(let i = 0; i < this.gameManagerDatabaseMatch.length; i++){
- // set player 123, detirmine if its "My turn "
- }
- }
- onlinePlay(){
- this.player1uid = this.tsotsLobbyService.player1uid
- this.player1name=this.tsotsLobbyService.player1name
- this.player2uid=this.tsotsLobbyService.player2uid
- this.player2name = this.tsotsLobbyService.player2name
- this.tsotsGameMatchKey = this.tsotsLobbyService.tsotsGameMatchKey
- this.player = this.tsotsLobbyService.player
- console.log(this.player1name)
- console.log(this.player1uid)
- console.log(this.player2name)
- console.log(this.player2uid)
- this.inGamePlay = true ;
- console.log('gameMatchKey')
- console.log(this.tsotsGameMatchKey)
- // this isn't fast enough to populate this data intime.
- // we will have to have another button???
- // that or an if statement to start looping when we have a game match key.
- this.gameObject = {
- player1uid : this.player1uid,
- player2uid : this.player2uid,
- gameMatchKey : this.tsotsGameMatchKey,
- player : this.player ,
- gameManagerDatabase$ : this.gameManagerDatabase$ ,
- gameManagerDatabaseMatchObject : this.gameManagerDatabaseMatchObject,
- boardDBList : this.boardDBList,
- boardDBList$ : this.boardDBList$
- }
- this.tsotsGameManagerService.totalGameManager(this.gameObject)
- }
- endTurn(){
- this.turnsTaken += 1
- this.timeBasedEvents()
- switch(this.playerTurn){
- case 1:
- console.log('tried to change 1 turn')
- this.gameManagerDatabase$.update(this.tsotsGameMatchKey , {playerTurn : 2})
- break;
- case 2:
- console.log('tried 2 change 2 turn ')
- this.playerTurn = 1
- this.gameManagerDatabase$.update(this.tsotsGameMatchKey , {playerTurn : 1})
- break;
- }
- //this.playerTurn = 2
- //this.startAIturn()
- }
- currentPlayerPeaces
- currentPlayerPeaceInTime
- timeBasedEvents(){
- this.currentPlayerPeaces= []
- // instead of finding human peaces, find the peaces for the person whos turn just ended.
- // fires on end of turns, operates on all peaces on board.
- // perhaps they have an inventory array of turned based events
- // all waiting to be iterated and operated on .
- for(let i = 0 ; i < this.boardDBList.length ;i++){
- if(this.boardDBList[i].peace.player == this.currentTurn ){
- console.log('[i]')
- console.log(this.boardDBList[i].peace.player)
- this.currentPlayerPeaces.push(this.boardDBList[i].peace)
- }}
- for(let i = 0 ; i < this.currentPlayerPeaces.length; i++){
- for(let j =0 ; j< this.currentPlayerPeaces[i].timeBasedEvents.length; j++){
- this.currentPlayerPeaceInTime = this.currentPlayerPeaces[i]
- eval(this.currentPlayerPeaces[i].timeBasedEvents[j].method)
- }
- }
- console.log('in time based events')
- console.log(this.currentTurn)
- console.log(this.currentPlayerPeaces)
- }
- endGame(){
- this.boardDBsideData$.remove()
- this.boardDBsideDataKeyed$.remove()
- this.gameManagerDatabaseMatch$.remove()
- this.userService.userFolderData$.remove() // multiple ai's
- this.matchFolderDataObject = undefined ;
- //
- this.userService.deleteAIuser()
- this.player2uid = null
- this.player2name = null
- this.inGamePlay = false
- this.playerTurn = null
- this.tsotsGameMatchKey = null
- }
- saveBoardCloud(named){
- // we are redoing save load because of mysterious bugs
- //this.boardDBList.boardName = this.boardName
- let banger = []
- for(let i=0; i < this.boardDBList.length;i++){
- console.log(this.boardDBList[i].peace)
- console.log(this.boardDBList[i].$key)
- var sprite = this.boardDBList[i].peace;
- sprite.key = this.boardDBList[i].$key
- banger.push(sprite)
- }
- // here is where dimensions can be saved properly
- let dimension = this.gameWorld
- this.franchiseBoardDatabase$.update(named +'tsots1', { boardDimension :this.gameWorld });
- this.franchiseBoardDatabase$.update(named +'tsots1', { board :banger });
- // very sensitive, this is the only way to put the data
- }
- savedBoardMenuViewCloud
- subC
- eggPantsLobby
- normansDatabase$
- normansDatabase
- subREE
- subUFD
- subUFL
- subMFL
- userFolderDataObject$
- userFolderDataObject
- matchFolderDataObject$
- matchFolderDataObject
- userFolderDataList$
- userFolderDataList
- matchFolderDataList$
- matchFolderDataList
- deleteSeek(item){
- this.normansDatabase$ = this.af.database.list('BOTSGlobalData/lobbyHumanAI/' + item.matchKey)
- this.normansDatabase$.remove()
- this.setLoadCloudLobby()
- //mySubscription.unsubscribe();
- }
- deleteAISeek(){
- this.normansDatabase$ = this.af.database.list('BOTSGlobalData/lobbyHumanAI/' + this.tsotsGameMatchKey)
- this.normansDatabase$.remove()
- }
- total
- // could pass EVAL('db list in qutations.subscribe ') through the cloud.
- // cloud code communication. try, catch for eval(e)errors
- joinSeek(item, i){
- this.userFolderDataList$ = this.af.database.list('BOTSusers/'+ this.userService.uid +'/userFolder/userFolderData/' )
- console.log('join seek')
- // console.log(item)
- // console.log(i)
- let fill = item.seek - 1
- let arrOb = item.object
- let seaKing = item.seeking
- let total = fill - arrOb.length+1
- this.total = total
- //{object : object , seek : humans - 1 , ai : ai , matchKey : this.uid}
- console.log('in seek 1 ')
- let humanObject = { uid: this.userService.uid,
- name: this.userService.uid, type : 2 ,playerTurn : 1,
- gameMatchKey : item.matchKey }
- arrOb.push(humanObject)
- console.log(item)
- console.log('in seek 2')
- this.lobbyHumanAI$.update(item.matchKey,{playersObject: arrOb})
- this.lobbyHumanAI$.update(item.matchKey,{seeking: seaKing - 1})
- console.log('in seek 2 1/2')
- this.matchFolderDataList$ = this.af.database.list('BOTSusers/'+ item.matchKey +'/userFolder/userFolderData/' )
- this.matchFolderDataObject$ = this.af.database.object('BOTSusers/'+ item.matchKey +'/userFolder/userFolderData/' )
- // come get me
- //this.matchFolderDataList$.update('seekState', {state : 72 })
- console.log('in seek 3')
- this.subUFL = this.userFolderDataList$.subscribe($ =>{
- this.userFolderDataList = $
- //console.log($)
- })
- this.subMFL = this.matchFolderDataObject$.subscribe($ =>{
- this.matchFolderDataObject = $
- //console.log($)
- })
- //this.userService.lobbyHumanAI$.update(this.tsotsGameMatchKey, {seek : item.seek -1 })
- console.log(item.object.length + 'length')
- console.log(item.seeking -1 + 'seek')
- console.log('case 53')
- //
- console.log('in seek 4')
- this.userFolderDataList$.update('seekState', {state : 53 })
- this.userFolderDataList$.update('matchKey', {state : item.matchKey})
- this.tsotsGameMatchKey = item.matchKey
- if(item.seeking -1 == 0){
- this.matchFolderDataList$.update('seekState', {state : 72 })
- this.userFolderDataList$.update('seekState', {state : 72 })
- this.lobbyHumanAI$.update(item.matchKey, {middleHuman: false })
- console.log('congratulations all seeks met !, delet this seek. ')
- this.deleteSeek(item)
- // put this 2 matchkey user folder object
- this.toySwitch == 10
- this.tsotsGameMatchKey = item.matchKey
- this.gameManagerDatabase$ = this.af.database.list('BOTSGlobalData/tsots/gameManagerDatabase/')
- for(let i = 0 ;i < arrOb.length; i++){
- arrOb[i].player = i +1
- }
- this.gameManagerDatabase$.update(item.matchKey,{playersObject: arrOb})
- this.gameManagerDatabase$.update(item.matchKey,{turn: 1})
- this.gameManagerDatabase$.update(item.matchKey,{matchKey: item.matchKey})
- this.gameManagerDatabase$.update(item.matchKey,{crossBrowser : {menu1 : 0, menu2: 0}})
- this.cancelChickMenu()
- }else{
- //console.log('message me pls respond. ')
- //console.log(this.matchFolderDataList)
- this.matchFolder()
- }
- }
- matcher = false
- iter = 0
- matchFolder(){
- //console.log('match folder')
- if(this.iter < 100){
- this.iter++
- //console.log(this.matchFolderDataObject)
- // fat arrow preserves "this."
- if(this.matchFolderDataObject !== undefined){
- if(this.matchFolderDataObject.seekState.state == 72){
- console.log('found match')
- this.iter = 101
- this.userFolderDataList$.update('seekState', {state : 72 })
- } setTimeout(()=>{ this.matchFolder() }, 2000);
- }else{
- setTimeout(()=>{ this.matchFolder() }, 2000);
- }
- }else{
- // this iter is too high, pull me from the lobby altogether and tell me join failed.
- }
- }
- subWhy
- setLoadCloud(){
- this.savedBoardMenuViewCloud = []
- for(let i = 0 ; i < this.franchiseBoardDatabase.length; i++){
- let saved = this.franchiseBoardDatabase[i]
- saved.key = saved.$key
- //saved.owner = this.userService.userObject.displayName
- //saved.ownerUID =this.userService.userObject.uid
- this.savedBoardMenuViewCloud.push(saved)
- //console.log(this.savedBoardMenuViewCloud)
- }
- // keep checking lobby 10 times , i dont believe lobby viewcloud is dynamic otherwise.
- }
- savedBoard
- lobbyDatabaseViewCloud
- lobbyHumanAI$
- lobbyHumanAI
- selectedFile
- setLoadCloudLobby(){
- let i = 0
- //console.log('view cloud')
- if(this.gameType=1){
- // classic game seek type . random by rank .
- this.classicVS()
- console.log('set game type mode here! classic = 1, expanse = 2 ')
- return;
- }
- this.lobbyDatabaseViewCloud = []
- this.userObject= this.userService.userObject
- for(let i = 0 ; i < this.lobbyHumanAI.length; i++){
- let saved = this.lobbyHumanAI[i]
- saved.name = saved.$key
- //saved.owner = this.userService.userObject.displayName
- //saved.ownerUID =this.userService.userObject.uid
- this.lobbyDatabaseViewCloud.push(saved)
- this.eggPantsLobby = this.lobbyDatabaseViewCloud
- }
- if(i > 10){
- setTimeout(()=>{ this.matchFolder() }, 9000);
- }
- }
- /////
- submitFile(){
- try{
- for (let selectedFile of [(<HTMLInputElement>document.getElementById('file')).files[0]]) {
- console.log(selectedFile);
- this.selectedFile = selectedFile
- }
- let number = this.classicBoardBuildsJSON.length
- let storageRef = firebase.storage().ref();
- // get length and save the name of file with a number of +`1` last file
- let af = this.af;
- let folder = 'allBoardsJSON/classicBoardBuildsJSON'
- let name = number + 'classicBoard.json' // + number
- let path = `/${folder}/${name}`;
- let user = this.userService.uid
- let time = Date.now()
- var iRef = storageRef.child(path);
- console.log(iRef)
- iRef.put(this.selectedFile).then((snapshot) => {
- console.log('Uploaded a blob or file! Now storing the reference');
- // push with merkle root as the key if new .
- af.database.list(`/${folder}/`).push({ path: path, filename: name ,
- user : user,
- time : time})
- })
- this.parseLoadClassicJSON()
- }catch(e){
- }
- }
- selectedFileRead
- parseLoadClassicJSON(){
- this.selectedFile
- var reader = new FileReader();
- // using fat arrow retains our ".this" scope !
- reader.onload = ()=>{
- var text = reader.result;
- reader.onloadend = () =>{
- this.selectedFileRead = reader.result
- this.JSONtoDBList()
- }
- return reader.result
- }
- reader.readAsText(this.selectedFile);
- }
- designatedBlankPeace
- JSONtoDBList(){
- console.log('json 2 db list.')
- let board = JSON.parse(this.selectedFileRead)
- //console.log(board)
- this.boardDBList$.remove()
- // sometimes, leaves that one off .
- // when paste to rendering board dblist.
- // crazy thing is, this is 40 peaces.
- // and it still only dropped 1 off. ???
- for(var prop in board){
- if(board[prop].peace){
- var sprite = board[prop].peace
- //console.log(sprite)
- this.boardDBList$.update(sprite.key , {peace : sprite})
- }
- //prevents them from robbing our peace list.
- sprite = this.tsotsPeaceService.peaceLegend.holyGhost
- this.boardDBList$.update(sprite.key , {peace : sprite})
- this.boardDBList$.update(sprite.key+1 , {peace : sprite})
- }
- }
- // we are actually going to save no to that node , but
- // to a JSON file . , ergo , we are also going to load from that JSON file
- // because this is HUGE , and doesn't need to be real time.
- downloadBoardForR(i){
- console.log('trying to download. ')
- let sprite = this.tsotsPeaceService.peaceLegend.holyGhost
- this.boardDBObject = this.databaseService.boardDBObject
- for(let i =0 ; i <this.boardDBObject.length; i++){
- if(this.boardDBObject[i].key == sprite.key){
- this.databaseService.boardDBList$.remove(sprite.key)
- }
- if(this.boardDBObject[i].key == sprite.key +1){
- this.databaseService.boardDBList$.remove(sprite.key)
- }
- }
- // if u are serious about using this in "R" your going to have to
- // pre strip the data that u dont actually want
- // like how R doesn't even know how to parse that firebase image data//
- // but we can easily strip that !
- // right now, lets just have botscoin protocool , make us a
- // mini numerai like dataset .
- // so at least tonight we did SOMETHING about intergrating those 2 , after all this.
- let dataString = JSON.stringify([this.boardDBObject]) //this.ConvertToCSV(this.data);
- // converting to "R" readable, only happens on download.
- // ofc if u want to reupload u need to strip these strings maybe.
- //dataString = " boardPeaces -> '[" +dataString + "]'"
- // im about to make a random numerai data maker , right on the botscoin component.
- // to generate me random sets i can test against.
- // also , the block chain
- // will each time generate a random data set , based on a certain correlation
- // save it , and ask the users to find the closest prediction , it will generate based on merkel root
- // and compare.
- console.log(dataString)
- let a = document.createElement("a");
- a.setAttribute('style', 'display:none;');
- document.body.appendChild(a);
- let blob = new Blob([dataString], { type: 'text/csv' });
- let url= window.URL.createObjectURL(blob);
- a.href = url;
- if(i ===0 ){
- a.download = 'boardClassicBuildJSON.csv';
- }
- if(i===1){
- a.download = this.bookNumber +'boardStoryBuild.csv'
- }
- a.click();
- }
- downloadBoard(i){
- console.log('trying to download. ')
- let sprite = this.tsotsPeaceService.peaceLegend.holyGhost
- this.boardDBObject = this.databaseService.boardDBObject
- for(let i =0 ; i <this.boardDBObject.length; i++){
- if(this.boardDBObject[i].key == sprite.key){
- this.databaseService.boardDBList$.remove(sprite.key)
- }
- if(this.boardDBObject[i].key == sprite.key +1){
- this.databaseService.boardDBList$.remove(sprite.key)
- }
- }
- let dataString = JSON.stringify(this.boardDBObject) //this.ConvertToCSV(this.data);
- // converting to "R" readable, only happens on download.
- // ofc if u want to reupload u need to strip these strings maybe.
- //dataString = "'[" +dataString + "]'"
- // im about to make a random numerai data maker , right on the botscoin component.
- // to generate me random sets i can test against.
- // also , the block chain
- // will each time generate a random data set , based on a certain correlation
- // save it , and ask the users to find the closest prediction , it will generate based on merkel root
- // and compare.
- console.log(dataString)
- let a = document.createElement("a");
- a.setAttribute('style', 'display:none;');
- document.body.appendChild(a);
- let blob = new Blob([dataString], { type: 'application/json' });
- let url= window.URL.createObjectURL(blob);
- a.href = url;
- if(i ===0 ){
- a.download = 'boardClassicBuildJSON.json';
- }
- if(i===1){
- a.download = this.bookNumber +'boardStoryBuild.json'
- }
- a.click();
- }
- downloadAllStoryJSON(){
- // just download entire story node from time to time.
- }
- saveBoardClassic(named){
- /// save is totally differe we will be saving an uploaded file
- // then uploading it to be stored.
- // its waaay to much trouble to make a file and store at the sametime apperantly
- // and it would involved hacking around the file reader system , incase u ever feel like doing that.
- // were going to save json with '[]' for easy "R " playersInGame
- // when we load we remove like so :
- /*
- var str = "12345.00";
- str = str.slice(0, -1);
- >>"12345.0"
- var str = "12345.00";
- str = str.slice(0, -2);
- >>"12345."
- to remove first
- str = str.substring(1);
- >>"2345.00"
- obviously jsonstringify "'["+ objectString +"]'"
- */
- console.log("HELLO!??!")
- this.boardName = named
- this.selectedFile = JSON.stringify(this.databaseService.boardDBObject)
- console.log(this.databaseService.boardDBObject)
- this.savingBoardList$ = this.af.database.list('TSOTSLevels/classicBoardBuilds/')
- console.log('this.selectedFile')
- console.log(this.selectedFile)
- this.savingBoardList$.update(named, {board:this.selectedFile})
- this.savingBoardList$.update(named , { boardDimension :this.gameWorld });
- }
- savingBoardList$
- savingBoardDimension
- subBoardList
- bookNumber = 0
- savingBoardDimension$
- saveBoardStory(named){
- this.boardName = named
- for(let i =0 ; i <this.boardDBObject.length; i++){
- if(this.boardDBObject[i].key == this.tsotsPeaceService.peaceLegend.spirit.key){
- this.boardDBList$.remove(this.boardDBObject[i].key)
- }
- if(this.boardDBObject[i].key == this.tsotsPeaceService.peaceLegend.spirit.key +1){
- this.boardDBList$.remove(this.boardDBObject[i].key)
- }}
- this.savingBoardList$ = this.af.database.list('TSOTSLevels/storyLevels/'+this.bookNumber+"/"+ named + '/board' )
- this.savingBoardDimension$= this.af.database.list('TSOTSLevels/storyLevels/'+this.bookNumber )
- // might wanna save up 2 board , then boardDimension
- let banger = []
- for(let i=0; i < this.boardDBList.length;i++){
- console.log(this.boardDBList[i].peace)
- console.log(this.boardDBList[i].$key)
- var sprite = this.boardDBList[i].peace;
- sprite.key = this.boardDBList[i].$key
- this.savingBoardList$.update(sprite.key, {peace :sprite });
- }
- this.savingBoardDimension$.update(named, { boardDimension :this.gameWorld });
- }
- boardListTemp
- boardObjectTemp
- tempObject$
- tempObject
- loadBoardClassic(it,i ){
- let named = it.$key.toString()
- console.log('loading. ')
- this.tempObject$ = this.af.database.object('TSOTSLevels/classicBoardBuilds/'+ named)
- this.boardDBList$.remove()
- this.subBoardList = this.tempObject$.subscribe($ =>{
- this.tempObject = $
- this.databaseService.boardDBList$ = this.af.database.list('developerData/boardDev',
- {
- query: {
- orderByChild : '/peace/layer'
- //limitToFirst : 1
- // orderByKey : true
- // orderByChild: 'size',
- // equalTo: this.sizeSubject
- }
- })
- this.databaseService.boardDBObject$ = this.af.database.object('developerData/boardDev')
- this.boardDBList$ = this.databaseService.boardDBList$
- this.boardDBObject$ = this.databaseService.boardDBObject$
- })
- setTimeout(()=>{this.objectPopulateBoardDBList()
- console.log('this.tempObject.boardDimension')
- console.log(this.tempObject.boardDimension)
- this.gameWorld = this.tempObject.boardDimension
- if(this.gameWorld.width > 10){
- this.canvas.width = this.gameWorld.width*48
- if(this.gameWorld.width> 20){
- this.canvas.width = 20 * 48
- }
- this.spaceHtml = [1]
- }else{
- this.canvas.width = this.gameWorld.width*48
- this.spaceHtml = []
- }
- },1300)
- }
- loadBoardClassicOfficial(){
- console.log('trying to loadBoardClassicOfficial')
- //if players > 2 long board. set var at search.
- //console.log('this.playersInGame')
- //console.log(this.playersInGame)
- // doesn't know yet.
- this.tempObject$ = this.af.database.object('TSOTSLevels/classicBoardBuilds/official/')
- this.databaseService.boardDBList$.remove()
- this.subBoardList = this.tempObject$.subscribe($ =>{
- this.tempObject = $
- // this.databaseService.boardDBList$ = this.af.database.list('developerData/boardDev')
- //this.databaseService.boardDBObject$ = this.af.database.object('developerData/boardDev')
- console.log('switched lists')
- this.boardDBList$ = this.databaseService.boardDBList$
- this.boardDBObject$ = this.databaseService.boardDBObject$
- })
- //comeback
- setTimeout(()=>{this.objectPopulateBoardDBList()
- },1300)
- }
- objectPopulateBoardDBList(){
- let board = JSON.parse(this.tempObject.board)
- console.log('board')
- console.log(board)
- for(var prop in board){
- if(board[prop].peace){
- var sprite = board[prop].peace
- //console.log(sprite)
- if(
- sprite.key[1]=== "1"){
- sprite.player = 1
- }
- if(
- sprite.key[1]=== "2"
- ){
- sprite.player = 2
- }
- this.databaseService.boardDBList$.update(sprite.key , {peace : sprite})
- }
- //prevents them from robbing our peace list.
- sprite = this.tsotsPeaceService.peaceLegend.holyGhost
- this.databaseService.boardDBList$.update(sprite.key , {peace : sprite})
- this.databaseService.boardDBList$.update(sprite.key+1 , {peace : sprite})
- this.databaseService.reSub()
- }
- //setTimeout(()=>{ this.databaseService.overlappingPeacesCheck()},1300)
- }
- loadBoardClassicOfficial4(){
- //if players > 2 long board. set var at search.
- this.tempObject$ = this.af.database.object('TSOTSLevels/classicBoardBuilds/official4/')
- this.subBoardList = this.tempObject$.subscribe($ =>{
- this.tempObject = $
- for(let i = 0 ; i<$.length;i++){
- }
- })
- //comeback
- setTimeout(()=>{
- this.objectPopulateBoardDBList()
- console.log(this.tempObject.boardDimension)
- console.log(this.tempObject.boardDimension)
- if(this.tempObject.boardDimension){
- this.gameWorld = this.tempObject.boardDimension
- if(this.gameWorld.width){
- if(this.gameWorld.width > 10){
- this.canvas.width = this.gameWorld.width*48
- if(this.gameWorld.width> 20){
- this.canvas.width = 20 * 48
- }
- this.spaceHtml = [1]
- }
- }else{
- this.canvas.width = this.gameWorld.width*48
- this.spaceHtml = []
- }
- }
- },1300)
- }
- savingBoardList
- loadingBoardList$
- loadingBoardList
- shoeString
- bookPull
- book
- storyBookChoose(book){
- this.bookPull = true
- console.log('story book')
- this.shoeString = 'TSOTSLevels/storyLevels/' + book
- this.storyLevelsList$ = this.af.database.list(this.shoeString)
- this.subStory = this.storyLevelsList$.subscribe($ =>
- {
- this.storyLevelsList = $
- console.log($)
- })
- this.bookNumber = book
- }
- tempList$
- tempList
- storyMenu
- savedState = []
- saveStoryGameState(){
- let peace
- for(let i = 0 ; i < this.boardDBList$ ; i++){
- peace = this.boardDBList$[i]
- this.userService.userFolderStoryList$.update('storyData',{peace : peace })
- }
- this.userService.userFolderStoryList$.update('storyData',{
- savedState : JSON.stringify(this.boardDBList),
- level : 1,
- gameWorld : this.gameWorld
- })
- }
- storyTriggerClick(){
- // use this menu for development saving board and loading test boards.
- this.storyMenu = true
- this.storyBookChoose(1)
- }
- newStoryMenu
- genderSelect
- newStoryPeaceName
- // get name input, and gender. and create the players janior peace
- // and stor that as the first peace in their peace library
- // instantly able to be manage in peace manager.
- // *you can only go in expanse areas u have unlocked in story mode.
- newSpiritBody(){
- this.storyMenu= false
- this.newStoryMenu = true
- }
- testList$
- createPlayerPeaceDebug(){
- console.log('createPlayerPeace')
- this.blockChain.genericKeyGen()
- let spirit = this.tsotsPeaceService.peaceLegend.spirit
- spirit.inventory = []
- spirit.key = this.blockChain.keyMade
- spirit.owner = this.userService.uid
- spirit.tileXY =[0,5]
- spirit.sourceX = 3 *48
- spirit.sourceY = 0
- spirit.imageSrc = "https://firebasestorage.googleapis.com/v0/b/data-core-0.appspot.com/o/franchisefiles%2Frmmvfiles%2Fimg%2Fcharacters%2FActor1.png?alt=media&token=6c0a8107-96f6-4389-9614-a8ad00bef9b2"
- console.log('spirit')
- console.log(spirit)
- if(this.genderSelect =='male'){
- console.log('setting male')
- spirit.imageSrc = "https://firebasestorage.googleapis.com/v0/b/data-core-0.appspot.com/o/franchisefiles%2Frmmvfiles%2Fimg%2Fcharacters%2FActor1.png?alt=media&token=6c0a8107-96f6-4389-9614-a8ad00bef9b2"
- spirit.sourceX = 2 *48
- spirit.sourceY = 0
- //spirit.player = 1
- console.log('spirit')
- console.log(spirit)
- }
- if(this.genderSelect == 'female'){
- console.log('setting female')
- spirit.imageSrc = "https://firebasestorage.googleapis.com/v0/b/data-core-0.appspot.com/o/franchisefiles%2Frmmvfiles%2Fimg%2Fcharacters%2FActor1.png?alt=media&token=6c0a8107-96f6-4389-9614-a8ad00bef9b2"
- spirit.sourceX = 4 *48
- spirit.sourceY = 0
- }
- this.boardDBList$.update(spirit.key,{peace: spirit})
- let node = []
- node.push(spirit)
- this.userService.userStoryObjectivesList$.update(
- 'testObjective1',{objective : ' clean the farm animals poop! ',
- completed : 'no'}
- )
- this.userService.userFolderStoryList$.update('storyData',{
- peaceLibrary : node, // players peace
- savedState :
- JSON.stringify(
- this.boardDBList
- ),
- savedStateDimension : this.gameWorld
- //' current level with player peace on it '
- //level
- })
- }
- createPlayerPeace(){
- console.log('createPlayerPeace')
- this.newStoryMenu = false
- this.loadBoardStoryMode(this.storyLevelsList[0],0,'farm')
- // actually need to point board db list to user folder "savedState"
- setTimeout(()=>{
- this.createPlayerPeaceDebug()
- // had to move this logic out of the function dunno why !?
- }, 1000);
- this.userService.userFolderStoryList$.update('storyData',{
- level : 1,
- gender :this.genderSelect ,
- peaceName : this.newStoryPeaceName ,
- savedState : 'none',
- playerPeaceKey : this.blockChain.keyMade ,
- //level
- })
- console.log(this.storyLevelsList[1])
- // what array index is first levels level in, thats what "0" is.
- // [1] is what book . 0 would be "base"
- }
- loadStoryGameState(){
- console.log('saved state')
- //
- // cant cut the filler nodes off at save without corrupt boardDBList
- // ofc we could put them back, but lets just load the json from user folder
- // and see how that works .
- try{
- console.log(JSON.parse(this.userService.userFolderStoryObject.storyData.savedState))
- this.tempList = JSON.parse(this.userService.userFolderStoryObject.storyData.savedState)
- this.gameWorld = this.userService.userFolderStoryObject.storyData.savedStateDimension
- if(this.gameWorld.width > 10){
- this.canvas.width = this.gameWorld.width*48
- this.spaceHtml = [1]
- }else{
- this.canvas.width = this.gameWorld.width*48
- this.spaceHtml = []
- }
- // this point should actually set to boardDBList the moment
- // we start a new game.
- // or multiple new games are going to clobber eachother
- // will probably need to do this with classic AI also VV
- this.databaseService.boardDBList$ = this.af.database.list(this.userService.userFolderDBpointer ,
- {
- query: {
- orderByChild : '/peace/layer'
- //limitToFirst : 1
- // orderByKey : true
- // orderByChild: 'size',
- // equalTo: this.sizeSubject
- }
- })
- this.databaseService.boardDBObject$ = this.af.database.object(this.userService.userFolderDBpointer)
- this.databaseService.gameSideDataList$ = this.af.database.list(this.userService.userFolderSideDataListPointer)
- this.databaseService.legalLogList$ = this.af.database.list(this.userService.userFolderLegalLogListPointer)
- this.databaseService.subLegalLog = this.legalLogList$.subscribe($ =>
- {
- this.databaseService.legalLogList = $
- ;}
- )
- this.databaseService.gameSideDataObject$ = this.af.database.object(this.userService.userFolderSideDataListPointer)
- this.populateBoardDBList()
- console.log('apperently theres a file here')}catch(e){
- console.log(e)
- }
- }
- loadBoardStoryJSON(it, i){
- console.log('load it')
- console.log(it)
- this.gameWorld = this.storyLevelsList[i].boardDimension
- console.log('this.gameWorld')
- console.log(this.gameWorld)
- if(this.gameWorld.width > 10){
- this.canvas.width = this.gameWorld.width*48
- this.spaceHtml = [1]
- }else{
- this.canvas.width = this.gameWorld.width*48
- this.spaceHtml = []
- }
- let named = it.$key.toString()
- console.log('loading. ')
- // we will also save json with '[]' if possible, so easier loading in "R"
- // but one thing at a time.
- // obviously we can even move this stuff out into a dedicated service...
- this.tempList$ = this.af.database.list('TSOTSLevels/storyLevelsJSON/'+this.bookNumber + "/"+ named +'/board')
- this.subBoardList = this.tempList$.subscribe($ =>{
- this.tempList = $
- this.databaseService.boardDBList$ = this.af.database.list('developerData/boardDev',
- {
- query: {
- orderByChild : '/peace/layer'
- //limitToFirst : 1
- // orderByKey : true
- // orderByChild: 'size',
- // equalTo: this.sizeSubject
- }
- })
- this.databaseService.boardDBObject$ = this.af.database.object('developerData/boardDev')
- this.populateBoardDBList()
- })
- }
- loadBoardStory(it,i ){
- console.log('load it')
- console.log(it)
- this.gameWorld = this.storyLevelsList[i].boardDimension
- console.log('this.gameWorld')
- console.log(this.gameWorld)
- if(this.gameWorld.width > 10){
- this.canvas.width = this.gameWorld.width*48
- this.spaceHtml = [1]
- }else{
- this.canvas.width = this.gameWorld.width*48
- this.spaceHtml = []
- }
- let named = it.$key.toString()
- console.log('loading. ')
- this.tempList$ = this.af.database.list('TSOTSLevels/storyLevels/'+this.bookNumber + "/"+ named +'/board')
- this.subBoardList = this.tempList$.subscribe($ =>{
- this.tempList = $
- this.databaseService.boardDBList$ = this.af.database.list('developerData/boardDev'
- ,
- {
- query: {
- orderByChild : '/peace/layer'
- //limitToFirst : 1
- // orderByKey : true
- // orderByChild: 'size',
- // equalTo: this.sizeSubject
- }
- })
- this.databaseService.boardDBObject$ = this.af.database.object('developerData/boardDev')
- this.populateBoardDBList()
- })
- }
- loadBoardStoryMode(it,i ,named){
- console.log('load it')
- console.log(it)
- this.gameWorld = this.storyLevelsList[i].boardDimension
- console.log('this.gameWorld')
- console.log(this.gameWorld)
- if(this.gameWorld.width > 10){
- this.canvas.width = this.gameWorld.width*48
- this.spaceHtml = [1]
- }else{
- this.canvas.width = this.gameWorld.width*48
- this.spaceHtml = []
- }
- console.log('loading. ')
- this.tempList$ = this.af.database.list('TSOTSLevels/storyLevels/'+this.bookNumber + "/"+ named +'/board')
- this.subBoardList = this.tempList$.subscribe($ =>{
- this.tempList = $
- this.databaseService.boardDBList$ = this.af.database.list('developerData/boardDev'
- ,
- {
- query: {
- orderByChild : '/peace/layer'
- //limitToFirst : 1
- // orderByKey : true
- // orderByChild: 'size',
- // equalTo: this.sizeSubject
- }
- })
- this.databaseService.boardDBObject$ = this.af.database.object('developerData/boardDev')
- this.populateBoardDBList()
- })
- }
- subRe
- populateBoardDBList(){
- this.boardDBList$.remove()
- for(let i=0; i < this.tempList.length;i++){
- var sprite = this.tempList[i].peace;
- sprite.key = this.tempList[i].$key
- this.boardDBList$.update(sprite.key , {peace : sprite})
- }
- //prevents them from robbing our peace list.
- sprite = this.tsotsPeaceService.peaceLegend.holyGhost
- this.boardDBList$.update(sprite.key , {peace : sprite})
- this.boardDBList$.update(sprite.key+1 , {peace : sprite})
- /*
- this.subRe = this.boardDBList$.subscribe($ =>{
- this.boardDBList = $
- // console.log($)
- })
- */
- this.databaseService.reSub()
- //setTimeout(()=>{ this.databaseService.overlappingPeacesCheck()},2300)
- }
- nodeToDelete$
- deleteStoryLevel(it,i){
- let named = it.$key.toString()
- console.log('loading. ')
- this.nodeToDelete$ = this.af.database.list('TSOTSLevels/storyLevels/'+this.bookNumber + "/"+ named)
- this.nodeToDelete$.remove()
- //this.storyLevelsList$.remove()
- }
- deleteClassicLevel(it,i){
- let named = it.$key.toString()
- console.log('loading. ')
- this.nodeToDelete$ = this.af.database.list('TSOTSLevels/classicBoardBuilds/'+ named )
- this.nodeToDelete$.remove()
- }
- /// i = save number, save made map to database < boards created
- // edit size of board on the fly ,
- // all peaces are moveable character peaces until limited by type.
- saveBoard(named){
- // var aRef = firebase.database ().ref().child ('/BOTSusers/'+this.userService.user +'/boardSaves').push({
- // name : this.boardDBList
- //});
- //doesn't work .
- console.log(named + 'named')
- this.boardName = named
- //this.boardDBList.boardName = this.boardName
- let banger = []
- for(let i=0; i < this.boardDBList.length;i++){
- console.log(this.boardDBList[i].peace)
- console.log(this.boardDBList[i].$key)
- var sprite = this.boardDBList[i].peace;
- sprite.key = this.boardDBList[i].$key
- //sprite.boardName = this.boardName
- //var ugly = {peace : {key:1} , boardName : {boardNameSaved :this.boardName}}
- //ugly.peace = sprite
- //ugly.peace.key = this.boardDBList[i].key
- banger.push(sprite)
- }
- // here is where dimensions can be saved properly
- let dimension = this.gameWorld
- if(this.selectedFolderLoad =1){
- this.franchiseBoardDatabase$.update(this.boardName +'tsots1', { boardDimension :this.gameWorld });
- this.franchiseBoardDatabase$.update(this.boardName+'tsots1', { board :banger });
- }
- if(this.selectedFolderLoad =2 ){
- this.userService.userFolderSavedBoards$.update(this.boardName +'tsots1', { board :banger });
- this.userService.userFolderSavedBoards$.update(this.boardName+'tsots1', { boardDimension :this.gameWorld });
- }
- if(this.selectedFolderLoad = 3 ){
- this.officialStoryBoards$.update(this.boardName+'tsots1', { board :banger });
- this.officialStoryBoards$.update(this.boardName+'tsots1', { boardDimension :this.gameWorld });
- }
- // very sensitive, this is the only way to put the data
- }
- setFolder(n){
- this.selectedFolderLoad = n
- }
- savedBoardMenuView=[]
- savedNames
- userNom
- userID
- userEmail
- userObject
- gummyPhone =[]
- userTest(){
- this.userObject= this.userService.userObject
- console.log(this.userObject)
- console.log(this.userObject.displayName)
- }
- aiNum
- humanNum
- menu2softLobby = false
- aiInGameNumber = 0
- humansInGameNumber = 0
- playersGameNumber = 0
- gameManagerBrowser
- doubleMatch(){
- }
- ////
- newOnlineGamePlayers(ai, human){
- this.gameManagerBrowser = true
- // so player 1 animator can catch state : 72
- this.matchFolderDataObject$ = this.af.database.object('BOTSusers/'+ this.userService.uid +'/userFolder/userFolderData/' )
- this.matchFolderDataList$ = this.af.database.list('BOTSusers/'+ this.userService.uid +'/userFolder/userFolderData/' )
- //
- this.subMFL = this.matchFolderDataObject$.subscribe($ =>{
- this.matchFolderDataObject = $
- })
- this.tsotsGameMatchKey = this.userService.uid
- //
- this.testTube = true
- this.menu2soft = false
- //console.log('players new' + human)
- this.aiNum = parseInt(ai)
- this.humanNum = parseInt(human)
- var sumOne = parseInt(ai) + parseInt(human)
- this.humansInGameNumber = this.aiNum
- this.aiInGameNumber = this.humanNum
- this.playersGameNumber = sumOne
- if(sumOne > 4){
- console.log('too many peaces ' + sumOne )
- this.menu2soft = true
- return;
- }
- //trigger open lobby
- //number = number of human players to connect to .
- if(human> 1 ){
- this.menu2softLobby = true
- this.cancelMenu2soft()
- this.menu2softLobbyView(ai, human)
- this.humansInGameNumber = this.humanNum
- this.aiInGameNumber = this.aiNum
- this.playersGameNumber = sumOne
- console.log('trying lobby service')
- this.tsotsLobbyService.multiJoinLobby(this.aiNum,this.humansInGameNumber,this.playersGameNumber, this.userService.uid , this.userService.userArena$)
- }else{
- this.cancelMenu2soft()
- console.log('1 human only game ')
- this.createAI(ai)
- for(let i = 0 ;i < this.userService.arrOb.length; i++){
- this.userService.arrOb[i].player = i +1
- }
- this.gameManagerDatabase$ = this.af.database.list('BOTSGlobalData/tsots/gameManagerDatabase/')
- //this.playersInGame = this.gameManagerDatabaseObject.playersObject.length
- //this.currentTurn = this.gameManagerDatabaseObject.turn
- this.gameManagerDatabase$.update(this.tsotsGameMatchKey,{matchKey: this.userService.uid})
- this.gameManagerDatabase$.update(this.tsotsGameMatchKey,{turn: 1})
- this.gameManagerDatabase$.update(this.tsotsGameMatchKey,{playersObject: this.userService.arrOb})
- //this.gameManagerDatabase$.update(this.tsotsGameMatchKey,{playersObject: false})
- //this.gameManagerDatabaseObject.crossBrowser.trading == false
- this.aiInGameNumber = this.aiNum
- this.playersGameNumber = sumOne
- this.experiencingOfflineGamePlay = true
- this.beginExperiencingOfflineGamePlay()
- this.normansDatabase$ = this.af.database.list('BOTSGlobalData/lobbyHumanAI/' + this.tsotsGameMatchKey)
- this.normansDatabase$.remove()
- return;
- }
- //this.menu2soft = false
- //
- this.createAI(ai)
- // some ai players will have to be created?
- /// trigger to
- }
- joinExisting(){
- //console.log('lobby object')
- // console.log(this.userService.lobbyHumanAI)
- this.setLoadCloudLobby()
- }
- gameType = 0 /// 1 =classic 2=expanse
- createAI(ai){
- console.log(ai)
- //^keeps track of how many ai in game for turn counter
- // tsotsGameMatchKey will always be this.uid VV
- this.userService.aiFactory(ai, this.userService.uid , this.humansInGameNumber
- , this.gameType
- )
- //ai = number of ai 2 create
- }
- menu2softLobby2
- menu2ai
- menu2human
- menu2softLobbyView(x,y){
- console.log(x + 'ai')
- // create ai, put there name(s) in lobby view
- console.log(y + 'human')
- this.menu2ai = x
- this.menu2human = y
- // seek human
- // x = ai
- //y = human
- let text = 'weirdo'
- if (isNaN(x) || x < 2 || x > 4) { // 4 = limit, makign sure "number" isn't past limit
- text = "Input not valid";
- this.menu2softLobby = false
- //this.menu2soft = true
- } else {
- text = "Input OK";
- }
- console.log(text)
- }
- //menu2softLobby2 = false
- testTube
- createAIopponent(){
- // pass argument for how many u want to create !
- this.userService.createAIuser()
- // added a 1 in the argument
- }
- userArenaObject$
- userArena$
- playerTurn
- gameMatchKey
- inGamePlay
- gameData
- ////----------------- ARTIFICIAL INTELLIGENCE -- atoms genesis protien labratory
- userFolderData$
- userFolderData
- devDebugPeaceMenu
- devDebugPeaceTriggerClick(){
- console.log('devDebugPeaceMenu')
- this.devDebugPeaceMenu = true
- }
- devInput
- keyHold
- devMethod(value){
- this.devInput = value
- console.log('devmeth')
- this.keyHold = this.clickedSprite.key
- console.log(this.clickedSprite.key)
- console.log('devInput')
- console.log(this.devInput)
- // this.clickedSprite.key = this.devInput
- this.boardDBList$.update(this.devInput , {peace : this.clickedSprite})
- this.boardDBList$.remove(this.clickedSprite.key)
- this.cancelDevDebugPeaceMenu()
- }
- cancelDevDebugPeaceMenu(){
- this.devDebugPeaceMenu = false
- }
- debugPeace(){
- }
- tsotsDebug(){
- this.peaceBlockChainService.pushIt('hi')
- // you tell me what player u clicked, and i can have the perpetual animator alert there browsers
- // if we haven't cut that animator off....
- }
- seekDebug(){
- console.log(this.userService.uid )
- console.log(this.me)
- console.log('ai array')
- console.log(this.aiArray)
- }
- aiDebug(){
- console.log('hi')
- console.log(this.boardDBsideDataKeyed.playerTurn)
- console.log('hi')
- console.log(this.boardDBsideDataKeyed)
- console.log('hi')
- console.log(this.playerTurn)
- }
- multiDebug(){
- console.log('multiDebug')
- //console.log(this.userService.userFolderObject)
- console.log('matchComponentInfo')
- //console.log(this.userService.userFolderObject.matchComponentInfo)
- //console.log('this.userService.userFolderObject.matchComponentInfo.gameMatchKey')
- //console.log(this.userService.userFolderObject.matchComponentInfo.gameMatchKey)
- console.log('gameManagerDatabaseMatchObject')
- console.log(this.gameManagerDatabaseMatchObject)
- this.playerTurn = this.gameManagerDatabaseMatchObject.playerTurn
- console.log('subplayer turn')
- console.log(this.playerTurn)
- console.log('its my turn')
- console.log(this.myTurn)
- console.log('this . player')
- console.log(this.player)
- console.log('game manager my turn')
- console.log(this.tsotsGameManagerService.myTurn)
- console.log('game manager service game object')
- console.log(this.gameManagerDatabaseMatchObject)
- }
- boardDBsideDataKeyed$
- boardDBsideDataKeyed
- startAIgame(){
- this.player1uid= this.userService.uid
- this.player1name= this.userService.userObject.displayName
- this.player2uid= this.userService.AIuid
- this.player2name= this.userService.AIname
- // this.player3uid
- //this.player4uid
- this.gameMatchKey = this.userService.uid
- this.playerTurn= 1
- this.inGamePlay = true
- console.log(this.player1uid)
- console.log(this.player2uid)
- //this.loadOfficialStoryBoard()
- this.boardDBsideData$ = this.af.database.list('BOTSGlobalData/boardDBsideData/')
- this.boardDBsideDataKeyed$ = this.af.database.object('BOTSGlobalData/boardDBsideData/'+this.gameMatchKey)
- this.subSDobject = this.boardDBsideDataKeyed$.subscribe(
- $ =>{ this.boardDBsideDataKeyed= $;
- // now update the boardDB from db.
- })
- let totalBoard =[]
- for(let i = 0 ; i < this.boardDBList.length ;i++){
- totalBoard.push(this.boardDBList[i].peace)
- }
- // check board
- // what peaces it owns -- definite peace ownership on gamestart
- // make all availiable moves -- definite availiable moves.. (2 peace actions per turn?)
- // end its turn .
- //this.boardDBsideData$.remove()
- this.boardDBsideData$.update(this.gameMatchKey, {
- player1uid: this.player1uid,
- player2uid: this.player2uid,
- playerTurn : this.playerTurn,
- gameMatchKey : this.player1uid,
- totalBoard : totalBoard
- })
- }
- startAIturn(){
- // probably need to move this into a service before it becomes to dependant
- // on component calls.
- console.log( 'ai turn begins')
- //console.log(this.boardDBList)
- this.tsotsAIService.aiServiceStart(this.boardDBList$,this.boardDBList,
- this.boardDBsideData$, this.boardDBsideDataKeyed,
- this.gameMatchKey, this.gameWorld)
- }
- selectedFolderLoad
- userFolderPetition(){
- // make deletable and change name able. little fab buttons by saved name.
- this.selectedFolderLoad = 1
- this.savedBoardMenuView = []
- console.log('test two')
- this.userObject= this.userService.userObject
- console.log(this.userObject)
- for(let i = 0 ; i < this.userService.userFolderSavedBoards.length; i++){
- let saved = this.userService.userFolderSavedBoards[i]
- saved.name = saved.$key
- //saved.owner = this.userService.userObject.displayName
- //saved.ownerUID =this.userService.userObject.uid
- console.log(saved)
- this.savedBoardMenuView.push(saved)
- }
- this.selectedFolder = this.userService.userFolderSavedBoards
- }
- subEx
- globalFolderPetition(){
- this.selectedFolderLoad = 2
- this.savedBoardMenuView = []
- this.userObject= this.userService.userObject
- this.subEx = this.franchiseBoardDatabase$.subscribe($ =>
- {
- this.franchiseBoardDatabase = $
- for(let i = 0 ; i < this.franchiseBoardDatabase.length; i++){
- let saved = this.franchiseBoardDatabase[i]
- saved.name = saved.$key
- //saved.owner = this.userService.userObject.displayName
- //saved.ownerUID =this.userService.userObject.uid
- this.savedBoardMenuView.push(saved)
- this.selectedFolder = this.franchiseBoardDatabase
- }
- ;}
- )
- }
- selectedFolder
- officialStoryBoard$
- officialStoryBoard
- officialStoryBoards
- subY
- franchiseBoardsPetition(){
- this.selectedFolderLoad = 3
- this.savedBoardMenuView = []
- this.subY = this.officialStoryBoards$.subscribe($ =>
- {
- this.officialStoryBoards = $
- for(let i = 0 ; i < this.officialStoryBoards.length; i++){
- let saved = this.officialStoryBoards[i]
- saved.name = saved.$key
- //saved.owner = this.userService.userObject.displayName
- //saved.ownerUID =this.userService.userObject.uid
- this.savedBoardMenuView.push(saved)
- this.selectedFolder = this.officialStoryBoards
- }
- ;}
- )
- }
- loadOfficialStoryBoard(){
- this.boardDBList$.remove()
- // loads official classic and tsots boards.
- let saved = this.officialStoryBoard[0]
- //console.log(saved)
- for(let i = 0; i<= saved.length; i++){
- var sprite = saved[i]
- this.boardDBList$.update(sprite.key , {peace : sprite})
- }
- this.gameWorld = this.officialStoryBoard[1]
- }
- loadBoard(it){
- this.boardDBList$.remove()
- let saved = this.franchiseBoardDatabase[it].board
- console.log(saved)
- for(let i = 0; i < saved.length; i++){
- var sprite = saved[i]
- console.log(sprite)
- this.boardDBList$.update(sprite.key , {peace : sprite})
- }
- this.gameWorld = this.selectedFolder[it].boardDimension
- console.log(this.selectedFolder[it].boardDimension)
- }
- prophets = {
- john : {
- name : 'john'
- }
- }
- keyRingReturn = []
- sub1
- sub2
- dataList
- testLog(){
- if(this.rangeObject){
- console.log(this.rangeObject)
- }
- }
- resizeCanvas(width, height){
- /// need to fill
- this.canvas.width =width
- this.canvas.height =height
- }
- htmlText
- spaceHtml = []
- wideBoardView(){
- if(this.gameWorld.width <= 10){
- return ;
- }
- if(this.canvas.width !== this.gameWorld.width * 48){
- console.log('wide board')
- this.canvas.width = this.gameWorld.width * 48
- console.log(this.canvas.width)
- this.spaceHtml = [1]
- }else{
- this.canvas.width =10*48
- this.spaceHtml = []
- }
- }
- zoomInCanvas(){
- }
- zoomOutCanvas(){
- }
- resizeGameWorld(){
- // to change size of board
- }
- resizeCanvas2(width, height){
- //take argum based on measurment requirements
- this.canvas2.width =width
- this.canvas2.height =height
- }
- //
- divFontLeft = 233
- divTop = 273 // other wise first div starts off too far off center /
- user
- @ViewChild("doc")
- @ViewChild("menuCanvas")
- menuCanvas
- @ViewChild("inventoryMenuCanvas")
- inventoryMenuCanvas
- @ViewChild("trade1Canvas")
- trade1Canvas
- @ViewChild("trade2Canvas")
- trade2Canvas
- @ViewChild("offer1Canvas")
- offer1Canvas
- @ViewChild("offer2Canvas")
- offer2Canvas
- @ViewChild("still1Canvas")
- still1Canvas
- @ViewChild("still2Canvas")
- still2Canvas
- @ViewChild("offerStill1Canvas")
- offerStill1Canvas
- @ViewChild("offerStill2Canvas")
- offerStill2Canvas
- @ViewChild("counter1Canvas")
- counter1Canvas
- @ViewChild("counter2Canvas")
- counter2Canvas
- @ViewChild("counterOffer1Canvas")
- counterOffer1Canvas
- @ViewChild("counterOffer2Canvas")
- counterOffer2Canvas
- @ViewChild("multiPeaceMenuCanvas")
- multiPeaceMenuCanvas
- @ViewChild("multiLeftClickCanvas")
- multiLeftClickCanvas
- @ViewChild("fakeCanvas")
- fakeCanvas
- @ViewChild("menuTrigger")
- menuTrigger
- @ViewChild("myMenu")
- myMenu
- @ViewChild("menuTrigger2")
- menuTrigger2
- @ViewChild("menu2")
- menu2
- @ViewChild("menuTrigger3")
- menuTrigger3
- @ViewChild("menu3")
- menu3
- @ViewChild("statsMenuTrigger")
- statsMenuTrigger
- @ViewChild("statsMenu")
- statsMenu
- @ViewChild("inventoryMenuTrigger")
- inventoryMenuTrigger
- @ViewChild("inventoryMenu")
- inventoryMenu
- @ViewChild("inventory2MenuTrigger")
- inventory2MenuTrigger
- @ViewChild("inventory2Menu")
- inventory2Menu
- @ViewChild("skillsMenuTrigger")
- skillsMenuTrigger
- @ViewChild("skillsMenu")
- skillsMenu
- @ViewChild("customizeMenuTrigger")
- customizeMenuTrigger
- @ViewChild("customizeMenu")
- customizeMenu
- boardMatrix = []
- menuBool = false
- menuBox
- menuView
- menuMethod
- dialogeBox
- doc
- canvas
- context
- rangeVar
- attacking = false ;
- // handle all the clicks and superficial menus and views,
- // from this component. but most of these things will be done in the game manager?
- menuOptions = []
- player1Avatar = "https://tracker.moodle.org/secure/projectavatar?size=small" ;
- player2Avatar = "https://ecosystem.atlassian.net/secure/projectavatar?pid=17170&avatarId=14500" ;
- player3Avatar = "https://tracker.moodle.org/secure/projectavatar?size=small" ;
- player4Avatar = "https://ecosystem.atlassian.net/secure/projectavatar?pid=17170&avatarId=14500" ;
- spriteObject = {
- imageSrc : null,
- sourceX: 0,
- sourceY: 0,
- sourceWidth: 48,
- sourceHeight: 48,
- x: 0,
- y: 0,
- width: 48,
- height: 48,
- };
- peace2
- peace3
- boardTileCoordinate
- terrainType //can peace move here ? under what conditions ? // are two different terain types possible?
- spriteCursor
- rangeSprite
- rangeObject = {
- right : [],
- left : [],
- up : [],
- down : [],
- rangeArray : []
- }
- animationSprite
- placementSprite
- background
- background2
- gameWorld = {
- x: 0,
- y: 0 ,
- width : 10,
- height: 10,
- }
- camera
- backgroundSprites =[]
- foregroundSprites =[]
- placingCreation
- boardDBList$
- boardDBList = []
- boardDBObject$
- boardDBObject
- peaceMatrix
- menuCanvasOn
- turnMenuCanvasOn(){
- //stop rendering canas
- }
- turnMenuCanvasOff(){
- }
- debug(){
- this.boardDBList$.remove()
- }
- debugList(){
- console.log(this.boardDBList)
- }
- //debugA(){
- //this.boardDBList$.push({ peace: this.tsotsPeaceService.peaceLegend.createPeace2 }); }
- boardMatrixList = []
- tsotsMultiGame(){
- }
- peaceCreation(){
- }
- animationCreation(){
- }
- /*
- userObject ={
- uid : 0,
- email: 0,
- userName: 0,
- phoneNumber: 'for push alerts',
- password : 'for tranfer confirmations'
- }
- */
- userName
- tsotsList$
- tsotsList
- sub3
- debug01(){
- console.log(
- this.userService.user[0].$value);
- console.log(this.userService.user)
- for(var prop in this.userService.user){
- if(this.userService.user[prop].$key = 'userName'){
- console.log('yeah!' + this.userService.user[prop].$value)
- }
- }
- }
- peaceMenu(tile){
- this.imagingSrc = 0 ;
- switch(tile) {
- case 1:
- this.imagingSrc = {sauce:this.tsotsPeaceService.gate1.source,
- height:this.tsotsPeaceService.dungeon_B.height , width:this.tsotsPeaceService.dungeon_B.width}
- break;
- case 2:
- this.imagingSrc = {sauce:this.tsotsPeaceService.gate2.source, height:this.tsotsPeaceService.dungeon_B.height , width:this.tsotsPeaceService.dungeon_B.width}
- break;
- case 3:
- this.imagingSrc = {sauce:this.tsotsPeaceService.chest.source ,
- height:this.tsotsPeaceService.dungeon_B.height , width:this.tsotsPeaceService.dungeon_B.width}
- break;
- case 4:
- this.imagingSrc = {sauce:this.tsotsPeaceService.crystal.source
- ,
- height:this.tsotsPeaceService.dungeon_B.height , width:this.tsotsPeaceService.dungeon_B.width}
- break; case 5:
- this.imagingSrc = {sauce:this.tsotsPeaceService.door1.source ,
- height:this.tsotsPeaceService.dungeon_B.height , width:this.tsotsPeaceService.dungeon_B.width}
- break;
- case 6:
- this.imagingSrc = {sauce:this.tsotsPeaceService.door2.source,
- height:this.tsotsPeaceService.dungeon_B.height , width:this.tsotsPeaceService.dungeon_B.width}
- break; case 7:
- this.imagingSrc = {sauce:this.tsotsPeaceService.flame.source ,
- height:this.tsotsPeaceService.dungeon_B.height , width:this.tsotsPeaceService.dungeon_B.width}
- break;
- case 8:
- this.imagingSrc = {sauce:this.tsotsPeaceService.other1.source ,
- height:this.tsotsPeaceService.dungeon_B.height , width:this.tsotsPeaceService.dungeon_B.width}
- break; case 9:
- this.imagingSrc = {sauce:this.tsotsPeaceService.other2.source ,
- height:this.tsotsPeaceService.dungeon_B.height , width:this.tsotsPeaceService.dungeon_B.width}
- break;
- case 10:
- this.imagingSrc = {sauce:this.tsotsPeaceService.sfDoor1.source ,
- height:this.tsotsPeaceService.dungeon_B.height , width:this.tsotsPeaceService.dungeon_B.width}
- break; case 11:
- this.imagingSrc = {sauce:this.tsotsPeaceService.sfDoor2.source ,
- height:this.tsotsPeaceService.dungeon_B.height , width:this.tsotsPeaceService.dungeon_B.width}
- break;
- case 12:
- this.imagingSrc = {sauce:this.tsotsPeaceService.switch1.source ,
- height:this.tsotsPeaceService.dungeon_B.height , width:this.tsotsPeaceService.dungeon_B.width}
- break;
- case 13:
- this.imagingSrc = {sauce:this.tsotsPeaceService.switch2.source ,
- height:this.tsotsPeaceService.dungeon_B.height , width:this.tsotsPeaceService.dungeon_B.width}
- break;
- case 14:
- this.imagingSrc = {sauce:this.tsotsPeaceService.bigMonster1.source
- ,
- height:this.tsotsPeaceService.dungeon_B.height , width:this.tsotsPeaceService.dungeon_B.width}
- break; case 15:
- this.imagingSrc = {sauce:this.tsotsPeaceService.bigMonster2.source ,
- height:this.tsotsPeaceService.dungeon_B.height , width:this.tsotsPeaceService.dungeon_B.width}
- break;
- case 16:
- this.imagingSrc = {sauce:this.tsotsPeaceService.charactersActor1.source,
- height:this.tsotsPeaceService.dungeon_B.height , width:this.tsotsPeaceService.dungeon_B.width}
- break; case 17:
- this.imagingSrc = {sauce:this.tsotsPeaceService.charactersActor2.source ,
- height:this.tsotsPeaceService.dungeon_B.height , width:this.tsotsPeaceService.dungeon_B.width}
- break;
- case 18:
- this.imagingSrc = {sauce:this.tsotsPeaceService.charactersActor3.source ,
- height:this.tsotsPeaceService.dungeon_B.height , width:this.tsotsPeaceService.dungeon_B.width}
- break; case 19:
- this.imagingSrc = {sauce:this.tsotsPeaceService.damage1.source ,
- height:this.tsotsPeaceService.dungeon_B.height , width:this.tsotsPeaceService.dungeon_B.width}
- break;
- case 20:
- this.imagingSrc = {sauce:this.tsotsPeaceService.damage2.source ,
- height:this.tsotsPeaceService.dungeon_B.height , width:this.tsotsPeaceService.dungeon_B.width}
- break; case 21:
- this.imagingSrc = {sauce:this.tsotsPeaceService.damage3.source ,
- height:this.tsotsPeaceService.dungeon_B.height , width:this.tsotsPeaceService.dungeon_B.width}
- break;
- case 22:
- this.imagingSrc = {sauce:this.tsotsPeaceService.charactersEvil.source ,
- height:this.tsotsPeaceService.dungeon_B.height , width:this.tsotsPeaceService.dungeon_B.width}
- break;
- case 23:
- this.imagingSrc = {sauce:this.tsotsPeaceService.charactersMonster.source ,
- height:this.tsotsPeaceService.dungeon_B.height , width:this.tsotsPeaceService.dungeon_B.width}
- break;
- case 24:
- this.imagingSrc = {sauce:this.tsotsPeaceService.characterNature.source
- ,
- height:this.tsotsPeaceService.dungeon_B.height , width:this.tsotsPeaceService.bigMonster2.width}
- break; case 25:
- this.imagingSrc = {sauce:this.tsotsPeaceService.charactersPeople1.source ,
- height:this.tsotsPeaceService.dungeon_B.height , width:this.tsotsPeaceService.dungeon_B.width}
- break;
- case 26:
- this.imagingSrc = {sauce:this.tsotsPeaceService.charactersPeople2.source,
- height:this.tsotsPeaceService.dungeon_B.height , width:this.tsotsPeaceService.dungeon_B.width}
- break; case 27:
- this.imagingSrc = {sauce:this.tsotsPeaceService.charactersPeople3.source ,
- height:this.tsotsPeaceService.dungeon_B.height , width:this.tsotsPeaceService.dungeon_B.width}
- break;
- case 28:
- this.imagingSrc = {sauce:this.tsotsPeaceService.charctersPeople4.source ,
- height:this.tsotsPeaceService.dungeon_B.height , width:this.tsotsPeaceService.dungeon_B.width}
- break;
- case 29:
- this.imagingSrc = {sauce:this.tsotsPeaceService.vehicle.source ,
- height:this.tsotsPeaceService.dungeon_B.height , width:this.tsotsPeaceService.dungeon_B.width}
- break;
- case 30:
- this.imagingSrc = {sauce:this.tsotsPeaceService.charctersHiTech.source ,
- height:this.tsotsPeaceService.dungeon_B.height , width:this.tsotsPeaceService.dungeon_B.width}
- break;
- default:
- console.log('default')
- }
- }
- deletePeace(){
- this.boardDBList$.remove(this.clickedSprite.key);
- }
- tileMenu(tile) {
- this.imagingSrc = 0 ;
- switch(tile) {
- case 1:
- this.imagingSrc = {sauce:this.tsotsPeaceService.dungeon_A1.source ,
- height:this.tsotsPeaceService.dungeon_B.height , width:this.tsotsPeaceService.dungeon_B.width}
- console.log('boaaaarrararad')
- break;
- case 2:
- this.imagingSrc = {sauce:this.tsotsPeaceService.dungeon_A2.source ,
- height:this.tsotsPeaceService.dungeon_B.height , width:this.tsotsPeaceService.dungeon_B.width}
- break;
- case 3:
- this.imagingSrc = {sauce:this.tsotsPeaceService.dungeon_A4.source ,
- height:this.tsotsPeaceService.dungeon_B.height , width:this.tsotsPeaceService.dungeon_B.width}
- break;
- case 4:
- this.imagingSrc = {sauce:this.tsotsPeaceService.dungeon_A5.source ,
- height:this.tsotsPeaceService.dungeon_B.height , width:this.tsotsPeaceService.dungeon_B.width}
- break; case 5:
- this.imagingSrc = {sauce:this.tsotsPeaceService.dungeon_B.source ,
- height:this.tsotsPeaceService.dungeon_B.height , width:this.tsotsPeaceService.dungeon_B.width}
- break;
- case 6:
- this.imagingSrc = {sauce:this.tsotsPeaceService.dungeon_C.source ,
- height:this.tsotsPeaceService.dungeon_B.height , width:this.tsotsPeaceService.dungeon_B.width}
- break; case 7:
- this.imagingSrc = {sauce:this.tsotsPeaceService.inside_A1.source ,
- height:this.tsotsPeaceService.dungeon_B.height , width:this.tsotsPeaceService.dungeon_B.width}
- break;
- case 8:
- this.imagingSrc = {sauce:this.tsotsPeaceService.inside_A2.source ,
- height:this.tsotsPeaceService.dungeon_B.height , width:this.tsotsPeaceService.dungeon_B.width}
- break;
- case 9:
- this.imagingSrc = {sauce:this.tsotsPeaceService.inside_A4.source ,
- height:this.tsotsPeaceService.dungeon_B.height , width:this.tsotsPeaceService.dungeon_B.width}
- break; case 10:
- this.imagingSrc = {sauce:this.tsotsPeaceService.inside_A5.source ,
- height:this.tsotsPeaceService.dungeon_B.height , width:this.tsotsPeaceService.dungeon_B.width}
- break;
- case 11:
- this.imagingSrc = {sauce:this.tsotsPeaceService.inside_B.source ,
- height:this.tsotsPeaceService.dungeon_B.height , width:this.tsotsPeaceService.dungeon_B.width}
- break; case 12:
- this.imagingSrc = {sauce:this.tsotsPeaceService.inside_C.source ,
- height:this.tsotsPeaceService.dungeon_B.height , width:this.tsotsPeaceService.dungeon_B.width}
- break;
- case 13:
- this.imagingSrc = {sauce:this.tsotsPeaceService.outside_A1.source ,
- height:this.tsotsPeaceService.dungeon_B.height , width:this.tsotsPeaceService.dungeon_B.width}
- break;
- case 14:
- this.imagingSrc = {sauce:this.tsotsPeaceService.outside_A2.source ,
- height:this.tsotsPeaceService.dungeon_B.height , width:this.tsotsPeaceService.dungeon_B.width}
- break;
- case 15:
- this.imagingSrc = {sauce:this.tsotsPeaceService.outside_A3.source ,
- height:this.tsotsPeaceService.dungeon_B.height , width:this.tsotsPeaceService.dungeon_B.width}
- break; case 16:
- this.imagingSrc = {sauce:this.tsotsPeaceService.outside_A4.source ,
- height:this.tsotsPeaceService.dungeon_B.height , width:this.tsotsPeaceService.dungeon_B.width}
- break;
- case 17:
- this.imagingSrc = {sauce:this.tsotsPeaceService.outside_A5.source ,
- height:this.tsotsPeaceService.dungeon_B.height , width:this.tsotsPeaceService.dungeon_B.width}
- break;
- case 18:
- this.imagingSrc = {sauce:this.tsotsPeaceService.outside_B.source ,
- height:this.tsotsPeaceService.dungeon_B.height , width:this.tsotsPeaceService.dungeon_B.width}
- break;
- case 19:
- this.imagingSrc = {sauce:this.tsotsPeaceService.outside_C.source ,
- height:this.tsotsPeaceService.dungeon_B.height , width:this.tsotsPeaceService.dungeon_B.width}
- break; case 20:
- this.imagingSrc = {sauce:this.tsotsPeaceService.sfInsideA4.source ,
- height:this.tsotsPeaceService.dungeon_B.height , width:this.tsotsPeaceService.dungeon_B.width}
- break;
- case 21:
- this.imagingSrc = {sauce:this.tsotsPeaceService.sfInsideB.source ,
- height:this.tsotsPeaceService.dungeon_B.height , width:this.tsotsPeaceService.dungeon_B.width}
- break; case 22:
- this.imagingSrc = {sauce:this.tsotsPeaceService.sfInsideC.source ,
- height:this.tsotsPeaceService.dungeon_B.height , width:this.tsotsPeaceService.dungeon_B.width}
- break;
- case 23:
- this.imagingSrc = {sauce:this.tsotsPeaceService.sfOutside_A3.source ,
- height:this.tsotsPeaceService.dungeon_B.height , width:this.tsotsPeaceService.dungeon_B.width}
- break;
- case 24:
- this.imagingSrc = {sauce:this.tsotsPeaceService.sfOutside_A4.source ,
- height:this.tsotsPeaceService.dungeon_B.height , width:this.tsotsPeaceService.dungeon_B.width}
- break;
- case 25:
- this.imagingSrc = {sauce:this.tsotsPeaceService.sfOutside_A5.source ,
- height:this.tsotsPeaceService.dungeon_B.height , width:this.tsotsPeaceService.dungeon_B.width}
- break; case 26:
- this.imagingSrc = {sauce:this.tsotsPeaceService.sfOutside_B.source ,
- height:this.tsotsPeaceService.dungeon_B.height , width:this.tsotsPeaceService.dungeon_B.width}
- break;
- case 27:
- this.imagingSrc = {sauce:this.tsotsPeaceService.sfOutside_C.source ,
- height:this.tsotsPeaceService.dungeon_B.height , width:this.tsotsPeaceService.dungeon_B.width}
- break; case 28:
- this.imagingSrc = {sauce:this.tsotsPeaceService.world_A1.source ,
- height:this.tsotsPeaceService.dungeon_B.height , width:this.tsotsPeaceService.dungeon_B.width}
- break;
- case 29:
- this.imagingSrc = {sauce:this.tsotsPeaceService.world_A2.source ,
- height:this.tsotsPeaceService.dungeon_B.height , width:this.tsotsPeaceService.dungeon_B.width}
- break; case 30:
- this.imagingSrc = {sauce:this.tsotsPeaceService.world_B.source ,
- height:this.tsotsPeaceService.dungeon_B.height , width:this.tsotsPeaceService.dungeon_B.width}
- break;
- case 31:
- this.imagingSrc = {sauce:this.tsotsPeaceService.world_C.source ,
- height:this.tsotsPeaceService.dungeon_B.height , width:this.tsotsPeaceService.dungeon_B.width}
- break;
- case 32:
- this.imagingSrc = {sauce:this.tsotsPeaceService.world_C.source ,
- height:this.tsotsPeaceService.dungeon_B.height , width:this.tsotsPeaceService.dungeon_B.width}
- break;
- // 2nd canvas needs to be scrollable as well.
- // some stuff comes off map.
- default:
- console.log('default')
- }
- console.log(this.imagingSrc)
- }
- imagingSrc
- officialStoryBoards$
- subOfficial
- boardDBsideData$
- boardDBsideData
- subSD
- boardDBsideDataObject$
- boardDBsideDataObject
- subSDobject
- subTen
- centralBotscoinBlockChainList$
- centralBotscoinBlockChainList
- centralPeaceBlockChainList$
- centralPeaceBlockChainList
- centralTurnsBlockChainList$
- centralTurnsBlockChainList
- subChain
- subChain2
- subChain3
- classicLevelsList$
- classicLevelsList
- storyLevelsList$
- storyLevelsList
- subClassic
- subStory
- subObject
- subBetter
- subClassicJSON
- subAudio
- classicBoardBuildsJSON$
- classicBoardBuildsJSON
- gameSideDataList$
- gameSideDataList
- gameSideDataObject$
- gameSideDataObject
- legalLogList$
- legalLogList
- subAnimate
- boardDBAnimationList$
- boardDBAnimationList
- boardDBAudioList$
- boardDBAudioList
- subLegalLog
- debugVar = 1
- //maybe a global skills
- soundDebug(){
- eval("this.audioService.soundEffectLegend.Attack3.play()")
- //this.audioService.soundEffectLegend.Attack3.play()
- console.log('this.humanArray')
- }
- dedicatedDebugMenu
- dedicatedDebugMenuTrigger(){
- this.dedicatedDebugMenu = true
- console.log('debug result')
- }
- cancelDedicatedDebugMenu(){
- this.dedicatedDebugMenu = false
- }
- debugVar1
- debugArray1 =[]
- dedicatedDebug(){
- console.log('tried.')
- console.log(this.boardDBList.length)
- for(let i = 0 ; i< this.boardDBList.length; i++){
- this.debugArray1.push(this.boardDBList[i].peace)
- }
- console.log('tried.2')
- console.table(this.debugArray1)
- console.log(this.debugArray1)
- }
- ngAfterViewChecked(){
- //console.log(`viewChecked`);
- //this.databaseService.overlappingPeacesCheck()
- // can cut this after it finds boardDBList
- }
- ngOnDestroy(){
- console.log("destroyeR")
- }
- constructor(
- public af: AngularFire ,
- private userService : userService,
- private tsotsLobbyService : tsotsLobbyService ,
- private tsotsGameManagerService : tsotsGameManagerService,
- private tsotsPeaceService : tsotsPeaceService ,
- private tsotsAIService : tsotsAIService,
- private peaceBlockChainService : peaceBlockChainService,
- private turnsBlockChainService :turnsBlockChainService,
- private animationService : animationService,
- public audioService : audioService ,
- private blockChain : blockChain,
- private databaseService : databaseService,
- private skillsService : skillsService
- ){
- //console.log('this is our file!')
- this.gameSideDataList$ = this.databaseService.gameSideDataList$
- this.gameSideDataObject$ = this.databaseService.gameSideDataObject$
- this.boardDBList$ = this.databaseService.boardDBList$
- this.boardDBObject$ = this.databaseService.boardDBObject$
- this.userService.gameValue = 2
- this.userName = this.userService.user
- //console.log(this.userName)
- //console.log('this.userName')
- this.centralBotscoinBlockChainList$ = this.af.database.list('BOTSblockChain/centralBotscoinBlockChain/')
- this.subChain = this.centralBotscoinBlockChainList$.subscribe($ =>
- {
- console.log($)
- this.centralBotscoinBlockChainList = $})
- ////
- this.centralPeaceBlockChainList$ = this.af.database.list('BOTSblockChain/centralPeaceBlockChain/')
- this.subChain2 = this.centralPeaceBlockChainList$.subscribe($ =>
- {
- this.centralPeaceBlockChainList = $})
- this.centralTurnsBlockChainList$ = this.af.database.list('BOTSblockChain/centralTurnsBlockChain/')
- this.subChain3 = this.centralTurnsBlockChainList$.subscribe($ =>
- {
- this.centralTurnsBlockChainList = $})
- this.classicBoardBuildsJSON$ = this.af.database.list('allBoardsJSON/classicBoardBuildsJSON')
- this.subClassicJSON = this.classicBoardBuildsJSON$.subscribe($ =>
- {
- this.classicBoardBuildsJSON = $
- })
- this.classicLevelsList$ = this.af.database.list('TSOTSLevels/classicBoardBuilds/')
- this.subClassic = this.classicLevelsList$.subscribe($ =>
- {
- this.classicLevelsList = $})
- ///
- this.storyLevelsList$ = this.af.database.list('TSOTSLevels/storyLevels/')
- this.subStory = this.storyLevelsList$.subscribe($ =>
- {
- this.storyLevelsList = $})
- this.officialStoryBoards$ = this.af.database.list('BOTSGlobalData/officialStoryBoards')
- this.officialStoryBoard$ = this.af.database.list('BOTSGlobalData/officialStoryBoards/tsots')
- this.boardDBAnimationList$ =this.af.database.list('BOTSGlobalData/boardDBAnimation')
- this.subAnimate = this.boardDBAnimationList$.subscribe($ =>
- {
- this.boardDBAnimationList = $}
- )
- this.boardDBAnimationList$.remove()
- this.boardDBAudioList$ =this.af.database.list('BOTSGlobalData/boardDBAudio')
- this.subAudio = this.boardDBAudioList$.subscribe($ =>
- {
- this.boardDBAudioList = $}
- )
- this.boardDBAudioList$.remove()
- //boardDBAnimationList
- //subAnimate
- /// sometimes this leaves off the last object in the tree for animation
- // solution?? since we are ordering by child.
- // make is so the one that it usually drop off is a blank object
- // we can even do that at wrapper, after it has wrapped all the other peace/
- // and leaves the for loop.
- this.databaseService.boardDBList$ = this.databaseService.boardDBList$
- //
- this.boardDBObject$ = this.databaseService.boardDBObject$
- //
- this.gameManagerDatabase$ = this.af.database.list('BOTSGlobalData/tsots/gameManagerDatabase/')
- this.franchiseBoardDatabase$ = this.af.database.list('BOTSGlobalData/franchiseBoardDatabase/')
- this.subWhy = this.franchiseBoardDatabase$.subscribe($ =>
- {
- this.franchiseBoardDatabase = $})
- ///////
- this.lobbyHumanAI$ = this.af.database.list('BOTSGlobalData/lobbyHumanAI/' )
- this.subTen = this.lobbyHumanAI$.subscribe($ =>
- {
- this.lobbyHumanAI = $
- //console.log(this.lobbyHumanAI)
- return $;
- })
- ///
- this.subOfficial = this.officialStoryBoard$.subscribe($ =>
- {
- this.officialStoryBoard = $ ;})
- // should be a tile layer
- // then a placement layer above that
- /*
- this.animationSprite = Object.create(this.spriteObject)
- this.animationSprite.name = 'animationSprite'
- this.rangeSprite.sourceX = 4* 32
- this.rangeSprite.sourceY = 0 *32
- this.rangeSprite.sourceWidth = 32
- this.rangeSprite.sourceHeight = 32
- this.rangeSprite.tileXY = []
- this.rangeSprite.imageSrc = new Image();
- this.rangeSprite.imageSrc.src = 'https://firebasestorage.googleapis.com/v0/b/bodyoftheson-cloud.appspot.com/o/monster%2Fspritesheet.png?alt=media&token=e5f7458b-04c9-4f15-af39-0d1f29a515ff';
- */
- this.rangeSprite = Object.create(this.spriteObject)
- this.rangeSprite.name = 'rangeSprite'
- this.rangeSprite.sourceX = 4* 32
- this.rangeSprite.sourceY = 0 *32
- this.rangeSprite.sourceWidth = 32
- this.rangeSprite.sourceHeight = 32
- this.rangeSprite.tileXY = []
- this.rangeSprite.imageSrc = new Image();
- this.rangeSprite.imageSrc.src = 'https://firebasestorage.googleapis.com/v0/b/bodyoftheson-cloud.appspot.com/o/monster%2Fspritesheet.png?alt=media&token=e5f7458b-04c9-4f15-af39-0d1f29a515ff';
- /// sprite cursor
- this.spriteCursor = Object.create(this.spriteObject)
- this.spriteCursor.name = 'spirit'
- this.spriteCursor.x = 0
- this.spriteCursor.y = 0
- this.spriteCursor.sourceX = 48 * 9;
- this.spriteCursor.sourceY = 48 * 7 ;
- this.spriteCursor.tileX= 0;
- this.spriteCursor.tileY= 0;
- this.spriteCursor.tileXY = [0,0]
- this.spriteCursor.imageSrc = new Image();
- this.spriteCursor.imageSrc.src = 'https://firebasestorage.googleapis.com/v0/b/data-core-0.appspot.com/o/franchisefiles%2Frmmvfiles%2Fimg%2Fcharacters%2F!Flame.png?alt=media&token=998e0903-8624-448b-9154-a5a2dd4f09f3';
- // console.log(this.background2)
- // clone male
- //clone female
- // give even single player ability to choose gender.
- // which will spawn all same peices but either female or male clone janitor
- //this.backgroundSprites.push(this.background)
- this.foregroundSprites.push(this.spriteCursor)
- // gonna save this in tsots and try "better scrolling"
- this.camera = {
- x:0,
- y:0,
- width : 480,
- height : 480
- };
- }
- ready = false ;
- e
- canvasSpace
- cellClicked
- name = 10
- boardTempHeight = 10
- boardTempWidth = 10
- boardHeight = 10
- boardWidth = 10
- tileHeight = 48
- tileWidth = 48
- tileSet
- spriteSheet
- actor1
- // another name for boards is "rooms" connect 2 10x10 boards and have a 20x10 play room vs arena
- // and 2 more for 2vs2 007golden eye james bonds style
- e2
- UP = 38;
- DOWN = 40;
- RIGHT = 39;
- LEFT = 37;
- camera2={
- x:0,
- y:0,
- width : 480,
- height : 480
- };
- // CAMERA DEDICATED TO DIRECTIONAL KEYS
- @HostListener('window:keydown', ['$event'])
- keydownHandler(event:any){
- //console.log(event.keyCode)
- try{
- switch(event.keyCode)
- {
- case this.UP:
- event.preventDefault()
- this.camera.y -= 48;
- if(this.camera.y < 0){
- this.camera.y=0
- }
- if(this.imagingSrc){
- this.camera2.y -= 48;
- if(this.camera2.y < 0){
- this.camera2.y=0
- }
- }
- // if this
- break;
- case this.DOWN :
- event.preventDefault()
- this.camera.y += 48;
- if(this.camera.y > this.gameWorld.height*48 -480 ){
- this.camera.y=this.gameWorld.height*48 -480
- }
- if(this.imagingSrc){
- this.camera2.y += 48;
- if(this.camera2.y >this.imagingSrc.height - 480){
- this.camera2.y=this.imagingSrc.height - 480
- }
- }
- break;
- case this.LEFT:
- event.preventDefault()
- this.camera.x -= 48;
- if(this.camera.x < 0){
- this.camera.x=0
- }
- if(this.imagingSrc){
- this.camera2.x -= 48;
- if(this.camera2.x < 0){
- this.camera2.x= 0
- }
- }
- break;
- case this.RIGHT :
- event.preventDefault()
- this.camera.x += 48;
- if(this.camera.x > this.gameWorld.width*48 -480){
- this.camera.x = this.gameWorld.width*48 -480
- }
- if(this.imagingSrc){
- this.camera2.x += 48;
- if(this.camera2.x < this.imagingSrc.width -480){
- this.camera2.x= this.imagingSrc.width - 480
- }
- }
- break;
- }
- }catch(e){}
- }
- e6
- cellTouched
- posX
- posY
- // ON MOUSE
- @HostListener('document:mousemove', ['$event'])
- mouseHandler(){
- try{
- // have it follow cell by cell .
- //console.log(event)
- this.e2 = event
- this.e6 = event
- this.canvasSpace = this.canvas.getBoundingClientRect()
- var x = this.e2.x - this.canvasSpace.left +this.camera.x
- var y = this.e2.y - this.canvasSpace.top +this.camera.y
- this.spriteCursor.x = x
- this.spriteCursor.y = y
- this.spriteCursor.tileXY[0] = Math.floor(x/48)
- this.spriteCursor.tileXY[1] = Math.floor(y/48)
- //bounds sprite mouse on screen for camera // this.background.height
- if(this.spriteCursor.tileXY[1]< 0){
- this.spriteCursor.tileXY[1] = 0}
- if(this.spriteCursor.tileXY[1]> this.gameWorld.height){
- this.spriteCursor.tileXY[1] = this.gameWorld.height}
- if(this.spriteCursor.tileXY[0]<0){
- this.spriteCursor.tileXY[0] = 0}
- if(this.spriteCursor.tileXY[0]> this.gameWorld.width){
- this.spriteCursor.tileXY[0] = this.gameWorld.width}
- // now for visualInventoryMenu tooltips
- if(this.canvas3){
- this.canvasSpace3 = this.canvas3.getBoundingClientRect()
- //console.log(this.canvasSpace3)
- this.posX = this.e6.x - this.canvasSpace3.left
- this.posY = this.e6.y - this.canvasSpace3.top
- if(this.e6.x < this.canvasSpace3.left || this.e6.x > this.canvasSpace3.right || this.e6.y < this.canvasSpace3.top || this.e6.y > this.canvasSpace3.bottom){
- // console.log('mouse moved out of canvas 3 bounds')
- // return
- this.inventoryToolTip = false
- this.toolTipValue = null
- }else{
- // this is actually the best way to do it , because if canvas3 isn't loaded ,
- // all this will just get skipped right over ;)
- ///console.log('mouse in the inventory menu. ')
- // somehow map item cell posotion to inventory view index
- var cell =
- [
- Math.floor(this.posX/32 ),
- Math.floor(this.posY/32)
- ];
- this.cellTouched= cell
- //console.log(this.cellTouched)
- this.inventoryToolTip = true
- this.inventoryToolTipTrigger()
- }
- }
- }catch(e){}
- }
- inventoryToolTip
- toolTipValue
- inventoryToolTipTrigger(){
- let i = Math.floor(this.posX/32)
- this.toolTipValue = this.inventoryMenuView[i]
- }
- inventorySubMenu
- visualInventoryXY
- visualInventoryItemClicked
- tradeMenuViewXY
- tradeMenuView2XY
- offer1XY
- offer2XY
- inventoryIndex
- itemDescription
- ////
- ///peace service methods
- ////
- reload(){
- console.log(this.visualInventoryItemClicked)
- }
- inventorySubMenuTrigger(){
- // console.log('inventory submenu')
- //console.log(this.visualInventoryXY[1])
- this.inventoryIndex = Math.floor(this.visualInventoryXY[0])
- //console.log(i)
- this.visualInventoryItemClicked = this.inventoryMenuView[this.inventoryIndex]
- //
- console.log(this.visualInventoryItemClicked)
- this.itemDescription = this.visualInventoryItemClicked.description
- this.inventorySubMenu = true
- }
- e3
- num
- divLeft
- programMenuFake
- programTriggerMenu(){
- this.menuTrigger2.openMenu()
- //this.fakeMenu = true
- //this.programMenuFake = true
- }
- clickTriggerFake
- clickTrigger(){
- console.log('trigger clicked')
- //this.fakeMenu = true
- //this.clickTriggerFake = true
- this.menuTrigger3.openMenu()
- }
- keysIn
- valuesIn =[]
- changeKey$
- changeKey
- sub11
- sub10
- itemChosen
- itemChosen2
- itemChosenIndexNumber
- chosenMenuItem(item, indexNumber ){
- //console.log('chosen menu item')
- //console.log(item)
- //console.log(indexNumber)
- this.itemChosenIndexNumber = indexNumber
- this.itemChosen = item
- }
- itemSubMenu
- itemSubMenuView
- itemSubMenuTrigger(){
- this.itemSubMenu = true
- console.log('current system')
- /// this stuff logs too slow, but maybe it will be there by the time we open menu
- console.log(this.peaceItemChosen)
- //console.log(this.itemChosenIndexNumber)
- this.itemSubMenuView = this.peaceItemChosen.inventory
- }
- peaceItemChosen
- peaceItemChosenIndex
- // get actual clicked item, not menu item.
- chosenPeaceItem(item, index){
- this.peaceItemChosen = item
- this.peaceItemChosenIndex = index
- console.log('chosenPeaceItem')
- console.log(item)
- }
- destroyItem(i , index){
- // obviously u can't just put something in ur inventory and destroy it.
- // especially human beings, or strong enemy.
- // destroy is a awful button for game functionality
- // and there should be a dedicated trash compactor or something
- // that will work on destroying an item based on its HP.
- this.clickedSprite.inventory.splice(index,1)
- this.boardDBList$.update(this.clickedSprite.key,{peace : this.clickedSprite });
- }
- itemUsed(){
- this.inventorySubMenu = false
- }
- destroyVisualItem(){
- this.inventorySubMenu = false
- console.log(this.inventoryIndex)
- this.clickedSprite.inventory.splice(this.inventoryIndex,1)
- this.animateInventory()
- this.boardDBList$.update(this.clickedSprite.key,{peace : this.clickedSprite });
- }
- offer1=[]
- tradeItems1(i, index){
- if(this.offer1){
- this.offer1.push(i)
- this.trader1.inventory.splice(index, 1)
- console.log(this.offer1)
- console.log(this.clickedSprite)
- console.log('EYE')
- console.log(i)
- }else{
- this.offer1 = []
- this.offer1.push(i)
- console.log('EYE')
- console.log(i)
- this.trader1.inventory.splice(index, 1)
- }
- //this.gameManagerDatabaseCrossBrowser$.update('crossBrowser',{trader1: this.trader1})
- this.tradeMenuView = this.trader1.inventory
- this.tradeMenuView2 = this.trader2.inventory
- // instead of this, just submit the deal when your done, and can wait for confirmation or renegotiation
- if(this.inOnlineGame){
- this.gameManagerDatabaseCrossBrowser$.update('crossBrowser',{tradeMenuView: this.tradeMenuView})
- this.gameManagerDatabaseCrossBrowser$.update('crossBrowser',{offer1: this.offer1})////
- }
- }
- offer2 =[]
- // splice off trader inventory after item chosen
- // that will stop double spending
- tradeItems2(i, index){
- if(this.offer2){
- this.offer2.push(i)
- console.log('EYE')
- console.log(i)
- this.trader2.inventory.splice(index, 1)
- console.log(this.offer2)
- }else{
- this.offer2 = []
- this.offer2.push(i);
- console.log('EYE')
- console.log(i)
- this.trader2.inventory.splice(index, 1)
- }
- this.tradeMenuView = this.trader1.inventory
- this.tradeMenuView2 = this.trader2.inventory
- if(this.inOnlineGame){
- //this.gameManagerDatabaseCrossBrowser$.update('crossBrowser',{trader2: this.trader2})
- this.gameManagerDatabaseCrossBrowser$.update('crossBrowser',{tradeMenuView2: this.tradeMenuView2})
- this.gameManagerDatabaseCrossBrowser$.update('crossBrowser',{offer2: this.offer2})
- }
- }
- unOffer1(i,index){
- if(i){
- console.log(this.offer1)
- this.offer1.splice(index,1)
- console.log('unOffer1')
- console.log(this.offer1)
- console.log(i)
- this.trader1.inventory.push(i)
- this.tradeMenuView = this.trader1.inventory
- }
- }
- unOffer2(i,index){
- if(i){
- console.log(this.offer2)
- this.offer2.splice(index,1)
- console.log('unOffer2')
- console.log(this.offer2)
- console.log(i)
- this.trader2.inventory.push(i)
- this.tradeMenuView2 = this.trader2.inventory
- }
- }
- chosenMenuItem2(i,index){
- this.itemChosen2 = i
- console.log(i)
- }
- dealPending = false
- tradingWithAI
- tradingWithOwnPeace
- tryMonopolyDeal(){
- if(this.tradingOnline){
- this.counterOffer1 = false
- this.dealPending = true
- this.trader1.offerBotsCoins = this.offerBotsCoins
- this.trader2.offerBotsCoins2 = this.offerBotsCoins2
- this.gameManagerDatabaseCrossBrowser$.update('crossBrowser',{tradeMenu: true })
- this.gameManagerDatabaseCrossBrowser$.update('crossBrowser',{trader1: this.trader1})
- this.gameManagerDatabaseCrossBrowser$.update('crossBrowser',{trader2: this.trader2 })
- this.gameManagerDatabaseCrossBrowser$.update('crossBrowser',{offer1: this.offer1})
- this.gameManagerDatabaseCrossBrowser$.update('crossBrowser',{offer2: this.offer2})
- this.gameManagerDatabaseCrossBrowser$.update('crossBrowser',{tradeMenuView: this.tradeMenuView})
- this.gameManagerDatabaseCrossBrowser$.update('crossBrowser',{tradeMenuView2: this.tradeMenuView2})
- }
- if(this.tradingWithOwnPeace){
- this.acceptDeal()
- }
- if(this.tradingWithAI){
- console.log('')
- this.tsotsAIService.humanToAiTradeRequest()
- }
- this.tradingOnline
- }
- counterTradeMenu
- counterTradeMenu2
- counterDeal(){
- this.gameManagerDatabaseCrossBrowser$.update('crossBrowser',{tradeMenu: false })
- this.tradeMenuCrossBrowser = false
- this.counterTradeMenu = true
- this.animateCounterDeal()
- }
- canvas14
- canvas15
- canvas16
- canvas17
- context14
- context15
- context16
- context17
- animateCounterDeal(){
- if(this.counter1Canvas){
- //console.log('made it into here')
- this.canvas14 = document.getElementById('counter1Canvas')
- this.context14 = this.canvas14.getContext('2d');
- if(this.tradeMenuView){
- this.canvas14.width = 32*this.tradeMenuView.length;
- this.canvas14.height = 32 ;
- }
- }else{
- console.log('trying to animate counter deal gain')
- setTimeout(()=>{ this.animateCounterDeal() }, 200);
- }
- if(this.counter2Canvas){
- //console.log('made it into here')
- this.canvas15 = document.getElementById('counter2Canvas')
- this.context15 = this.canvas15.getContext('2d');
- if(this.tradeMenuView){
- this.canvas15.width = 32*this.tradeMenuView.length;
- this.canvas15.height = 32 ;
- }
- }else{
- //console.log('trying to animate counter deal gain')
- setTimeout(()=>{ this.animateCounterDeal() }, 200);
- }
- if(this.counterOffer1Canvas){
- //console.log('made it into here')
- this.canvas16 = document.getElementById('counterOffer1Canvas')
- this.context16 = this.canvas16.getContext('2d');
- if(this.tradeMenuView){
- this.canvas16.width = 32*this.tradeMenuView.length;
- this.canvas16.height = 32 ;
- }
- }else{
- // console.log('trying to animate counter deal gain')
- setTimeout(()=>{ this.animateCounterDeal() }, 200);
- }
- if(this.counterOffer2Canvas){
- //console.log('made it into here')
- this.canvas17 = document.getElementById('counterOffer2Canvas')
- this.context17 = this.canvas17.getContext('2d');
- if(this.tradeMenuView){
- this.canvas17.width = 32*this.tradeMenuView.length;
- this.canvas17.height = 32 ;
- }
- }else{
- console.log('trying to animate counter deal gain')
- setTimeout(()=>{ this.animateCounterDeal() }, 200);
- }
- }
- tryCounterDeal(){
- this.trader1.offerBotsCoins = this.offerBotsCoins
- this.trader2.offerBotsCoins2 = this.offerBotsCoins2
- this.dealPending= true
- // this is opposite, if IS my turn , i will beable to receive the counter deal trigger
- // that would simply re open the monopolyTradeMenu and close trade pending menu.
- this.gameManagerDatabaseCrossBrowser$.update('crossBrowser',{trader1: this.trader1})
- this.gameManagerDatabaseCrossBrowser$.update('crossBrowser',{trader2: this.trader2 })
- if(this.offer1){
- this.gameManagerDatabaseCrossBrowser$.update('crossBrowser',{offer1: this.offer1})
- }
- if(this.offer2){
- this.gameManagerDatabaseCrossBrowser$.update('crossBrowser',{offer2: this.offer2})
- }
- this.gameManagerDatabaseCrossBrowser$.update('crossBrowser',{tradeMenuView: this.tradeMenuView})
- this.gameManagerDatabaseCrossBrowser$.update('crossBrowser',{tradeMenuView2: this.tradeMenuView2})
- if(this.myTurn ==! true ){
- this.gameManagerDatabaseCrossBrowser$.update('crossBrowser',{counterDeal: true })
- this.gameManagerDatabaseCrossBrowser$.update('crossBrowser',{counterDeal2: false })
- }
- if(this.myTurn ){
- this.gameManagerDatabaseCrossBrowser$.update('crossBrowser',{counterDeal2: true })
- this.gameManagerDatabaseCrossBrowser$.update('crossBrowser',{counterDeal: false })
- }
- setTimeout(()=>{
- }, 1000);
- }
- acceptDeal(){
- console.log(this.trader1)
- console.log(this.trader2)
- console.log(this.offer1)
- console.log(this.offer2 )
- this.trader1.money += this.offerBotsCoins2
- this.trader2.money += this.offerBotsCoins
- this.trader1.money -= this.offerBotsCoins
- this.trader2.money -= this.offerBotsCoins2
- if(this.offer2){
- for(let i = 0; i < this.offer2.length; i++){
- this.trader1.inventory.push(this.offer2[i])
- }
- }
- if(this.offer1){
- for(let i = 0; i < this.offer1.length; i++){
- this.trader2.inventory.push(this.offer1[i])
- }
- }
- console.log(this.trader1.inventory)
- console.log(this.trader2.inventory)
- this.offer1 = []
- this.offer2 = []
- this.tradeMenuView = []
- this.tradeMenuView = []
- this.boardDBList$.update( this.trader1.key, { peace: this.trader1 });
- this.boardDBList$.update( this.trader2.key, { peace: this.trader2 });
- //
- this.cancelMonopolyTradeMenu()
- if(this.inOnlineGame){
- //
- this.gameManagerDatabaseCrossBrowser$.update('crossBrowser',{trading: false })
- this.gameManagerDatabaseCrossBrowser$.update('crossBrowser',{counterDeal: false })
- this.gameManagerDatabaseCrossBrowser$.update('crossBrowser',{counterDeal2: false })
- this.cancelTradeMenuCrossBrowser()
- }
- }
- dealAccepted
- tryDeal1(){
- this.gameManagerDatabaseCrossBrowser$.update('crossBrowser',{deal1: true})
- // if they dont wanna do the deal, if they are involved in this trade, they can just cancel menu . ..
- // eventually , dont let them trade quantify of items they dont have
- // make both parties agree on trade.
- // which will have to involve database escrow probably...
- // if deal 1 and deal 2 = true execute deal and set them both back to false
- }
- tryDeal2(){
- this.gameManagerDatabaseCrossBrowser$.update('crossBrowser',{deal2: true})
- }
- deal(){
- for(let i = 0; i < this.offer2.length; i++){
- this.trader1.inventory.push(this.offer2[i])
- }
- for(let i = 0; i < this.offer1.length; i++){
- this.trader2.inventory.push(this.offer1[i])
- }
- this.offer1 = []
- this.offer2 = []
- this.tradeMenuView = []
- this.tradeMenuView = []
- this.offerBotsCoins = this.trader1.offerBotsCoins
- this.offerBotsCoins2 = this.trader1.offerBotsCoins2
- this.gameManagerDatabaseCrossBrowser$.update('crossBrowser',{offer1: this.offer1})
- this.gameManagerDatabaseCrossBrowser$.update('crossBrowser',{offer2: this.offer2})
- this.gameManagerDatabaseCrossBrowser$.update('crossBrowser',{tradeMenuView: this.tradeMenuView})
- this.gameManagerDatabaseCrossBrowser$.update('crossBrowser',{tradeMenuView2: this.tradeMenuView2})
- this.gameManagerDatabaseCrossBrowser$.update('crossBrowser',{tradeMenu: false})
- this.boardDBList$.update( this.trader1.key, { peace: this.trader1 });
- this.boardDBList$.update( this.trader2.key, { peace: this.trader2 });
- // eventually , dont let them trade quantify of items they dont have
- // make both parties agree on trade.
- // which will have to involve database escrow probably...
- }
- tradeConfirmed(trader){
- if(
- this.clickedSprite.player = this.clickedSprite.player
- ){
- //just do the trade
- }
- // if items are not real , not valid trade , show message , cancel deal .
- }
- savePeaceCustomizationChanges(iv,i ){
- console.log('saved')
- // turns input into a number , because all are strings
- if(isNaN(iv)){
- }else{
- iv = parseInt(iv)
- }
- this.keysIn = Object.keys(this.clickedSprite)
- this.valuesIn = []
- for(var prop in this.clickedSprite){
- this.valuesIn.push(this.clickedSprite[prop])
- }
- //console.log(iv)
- //console.log('input value')
- //console.log(i)
- //console.log('iterative')
- let keyO = Object.keys(this.clickedSprite)
- let newO = keyO[i]
- let stringO = newO.toString()
- //console.log('new o ')
- //console.log(newO)
- //console.log(keyO[i])
- // console.log('key 0 i ')
- //console.log(this.dataItem.key)
- //console.log(this.clickedSprite)
- //console.log('trying to customize !!!')
- // display wont display updated values !?? they update in db tho?
- // somehow refresh and redisplay !?
- // try rockign with the actual observable$ and just ngFor .$key and .$value in html
- // then push simply
- //console.log('this.changeKey')
- this.changeKey$.update({[stringO] : iv})
- }
- customizePeaceMenu(){
- var key = this.clickedSprite.key
- console.log('subber')
- console.log(this.boardDBList)
- console.log(this.boardDBObject)
- // this is the adress .
- this.changeKey$ = this.af.database.object('BOTSGlobalData/tsots/gameManagerDatabase/'+this.userService.uid+ '/boardDBList/' +this.dataItem.key +'/peace' )
- this.sub10 = this.changeKey$.subscribe($ =>
- {
- this.changeKey = $
- console.log('this.changeKey')
- console.log(this.changeKey)
- this.keysIn = Object.keys(this.changeKey)
- this.valuesIn = []
- for(var prop in this.changeKey){
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement