summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/models/item.rb5
-rw-r--r--data/items.yml57
-rw-r--r--db/migrate/20210502212517_create_items.rb14
-rw-r--r--db/schema.rb13
-rw-r--r--db/seeds.rb10
-rw-r--r--test/fixtures/items.yml17
-rw-r--r--test/models/item_test.rb7
7 files changed, 122 insertions, 1 deletions
diff --git a/app/models/item.rb b/app/models/item.rb
new file mode 100644
index 0000000..b570b4e
--- /dev/null
+++ b/app/models/item.rb
@@ -0,0 +1,5 @@
+class Item < ApplicationRecord
+ enum equip_slot: [:mainhand, :offhand, :head, :neck, :back, :torso, :grip,
+ :left_ring, :right_ring, :waist, :legs, :feet, :curio]
+ validates :gid, :name, :description, :usable, presence: true
+end
diff --git a/data/items.yml b/data/items.yml
new file mode 100644
index 0000000..19e3534
--- /dev/null
+++ b/data/items.yml
@@ -0,0 +1,57 @@
+crude_iron_ore:
+ name: "Crude iron ore"
+ description: "A chunk of very impure iron ore."
+ whatnot:
+ xp_value:
+ planequarry: 5
+pure_iron_ore:
+ name: "Pure iron ore"
+ description: "A chunk of naturally rich and pure iron ore."
+ whatnot:
+ xp_value:
+ planequarry: 10
+paraiba_tourmaline:
+ name: "Paraiba tourmaline"
+ description: "A rare and beautiful turquoise gem."
+ whatnot:
+ xp_value:
+ planequarry: 50
+red_beryl:
+ name: "Red beryl"
+ description: "A simple red gem."
+ whatnot:
+ xp_value:
+ planequarry: 30
+tourmaline:
+ name: "Tourmaline"
+ description: "A crude pink-blue gem."
+ whatnot:
+ xp_value:
+ planequarry: 30
+yellow_beryl:
+ name: "Yellow beryl"
+ description: "A rare and beautiful yellow gem."
+ whatnot:
+ xp_value:
+ planequarry: 50
+iron_short_sword:
+ name: "Iron short sword"
+ description: "A short sword made of iron."
+ whatnot:
+ xp_value:
+ otherforge: 15
+ equip_slot: "mainhand"
+iron_longsword:
+ name: "Iron longsword"
+ description: "A longsword made of iron."
+ equip_slot: "mainhand"
+ whatnot:
+ xp_value:
+ otherforge: 45
+ equip_requirements:
+ skills:
+ beastslay: 3
+mending_salve:
+ name: "Mending salve"
+ description: "A healing mixture capable of closing wounds."
+ usable: true
diff --git a/db/migrate/20210502212517_create_items.rb b/db/migrate/20210502212517_create_items.rb
new file mode 100644
index 0000000..1bb17ce
--- /dev/null
+++ b/db/migrate/20210502212517_create_items.rb
@@ -0,0 +1,14 @@
+class CreateItems < ActiveRecord::Migration[6.1]
+ def change
+ create_table :items do |t|
+ t.string :gid
+ t.string :name
+ t.text :description
+ t.integer :equip_slot
+ t.boolean :usable
+ t.jsonb :whatnot
+
+ t.timestamps
+ end
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index 5fc0f94..67fd0f5 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -10,11 +10,22 @@
#
# It's strongly recommended that you check this file into your version control system.
-ActiveRecord::Schema.define(version: 2021_05_02_200959) do
+ActiveRecord::Schema.define(version: 2021_05_02_212517) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
+ create_table "items", force: :cascade do |t|
+ t.string "gid"
+ t.string "name"
+ t.text "description"
+ t.integer "equip_slot"
+ t.boolean "usable"
+ t.jsonb "whatnot"
+ t.datetime "created_at", precision: 6, null: false
+ t.datetime "updated_at", precision: 6, null: false
+ end
+
create_table "skills", force: :cascade do |t|
t.string "gid"
t.string "name"
diff --git a/db/seeds.rb b/db/seeds.rb
index 637a355..2008d89 100644
--- a/db/seeds.rb
+++ b/db/seeds.rb
@@ -14,3 +14,13 @@ load_data_file("data/skills.yml").map do |gid, hash|
skill = Skill.find_or_create_by(gid: gid)
skill.update(hash)
end
+
+load_data_file("data/items.yml").map do |gid, hash|
+ item = Item.find_or_create_by(gid: gid)
+ item.name = hash[:name]
+ item.description = hash[:description]
+ item.equip_slot = hash[:equip_slot]&.to_sym
+ item.usable = hash[:usable] || false
+ item.whatnot = hash[:whatnot]
+ item.save
+end
diff --git a/test/fixtures/items.yml b/test/fixtures/items.yml
new file mode 100644
index 0000000..2540b9e
--- /dev/null
+++ b/test/fixtures/items.yml
@@ -0,0 +1,17 @@
+# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
+
+one:
+ gid: MyString
+ name: MyString
+ description: MyText
+ equip_slot: 1
+ usable: false
+ whatnot:
+
+two:
+ gid: MyString
+ name: MyString
+ description: MyText
+ equip_slot: 1
+ usable: false
+ whatnot:
diff --git a/test/models/item_test.rb b/test/models/item_test.rb
new file mode 100644
index 0000000..4bd69ff
--- /dev/null
+++ b/test/models/item_test.rb
@@ -0,0 +1,7 @@
+require "test_helper"
+
+class ItemTest < ActiveSupport::TestCase
+ # test "the truth" do
+ # assert true
+ # end
+end