Permalink
Browse files

boggleit

  • Loading branch information...
0 parents commit 260861e98280dfcb592bdc30ae3cd7d6ca631604 @tejo committed Jan 18, 2012
Showing with 124 additions and 0 deletions.
  1. +1 −0 .rvmrc
  2. +2 −0 Gemfile
  3. +19 −0 Gemfile.lock
  4. +8 −0 config.ru
  5. +13 −0 main.rb
  6. +4 −0 public/css/ib.css
  7. +65 −0 public/js/boggle.coffee
  8. +12 −0 views/index.erb
@@ -0,0 +1 @@
+rvm use ruby-1.9.2-p180@r3.0.8
@@ -0,0 +1,2 @@
+gem "sinatra", :require => "sinatra/base"
+gem "coffee-script", :require => 'coffee-script'
@@ -0,0 +1,19 @@
+GEM
+ specs:
+ coffee-script (2.2.0)
+ coffee-script-source
+ execjs
+ coffee-script-source (1.1.2)
+ execjs (1.2.9)
+ multi_json (~> 1.0)
+ multi_json (1.0.3)
+ rack (1.2.4)
+ sinatra (1.0)
+ rack (>= 1.0)
+
+PLATFORMS
+ ruby
+
+DEPENDENCIES
+ coffee-script
+ sinatra
@@ -0,0 +1,8 @@
+require 'rubygems'
+require 'bundler'
+
+Bundler.require
+
+require './main'
+
+run Sinatra::Application
@@ -0,0 +1,13 @@
+require 'sinatra'
+
+
+get "/" do
+ erb :index
+end
+
+get "/boggle.js" do
+ coffee_file = File.read(File.join('public', 'js', 'boggle.coffee'))
+ content_type "text/javascript"
+ CoffeeScript.compile(coffee_file)
+end
+
@@ -0,0 +1,4 @@
+#container > div > div {float:left; width:100px;height:100px; text-align:center; line-height:100px; font-size:80px; border:1px solid black;}
+#container > div { clear:both}
+#button { clear:both; font-size:80px; text-align:center}
+
@@ -0,0 +1,65 @@
+Array::randomize = -> @sort -> 0.5 - Math.random()
+
+class Boggle
+ constructor: ->
+ @dices = [
+ ['A', 'Z', 'F', 'S', 'Qu', 'B'],
+ ['G', 'C', 'S', 'V', 'P', 'A'],
+ ['H', 'I', 'S', 'E', 'R', 'N'],
+ ['A', 'I', 'O', 'B', 'M', 'C'],
+ ['T', 'I', 'V', 'E', 'N', 'G'],
+ ['M', 'O', 'V', 'D', 'I', 'T'],
+ ['V', 'N', 'D', 'Z', 'A', 'E'],
+ ['O', 'A', 'A', 'I', 'E', 'T'],
+ ['F', 'R', 'I', 'P', 'A', 'G'],
+ ['M', 'L', 'R', 'C', 'O', 'I'],
+ ['O', 'N', 'F', 'E', 'B', 'L'],
+ ['L', 'O', 'C', 'I', 'D', 'M'],
+ ['T', 'B', 'R', 'L', 'I', 'A'],
+ ['C', 'F', 'A', 'R', 'O', 'I'],
+ ['N', 'U', 'E', 'O', 'C', 'T'],
+ ['L', 'E', 'P', 'U', 'S', 'T'],
+ ['N', 'O', 'D', 'E', 'S', 'T'],
+ ['A', 'I', 'O', 'S', 'M', 'R'],
+ ['T', 'G', 'C', 'A', 'P', 'I'],
+ ['L', 'A', 'R', 'E', 'S', 'C'],
+ ['A', 'B', 'O', 'O', 'Qu', 'M'],
+ ['G', 'U', 'E', 'O', 'N', 'L'],
+ ['C', 'D', 'P', 'M', 'A', 'E'],
+ ['R', 'O', 'E', 'L', 'U', 'I'],
+ ['H', 'I', 'F', 'E', 'I', 'E'],
+ ]
+ @result = []
+
+ roll: ->
+ res =[]
+ for roll in @dices.randomize()
+ dice = roll.randomize()
+ res.push dice[0]
+ for i in [0..4]
+ @result.push res[(i*5)..((5*(i+1))-1)]
+ @result
+
+
+window.draw = ()->
+ b = new Boggle
+ c = document.getElementById "container"
+ c.innerHTML = ''
+ for row in b.roll()
+ d = document.createElement 'div'
+ for i in row
+ dd = document.createElement 'div'
+ dd.innerHTML = i
+ d.appendChild dd
+ c.appendChild d
+
+
+window.draw()
+
+document.getElementById('button').firstChild.onclick = ()-> window.draw()
+
+
+
+
+
+phantom.exit() if phantom?
@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <title>Italian Boggle</title>
+ <link type='text/css' rel='stylesheet' href='/css/ib.css' />
+ </head>
+ <body>
+ <div id="container"></div>
+ <div id="button"><a href="javascript:;">roll</a></div>
+ <script src="/boggle.js" type="text/javascript"></script>
+ </body>
+</html>

0 comments on commit 260861e

Please sign in to comment.