forked from GitHub/dbot
		
	access
This commit is contained in:
		
							parent
							
								
									b1697464d9
								
							
						
					
					
						commit
						333c8de2ad
					
				| @ -295,6 +295,8 @@ var commands = function(dbot) { | ||||
|     commands['~ununsub'].regex = [/^ununsub ([^ ]+)$/, 2]; | ||||
|     commands['~ustatus'].regex = [/^ustatus ([^ ]+)$/, 2]; | ||||
|     commands['~sustatus'].regex = [/^sustatus ([^ ]+)$/, 2]; | ||||
|     commands['~nunsub'].access = 'power_user'; | ||||
|     commands['~ununsub'].access = 'power_user'; | ||||
| 
 | ||||
|     return commands; | ||||
| }; | ||||
|  | ||||
| @ -1,14 +1,258 @@ | ||||
| { | ||||
|     "dict": "/usr/share/dict/british-english", | ||||
|     "puzzles": [ | ||||
|         { | ||||
|             "type": "end", | ||||
|             "part": "er" | ||||
|         }, | ||||
|         { | ||||
|             "type": "end", | ||||
|             "part": "or" | ||||
|         }, | ||||
|         { | ||||
|             "type": "end", | ||||
|             "part": "ance" | ||||
|         }, | ||||
|         { | ||||
|             "type": "end", | ||||
|             "part": "ence" | ||||
|         }, | ||||
|         { | ||||
|             "type": "end", | ||||
|             "part": "ant" | ||||
|         }, | ||||
|         { | ||||
|             "type": "end", | ||||
|             "part": "ent" | ||||
|         }, | ||||
|         { | ||||
|             "type": "end", | ||||
|             "part": "ee" | ||||
|         }, | ||||
|         { | ||||
|             "type": "end", | ||||
|             "part": "ess" | ||||
|         }, | ||||
|         { | ||||
|             "type": "end", | ||||
|             "part": "ian" | ||||
|         }, | ||||
|         { | ||||
|             "type": "end", | ||||
|             "part": "ism" | ||||
|         }, | ||||
|         { | ||||
|             "type": "end", | ||||
|             "part": "ics" | ||||
|         }, | ||||
|         { | ||||
|             "type": "end", | ||||
|             "part": "ist" | ||||
|         }, | ||||
|         { | ||||
|             "type": "end", | ||||
|             "part": "ity" | ||||
|         }, | ||||
|         { | ||||
|             "type": "end", | ||||
|             "part": "ment" | ||||
|         }, | ||||
|         { | ||||
|             "type": "end", | ||||
|             "part": "ness" | ||||
|         }, | ||||
|         { | ||||
|             "type": "end", | ||||
|             "part": "ship" | ||||
|         }, | ||||
|         { | ||||
|             "type": "end", | ||||
|             "part": "tion" | ||||
|         }, | ||||
|         { | ||||
|             "type": "end", | ||||
|             "part": "ation" | ||||
|         }, | ||||
|         { | ||||
|             "type": "end", | ||||
|             "part": "ate" | ||||
|         }, | ||||
|         { | ||||
|             "type": "end", | ||||
|             "part": "ify" | ||||
|         }, | ||||
|         { | ||||
|             "type": "end", | ||||
|             "part": "ize" | ||||
|         }, | ||||
|         { | ||||
|             "type": "end", | ||||
|             "part": "able" | ||||
|         }, | ||||
|         { | ||||
|             "type": "end", | ||||
|             "part": "ible" | ||||
|         }, | ||||
|         { | ||||
|             "type": "end", | ||||
|             "part": "al" | ||||
|         }, | ||||
|         { | ||||
|             "type": "end", | ||||
|             "part": "ful" | ||||
|         }, | ||||
|         { | ||||
|             "type": "end", | ||||
|             "part": "ish" | ||||
|         }, | ||||
|         { | ||||
|             "type": "end", | ||||
|             "part": "ive" | ||||
|         }, | ||||
|         { | ||||
|             "type": "end", | ||||
|             "part": "ous" | ||||
|         }, | ||||
|         { | ||||
|             "type": "end", | ||||
|             "part": "ious" | ||||
|         }, | ||||
|         { | ||||
|             "type": "end", | ||||
|             "part": "ly" | ||||
|         }, | ||||
|         { | ||||
|             "type": "end", | ||||
|             "part": "ally" | ||||
|         }, | ||||
|         { | ||||
|             "type": "start", | ||||
|             "part": "en" | ||||
|             "part": "anti" | ||||
|         }, | ||||
|         { | ||||
|             "type": "start", | ||||
|             "part": "bi" | ||||
|         }, | ||||
|         { | ||||
|             "type": "start", | ||||
|             "part": "contra" | ||||
|         }, | ||||
|         { | ||||
|             "type": "start", | ||||
|             "part": "di" | ||||
|         }, | ||||
|         { | ||||
|             "type": "start", | ||||
|             "part": "dis" | ||||
|         }, | ||||
|         { | ||||
|             "type": "start", | ||||
|             "part": "ex" | ||||
|         }, | ||||
|         { | ||||
|             "type": "start", | ||||
|             "part": "extra" | ||||
|         }, | ||||
|         { | ||||
|             "type": "start", | ||||
|             "part": "hyper" | ||||
|         }, | ||||
|         { | ||||
|             "type": "start", | ||||
|             "part": "in" | ||||
|         }, | ||||
|         { | ||||
|             "type": "start", | ||||
|             "part": "inter" | ||||
|         }, | ||||
|         { | ||||
|             "type": "start", | ||||
|             "part": "intra" | ||||
|         }, | ||||
|         { | ||||
|             "type": "start", | ||||
|             "part": "intro" | ||||
|         }, | ||||
|         { | ||||
|             "type": "start", | ||||
|             "part": "macro" | ||||
|         }, | ||||
|         { | ||||
|             "type": "start", | ||||
|             "part": "micro" | ||||
|         }, | ||||
|         { | ||||
|             "type": "start", | ||||
|             "part": "mis" | ||||
|         }, | ||||
|         { | ||||
|             "type": "start", | ||||
|             "part": "mono" | ||||
|         }, | ||||
|         { | ||||
|             "type": "start", | ||||
|             "part": "multi" | ||||
|         }, | ||||
|         { | ||||
|             "type": "start", | ||||
|             "part": "neo" | ||||
|         }, | ||||
|         { | ||||
|             "type": "start", | ||||
|             "part": "non" | ||||
|         }, | ||||
|         { | ||||
|             "type": "start", | ||||
|             "part": "omni" | ||||
|         }, | ||||
|         { | ||||
|             "type": "start", | ||||
|             "part": "poly" | ||||
|         }, | ||||
|         { | ||||
|             "type": "start", | ||||
|             "part": "post" | ||||
|         }, | ||||
|         { | ||||
|             "type": "start", | ||||
|             "part": "pre" | ||||
|         }, | ||||
|         { | ||||
|             "type": "start", | ||||
|             "part": "re" | ||||
|         }, | ||||
|         { | ||||
|             "type": "start", | ||||
|             "part": "retro" | ||||
|         }, | ||||
|         { | ||||
|             "type": "start", | ||||
|             "part": "semi" | ||||
|         }, | ||||
|         { | ||||
|             "type": "start", | ||||
|             "part": "sub" | ||||
|         }, | ||||
|         { | ||||
|             "type": "start", | ||||
|             "part": "super" | ||||
|         }, | ||||
|         { | ||||
|             "type": "start", | ||||
|             "part": "tri" | ||||
|         }, | ||||
|         { | ||||
|             "type": "start", | ||||
|             "part": "un" | ||||
|         }, | ||||
|         { | ||||
|             "type": "start", | ||||
|             "part": "uni" | ||||
|         }, | ||||
|         { | ||||
|             "type": "start", | ||||
|             "part": "en" | ||||
|         }, | ||||
|         { | ||||
|             "type": "end", | ||||
|             "part": "tain" | ||||
| @ -22,5 +266,5 @@ | ||||
|             "part": "under" | ||||
|         } | ||||
|     ], | ||||
|     "allowed_chans": [ "#realitree" ] | ||||
|     "allowed_chans": [ "#realitree", "#realitwo" ] | ||||
| } | ||||
|  | ||||
| @ -8,34 +8,96 @@ var fs = require('fs'), | ||||
| var wordcrimes = function(dbot) { | ||||
|     this.game = null; | ||||
| 
 | ||||
|     this.internalAPI = { | ||||
|         'createPuzzle': function(channel) { | ||||
|  //           if(_.random(0, 3) === 1) {
 | ||||
|                 return this.internalAPI.createAnagramPuzzle(channel); | ||||
|   //          }
 | ||||
| 
 | ||||
|             var puzzle = this.puzzles[_.random(0, this.puzzles.length -1)], | ||||
|                 solutions = _.filter(this.dict, function(word) { | ||||
|                     if(puzzle.type === 'start') { | ||||
|                         return word.match('^' + puzzle.part); | ||||
|                     } else if(puzzle.type === 'end') { | ||||
|                         return word.match(puzzle.part + '$'); | ||||
|                     } | ||||
|                 }); | ||||
| 
 | ||||
|             this.game = { | ||||
|                 'puzzle': puzzle, | ||||
|                 'solutions': solutions, | ||||
|                 'channel': channel, | ||||
|                 'found': [], | ||||
|                 'scores': {} | ||||
|             }; | ||||
| 
 | ||||
|             return true; | ||||
|         }.bind(this), | ||||
| 
 | ||||
|         'createAnagramPuzzle': function(channel) { | ||||
|             var randomV = function(len) { | ||||
|                 var chars = "aeiou"; | ||||
|                 return len ? chars.charAt(~~(Math.random()*chars.length)) + randomV(len-1) : ""; | ||||
|             }; | ||||
|             var randomC = function(len) { | ||||
|                 var chars = "bcdfghklmnpqrstvwxyz"; | ||||
|                 return len ? chars.charAt(~~(Math.random()*chars.length)) + randomC(len-1) : ""; | ||||
|             }; | ||||
|             var puzzle = { | ||||
|                 'type': 'anagram', | ||||
|                 'part': (randomV(3) + randomC(6)).split('').sort(function(){return 0.5-Math.random();}).join('') | ||||
|             }; | ||||
| 
 | ||||
|             var partArr = puzzle.part.split(''), | ||||
|                 solutions = _.filter(this.dict, function(word) { | ||||
|                     return (word.length > 1 && _.difference(word.split(''), partArr).length === 0);  | ||||
|                 }); | ||||
| 
 | ||||
|             if(solutions.length < 30) { | ||||
|                 return this.internalAPI.createAnagramPuzzle(channel);  | ||||
|             } | ||||
| 
 | ||||
|             this.game = { | ||||
|                 'puzzle': puzzle, | ||||
|                 'solutions': solutions, | ||||
|                 'channel': channel, | ||||
|                 'found': [], | ||||
|                 'scores': {} | ||||
|             }; | ||||
| 
 | ||||
|             return true; | ||||
| 
 | ||||
|         }.bind(this) | ||||
|     }; | ||||
| 
 | ||||
|     this.commands = { | ||||
|         '~startgame': function(event) { | ||||
|             if(!this.game && _.include(this.config.allowed_chans, event.channel.name)) { | ||||
|             if(_.isNull(this.game) && _.include(this.config.allowed_chans, event.channel.name)) { | ||||
|                 this.game = {}; | ||||
|                 event.reply('WORD GAME STARTING IN 5 SECONDS'); | ||||
|                 setTimeout(function() { | ||||
|                     var puzzle = this.puzzles[_.random(0, this.puzzles.length -1)], | ||||
|                         solutions = _.filter(this.dict, function(word) { | ||||
|                             if(puzzle.type === 'start') { | ||||
|                                 return word.match('^' + puzzle.part); | ||||
|                             } else if(puzzle.type === 'end') { | ||||
|                                 return word.match(puzzle.part + '$'); | ||||
|                             } | ||||
|                         }); | ||||
|                     this.internalAPI.createPuzzle(event.channel.name);  | ||||
|                      | ||||
|                     var game = this.game; | ||||
| 
 | ||||
|                     this.game = { | ||||
|                         'puzzle': puzzle, | ||||
|                         'solutions': solutions, | ||||
|                         'channel': event.channel.name, | ||||
|                         'found': [], | ||||
|                         'scores': {} | ||||
|                     }; | ||||
| 
 | ||||
|                     if(puzzle.type === 'start') { | ||||
|                         event.reply('NAME ALL THE WORDS YOU CAN THINK OF THAT START WITH ' + puzzle.part); | ||||
|                     } else if(puzzle.type === 'end') { | ||||
|                         event.reply('NAME ALL THE WORDS YOU CAN THINK OF THAT END IN ' + puzzle.part); | ||||
|                     if(game.puzzle.type === 'start') { | ||||
|                         event.reply('NAME ALL THE WORDS YOU CAN THINK OF THAT START WITH ' + game.puzzle.part); | ||||
|                     } else if(game.puzzle.type === 'end') { | ||||
|                         event.reply('NAME ALL THE WORDS YOU CAN THINK OF THAT END IN ' + game.puzzle.part); | ||||
|                     } else if(game.puzzle.type === 'anagram') { | ||||
|                         event.reply('NAME ALL THE ANAGRAMS OF ' + game.puzzle.part); | ||||
|                     } | ||||
| 
 | ||||
|                    /* setTimeout(function() { | ||||
|                         if(!_.isNull(this.game)) { | ||||
|                             event.reply('30 SECONDS REMAINING'); | ||||
|                         } | ||||
|                     }.bind(this), 30000);*/ | ||||
|                     setTimeout(function() { | ||||
|                         if(!_.isNull(this.game)) { | ||||
|                             event.reply('10 SECONDS REMAINING'); | ||||
|                         } | ||||
|                     }.bind(this), 20000); | ||||
|                     setTimeout(function() { | ||||
|                         if(!_.isNull(this.game)) { | ||||
|                             if(this.game.found.length > 0) { | ||||
| @ -47,8 +109,10 @@ var wordcrimes = function(dbot) { | ||||
|                             } | ||||
|                             this.game = null; | ||||
|                         } | ||||
|                     }.bind(this), 40000); | ||||
|                     }.bind(this), 30000); | ||||
|                 }.bind(this), 5000); | ||||
|             } else { | ||||
|                 event.reply('GAME ALREADY RUNNING'); | ||||
|             } | ||||
|         } | ||||
|     }; | ||||
|  | ||||
| @ -4,6 +4,7 @@ html(lang='en') | ||||
|     meta(charset='utf-8') | ||||
|     script(type="text/javascript", src="//ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js") | ||||
|     script(type="text/javascript", src="/fs_edit.js") | ||||
|     script(type="text/javascritp" src="project.js") | ||||
|     link(rel="stylesheet", type="text/css", href="http://fonts.googleapis.com/css?family=Source+Sans+Pro") | ||||
|     link(rel="stylesheet", type="text/css", href="/bootstrap/css/bootstrap.min.css") | ||||
|     link(rel='stylesheet', type='text/css', href='/styles.css') | ||||
| @ -25,5 +26,5 @@ html(lang='en') | ||||
|                 a#bread(href='/login') Login  | ||||
| 
 | ||||
|     script(type="text/javascript", src="/bootstrap/js/bootstrap.min.js") | ||||
|     script(type="text/javascript", src="/d3/d3.v3.min.js") | ||||
|     script(type="text/javascript", src="/d3/d3.min.js") | ||||
|     script(type="text/javascript", src="/script.js") | ||||
|  | ||||
| @ -1,18 +1,7 @@ | ||||
| !!! | ||||
| html(lang='#{curr839}') | ||||
|   head | ||||
|     meta(charset='utf-8') | ||||
|     script(type="text/javascript", src="//ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js") | ||||
|     link(rel="stylesheet", type="text/css", href="http://fonts.googleapis.com/css?family=Source+Sans+Pro") | ||||
|     link(rel="stylesheet", type="text/css", href="/bootstrap/css/bootstrap.min.css")    | ||||
|     link(rel='stylesheet', type='text/css', href='/styles.css')     | ||||
|     link(rel="stylesheet", href="/project.css") | ||||
|     script(src="../project.js") | ||||
|   body   | ||||
| extends ../layout     | ||||
| 
 | ||||
| block content | ||||
|     div.container | ||||
|       div#page | ||||
|         div#title #{pagetitle} | ||||
|         div.container#main | ||||
|           p.intro #{dquote} | ||||
|           section#git | ||||
|             h2 #{development}  | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 reality
						reality