summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Gay <david@davidgay.org>2021-05-02 20:21:04 -0400
committerDavid Gay <david@davidgay.org>2021-05-02 20:21:04 -0400
commit2b32a88a8e9f1d0bb5055843ac987d9cb9981803 (patch)
tree19bf361b7cbb69ae493cc02d07f0fae2cf6da928
parent5fe4e8f4a080e02dfc4e4adabd09d6f5c7e38f40 (diff)
Add Activities
-rw-r--r--app/models/activity.rb3
-rw-r--r--data/activities.yml30
-rw-r--r--db/migrate/20210503001859_create_activities.rb12
-rw-r--r--db/schema.rb11
-rw-r--r--db/seeds.rb5
-rw-r--r--test/fixtures/activities.yml13
-rw-r--r--test/models/activity_test.rb7
7 files changed, 80 insertions, 1 deletions
diff --git a/app/models/activity.rb b/app/models/activity.rb
new file mode 100644
index 0000000..2f93564
--- /dev/null
+++ b/app/models/activity.rb
@@ -0,0 +1,3 @@
+class Activity < ApplicationRecord
+ validates :gid, :name, :description, presence: true
+end
diff --git a/data/activities.yml b/data/activities.yml
new file mode 100644
index 0000000..15bd3e2
--- /dev/null
+++ b/data/activities.yml
@@ -0,0 +1,30 @@
+quarry_floret_mines:
+ name: "Quarry Floret Mines"
+ description: "Planequarry at the Floret Mines."
+ whatnot:
+ duration:
+ base: 70
+ minimum: 35
+ scaling:
+ planequarry: 2
+ results:
+ - item:
+ chance: 1
+ table:
+ stone: 0
+ - item:
+ chance: 1
+ table:
+ crude_iron_ore: 0
+ iron_ore: 0.98
+ pure_iron_ore: 0.996
+ table_scaling:
+ skills:
+ planequarry: 1.25
+ - item:
+ chance: 0.02
+ table:
+ red_beryl: 0
+ tourmaline: 0.45
+ yellow_beryl: 0.90
+ paraiba_tourmaline: 0.95
diff --git a/db/migrate/20210503001859_create_activities.rb b/db/migrate/20210503001859_create_activities.rb
new file mode 100644
index 0000000..883d82a
--- /dev/null
+++ b/db/migrate/20210503001859_create_activities.rb
@@ -0,0 +1,12 @@
+class CreateActivities < ActiveRecord::Migration[6.1]
+ def change
+ create_table :activities do |t|
+ t.string :gid
+ t.string :name
+ t.text :description
+ t.jsonb :whatnot
+
+ t.timestamps
+ end
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index 67fd0f5..85aa952 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -10,11 +10,20 @@
#
# It's strongly recommended that you check this file into your version control system.
-ActiveRecord::Schema.define(version: 2021_05_02_212517) do
+ActiveRecord::Schema.define(version: 2021_05_03_001859) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
+ create_table "activities", force: :cascade do |t|
+ t.string "gid"
+ t.string "name"
+ t.text "description"
+ t.jsonb "whatnot"
+ t.datetime "created_at", precision: 6, null: false
+ t.datetime "updated_at", precision: 6, null: false
+ end
+
create_table "items", force: :cascade do |t|
t.string "gid"
t.string "name"
diff --git a/db/seeds.rb b/db/seeds.rb
index 2008d89..00a0566 100644
--- a/db/seeds.rb
+++ b/db/seeds.rb
@@ -24,3 +24,8 @@ load_data_file("data/items.yml").map do |gid, hash|
item.whatnot = hash[:whatnot]
item.save
end
+
+load_data_file("data/activities.yml").map do |gid, hash|
+ activity = Activity.find_or_create_by(gid: gid)
+ activity.update(hash)
+end
diff --git a/test/fixtures/activities.yml b/test/fixtures/activities.yml
new file mode 100644
index 0000000..6a7ba8a
--- /dev/null
+++ b/test/fixtures/activities.yml
@@ -0,0 +1,13 @@
+# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
+
+one:
+ gid: MyString
+ name: MyString
+ description: MyText
+ whatnot:
+
+two:
+ gid: MyString
+ name: MyString
+ description: MyText
+ whatnot:
diff --git a/test/models/activity_test.rb b/test/models/activity_test.rb
new file mode 100644
index 0000000..c07a8b9
--- /dev/null
+++ b/test/models/activity_test.rb
@@ -0,0 +1,7 @@
+require "test_helper"
+
+class ActivityTest < ActiveSupport::TestCase
+ # test "the truth" do
+ # assert true
+ # end
+end