From 4c96893a114059dc4e748307c6d046ec1faa778f Mon Sep 17 00:00:00 2001 From: David Gay Date: Wed, 2 Jun 2021 22:15:02 -0400 Subject: Magiculture --- CHANGELOG.md | 18 +- .../hearth/hearth_plantings_controller.rb | 39 +++ app/controllers/game_controller.rb | 12 + app/errors/hearth_planting_error.rb | 2 + app/models/character.rb | 10 + app/models/concerns/has_whatnot.rb | 4 + app/models/hearth.rb | 11 + app/models/hearth_planting.rb | 9 + .../hearth/hearth_plantings/index.html.erb | 29 ++ app/views/characters/hearth/index.html.erb | 3 + app/views/look/_results.html.erb | 3 + config/routes.rb | 1 + data/activities.yml | 327 ++++++++++++++++++++- data/hearth_amenities.yml | 9 + data/items.yml | 99 +++++++ .../20210602225942_create_hearth_plantings.rb | 10 + db/schema.rb | 13 +- test/fixtures/hearth_plantings.yml | 9 + test/models/hearth_planting_test.rb | 7 + 19 files changed, 609 insertions(+), 6 deletions(-) create mode 100644 app/controllers/characters/hearth/hearth_plantings_controller.rb create mode 100644 app/errors/hearth_planting_error.rb create mode 100644 app/models/hearth_planting.rb create mode 100644 app/views/characters/hearth/hearth_plantings/index.html.erb create mode 100644 db/migrate/20210602225942_create_hearth_plantings.rb create mode 100644 test/fixtures/hearth_plantings.yml create mode 100644 test/models/hearth_planting_test.rb diff --git a/CHANGELOG.md b/CHANGELOG.md index de1ecd9..9c1410c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,15 +1,25 @@ # Changelog All notable changes to this project will be documented in this file. -## [Unreleased] - 2021-06-02 +## [0.1.5] - 2021-06-03 ### Added +- Magiculture has been implemented. You can now find seeds and plant them at your hearth after you construct + a loamspire. After some time has passed, you can harvest the result. You can perform other activities whilst your + crops are growing. - New hearth amenities: loamspire level 1, loamspire level 2 -- New activities: Construct Loamspire Level 1, Construct Loamspire Level 2 +- New items: mudtub seed, midorias seed, templis seed, enzon seed, mudtub, midoras, templis, enzon, stone spade, + iron spade, arcanite spade +- New activities: construct loamspire level 1, construct loamspire level 2, craft iron spade, craft arcanite spade, + and all plant and harvest activities for the seeds and crops listed above ### Changed -- Initiative rolls are now made with a d20 instead of a d10. Therefore, speed is now more important. Previously, once a - combatant had a decent speed stat advantage, the roll was fairly easy to call. So this is a buff, but also a nerf. +- Initiative rolls are now made with a d20 instead of a d10. Therefore, having a good speed stat is now more important. + Previously, once a combatant had a decent speed stat advantage, the roll was fairly easy to call. So this is a buff, + but also a nerf. A bnerf. +- Stone spade can now be found while wildscouring crumbling ruins. Other drop chances have not changed, so the net + result is that you come up empty less. +- Seeds can now be found while wealdreaping in Twil Woods and Twil Grove. ### Fixed - Arcanite short sword was named "iron short sword". diff --git a/app/controllers/characters/hearth/hearth_plantings_controller.rb b/app/controllers/characters/hearth/hearth_plantings_controller.rb new file mode 100644 index 0000000..198943f --- /dev/null +++ b/app/controllers/characters/hearth/hearth_plantings_controller.rb @@ -0,0 +1,39 @@ +class Characters::Hearth::HearthPlantingsController < ApplicationController + before_action :redirect_unless_character_has_loamspire, :set_hearth + + def index + @hearth_plantings = @hearth.hearth_plantings + @planting_activities = Activity.where("gid like ?", "plant_%") + end + + def create + item = Item.find(params[:item_id]) + unless item.tags&.include?("seed") + flash[:alert] = "You can only plant seeds here." + redirect_to character_hearth_loamspire_path and return + end + + quantity = [params[:quantity], @hearth.available_planting_spots].min + if quantity < 1 + flash[:alert] = "You don't have any available planting slots." + redirect_to character_hearth_loamspire_path and return + end + + @hearth_planting = @hearth.hearth_plantings.new(item: item, quantity: quantity) + if @hearth_planting.save + flash[:notice] = "Planted #{quantity} #{item.name}." + else + flash[:alert] = "Failed to plant seeds." + end + redirect_to character_hearth_loamspire_path + end + + private + def redirect_unless_character_has_loamspire + redirect_to character_hearth_path(current_char) unless current_char.hearth.has_amenity?("loamspire", 1) + end + + def set_hearth + @hearth = current_char.hearth + end +end diff --git a/app/controllers/game_controller.rb b/app/controllers/game_controller.rb index 2de342a..04d743c 100644 --- a/app/controllers/game_controller.rb +++ b/app/controllers/game_controller.rb @@ -129,6 +129,15 @@ class GameController < ApplicationController .find_or_initialize_by(hearth_amenity: HearthAmenity.find_by_gid(result[:gid])) bhi.update(level: result[:level]) @results.push({ type: type, hearth_amenity: bhi.hearth_amenity }) + when "hearth_planting" + unless current_char.hearth.available_planting_spots > 0 + @results.replace([{ type: "error", message: "You're out of space to plant seeds." }]) + current_char.stop_activity + return + end + item = Item.find_by_gid(result[:gid]) + hp = current_char.hearth.hearth_plantings.create(item: item) + @results.push({ type: type, hearth_planting: hp }) when "activity" next if rand > (result[:chance] || 1) table_roll = rand @@ -174,6 +183,9 @@ class GameController < ApplicationController rescue ItemQuantityError current_char.stop_activity @results.replace([{ type: "error", message: "You don't have enough items to complete this activity." }]) + rescue HearthPlantingError + current_char.stop_activity + @results.replace([{ type: "error", message: "You don't have that crop planted." }]) rescue TooManyWoundsError current_char.stop_activity @results.replace([{ type: "error", diff --git a/app/errors/hearth_planting_error.rb b/app/errors/hearth_planting_error.rb new file mode 100644 index 0000000..4a2306f --- /dev/null +++ b/app/errors/hearth_planting_error.rb @@ -0,0 +1,2 @@ +class HearthPlantingError < StandardError +end diff --git a/app/models/character.rb b/app/models/character.rb index b7b323d..84583a8 100644 --- a/app/models/character.rb +++ b/app/models/character.rb @@ -106,6 +106,10 @@ class Character < ApplicationRecord case cost[:type] when "item" self.shift_item(cost[:gid], -(cost[:quantity] || 1)) + when "hearth_planting" + hp = hearth.ripe_hearth_plantings_of(cost[:gid]).first + raise HearthPlantingError unless hp + hp.destroy end end end @@ -217,6 +221,8 @@ class Character < ApplicationRecord case cost[:type] when "item" return false unless self.has_item?(cost[:gid], cost[:quantity] || 1) + when "hearth_planting" + return false unless hearth.ripe_hearth_plantings_of(cost[:gid]).first else raise "Invalid cost type string (#{cost[:type]})" end @@ -288,6 +294,10 @@ class Character < ApplicationRecord effects.filter_map { |e| e[:modifier] if e[:type] == "stat_change" && e[:gid] == gid }.sum end + def planting_spots + [total_stat_change("planting_spots"), 0].max + end + def can_fight? self.wounds < max_wounds end diff --git a/app/models/concerns/has_whatnot.rb b/app/models/concerns/has_whatnot.rb index a4dcfa0..289fe40 100644 --- a/app/models/concerns/has_whatnot.rb +++ b/app/models/concerns/has_whatnot.rb @@ -5,5 +5,9 @@ module HasWhatnot def whatnot @whatnot ||= super.is_a?(Hash) ? super.deep_symbolize_keys! : nil end + + def tags + whatnot[:tags] if whatnot + end end end diff --git a/app/models/hearth.rb b/app/models/hearth.rb index 1bd54a5..ee00c0c 100644 --- a/app/models/hearth.rb +++ b/app/models/hearth.rb @@ -2,6 +2,7 @@ class Hearth < ApplicationRecord belongs_to :character has_many :built_hearth_amenities has_many :hearth_amenities, through: :built_hearth_amenities + has_many :hearth_plantings def has_amenity?(hearth_amenity, level = 1) hearth_amenity = HearthAmenity.find_by_gid(hearth_amenity) if hearth_amenity.is_a? String @@ -15,4 +16,14 @@ class Hearth < ApplicationRecord bhi = self.built_hearth_amenities.find_by(hearth_amenity: hearth_amenity) bhi ? bhi.level : 0 end + + def available_planting_spots + character.planting_spots - hearth_plantings.count + end + + def ripe_hearth_plantings_of(item) + item = Item.find_by_gid(item) if item.is_a? String + # TODO: Proper querey instead of loading all into memory. + hearth_plantings.all.select { |hp| hp.item == item && hp.ripens_at < Time.now } + end end diff --git a/app/models/hearth_planting.rb b/app/models/hearth_planting.rb new file mode 100644 index 0000000..d6ae714 --- /dev/null +++ b/app/models/hearth_planting.rb @@ -0,0 +1,9 @@ +class HearthPlanting < ApplicationRecord + belongs_to :hearth + belongs_to :item + + def ripens_at + created_at + item.whatnot[:ripen_duration][:base].seconds + end +end + diff --git a/app/views/characters/hearth/hearth_plantings/index.html.erb b/app/views/characters/hearth/hearth_plantings/index.html.erb new file mode 100644 index 0000000..8aaefcc --- /dev/null +++ b/app/views/characters/hearth/hearth_plantings/index.html.erb @@ -0,0 +1,29 @@ +

Loamspire

+ +

You have <%= @hearth.available_planting_spots %> available planting spots.

+ +
+ <%= form_with url: start_activity_path, method: :post do |f| %> + <%= f.select :id, @planting_activities.sort_by { |a| a.name }.map { |a| [a.name, a.id] } %> + <%= f.number_field :actions, value: 1, size: 5, min: 1, max: 2_000_000_000 %> + <%= f.submit "Plant" %> + <% end %> +
+ +
+ <% @hearth_plantings.each do |hp| %> +
+

<%= hp.item.name %>

+ <% if hp.ripens_at > Time.now %> +

Ripens in <%= distance_of_time_in_words_to_now(hp.ripens_at) %>

+ <% else %> + <% harvest_activity = Activity.find_by_gid(hp.item.whatnot[:harvest_activity]) %> + <%= form_with url: start_activity_path(harvest_activity) do |f| %> + <%= f.hidden_field :id, value: harvest_activity.id %> + <%= f.hidden_field :actions, value: current_char.hearth.ripe_hearth_plantings_of(hp.item).count %> + <%= f.submit "Harvest" %> + <% end %> + <% end %> +
+ <% end %> +
diff --git a/app/views/characters/hearth/index.html.erb b/app/views/characters/hearth/index.html.erb index c058007..7ff34c5 100644 --- a/app/views/characters/hearth/index.html.erb +++ b/app/views/characters/hearth/index.html.erb @@ -24,6 +24,9 @@ <% if built_amenity.usable? %> <%= button_to "Use", hearth_amenity_use_path(built_amenity.hearth_amenity) %> <% end %> + <% if built_amenity.hearth_amenity.gid == "loamspire" %> + <%= link_to "Manage", character_hearth_loamspire_path, class: "btn btn-primary" %> + <% end %> <% end %> <% next_level = built_amenity ? built_amenity.level + 1 : 1 %> <% construct_activity = ha.construct_activity(next_level) %> diff --git a/app/views/look/_results.html.erb b/app/views/look/_results.html.erb index beb2deb..2c79812 100644 --- a/app/views/look/_results.html.erb +++ b/app/views/look/_results.html.erb @@ -9,6 +9,9 @@

<% when "hearth_amenity" %>

You constructed <%= result[:hearth_amenity].name %>.

+ <% when "hearth_planting" %> +

You planted <%= link_to result[:hearth_planting].item.name, + item_path(result[:hearth_planting].item) %> in the loam.

<% when "activity" %>

You realized how to <%= result[:activity].name %>!

<% when "monster" %> diff --git a/config/routes.rb b/config/routes.rb index 88d75ef..4dea419 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -33,6 +33,7 @@ Rails.application.routes.draw do post "/activate", to: "titles#activate" end get "/hearth", to: "hearth#index" + get "/hearth/loamspire", to: "hearth/hearth_plantings#index" end end diff --git a/data/activities.yml b/data/activities.yml index 8208d26..7ab2413 100644 --- a/data/activities.yml +++ b/data/activities.yml @@ -203,6 +203,220 @@ construct_loamspire_level2: - type: "hearth_amenity" gid: "loamspire" level: 2 +plant_mudtub_seed: + name: "Plant Mudtub Seed" + description: "Plant a mudtub seed." + whatnot: + requirements: + - type: "hearth_amenity" + gid: "loamspire" + level: 1 + duration: + base: 120 + scaling: + - type: "skill" + gid: "magiculture" + scale_value: 1 + - type: "stat" + gid: "magiculture_speed" + scale_value: 1 + cost: + - type: "item" + gid: "mudtub_seed" + results: + - type: "hearth_planting" + gid: "mudtub_seed" +harvest_mudtub: + name: "Harvest Mudtub" + description: "Harvest a mudtub." + whatnot: + requirements: + - type: "hearth_amenity" + gid: "loamspire" + level: 1 + duration: + base: 120 + scaling: + - type: "skill" + gid: "magiculture" + scale_value: 1 + - type: "stat" + gid: "magiculture_speed" + scale_value: 1 + cost: + - type: "hearth_planting" + gid: "mudtub_seed" + results: + - type: "item" + gid: "mudtub" + xp: + - gid: "magiculture" + value: 10 +plant_midorias_seed: + name: "Plant Midorias Seed" + description: "Plant a midorias seed." + whatnot: + requirements: + - type: "hearth_amenity" + gid: "loamspire" + level: 1 + - type: "skill" + gid: "magiculture" + level: 2 + duration: + base: 130 + scaling: + - type: "skill" + gid: "magiculture" + scale_value: 1 + - type: "stat" + gid: "magiculture_speed" + scale_value: 1 + cost: + - type: "item" + gid: "midorias_seed" + results: + - type: "hearth_planting" + gid: "midorias_seed" +harvest_midorias: + name: "Harvest Midorias" + description: "Harvest a midorias." + whatnot: + requirements: + - type: "hearth_amenity" + gid: "loamspire" + level: 1 + - type: "skill" + gid: "magiculture" + level: 2 + duration: + base: 130 + scaling: + - type: "skill" + gid: "magiculture" + scale_value: 1 + - type: "stat" + gid: "magiculture_speed" + scale_value: 1 + cost: + - type: "hearth_planting" + gid: "midorias_seed" + results: + - type: "item" + gid: "midorias" + xp: + - gid: "magiculture" + value: 15 +plant_templis_seed: + name: "Plant Templis Seed" + description: "Plant a templis seed." + whatnot: + requirements: + - type: "hearth_amenity" + gid: "loamspire" + level: 1 + - type: "skill" + gid: "magiculture" + level: 4 + duration: + base: 140 + scaling: + - type: "skill" + gid: "magiculture" + scale_value: 1 + - type: "stat" + gid: "magiculture_speed" + scale_value: 1 + cost: + - type: "item" + gid: "templis_seed" + results: + - type: "hearth_planting" + gid: "templis_seed" +harvest_templis: + name: "Harvest Templis" + description: "Harvest a templis." + whatnot: + requirements: + - type: "hearth_amenity" + gid: "loamspire" + level: 1 + - type: "skill" + gid: "magiculture" + level: 4 + duration: + base: 140 + scaling: + - type: "skill" + gid: "magiculture" + scale_value: 1 + - type: "stat" + gid: "magiculture_speed" + scale_value: 1 + cost: + - type: "hearth_planting" + gid: "templis_seed" + results: + - type: "item" + gid: "templis" + xp: + - gid: "magiculture" + value: 30 +plant_enzon_seed: + name: "Plant Enzon Seed" + description: "Plant an enzon seed." + whatnot: + requirements: + - type: "hearth_amenity" + gid: "loamspire" + level: 1 + - type: "skill" + gid: "magiculture" + level: 7 + duration: + base: 150 + scaling: + - type: "skill" + gid: "magiculture" + scale_value: 1 + - type: "stat" + gid: "magiculture_speed" + scale_value: 1 + cost: + - type: "item" + gid: "enzon_seed" + results: + - type: "hearth_planting" + gid: "enzon_seed" +harvest_enzon: + name: "Harvest Enzon" + description: "Harvest an enzon." + whatnot: + requirements: + - type: "hearth_amenity" + gid: "loamspire" + level: 1 + - type: "skill" + gid: "magiculture" + level: 7 + duration: + base: 150 + scaling: + - type: "skill" + gid: "magiculture" + scale_value: 1 + - type: "stat" + gid: "magiculture_speed" + scale_value: 1 + cost: + - type: "hearth_planting" + gid: "enzon_seed" + results: + - type: "item" + gid: "enzon" + xp: + - gid: "magiculture" + value: 45 craft_pig_iron_ingot: name: "Smelt Pig Iron Ingot" description: "Smelt a pig iron ingot." @@ -777,6 +991,37 @@ craft_iron_axe: xp: - gid: "otherforge" value: 15 +craft_iron_spade: + name: "Craft Iron Spade" + description: "Craft an iron spade." + whatnot: + requirements: + - type: "hearth_amenity" + gid: "forge" + level: 1 + duration: + base: 120 + minimum: 35 + scaling: + - type: "skill" + gid: "otherforge" + scale_value: 1 + - type: "stat" + gid: "otherforge_speed" + scale_value: 1 + cost: + - type: "item" + gid: "iron_ingot" + quantity: 3 + - type: "item" + gid: "wood" + quantity: 2 + results: + - type: "item" + gid: "iron_spade" + xp: + - gid: "otherforge" + value: 15 craft_arcanite_pickaxe: name: "Craft Arcanite Pickaxe" description: "Craft an arcanite pickaxe." @@ -845,6 +1090,40 @@ craft_arcanite_axe: xp: - gid: "otherforge" value: 30 +craft_arcanite_spade: + name: "Craft Arcanite Spade" + description: "Craft an arcanite spade." + whatnot: + requirements: + - type: "hearth_amenity" + gid: "forge" + level: 2 + - type: "skill" + gid: "otherforge" + level: 10 + duration: + base: 140 + minimum: 35 + scaling: + - type: "skill" + gid: "otherforge" + scale_value: 1 + - type: "stat" + gid: "otherforge_speed" + scale_value: 1 + cost: + - type: "item" + gid: "arcanite_ingot" + quantity: 3 + - type: "item" + gid: "wood" + quantity: 2 + results: + - type: "item" + gid: "arcanite_spade" + xp: + - gid: "otherforge" + value: 30 craft_onus_of_vision: name: "Craft onus of vision" description: "Craft an onus of vision." @@ -1351,6 +1630,24 @@ wealdreap_twil_woods: xp: - gid: "wealdreap" value: 50 + - type: "item" + chance: 0.02 + table: + - gid: "mudtub_seed" + score: 0 + xp: + - gid: "wealdreap" + value: 10 + - gid: "midorias_seed" + score: 0.45 + xp: + - gid: "wealdreap" + value: 15 + - gid: "templis_seed" + score: 0.90 + xp: + - gid: "wealdreap" + value: 30 wealdreap_twil_grove: name: "Reap Twil Grove" description: "Wealdreap within the hidden woodways of the Twil Woods Grove." @@ -1394,6 +1691,29 @@ wealdreap_twil_grove: xp: - gid: "wealdreap" value: 85 + - type: "item" + chance: 0.02 + table: + - gid: "mudtub_seed" + score: 0 + xp: + - gid: "wealdreap" + value: 10 + - gid: "midorias_seed" + score: 0.30 + xp: + - gid: "wealdreap" + value: 15 + - gid: "templis_seed" + score: 0.60 + xp: + - gid: "wealdreap" + value: 30 + - gid: "enzon_seed" + score: 0.90 + xp: + - gid: "wealdreap" + value: 45 manatrawl_sor_well: name: "Trawl Sor Well" description: "Manatrawl within Sor Well." @@ -1555,12 +1875,17 @@ wildscour_crumbling_ruins: chance: 1 table: - gid: "vestige" - score: 0.45 + score: 0.35 max_quantity: 5 xp: - gid: "wildscour" value: 2 - gid: "aethermesh" + score: 0.50 + xp: + - gid: "wildscour" + value: 4 + - gid: "stone_spade" score: 0.60 xp: - gid: "wildscour" diff --git a/data/hearth_amenities.yml b/data/hearth_amenities.yml index bb60d3f..9d6aeb3 100644 --- a/data/hearth_amenities.yml +++ b/data/hearth_amenities.yml @@ -62,3 +62,12 @@ loamspire: gid: "construct_loamspire_level1" - level: 2 gid: "construct_loamspire_level2" + effects: + - type: "stat_change" + level: 1 + gid: "planting_spots" + modifier: 5 + - type: "stat_change" + level: 2 + gid: "planting_spots" + modifier: 5 diff --git a/data/items.yml b/data/items.yml index df2def6..6dc187a 100644 --- a/data/items.yml +++ b/data/items.yml @@ -386,9 +386,56 @@ granite_ring: - type: "stat_change" gid: "block" modifier: 1 +mudtub_seed: + name: "mudtub seed" + description: "The seed of a mudtub plant." + whatnot: + tags: + - "seed" + ripen_duration: + base: 28800 # 8 hours + harvest_activity: "harvest_mudtub" +midorias_seed: + name: "midorias seed" + description: "The seed of a midorias plant." + whatnot: + tags: + - "seed" + ripen_duration: + base: 36000 # 10 hours + harvest_activity: "harvest_midorias" +templis_seed: + name: "templis seed" + description: "The seed of a templis plant." + whatnot: + tags: + - "seed" + ripen_duration: + base: 43200 # 12 hours + harvest_activity: "harvest_templis" enzon_seed: name: "enzon seed" description: "The seed of an enzon plant." + whatnot: + tags: + - "seed" + ripen_duration: + base: 50400 # 14 hours + harvest_activity: "harvest_enzon" +mudtub: + name: "mudtub" + description: "A bulbous, brown tuber that smells terrible and tastes like nothing." +midoras: + name: "midoras" + description: "A dark green vegetable with massive leaves many times the size of its stalk." +templis: + name: "templis" + description: "A plant consisting of thin stems from which dangle small, yellow, oblong peppers." +enzon: + name: "enzon" + description: >- + A huge, black vegetable that grows from a vine. Looks like a giant seed, but its insides contain white, meaty + flesh. iron_lockpicks: name: "iron lockpicks" description: "Tools for getting into places other people -- or things -- don't want you to be." @@ -427,6 +474,22 @@ stone_axe: - type: "stat_change" gid: "power" modifier: 1 +stone_spade: + name: "stone spade" + description: "An old spade found in some ruins." + whatnot: + equip_slots: + - "mainhand" + equip_effects: + - type: "stat_change" + gid: "magiculture_speed" + modifier: 60 + - type: "stat_change" + gid: "accuracy" + modifier: 0 + - type: "stat_change" + gid: "power" + modifier: 1 iron_pickaxe: name: "iron pickaxe" description: "A pickaxe made of iron." @@ -459,6 +522,22 @@ iron_axe: - type: "stat_change" gid: "power" modifier: 2 +iron_spade: + name: "iron spade" + description: "A spade made of iron." + whatnot: + equip_slots: + - "mainhand" + equip_effects: + - type: "stat_change" + gid: "magiculture_speed" + modifier: 80 + - type: "stat_change" + gid: "accuracy" + modifier: 1 + - type: "stat_change" + gid: "power" + modifier: 2 arcanite_pickaxe: name: "arcanite pickaxe" description: "A pickaxe made of arcanite." @@ -499,6 +578,26 @@ arcanite_axe: - type: "stat_change" gid: "power" modifier: 3 +arcanite_spade: + name: "arcanite spade" + description: "A spade made of arcanite." + whatnot: + equip_slots: + - "mainhand" + equip_requirements: + - type: "skill" + gid: "magiculture" + level: 10 + equip_effects: + - type: "stat_change" + gid: "magiculture_speed" + modifier: 100 + - type: "stat_change" + gid: "accuracy" + modifier: 2 + - type: "stat_change" + gid: "power" + modifier: 3 aethermesh: name: "aethermesh" description: "A tool for manatrawl." diff --git a/db/migrate/20210602225942_create_hearth_plantings.rb b/db/migrate/20210602225942_create_hearth_plantings.rb new file mode 100644 index 0000000..b5d0adb --- /dev/null +++ b/db/migrate/20210602225942_create_hearth_plantings.rb @@ -0,0 +1,10 @@ +class CreateHearthPlantings < ActiveRecord::Migration[6.1] + def change + create_table :hearth_plantings do |t| + t.references :hearth, null: false, foreign_key: true + t.references :item, null: false, foreign_key: true + + t.timestamps + end + end +end diff --git a/db/schema.rb b/db/schema.rb index 2a0b30a..9e20579 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 2021_05_31_192205) do +ActiveRecord::Schema.define(version: 2021_06_02_225942) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -140,6 +140,15 @@ ActiveRecord::Schema.define(version: 2021_05_31_192205) do t.index ["gid"], name: "index_hearth_amenities_on_gid" end + create_table "hearth_plantings", force: :cascade do |t| + t.bigint "hearth_id", null: false + t.bigint "item_id", null: false + t.datetime "created_at", precision: 6, null: false + t.datetime "updated_at", precision: 6, null: false + t.index ["hearth_id"], name: "index_hearth_plantings_on_hearth_id" + t.index ["item_id"], name: "index_hearth_plantings_on_item_id" + end + create_table "hearths", force: :cascade do |t| t.bigint "character_id", null: false t.datetime "created_at", precision: 6, null: false @@ -265,6 +274,8 @@ ActiveRecord::Schema.define(version: 2021_05_31_192205) do add_foreign_key "chat_messages", "chat_rooms" add_foreign_key "equipment", "characters" add_foreign_key "equipment", "items" + add_foreign_key "hearth_plantings", "hearths" + add_foreign_key "hearth_plantings", "items" add_foreign_key "hearths", "characters" add_foreign_key "learned_activities", "activities" add_foreign_key "learned_activities", "characters" diff --git a/test/fixtures/hearth_plantings.yml b/test/fixtures/hearth_plantings.yml new file mode 100644 index 0000000..3bdbb5d --- /dev/null +++ b/test/fixtures/hearth_plantings.yml @@ -0,0 +1,9 @@ +# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html + +one: + hearth: one + item: one + +two: + hearth: two + item: two diff --git a/test/models/hearth_planting_test.rb b/test/models/hearth_planting_test.rb new file mode 100644 index 0000000..ccfbb79 --- /dev/null +++ b/test/models/hearth_planting_test.rb @@ -0,0 +1,7 @@ +require "test_helper" + +class HearthPlantingTest < ActiveSupport::TestCase + # test "the truth" do + # assert true + # end +end -- cgit v1.2.3