Skip to content
Browse files

Added Ability Scores to the Character table, created the AbilityScore…

… tableless model, added the edited of the base scores in the character form, and added initial rendering of the Ability Scores.
  • Loading branch information...
1 parent 99fb538 commit 316d222d02f9c2bf892652514e3a964ab932efa2 @drovani committed Dec 31, 2011
View
60 app/assets/stylesheets/characters.css.scss
@@ -2,16 +2,70 @@ div.characterbox{
div#playername{
float: right;
}
- table{
+ table.infobox{
border-spacing: 0.5em 0;
margin-top: 1em;
tr:first-child td{
border-bottom: 1px solid black;
white-space: nowrap;
}
- td.boxed {
- border: 1px solid black;
+ }
+}
+div.column{
+ width: 400px;
+ h2{
+ color: white;
+ text-transform: uppercase;
+ text-align: center;
+ background-color: black;
+ }
+ table{
+ width: 100%;
+ border-spacing: 0px 1px;
+
+ h3{
+ font-size: x-large;
+ line-height: 1.6em;
+ }
+ tr.black_bar{
+ background-color: black;
+ color: white;
+ padding: 5px;
+ font-weight: bold;
+ }
+ td.boxed{
+ padding: 3px;
+ height: 2em;
+ position: relative;
+ text-align: center;
+ }
+ td.boxed div.score{
+ background-color: white;
+ color: black;
+ font-size: xx-large;
+ width: 2.2em;
+ margin-left: auto;
+ margin-right: auto;
+ }
+ tr.spacer td{
+ height: 5px;
+ }
+ th{
+ text-transform: uppercase;
+ font-size: x-small;
+ }
+ dt{
+ text-transform: uppercase;
+ font-size: x-large;
+ }
+ dd{
+ font-size: small;
}
}
}
+td.boxed {
+ border: 1px solid black;
+ text-align: right;
+ padding-right: 5px;
+}
View
2 app/assets/stylesheets/sitewide.scss
@@ -10,7 +10,7 @@ input[type="text"] { width: 300px; }
input[type="text"].char { width: 2em; }
textarea { width: 300px; height: 6em; }
textarea.paragraph { height: 20em; }
-
+table {empty-cells: show;}
table.gridview {
border-collapse: collapse;
View
18 app/models/ability_score.rb
@@ -0,0 +1,18 @@
+class AbilityScore
+ attr_reader :name, :score, :abbr
+
+ def initialize name, score
+ @name = name
@pushcx
pushcx added a note Jan 4, 2012

Consider using the enumerated_attribute gem to constrain these names.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+ @score = score
+ @abbr = name[0, 3]
+ end
+ def mod
+ ((score - 10) / 2).floor
+ end
+ def to_s
+ score.to_s
+ end
+ def to_i
+ score.to_i
+ end
+end
View
26 app/models/character.rb
@@ -18,4 +18,30 @@ def self.allowed user
Character.limit(0)
end
end
+
+ def level
+ 0
+ end
+ def half_level
+ (level / 2).floor
+ end
+
+ def str
+ AbilityScore.new 'Strength', base_str
+ end
+ def con
+ AbilityScore.new 'Constitution', base_con
+ end
+ def dex
+ AbilityScore.new 'Dexterity', base_dex
+ end
+ def int
+ AbilityScore.new 'Intelligence', base_int
+ end
+ def wis
+ AbilityScore.new 'Wisdom', base_wis
+ end
+ def cha
+ AbilityScore.new 'Charisma', base_cha
+ end
end
View
11 app/views/characters/_ability_score.html.haml
@@ -0,0 +1,11 @@
+%tr.black_bar
+ %td.boxed
+ .score= abilityscore
+ %td
+ %dl
+ %dt= abilityscore.abbr
+ %dd= abilityscore.name
+ %td.boxed
+ .score= abilityscore.mod
+ %td.boxed
+ .score= abilityscore.mod + character.half_level
View
78 app/views/characters/_character.html.haml
@@ -1,29 +1,29 @@
-%table
+%table.infobox
%tr
%td= character.name
- %td.boxed  
- %td  
- %td  
- %td  
- %td.boxed  
+ %td.boxed= character.level
+ %td
+ %td
+ %td
+ %td.boxed
%tr
%td Character Name
%td Level
%td Class
%td Paragon Path
%td Epic Destiny
%td Total XP
-%table
+%table.infobox
%tr
- %td  
+ %td
%td= (character.size.present? ? character.size.letter : '')
%td= character.age
%td= character.gender
%td= character.height
%td= character.weight
%td= (character.alignment.present? ? character.alignment.name : '')
- %td  
- %td  
+ %td
+ %td
%tr
%td Race
%td Size
@@ -34,3 +34,61 @@
%td Alignment
%td Deity
%td Adventuring Company or Other Affiliations
+.column
+ %h2 Initiative
+ %table
+ %tr
+ %th Score
+ %th
+ %th Dex
+ %th 1/2 Level
+ %th Misc
+ %tr.black_bar
+ %td.boxed
+ %td
+ %h3 Initiative
+ %td.boxed
+ .score= character.dex
+ %td.boxed
+ .score= character.half_level
+ %td.boxed
+ %tr
+ %th{:colspan => 5, :style => "text-align: left;"} Conditional Modifiers
+ %tr
+ %td{:colspan => 5}
+ %h2 Ability Scores
+ %table
+ %tr
+ %th Score
+ %th Ability
+ %th Abil Mod
+ %th Mod + 1/2 Lvl
+ = render :partial => "ability_score", :locals => { :abilityscore => character.str, :character => character }
+ = render :partial => "ability_score", :locals => { :abilityscore => character.con, :character => character }
+ %tr.spacer
+ %td{:colspan => 4}
+ = render :partial => "ability_score", :locals => { :abilityscore => character.dex, :character => character }
+ = render :partial => "ability_score", :locals => { :abilityscore => character.int, :character => character }
+ %tr.spacer
+ %td{:colspan => 4}
+ = render :partial => "ability_score", :locals => { :abilityscore => character.wis, :character => character }
+ = render :partial => "ability_score", :locals => { :abilityscore => character.cha, :character => character }
+ %h2 Hit Points
+ %table
+ %tr
+ %th Max HP
+ %th
+ %th{:colspan => 2} Healing Surges
+ %tr
+ %td.boxed{:rowspan => 3}
+ %th Bloodied
+ %th Surge Value
+ %th Surges/Day
+ %tr
+ %td.boxed
+ %td.boxed
+ %td.boxed
+ %tr
+ %td 1/2 HP
+ %td 1/4 HP
+ %td
View
13 app/views/characters/_form.html.haml
@@ -10,3 +10,16 @@
%dd= form.text_field :height
%dt= form.label :weight
%dd= form.text_field :weight
+ %dt= form.label :base_str
+ %dd= form.text_field :base_str
+ %dt= form.label :base_con
+ %dd= form.text_field :base_con
+ %dt= form.label :base_dex
+ %dd= form.text_field :base_dex
+ %dt= form.label :base_int
+ %dd= form.text_field :base_int
+ %dt= form.label :base_wis
+ %dd= form.text_field :base_wis
+ %dt= form.label :base_cha
+ %dd= form.text_field :base_cha
+
View
2 app/views/posts/_post.html.haml
@@ -2,4 +2,6 @@
.byline
Posted by:
=post.user.name unless post.user.nil?
+  • 
+ =post.created_at
!= post.content
View
2 config/application.rb
@@ -27,7 +27,7 @@ class Application < Rails::Application
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
- # config.time_zone = 'Central Time (US & Canada)'
+ config.time_zone = 'Central Time (US & Canada)'
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
View
4 config/database.yml
@@ -3,7 +3,7 @@ development:
encoding: utf-8
database: dtj_development
pool: 5
- username: postgres
+ username: dbadmin
password: root
min_messages: WARNING
host: localhost
@@ -14,6 +14,6 @@ test:
encoding: unicode
database: dtj_test
pool: 5
- username: postgres
+ username: dbadmin
password: root
min_messages: WARNING
View
10 db/migrate/20111231200950_add_ability_scores_to_characters.rb
@@ -0,0 +1,10 @@
+class AddAbilityScoresToCharacters < ActiveRecord::Migration
+ def change
+ add_column :characters, :base_str, :integer, :default => 0, :null => false
+ add_column :characters, :base_con, :integer, :default => 0, :null => false
+ add_column :characters, :base_dex, :integer, :default => 0, :null => false
+ add_column :characters, :base_int, :integer, :default => 0, :null => false
+ add_column :characters, :base_wis, :integer, :default => 0, :null => false
+ add_column :characters, :base_cha, :integer, :default => 0, :null => false
+ end
+end
View
9 db/schema.rb
@@ -1,3 +1,4 @@
+# encoding: UTF-8
# This file is auto-generated from the current state of the database. Instead
# of editing this file, please use the migrations feature of Active Record to
# incrementally modify your database, and then regenerate this schema definition.
@@ -10,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.
-ActiveRecord::Schema.define(:version => 20111215224503) do
+ActiveRecord::Schema.define(:version => 20111231200950) do
create_table "alignments", :force => true do |t|
t.string "name"
@@ -41,6 +42,12 @@
t.datetime "updated_at"
t.integer "size_id"
t.integer "alignment_id"
+ t.integer "base_str", :default => 0, :null => false
+ t.integer "base_con", :default => 0, :null => false
+ t.integer "base_dex", :default => 0, :null => false
+ t.integer "base_int", :default => 0, :null => false
+ t.integer "base_wis", :default => 0, :null => false
+ t.integer "base_cha", :default => 0, :null => false
end
create_table "comments", :force => true do |t|

0 comments on commit 316d222

Please sign in to comment.
Something went wrong with that request. Please try again.