werewolf 0.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +1 -0
- data/LICENSE +20 -0
- data/Manifest +6 -0
- data/README +1 -0
- data/bin/werewolf +7 -0
- data/lib/werewolf.rb +147 -0
- data/werewolf.gemspec +29 -0
- metadata +52 -0
data/CHANGELOG
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
v0.0.0 Initial package, test release.
|
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2007 Jason L Perry
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Manifest
ADDED
data/README
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
= Werewolf
|
data/bin/werewolf
ADDED
data/lib/werewolf.rb
ADDED
@@ -0,0 +1,147 @@
|
|
1
|
+
Camping.goes :Werewolf
|
2
|
+
|
3
|
+
module Werewolf::Models
|
4
|
+
class Villager < Base
|
5
|
+
belongs_to :village
|
6
|
+
belongs_to :role
|
7
|
+
def dead?; killed_at >= Time.now; end
|
8
|
+
end
|
9
|
+
|
10
|
+
class Village < Base
|
11
|
+
has_many :villagers
|
12
|
+
has_many :observations
|
13
|
+
has_many :observers, :through => :observations
|
14
|
+
end
|
15
|
+
|
16
|
+
class Role < Base; end
|
17
|
+
|
18
|
+
class Observer < Base
|
19
|
+
has_many :observations
|
20
|
+
has_many :villages, :through => :observations
|
21
|
+
end
|
22
|
+
|
23
|
+
class Wager < Base
|
24
|
+
belongs_to :observation
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
module Werewolf::Controllers
|
29
|
+
class Index < R "/"
|
30
|
+
def get
|
31
|
+
@village = Models::Village.find(:first, :conditions => "ended_at IS NULL", :order => "started_at DESC")
|
32
|
+
@village ? render(:village) : redirect(Villages)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
class Villages < R "/villages"
|
37
|
+
def get
|
38
|
+
@villages = Models::Village.find(:all, :order => "started_at DESC")
|
39
|
+
render :villages
|
40
|
+
end
|
41
|
+
def post
|
42
|
+
@village = Models::Village.create
|
43
|
+
redirect Index
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
class Village < R "/villages/(\d+)"
|
48
|
+
def get(id)
|
49
|
+
@village = Models::Village.find(id)
|
50
|
+
render :village
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
class Villagers < R "/village/(\d+)/villagers"
|
55
|
+
def post(id)
|
56
|
+
Village.find(id).villagers.create(input.villager)
|
57
|
+
redirect Village(id)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
class Image < R "/images/(.*)"
|
62
|
+
def get(static_name)
|
63
|
+
current_dir = File.expand_path(File.dirname(__FILE__))
|
64
|
+
@headers["Content-Type"] = "image/png"
|
65
|
+
@headers["X-Sendfile"] = "#{current_dir}/assets/#{static_name}"
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
module Werewolf::Views
|
71
|
+
def layout
|
72
|
+
html do
|
73
|
+
title "Werewolf"
|
74
|
+
body do
|
75
|
+
h1 "Werewolf"
|
76
|
+
self << yield
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
def village
|
82
|
+
ul do
|
83
|
+
for villager in @village.villagers do
|
84
|
+
li villager.name
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
form(:action => R(Villagers, @village.id), :method => "post") do
|
89
|
+
label "Add Player", :for => "villager[name]"; br
|
90
|
+
input :name => "villager[name]", :type => "text"; br
|
91
|
+
input :type => "submit", :value => "Add"
|
92
|
+
end
|
93
|
+
|
94
|
+
p "Roles are " + Werewolf::Models::Role.find(:all).map(&:name).to_sentence
|
95
|
+
p { a "All", :href => R(Villages) }
|
96
|
+
end
|
97
|
+
|
98
|
+
def villages
|
99
|
+
ul do
|
100
|
+
for village in @villages do
|
101
|
+
li village.started_at
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
form(:action => R(Villages), :method => "post") do
|
106
|
+
input :type => "submit", :value => "Create"
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
end
|
111
|
+
|
112
|
+
class Werewolf::Models::Schema < Werewolf::Models::V 1
|
113
|
+
def self.up
|
114
|
+
create_table :werewolf_villagers do |t|
|
115
|
+
t.column :name, :string
|
116
|
+
t.column :killed_at, :datetime
|
117
|
+
t.column :role_id, :integer
|
118
|
+
t.column :village_id, :integer
|
119
|
+
end
|
120
|
+
create_table :werewolf_roles do |t|
|
121
|
+
t.column :name, :string
|
122
|
+
end
|
123
|
+
create_table :werewolf_villages do |t|
|
124
|
+
t.column :started_at, :datetime
|
125
|
+
t.column :ended_at, :datetime
|
126
|
+
end
|
127
|
+
create_table :werewolf_observers do |t|
|
128
|
+
t.column :name, :string
|
129
|
+
end
|
130
|
+
create_table :werewolf_observations do |t|
|
131
|
+
t.column :observer_id, :integer
|
132
|
+
t.column :village_id, :integer
|
133
|
+
end
|
134
|
+
create_table :werewolf_wagers do |t|
|
135
|
+
t.column :observation_id, :integer
|
136
|
+
end
|
137
|
+
end
|
138
|
+
end
|
139
|
+
|
140
|
+
def Werewolf.create
|
141
|
+
Werewolf::Models.create_schema
|
142
|
+
if Werewolf::Models::Role.find(:all).empty?
|
143
|
+
Werewolf::Models::Role.create(:name => "Villager")
|
144
|
+
Werewolf::Models::Role.create(:name => "Werewolf")
|
145
|
+
Werewolf::Models::Role.create(:name => "Seer")
|
146
|
+
end
|
147
|
+
end
|
data/werewolf.gemspec
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
|
2
|
+
# Gem::Specification for Werewolf-0.0.0
|
3
|
+
# Originally generated by Echoe
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = %q{werewolf}
|
7
|
+
s.version = "0.0.0"
|
8
|
+
s.date = %q{2007-11-04}
|
9
|
+
s.summary = %q{}
|
10
|
+
s.email = %q{}
|
11
|
+
s.homepage = %q{}
|
12
|
+
s.rubyforge_project = %q{paintitred}
|
13
|
+
s.description = %q{}
|
14
|
+
s.default_executable = %q{werewolf}
|
15
|
+
s.has_rdoc = true
|
16
|
+
s.authors = ["Jason L Perry"]
|
17
|
+
s.files = ["bin/werewolf", "CHANGELOG", "lib/werewolf.rb", "LICENSE", "Manifest", "README", "werewolf.gemspec"]
|
18
|
+
s.executables = ["werewolf"]
|
19
|
+
end
|
20
|
+
|
21
|
+
|
22
|
+
# # Original Rakefile source (requires the Echoe gem):
|
23
|
+
#
|
24
|
+
# require 'echoe'
|
25
|
+
#
|
26
|
+
# Echoe.new("werewolf") do |p|
|
27
|
+
# p.author = "Jason L Perry"
|
28
|
+
# p.project = "paintitred"
|
29
|
+
# end
|
metadata
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
rubygems_version: 0.9.4
|
3
|
+
specification_version: 1
|
4
|
+
name: werewolf
|
5
|
+
version: !ruby/object:Gem::Version
|
6
|
+
version: 0.0.0
|
7
|
+
date: 2007-11-04 00:00:00 -04:00
|
8
|
+
summary: ""
|
9
|
+
require_paths:
|
10
|
+
- lib
|
11
|
+
email: ""
|
12
|
+
homepage: ""
|
13
|
+
rubyforge_project: paintitred
|
14
|
+
description: ""
|
15
|
+
autorequire:
|
16
|
+
default_executable:
|
17
|
+
bindir: bin
|
18
|
+
has_rdoc: true
|
19
|
+
required_ruby_version: !ruby/object:Gem::Version::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">"
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 0.0.0
|
24
|
+
version:
|
25
|
+
platform: ruby
|
26
|
+
signing_key:
|
27
|
+
cert_chain:
|
28
|
+
post_install_message:
|
29
|
+
authors:
|
30
|
+
- Jason L Perry
|
31
|
+
files:
|
32
|
+
- bin/werewolf
|
33
|
+
- CHANGELOG
|
34
|
+
- lib/werewolf.rb
|
35
|
+
- LICENSE
|
36
|
+
- Manifest
|
37
|
+
- README
|
38
|
+
- werewolf.gemspec
|
39
|
+
test_files: []
|
40
|
+
|
41
|
+
rdoc_options: []
|
42
|
+
|
43
|
+
extra_rdoc_files: []
|
44
|
+
|
45
|
+
executables:
|
46
|
+
- werewolf
|
47
|
+
extensions: []
|
48
|
+
|
49
|
+
requirements: []
|
50
|
+
|
51
|
+
dependencies: []
|
52
|
+
|