Add new tables for stats
This commit is contained in:
parent
600fcef87d
commit
c9af398b8f
9 changed files with 81 additions and 1 deletions
3
app/models/stat.rb
Normal file
3
app/models/stat.rb
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
class Stat < ActiveRecord::Base
|
||||||
|
belongs_to :state_type
|
||||||
|
end
|
2
app/models/stat_type.rb
Normal file
2
app/models/stat_type.rb
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
class StatType < ActiveRecord::Base
|
||||||
|
end
|
10
db/migrate/20151020173640_create_stat_types.rb
Normal file
10
db/migrate/20151020173640_create_stat_types.rb
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
class CreateStatTypes < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
create_table :stat_types do |t|
|
||||||
|
t.string :name
|
||||||
|
t.string :description
|
||||||
|
|
||||||
|
t.timestamps null: false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
13
db/migrate/20151020183446_create_stats.rb
Normal file
13
db/migrate/20151020183446_create_stats.rb
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
class CreateStats < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
create_table :stats do |t|
|
||||||
|
t.integer :min
|
||||||
|
t.integer :max
|
||||||
|
t.integer :awaken_min
|
||||||
|
t.integer :awaken_make
|
||||||
|
t.references :state_type, index: true, foreign_key: true
|
||||||
|
|
||||||
|
t.timestamps null: false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
7
db/migrate/20151020183709_add_stats_to_cards.rb
Normal file
7
db/migrate/20151020183709_add_stats_to_cards.rb
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
class AddStatsToCards < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
add_column :cards, :hp_stat_id, :integer
|
||||||
|
add_column :cards, :atk_stat_id, :integer
|
||||||
|
add_column :cards, :def_stat_id, :integer
|
||||||
|
end
|
||||||
|
end
|
5
db/migrate/20151020212018_fix_stat_columns.rb
Normal file
5
db/migrate/20151020212018_fix_stat_columns.rb
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
class FixStatColumns < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
rename_column :stats, :awaken_make, :awaken_max
|
||||||
|
end
|
||||||
|
end
|
8
db/migrate/20151020212132_add_defaults_to_stats.rb
Normal file
8
db/migrate/20151020212132_add_defaults_to_stats.rb
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
class AddDefaultsToStats < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
change_column :stats, :min, :integer, default: 0
|
||||||
|
change_column :stats, :max, :integer, default: 0
|
||||||
|
change_column :stats, :awaken_min, :integer, default: 0
|
||||||
|
change_column :stats, :awaken_max, :integer, default: 0
|
||||||
|
end
|
||||||
|
end
|
24
db/schema.rb
24
db/schema.rb
|
@ -11,7 +11,7 @@
|
||||||
#
|
#
|
||||||
# It's strongly recommended that you check this file into your version control system.
|
# It's strongly recommended that you check this file into your version control system.
|
||||||
|
|
||||||
ActiveRecord::Schema.define(version: 20151014155435) do
|
ActiveRecord::Schema.define(version: 20151020212132) do
|
||||||
|
|
||||||
create_table "awaken_types", force: :cascade do |t|
|
create_table "awaken_types", force: :cascade do |t|
|
||||||
t.string "name"
|
t.string "name"
|
||||||
|
@ -33,6 +33,9 @@ ActiveRecord::Schema.define(version: 20151014155435) do
|
||||||
t.datetime "updated_at", null: false
|
t.datetime "updated_at", null: false
|
||||||
t.integer "awaken_type_id"
|
t.integer "awaken_type_id"
|
||||||
t.boolean "verified", default: false
|
t.boolean "verified", default: false
|
||||||
|
t.integer "hp_stat_id"
|
||||||
|
t.integer "atk_stat_id"
|
||||||
|
t.integer "def_stat_id"
|
||||||
end
|
end
|
||||||
|
|
||||||
add_index "cards", ["awaken_type_id"], name: "index_cards_on_awaken_type_id"
|
add_index "cards", ["awaken_type_id"], name: "index_cards_on_awaken_type_id"
|
||||||
|
@ -117,6 +120,25 @@ ActiveRecord::Schema.define(version: 20151014155435) do
|
||||||
add_index "roles", ["name", "resource_type", "resource_id"], name: "index_roles_on_name_and_resource_type_and_resource_id"
|
add_index "roles", ["name", "resource_type", "resource_id"], name: "index_roles_on_name_and_resource_type_and_resource_id"
|
||||||
add_index "roles", ["name"], name: "index_roles_on_name"
|
add_index "roles", ["name"], name: "index_roles_on_name"
|
||||||
|
|
||||||
|
create_table "stat_types", force: :cascade do |t|
|
||||||
|
t.string "name"
|
||||||
|
t.string "description"
|
||||||
|
t.datetime "created_at", null: false
|
||||||
|
t.datetime "updated_at", null: false
|
||||||
|
end
|
||||||
|
|
||||||
|
create_table "stats", force: :cascade do |t|
|
||||||
|
t.integer "min", default: 0
|
||||||
|
t.integer "max", default: 0
|
||||||
|
t.integer "awaken_min", default: 0
|
||||||
|
t.integer "awaken_max", default: 0
|
||||||
|
t.integer "state_type_id"
|
||||||
|
t.datetime "created_at", null: false
|
||||||
|
t.datetime "updated_at", null: false
|
||||||
|
end
|
||||||
|
|
||||||
|
add_index "stats", ["state_type_id"], name: "index_stats_on_state_type_id"
|
||||||
|
|
||||||
create_table "super_attacks", force: :cascade do |t|
|
create_table "super_attacks", force: :cascade do |t|
|
||||||
t.string "name"
|
t.string "name"
|
||||||
t.string "description"
|
t.string "description"
|
||||||
|
|
10
db/seeds.rb
10
db/seeds.rb
|
@ -19,6 +19,12 @@ awaken_types = [
|
||||||
'Extreme',
|
'Extreme',
|
||||||
]
|
]
|
||||||
|
|
||||||
|
stat_types = [
|
||||||
|
['HP', 'Health Points'],
|
||||||
|
['ATK', 'Attack'],
|
||||||
|
['DEF', 'Defense'],
|
||||||
|
]
|
||||||
|
|
||||||
roles = [
|
roles = [
|
||||||
:admin,
|
:admin,
|
||||||
:moderator,
|
:moderator,
|
||||||
|
@ -41,3 +47,7 @@ end
|
||||||
roles.each do |role|
|
roles.each do |role|
|
||||||
Role.where({ name: role }, without_protection: true).first_or_create
|
Role.where({ name: role }, without_protection: true).first_or_create
|
||||||
end
|
end
|
||||||
|
|
||||||
|
stat_types.each do |name, description|
|
||||||
|
StatType.create(name: name, description: description)
|
||||||
|
end
|
||||||
|
|
Loading…
Reference in a new issue