Advertisement
Guest User

Untitled

a guest
Aug 13th, 2017
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 119.52 KB | None | 0 0
  1.  
  2. tradeMenuCrossBrowser = false
  3.  
  4. inOnlineGame
  5. inOfflineGame
  6. inAnyGamePlay = false
  7.  
  8. legalLog : any =[]
  9.  
  10. // board needs to set up correctly
  11. // by loading our saved classic board.
  12.  
  13. classicGamePlayOn
  14. searchingClassicLobby
  15.  
  16. vsHumanClassic(){
  17. this.gameType = 1
  18.  
  19. if(this.lobbyHumanAI.length > 0){
  20. for(let i=0; i<this.lobbyHumanAI.length; i++){
  21. if(this.lobbyHumanAI[i].type=1){
  22. console.log('type = 1 ')
  23.  
  24. console.log('run found match routine')
  25.  
  26. this.joinSeek(this.lobbyHumanAI[i], i)
  27. return;
  28. }
  29. // check if its a classic seek, and player score.
  30. }
  31. }
  32. this.searchingClassicLobby = true
  33. this.classicGamePlayOn = true
  34.  
  35. this.newOnlineGamePlayers(0,2)
  36.  
  37. // let browser know to set up classic board,
  38. }
  39.  
  40. vsHumanClassic4(){
  41. this.gameType = 1
  42.  
  43. if(this.lobbyHumanAI.length > 0){
  44. for(let i=0; i<this.lobbyHumanAI.length; i++){
  45. if(this.lobbyHumanAI[i].type=1){
  46. console.log('type = 1 ')
  47.  
  48. console.log('run found match routine')
  49.  
  50. this.joinSeek(this.lobbyHumanAI[i], i)
  51. return;
  52. }
  53. // check if its a classic seek, and player score.
  54. }
  55. }
  56. this.searchingClassicLobby = true
  57. this.classicGamePlayOn = true
  58.  
  59. this.newOnlineGamePlayers(0,4)
  60.  
  61. // let browser know to set up classic board,
  62. }
  63.  
  64. instantMatch(){
  65.  
  66. // later we will match based on ranking just like chess.
  67.  
  68. }
  69.  
  70. classicVS(){
  71. console.log('made it to classic vs ! ')
  72. }
  73.  
  74. classicVSAI
  75. vsAIClassic(){
  76.  
  77. console.log('made it to vs ai')
  78. this.newOnlineGamePlayers(1,1)
  79. this.classicGamePlayOn = true
  80.  
  81. this.classicVSAI = true
  82. this.loadBoardClassicOfficial()
  83. this.databaseService.overlappingPeacesCheck()
  84.  
  85. }
  86.  
  87. vsAIClassic4(){
  88. this.newOnlineGamePlayers(3,1)
  89. this.classicGamePlayOn = true
  90.  
  91. this.classicVSAI = true
  92. this.loadBoardClassicOfficial()
  93. this.databaseService.overlappingPeacesCheck()
  94.  
  95. }
  96.  
  97.  
  98. beginExperiencingClassicHumanGamePlay(){
  99. this.inOnlineGame = true
  100. this.inAnyGamePlay = true
  101. this.loadBoardClassicOfficial()
  102. }
  103.  
  104.  
  105. beginExperiencingClassicAIGamePlay(){
  106. this.inOfflineGame = true
  107. this.inAnyGamePlay = true
  108.  
  109. this.loadBoardClassicOfficial()
  110. }
  111.  
  112. beginExperiencingStoryGamePlay(){
  113. this.inOfflineGame = false
  114. this.inAnyGamePlay = true
  115.  
  116.  
  117. }
  118.  
  119. beginExperiencingOfflineGamePlay(){
  120.  
  121. this.turnsBlockChainService.newGame = true
  122.  
  123. //this.skillsService.boardDBAtStartSnapShot = JSON.parse(JSON.stringify(this.boardDBList))
  124.  
  125. this.genericPlayer = false // for development
  126. this.testTube = false
  127. this.inGamePlay = true ;
  128. this.inOfflineGame = true
  129. this.inAnyGamePlay = true
  130.  
  131. this.deleteAISeek()
  132.  
  133. console.log('offline gameplay has begun')
  134. console.log('this.gameMatchKey')
  135. console.log(this.tsotsGameMatchKey)
  136.  
  137. /// why would this have anything in it ? ?
  138.  
  139. // bring back
  140. let boardListTemp = this.databaseService.boardDBList
  141. this.loadBoardClassicOfficial()
  142.  
  143. this.databaseService.boardDBList$ = this.af.database.list('BOTSGlobalData/tsots/gameManagerDatabase/'+ this.tsotsGameMatchKey + '/boardDBList',
  144. {
  145. query: {
  146.  
  147. orderByChild : '/peace/layer'
  148. //limitToFirst : 1
  149. // orderByKey : true
  150. // orderByChild: 'size',
  151. // equalTo: this.sizeSubject
  152. }
  153. })
  154.  
  155. this.databaseService.boardDBObject$ = this.af.database.object(
  156. 'BOTSGlobalData/tsots/gameManagerDatabase/'+ this.tsotsGameMatchKey + '/boardDBList')
  157.  
  158. this.boardDBList$ = this.databaseService.boardDBList$
  159. this.boardDBObject$ = this.databaseService.boardDBObject$
  160.  
  161.  
  162. console.log(boardListTemp)
  163. //console.log(this.tsotsGameMatchKey)
  164.  
  165. this.databaseService.gameSideDataList$ = this.af.database.list(
  166. 'BOTSGlobalData/tsots/gameManagerDatabase/'+ this.tsotsGameMatchKey + '/gameSideDataList')
  167.  
  168. this.databaseService.legalLogList$ = this.af.database.list(
  169. 'BOTSGlobalData/tsots/gameManagerDatabase/'+ this.tsotsGameMatchKey + '/gameSideDataList/legalLogList')
  170.  
  171. this.databaseService.subLegalLog = this.legalLogList$.subscribe($ =>
  172. {
  173. this.databaseService.legalLogList = $
  174.  
  175. ;}
  176. )
  177.  
  178.  
  179. this.databaseService.gameSideDataObject$ = this.af.database.object(
  180. 'BOTSGlobalData/tsots/gameManagerDatabase/'+ this.tsotsGameMatchKey + '/gameSideDataList')
  181.  
  182.  
  183.  
  184.  
  185. this.databaseService.boardDBList$ = this.af.database.list(
  186. 'BOTSGlobalData/tsots/gameManagerDatabase/'+ this.tsotsGameMatchKey + '/boardDBList',
  187. {
  188. query: {
  189.  
  190. orderByChild : '/peace/layer'
  191. //limitToFirst : 1
  192. // orderByKey : true
  193. // orderByChild: 'size',
  194. // equalTo: this.sizeSubject
  195. }
  196. })
  197.  
  198. this.databaseService.reSub()
  199.  
  200.  
  201. // load the board you would like to use here depending on the number of players in game.
  202. // this.gameManagerDatabase$.update(this.tsotsGameMatchKey,{board: this.boardDBList})
  203.  
  204.  
  205. for(let i = 0 ; i < boardListTemp.length ;i ++){
  206. let key = boardListTemp[i].$key
  207.  
  208. boardListTemp[i].peace.key = key
  209.  
  210. this.databaseService.boardDBList$.update(key , {peace : boardListTemp[i].peace})
  211. }
  212.  
  213.  
  214. this.gameManagerDatabase$ = this.af.database.list('BOTSGlobalData/tsots/gameManagerDatabase/')
  215.  
  216. this.gameManagerDatabaseObject$ = this.af.database.object('BOTSGlobalData/tsots/gameManagerDatabase/'+ this.tsotsGameMatchKey)
  217.  
  218.  
  219.  
  220. this.subOX = this.gameManagerDatabaseObject$.subscribe($ =>{
  221. this.gameManagerDatabaseObject = $
  222. //console.log($)
  223.  
  224.  
  225. this.playersInGame = this.gameManagerDatabaseObject.playersObject.length
  226.  
  227. this.currentTurn = this.gameManagerDatabaseObject.turn
  228.  
  229. ///
  230. if(this.classicVSAI){
  231. this.gameManagerDatabaseObject.playersObject[0].player = 2
  232. this.player2name = this.gameManagerDatabaseObject.playersObject[0].email
  233.  
  234. this.gameManagerDatabaseObject.playersObject[1].player = 1
  235. this.player1name = this.gameManagerDatabaseObject.playersObject[1].email
  236.  
  237. this.aiArray.push(this.gameManagerDatabaseObject.playersObject[0])
  238. if(this.gameManagerDatabaseObject.turn == this.gameManagerDatabaseObject.playersObject[0].player){
  239.  
  240.  
  241. console.log('its ais turn right now')
  242.  
  243. console.log(this.gameManagerDatabaseObject.playersObject[0])
  244. this.aiTurnManager(this.gameManagerDatabaseObject.playersObject[0])
  245.  
  246.  
  247. }
  248. if(this.userService.uid == this.gameManagerDatabaseObject.playersObject[1].uid){
  249. this.me = this.gameManagerDatabaseObject.playersObject[1]
  250.  
  251. }
  252.  
  253. }else{
  254.  
  255.  
  256. for(let i = 0 ; i < this.gameManagerDatabaseObject.playersObject.length ; i++ )
  257. {
  258.  
  259. if(this.gameManagerDatabaseObject.playersObject[i].player ==1 ){
  260.  
  261. this.player1name = this.gameManagerDatabaseObject.playersObject[i].email
  262. }
  263. if(this.gameManagerDatabaseObject.playersObject[i].player ==2 ){
  264.  
  265. this.player2name = this.gameManagerDatabaseObject.playersObject[i].email
  266. }
  267. if(this.gameManagerDatabaseObject.playersObject[i].player ==3 ){
  268.  
  269. this.player3name = this.gameManagerDatabaseObject.playersObject[i].email
  270. }
  271. if(this.gameManagerDatabaseObject.playersObject[i].player ==4 ){
  272.  
  273. this.player4name = this.gameManagerDatabaseObject.playersObject[i].email
  274. }
  275.  
  276.  
  277.  
  278.  
  279. if(this.gameManagerDatabaseObject.playersObject[i].type ==1 ){
  280.  
  281.  
  282.  
  283. this.aiArray.push(this.gameManagerDatabaseObject.playersObject[i])
  284. if(this.gameManagerDatabaseObject.turn == this.gameManagerDatabaseObject.playersObject[i].player){
  285.  
  286.  
  287. console.log('its ais turn right now')
  288. this.aiTurnManager(this.gameManagerDatabaseObject.playersObject[i])
  289. }
  290. }
  291.  
  292. if(this.userService.uid == this.gameManagerDatabaseObject.playersObject[i].uid){
  293. this.me = this.gameManagerDatabaseObject.playersObject[i]
  294.  
  295. }
  296. }
  297. }
  298.  
  299. if(this.gameManagerDatabaseObject.turn == this.me.player){
  300. //console.log('its my turn right now + this.me ')
  301. // console.log(this.me)
  302. this.myTurn = true
  303. // console.log(this.myTurn)
  304. }else{
  305. this.myTurn = false
  306. }
  307.  
  308.  
  309. })
  310. this.identifyPeaceControl()
  311. }
  312.  
  313. aiPeaces
  314.  
  315.  
  316.  
  317.  
  318. ////
  319. identifyPeaceControl(){
  320.  
  321. console.log('what')
  322.  
  323.  
  324. if(this.gameManagerDatabaseObject){
  325.  
  326. if(this.gameManagerDatabaseObject.matchKey === this.userService.uid){
  327.  
  328.  
  329. // run this function anytime a peace is spawned or captured in game?
  330.  
  331. // or just inherit from placer at placement!! ;)
  332.  
  333. console.log('identifyPeaceControl')
  334. // console.log(this.gameManagerDatabaseObject)
  335.  
  336.  
  337.  
  338. for(let o = 0 ; o < this.gameManagerDatabaseObject.playersObject.length ; o++ ) {
  339.  
  340.  
  341. for(let p = 0 ; p< this.databaseService.boardDBList.length ;p ++){
  342.  
  343. var spirit = this.databaseService.boardDBList[p].peace;
  344.  
  345. if(this.gameManagerDatabaseObject.playersObject[o].type ==1 ){
  346.  
  347.  
  348. if(this.gameManagerDatabaseObject.playersObject[o].player == this.databaseService.boardDBList[p].peace.player ){
  349.  
  350. // single player doesn't have game match key
  351.  
  352. console.log('ai matches')
  353. spirit.type = 1
  354. //console.log(spirit)
  355.  
  356.  
  357.  
  358. this.databaseService.boardDBList$.update(spirit.key , {peace : spirit})
  359.  
  360. }else{
  361. console.log('no ai matches!')
  362. spirit.type = 2
  363. ///console.log(spirit)
  364.  
  365. this.databaseService.boardDBList$.update(spirit.key , {peace : spirit})
  366. }
  367.  
  368.  
  369. //
  370. }
  371.  
  372.  
  373. }
  374.  
  375.  
  376. }
  377.  
  378. }else{
  379. console.log('not the party instigator ')
  380. }
  381.  
  382. }else{
  383.  
  384. console.log('relooping id p c ')
  385. setTimeout(()=>{ this.identifyPeaceControl() }, 1000);}
  386.  
  387.  
  388. }
  389.  
  390.  
  391.  
  392.  
  393. beginExperiencingOnlineGamePlay(){
  394.  
  395.  
  396. this.turnsBlockChainService.newGame = true
  397.  
  398. this.genericPlayer = false
  399.  
  400. //this.identifyPeaceControl()
  401.  
  402. this.inGamePlay = true ;
  403. this.cancelMenu2softLobby2()
  404. this.testTube = false
  405. this.searchingClassicLobby = false
  406. this.inOnlineGame = true
  407. this.inAnyGamePlay = true
  408. console.log('online exp')
  409. console.log('this.gameMatchKey')
  410. console.log(this.tsotsGameMatchKey)
  411.  
  412. this.skillsService.boardDBAtStartSnapShot = JSON.parse(JSON.stringify(this.boardDBList))
  413. // currently loads w/e board is already up , but can be made to load w/e based on w/e
  414. // this.playersInGame =
  415. let boardListTemp = this.databaseService.boardDBList
  416.  
  417.  
  418. //console.log(boardListTemp)
  419. //console.log(this.tsotsGameMatchKey)
  420.  
  421. /*
  422. this.databaseService.gameSideDataList$ = this.af.database.list('BOTSGlobalData/tsots/gameManagerDatabase/'+ this.tsotsGameMatchKey + '/gameSideDataList')
  423. this.databaseService.legalLogList$ = this.af.database.list('BOTSGlobalData/tsots/gameManagerDatabase/'+ this.tsotsGameMatchKey + '/gameSideDataList/legalLogList')
  424. this.databaseService.subLegalLog = this.legalLogList$.subscribe($ =>
  425. {
  426. this.databaseService.legalLogList = $
  427.  
  428. ;}
  429. )
  430. this.databaseService.gameSideDataObject$ = this.af.database.object('BOTSGlobalData/tsots/gameManagerDatabase/'+ this.tsotsGameMatchKey + '/gameSideDataList')
  431.  
  432. */
  433.  
  434. this.loadBoardClassicOfficial()
  435.  
  436.  
  437.  
  438.  
  439. this.databaseService.boardDBList$ = this.af.database.list('BOTSGlobalData/tsots/gameManagerDatabase/'+ this.tsotsGameMatchKey + '/boardDBList',
  440. {
  441. query: {
  442.  
  443. orderByChild : '/peace/layer'
  444. //limitToFirst : 1
  445. // orderByKey : true
  446. // orderByChild: 'size',
  447. // equalTo: this.sizeSubject
  448. }
  449. })
  450.  
  451.  
  452. this.databaseService.boardDBObject$ = this.af.database.object(
  453. 'BOTSGlobalData/tsots/gameManagerDatabase/'+ this.tsotsGameMatchKey + '/boardDBList')
  454.  
  455. this.boardDBList$ = this.databaseService.boardDBList$
  456. this.boardDBObject$ = this.databaseService.boardDBObject$
  457.  
  458.  
  459.  
  460. this.databaseService.reSub()
  461.  
  462.  
  463. // load the board you would like to use here depending on the number of players in game.
  464. // this.gameManagerDatabase$.update(this.tsotsGameMatchKey,{board: this.boardDBList})
  465.  
  466.  
  467. for(let i = 0 ; i < boardListTemp.length ;i ++){
  468. let key = boardListTemp[i].$key
  469.  
  470. boardListTemp[i].peace.key = key
  471.  
  472. this.databaseService.boardDBList$.update(key , {peace : boardListTemp[i].peace})
  473. }
  474.  
  475.  
  476.  
  477. this.experiencingOnlineGamePlay = true
  478. this.menu2softLobby2 = false
  479.  
  480. console.log(' experiencing online gameplay ')
  481. this.gameManagerDatabase$ = this.af.database.list('BOTSGlobalData/tsots/gameManagerDatabase/')
  482.  
  483. this.gameManagerDatabaseObject$ = this.af.database.object('BOTSGlobalData/tsots/gameManagerDatabase/'+ this.tsotsGameMatchKey)
  484.  
  485. this.gameManagerDatabaseCrossBrowser$ = this.af.database.list('BOTSGlobalData/tsots/gameManagerDatabase/'+ this.tsotsGameMatchKey)
  486.  
  487. this.gameManagerDatabaseCrossBrowserObject$ = this.af.database.object('BOTSGlobalData/tsots/gameManagerDatabase/'+ this.tsotsGameMatchKey + '/crossBrowser')
  488.  
  489.  
  490. this.subCross = this.gameManagerDatabaseCrossBrowserObject$.subscribe($ =>{
  491. this.gameManagerDatabaseCrossBrowserObject = $
  492. })
  493.  
  494. // this.gameManagerDatabase$.update(item.name,{object: arrOb})
  495. this.subOX = this.gameManagerDatabaseObject$.subscribe($ =>{
  496. this.gameManagerDatabaseObject = $
  497. //console.log($)
  498.  
  499.  
  500. this.playersInGame = this.gameManagerDatabaseObject.playersObject.length
  501.  
  502. this.currentTurn = this.gameManagerDatabaseObject.turn
  503.  
  504. if(this.gameManagerDatabaseObject.crossBrowser){
  505. if( this.gameManagerDatabaseObject.crossBrowser.trading == false){
  506. this.dealPending = false
  507. this.monopolyTradeMenu = false
  508.  
  509. this.counterTradeMenu = false
  510. //this.tradeRejectedCardTrigger()
  511. console.log('not trading , cutting trade menus')
  512. }
  513.  
  514.  
  515. if(this.myTurn == true){
  516. if(this.gameManagerDatabaseObject.crossBrowser.counterDeal == true){
  517. if(this.gameManagerDatabaseObject.crossBrowser.counterDeal2 == false){
  518.  
  519. console.log('first cross menu trigger click')
  520. this.dealPending= false
  521. this.tradeMenuCrossBrowserTriggerClick()
  522. this.monopolyTradeMenu = false
  523.  
  524.  
  525. this.counterTradeMenu = false
  526. }}
  527.  
  528.  
  529. }
  530.  
  531. // VV this was opening erroneously for player 2 during counter trade wait.
  532. // now we need all these crazy if conditions to prevent the menu from opening lol.
  533. // but at least its locked down tight and works now WEW LAD!!!?!
  534.  
  535. if(this.myTurn !== true){
  536.  
  537. if(this.gameManagerDatabaseObject.crossBrowser.counterDeal2 !== false){
  538. if(this.gameManagerDatabaseObject.crossBrowser.counterDeal !== true){
  539. if(this.gameManagerDatabaseObject.crossBrowser.counterDeal2 == true){
  540. this.gameManagerDatabaseCrossBrowser$.update('crossBrowser',{trading: true })
  541.  
  542. console.log('final counter deal tried')
  543. this.tradeMenuCrossBrowserTriggerClick()
  544.  
  545. this.dealPending= false
  546. this.counterTradeMenu = false
  547.  
  548. }
  549. }
  550. }}
  551. if(this.gameManagerDatabaseObject.crossBrowser.trading == true){
  552. if(this.gameManagerDatabaseObject.crossBrowser.tradeMenu ==! undefined){
  553. if(this.myTurn !== true){
  554. // for counter menu do the opposite ...
  555.  
  556. if(this.gameManagerDatabaseObject.crossBrowser.tradeMenu == true){
  557. if(this.tradeMenuCrossBrowser == false ){
  558.  
  559. this.gameManagerDatabaseCrossBrowser$.update('crossBrowser',{trading: true })
  560.  
  561. // this is to try to stop that menu from opening !!! argggh
  562. this.gameManagerDatabaseCrossBrowser$.update('crossBrowser',{counterDeal2: false })
  563.  
  564. console.log(' we should execute trade menu NOW ')
  565.  
  566. if(this.gameManagerDatabaseObject.crossBrowser.trader2){
  567.  
  568. this.tradeMenuCrossBrowserTriggerClick()
  569. this.counterTradeMenu = false
  570. }
  571. }
  572. }
  573. }
  574.  
  575. }
  576.  
  577. }
  578.  
  579. }
  580.  
  581.  
  582. for(let i = 0 ; i < this.gameManagerDatabaseObject.playersObject.length ; i++ ) {
  583. // console.log(this.gameManagerDatabaseObject.playersObject[i])
  584.  
  585.  
  586.  
  587. /// this is something that should continually run , and lets be honest, copared to animation, doesn't
  588. // take significiant resource and the browser handles our 2d turn based animation extremely well so....
  589. // anyways. ..
  590. // this is the html menu cross browser checker.
  591.  
  592.  
  593. /// this doesn't not need to continually run , inside this subscrption, if u need time for it to load
  594. // just program a simple setTimeout subroutine , thats way more efficient that this nonsense
  595.  
  596.  
  597.  
  598.  
  599.  
  600. if(this.gameManagerDatabaseObject.playersObject[i].player ==1 ){
  601.  
  602. this.player1name = this.gameManagerDatabaseObject.playersObject[i].name
  603. }
  604. if(this.gameManagerDatabaseObject.playersObject[i].player ==2 ){
  605.  
  606. this.player2name = this.gameManagerDatabaseObject.playersObject[i].name
  607. }
  608. if(this.gameManagerDatabaseObject.playersObject[i].player ==3 ){
  609.  
  610. this.player3name = this.gameManagerDatabaseObject.playersObject[i].name
  611. }
  612. if(this.gameManagerDatabaseObject.playersObject[i].player ==4 ){
  613.  
  614. this.player4name = this.gameManagerDatabaseObject.playersObject[i].name
  615. }
  616.  
  617. /// sets marker between human and ai peace control
  618.  
  619. // this is fine for online, but we need the same thing for offline....
  620.  
  621.  
  622.  
  623. if(this.gameManagerDatabaseObject.playersObject[i].type ==1 ){
  624.  
  625.  
  626.  
  627. this.aiArray.push(this.gameManagerDatabaseObject.playersObject[i])
  628. if(this.gameManagerDatabaseObject.turn == this.gameManagerDatabaseObject.playersObject[i].player){
  629.  
  630.  
  631. console.log('its ais turn right now')
  632. this.aiTurnManager(this.gameManagerDatabaseObject.playersObject[i])
  633. }
  634. }else{
  635.  
  636.  
  637. // pushed is bad do players in game - ai .
  638. if(this.pushCount < this.playersInGame - this.aiArray.length ){
  639. console.log('did human array')
  640. this.humanArray.push(this.gameManagerDatabaseObject.playersObject[i])
  641. console.log(this.humanArray)
  642. //this.pushed = true
  643. this.pushCount += 1
  644.  
  645. }
  646. //come back to this code
  647. }
  648.  
  649. if(this.userService.uid == this.gameManagerDatabaseObject.playersObject[i].uid){
  650. this.me = this.gameManagerDatabaseObject.playersObject[i]
  651.  
  652. }
  653.  
  654. }
  655.  
  656. if(this.gameManagerDatabaseObject.turn == this.me.player){
  657. //console.log('its my turn right now + this.me ')
  658. // console.log(this.me)
  659.  
  660. this.myTurn = true
  661. // console.log(this.myTurn)
  662. }else{
  663. this.myTurn = false
  664. }
  665.  
  666. })
  667. //this.postGameStartArrayFiller()
  668. }
  669.  
  670.  
  671. pushed = false
  672.  
  673. pushCount = 0
  674.  
  675.  
  676.  
  677. ///turn based, and peace move based logic
  678.  
  679. checkBoardPeaceStates(){
  680.  
  681. console.log(" pre skelly")
  682. for(let i= 0; this.boardDBList; i++){
  683. let sprite = this.boardDBList[i].peace
  684.  
  685. if(sprite.hp <= 0){
  686. console.log(" dead skeleton peace")
  687.  
  688. // this.boardDBList$.remove(this.boardDBList[i].peace.key)
  689. sprite.imageSrc = sprite.otherStates.skeleton.image
  690. sprite.sourceX = sprite.otherStates.skeleton.sourceX
  691. sprite.sourceY = sprite.otherStates.skeleton.sourceY
  692. sprite.player = 0
  693.  
  694. // later maybe make un movable?
  695. // a skeleton with no player affiliation? whoever revives
  696. // it joins their team?
  697. // or skeleton can be disposed of destroyed to remove peace completely
  698.  
  699. this.boardDBList$.update(sprite.key, {peace : sprite})
  700. }
  701. }
  702. }
  703.  
  704.  
  705.  
  706.  
  707.  
  708. endMyTurn(){
  709. console.log('current turn')
  710.  
  711. if(this.playersInGame){
  712.  
  713.  
  714.  
  715. this.tsotsAIService.aiOverRun = 0 ;
  716. this.turnsTaken += 1
  717. this.databaseService.overlappingPeacesCheck()
  718. this.turnsBlockChainService.turnsBlockChainIntercept(
  719. JSON.stringify(this.gameManagerDatabaseObject)
  720. )
  721.  
  722.  
  723. this.timeBasedEvents()
  724.  
  725.  
  726. if(this.currentTurn < this.playersInGame){
  727. console.log('current turn')
  728. console.log(this.currentTurn)
  729. this.currentTurn += 1
  730. this.gameManagerDatabase$.update(this.tsotsGameMatchKey,{turn: this.currentTurn})
  731. }else{
  732. this.currentTurn = 1
  733. console.log('current turn')
  734. console.log(this.currentTurn)
  735. this.gameManagerDatabase$.update(this.tsotsGameMatchKey,{turn: this.currentTurn})
  736. }
  737. }else{
  738. console.log('players in game not read yet')
  739. }
  740. }
  741.  
  742.  
  743. aiEval(){
  744.  
  745.  
  746.  
  747. this.cancelMonopolyTradeMenu
  748. }
  749.  
  750.  
  751. aiTurnManager(ai){
  752.  
  753. //console.log('managing ARTIFICIAL INTELLIGENCE turn' + ai)
  754.  
  755.  
  756. // someone has to manage ai turns, but not everyone.
  757. if(this.gameManagerBrowser == true ){
  758.  
  759. console.log(' i am the game manager BROWSER ')
  760. if(this.boardDBList$){
  761. this.tsotsAIService.mmoAIonlineServiceStart(ai, this.gameManagerDatabase$,
  762. this.gameManagerDatabaseObject, this.boardDBList$ , this.boardDBList , this.gameWorld, this.playersInGame,
  763. this.tsotsGameMatchKey , this.currentTurn )
  764.  
  765. this.databaseService.overlappingPeacesCheck()
  766.  
  767. }else{
  768. console.log('this observable wasnt ready')
  769. }
  770.  
  771. }else{
  772. console.log('nacho turn. ')
  773. }
  774.  
  775.  
  776. }
  777.  
  778.  
  779.  
  780.  
  781.  
  782. myTurnManager(){
  783. }
  784.  
  785. turnManager(){
  786.  
  787. // this sees how many players are in game , and manages turn privedges for each
  788. }
  789.  
  790.  
  791. onlineMatch(){
  792.  
  793. this.tsotsLobbyService.joinLobby()
  794.  
  795. }
  796.  
  797. counterOffer1
  798. tsotsGameMatchKey
  799. player
  800.  
  801. gameManagerDatabase$
  802.  
  803. gameManagerDatabaseMatch$
  804. gameManagerDatabaseMatch
  805.  
  806. gameManagerDatabaseMatchObject$
  807. gameManagerDatabaseMatchObject
  808.  
  809. subGMDO
  810. subGG
  811. gameObject
  812.  
  813. mmo = false
  814.  
  815. aiPlayers
  816. humanPlayers
  817.  
  818. toySwitch
  819.  
  820. mmoMatchUp(){
  821. this.mmo = true
  822. //console.log('mmoMatchUp')
  823. //console.log(this.gameManagerDatabaseMatchObject)
  824. //console.log(this.gameManagerDatabaseMatchObject.object)
  825.  
  826. for(let i = 0; i < this.gameManagerDatabaseMatch.length; i++){
  827. // set player 123, detirmine if its "My turn "
  828.  
  829. }
  830. }
  831. onlinePlay(){
  832.  
  833. this.player1uid = this.tsotsLobbyService.player1uid
  834. this.player1name=this.tsotsLobbyService.player1name
  835.  
  836. this.player2uid=this.tsotsLobbyService.player2uid
  837. this.player2name = this.tsotsLobbyService.player2name
  838. this.tsotsGameMatchKey = this.tsotsLobbyService.tsotsGameMatchKey
  839. this.player = this.tsotsLobbyService.player
  840. console.log(this.player1name)
  841. console.log(this.player1uid)
  842. console.log(this.player2name)
  843. console.log(this.player2uid)
  844.  
  845.  
  846. this.inGamePlay = true ;
  847.  
  848. console.log('gameMatchKey')
  849. console.log(this.tsotsGameMatchKey)
  850.  
  851. // this isn't fast enough to populate this data intime.
  852. // we will have to have another button???
  853. // that or an if statement to start looping when we have a game match key.
  854.  
  855.  
  856. this.gameObject = {
  857. player1uid : this.player1uid,
  858. player2uid : this.player2uid,
  859. gameMatchKey : this.tsotsGameMatchKey,
  860. player : this.player ,
  861. gameManagerDatabase$ : this.gameManagerDatabase$ ,
  862. gameManagerDatabaseMatchObject : this.gameManagerDatabaseMatchObject,
  863. boardDBList : this.boardDBList,
  864. boardDBList$ : this.boardDBList$
  865. }
  866.  
  867. this.tsotsGameManagerService.totalGameManager(this.gameObject)
  868.  
  869. }
  870.  
  871.  
  872.  
  873. endTurn(){
  874. this.turnsTaken += 1
  875. this.timeBasedEvents()
  876.  
  877. switch(this.playerTurn){
  878. case 1:
  879. console.log('tried to change 1 turn')
  880. this.gameManagerDatabase$.update(this.tsotsGameMatchKey , {playerTurn : 2})
  881. break;
  882. case 2:
  883. console.log('tried 2 change 2 turn ')
  884. this.playerTurn = 1
  885. this.gameManagerDatabase$.update(this.tsotsGameMatchKey , {playerTurn : 1})
  886. break;
  887. }
  888.  
  889. //this.playerTurn = 2
  890. //this.startAIturn()
  891.  
  892.  
  893. }
  894.  
  895.  
  896. currentPlayerPeaces
  897. currentPlayerPeaceInTime
  898. timeBasedEvents(){
  899.  
  900.  
  901.  
  902. this.currentPlayerPeaces= []
  903.  
  904.  
  905. // instead of finding human peaces, find the peaces for the person whos turn just ended.
  906. // fires on end of turns, operates on all peaces on board.
  907. // perhaps they have an inventory array of turned based events
  908. // all waiting to be iterated and operated on .
  909.  
  910.  
  911. for(let i = 0 ; i < this.boardDBList.length ;i++){
  912.  
  913. if(this.boardDBList[i].peace.player == this.currentTurn ){
  914. console.log('[i]')
  915. console.log(this.boardDBList[i].peace.player)
  916. this.currentPlayerPeaces.push(this.boardDBList[i].peace)
  917.  
  918. }}
  919.  
  920. for(let i = 0 ; i < this.currentPlayerPeaces.length; i++){
  921.  
  922. for(let j =0 ; j< this.currentPlayerPeaces[i].timeBasedEvents.length; j++){
  923.  
  924. this.currentPlayerPeaceInTime = this.currentPlayerPeaces[i]
  925.  
  926. eval(this.currentPlayerPeaces[i].timeBasedEvents[j].method)
  927. }
  928. }
  929.  
  930. console.log('in time based events')
  931. console.log(this.currentTurn)
  932. console.log(this.currentPlayerPeaces)
  933. }
  934.  
  935.  
  936.  
  937.  
  938.  
  939.  
  940.  
  941. endGame(){
  942. this.boardDBsideData$.remove()
  943. this.boardDBsideDataKeyed$.remove()
  944. this.gameManagerDatabaseMatch$.remove()
  945. this.userService.userFolderData$.remove() // multiple ai's
  946. this.matchFolderDataObject = undefined ;
  947. //
  948. this.userService.deleteAIuser()
  949. this.player2uid = null
  950. this.player2name = null
  951. this.inGamePlay = false
  952. this.playerTurn = null
  953. this.tsotsGameMatchKey = null
  954. }
  955.  
  956.  
  957. saveBoardCloud(named){
  958. // we are redoing save load because of mysterious bugs
  959.  
  960.  
  961. //this.boardDBList.boardName = this.boardName
  962.  
  963. let banger = []
  964. for(let i=0; i < this.boardDBList.length;i++){
  965. console.log(this.boardDBList[i].peace)
  966. console.log(this.boardDBList[i].$key)
  967.  
  968.  
  969. var sprite = this.boardDBList[i].peace;
  970. sprite.key = this.boardDBList[i].$key
  971.  
  972.  
  973. banger.push(sprite)
  974.  
  975. }
  976.  
  977. // here is where dimensions can be saved properly
  978. let dimension = this.gameWorld
  979.  
  980.  
  981.  
  982. this.franchiseBoardDatabase$.update(named +'tsots1', { boardDimension :this.gameWorld });
  983. this.franchiseBoardDatabase$.update(named +'tsots1', { board :banger });
  984.  
  985. // very sensitive, this is the only way to put the data
  986. }
  987.  
  988.  
  989. savedBoardMenuViewCloud
  990.  
  991. subC
  992.  
  993. eggPantsLobby
  994. normansDatabase$
  995. normansDatabase
  996. subREE
  997.  
  998. subUFD
  999. subUFL
  1000. subMFL
  1001. userFolderDataObject$
  1002. userFolderDataObject
  1003.  
  1004. matchFolderDataObject$
  1005. matchFolderDataObject
  1006.  
  1007. userFolderDataList$
  1008. userFolderDataList
  1009.  
  1010. matchFolderDataList$
  1011. matchFolderDataList
  1012.  
  1013. deleteSeek(item){
  1014.  
  1015. this.normansDatabase$ = this.af.database.list('BOTSGlobalData/lobbyHumanAI/' + item.matchKey)
  1016. this.normansDatabase$.remove()
  1017. this.setLoadCloudLobby()
  1018. //mySubscription.unsubscribe();
  1019. }
  1020.  
  1021. deleteAISeek(){
  1022. this.normansDatabase$ = this.af.database.list('BOTSGlobalData/lobbyHumanAI/' + this.tsotsGameMatchKey)
  1023. this.normansDatabase$.remove()
  1024.  
  1025. }
  1026.  
  1027. total
  1028.  
  1029.  
  1030. // could pass EVAL('db list in qutations.subscribe ') through the cloud.
  1031. // cloud code communication. try, catch for eval(e)errors
  1032.  
  1033. joinSeek(item, i){
  1034. this.userFolderDataList$ = this.af.database.list('BOTSusers/'+ this.userService.uid +'/userFolder/userFolderData/' )
  1035.  
  1036. console.log('join seek')
  1037. // console.log(item)
  1038. // console.log(i)
  1039. let fill = item.seek - 1
  1040. let arrOb = item.object
  1041. let seaKing = item.seeking
  1042. let total = fill - arrOb.length+1
  1043. this.total = total
  1044. //{object : object , seek : humans - 1 , ai : ai , matchKey : this.uid}
  1045. console.log('in seek 1 ')
  1046. let humanObject = { uid: this.userService.uid,
  1047. name: this.userService.uid, type : 2 ,playerTurn : 1,
  1048.  
  1049. gameMatchKey : item.matchKey }
  1050.  
  1051. arrOb.push(humanObject)
  1052.  
  1053. console.log(item)
  1054.  
  1055.  
  1056.  
  1057. console.log('in seek 2')
  1058.  
  1059.  
  1060.  
  1061. this.lobbyHumanAI$.update(item.matchKey,{playersObject: arrOb})
  1062.  
  1063. this.lobbyHumanAI$.update(item.matchKey,{seeking: seaKing - 1})
  1064.  
  1065. console.log('in seek 2 1/2')
  1066.  
  1067.  
  1068. this.matchFolderDataList$ = this.af.database.list('BOTSusers/'+ item.matchKey +'/userFolder/userFolderData/' )
  1069. this.matchFolderDataObject$ = this.af.database.object('BOTSusers/'+ item.matchKey +'/userFolder/userFolderData/' )
  1070.  
  1071. // come get me
  1072. //this.matchFolderDataList$.update('seekState', {state : 72 })
  1073. console.log('in seek 3')
  1074.  
  1075. this.subUFL = this.userFolderDataList$.subscribe($ =>{
  1076. this.userFolderDataList = $
  1077. //console.log($)
  1078.  
  1079. })
  1080.  
  1081. this.subMFL = this.matchFolderDataObject$.subscribe($ =>{
  1082. this.matchFolderDataObject = $
  1083. //console.log($)
  1084.  
  1085. })
  1086.  
  1087. //this.userService.lobbyHumanAI$.update(this.tsotsGameMatchKey, {seek : item.seek -1 })
  1088. console.log(item.object.length + 'length')
  1089. console.log(item.seeking -1 + 'seek')
  1090. console.log('case 53')
  1091. //
  1092. console.log('in seek 4')
  1093.  
  1094. this.userFolderDataList$.update('seekState', {state : 53 })
  1095. this.userFolderDataList$.update('matchKey', {state : item.matchKey})
  1096. this.tsotsGameMatchKey = item.matchKey
  1097.  
  1098. if(item.seeking -1 == 0){
  1099.  
  1100.  
  1101. this.matchFolderDataList$.update('seekState', {state : 72 })
  1102. this.userFolderDataList$.update('seekState', {state : 72 })
  1103.  
  1104. this.lobbyHumanAI$.update(item.matchKey, {middleHuman: false })
  1105.  
  1106.  
  1107.  
  1108. console.log('congratulations all seeks met !, delet this seek. ')
  1109. this.deleteSeek(item)
  1110.  
  1111. // put this 2 matchkey user folder object
  1112. this.toySwitch == 10
  1113. this.tsotsGameMatchKey = item.matchKey
  1114. this.gameManagerDatabase$ = this.af.database.list('BOTSGlobalData/tsots/gameManagerDatabase/')
  1115. for(let i = 0 ;i < arrOb.length; i++){
  1116. arrOb[i].player = i +1
  1117. }
  1118. this.gameManagerDatabase$.update(item.matchKey,{playersObject: arrOb})
  1119. this.gameManagerDatabase$.update(item.matchKey,{turn: 1})
  1120. this.gameManagerDatabase$.update(item.matchKey,{matchKey: item.matchKey})
  1121. this.gameManagerDatabase$.update(item.matchKey,{crossBrowser : {menu1 : 0, menu2: 0}})
  1122.  
  1123. this.cancelChickMenu()
  1124. }else{
  1125. //console.log('message me pls respond. ')
  1126. //console.log(this.matchFolderDataList)
  1127.  
  1128. this.matchFolder()
  1129.  
  1130. }
  1131.  
  1132.  
  1133.  
  1134. }
  1135.  
  1136. matcher = false
  1137. iter = 0
  1138. matchFolder(){
  1139. //console.log('match folder')
  1140. if(this.iter < 100){
  1141. this.iter++
  1142. //console.log(this.matchFolderDataObject)
  1143.  
  1144.  
  1145. // fat arrow preserves "this."
  1146.  
  1147. if(this.matchFolderDataObject !== undefined){
  1148. if(this.matchFolderDataObject.seekState.state == 72){
  1149. console.log('found match')
  1150. this.iter = 101
  1151. this.userFolderDataList$.update('seekState', {state : 72 })
  1152. } setTimeout(()=>{ this.matchFolder() }, 2000);
  1153. }else{
  1154.  
  1155. setTimeout(()=>{ this.matchFolder() }, 2000);
  1156. }
  1157. }else{
  1158. // this iter is too high, pull me from the lobby altogether and tell me join failed.
  1159. }
  1160.  
  1161. }
  1162.  
  1163. subWhy
  1164. setLoadCloud(){
  1165.  
  1166.  
  1167. this.savedBoardMenuViewCloud = []
  1168.  
  1169. for(let i = 0 ; i < this.franchiseBoardDatabase.length; i++){
  1170. let saved = this.franchiseBoardDatabase[i]
  1171. saved.key = saved.$key
  1172. //saved.owner = this.userService.userObject.displayName
  1173. //saved.ownerUID =this.userService.userObject.uid
  1174.  
  1175. this.savedBoardMenuViewCloud.push(saved)
  1176.  
  1177. //console.log(this.savedBoardMenuViewCloud)
  1178. }
  1179.  
  1180. // keep checking lobby 10 times , i dont believe lobby viewcloud is dynamic otherwise.
  1181.  
  1182. }
  1183.  
  1184. savedBoard
  1185. lobbyDatabaseViewCloud
  1186. lobbyHumanAI$
  1187. lobbyHumanAI
  1188. selectedFile
  1189.  
  1190. setLoadCloudLobby(){
  1191. let i = 0
  1192. //console.log('view cloud')
  1193.  
  1194. if(this.gameType=1){
  1195.  
  1196. // classic game seek type . random by rank .
  1197. this.classicVS()
  1198.  
  1199. console.log('set game type mode here! classic = 1, expanse = 2 ')
  1200. return;
  1201.  
  1202.  
  1203. }
  1204.  
  1205. this.lobbyDatabaseViewCloud = []
  1206. this.userObject= this.userService.userObject
  1207.  
  1208.  
  1209. for(let i = 0 ; i < this.lobbyHumanAI.length; i++){
  1210. let saved = this.lobbyHumanAI[i]
  1211.  
  1212. saved.name = saved.$key
  1213. //saved.owner = this.userService.userObject.displayName
  1214. //saved.ownerUID =this.userService.userObject.uid
  1215.  
  1216. this.lobbyDatabaseViewCloud.push(saved)
  1217. this.eggPantsLobby = this.lobbyDatabaseViewCloud
  1218.  
  1219. }
  1220. if(i > 10){
  1221. setTimeout(()=>{ this.matchFolder() }, 9000);
  1222. }
  1223.  
  1224. }
  1225.  
  1226. /////
  1227.  
  1228.  
  1229. submitFile(){
  1230. try{
  1231.  
  1232. for (let selectedFile of [(<HTMLInputElement>document.getElementById('file')).files[0]]) {
  1233. console.log(selectedFile);
  1234. this.selectedFile = selectedFile
  1235. }
  1236.  
  1237. let number = this.classicBoardBuildsJSON.length
  1238.  
  1239. let storageRef = firebase.storage().ref();
  1240.  
  1241. // get length and save the name of file with a number of +`1` last file
  1242.  
  1243. let af = this.af;
  1244. let folder = 'allBoardsJSON/classicBoardBuildsJSON'
  1245. let name = number + 'classicBoard.json' // + number
  1246. let path = `/${folder}/${name}`;
  1247. let user = this.userService.uid
  1248. let time = Date.now()
  1249. var iRef = storageRef.child(path);
  1250. console.log(iRef)
  1251. iRef.put(this.selectedFile).then((snapshot) => {
  1252. console.log('Uploaded a blob or file! Now storing the reference');
  1253.  
  1254. // push with merkle root as the key if new .
  1255. af.database.list(`/${folder}/`).push({ path: path, filename: name ,
  1256. user : user,
  1257. time : time})
  1258.  
  1259. })
  1260.  
  1261. this.parseLoadClassicJSON()
  1262.  
  1263. }catch(e){
  1264.  
  1265. }
  1266. }
  1267.  
  1268.  
  1269. selectedFileRead
  1270.  
  1271. parseLoadClassicJSON(){
  1272. this.selectedFile
  1273.  
  1274. var reader = new FileReader();
  1275.  
  1276. // using fat arrow retains our ".this" scope !
  1277. reader.onload = ()=>{
  1278. var text = reader.result;
  1279.  
  1280. reader.onloadend = () =>{
  1281. this.selectedFileRead = reader.result
  1282. this.JSONtoDBList()
  1283.  
  1284. }
  1285.  
  1286. return reader.result
  1287. }
  1288.  
  1289. reader.readAsText(this.selectedFile);
  1290.  
  1291.  
  1292. }
  1293.  
  1294.  
  1295. designatedBlankPeace
  1296.  
  1297. JSONtoDBList(){
  1298.  
  1299. console.log('json 2 db list.')
  1300. let board = JSON.parse(this.selectedFileRead)
  1301. //console.log(board)
  1302.  
  1303. this.boardDBList$.remove()
  1304.  
  1305.  
  1306.  
  1307. // sometimes, leaves that one off .
  1308. // when paste to rendering board dblist.
  1309. // crazy thing is, this is 40 peaces.
  1310. // and it still only dropped 1 off. ???
  1311.  
  1312. for(var prop in board){
  1313. if(board[prop].peace){
  1314. var sprite = board[prop].peace
  1315. //console.log(sprite)
  1316. this.boardDBList$.update(sprite.key , {peace : sprite})
  1317. }
  1318.  
  1319. //prevents them from robbing our peace list.
  1320. sprite = this.tsotsPeaceService.peaceLegend.holyGhost
  1321. this.boardDBList$.update(sprite.key , {peace : sprite})
  1322. this.boardDBList$.update(sprite.key+1 , {peace : sprite})
  1323.  
  1324. }
  1325.  
  1326.  
  1327. }
  1328. // we are actually going to save no to that node , but
  1329. // to a JSON file . , ergo , we are also going to load from that JSON file
  1330. // because this is HUGE , and doesn't need to be real time.
  1331. downloadBoardForR(i){
  1332.  
  1333.  
  1334. console.log('trying to download. ')
  1335. let sprite = this.tsotsPeaceService.peaceLegend.holyGhost
  1336.  
  1337. this.boardDBObject = this.databaseService.boardDBObject
  1338.  
  1339.  
  1340. for(let i =0 ; i <this.boardDBObject.length; i++){
  1341.  
  1342. if(this.boardDBObject[i].key == sprite.key){
  1343. this.databaseService.boardDBList$.remove(sprite.key)
  1344. }
  1345. if(this.boardDBObject[i].key == sprite.key +1){
  1346. this.databaseService.boardDBList$.remove(sprite.key)
  1347. }
  1348. }
  1349.  
  1350. // if u are serious about using this in "R" your going to have to
  1351. // pre strip the data that u dont actually want
  1352. // like how R doesn't even know how to parse that firebase image data//
  1353. // but we can easily strip that !
  1354. // right now, lets just have botscoin protocool , make us a
  1355. // mini numerai like dataset .
  1356. // so at least tonight we did SOMETHING about intergrating those 2 , after all this.
  1357.  
  1358. let dataString = JSON.stringify([this.boardDBObject]) //this.ConvertToCSV(this.data);
  1359.  
  1360. // converting to "R" readable, only happens on download.
  1361. // ofc if u want to reupload u need to strip these strings maybe.
  1362. //dataString = " boardPeaces -> '[" +dataString + "]'"
  1363.  
  1364. // im about to make a random numerai data maker , right on the botscoin component.
  1365. // to generate me random sets i can test against.
  1366. // also , the block chain
  1367. // will each time generate a random data set , based on a certain correlation
  1368. // save it , and ask the users to find the closest prediction , it will generate based on merkel root
  1369. // and compare.
  1370.  
  1371. console.log(dataString)
  1372.  
  1373. let a = document.createElement("a");
  1374. a.setAttribute('style', 'display:none;');
  1375. document.body.appendChild(a);
  1376. let blob = new Blob([dataString], { type: 'text/csv' });
  1377. let url= window.URL.createObjectURL(blob);
  1378. a.href = url;
  1379.  
  1380. if(i ===0 ){
  1381. a.download = 'boardClassicBuildJSON.csv';
  1382. }
  1383. if(i===1){
  1384. a.download = this.bookNumber +'boardStoryBuild.csv'
  1385. }
  1386.  
  1387. a.click();
  1388.  
  1389.  
  1390. }
  1391.  
  1392. downloadBoard(i){
  1393.  
  1394.  
  1395. console.log('trying to download. ')
  1396. let sprite = this.tsotsPeaceService.peaceLegend.holyGhost
  1397.  
  1398. this.boardDBObject = this.databaseService.boardDBObject
  1399.  
  1400.  
  1401. for(let i =0 ; i <this.boardDBObject.length; i++){
  1402.  
  1403. if(this.boardDBObject[i].key == sprite.key){
  1404. this.databaseService.boardDBList$.remove(sprite.key)
  1405. }
  1406. if(this.boardDBObject[i].key == sprite.key +1){
  1407. this.databaseService.boardDBList$.remove(sprite.key)
  1408. }
  1409. }
  1410.  
  1411.  
  1412.  
  1413. let dataString = JSON.stringify(this.boardDBObject) //this.ConvertToCSV(this.data);
  1414. // converting to "R" readable, only happens on download.
  1415. // ofc if u want to reupload u need to strip these strings maybe.
  1416. //dataString = "'[" +dataString + "]'"
  1417.  
  1418. // im about to make a random numerai data maker , right on the botscoin component.
  1419. // to generate me random sets i can test against.
  1420. // also , the block chain
  1421. // will each time generate a random data set , based on a certain correlation
  1422. // save it , and ask the users to find the closest prediction , it will generate based on merkel root
  1423. // and compare.
  1424.  
  1425. console.log(dataString)
  1426.  
  1427. let a = document.createElement("a");
  1428. a.setAttribute('style', 'display:none;');
  1429. document.body.appendChild(a);
  1430. let blob = new Blob([dataString], { type: 'application/json' });
  1431. let url= window.URL.createObjectURL(blob);
  1432. a.href = url;
  1433.  
  1434. if(i ===0 ){
  1435. a.download = 'boardClassicBuildJSON.json';
  1436. }
  1437. if(i===1){
  1438. a.download = this.bookNumber +'boardStoryBuild.json'
  1439. }
  1440.  
  1441. a.click();
  1442.  
  1443.  
  1444. }
  1445.  
  1446. downloadAllStoryJSON(){
  1447. // just download entire story node from time to time.
  1448. }
  1449.  
  1450.  
  1451.  
  1452. saveBoardClassic(named){
  1453.  
  1454. /// save is totally differe we will be saving an uploaded file
  1455. // then uploading it to be stored.
  1456. // its waaay to much trouble to make a file and store at the sametime apperantly
  1457. // and it would involved hacking around the file reader system , incase u ever feel like doing that.
  1458.  
  1459. // were going to save json with '[]' for easy "R " playersInGame
  1460. // when we load we remove like so :
  1461. /*
  1462. var str = "12345.00";
  1463.  
  1464. str = str.slice(0, -1);
  1465. >>"12345.0"
  1466. var str = "12345.00";
  1467.  
  1468. str = str.slice(0, -2);
  1469. >>"12345."
  1470.  
  1471.  
  1472. to remove first
  1473. str = str.substring(1);
  1474. >>"2345.00"
  1475.  
  1476. obviously jsonstringify "'["+ objectString +"]'"
  1477. */
  1478.  
  1479.  
  1480. console.log("HELLO!??!")
  1481.  
  1482. this.boardName = named
  1483.  
  1484.  
  1485. this.selectedFile = JSON.stringify(this.databaseService.boardDBObject)
  1486.  
  1487. console.log(this.databaseService.boardDBObject)
  1488.  
  1489. this.savingBoardList$ = this.af.database.list('TSOTSLevels/classicBoardBuilds/')
  1490.  
  1491. console.log('this.selectedFile')
  1492. console.log(this.selectedFile)
  1493.  
  1494. this.savingBoardList$.update(named, {board:this.selectedFile})
  1495. this.savingBoardList$.update(named , { boardDimension :this.gameWorld });
  1496.  
  1497.  
  1498. }
  1499.  
  1500. savingBoardList$
  1501. savingBoardDimension
  1502.  
  1503. subBoardList
  1504.  
  1505. bookNumber = 0
  1506.  
  1507. savingBoardDimension$
  1508.  
  1509. saveBoardStory(named){
  1510. this.boardName = named
  1511.  
  1512. for(let i =0 ; i <this.boardDBObject.length; i++){
  1513.  
  1514. if(this.boardDBObject[i].key == this.tsotsPeaceService.peaceLegend.spirit.key){
  1515. this.boardDBList$.remove(this.boardDBObject[i].key)
  1516. }
  1517. if(this.boardDBObject[i].key == this.tsotsPeaceService.peaceLegend.spirit.key +1){
  1518. this.boardDBList$.remove(this.boardDBObject[i].key)
  1519. }}
  1520.  
  1521. this.savingBoardList$ = this.af.database.list('TSOTSLevels/storyLevels/'+this.bookNumber+"/"+ named + '/board' )
  1522. this.savingBoardDimension$= this.af.database.list('TSOTSLevels/storyLevels/'+this.bookNumber )
  1523. // might wanna save up 2 board , then boardDimension
  1524.  
  1525.  
  1526. let banger = []
  1527. for(let i=0; i < this.boardDBList.length;i++){
  1528. console.log(this.boardDBList[i].peace)
  1529. console.log(this.boardDBList[i].$key)
  1530.  
  1531.  
  1532. var sprite = this.boardDBList[i].peace;
  1533. sprite.key = this.boardDBList[i].$key
  1534.  
  1535. this.savingBoardList$.update(sprite.key, {peace :sprite });
  1536.  
  1537.  
  1538. }
  1539. this.savingBoardDimension$.update(named, { boardDimension :this.gameWorld });
  1540.  
  1541. }
  1542.  
  1543. boardListTemp
  1544. boardObjectTemp
  1545. tempObject$
  1546. tempObject
  1547.  
  1548. loadBoardClassic(it,i ){
  1549.  
  1550. let named = it.$key.toString()
  1551.  
  1552. console.log('loading. ')
  1553.  
  1554.  
  1555. this.tempObject$ = this.af.database.object('TSOTSLevels/classicBoardBuilds/'+ named)
  1556.  
  1557.  
  1558. this.boardDBList$.remove()
  1559.  
  1560. this.subBoardList = this.tempObject$.subscribe($ =>{
  1561. this.tempObject = $
  1562.  
  1563. this.databaseService.boardDBList$ = this.af.database.list('developerData/boardDev',
  1564. {
  1565. query: {
  1566.  
  1567. orderByChild : '/peace/layer'
  1568. //limitToFirst : 1
  1569. // orderByKey : true
  1570. // orderByChild: 'size',
  1571. // equalTo: this.sizeSubject
  1572. }
  1573. })
  1574.  
  1575. this.databaseService.boardDBObject$ = this.af.database.object('developerData/boardDev')
  1576.  
  1577. this.boardDBList$ = this.databaseService.boardDBList$
  1578. this.boardDBObject$ = this.databaseService.boardDBObject$
  1579. })
  1580.  
  1581. setTimeout(()=>{this.objectPopulateBoardDBList()
  1582.  
  1583.  
  1584.  
  1585. console.log('this.tempObject.boardDimension')
  1586. console.log(this.tempObject.boardDimension)
  1587. this.gameWorld = this.tempObject.boardDimension
  1588.  
  1589.  
  1590.  
  1591. if(this.gameWorld.width > 10){
  1592. this.canvas.width = this.gameWorld.width*48
  1593.  
  1594. if(this.gameWorld.width> 20){
  1595. this.canvas.width = 20 * 48
  1596. }
  1597.  
  1598.  
  1599. this.spaceHtml = [1]
  1600. }else{
  1601.  
  1602. this.canvas.width = this.gameWorld.width*48
  1603. this.spaceHtml = []
  1604. }
  1605.  
  1606.  
  1607. },1300)
  1608.  
  1609.  
  1610.  
  1611. }
  1612.  
  1613. loadBoardClassicOfficial(){
  1614. console.log('trying to loadBoardClassicOfficial')
  1615.  
  1616. //if players > 2 long board. set var at search.
  1617. //console.log('this.playersInGame')
  1618. //console.log(this.playersInGame)
  1619. // doesn't know yet.
  1620.  
  1621. this.tempObject$ = this.af.database.object('TSOTSLevels/classicBoardBuilds/official/')
  1622.  
  1623. this.databaseService.boardDBList$.remove()
  1624.  
  1625. this.subBoardList = this.tempObject$.subscribe($ =>{
  1626. this.tempObject = $
  1627.  
  1628. // this.databaseService.boardDBList$ = this.af.database.list('developerData/boardDev')
  1629. //this.databaseService.boardDBObject$ = this.af.database.object('developerData/boardDev')
  1630. console.log('switched lists')
  1631. this.boardDBList$ = this.databaseService.boardDBList$
  1632. this.boardDBObject$ = this.databaseService.boardDBObject$
  1633. })
  1634.  
  1635.  
  1636.  
  1637. //comeback
  1638. setTimeout(()=>{this.objectPopulateBoardDBList()
  1639.  
  1640.  
  1641. },1300)
  1642.  
  1643. }
  1644.  
  1645.  
  1646.  
  1647.  
  1648. objectPopulateBoardDBList(){
  1649.  
  1650. let board = JSON.parse(this.tempObject.board)
  1651. console.log('board')
  1652. console.log(board)
  1653.  
  1654.  
  1655.  
  1656. for(var prop in board){
  1657. if(board[prop].peace){
  1658. var sprite = board[prop].peace
  1659. //console.log(sprite)
  1660.  
  1661.  
  1662. if(
  1663. sprite.key[1]=== "1"){
  1664. sprite.player = 1
  1665. }
  1666. if(
  1667. sprite.key[1]=== "2"
  1668.  
  1669. ){
  1670. sprite.player = 2
  1671. }
  1672.  
  1673.  
  1674. this.databaseService.boardDBList$.update(sprite.key , {peace : sprite})
  1675. }
  1676.  
  1677. //prevents them from robbing our peace list.
  1678. sprite = this.tsotsPeaceService.peaceLegend.holyGhost
  1679. this.databaseService.boardDBList$.update(sprite.key , {peace : sprite})
  1680. this.databaseService.boardDBList$.update(sprite.key+1 , {peace : sprite})
  1681.  
  1682.  
  1683. this.databaseService.reSub()
  1684.  
  1685. }
  1686. //setTimeout(()=>{ this.databaseService.overlappingPeacesCheck()},1300)
  1687.  
  1688.  
  1689. }
  1690.  
  1691.  
  1692.  
  1693. loadBoardClassicOfficial4(){
  1694.  
  1695. //if players > 2 long board. set var at search.
  1696.  
  1697.  
  1698. this.tempObject$ = this.af.database.object('TSOTSLevels/classicBoardBuilds/official4/')
  1699.  
  1700.  
  1701. this.subBoardList = this.tempObject$.subscribe($ =>{
  1702. this.tempObject = $
  1703.  
  1704. for(let i = 0 ; i<$.length;i++){
  1705.  
  1706. }
  1707. })
  1708.  
  1709.  
  1710.  
  1711. //comeback
  1712. setTimeout(()=>{
  1713. this.objectPopulateBoardDBList()
  1714. console.log(this.tempObject.boardDimension)
  1715. console.log(this.tempObject.boardDimension)
  1716. if(this.tempObject.boardDimension){
  1717. this.gameWorld = this.tempObject.boardDimension
  1718.  
  1719. if(this.gameWorld.width){
  1720.  
  1721. if(this.gameWorld.width > 10){
  1722. this.canvas.width = this.gameWorld.width*48
  1723.  
  1724. if(this.gameWorld.width> 20){
  1725. this.canvas.width = 20 * 48
  1726. }
  1727.  
  1728.  
  1729. this.spaceHtml = [1]
  1730. }
  1731. }else{
  1732.  
  1733. this.canvas.width = this.gameWorld.width*48
  1734. this.spaceHtml = []
  1735. }
  1736.  
  1737. }
  1738. },1300)
  1739.  
  1740. }
  1741.  
  1742. savingBoardList
  1743. loadingBoardList$
  1744. loadingBoardList
  1745.  
  1746.  
  1747. shoeString
  1748. bookPull
  1749. book
  1750. storyBookChoose(book){
  1751. this.bookPull = true
  1752. console.log('story book')
  1753.  
  1754. this.shoeString = 'TSOTSLevels/storyLevels/' + book
  1755.  
  1756. this.storyLevelsList$ = this.af.database.list(this.shoeString)
  1757.  
  1758. this.subStory = this.storyLevelsList$.subscribe($ =>
  1759. {
  1760.  
  1761. this.storyLevelsList = $
  1762. console.log($)
  1763. })
  1764.  
  1765.  
  1766. this.bookNumber = book
  1767. }
  1768.  
  1769.  
  1770. tempList$
  1771. tempList
  1772.  
  1773.  
  1774.  
  1775. storyMenu
  1776.  
  1777. savedState = []
  1778.  
  1779. saveStoryGameState(){
  1780.  
  1781.  
  1782. let peace
  1783. for(let i = 0 ; i < this.boardDBList$ ; i++){
  1784.  
  1785.  
  1786. peace = this.boardDBList$[i]
  1787. this.userService.userFolderStoryList$.update('storyData',{peace : peace })
  1788.  
  1789.  
  1790. }
  1791.  
  1792.  
  1793.  
  1794. this.userService.userFolderStoryList$.update('storyData',{
  1795. savedState : JSON.stringify(this.boardDBList),
  1796. level : 1,
  1797. gameWorld : this.gameWorld
  1798. })
  1799. }
  1800.  
  1801. storyTriggerClick(){
  1802.  
  1803. // use this menu for development saving board and loading test boards.
  1804. this.storyMenu = true
  1805. this.storyBookChoose(1)
  1806. }
  1807.  
  1808.  
  1809. newStoryMenu
  1810.  
  1811. genderSelect
  1812. newStoryPeaceName
  1813.  
  1814. // get name input, and gender. and create the players janior peace
  1815. // and stor that as the first peace in their peace library
  1816. // instantly able to be manage in peace manager.
  1817. // *you can only go in expanse areas u have unlocked in story mode.
  1818.  
  1819.  
  1820.  
  1821. newSpiritBody(){
  1822. this.storyMenu= false
  1823. this.newStoryMenu = true
  1824.  
  1825. }
  1826.  
  1827. testList$
  1828. createPlayerPeaceDebug(){
  1829. console.log('createPlayerPeace')
  1830.  
  1831.  
  1832. this.blockChain.genericKeyGen()
  1833.  
  1834. let spirit = this.tsotsPeaceService.peaceLegend.spirit
  1835.  
  1836. spirit.inventory = []
  1837.  
  1838. spirit.key = this.blockChain.keyMade
  1839. spirit.owner = this.userService.uid
  1840. spirit.tileXY =[0,5]
  1841.  
  1842. spirit.sourceX = 3 *48
  1843. spirit.sourceY = 0
  1844. 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"
  1845.  
  1846. console.log('spirit')
  1847. console.log(spirit)
  1848.  
  1849. if(this.genderSelect =='male'){
  1850. console.log('setting male')
  1851.  
  1852. 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"
  1853.  
  1854. spirit.sourceX = 2 *48
  1855. spirit.sourceY = 0
  1856. //spirit.player = 1
  1857.  
  1858. console.log('spirit')
  1859. console.log(spirit)
  1860.  
  1861. }
  1862. if(this.genderSelect == 'female'){
  1863. console.log('setting female')
  1864. 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"
  1865.  
  1866. spirit.sourceX = 4 *48
  1867. spirit.sourceY = 0
  1868. }
  1869.  
  1870.  
  1871. this.boardDBList$.update(spirit.key,{peace: spirit})
  1872.  
  1873. let node = []
  1874. node.push(spirit)
  1875.  
  1876. this.userService.userStoryObjectivesList$.update(
  1877. 'testObjective1',{objective : ' clean the farm animals poop! ',
  1878.  
  1879. completed : 'no'}
  1880. )
  1881.  
  1882.  
  1883. this.userService.userFolderStoryList$.update('storyData',{
  1884. peaceLibrary : node, // players peace
  1885. savedState :
  1886. JSON.stringify(
  1887. this.boardDBList
  1888. ),
  1889.  
  1890. savedStateDimension : this.gameWorld
  1891. //' current level with player peace on it '
  1892. //level
  1893. })
  1894.  
  1895. }
  1896.  
  1897.  
  1898. createPlayerPeace(){
  1899.  
  1900. console.log('createPlayerPeace')
  1901. this.newStoryMenu = false
  1902.  
  1903.  
  1904.  
  1905.  
  1906. this.loadBoardStoryMode(this.storyLevelsList[0],0,'farm')
  1907. // actually need to point board db list to user folder "savedState"
  1908.  
  1909.  
  1910.  
  1911. setTimeout(()=>{
  1912. this.createPlayerPeaceDebug()
  1913. // had to move this logic out of the function dunno why !?
  1914.  
  1915. }, 1000);
  1916.  
  1917.  
  1918. this.userService.userFolderStoryList$.update('storyData',{
  1919. level : 1,
  1920. gender :this.genderSelect ,
  1921. peaceName : this.newStoryPeaceName ,
  1922. savedState : 'none',
  1923. playerPeaceKey : this.blockChain.keyMade ,
  1924.  
  1925. //level
  1926. })
  1927.  
  1928. console.log(this.storyLevelsList[1])
  1929.  
  1930. // what array index is first levels level in, thats what "0" is.
  1931. // [1] is what book . 0 would be "base"
  1932.  
  1933. }
  1934.  
  1935.  
  1936.  
  1937.  
  1938. loadStoryGameState(){
  1939. console.log('saved state')
  1940. //
  1941.  
  1942. // cant cut the filler nodes off at save without corrupt boardDBList
  1943. // ofc we could put them back, but lets just load the json from user folder
  1944. // and see how that works .
  1945.  
  1946. try{
  1947. console.log(JSON.parse(this.userService.userFolderStoryObject.storyData.savedState))
  1948.  
  1949. this.tempList = JSON.parse(this.userService.userFolderStoryObject.storyData.savedState)
  1950.  
  1951.  
  1952. this.gameWorld = this.userService.userFolderStoryObject.storyData.savedStateDimension
  1953.  
  1954.  
  1955.  
  1956. if(this.gameWorld.width > 10){
  1957. this.canvas.width = this.gameWorld.width*48
  1958.  
  1959. this.spaceHtml = [1]
  1960. }else{
  1961.  
  1962. this.canvas.width = this.gameWorld.width*48
  1963. this.spaceHtml = []
  1964. }
  1965.  
  1966.  
  1967.  
  1968.  
  1969.  
  1970.  
  1971. // this point should actually set to boardDBList the moment
  1972. // we start a new game.
  1973. // or multiple new games are going to clobber eachother
  1974.  
  1975. // will probably need to do this with classic AI also VV
  1976.  
  1977. this.databaseService.boardDBList$ = this.af.database.list(this.userService.userFolderDBpointer ,
  1978. {
  1979. query: {
  1980.  
  1981. orderByChild : '/peace/layer'
  1982. //limitToFirst : 1
  1983. // orderByKey : true
  1984. // orderByChild: 'size',
  1985. // equalTo: this.sizeSubject
  1986. }
  1987. })
  1988.  
  1989. this.databaseService.boardDBObject$ = this.af.database.object(this.userService.userFolderDBpointer)
  1990.  
  1991. this.databaseService.gameSideDataList$ = this.af.database.list(this.userService.userFolderSideDataListPointer)
  1992.  
  1993. this.databaseService.legalLogList$ = this.af.database.list(this.userService.userFolderLegalLogListPointer)
  1994. this.databaseService.subLegalLog = this.legalLogList$.subscribe($ =>
  1995. {
  1996. this.databaseService.legalLogList = $
  1997.  
  1998. ;}
  1999. )
  2000. this.databaseService.gameSideDataObject$ = this.af.database.object(this.userService.userFolderSideDataListPointer)
  2001.  
  2002.  
  2003. this.populateBoardDBList()
  2004. console.log('apperently theres a file here')}catch(e){
  2005. console.log(e)
  2006. }
  2007. }
  2008.  
  2009.  
  2010. loadBoardStoryJSON(it, i){
  2011.  
  2012. console.log('load it')
  2013. console.log(it)
  2014. this.gameWorld = this.storyLevelsList[i].boardDimension
  2015. console.log('this.gameWorld')
  2016. console.log(this.gameWorld)
  2017. if(this.gameWorld.width > 10){
  2018. this.canvas.width = this.gameWorld.width*48
  2019.  
  2020.  
  2021. this.spaceHtml = [1]
  2022. }else{
  2023.  
  2024. this.canvas.width = this.gameWorld.width*48
  2025. this.spaceHtml = []
  2026. }
  2027.  
  2028.  
  2029. let named = it.$key.toString()
  2030.  
  2031. console.log('loading. ')
  2032.  
  2033.  
  2034. // we will also save json with '[]' if possible, so easier loading in "R"
  2035. // but one thing at a time.
  2036. // obviously we can even move this stuff out into a dedicated service...
  2037.  
  2038. this.tempList$ = this.af.database.list('TSOTSLevels/storyLevelsJSON/'+this.bookNumber + "/"+ named +'/board')
  2039.  
  2040.  
  2041. this.subBoardList = this.tempList$.subscribe($ =>{
  2042. this.tempList = $
  2043.  
  2044.  
  2045. this.databaseService.boardDBList$ = this.af.database.list('developerData/boardDev',
  2046. {
  2047. query: {
  2048.  
  2049. orderByChild : '/peace/layer'
  2050. //limitToFirst : 1
  2051. // orderByKey : true
  2052. // orderByChild: 'size',
  2053. // equalTo: this.sizeSubject
  2054. }
  2055. })
  2056.  
  2057. this.databaseService.boardDBObject$ = this.af.database.object('developerData/boardDev')
  2058. this.populateBoardDBList()
  2059.  
  2060. })
  2061. }
  2062.  
  2063. loadBoardStory(it,i ){
  2064.  
  2065. console.log('load it')
  2066. console.log(it)
  2067. this.gameWorld = this.storyLevelsList[i].boardDimension
  2068. console.log('this.gameWorld')
  2069. console.log(this.gameWorld)
  2070. if(this.gameWorld.width > 10){
  2071. this.canvas.width = this.gameWorld.width*48
  2072.  
  2073.  
  2074. this.spaceHtml = [1]
  2075. }else{
  2076.  
  2077. this.canvas.width = this.gameWorld.width*48
  2078. this.spaceHtml = []
  2079. }
  2080.  
  2081.  
  2082. let named = it.$key.toString()
  2083.  
  2084. console.log('loading. ')
  2085.  
  2086. this.tempList$ = this.af.database.list('TSOTSLevels/storyLevels/'+this.bookNumber + "/"+ named +'/board')
  2087.  
  2088.  
  2089. this.subBoardList = this.tempList$.subscribe($ =>{
  2090. this.tempList = $
  2091.  
  2092.  
  2093. this.databaseService.boardDBList$ = this.af.database.list('developerData/boardDev'
  2094. ,
  2095. {
  2096. query: {
  2097.  
  2098. orderByChild : '/peace/layer'
  2099. //limitToFirst : 1
  2100. // orderByKey : true
  2101. // orderByChild: 'size',
  2102. // equalTo: this.sizeSubject
  2103. }
  2104. })
  2105. this.databaseService.boardDBObject$ = this.af.database.object('developerData/boardDev')
  2106. this.populateBoardDBList()
  2107.  
  2108. })
  2109.  
  2110.  
  2111. }
  2112.  
  2113. loadBoardStoryMode(it,i ,named){
  2114.  
  2115. console.log('load it')
  2116. console.log(it)
  2117. this.gameWorld = this.storyLevelsList[i].boardDimension
  2118. console.log('this.gameWorld')
  2119. console.log(this.gameWorld)
  2120. if(this.gameWorld.width > 10){
  2121. this.canvas.width = this.gameWorld.width*48
  2122.  
  2123.  
  2124. this.spaceHtml = [1]
  2125. }else{
  2126.  
  2127. this.canvas.width = this.gameWorld.width*48
  2128. this.spaceHtml = []
  2129. }
  2130.  
  2131.  
  2132.  
  2133.  
  2134. console.log('loading. ')
  2135.  
  2136. this.tempList$ = this.af.database.list('TSOTSLevels/storyLevels/'+this.bookNumber + "/"+ named +'/board')
  2137.  
  2138.  
  2139. this.subBoardList = this.tempList$.subscribe($ =>{
  2140. this.tempList = $
  2141.  
  2142.  
  2143. this.databaseService.boardDBList$ = this.af.database.list('developerData/boardDev'
  2144. ,
  2145. {
  2146. query: {
  2147.  
  2148. orderByChild : '/peace/layer'
  2149. //limitToFirst : 1
  2150. // orderByKey : true
  2151. // orderByChild: 'size',
  2152. // equalTo: this.sizeSubject
  2153. }
  2154. })
  2155. this.databaseService.boardDBObject$ = this.af.database.object('developerData/boardDev')
  2156.  
  2157. this.populateBoardDBList()
  2158.  
  2159. })
  2160.  
  2161.  
  2162. }
  2163.  
  2164.  
  2165.  
  2166. subRe
  2167. populateBoardDBList(){
  2168.  
  2169. this.boardDBList$.remove()
  2170.  
  2171. for(let i=0; i < this.tempList.length;i++){
  2172.  
  2173.  
  2174. var sprite = this.tempList[i].peace;
  2175. sprite.key = this.tempList[i].$key
  2176.  
  2177. this.boardDBList$.update(sprite.key , {peace : sprite})
  2178. }
  2179.  
  2180.  
  2181. //prevents them from robbing our peace list.
  2182. sprite = this.tsotsPeaceService.peaceLegend.holyGhost
  2183. this.boardDBList$.update(sprite.key , {peace : sprite})
  2184. this.boardDBList$.update(sprite.key+1 , {peace : sprite})
  2185.  
  2186.  
  2187. /*
  2188. this.subRe = this.boardDBList$.subscribe($ =>{
  2189. this.boardDBList = $
  2190. // console.log($)
  2191.  
  2192. })
  2193. */
  2194.  
  2195. this.databaseService.reSub()
  2196.  
  2197. //setTimeout(()=>{ this.databaseService.overlappingPeacesCheck()},2300)
  2198.  
  2199. }
  2200.  
  2201. nodeToDelete$
  2202. deleteStoryLevel(it,i){
  2203.  
  2204. let named = it.$key.toString()
  2205.  
  2206. console.log('loading. ')
  2207.  
  2208. this.nodeToDelete$ = this.af.database.list('TSOTSLevels/storyLevels/'+this.bookNumber + "/"+ named)
  2209. this.nodeToDelete$.remove()
  2210.  
  2211. //this.storyLevelsList$.remove()
  2212.  
  2213. }
  2214. deleteClassicLevel(it,i){
  2215.  
  2216. let named = it.$key.toString()
  2217.  
  2218. console.log('loading. ')
  2219.  
  2220. this.nodeToDelete$ = this.af.database.list('TSOTSLevels/classicBoardBuilds/'+ named )
  2221. this.nodeToDelete$.remove()
  2222.  
  2223. }
  2224.  
  2225. /// i = save number, save made map to database < boards created
  2226. // edit size of board on the fly ,
  2227. // all peaces are moveable character peaces until limited by type.
  2228.  
  2229.  
  2230.  
  2231.  
  2232.  
  2233.  
  2234.  
  2235.  
  2236.  
  2237.  
  2238.  
  2239.  
  2240.  
  2241. saveBoard(named){
  2242.  
  2243. // var aRef = firebase.database ().ref().child ('/BOTSusers/'+this.userService.user +'/boardSaves').push({
  2244. // name : this.boardDBList
  2245. //});
  2246. //doesn't work .
  2247. console.log(named + 'named')
  2248. this.boardName = named
  2249.  
  2250. //this.boardDBList.boardName = this.boardName
  2251.  
  2252. let banger = []
  2253. for(let i=0; i < this.boardDBList.length;i++){
  2254. console.log(this.boardDBList[i].peace)
  2255. console.log(this.boardDBList[i].$key)
  2256.  
  2257.  
  2258. var sprite = this.boardDBList[i].peace;
  2259. sprite.key = this.boardDBList[i].$key
  2260.  
  2261. //sprite.boardName = this.boardName
  2262. //var ugly = {peace : {key:1} , boardName : {boardNameSaved :this.boardName}}
  2263. //ugly.peace = sprite
  2264.  
  2265. //ugly.peace.key = this.boardDBList[i].key
  2266.  
  2267. banger.push(sprite)
  2268.  
  2269. }
  2270.  
  2271. // here is where dimensions can be saved properly
  2272. let dimension = this.gameWorld
  2273.  
  2274.  
  2275.  
  2276.  
  2277.  
  2278. if(this.selectedFolderLoad =1){
  2279. this.franchiseBoardDatabase$.update(this.boardName +'tsots1', { boardDimension :this.gameWorld });
  2280. this.franchiseBoardDatabase$.update(this.boardName+'tsots1', { board :banger });
  2281. }
  2282.  
  2283. if(this.selectedFolderLoad =2 ){
  2284. this.userService.userFolderSavedBoards$.update(this.boardName +'tsots1', { board :banger });
  2285. this.userService.userFolderSavedBoards$.update(this.boardName+'tsots1', { boardDimension :this.gameWorld });
  2286.  
  2287. }
  2288.  
  2289. if(this.selectedFolderLoad = 3 ){
  2290. this.officialStoryBoards$.update(this.boardName+'tsots1', { board :banger });
  2291. this.officialStoryBoards$.update(this.boardName+'tsots1', { boardDimension :this.gameWorld });
  2292.  
  2293. }
  2294.  
  2295. // very sensitive, this is the only way to put the data
  2296. }
  2297.  
  2298. setFolder(n){
  2299.  
  2300. this.selectedFolderLoad = n
  2301.  
  2302. }
  2303. savedBoardMenuView=[]
  2304.  
  2305. savedNames
  2306. userNom
  2307. userID
  2308. userEmail
  2309.  
  2310. userObject
  2311.  
  2312. gummyPhone =[]
  2313. userTest(){
  2314.  
  2315. this.userObject= this.userService.userObject
  2316.  
  2317. console.log(this.userObject)
  2318. console.log(this.userObject.displayName)
  2319.  
  2320.  
  2321. }
  2322.  
  2323. aiNum
  2324. humanNum
  2325. menu2softLobby = false
  2326.  
  2327. aiInGameNumber = 0
  2328. humansInGameNumber = 0
  2329. playersGameNumber = 0
  2330. gameManagerBrowser
  2331.  
  2332.  
  2333. doubleMatch(){
  2334.  
  2335. }
  2336.  
  2337.  
  2338. ////
  2339. newOnlineGamePlayers(ai, human){
  2340. this.gameManagerBrowser = true
  2341. // so player 1 animator can catch state : 72
  2342. this.matchFolderDataObject$ = this.af.database.object('BOTSusers/'+ this.userService.uid +'/userFolder/userFolderData/' )
  2343. this.matchFolderDataList$ = this.af.database.list('BOTSusers/'+ this.userService.uid +'/userFolder/userFolderData/' )
  2344. //
  2345. this.subMFL = this.matchFolderDataObject$.subscribe($ =>{
  2346. this.matchFolderDataObject = $
  2347. })
  2348.  
  2349.  
  2350. this.tsotsGameMatchKey = this.userService.uid
  2351. //
  2352. this.testTube = true
  2353. this.menu2soft = false
  2354. //console.log('players new' + human)
  2355. this.aiNum = parseInt(ai)
  2356. this.humanNum = parseInt(human)
  2357. var sumOne = parseInt(ai) + parseInt(human)
  2358.  
  2359. this.humansInGameNumber = this.aiNum
  2360. this.aiInGameNumber = this.humanNum
  2361. this.playersGameNumber = sumOne
  2362.  
  2363. if(sumOne > 4){
  2364. console.log('too many peaces ' + sumOne )
  2365. this.menu2soft = true
  2366. return;
  2367. }
  2368.  
  2369. //trigger open lobby
  2370. //number = number of human players to connect to .
  2371. if(human> 1 ){
  2372. this.menu2softLobby = true
  2373. this.cancelMenu2soft()
  2374. this.menu2softLobbyView(ai, human)
  2375.  
  2376.  
  2377. this.humansInGameNumber = this.humanNum
  2378. this.aiInGameNumber = this.aiNum
  2379. this.playersGameNumber = sumOne
  2380. console.log('trying lobby service')
  2381. this.tsotsLobbyService.multiJoinLobby(this.aiNum,this.humansInGameNumber,this.playersGameNumber, this.userService.uid , this.userService.userArena$)
  2382. }else{
  2383.  
  2384. this.cancelMenu2soft()
  2385. console.log('1 human only game ')
  2386.  
  2387. this.createAI(ai)
  2388.  
  2389.  
  2390. for(let i = 0 ;i < this.userService.arrOb.length; i++){
  2391. this.userService.arrOb[i].player = i +1
  2392. }
  2393.  
  2394.  
  2395. this.gameManagerDatabase$ = this.af.database.list('BOTSGlobalData/tsots/gameManagerDatabase/')
  2396.  
  2397.  
  2398. //this.playersInGame = this.gameManagerDatabaseObject.playersObject.length
  2399.  
  2400. //this.currentTurn = this.gameManagerDatabaseObject.turn
  2401.  
  2402.  
  2403. this.gameManagerDatabase$.update(this.tsotsGameMatchKey,{matchKey: this.userService.uid})
  2404. this.gameManagerDatabase$.update(this.tsotsGameMatchKey,{turn: 1})
  2405. this.gameManagerDatabase$.update(this.tsotsGameMatchKey,{playersObject: this.userService.arrOb})
  2406. //this.gameManagerDatabase$.update(this.tsotsGameMatchKey,{playersObject: false})
  2407.  
  2408. //this.gameManagerDatabaseObject.crossBrowser.trading == false
  2409.  
  2410.  
  2411. this.aiInGameNumber = this.aiNum
  2412. this.playersGameNumber = sumOne
  2413.  
  2414. this.experiencingOfflineGamePlay = true
  2415. this.beginExperiencingOfflineGamePlay()
  2416.  
  2417.  
  2418. this.normansDatabase$ = this.af.database.list('BOTSGlobalData/lobbyHumanAI/' + this.tsotsGameMatchKey)
  2419. this.normansDatabase$.remove()
  2420. return;
  2421. }
  2422.  
  2423.  
  2424.  
  2425.  
  2426. //this.menu2soft = false
  2427. //
  2428. this.createAI(ai)
  2429.  
  2430.  
  2431. // some ai players will have to be created?
  2432.  
  2433. /// trigger to
  2434. }
  2435.  
  2436.  
  2437.  
  2438.  
  2439. joinExisting(){
  2440. //console.log('lobby object')
  2441. // console.log(this.userService.lobbyHumanAI)
  2442.  
  2443. this.setLoadCloudLobby()
  2444. }
  2445.  
  2446. gameType = 0 /// 1 =classic 2=expanse
  2447.  
  2448. createAI(ai){
  2449. console.log(ai)
  2450.  
  2451. //^keeps track of how many ai in game for turn counter
  2452. // tsotsGameMatchKey will always be this.uid VV
  2453. this.userService.aiFactory(ai, this.userService.uid , this.humansInGameNumber
  2454. , this.gameType
  2455. )
  2456. //ai = number of ai 2 create
  2457. }
  2458.  
  2459.  
  2460.  
  2461.  
  2462. menu2softLobby2
  2463.  
  2464. menu2ai
  2465. menu2human
  2466.  
  2467. menu2softLobbyView(x,y){
  2468. console.log(x + 'ai')
  2469. // create ai, put there name(s) in lobby view
  2470. console.log(y + 'human')
  2471.  
  2472. this.menu2ai = x
  2473. this.menu2human = y
  2474. // seek human
  2475. // x = ai
  2476. //y = human
  2477.  
  2478. let text = 'weirdo'
  2479. if (isNaN(x) || x < 2 || x > 4) { // 4 = limit, makign sure "number" isn't past limit
  2480. text = "Input not valid";
  2481. this.menu2softLobby = false
  2482. //this.menu2soft = true
  2483. } else {
  2484. text = "Input OK";
  2485. }
  2486.  
  2487. console.log(text)
  2488. }
  2489.  
  2490. //menu2softLobby2 = false
  2491. testTube
  2492.  
  2493. createAIopponent(){
  2494.  
  2495. // pass argument for how many u want to create !
  2496.  
  2497. this.userService.createAIuser()
  2498. // added a 1 in the argument
  2499.  
  2500. }
  2501.  
  2502. userArenaObject$
  2503. userArena$
  2504. playerTurn
  2505. gameMatchKey
  2506. inGamePlay
  2507. gameData
  2508.  
  2509. ////----------------- ARTIFICIAL INTELLIGENCE -- atoms genesis protien labratory
  2510. userFolderData$
  2511. userFolderData
  2512.  
  2513. devDebugPeaceMenu
  2514.  
  2515. devDebugPeaceTriggerClick(){
  2516.  
  2517. console.log('devDebugPeaceMenu')
  2518. this.devDebugPeaceMenu = true
  2519.  
  2520. }
  2521. devInput
  2522. keyHold
  2523. devMethod(value){
  2524.  
  2525. this.devInput = value
  2526. console.log('devmeth')
  2527.  
  2528. this.keyHold = this.clickedSprite.key
  2529.  
  2530.  
  2531. console.log(this.clickedSprite.key)
  2532. console.log('devInput')
  2533. console.log(this.devInput)
  2534.  
  2535. // this.clickedSprite.key = this.devInput
  2536.  
  2537.  
  2538. this.boardDBList$.update(this.devInput , {peace : this.clickedSprite})
  2539. this.boardDBList$.remove(this.clickedSprite.key)
  2540. this.cancelDevDebugPeaceMenu()
  2541. }
  2542.  
  2543. cancelDevDebugPeaceMenu(){
  2544. this.devDebugPeaceMenu = false
  2545. }
  2546.  
  2547.  
  2548. debugPeace(){
  2549.  
  2550. }
  2551.  
  2552. tsotsDebug(){
  2553.  
  2554.  
  2555. this.peaceBlockChainService.pushIt('hi')
  2556.  
  2557. // you tell me what player u clicked, and i can have the perpetual animator alert there browsers
  2558. // if we haven't cut that animator off....
  2559. }
  2560. seekDebug(){
  2561. console.log(this.userService.uid )
  2562. console.log(this.me)
  2563. console.log('ai array')
  2564. console.log(this.aiArray)
  2565.  
  2566. }
  2567. aiDebug(){
  2568. console.log('hi')
  2569. console.log(this.boardDBsideDataKeyed.playerTurn)
  2570. console.log('hi')
  2571. console.log(this.boardDBsideDataKeyed)
  2572. console.log('hi')
  2573. console.log(this.playerTurn)
  2574. }
  2575.  
  2576.  
  2577.  
  2578. multiDebug(){
  2579.  
  2580.  
  2581. console.log('multiDebug')
  2582. //console.log(this.userService.userFolderObject)
  2583. console.log('matchComponentInfo')
  2584. //console.log(this.userService.userFolderObject.matchComponentInfo)
  2585. //console.log('this.userService.userFolderObject.matchComponentInfo.gameMatchKey')
  2586. //console.log(this.userService.userFolderObject.matchComponentInfo.gameMatchKey)
  2587.  
  2588. console.log('gameManagerDatabaseMatchObject')
  2589. console.log(this.gameManagerDatabaseMatchObject)
  2590.  
  2591. this.playerTurn = this.gameManagerDatabaseMatchObject.playerTurn
  2592. console.log('subplayer turn')
  2593. console.log(this.playerTurn)
  2594. console.log('its my turn')
  2595. console.log(this.myTurn)
  2596.  
  2597.  
  2598. console.log('this . player')
  2599. console.log(this.player)
  2600.  
  2601. console.log('game manager my turn')
  2602. console.log(this.tsotsGameManagerService.myTurn)
  2603.  
  2604. console.log('game manager service game object')
  2605. console.log(this.gameManagerDatabaseMatchObject)
  2606.  
  2607. }
  2608.  
  2609.  
  2610.  
  2611. boardDBsideDataKeyed$
  2612. boardDBsideDataKeyed
  2613. startAIgame(){
  2614. this.player1uid= this.userService.uid
  2615. this.player1name= this.userService.userObject.displayName
  2616. this.player2uid= this.userService.AIuid
  2617. this.player2name= this.userService.AIname
  2618.  
  2619. // this.player3uid
  2620. //this.player4uid
  2621. this.gameMatchKey = this.userService.uid
  2622. this.playerTurn= 1
  2623.  
  2624.  
  2625. this.inGamePlay = true
  2626. console.log(this.player1uid)
  2627. console.log(this.player2uid)
  2628.  
  2629.  
  2630. //this.loadOfficialStoryBoard()
  2631.  
  2632.  
  2633. this.boardDBsideData$ = this.af.database.list('BOTSGlobalData/boardDBsideData/')
  2634.  
  2635. this.boardDBsideDataKeyed$ = this.af.database.object('BOTSGlobalData/boardDBsideData/'+this.gameMatchKey)
  2636.  
  2637.  
  2638.  
  2639. this.subSDobject = this.boardDBsideDataKeyed$.subscribe(
  2640. $ =>{ this.boardDBsideDataKeyed= $;
  2641. // now update the boardDB from db.
  2642. })
  2643.  
  2644.  
  2645.  
  2646.  
  2647.  
  2648. let totalBoard =[]
  2649.  
  2650. for(let i = 0 ; i < this.boardDBList.length ;i++){
  2651. totalBoard.push(this.boardDBList[i].peace)
  2652.  
  2653. }
  2654.  
  2655. // check board
  2656. // what peaces it owns -- definite peace ownership on gamestart
  2657. // make all availiable moves -- definite availiable moves.. (2 peace actions per turn?)
  2658. // end its turn .
  2659.  
  2660. //this.boardDBsideData$.remove()
  2661.  
  2662. this.boardDBsideData$.update(this.gameMatchKey, {
  2663. player1uid: this.player1uid,
  2664. player2uid: this.player2uid,
  2665. playerTurn : this.playerTurn,
  2666. gameMatchKey : this.player1uid,
  2667. totalBoard : totalBoard
  2668. })
  2669.  
  2670.  
  2671.  
  2672. }
  2673.  
  2674. startAIturn(){
  2675.  
  2676. // probably need to move this into a service before it becomes to dependant
  2677. // on component calls.
  2678.  
  2679.  
  2680. console.log( 'ai turn begins')
  2681. //console.log(this.boardDBList)
  2682.  
  2683.  
  2684. this.tsotsAIService.aiServiceStart(this.boardDBList$,this.boardDBList,
  2685. this.boardDBsideData$, this.boardDBsideDataKeyed,
  2686. this.gameMatchKey, this.gameWorld)
  2687.  
  2688. }
  2689.  
  2690.  
  2691.  
  2692. selectedFolderLoad
  2693.  
  2694. userFolderPetition(){
  2695.  
  2696. // make deletable and change name able. little fab buttons by saved name.
  2697.  
  2698. this.selectedFolderLoad = 1
  2699.  
  2700. this.savedBoardMenuView = []
  2701. console.log('test two')
  2702.  
  2703.  
  2704. this.userObject= this.userService.userObject
  2705.  
  2706. console.log(this.userObject)
  2707.  
  2708.  
  2709.  
  2710. for(let i = 0 ; i < this.userService.userFolderSavedBoards.length; i++){
  2711. let saved = this.userService.userFolderSavedBoards[i]
  2712.  
  2713.  
  2714. saved.name = saved.$key
  2715. //saved.owner = this.userService.userObject.displayName
  2716. //saved.ownerUID =this.userService.userObject.uid
  2717. console.log(saved)
  2718. this.savedBoardMenuView.push(saved)
  2719. }
  2720.  
  2721. this.selectedFolder = this.userService.userFolderSavedBoards
  2722. }
  2723.  
  2724.  
  2725. subEx
  2726.  
  2727.  
  2728. globalFolderPetition(){
  2729. this.selectedFolderLoad = 2
  2730.  
  2731.  
  2732. this.savedBoardMenuView = []
  2733. this.userObject= this.userService.userObject
  2734.  
  2735. this.subEx = this.franchiseBoardDatabase$.subscribe($ =>
  2736. {
  2737. this.franchiseBoardDatabase = $
  2738.  
  2739.  
  2740.  
  2741. for(let i = 0 ; i < this.franchiseBoardDatabase.length; i++){
  2742. let saved = this.franchiseBoardDatabase[i]
  2743.  
  2744.  
  2745. saved.name = saved.$key
  2746. //saved.owner = this.userService.userObject.displayName
  2747. //saved.ownerUID =this.userService.userObject.uid
  2748.  
  2749. this.savedBoardMenuView.push(saved)
  2750. this.selectedFolder = this.franchiseBoardDatabase
  2751.  
  2752. }
  2753. ;}
  2754. )
  2755.  
  2756. }
  2757.  
  2758. selectedFolder
  2759. officialStoryBoard$
  2760. officialStoryBoard
  2761.  
  2762. officialStoryBoards
  2763.  
  2764. subY
  2765. franchiseBoardsPetition(){
  2766. this.selectedFolderLoad = 3
  2767. this.savedBoardMenuView = []
  2768.  
  2769.  
  2770. this.subY = this.officialStoryBoards$.subscribe($ =>
  2771. {
  2772. this.officialStoryBoards = $
  2773.  
  2774. for(let i = 0 ; i < this.officialStoryBoards.length; i++){
  2775. let saved = this.officialStoryBoards[i]
  2776.  
  2777.  
  2778. saved.name = saved.$key
  2779. //saved.owner = this.userService.userObject.displayName
  2780. //saved.ownerUID =this.userService.userObject.uid
  2781.  
  2782. this.savedBoardMenuView.push(saved)
  2783. this.selectedFolder = this.officialStoryBoards
  2784. }
  2785. ;}
  2786. )
  2787.  
  2788.  
  2789. }
  2790.  
  2791.  
  2792. loadOfficialStoryBoard(){
  2793.  
  2794. this.boardDBList$.remove()
  2795.  
  2796. // loads official classic and tsots boards.
  2797. let saved = this.officialStoryBoard[0]
  2798. //console.log(saved)
  2799.  
  2800. for(let i = 0; i<= saved.length; i++){
  2801. var sprite = saved[i]
  2802.  
  2803.  
  2804.  
  2805. this.boardDBList$.update(sprite.key , {peace : sprite})
  2806.  
  2807. }
  2808.  
  2809. this.gameWorld = this.officialStoryBoard[1]
  2810. }
  2811.  
  2812. loadBoard(it){
  2813. this.boardDBList$.remove()
  2814.  
  2815.  
  2816. let saved = this.franchiseBoardDatabase[it].board
  2817. console.log(saved)
  2818.  
  2819. for(let i = 0; i < saved.length; i++){
  2820. var sprite = saved[i]
  2821.  
  2822. console.log(sprite)
  2823. this.boardDBList$.update(sprite.key , {peace : sprite})
  2824.  
  2825.  
  2826.  
  2827. }
  2828.  
  2829. this.gameWorld = this.selectedFolder[it].boardDimension
  2830. console.log(this.selectedFolder[it].boardDimension)
  2831.  
  2832. }
  2833.  
  2834. prophets = {
  2835. john : {
  2836. name : 'john'
  2837. }
  2838.  
  2839. }
  2840.  
  2841.  
  2842.  
  2843.  
  2844. keyRingReturn = []
  2845. sub1
  2846. sub2
  2847. dataList
  2848.  
  2849. testLog(){
  2850.  
  2851. if(this.rangeObject){
  2852. console.log(this.rangeObject)
  2853. }
  2854. }
  2855.  
  2856. resizeCanvas(width, height){
  2857.  
  2858. /// need to fill
  2859. this.canvas.width =width
  2860. this.canvas.height =height
  2861.  
  2862. }
  2863.  
  2864.  
  2865. htmlText
  2866. spaceHtml = []
  2867.  
  2868. wideBoardView(){
  2869.  
  2870. if(this.gameWorld.width <= 10){
  2871. return ;
  2872. }
  2873.  
  2874.  
  2875. if(this.canvas.width !== this.gameWorld.width * 48){
  2876. console.log('wide board')
  2877. this.canvas.width = this.gameWorld.width * 48
  2878.  
  2879. console.log(this.canvas.width)
  2880.  
  2881. this.spaceHtml = [1]
  2882.  
  2883. }else{
  2884. this.canvas.width =10*48
  2885.  
  2886. this.spaceHtml = []
  2887. }
  2888.  
  2889. }
  2890.  
  2891.  
  2892.  
  2893.  
  2894. zoomInCanvas(){
  2895. }
  2896. zoomOutCanvas(){
  2897. }
  2898.  
  2899.  
  2900. resizeGameWorld(){
  2901. // to change size of board
  2902. }
  2903.  
  2904. resizeCanvas2(width, height){
  2905.  
  2906. //take argum based on measurment requirements
  2907.  
  2908. this.canvas2.width =width
  2909. this.canvas2.height =height
  2910. }
  2911.  
  2912. //
  2913. divFontLeft = 233
  2914. divTop = 273 // other wise first div starts off too far off center /
  2915.  
  2916. user
  2917.  
  2918. @ViewChild("doc")
  2919.  
  2920. @ViewChild("menuCanvas")
  2921. menuCanvas
  2922.  
  2923. @ViewChild("inventoryMenuCanvas")
  2924. inventoryMenuCanvas
  2925.  
  2926.  
  2927. @ViewChild("trade1Canvas")
  2928. trade1Canvas
  2929.  
  2930. @ViewChild("trade2Canvas")
  2931. trade2Canvas
  2932. @ViewChild("offer1Canvas")
  2933. offer1Canvas
  2934. @ViewChild("offer2Canvas")
  2935. offer2Canvas
  2936.  
  2937.  
  2938.  
  2939. @ViewChild("still1Canvas")
  2940. still1Canvas
  2941.  
  2942. @ViewChild("still2Canvas")
  2943. still2Canvas
  2944. @ViewChild("offerStill1Canvas")
  2945. offerStill1Canvas
  2946. @ViewChild("offerStill2Canvas")
  2947. offerStill2Canvas
  2948.  
  2949.  
  2950.  
  2951. @ViewChild("counter1Canvas")
  2952. counter1Canvas
  2953.  
  2954. @ViewChild("counter2Canvas")
  2955. counter2Canvas
  2956. @ViewChild("counterOffer1Canvas")
  2957. counterOffer1Canvas
  2958. @ViewChild("counterOffer2Canvas")
  2959. counterOffer2Canvas
  2960.  
  2961.  
  2962.  
  2963. @ViewChild("multiPeaceMenuCanvas")
  2964. multiPeaceMenuCanvas
  2965.  
  2966. @ViewChild("multiLeftClickCanvas")
  2967. multiLeftClickCanvas
  2968.  
  2969. @ViewChild("fakeCanvas")
  2970. fakeCanvas
  2971.  
  2972. @ViewChild("menuTrigger")
  2973. menuTrigger
  2974. @ViewChild("myMenu")
  2975. myMenu
  2976.  
  2977. @ViewChild("menuTrigger2")
  2978. menuTrigger2
  2979. @ViewChild("menu2")
  2980. menu2
  2981.  
  2982.  
  2983.  
  2984. @ViewChild("menuTrigger3")
  2985. menuTrigger3
  2986. @ViewChild("menu3")
  2987. menu3
  2988.  
  2989.  
  2990.  
  2991.  
  2992.  
  2993. @ViewChild("statsMenuTrigger")
  2994. statsMenuTrigger
  2995. @ViewChild("statsMenu")
  2996. statsMenu
  2997.  
  2998. @ViewChild("inventoryMenuTrigger")
  2999. inventoryMenuTrigger
  3000. @ViewChild("inventoryMenu")
  3001. inventoryMenu
  3002.  
  3003. @ViewChild("inventory2MenuTrigger")
  3004. inventory2MenuTrigger
  3005. @ViewChild("inventory2Menu")
  3006. inventory2Menu
  3007.  
  3008. @ViewChild("skillsMenuTrigger")
  3009. skillsMenuTrigger
  3010. @ViewChild("skillsMenu")
  3011. skillsMenu
  3012.  
  3013. @ViewChild("customizeMenuTrigger")
  3014. customizeMenuTrigger
  3015. @ViewChild("customizeMenu")
  3016. customizeMenu
  3017.  
  3018.  
  3019. boardMatrix = []
  3020.  
  3021.  
  3022. menuBool = false
  3023.  
  3024. menuBox
  3025. menuView
  3026. menuMethod
  3027. dialogeBox
  3028. doc
  3029. canvas
  3030. context
  3031.  
  3032. rangeVar
  3033.  
  3034.  
  3035. attacking = false ;
  3036.  
  3037. // handle all the clicks and superficial menus and views,
  3038. // from this component. but most of these things will be done in the game manager?
  3039.  
  3040.  
  3041.  
  3042.  
  3043.  
  3044. menuOptions = []
  3045.  
  3046. player1Avatar = "https://tracker.moodle.org/secure/projectavatar?size=small" ;
  3047. player2Avatar = "https://ecosystem.atlassian.net/secure/projectavatar?pid=17170&avatarId=14500" ;
  3048. player3Avatar = "https://tracker.moodle.org/secure/projectavatar?size=small" ;
  3049. player4Avatar = "https://ecosystem.atlassian.net/secure/projectavatar?pid=17170&avatarId=14500" ;
  3050.  
  3051.  
  3052.  
  3053.  
  3054. spriteObject = {
  3055. imageSrc : null,
  3056. sourceX: 0,
  3057. sourceY: 0,
  3058. sourceWidth: 48,
  3059. sourceHeight: 48,
  3060. x: 0,
  3061. y: 0,
  3062. width: 48,
  3063. height: 48,
  3064. };
  3065.  
  3066. peace2
  3067. peace3
  3068.  
  3069. boardTileCoordinate
  3070.  
  3071.  
  3072. terrainType //can peace move here ? under what conditions ? // are two different terain types possible?
  3073.  
  3074. spriteCursor
  3075. rangeSprite
  3076.  
  3077. rangeObject = {
  3078. right : [],
  3079. left : [],
  3080. up : [],
  3081. down : [],
  3082. rangeArray : []
  3083. }
  3084.  
  3085. animationSprite
  3086. placementSprite
  3087.  
  3088. background
  3089. background2
  3090. gameWorld = {
  3091. x: 0,
  3092. y: 0 ,
  3093. width : 10,
  3094. height: 10,
  3095. }
  3096. camera
  3097. backgroundSprites =[]
  3098. foregroundSprites =[]
  3099.  
  3100. placingCreation
  3101.  
  3102.  
  3103. boardDBList$
  3104. boardDBList = []
  3105.  
  3106. boardDBObject$
  3107. boardDBObject
  3108.  
  3109.  
  3110.  
  3111. peaceMatrix
  3112.  
  3113. menuCanvasOn
  3114.  
  3115. turnMenuCanvasOn(){
  3116. //stop rendering canas
  3117. }
  3118. turnMenuCanvasOff(){
  3119.  
  3120. }
  3121.  
  3122. debug(){
  3123.  
  3124. this.boardDBList$.remove()
  3125. }
  3126.  
  3127. debugList(){
  3128. console.log(this.boardDBList)
  3129. }
  3130.  
  3131. //debugA(){
  3132. //this.boardDBList$.push({ peace: this.tsotsPeaceService.peaceLegend.createPeace2 }); }
  3133.  
  3134. boardMatrixList = []
  3135. tsotsMultiGame(){
  3136.  
  3137.  
  3138. }
  3139.  
  3140.  
  3141. peaceCreation(){
  3142.  
  3143. }
  3144.  
  3145. animationCreation(){
  3146.  
  3147. }
  3148. /*
  3149. userObject ={
  3150. uid : 0,
  3151. email: 0,
  3152. userName: 0,
  3153. phoneNumber: 'for push alerts',
  3154. password : 'for tranfer confirmations'
  3155. }
  3156. */
  3157. userName
  3158.  
  3159. tsotsList$
  3160. tsotsList
  3161.  
  3162. sub3
  3163.  
  3164. debug01(){
  3165. console.log(
  3166. this.userService.user[0].$value);
  3167.  
  3168.  
  3169. console.log(this.userService.user)
  3170.  
  3171. for(var prop in this.userService.user){
  3172.  
  3173.  
  3174.  
  3175.  
  3176. if(this.userService.user[prop].$key = 'userName'){
  3177.  
  3178. console.log('yeah!' + this.userService.user[prop].$value)
  3179. }
  3180. }
  3181. }
  3182.  
  3183. peaceMenu(tile){
  3184.  
  3185. this.imagingSrc = 0 ;
  3186. switch(tile) {
  3187. case 1:
  3188. this.imagingSrc = {sauce:this.tsotsPeaceService.gate1.source,
  3189. height:this.tsotsPeaceService.dungeon_B.height , width:this.tsotsPeaceService.dungeon_B.width}
  3190.  
  3191. break;
  3192. case 2:
  3193. this.imagingSrc = {sauce:this.tsotsPeaceService.gate2.source, height:this.tsotsPeaceService.dungeon_B.height , width:this.tsotsPeaceService.dungeon_B.width}
  3194.  
  3195. break;
  3196. case 3:
  3197. this.imagingSrc = {sauce:this.tsotsPeaceService.chest.source ,
  3198. height:this.tsotsPeaceService.dungeon_B.height , width:this.tsotsPeaceService.dungeon_B.width}
  3199. break;
  3200. case 4:
  3201. this.imagingSrc = {sauce:this.tsotsPeaceService.crystal.source
  3202. ,
  3203. height:this.tsotsPeaceService.dungeon_B.height , width:this.tsotsPeaceService.dungeon_B.width}
  3204. break; case 5:
  3205. this.imagingSrc = {sauce:this.tsotsPeaceService.door1.source ,
  3206. height:this.tsotsPeaceService.dungeon_B.height , width:this.tsotsPeaceService.dungeon_B.width}
  3207.  
  3208. break;
  3209. case 6:
  3210. this.imagingSrc = {sauce:this.tsotsPeaceService.door2.source,
  3211. height:this.tsotsPeaceService.dungeon_B.height , width:this.tsotsPeaceService.dungeon_B.width}
  3212. break; case 7:
  3213.  
  3214. this.imagingSrc = {sauce:this.tsotsPeaceService.flame.source ,
  3215. height:this.tsotsPeaceService.dungeon_B.height , width:this.tsotsPeaceService.dungeon_B.width}
  3216. break;
  3217. case 8:
  3218. this.imagingSrc = {sauce:this.tsotsPeaceService.other1.source ,
  3219. height:this.tsotsPeaceService.dungeon_B.height , width:this.tsotsPeaceService.dungeon_B.width}
  3220. break; case 9:
  3221. this.imagingSrc = {sauce:this.tsotsPeaceService.other2.source ,
  3222. height:this.tsotsPeaceService.dungeon_B.height , width:this.tsotsPeaceService.dungeon_B.width}
  3223. break;
  3224. case 10:
  3225. this.imagingSrc = {sauce:this.tsotsPeaceService.sfDoor1.source ,
  3226. height:this.tsotsPeaceService.dungeon_B.height , width:this.tsotsPeaceService.dungeon_B.width}
  3227. break; case 11:
  3228. this.imagingSrc = {sauce:this.tsotsPeaceService.sfDoor2.source ,
  3229. height:this.tsotsPeaceService.dungeon_B.height , width:this.tsotsPeaceService.dungeon_B.width}
  3230. break;
  3231. case 12:
  3232.  
  3233. this.imagingSrc = {sauce:this.tsotsPeaceService.switch1.source ,
  3234. height:this.tsotsPeaceService.dungeon_B.height , width:this.tsotsPeaceService.dungeon_B.width}
  3235. break;
  3236. case 13:
  3237. this.imagingSrc = {sauce:this.tsotsPeaceService.switch2.source ,
  3238. height:this.tsotsPeaceService.dungeon_B.height , width:this.tsotsPeaceService.dungeon_B.width}
  3239. break;
  3240. case 14:
  3241. this.imagingSrc = {sauce:this.tsotsPeaceService.bigMonster1.source
  3242. ,
  3243. height:this.tsotsPeaceService.dungeon_B.height , width:this.tsotsPeaceService.dungeon_B.width}
  3244. break; case 15:
  3245. this.imagingSrc = {sauce:this.tsotsPeaceService.bigMonster2.source ,
  3246. height:this.tsotsPeaceService.dungeon_B.height , width:this.tsotsPeaceService.dungeon_B.width}
  3247.  
  3248. break;
  3249. case 16:
  3250. this.imagingSrc = {sauce:this.tsotsPeaceService.charactersActor1.source,
  3251. height:this.tsotsPeaceService.dungeon_B.height , width:this.tsotsPeaceService.dungeon_B.width}
  3252. break; case 17:
  3253.  
  3254. this.imagingSrc = {sauce:this.tsotsPeaceService.charactersActor2.source ,
  3255. height:this.tsotsPeaceService.dungeon_B.height , width:this.tsotsPeaceService.dungeon_B.width}
  3256. break;
  3257. case 18:
  3258. this.imagingSrc = {sauce:this.tsotsPeaceService.charactersActor3.source ,
  3259. height:this.tsotsPeaceService.dungeon_B.height , width:this.tsotsPeaceService.dungeon_B.width}
  3260. break; case 19:
  3261. this.imagingSrc = {sauce:this.tsotsPeaceService.damage1.source ,
  3262. height:this.tsotsPeaceService.dungeon_B.height , width:this.tsotsPeaceService.dungeon_B.width}
  3263. break;
  3264. case 20:
  3265. this.imagingSrc = {sauce:this.tsotsPeaceService.damage2.source ,
  3266. height:this.tsotsPeaceService.dungeon_B.height , width:this.tsotsPeaceService.dungeon_B.width}
  3267. break; case 21:
  3268. this.imagingSrc = {sauce:this.tsotsPeaceService.damage3.source ,
  3269. height:this.tsotsPeaceService.dungeon_B.height , width:this.tsotsPeaceService.dungeon_B.width}
  3270. break;
  3271. case 22:
  3272. this.imagingSrc = {sauce:this.tsotsPeaceService.charactersEvil.source ,
  3273. height:this.tsotsPeaceService.dungeon_B.height , width:this.tsotsPeaceService.dungeon_B.width}
  3274. break;
  3275. case 23:
  3276. this.imagingSrc = {sauce:this.tsotsPeaceService.charactersMonster.source ,
  3277. height:this.tsotsPeaceService.dungeon_B.height , width:this.tsotsPeaceService.dungeon_B.width}
  3278. break;
  3279. case 24:
  3280. this.imagingSrc = {sauce:this.tsotsPeaceService.characterNature.source
  3281. ,
  3282. height:this.tsotsPeaceService.dungeon_B.height , width:this.tsotsPeaceService.bigMonster2.width}
  3283. break; case 25:
  3284. this.imagingSrc = {sauce:this.tsotsPeaceService.charactersPeople1.source ,
  3285. height:this.tsotsPeaceService.dungeon_B.height , width:this.tsotsPeaceService.dungeon_B.width}
  3286.  
  3287. break;
  3288. case 26:
  3289. this.imagingSrc = {sauce:this.tsotsPeaceService.charactersPeople2.source,
  3290. height:this.tsotsPeaceService.dungeon_B.height , width:this.tsotsPeaceService.dungeon_B.width}
  3291. break; case 27:
  3292.  
  3293. this.imagingSrc = {sauce:this.tsotsPeaceService.charactersPeople3.source ,
  3294. height:this.tsotsPeaceService.dungeon_B.height , width:this.tsotsPeaceService.dungeon_B.width}
  3295. break;
  3296. case 28:
  3297. this.imagingSrc = {sauce:this.tsotsPeaceService.charctersPeople4.source ,
  3298. height:this.tsotsPeaceService.dungeon_B.height , width:this.tsotsPeaceService.dungeon_B.width}
  3299. break;
  3300. case 29:
  3301. this.imagingSrc = {sauce:this.tsotsPeaceService.vehicle.source ,
  3302. height:this.tsotsPeaceService.dungeon_B.height , width:this.tsotsPeaceService.dungeon_B.width}
  3303. break;
  3304. case 30:
  3305. this.imagingSrc = {sauce:this.tsotsPeaceService.charctersHiTech.source ,
  3306. height:this.tsotsPeaceService.dungeon_B.height , width:this.tsotsPeaceService.dungeon_B.width}
  3307. break;
  3308. default:
  3309. console.log('default')
  3310. }
  3311.  
  3312.  
  3313. }
  3314.  
  3315.  
  3316. deletePeace(){
  3317. this.boardDBList$.remove(this.clickedSprite.key);
  3318.  
  3319. }
  3320.  
  3321. tileMenu(tile) {
  3322.  
  3323. this.imagingSrc = 0 ;
  3324. switch(tile) {
  3325. case 1:
  3326. this.imagingSrc = {sauce:this.tsotsPeaceService.dungeon_A1.source ,
  3327. height:this.tsotsPeaceService.dungeon_B.height , width:this.tsotsPeaceService.dungeon_B.width}
  3328. console.log('boaaaarrararad')
  3329. break;
  3330. case 2:
  3331. this.imagingSrc = {sauce:this.tsotsPeaceService.dungeon_A2.source ,
  3332. height:this.tsotsPeaceService.dungeon_B.height , width:this.tsotsPeaceService.dungeon_B.width}
  3333. break;
  3334. case 3:
  3335. this.imagingSrc = {sauce:this.tsotsPeaceService.dungeon_A4.source ,
  3336. height:this.tsotsPeaceService.dungeon_B.height , width:this.tsotsPeaceService.dungeon_B.width}
  3337. break;
  3338. case 4:
  3339. this.imagingSrc = {sauce:this.tsotsPeaceService.dungeon_A5.source ,
  3340. height:this.tsotsPeaceService.dungeon_B.height , width:this.tsotsPeaceService.dungeon_B.width}
  3341. break; case 5:
  3342. this.imagingSrc = {sauce:this.tsotsPeaceService.dungeon_B.source ,
  3343. height:this.tsotsPeaceService.dungeon_B.height , width:this.tsotsPeaceService.dungeon_B.width}
  3344. break;
  3345. case 6:
  3346. this.imagingSrc = {sauce:this.tsotsPeaceService.dungeon_C.source ,
  3347. height:this.tsotsPeaceService.dungeon_B.height , width:this.tsotsPeaceService.dungeon_B.width}
  3348.  
  3349. break; case 7:
  3350. this.imagingSrc = {sauce:this.tsotsPeaceService.inside_A1.source ,
  3351. height:this.tsotsPeaceService.dungeon_B.height , width:this.tsotsPeaceService.dungeon_B.width}
  3352. break;
  3353.  
  3354. case 8:
  3355. this.imagingSrc = {sauce:this.tsotsPeaceService.inside_A2.source ,
  3356. height:this.tsotsPeaceService.dungeon_B.height , width:this.tsotsPeaceService.dungeon_B.width}
  3357. break;
  3358. case 9:
  3359. this.imagingSrc = {sauce:this.tsotsPeaceService.inside_A4.source ,
  3360. height:this.tsotsPeaceService.dungeon_B.height , width:this.tsotsPeaceService.dungeon_B.width}
  3361. break; case 10:
  3362. this.imagingSrc = {sauce:this.tsotsPeaceService.inside_A5.source ,
  3363. height:this.tsotsPeaceService.dungeon_B.height , width:this.tsotsPeaceService.dungeon_B.width}
  3364. break;
  3365. case 11:
  3366. this.imagingSrc = {sauce:this.tsotsPeaceService.inside_B.source ,
  3367. height:this.tsotsPeaceService.dungeon_B.height , width:this.tsotsPeaceService.dungeon_B.width}
  3368. break; case 12:
  3369. this.imagingSrc = {sauce:this.tsotsPeaceService.inside_C.source ,
  3370. height:this.tsotsPeaceService.dungeon_B.height , width:this.tsotsPeaceService.dungeon_B.width}
  3371. break;
  3372. case 13:
  3373. this.imagingSrc = {sauce:this.tsotsPeaceService.outside_A1.source ,
  3374. height:this.tsotsPeaceService.dungeon_B.height , width:this.tsotsPeaceService.dungeon_B.width}
  3375. break;
  3376.  
  3377. case 14:
  3378. this.imagingSrc = {sauce:this.tsotsPeaceService.outside_A2.source ,
  3379. height:this.tsotsPeaceService.dungeon_B.height , width:this.tsotsPeaceService.dungeon_B.width}
  3380. break;
  3381. case 15:
  3382. this.imagingSrc = {sauce:this.tsotsPeaceService.outside_A3.source ,
  3383. height:this.tsotsPeaceService.dungeon_B.height , width:this.tsotsPeaceService.dungeon_B.width}
  3384. break; case 16:
  3385. this.imagingSrc = {sauce:this.tsotsPeaceService.outside_A4.source ,
  3386. height:this.tsotsPeaceService.dungeon_B.height , width:this.tsotsPeaceService.dungeon_B.width}
  3387. break;
  3388. case 17:
  3389. this.imagingSrc = {sauce:this.tsotsPeaceService.outside_A5.source ,
  3390. height:this.tsotsPeaceService.dungeon_B.height , width:this.tsotsPeaceService.dungeon_B.width}
  3391. break;
  3392. case 18:
  3393. this.imagingSrc = {sauce:this.tsotsPeaceService.outside_B.source ,
  3394. height:this.tsotsPeaceService.dungeon_B.height , width:this.tsotsPeaceService.dungeon_B.width}
  3395. break;
  3396. case 19:
  3397. this.imagingSrc = {sauce:this.tsotsPeaceService.outside_C.source ,
  3398. height:this.tsotsPeaceService.dungeon_B.height , width:this.tsotsPeaceService.dungeon_B.width}
  3399. break; case 20:
  3400. this.imagingSrc = {sauce:this.tsotsPeaceService.sfInsideA4.source ,
  3401. height:this.tsotsPeaceService.dungeon_B.height , width:this.tsotsPeaceService.dungeon_B.width}
  3402. break;
  3403. case 21:
  3404. this.imagingSrc = {sauce:this.tsotsPeaceService.sfInsideB.source ,
  3405. height:this.tsotsPeaceService.dungeon_B.height , width:this.tsotsPeaceService.dungeon_B.width}
  3406. break; case 22:
  3407. this.imagingSrc = {sauce:this.tsotsPeaceService.sfInsideC.source ,
  3408. height:this.tsotsPeaceService.dungeon_B.height , width:this.tsotsPeaceService.dungeon_B.width}
  3409. break;
  3410. case 23:
  3411. this.imagingSrc = {sauce:this.tsotsPeaceService.sfOutside_A3.source ,
  3412. height:this.tsotsPeaceService.dungeon_B.height , width:this.tsotsPeaceService.dungeon_B.width}
  3413. break;
  3414. case 24:
  3415. this.imagingSrc = {sauce:this.tsotsPeaceService.sfOutside_A4.source ,
  3416. height:this.tsotsPeaceService.dungeon_B.height , width:this.tsotsPeaceService.dungeon_B.width}
  3417. break;
  3418. case 25:
  3419. this.imagingSrc = {sauce:this.tsotsPeaceService.sfOutside_A5.source ,
  3420. height:this.tsotsPeaceService.dungeon_B.height , width:this.tsotsPeaceService.dungeon_B.width}
  3421. break; case 26:
  3422. this.imagingSrc = {sauce:this.tsotsPeaceService.sfOutside_B.source ,
  3423. height:this.tsotsPeaceService.dungeon_B.height , width:this.tsotsPeaceService.dungeon_B.width}
  3424. break;
  3425. case 27:
  3426. this.imagingSrc = {sauce:this.tsotsPeaceService.sfOutside_C.source ,
  3427. height:this.tsotsPeaceService.dungeon_B.height , width:this.tsotsPeaceService.dungeon_B.width}
  3428. break; case 28:
  3429. this.imagingSrc = {sauce:this.tsotsPeaceService.world_A1.source ,
  3430. height:this.tsotsPeaceService.dungeon_B.height , width:this.tsotsPeaceService.dungeon_B.width}
  3431. break;
  3432. case 29:
  3433. this.imagingSrc = {sauce:this.tsotsPeaceService.world_A2.source ,
  3434. height:this.tsotsPeaceService.dungeon_B.height , width:this.tsotsPeaceService.dungeon_B.width}
  3435. break; case 30:
  3436. this.imagingSrc = {sauce:this.tsotsPeaceService.world_B.source ,
  3437. height:this.tsotsPeaceService.dungeon_B.height , width:this.tsotsPeaceService.dungeon_B.width}
  3438. break;
  3439. case 31:
  3440. this.imagingSrc = {sauce:this.tsotsPeaceService.world_C.source ,
  3441. height:this.tsotsPeaceService.dungeon_B.height , width:this.tsotsPeaceService.dungeon_B.width}
  3442. break;
  3443. case 32:
  3444. this.imagingSrc = {sauce:this.tsotsPeaceService.world_C.source ,
  3445. height:this.tsotsPeaceService.dungeon_B.height , width:this.tsotsPeaceService.dungeon_B.width}
  3446. break;
  3447.  
  3448. // 2nd canvas needs to be scrollable as well.
  3449. // some stuff comes off map.
  3450.  
  3451.  
  3452.  
  3453.  
  3454. default:
  3455. console.log('default')
  3456. }
  3457.  
  3458.  
  3459.  
  3460. console.log(this.imagingSrc)
  3461.  
  3462. }
  3463.  
  3464.  
  3465. imagingSrc
  3466. officialStoryBoards$
  3467.  
  3468. subOfficial
  3469.  
  3470. boardDBsideData$
  3471. boardDBsideData
  3472. subSD
  3473. boardDBsideDataObject$
  3474. boardDBsideDataObject
  3475. subSDobject
  3476. subTen
  3477. centralBotscoinBlockChainList$
  3478. centralBotscoinBlockChainList
  3479. centralPeaceBlockChainList$
  3480. centralPeaceBlockChainList
  3481.  
  3482. centralTurnsBlockChainList$
  3483. centralTurnsBlockChainList
  3484.  
  3485. subChain
  3486. subChain2
  3487. subChain3
  3488.  
  3489. classicLevelsList$
  3490. classicLevelsList
  3491.  
  3492. storyLevelsList$
  3493. storyLevelsList
  3494.  
  3495. subClassic
  3496. subStory
  3497. subObject
  3498.  
  3499. subBetter
  3500. subClassicJSON
  3501.  
  3502. subAudio
  3503.  
  3504.  
  3505. classicBoardBuildsJSON$
  3506. classicBoardBuildsJSON
  3507. gameSideDataList$
  3508. gameSideDataList
  3509. gameSideDataObject$
  3510. gameSideDataObject
  3511. legalLogList$
  3512. legalLogList
  3513. subAnimate
  3514. boardDBAnimationList$
  3515. boardDBAnimationList
  3516.  
  3517. boardDBAudioList$
  3518. boardDBAudioList
  3519.  
  3520. subLegalLog
  3521.  
  3522. debugVar = 1
  3523.  
  3524.  
  3525. //maybe a global skills
  3526.  
  3527.  
  3528.  
  3529. soundDebug(){
  3530.  
  3531. eval("this.audioService.soundEffectLegend.Attack3.play()")
  3532.  
  3533. //this.audioService.soundEffectLegend.Attack3.play()
  3534.  
  3535. console.log('this.humanArray')
  3536.  
  3537. }
  3538.  
  3539. dedicatedDebugMenu
  3540.  
  3541. dedicatedDebugMenuTrigger(){
  3542. this.dedicatedDebugMenu = true
  3543.  
  3544. console.log('debug result')
  3545.  
  3546.  
  3547.  
  3548.  
  3549. }
  3550.  
  3551. cancelDedicatedDebugMenu(){
  3552. this.dedicatedDebugMenu = false
  3553. }
  3554.  
  3555.  
  3556.  
  3557. debugVar1
  3558. debugArray1 =[]
  3559. dedicatedDebug(){
  3560.  
  3561. console.log('tried.')
  3562. console.log(this.boardDBList.length)
  3563.  
  3564. for(let i = 0 ; i< this.boardDBList.length; i++){
  3565.  
  3566. this.debugArray1.push(this.boardDBList[i].peace)
  3567. }
  3568. console.log('tried.2')
  3569. console.table(this.debugArray1)
  3570. console.log(this.debugArray1)
  3571. }
  3572.  
  3573. ngAfterViewChecked(){
  3574. //console.log(`viewChecked`);
  3575. //this.databaseService.overlappingPeacesCheck()
  3576.  
  3577. // can cut this after it finds boardDBList
  3578. }
  3579.  
  3580. ngOnDestroy(){
  3581. console.log("destroyeR")
  3582. }
  3583.  
  3584. constructor(
  3585. public af: AngularFire ,
  3586. private userService : userService,
  3587.  
  3588. private tsotsLobbyService : tsotsLobbyService ,
  3589.  
  3590. private tsotsGameManagerService : tsotsGameManagerService,
  3591.  
  3592. private tsotsPeaceService : tsotsPeaceService ,
  3593.  
  3594. private tsotsAIService : tsotsAIService,
  3595.  
  3596. private peaceBlockChainService : peaceBlockChainService,
  3597.  
  3598. private turnsBlockChainService :turnsBlockChainService,
  3599. private animationService : animationService,
  3600. public audioService : audioService ,
  3601. private blockChain : blockChain,
  3602.  
  3603. private databaseService : databaseService,
  3604. private skillsService : skillsService
  3605.  
  3606. ){
  3607.  
  3608.  
  3609. //console.log('this is our file!')
  3610.  
  3611. this.gameSideDataList$ = this.databaseService.gameSideDataList$
  3612.  
  3613. this.gameSideDataObject$ = this.databaseService.gameSideDataObject$
  3614.  
  3615.  
  3616. this.boardDBList$ = this.databaseService.boardDBList$
  3617.  
  3618. this.boardDBObject$ = this.databaseService.boardDBObject$
  3619.  
  3620. this.userService.gameValue = 2
  3621.  
  3622. this.userName = this.userService.user
  3623. //console.log(this.userName)
  3624. //console.log('this.userName')
  3625.  
  3626.  
  3627. this.centralBotscoinBlockChainList$ = this.af.database.list('BOTSblockChain/centralBotscoinBlockChain/')
  3628.  
  3629. this.subChain = this.centralBotscoinBlockChainList$.subscribe($ =>
  3630. {
  3631. console.log($)
  3632. this.centralBotscoinBlockChainList = $})
  3633.  
  3634.  
  3635. ////
  3636.  
  3637.  
  3638.  
  3639.  
  3640. this.centralPeaceBlockChainList$ = this.af.database.list('BOTSblockChain/centralPeaceBlockChain/')
  3641.  
  3642. this.subChain2 = this.centralPeaceBlockChainList$.subscribe($ =>
  3643. {
  3644.  
  3645. this.centralPeaceBlockChainList = $})
  3646.  
  3647.  
  3648. this.centralTurnsBlockChainList$ = this.af.database.list('BOTSblockChain/centralTurnsBlockChain/')
  3649.  
  3650. this.subChain3 = this.centralTurnsBlockChainList$.subscribe($ =>
  3651. {
  3652.  
  3653. this.centralTurnsBlockChainList = $})
  3654.  
  3655.  
  3656.  
  3657.  
  3658.  
  3659.  
  3660. this.classicBoardBuildsJSON$ = this.af.database.list('allBoardsJSON/classicBoardBuildsJSON')
  3661.  
  3662. this.subClassicJSON = this.classicBoardBuildsJSON$.subscribe($ =>
  3663. {
  3664.  
  3665. this.classicBoardBuildsJSON = $
  3666.  
  3667. })
  3668.  
  3669.  
  3670.  
  3671.  
  3672.  
  3673.  
  3674.  
  3675.  
  3676.  
  3677. this.classicLevelsList$ = this.af.database.list('TSOTSLevels/classicBoardBuilds/')
  3678.  
  3679. this.subClassic = this.classicLevelsList$.subscribe($ =>
  3680. {
  3681.  
  3682. this.classicLevelsList = $})
  3683.  
  3684. ///
  3685.  
  3686. this.storyLevelsList$ = this.af.database.list('TSOTSLevels/storyLevels/')
  3687.  
  3688. this.subStory = this.storyLevelsList$.subscribe($ =>
  3689. {
  3690.  
  3691. this.storyLevelsList = $})
  3692.  
  3693.  
  3694.  
  3695.  
  3696. this.officialStoryBoards$ = this.af.database.list('BOTSGlobalData/officialStoryBoards')
  3697.  
  3698.  
  3699. this.officialStoryBoard$ = this.af.database.list('BOTSGlobalData/officialStoryBoards/tsots')
  3700.  
  3701.  
  3702.  
  3703.  
  3704. this.boardDBAnimationList$ =this.af.database.list('BOTSGlobalData/boardDBAnimation')
  3705.  
  3706. this.subAnimate = this.boardDBAnimationList$.subscribe($ =>
  3707. {
  3708. this.boardDBAnimationList = $}
  3709. )
  3710. this.boardDBAnimationList$.remove()
  3711.  
  3712. this.boardDBAudioList$ =this.af.database.list('BOTSGlobalData/boardDBAudio')
  3713.  
  3714. this.subAudio = this.boardDBAudioList$.subscribe($ =>
  3715. {
  3716. this.boardDBAudioList = $}
  3717. )
  3718. this.boardDBAudioList$.remove()
  3719.  
  3720. //boardDBAnimationList
  3721. //subAnimate
  3722.  
  3723.  
  3724. /// sometimes this leaves off the last object in the tree for animation
  3725. // solution?? since we are ordering by child.
  3726. // make is so the one that it usually drop off is a blank object
  3727. // we can even do that at wrapper, after it has wrapped all the other peace/
  3728. // and leaves the for loop.
  3729.  
  3730. this.databaseService.boardDBList$ = this.databaseService.boardDBList$
  3731. //
  3732. this.boardDBObject$ = this.databaseService.boardDBObject$
  3733. //
  3734.  
  3735.  
  3736. this.gameManagerDatabase$ = this.af.database.list('BOTSGlobalData/tsots/gameManagerDatabase/')
  3737.  
  3738. this.franchiseBoardDatabase$ = this.af.database.list('BOTSGlobalData/franchiseBoardDatabase/')
  3739.  
  3740. this.subWhy = this.franchiseBoardDatabase$.subscribe($ =>
  3741. {
  3742. this.franchiseBoardDatabase = $})
  3743.  
  3744. ///////
  3745. this.lobbyHumanAI$ = this.af.database.list('BOTSGlobalData/lobbyHumanAI/' )
  3746.  
  3747. this.subTen = this.lobbyHumanAI$.subscribe($ =>
  3748. {
  3749. this.lobbyHumanAI = $
  3750. //console.log(this.lobbyHumanAI)
  3751. return $;
  3752. })
  3753.  
  3754.  
  3755.  
  3756.  
  3757. ///
  3758.  
  3759. this.subOfficial = this.officialStoryBoard$.subscribe($ =>
  3760. {
  3761. this.officialStoryBoard = $ ;})
  3762.  
  3763.  
  3764. // should be a tile layer
  3765. // then a placement layer above that
  3766.  
  3767. /*
  3768. this.animationSprite = Object.create(this.spriteObject)
  3769.  
  3770. this.animationSprite.name = 'animationSprite'
  3771.  
  3772. this.rangeSprite.sourceX = 4* 32
  3773. this.rangeSprite.sourceY = 0 *32
  3774.  
  3775. this.rangeSprite.sourceWidth = 32
  3776. this.rangeSprite.sourceHeight = 32
  3777. this.rangeSprite.tileXY = []
  3778.  
  3779. this.rangeSprite.imageSrc = new Image();
  3780. 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';
  3781.  
  3782. */
  3783.  
  3784.  
  3785.  
  3786. this.rangeSprite = Object.create(this.spriteObject)
  3787.  
  3788. this.rangeSprite.name = 'rangeSprite'
  3789.  
  3790. this.rangeSprite.sourceX = 4* 32
  3791. this.rangeSprite.sourceY = 0 *32
  3792.  
  3793. this.rangeSprite.sourceWidth = 32
  3794. this.rangeSprite.sourceHeight = 32
  3795. this.rangeSprite.tileXY = []
  3796.  
  3797. this.rangeSprite.imageSrc = new Image();
  3798. 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';
  3799.  
  3800.  
  3801. /// sprite cursor
  3802. this.spriteCursor = Object.create(this.spriteObject)
  3803. this.spriteCursor.name = 'spirit'
  3804.  
  3805. this.spriteCursor.x = 0
  3806. this.spriteCursor.y = 0
  3807. this.spriteCursor.sourceX = 48 * 9;
  3808. this.spriteCursor.sourceY = 48 * 7 ;
  3809.  
  3810.  
  3811. this.spriteCursor.tileX= 0;
  3812. this.spriteCursor.tileY= 0;
  3813. this.spriteCursor.tileXY = [0,0]
  3814.  
  3815. this.spriteCursor.imageSrc = new Image();
  3816. 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';
  3817.  
  3818.  
  3819.  
  3820.  
  3821.  
  3822.  
  3823. // console.log(this.background2)
  3824.  
  3825.  
  3826.  
  3827. // clone male
  3828. //clone female
  3829. // give even single player ability to choose gender.
  3830. // which will spawn all same peices but either female or male clone janitor
  3831.  
  3832.  
  3833. //this.backgroundSprites.push(this.background)
  3834. this.foregroundSprites.push(this.spriteCursor)
  3835.  
  3836.  
  3837.  
  3838. // gonna save this in tsots and try "better scrolling"
  3839.  
  3840.  
  3841. this.camera = {
  3842. x:0,
  3843. y:0,
  3844. width : 480,
  3845. height : 480
  3846. };
  3847.  
  3848.  
  3849. }
  3850.  
  3851.  
  3852.  
  3853. ready = false ;
  3854.  
  3855. e
  3856.  
  3857. canvasSpace
  3858. cellClicked
  3859.  
  3860. name = 10
  3861. boardTempHeight = 10
  3862. boardTempWidth = 10
  3863. boardHeight = 10
  3864. boardWidth = 10
  3865. tileHeight = 48
  3866. tileWidth = 48
  3867. tileSet
  3868. spriteSheet
  3869. actor1
  3870.  
  3871.  
  3872. // another name for boards is "rooms" connect 2 10x10 boards and have a 20x10 play room vs arena
  3873. // and 2 more for 2vs2 007golden eye james bonds style
  3874.  
  3875. e2
  3876.  
  3877.  
  3878. UP = 38;
  3879. DOWN = 40;
  3880. RIGHT = 39;
  3881. LEFT = 37;
  3882.  
  3883. camera2={
  3884. x:0,
  3885. y:0,
  3886. width : 480,
  3887. height : 480
  3888. };
  3889.  
  3890.  
  3891.  
  3892. // CAMERA DEDICATED TO DIRECTIONAL KEYS
  3893. @HostListener('window:keydown', ['$event'])
  3894. keydownHandler(event:any){
  3895. //console.log(event.keyCode)
  3896. try{
  3897.  
  3898. switch(event.keyCode)
  3899. {
  3900. case this.UP:
  3901. event.preventDefault()
  3902. this.camera.y -= 48;
  3903. if(this.camera.y < 0){
  3904. this.camera.y=0
  3905. }
  3906.  
  3907. if(this.imagingSrc){
  3908. this.camera2.y -= 48;
  3909. if(this.camera2.y < 0){
  3910. this.camera2.y=0
  3911. }
  3912. }
  3913. // if this
  3914. break;
  3915.  
  3916. case this.DOWN :
  3917. event.preventDefault()
  3918. this.camera.y += 48;
  3919. if(this.camera.y > this.gameWorld.height*48 -480 ){
  3920. this.camera.y=this.gameWorld.height*48 -480
  3921. }
  3922. if(this.imagingSrc){
  3923. this.camera2.y += 48;
  3924. if(this.camera2.y >this.imagingSrc.height - 480){
  3925. this.camera2.y=this.imagingSrc.height - 480
  3926. }
  3927. }
  3928.  
  3929. break;
  3930. case this.LEFT:
  3931. event.preventDefault()
  3932. this.camera.x -= 48;
  3933. if(this.camera.x < 0){
  3934. this.camera.x=0
  3935. }
  3936. if(this.imagingSrc){
  3937. this.camera2.x -= 48;
  3938. if(this.camera2.x < 0){
  3939. this.camera2.x= 0
  3940. }
  3941. }
  3942.  
  3943.  
  3944. break;
  3945.  
  3946. case this.RIGHT :
  3947. event.preventDefault()
  3948. this.camera.x += 48;
  3949. if(this.camera.x > this.gameWorld.width*48 -480){
  3950. this.camera.x = this.gameWorld.width*48 -480
  3951. }
  3952. if(this.imagingSrc){
  3953. this.camera2.x += 48;
  3954. if(this.camera2.x < this.imagingSrc.width -480){
  3955. this.camera2.x= this.imagingSrc.width - 480
  3956. }
  3957. }
  3958. break;
  3959. }
  3960. }catch(e){}
  3961. }
  3962.  
  3963. e6
  3964. cellTouched
  3965. posX
  3966. posY
  3967. // ON MOUSE
  3968. @HostListener('document:mousemove', ['$event'])
  3969. mouseHandler(){
  3970.  
  3971. try{
  3972. // have it follow cell by cell .
  3973. //console.log(event)
  3974. this.e2 = event
  3975. this.e6 = event
  3976.  
  3977. this.canvasSpace = this.canvas.getBoundingClientRect()
  3978. var x = this.e2.x - this.canvasSpace.left +this.camera.x
  3979. var y = this.e2.y - this.canvasSpace.top +this.camera.y
  3980.  
  3981. this.spriteCursor.x = x
  3982. this.spriteCursor.y = y
  3983. this.spriteCursor.tileXY[0] = Math.floor(x/48)
  3984. this.spriteCursor.tileXY[1] = Math.floor(y/48)
  3985.  
  3986.  
  3987. //bounds sprite mouse on screen for camera // this.background.height
  3988. if(this.spriteCursor.tileXY[1]< 0){
  3989. this.spriteCursor.tileXY[1] = 0}
  3990. if(this.spriteCursor.tileXY[1]> this.gameWorld.height){
  3991. this.spriteCursor.tileXY[1] = this.gameWorld.height}
  3992. if(this.spriteCursor.tileXY[0]<0){
  3993. this.spriteCursor.tileXY[0] = 0}
  3994. if(this.spriteCursor.tileXY[0]> this.gameWorld.width){
  3995. this.spriteCursor.tileXY[0] = this.gameWorld.width}
  3996.  
  3997.  
  3998. // now for visualInventoryMenu tooltips
  3999. if(this.canvas3){
  4000. this.canvasSpace3 = this.canvas3.getBoundingClientRect()
  4001. //console.log(this.canvasSpace3)
  4002.  
  4003.  
  4004.  
  4005. this.posX = this.e6.x - this.canvasSpace3.left
  4006. this.posY = this.e6.y - this.canvasSpace3.top
  4007.  
  4008. 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){
  4009. // console.log('mouse moved out of canvas 3 bounds')
  4010. // return
  4011. this.inventoryToolTip = false
  4012. this.toolTipValue = null
  4013. }else{
  4014.  
  4015. // this is actually the best way to do it , because if canvas3 isn't loaded ,
  4016. // all this will just get skipped right over ;)
  4017. ///console.log('mouse in the inventory menu. ')
  4018. // somehow map item cell posotion to inventory view index
  4019. var cell =
  4020. [
  4021. Math.floor(this.posX/32 ),
  4022. Math.floor(this.posY/32)
  4023. ];
  4024.  
  4025. this.cellTouched= cell
  4026. //console.log(this.cellTouched)
  4027. this.inventoryToolTip = true
  4028. this.inventoryToolTipTrigger()
  4029. }
  4030.  
  4031. }
  4032.  
  4033. }catch(e){}
  4034. }
  4035.  
  4036. inventoryToolTip
  4037. toolTipValue
  4038. inventoryToolTipTrigger(){
  4039. let i = Math.floor(this.posX/32)
  4040.  
  4041. this.toolTipValue = this.inventoryMenuView[i]
  4042.  
  4043. }
  4044.  
  4045. inventorySubMenu
  4046.  
  4047. visualInventoryXY
  4048. visualInventoryItemClicked
  4049.  
  4050. tradeMenuViewXY
  4051. tradeMenuView2XY
  4052. offer1XY
  4053. offer2XY
  4054.  
  4055. inventoryIndex
  4056.  
  4057. itemDescription
  4058.  
  4059.  
  4060.  
  4061. ////
  4062. ///peace service methods
  4063.  
  4064.  
  4065. ////
  4066. reload(){
  4067. console.log(this.visualInventoryItemClicked)
  4068.  
  4069. }
  4070.  
  4071.  
  4072.  
  4073.  
  4074. inventorySubMenuTrigger(){
  4075. // console.log('inventory submenu')
  4076. //console.log(this.visualInventoryXY[1])
  4077.  
  4078. this.inventoryIndex = Math.floor(this.visualInventoryXY[0])
  4079. //console.log(i)
  4080.  
  4081.  
  4082. this.visualInventoryItemClicked = this.inventoryMenuView[this.inventoryIndex]
  4083. //
  4084. console.log(this.visualInventoryItemClicked)
  4085.  
  4086. this.itemDescription = this.visualInventoryItemClicked.description
  4087.  
  4088.  
  4089. this.inventorySubMenu = true
  4090. }
  4091.  
  4092. e3
  4093. num
  4094. divLeft
  4095.  
  4096.  
  4097. programMenuFake
  4098. programTriggerMenu(){
  4099.  
  4100. this.menuTrigger2.openMenu()
  4101. //this.fakeMenu = true
  4102.  
  4103. //this.programMenuFake = true
  4104.  
  4105. }
  4106.  
  4107.  
  4108. clickTriggerFake
  4109.  
  4110. clickTrigger(){
  4111. console.log('trigger clicked')
  4112.  
  4113. //this.fakeMenu = true
  4114. //this.clickTriggerFake = true
  4115. this.menuTrigger3.openMenu()
  4116. }
  4117.  
  4118. keysIn
  4119. valuesIn =[]
  4120. changeKey$
  4121. changeKey
  4122. sub11
  4123. sub10
  4124.  
  4125.  
  4126.  
  4127. itemChosen
  4128. itemChosen2
  4129.  
  4130.  
  4131. itemChosenIndexNumber
  4132.  
  4133. chosenMenuItem(item, indexNumber ){
  4134.  
  4135. //console.log('chosen menu item')
  4136. //console.log(item)
  4137. //console.log(indexNumber)
  4138. this.itemChosenIndexNumber = indexNumber
  4139. this.itemChosen = item
  4140.  
  4141. }
  4142.  
  4143.  
  4144.  
  4145. itemSubMenu
  4146. itemSubMenuView
  4147.  
  4148. itemSubMenuTrigger(){
  4149.  
  4150. this.itemSubMenu = true
  4151. console.log('current system')
  4152. /// this stuff logs too slow, but maybe it will be there by the time we open menu
  4153. console.log(this.peaceItemChosen)
  4154. //console.log(this.itemChosenIndexNumber)
  4155.  
  4156. this.itemSubMenuView = this.peaceItemChosen.inventory
  4157.  
  4158. }
  4159.  
  4160. peaceItemChosen
  4161. peaceItemChosenIndex
  4162. // get actual clicked item, not menu item.
  4163. chosenPeaceItem(item, index){
  4164.  
  4165. this.peaceItemChosen = item
  4166. this.peaceItemChosenIndex = index
  4167. console.log('chosenPeaceItem')
  4168.  
  4169. console.log(item)
  4170. }
  4171.  
  4172. destroyItem(i , index){
  4173.  
  4174. // obviously u can't just put something in ur inventory and destroy it.
  4175. // especially human beings, or strong enemy.
  4176. // destroy is a awful button for game functionality
  4177. // and there should be a dedicated trash compactor or something
  4178. // that will work on destroying an item based on its HP.
  4179.  
  4180. this.clickedSprite.inventory.splice(index,1)
  4181.  
  4182. this.boardDBList$.update(this.clickedSprite.key,{peace : this.clickedSprite });
  4183. }
  4184.  
  4185.  
  4186. itemUsed(){
  4187. this.inventorySubMenu = false
  4188. }
  4189. destroyVisualItem(){
  4190.  
  4191. this.inventorySubMenu = false
  4192. console.log(this.inventoryIndex)
  4193. this.clickedSprite.inventory.splice(this.inventoryIndex,1)
  4194. this.animateInventory()
  4195. this.boardDBList$.update(this.clickedSprite.key,{peace : this.clickedSprite });
  4196. }
  4197.  
  4198. offer1=[]
  4199.  
  4200.  
  4201. tradeItems1(i, index){
  4202. if(this.offer1){
  4203. this.offer1.push(i)
  4204.  
  4205. this.trader1.inventory.splice(index, 1)
  4206. console.log(this.offer1)
  4207. console.log(this.clickedSprite)
  4208. console.log('EYE')
  4209. console.log(i)
  4210. }else{
  4211. this.offer1 = []
  4212. this.offer1.push(i)
  4213.  
  4214. console.log('EYE')
  4215. console.log(i)
  4216. this.trader1.inventory.splice(index, 1)
  4217. }
  4218.  
  4219.  
  4220. //this.gameManagerDatabaseCrossBrowser$.update('crossBrowser',{trader1: this.trader1})
  4221.  
  4222. this.tradeMenuView = this.trader1.inventory
  4223. this.tradeMenuView2 = this.trader2.inventory
  4224.  
  4225. // instead of this, just submit the deal when your done, and can wait for confirmation or renegotiation
  4226.  
  4227. if(this.inOnlineGame){
  4228. this.gameManagerDatabaseCrossBrowser$.update('crossBrowser',{tradeMenuView: this.tradeMenuView})
  4229.  
  4230. this.gameManagerDatabaseCrossBrowser$.update('crossBrowser',{offer1: this.offer1})////
  4231. }
  4232. }
  4233.  
  4234.  
  4235. offer2 =[]
  4236.  
  4237. // splice off trader inventory after item chosen
  4238. // that will stop double spending
  4239.  
  4240.  
  4241.  
  4242.  
  4243. tradeItems2(i, index){
  4244. if(this.offer2){
  4245. this.offer2.push(i)
  4246. console.log('EYE')
  4247. console.log(i)
  4248. this.trader2.inventory.splice(index, 1)
  4249. console.log(this.offer2)
  4250. }else{
  4251. this.offer2 = []
  4252. this.offer2.push(i);
  4253. console.log('EYE')
  4254. console.log(i)
  4255.  
  4256.  
  4257. this.trader2.inventory.splice(index, 1)
  4258. }
  4259.  
  4260. this.tradeMenuView = this.trader1.inventory
  4261. this.tradeMenuView2 = this.trader2.inventory
  4262.  
  4263. if(this.inOnlineGame){
  4264. //this.gameManagerDatabaseCrossBrowser$.update('crossBrowser',{trader2: this.trader2})
  4265. this.gameManagerDatabaseCrossBrowser$.update('crossBrowser',{tradeMenuView2: this.tradeMenuView2})
  4266. this.gameManagerDatabaseCrossBrowser$.update('crossBrowser',{offer2: this.offer2})
  4267. }
  4268. }
  4269.  
  4270.  
  4271. unOffer1(i,index){
  4272. if(i){
  4273. console.log(this.offer1)
  4274. this.offer1.splice(index,1)
  4275. console.log('unOffer1')
  4276. console.log(this.offer1)
  4277. console.log(i)
  4278. this.trader1.inventory.push(i)
  4279.  
  4280.  
  4281. this.tradeMenuView = this.trader1.inventory
  4282. }
  4283. }
  4284. unOffer2(i,index){
  4285. if(i){
  4286. console.log(this.offer2)
  4287. this.offer2.splice(index,1)
  4288. console.log('unOffer2')
  4289. console.log(this.offer2)
  4290. console.log(i)
  4291. this.trader2.inventory.push(i)
  4292. this.tradeMenuView2 = this.trader2.inventory
  4293. }
  4294. }
  4295.  
  4296.  
  4297. chosenMenuItem2(i,index){
  4298. this.itemChosen2 = i
  4299.  
  4300. console.log(i)
  4301.  
  4302. }
  4303.  
  4304. dealPending = false
  4305.  
  4306.  
  4307. tradingWithAI
  4308. tradingWithOwnPeace
  4309.  
  4310. tryMonopolyDeal(){
  4311.  
  4312.  
  4313. if(this.tradingOnline){
  4314. this.counterOffer1 = false
  4315. this.dealPending = true
  4316.  
  4317.  
  4318. this.trader1.offerBotsCoins = this.offerBotsCoins
  4319. this.trader2.offerBotsCoins2 = this.offerBotsCoins2
  4320.  
  4321.  
  4322. this.gameManagerDatabaseCrossBrowser$.update('crossBrowser',{tradeMenu: true })
  4323. this.gameManagerDatabaseCrossBrowser$.update('crossBrowser',{trader1: this.trader1})
  4324. this.gameManagerDatabaseCrossBrowser$.update('crossBrowser',{trader2: this.trader2 })
  4325.  
  4326.  
  4327. this.gameManagerDatabaseCrossBrowser$.update('crossBrowser',{offer1: this.offer1})
  4328. this.gameManagerDatabaseCrossBrowser$.update('crossBrowser',{offer2: this.offer2})
  4329.  
  4330. this.gameManagerDatabaseCrossBrowser$.update('crossBrowser',{tradeMenuView: this.tradeMenuView})
  4331. this.gameManagerDatabaseCrossBrowser$.update('crossBrowser',{tradeMenuView2: this.tradeMenuView2})
  4332.  
  4333. }
  4334.  
  4335. if(this.tradingWithOwnPeace){
  4336. this.acceptDeal()
  4337. }
  4338.  
  4339. if(this.tradingWithAI){
  4340. console.log('')
  4341. this.tsotsAIService.humanToAiTradeRequest()
  4342. }
  4343.  
  4344.  
  4345. this.tradingOnline
  4346.  
  4347. }
  4348.  
  4349. counterTradeMenu
  4350. counterTradeMenu2
  4351.  
  4352. counterDeal(){
  4353. this.gameManagerDatabaseCrossBrowser$.update('crossBrowser',{tradeMenu: false })
  4354. this.tradeMenuCrossBrowser = false
  4355. this.counterTradeMenu = true
  4356.  
  4357. this.animateCounterDeal()
  4358. }
  4359.  
  4360.  
  4361. canvas14
  4362. canvas15
  4363. canvas16
  4364. canvas17
  4365. context14
  4366. context15
  4367. context16
  4368. context17
  4369.  
  4370.  
  4371. animateCounterDeal(){
  4372. if(this.counter1Canvas){
  4373.  
  4374. //console.log('made it into here')
  4375.  
  4376. this.canvas14 = document.getElementById('counter1Canvas')
  4377. this.context14 = this.canvas14.getContext('2d');
  4378. if(this.tradeMenuView){
  4379. this.canvas14.width = 32*this.tradeMenuView.length;
  4380. this.canvas14.height = 32 ;
  4381. }
  4382.  
  4383. }else{
  4384. console.log('trying to animate counter deal gain')
  4385. setTimeout(()=>{ this.animateCounterDeal() }, 200);
  4386. }
  4387.  
  4388.  
  4389. if(this.counter2Canvas){
  4390.  
  4391. //console.log('made it into here')
  4392.  
  4393. this.canvas15 = document.getElementById('counter2Canvas')
  4394. this.context15 = this.canvas15.getContext('2d');
  4395. if(this.tradeMenuView){
  4396. this.canvas15.width = 32*this.tradeMenuView.length;
  4397. this.canvas15.height = 32 ;
  4398. }
  4399.  
  4400. }else{
  4401. //console.log('trying to animate counter deal gain')
  4402. setTimeout(()=>{ this.animateCounterDeal() }, 200);
  4403. }
  4404.  
  4405. if(this.counterOffer1Canvas){
  4406.  
  4407. //console.log('made it into here')
  4408.  
  4409. this.canvas16 = document.getElementById('counterOffer1Canvas')
  4410. this.context16 = this.canvas16.getContext('2d');
  4411. if(this.tradeMenuView){
  4412. this.canvas16.width = 32*this.tradeMenuView.length;
  4413. this.canvas16.height = 32 ;
  4414. }
  4415.  
  4416. }else{
  4417. // console.log('trying to animate counter deal gain')
  4418. setTimeout(()=>{ this.animateCounterDeal() }, 200);
  4419. }
  4420.  
  4421.  
  4422. if(this.counterOffer2Canvas){
  4423.  
  4424. //console.log('made it into here')
  4425.  
  4426. this.canvas17 = document.getElementById('counterOffer2Canvas')
  4427. this.context17 = this.canvas17.getContext('2d');
  4428. if(this.tradeMenuView){
  4429. this.canvas17.width = 32*this.tradeMenuView.length;
  4430. this.canvas17.height = 32 ;
  4431. }
  4432.  
  4433. }else{
  4434. console.log('trying to animate counter deal gain')
  4435. setTimeout(()=>{ this.animateCounterDeal() }, 200);
  4436. }
  4437.  
  4438.  
  4439. }
  4440.  
  4441. tryCounterDeal(){
  4442.  
  4443. this.trader1.offerBotsCoins = this.offerBotsCoins
  4444. this.trader2.offerBotsCoins2 = this.offerBotsCoins2
  4445.  
  4446.  
  4447. this.dealPending= true
  4448. // this is opposite, if IS my turn , i will beable to receive the counter deal trigger
  4449. // that would simply re open the monopolyTradeMenu and close trade pending menu.
  4450. this.gameManagerDatabaseCrossBrowser$.update('crossBrowser',{trader1: this.trader1})
  4451. this.gameManagerDatabaseCrossBrowser$.update('crossBrowser',{trader2: this.trader2 })
  4452.  
  4453. if(this.offer1){
  4454. this.gameManagerDatabaseCrossBrowser$.update('crossBrowser',{offer1: this.offer1})
  4455. }
  4456. if(this.offer2){
  4457. this.gameManagerDatabaseCrossBrowser$.update('crossBrowser',{offer2: this.offer2})
  4458. }
  4459. this.gameManagerDatabaseCrossBrowser$.update('crossBrowser',{tradeMenuView: this.tradeMenuView})
  4460. this.gameManagerDatabaseCrossBrowser$.update('crossBrowser',{tradeMenuView2: this.tradeMenuView2})
  4461.  
  4462.  
  4463. if(this.myTurn ==! true ){
  4464. this.gameManagerDatabaseCrossBrowser$.update('crossBrowser',{counterDeal: true })
  4465. this.gameManagerDatabaseCrossBrowser$.update('crossBrowser',{counterDeal2: false })
  4466. }
  4467.  
  4468. if(this.myTurn ){
  4469. this.gameManagerDatabaseCrossBrowser$.update('crossBrowser',{counterDeal2: true })
  4470. this.gameManagerDatabaseCrossBrowser$.update('crossBrowser',{counterDeal: false })
  4471. }
  4472.  
  4473.  
  4474.  
  4475.  
  4476. setTimeout(()=>{
  4477.  
  4478.  
  4479. }, 1000);
  4480.  
  4481. }
  4482.  
  4483.  
  4484.  
  4485.  
  4486.  
  4487.  
  4488. acceptDeal(){
  4489.  
  4490. console.log(this.trader1)
  4491. console.log(this.trader2)
  4492. console.log(this.offer1)
  4493. console.log(this.offer2 )
  4494.  
  4495.  
  4496.  
  4497. this.trader1.money += this.offerBotsCoins2
  4498. this.trader2.money += this.offerBotsCoins
  4499.  
  4500. this.trader1.money -= this.offerBotsCoins
  4501. this.trader2.money -= this.offerBotsCoins2
  4502.  
  4503.  
  4504. if(this.offer2){
  4505. for(let i = 0; i < this.offer2.length; i++){
  4506. this.trader1.inventory.push(this.offer2[i])
  4507. }
  4508. }
  4509. if(this.offer1){
  4510.  
  4511. for(let i = 0; i < this.offer1.length; i++){
  4512. this.trader2.inventory.push(this.offer1[i])
  4513. }
  4514. }
  4515.  
  4516. console.log(this.trader1.inventory)
  4517. console.log(this.trader2.inventory)
  4518.  
  4519.  
  4520. this.offer1 = []
  4521. this.offer2 = []
  4522. this.tradeMenuView = []
  4523. this.tradeMenuView = []
  4524.  
  4525.  
  4526.  
  4527. this.boardDBList$.update( this.trader1.key, { peace: this.trader1 });
  4528. this.boardDBList$.update( this.trader2.key, { peace: this.trader2 });
  4529. //
  4530.  
  4531. this.cancelMonopolyTradeMenu()
  4532.  
  4533.  
  4534. if(this.inOnlineGame){
  4535.  
  4536. //
  4537. this.gameManagerDatabaseCrossBrowser$.update('crossBrowser',{trading: false })
  4538. this.gameManagerDatabaseCrossBrowser$.update('crossBrowser',{counterDeal: false })
  4539. this.gameManagerDatabaseCrossBrowser$.update('crossBrowser',{counterDeal2: false })
  4540.  
  4541. this.cancelTradeMenuCrossBrowser()
  4542. }
  4543. }
  4544.  
  4545. dealAccepted
  4546.  
  4547. tryDeal1(){
  4548.  
  4549.  
  4550.  
  4551.  
  4552. this.gameManagerDatabaseCrossBrowser$.update('crossBrowser',{deal1: true})
  4553.  
  4554.  
  4555. // if they dont wanna do the deal, if they are involved in this trade, they can just cancel menu . ..
  4556.  
  4557. // eventually , dont let them trade quantify of items they dont have
  4558. // make both parties agree on trade.
  4559. // which will have to involve database escrow probably...
  4560.  
  4561. // if deal 1 and deal 2 = true execute deal and set them both back to false
  4562. }
  4563.  
  4564. tryDeal2(){
  4565. this.gameManagerDatabaseCrossBrowser$.update('crossBrowser',{deal2: true})
  4566. }
  4567.  
  4568. deal(){
  4569.  
  4570.  
  4571. for(let i = 0; i < this.offer2.length; i++){
  4572. this.trader1.inventory.push(this.offer2[i])
  4573. }
  4574.  
  4575. for(let i = 0; i < this.offer1.length; i++){
  4576. this.trader2.inventory.push(this.offer1[i])
  4577. }
  4578.  
  4579. this.offer1 = []
  4580. this.offer2 = []
  4581. this.tradeMenuView = []
  4582. this.tradeMenuView = []
  4583.  
  4584.  
  4585. this.offerBotsCoins = this.trader1.offerBotsCoins
  4586. this.offerBotsCoins2 = this.trader1.offerBotsCoins2
  4587.  
  4588.  
  4589. this.gameManagerDatabaseCrossBrowser$.update('crossBrowser',{offer1: this.offer1})
  4590. this.gameManagerDatabaseCrossBrowser$.update('crossBrowser',{offer2: this.offer2})
  4591.  
  4592. this.gameManagerDatabaseCrossBrowser$.update('crossBrowser',{tradeMenuView: this.tradeMenuView})
  4593. this.gameManagerDatabaseCrossBrowser$.update('crossBrowser',{tradeMenuView2: this.tradeMenuView2})
  4594.  
  4595. this.gameManagerDatabaseCrossBrowser$.update('crossBrowser',{tradeMenu: false})
  4596.  
  4597. this.boardDBList$.update( this.trader1.key, { peace: this.trader1 });
  4598. this.boardDBList$.update( this.trader2.key, { peace: this.trader2 });
  4599.  
  4600. // eventually , dont let them trade quantify of items they dont have
  4601. // make both parties agree on trade.
  4602. // which will have to involve database escrow probably...
  4603.  
  4604.  
  4605. }
  4606.  
  4607.  
  4608. tradeConfirmed(trader){
  4609.  
  4610.  
  4611. if(
  4612. this.clickedSprite.player = this.clickedSprite.player
  4613. ){
  4614. //just do the trade
  4615. }
  4616.  
  4617.  
  4618.  
  4619. // if items are not real , not valid trade , show message , cancel deal .
  4620.  
  4621. }
  4622.  
  4623. savePeaceCustomizationChanges(iv,i ){
  4624. console.log('saved')
  4625.  
  4626. // turns input into a number , because all are strings
  4627. if(isNaN(iv)){
  4628.  
  4629. }else{
  4630. iv = parseInt(iv)
  4631. }
  4632.  
  4633.  
  4634. this.keysIn = Object.keys(this.clickedSprite)
  4635. this.valuesIn = []
  4636.  
  4637.  
  4638. for(var prop in this.clickedSprite){
  4639.  
  4640. this.valuesIn.push(this.clickedSprite[prop])
  4641. }
  4642.  
  4643. //console.log(iv)
  4644. //console.log('input value')
  4645. //console.log(i)
  4646. //console.log('iterative')
  4647.  
  4648. let keyO = Object.keys(this.clickedSprite)
  4649. let newO = keyO[i]
  4650. let stringO = newO.toString()
  4651. //console.log('new o ')
  4652. //console.log(newO)
  4653. //console.log(keyO[i])
  4654.  
  4655. // console.log('key 0 i ')
  4656.  
  4657.  
  4658.  
  4659. //console.log(this.dataItem.key)
  4660. //console.log(this.clickedSprite)
  4661. //console.log('trying to customize !!!')
  4662.  
  4663. // display wont display updated values !?? they update in db tho?
  4664. // somehow refresh and redisplay !?
  4665.  
  4666. // try rockign with the actual observable$ and just ngFor .$key and .$value in html
  4667. // then push simply
  4668.  
  4669.  
  4670.  
  4671. //console.log('this.changeKey')
  4672.  
  4673. this.changeKey$.update({[stringO] : iv})
  4674.  
  4675.  
  4676. }
  4677.  
  4678.  
  4679.  
  4680.  
  4681.  
  4682.  
  4683. customizePeaceMenu(){
  4684.  
  4685. var key = this.clickedSprite.key
  4686. console.log('subber')
  4687.  
  4688. console.log(this.boardDBList)
  4689. console.log(this.boardDBObject)
  4690.  
  4691. // this is the adress .
  4692. this.changeKey$ = this.af.database.object('BOTSGlobalData/tsots/gameManagerDatabase/'+this.userService.uid+ '/boardDBList/' +this.dataItem.key +'/peace' )
  4693.  
  4694.  
  4695. this.sub10 = this.changeKey$.subscribe($ =>
  4696. {
  4697. this.changeKey = $
  4698. console.log('this.changeKey')
  4699. console.log(this.changeKey)
  4700.  
  4701. this.keysIn = Object.keys(this.changeKey)
  4702. this.valuesIn = []
  4703.  
  4704.  
  4705. for(var prop in this.changeKey){
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement