-fiz emoji issue
-last change before skin functionality is added
This commit is contained in:
		
							parent
							
								
									cf3b794195
								
							
						
					
					
						commit
						f6496327fe
					
				
							
								
								
									
										12
									
								
								backend.js
									
									
									
									
									
								
							
							
						
						
									
										12
									
								
								backend.js
									
									
									
									
									
								
							| @ -11,7 +11,7 @@ const io = new Server(server, { | |||||||
|     pingTimeout:5000 |     pingTimeout:5000 | ||||||
| }) | }) | ||||||
| 
 | 
 | ||||||
| var Filter = require('bad-words') | var Filter = require('./bad-words-hacked'); | ||||||
| filter = new Filter(); | filter = new Filter(); | ||||||
| 
 | 
 | ||||||
| // app.use(requireHTTPS); // Set 'SET NODE_ENV=development' in local computer before use
 | // app.use(requireHTTPS); // Set 'SET NODE_ENV=development' in local computer before use
 | ||||||
| @ -46,6 +46,7 @@ io.on('connection', (socket)=>{ | |||||||
|         roomId:1, |         roomId:1, | ||||||
|         message:'', |         message:'', | ||||||
|         username:"Visitor", |         username:"Visitor", | ||||||
|  |         skin:"Green", | ||||||
|         timeoutId:0 |         timeoutId:0 | ||||||
|     } //create player object with new socket id property
 |     } //create player object with new socket id property
 | ||||||
| 
 | 
 | ||||||
| @ -73,11 +74,16 @@ io.on('connection', (socket)=>{ | |||||||
|         console.log("updated username for: "+bPlayers[socket.id].username) |         console.log("updated username for: "+bPlayers[socket.id].username) | ||||||
|     }) |     }) | ||||||
| 
 | 
 | ||||||
|  |     socket.on('skin',(skin)=>{ | ||||||
|  |         bPlayers[socket.id].skin = skin | ||||||
|  |         console.log("updated skin for: "+bPlayers[socket.id].username) | ||||||
|  |     }) | ||||||
|  | 
 | ||||||
|     socket.on('message',(message)=>{ |     socket.on('message',(message)=>{ | ||||||
|         let timeoutId; |         let timeoutId; | ||||||
|         clearTimeout(bPlayers[socket.id].timeoutId); |         clearTimeout(bPlayers[socket.id].timeoutId); | ||||||
|         // bPlayers[socket.id].message = filter.clean(message)
 |         bPlayers[socket.id].message = filter.cleanHacked(message) | ||||||
|         bPlayers[socket.id].message = message |         // bPlayers[socket.id].message = message
 | ||||||
| 
 | 
 | ||||||
|         function startTimer() { |         function startTimer() { | ||||||
|           timeoutId = setTimeout(() => { |           timeoutId = setTimeout(() => { | ||||||
|  | |||||||
							
								
								
									
										19
									
								
								bad-words-hacked.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										19
									
								
								bad-words-hacked.js
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,19 @@ | |||||||
|  | // Emoji error fix from: https://github.com/web-mech/badwords/issues/93
 | ||||||
|  | 
 | ||||||
|  | const Filter = require('bad-words') | ||||||
|  | 
 | ||||||
|  | class FilterHacked extends Filter { | ||||||
|  |     cleanHacked(string) { | ||||||
|  |         try { | ||||||
|  |             return this.clean(string); | ||||||
|  |         } catch { | ||||||
|  |             const joinMatch = this.splitRegex.exec(string); | ||||||
|  |             const joinString = (joinMatch && joinMatch[0]) || ''; | ||||||
|  |             return string.split(this.splitRegex).map((word) => { | ||||||
|  |               return this.isProfane(word) ? this.replaceWord(word) : word; | ||||||
|  |             }).join(joinString); | ||||||
|  |         } | ||||||
|  |       } | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | module.exports = FilterHacked | ||||||
							
								
								
									
										
											BIN
										
									
								
								public/characterSprites/Red/Down.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								public/characterSprites/Red/Down.png
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| After Width: | Height: | Size: 1.7 KiB | 
							
								
								
									
										
											BIN
										
									
								
								public/characterSprites/Red/Left.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								public/characterSprites/Red/Left.png
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| After Width: | Height: | Size: 1.7 KiB | 
							
								
								
									
										
											BIN
										
									
								
								public/characterSprites/Red/Right.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								public/characterSprites/Red/Right.png
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| After Width: | Height: | Size: 1.7 KiB | 
							
								
								
									
										
											BIN
										
									
								
								public/characterSprites/Red/Up.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								public/characterSprites/Red/Up.png
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| After Width: | Height: | Size: 1.7 KiB | 
| @ -1,7 +1,7 @@ | |||||||
| 
 | 
 | ||||||
| class Player extends Sprite { | class Player extends Sprite { | ||||||
|     constructor({position,clickX,clickY,incrementX,incrementY,userId,username,message,atPosition,animationColumn,imageSrc,frames,center,sprites}){ |     constructor({position,clickX,clickY,incrementX,incrementY,userId,username,skin,message,atPosition,animationColumn,imageSrc,frames,center,sprites}){ | ||||||
|         super({position,imageSrc,frames,center,atPosition,sprites}) |         super({position,imageSrc,frames,center,atPosition,sprites,skin}) | ||||||
|         // super({imageSrc})
 |         // super({imageSrc})
 | ||||||
|         this.clickX = clickX |         this.clickX = clickX | ||||||
|         this.clickY = clickY |         this.clickY = clickY | ||||||
|  | |||||||
| @ -78,17 +78,18 @@ socket.on('updatePlayers', (bPlayers) =>{ | |||||||
|                 clickY:bPlayer.clickY, |                 clickY:bPlayer.clickY, | ||||||
|                 userId:id, |                 userId:id, | ||||||
|                 username:'', |                 username:'', | ||||||
|  |                 skin:bPlayer.skin, | ||||||
|                 message:'', |                 message:'', | ||||||
|                 atPosition:true, |                 atPosition:true, | ||||||
|                 animationColumn:0, |                 animationColumn:0, | ||||||
|                 imageSrc:'characterSprites/Green/Down.png', |                 imageSrc:'characterSprites/' + bPlayer.skin + '/Down.png', | ||||||
|                 frames: 7, |                 frames: 7, | ||||||
|                 center:true, |                 center:true, | ||||||
|                 sprites:{ |                 sprites:{ | ||||||
|                     down:'characterSprites/Green/Down.png', |                     down:'characterSprites/' + bPlayer.skin + '/Down.png', | ||||||
|                     up:'characterSprites/Green/Up.png', |                     up:'characterSprites/' + bPlayer.skin + '/Up.png', | ||||||
|                     right:'characterSprites/Green/Right.png', |                     right:'characterSprites/' + bPlayer.skin + '/Right.png', | ||||||
|                     left:'characterSprites/Green/Left.png' |                     left:'characterSprites/' + bPlayer.skin + '/Left.png' | ||||||
|                 } |                 } | ||||||
|                  |                  | ||||||
|             }) |             }) | ||||||
| @ -101,6 +102,7 @@ socket.on('updatePlayers', (bPlayers) =>{ | |||||||
|             fPlayers[id].clickY = bPlayer.clickY |             fPlayers[id].clickY = bPlayer.clickY | ||||||
|             fPlayers[id].message = bPlayer.message |             fPlayers[id].message = bPlayer.message | ||||||
|             fPlayers[id].username = bPlayer.username |             fPlayers[id].username = bPlayer.username | ||||||
|  |             fPlayers[id].skin = bPlayer.skin | ||||||
| 
 | 
 | ||||||
|             //update player position without animation if tab is inactive
 |             //update player position without animation if tab is inactive
 | ||||||
|             if (document.hidden) { |             if (document.hidden) { | ||||||
| @ -205,6 +207,9 @@ document.querySelector('#textInput').addEventListener('submit',(event)=>{ | |||||||
|     }else if(inputValue==='/debug'){ |     }else if(inputValue==='/debug'){ | ||||||
|         if(debugMode) {debugMode=false;}else{debugMode=true;} |         if(debugMode) {debugMode=false;}else{debugMode=true;} | ||||||
|          |          | ||||||
|  |     }else if(inputValue==='/red'){ | ||||||
|  |         fPlayers[socket.id].skin = "Red"; | ||||||
|  |         socket.emit('skin',fPlayers[socket.id].skin); | ||||||
|     }else{ |     }else{ | ||||||
|     fPlayers[socket.id].message=document.querySelector('#input').value |     fPlayers[socket.id].message=document.querySelector('#input').value | ||||||
| 
 | 
 | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user