diff --git a/app/assets/javascripts/buildings.coffee b/app/assets/javascripts/buildings.coffee new file mode 100644 index 0000000..24f83d1 --- /dev/null +++ b/app/assets/javascripts/buildings.coffee @@ -0,0 +1,3 @@ +# Place all the behaviors and hooks related to the matching controller here. +# All this logic will automatically be available in application.js. +# You can use CoffeeScript in this file: http://coffeescript.org/ diff --git a/app/assets/stylesheets/buildings.scss b/app/assets/stylesheets/buildings.scss new file mode 100644 index 0000000..e416b77 --- /dev/null +++ b/app/assets/stylesheets/buildings.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the Buildings controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/controllers/buildings_controller.rb b/app/controllers/buildings_controller.rb new file mode 100644 index 0000000..8f6eabe --- /dev/null +++ b/app/controllers/buildings_controller.rb @@ -0,0 +1,74 @@ +class BuildingsController < ApplicationController + before_action :set_building, only: [:show, :edit, :update, :destroy] + + # GET /buildings + # GET /buildings.json + def index + @buildings = Building.all + end + + # GET /buildings/1 + # GET /buildings/1.json + def show + end + + # GET /buildings/new + def new + @building = Building.new + end + + # GET /buildings/1/edit + def edit + end + + # POST /buildings + # POST /buildings.json + def create + @building = Building.new(building_params) + + respond_to do |format| + if @building.save + format.html { redirect_to @building, notice: 'Building was successfully created.' } + format.json { render :show, status: :created, location: @building } + else + format.html { render :new } + format.json { render json: @building.errors, status: :unprocessable_entity } + end + end + end + + # PATCH/PUT /buildings/1 + # PATCH/PUT /buildings/1.json + def update + respond_to do |format| + if @building.update(building_params) + format.html { redirect_to @building, notice: 'Building was successfully updated.' } + format.json { render :show, status: :ok, location: @building } + else + format.html { render :edit } + format.json { render json: @building.errors, status: :unprocessable_entity } + end + end + end + + # DELETE /buildings/1 + # DELETE /buildings/1.json + def destroy + @building.destroy + respond_to do |format| + format.html { redirect_to buildings_url, notice: 'Building was successfully destroyed.' } + format.json { head :no_content } + end + end + + private + # Use callbacks to share common setup or constraints between actions. + def set_building + @building = Building.find(params[:id]) + end + + # Never trust parameters from the scary internet, only allow the white list through. + def building_params + params.require(:building).permit(:type, :name, :description, :population_bonus, :melange_bonus, :material_bonus, :solar_bonus, :exp_bonus, :population_cost, :melange_cost, :material_cost, :solar_cost, :exp_cost) + end +end diff --git a/app/helpers/buildings_helper.rb b/app/helpers/buildings_helper.rb new file mode 100644 index 0000000..d5c176b --- /dev/null +++ b/app/helpers/buildings_helper.rb @@ -0,0 +1,2 @@ +module BuildingsHelper +end diff --git a/app/models/building.rb b/app/models/building.rb new file mode 100644 index 0000000..dc179d4 --- /dev/null +++ b/app/models/building.rb @@ -0,0 +1,26 @@ +# == Schema Information +# +# Table name: buildings +# +# id :integer not null, primary key +# type :string +# name :string not null +# description :string default("") +# population_bonus :decimal(12, 4) default(0.0) +# melange_bonus :decimal(12, 4) default(0.0) +# material_bonus :decimal(12, 4) default(0.0) +# solar_bonus :decimal(12, 4) default(0.0) +# exp_bonus :decimal(12, 4) default(0.0) +# population_cost :decimal(12, 4) default(0.0) +# melange_cost :decimal(12, 4) default(0.0) +# material_cost :decimal(12, 4) default(0.0) +# solar_cost :decimal(12, 4) default(0.0) +# exp_cost :decimal(12, 4) default(0.0) +# created_at :datetime not null +# updated_at :datetime not null +# + +class Building < ApplicationRecord + has_many :estates + has_many :fields, through: :estates +end diff --git a/app/models/building/material.rb b/app/models/building/material.rb new file mode 100644 index 0000000..6ad987e --- /dev/null +++ b/app/models/building/material.rb @@ -0,0 +1,24 @@ +# == Schema Information +# +# Table name: buildings +# +# id :integer not null, primary key +# type :string +# name :string not null +# description :string default("") +# population_bonus :decimal(12, 4) default(0.0) +# melange_bonus :decimal(12, 4) default(0.0) +# material_bonus :decimal(12, 4) default(0.0) +# solar_bonus :decimal(12, 4) default(0.0) +# exp_bonus :decimal(12, 4) default(0.0) +# population_cost :decimal(12, 4) default(0.0) +# melange_cost :decimal(12, 4) default(0.0) +# material_cost :decimal(12, 4) default(0.0) +# solar_cost :decimal(12, 4) default(0.0) +# exp_cost :decimal(12, 4) default(0.0) +# created_at :datetime not null +# updated_at :datetime not null +# + +class Building::Material < Building +end diff --git a/app/models/building/material/borehole.rb b/app/models/building/material/borehole.rb new file mode 100644 index 0000000..984eef2 --- /dev/null +++ b/app/models/building/material/borehole.rb @@ -0,0 +1,24 @@ +# == Schema Information +# +# Table name: buildings +# +# id :integer not null, primary key +# type :string +# name :string not null +# description :string default("") +# population_bonus :decimal(12, 4) default(0.0) +# melange_bonus :decimal(12, 4) default(0.0) +# material_bonus :decimal(12, 4) default(0.0) +# solar_bonus :decimal(12, 4) default(0.0) +# exp_bonus :decimal(12, 4) default(0.0) +# population_cost :decimal(12, 4) default(0.0) +# melange_cost :decimal(12, 4) default(0.0) +# material_cost :decimal(12, 4) default(0.0) +# solar_cost :decimal(12, 4) default(0.0) +# exp_cost :decimal(12, 4) default(0.0) +# created_at :datetime not null +# updated_at :datetime not null +# + +class Building::Material::Borehole < Building::Material +end diff --git a/app/models/building/material/deep_core.rb b/app/models/building/material/deep_core.rb new file mode 100644 index 0000000..c6e2a2d --- /dev/null +++ b/app/models/building/material/deep_core.rb @@ -0,0 +1,24 @@ +# == Schema Information +# +# Table name: buildings +# +# id :integer not null, primary key +# type :string +# name :string not null +# description :string default("") +# population_bonus :decimal(12, 4) default(0.0) +# melange_bonus :decimal(12, 4) default(0.0) +# material_bonus :decimal(12, 4) default(0.0) +# solar_bonus :decimal(12, 4) default(0.0) +# exp_bonus :decimal(12, 4) default(0.0) +# population_cost :decimal(12, 4) default(0.0) +# melange_cost :decimal(12, 4) default(0.0) +# material_cost :decimal(12, 4) default(0.0) +# solar_cost :decimal(12, 4) default(0.0) +# exp_cost :decimal(12, 4) default(0.0) +# created_at :datetime not null +# updated_at :datetime not null +# + +class Building::Material::DeepCore < Building::Material +end diff --git a/app/models/building/material/mine.rb b/app/models/building/material/mine.rb new file mode 100644 index 0000000..10d1b2f --- /dev/null +++ b/app/models/building/material/mine.rb @@ -0,0 +1,24 @@ +# == Schema Information +# +# Table name: buildings +# +# id :integer not null, primary key +# type :string +# name :string not null +# description :string default("") +# population_bonus :decimal(12, 4) default(0.0) +# melange_bonus :decimal(12, 4) default(0.0) +# material_bonus :decimal(12, 4) default(0.0) +# solar_bonus :decimal(12, 4) default(0.0) +# exp_bonus :decimal(12, 4) default(0.0) +# population_cost :decimal(12, 4) default(0.0) +# melange_cost :decimal(12, 4) default(0.0) +# material_cost :decimal(12, 4) default(0.0) +# solar_cost :decimal(12, 4) default(0.0) +# exp_cost :decimal(12, 4) default(0.0) +# created_at :datetime not null +# updated_at :datetime not null +# + +class Building::Material::Mine < Building::Material +end diff --git a/app/models/building/melange.rb b/app/models/building/melange.rb new file mode 100644 index 0000000..0bd12b8 --- /dev/null +++ b/app/models/building/melange.rb @@ -0,0 +1,25 @@ +# == Schema Information +# +# Table name: buildings +# +# id :integer not null, primary key +# type :string +# name :string not null +# description :string default("") +# population_bonus :decimal(12, 4) default(0.0) +# melange_bonus :decimal(12, 4) default(0.0) +# material_bonus :decimal(12, 4) default(0.0) +# solar_bonus :decimal(12, 4) default(0.0) +# exp_bonus :decimal(12, 4) default(0.0) +# population_cost :decimal(12, 4) default(0.0) +# melange_cost :decimal(12, 4) default(0.0) +# material_cost :decimal(12, 4) default(0.0) +# solar_cost :decimal(12, 4) default(0.0) +# exp_cost :decimal(12, 4) default(0.0) +# created_at :datetime not null +# updated_at :datetime not null +# + +class Building::Melange < Building + +end diff --git a/app/models/building/melange/arraken.rb b/app/models/building/melange/arraken.rb new file mode 100644 index 0000000..0ad1e51 --- /dev/null +++ b/app/models/building/melange/arraken.rb @@ -0,0 +1,24 @@ +# == Schema Information +# +# Table name: buildings +# +# id :integer not null, primary key +# type :string +# name :string not null +# description :string default("") +# population_bonus :decimal(12, 4) default(0.0) +# melange_bonus :decimal(12, 4) default(0.0) +# material_bonus :decimal(12, 4) default(0.0) +# solar_bonus :decimal(12, 4) default(0.0) +# exp_bonus :decimal(12, 4) default(0.0) +# population_cost :decimal(12, 4) default(0.0) +# melange_cost :decimal(12, 4) default(0.0) +# material_cost :decimal(12, 4) default(0.0) +# solar_cost :decimal(12, 4) default(0.0) +# exp_cost :decimal(12, 4) default(0.0) +# created_at :datetime not null +# updated_at :datetime not null +# + +class Building::Melange::Arraken < Building::Melange +end diff --git a/app/models/building/melange/harvester.rb b/app/models/building/melange/harvester.rb new file mode 100644 index 0000000..1a05f84 --- /dev/null +++ b/app/models/building/melange/harvester.rb @@ -0,0 +1,24 @@ +# == Schema Information +# +# Table name: buildings +# +# id :integer not null, primary key +# type :string +# name :string not null +# description :string default("") +# population_bonus :decimal(12, 4) default(0.0) +# melange_bonus :decimal(12, 4) default(0.0) +# material_bonus :decimal(12, 4) default(0.0) +# solar_bonus :decimal(12, 4) default(0.0) +# exp_bonus :decimal(12, 4) default(0.0) +# population_cost :decimal(12, 4) default(0.0) +# melange_cost :decimal(12, 4) default(0.0) +# material_cost :decimal(12, 4) default(0.0) +# solar_cost :decimal(12, 4) default(0.0) +# exp_cost :decimal(12, 4) default(0.0) +# created_at :datetime not null +# updated_at :datetime not null +# + +class Building::Melange::Harvester < Building::Melange +end diff --git a/app/models/building/population.rb b/app/models/building/population.rb new file mode 100644 index 0000000..01c8853 --- /dev/null +++ b/app/models/building/population.rb @@ -0,0 +1,24 @@ +# == Schema Information +# +# Table name: buildings +# +# id :integer not null, primary key +# type :string +# name :string not null +# description :string default("") +# population_bonus :decimal(12, 4) default(0.0) +# melange_bonus :decimal(12, 4) default(0.0) +# material_bonus :decimal(12, 4) default(0.0) +# solar_bonus :decimal(12, 4) default(0.0) +# exp_bonus :decimal(12, 4) default(0.0) +# population_cost :decimal(12, 4) default(0.0) +# melange_cost :decimal(12, 4) default(0.0) +# material_cost :decimal(12, 4) default(0.0) +# solar_cost :decimal(12, 4) default(0.0) +# exp_cost :decimal(12, 4) default(0.0) +# created_at :datetime not null +# updated_at :datetime not null +# + +class Building::Population < Building +end diff --git a/app/models/building/population/city.rb b/app/models/building/population/city.rb new file mode 100644 index 0000000..3f22283 --- /dev/null +++ b/app/models/building/population/city.rb @@ -0,0 +1,24 @@ +# == Schema Information +# +# Table name: buildings +# +# id :integer not null, primary key +# type :string +# name :string not null +# description :string default("") +# population_bonus :decimal(12, 4) default(0.0) +# melange_bonus :decimal(12, 4) default(0.0) +# material_bonus :decimal(12, 4) default(0.0) +# solar_bonus :decimal(12, 4) default(0.0) +# exp_bonus :decimal(12, 4) default(0.0) +# population_cost :decimal(12, 4) default(0.0) +# melange_cost :decimal(12, 4) default(0.0) +# material_cost :decimal(12, 4) default(0.0) +# solar_cost :decimal(12, 4) default(0.0) +# exp_cost :decimal(12, 4) default(0.0) +# created_at :datetime not null +# updated_at :datetime not null +# + +class Building::Population::City < Building::Population +end diff --git a/app/models/building/population/metropolis.rb b/app/models/building/population/metropolis.rb new file mode 100644 index 0000000..0efecb8 --- /dev/null +++ b/app/models/building/population/metropolis.rb @@ -0,0 +1,24 @@ +# == Schema Information +# +# Table name: buildings +# +# id :integer not null, primary key +# type :string +# name :string not null +# description :string default("") +# population_bonus :decimal(12, 4) default(0.0) +# melange_bonus :decimal(12, 4) default(0.0) +# material_bonus :decimal(12, 4) default(0.0) +# solar_bonus :decimal(12, 4) default(0.0) +# exp_bonus :decimal(12, 4) default(0.0) +# population_cost :decimal(12, 4) default(0.0) +# melange_cost :decimal(12, 4) default(0.0) +# material_cost :decimal(12, 4) default(0.0) +# solar_cost :decimal(12, 4) default(0.0) +# exp_cost :decimal(12, 4) default(0.0) +# created_at :datetime not null +# updated_at :datetime not null +# + +class Building::Population::Metropolis < Building::Population +end diff --git a/app/models/building/population/town.rb b/app/models/building/population/town.rb new file mode 100644 index 0000000..64ac94c --- /dev/null +++ b/app/models/building/population/town.rb @@ -0,0 +1,24 @@ +# == Schema Information +# +# Table name: buildings +# +# id :integer not null, primary key +# type :string +# name :string not null +# description :string default("") +# population_bonus :decimal(12, 4) default(0.0) +# melange_bonus :decimal(12, 4) default(0.0) +# material_bonus :decimal(12, 4) default(0.0) +# solar_bonus :decimal(12, 4) default(0.0) +# exp_bonus :decimal(12, 4) default(0.0) +# population_cost :decimal(12, 4) default(0.0) +# melange_cost :decimal(12, 4) default(0.0) +# material_cost :decimal(12, 4) default(0.0) +# solar_cost :decimal(12, 4) default(0.0) +# exp_cost :decimal(12, 4) default(0.0) +# created_at :datetime not null +# updated_at :datetime not null +# + +class Building::Population::Town < Building::Population +end diff --git a/app/models/building/research.rb b/app/models/building/research.rb new file mode 100644 index 0000000..25d01ae --- /dev/null +++ b/app/models/building/research.rb @@ -0,0 +1,24 @@ +# == Schema Information +# +# Table name: buildings +# +# id :integer not null, primary key +# type :string +# name :string not null +# description :string default("") +# population_bonus :decimal(12, 4) default(0.0) +# melange_bonus :decimal(12, 4) default(0.0) +# material_bonus :decimal(12, 4) default(0.0) +# solar_bonus :decimal(12, 4) default(0.0) +# exp_bonus :decimal(12, 4) default(0.0) +# population_cost :decimal(12, 4) default(0.0) +# melange_cost :decimal(12, 4) default(0.0) +# material_cost :decimal(12, 4) default(0.0) +# solar_cost :decimal(12, 4) default(0.0) +# exp_cost :decimal(12, 4) default(0.0) +# created_at :datetime not null +# updated_at :datetime not null +# + +class Building::Research < Building +end diff --git a/app/models/building/research/laboratory.rb b/app/models/building/research/laboratory.rb new file mode 100644 index 0000000..b19ab88 --- /dev/null +++ b/app/models/building/research/laboratory.rb @@ -0,0 +1,24 @@ +# == Schema Information +# +# Table name: buildings +# +# id :integer not null, primary key +# type :string +# name :string not null +# description :string default("") +# population_bonus :decimal(12, 4) default(0.0) +# melange_bonus :decimal(12, 4) default(0.0) +# material_bonus :decimal(12, 4) default(0.0) +# solar_bonus :decimal(12, 4) default(0.0) +# exp_bonus :decimal(12, 4) default(0.0) +# population_cost :decimal(12, 4) default(0.0) +# melange_cost :decimal(12, 4) default(0.0) +# material_cost :decimal(12, 4) default(0.0) +# solar_cost :decimal(12, 4) default(0.0) +# exp_cost :decimal(12, 4) default(0.0) +# created_at :datetime not null +# updated_at :datetime not null +# + +class Building::Research::Laboratory < Building::Research +end diff --git a/app/models/building/research/temple_of_science.rb b/app/models/building/research/temple_of_science.rb new file mode 100644 index 0000000..425a787 --- /dev/null +++ b/app/models/building/research/temple_of_science.rb @@ -0,0 +1,24 @@ +# == Schema Information +# +# Table name: buildings +# +# id :integer not null, primary key +# type :string +# name :string not null +# description :string default("") +# population_bonus :decimal(12, 4) default(0.0) +# melange_bonus :decimal(12, 4) default(0.0) +# material_bonus :decimal(12, 4) default(0.0) +# solar_bonus :decimal(12, 4) default(0.0) +# exp_bonus :decimal(12, 4) default(0.0) +# population_cost :decimal(12, 4) default(0.0) +# melange_cost :decimal(12, 4) default(0.0) +# material_cost :decimal(12, 4) default(0.0) +# solar_cost :decimal(12, 4) default(0.0) +# exp_cost :decimal(12, 4) default(0.0) +# created_at :datetime not null +# updated_at :datetime not null +# + +class Building::Research::TempleOfScience < Building::Research +end diff --git a/app/models/building/research/univerzity.rb b/app/models/building/research/univerzity.rb new file mode 100644 index 0000000..3bc6b46 --- /dev/null +++ b/app/models/building/research/univerzity.rb @@ -0,0 +1,24 @@ +# == Schema Information +# +# Table name: buildings +# +# id :integer not null, primary key +# type :string +# name :string not null +# description :string default("") +# population_bonus :decimal(12, 4) default(0.0) +# melange_bonus :decimal(12, 4) default(0.0) +# material_bonus :decimal(12, 4) default(0.0) +# solar_bonus :decimal(12, 4) default(0.0) +# exp_bonus :decimal(12, 4) default(0.0) +# population_cost :decimal(12, 4) default(0.0) +# melange_cost :decimal(12, 4) default(0.0) +# material_cost :decimal(12, 4) default(0.0) +# solar_cost :decimal(12, 4) default(0.0) +# exp_cost :decimal(12, 4) default(0.0) +# created_at :datetime not null +# updated_at :datetime not null +# + +class Building::Research::Univerzity < Building::Research +end diff --git a/app/models/building/solar.rb b/app/models/building/solar.rb new file mode 100644 index 0000000..23c31fe --- /dev/null +++ b/app/models/building/solar.rb @@ -0,0 +1,24 @@ +# == Schema Information +# +# Table name: buildings +# +# id :integer not null, primary key +# type :string +# name :string not null +# description :string default("") +# population_bonus :decimal(12, 4) default(0.0) +# melange_bonus :decimal(12, 4) default(0.0) +# material_bonus :decimal(12, 4) default(0.0) +# solar_bonus :decimal(12, 4) default(0.0) +# exp_bonus :decimal(12, 4) default(0.0) +# population_cost :decimal(12, 4) default(0.0) +# melange_cost :decimal(12, 4) default(0.0) +# material_cost :decimal(12, 4) default(0.0) +# solar_cost :decimal(12, 4) default(0.0) +# exp_cost :decimal(12, 4) default(0.0) +# created_at :datetime not null +# updated_at :datetime not null +# + +class Building::Solar < Building +end diff --git a/app/models/building/solar/bank.rb b/app/models/building/solar/bank.rb new file mode 100644 index 0000000..79f50e0 --- /dev/null +++ b/app/models/building/solar/bank.rb @@ -0,0 +1,24 @@ +# == Schema Information +# +# Table name: buildings +# +# id :integer not null, primary key +# type :string +# name :string not null +# description :string default("") +# population_bonus :decimal(12, 4) default(0.0) +# melange_bonus :decimal(12, 4) default(0.0) +# material_bonus :decimal(12, 4) default(0.0) +# solar_bonus :decimal(12, 4) default(0.0) +# exp_bonus :decimal(12, 4) default(0.0) +# population_cost :decimal(12, 4) default(0.0) +# melange_cost :decimal(12, 4) default(0.0) +# material_cost :decimal(12, 4) default(0.0) +# solar_cost :decimal(12, 4) default(0.0) +# exp_cost :decimal(12, 4) default(0.0) +# created_at :datetime not null +# updated_at :datetime not null +# + +class Building::Solar::Bank < Building::Solar +end diff --git a/app/models/building/solar/market.rb b/app/models/building/solar/market.rb new file mode 100644 index 0000000..f7c7df8 --- /dev/null +++ b/app/models/building/solar/market.rb @@ -0,0 +1,24 @@ +# == Schema Information +# +# Table name: buildings +# +# id :integer not null, primary key +# type :string +# name :string not null +# description :string default("") +# population_bonus :decimal(12, 4) default(0.0) +# melange_bonus :decimal(12, 4) default(0.0) +# material_bonus :decimal(12, 4) default(0.0) +# solar_bonus :decimal(12, 4) default(0.0) +# exp_bonus :decimal(12, 4) default(0.0) +# population_cost :decimal(12, 4) default(0.0) +# melange_cost :decimal(12, 4) default(0.0) +# material_cost :decimal(12, 4) default(0.0) +# solar_cost :decimal(12, 4) default(0.0) +# exp_cost :decimal(12, 4) default(0.0) +# created_at :datetime not null +# updated_at :datetime not null +# + +class Building::Solar::Market < Building::Solar +end diff --git a/app/models/building/solar/stock_exchange.rb b/app/models/building/solar/stock_exchange.rb new file mode 100644 index 0000000..54e631d --- /dev/null +++ b/app/models/building/solar/stock_exchange.rb @@ -0,0 +1,24 @@ +# == Schema Information +# +# Table name: buildings +# +# id :integer not null, primary key +# type :string +# name :string not null +# description :string default("") +# population_bonus :decimal(12, 4) default(0.0) +# melange_bonus :decimal(12, 4) default(0.0) +# material_bonus :decimal(12, 4) default(0.0) +# solar_bonus :decimal(12, 4) default(0.0) +# exp_bonus :decimal(12, 4) default(0.0) +# population_cost :decimal(12, 4) default(0.0) +# melange_cost :decimal(12, 4) default(0.0) +# material_cost :decimal(12, 4) default(0.0) +# solar_cost :decimal(12, 4) default(0.0) +# exp_cost :decimal(12, 4) default(0.0) +# created_at :datetime not null +# updated_at :datetime not null +# + +class Building::Solar::StockExchange < Building::Solar +end diff --git a/app/models/estate.rb b/app/models/estate.rb new file mode 100644 index 0000000..001a0c5 --- /dev/null +++ b/app/models/estate.rb @@ -0,0 +1,16 @@ +# == Schema Information +# +# Table name: estates +# +# id :integer not null, primary key +# building_id :integer +# field_id :integer +# number :integer default(1) +# created_at :datetime not null +# updated_at :datetime not null +# + +class Estate < ApplicationRecord + belongs_to :field + belongs_to :building +end diff --git a/app/models/field.rb b/app/models/field.rb index 07c45ca..d7bc98d 100644 --- a/app/models/field.rb +++ b/app/models/field.rb @@ -17,4 +17,14 @@ class Field < ApplicationRecord belongs_to :user belongs_to :planet + + has_many :estates + has_many :buildings, through: :estates + + after_create :zalozeni + + def zalozeni + + end + end diff --git a/app/models/planet/arrakis.rb b/app/models/planet/arrakis.rb index bec9dc9..7ab9654 100644 --- a/app/models/planet/arrakis.rb +++ b/app/models/planet/arrakis.rb @@ -28,4 +28,10 @@ def self.vytvor fields_count: 1 ) end + + def fields_creation + arr = Field.create(planet_id: self.id, name: 'Arrakis', population: 250000, material: 50000) + Estate.create(field_id: arr.id, building_id: Building::Melange::Arraken.first.id, number: 1) + Estate.create(field_id: arr.id, building_id: Building::Melange::Harvester.first.id, number: 15) + end end diff --git a/app/views/buildings/_building.json.jbuilder b/app/views/buildings/_building.json.jbuilder new file mode 100644 index 0000000..36b7051 --- /dev/null +++ b/app/views/buildings/_building.json.jbuilder @@ -0,0 +1,2 @@ +json.extract! building, :id, :type, :name, :description, :population_bonus, :melange_bonus, :material_bonus, :solar_bonus, :exp_bonus, :population_cost, :melange_cost, :material_cost, :solar_cost, :exp_cost, :created_at, :updated_at +json.url building_url(building, format: :json) \ No newline at end of file diff --git a/app/views/buildings/_form.html.erb b/app/views/buildings/_form.html.erb new file mode 100644 index 0000000..48784a0 --- /dev/null +++ b/app/views/buildings/_form.html.erb @@ -0,0 +1,82 @@ +<%= form_for(building) do |f| %> + <% if building.errors.any? %> +
+

<%= pluralize(building.errors.count, "error") %> prohibited this building from being saved:

+ + +
+ <% end %> + +
+ <%= f.label :type %> + <%= f.text_field :type %> +
+ +
+ <%= f.label :name %> + <%= f.text_field :name %> +
+ +
+ <%= f.label :description %> + <%= f.text_field :description %> +
+ +
+ <%= f.label :population_bonus %> + <%= f.text_field :population_bonus %> +
+ +
+ <%= f.label :melange_bonus %> + <%= f.text_field :melange_bonus %> +
+ +
+ <%= f.label :material_bonus %> + <%= f.text_field :material_bonus %> +
+ +
+ <%= f.label :solar_bonus %> + <%= f.text_field :solar_bonus %> +
+ +
+ <%= f.label :exp_bonus %> + <%= f.text_field :exp_bonus %> +
+ +
+ <%= f.label :population_cost %> + <%= f.text_field :population_cost %> +
+ +
+ <%= f.label :melange_cost %> + <%= f.text_field :melange_cost %> +
+ +
+ <%= f.label :material_cost %> + <%= f.text_field :material_cost %> +
+ +
+ <%= f.label :solar_cost %> + <%= f.text_field :solar_cost %> +
+ +
+ <%= f.label :exp_cost %> + <%= f.text_field :exp_cost %> +
+ +
+ <%= f.submit %> +
+<% end %> diff --git a/app/views/buildings/edit.html.erb b/app/views/buildings/edit.html.erb new file mode 100644 index 0000000..a408ffe --- /dev/null +++ b/app/views/buildings/edit.html.erb @@ -0,0 +1,6 @@ +

Editing Building

+ +<%= render 'form', building: @building %> + +<%= link_to 'Show', @building %> | +<%= link_to 'Back', buildings_path %> diff --git a/app/views/buildings/index.html.erb b/app/views/buildings/index.html.erb new file mode 100644 index 0000000..0b0b5f1 --- /dev/null +++ b/app/views/buildings/index.html.erb @@ -0,0 +1,51 @@ +

<%= notice %>

+ +

Buildings

+ + + + + + + + + + + + + + + + + + + + + + + <% @buildings.each do |building| %> + + + + + + + + + + + + + + + + + + + <% end %> + +
TypeNameDescriptionPopulation bonusMelange bonusMaterial bonusSolar bonusExp bonusPopulation costMelange costMaterial costSolar costExp cost
<%= building.type %><%= building.name %><%= building.description %><%= building.population_bonus %><%= building.melange_bonus %><%= building.material_bonus %><%= building.solar_bonus %><%= building.exp_bonus %><%= building.population_cost %><%= building.melange_cost %><%= building.material_cost %><%= building.solar_cost %><%= building.exp_cost %><%= link_to 'Show', building %><%= link_to 'Edit', edit_building_path(building) %><%= link_to 'Destroy', building, method: :delete, data: { confirm: 'Are you sure?' } %>
+ +
+ +<%= link_to 'New Building', new_building_path %> diff --git a/app/views/buildings/index.json.jbuilder b/app/views/buildings/index.json.jbuilder new file mode 100644 index 0000000..d7914de --- /dev/null +++ b/app/views/buildings/index.json.jbuilder @@ -0,0 +1 @@ +json.array! @buildings, partial: 'buildings/building', as: :building \ No newline at end of file diff --git a/app/views/buildings/new.html.erb b/app/views/buildings/new.html.erb new file mode 100644 index 0000000..f24a833 --- /dev/null +++ b/app/views/buildings/new.html.erb @@ -0,0 +1,5 @@ +

New Building

+ +<%= render 'form', building: @building %> + +<%= link_to 'Back', buildings_path %> diff --git a/app/views/buildings/show.html.erb b/app/views/buildings/show.html.erb new file mode 100644 index 0000000..aecda77 --- /dev/null +++ b/app/views/buildings/show.html.erb @@ -0,0 +1,69 @@ +

<%= notice %>

+ +

+ Type: + <%= @building.type %> +

+ +

+ Name: + <%= @building.name %> +

+ +

+ Description: + <%= @building.description %> +

+ +

+ Population bonus: + <%= @building.population_bonus %> +

+ +

+ Melange bonus: + <%= @building.melange_bonus %> +

+ +

+ Material bonus: + <%= @building.material_bonus %> +

+ +

+ Solar bonus: + <%= @building.solar_bonus %> +

+ +

+ Exp bonus: + <%= @building.exp_bonus %> +

+ +

+ Population cost: + <%= @building.population_cost %> +

+ +

+ Melange cost: + <%= @building.melange_cost %> +

+ +

+ Material cost: + <%= @building.material_cost %> +

+ +

+ Solar cost: + <%= @building.solar_cost %> +

+ +

+ Exp cost: + <%= @building.exp_cost %> +

+ +<%= link_to 'Edit', edit_building_path(@building) %> | +<%= link_to 'Back', buildings_path %> diff --git a/app/views/buildings/show.json.jbuilder b/app/views/buildings/show.json.jbuilder new file mode 100644 index 0000000..d405d68 --- /dev/null +++ b/app/views/buildings/show.json.jbuilder @@ -0,0 +1 @@ +json.partial! "buildings/building", building: @building \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index cee5499..5b03e97 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,4 +1,5 @@ Rails.application.routes.draw do + resources :buildings resources :fields resources :planets resources :houses diff --git a/db/migrate/20160923212548_create_buildings.rb b/db/migrate/20160923212548_create_buildings.rb new file mode 100644 index 0000000..e54307e --- /dev/null +++ b/db/migrate/20160923212548_create_buildings.rb @@ -0,0 +1,21 @@ +class CreateBuildings < ActiveRecord::Migration[5.0] + def change + create_table :buildings do |t| + t.string :type + t.string :name, null: false + t.string :description, default: '' + t.decimal :population_bonus, precision: 12, scale: 4, default: 0.0 + t.decimal :melange_bonus, precision: 12, scale: 4, default: 0.0 + t.decimal :material_bonus, precision: 12, scale: 4, default: 0.0 + t.decimal :solar_bonus, precision: 12, scale: 4, default: 0.0 + t.decimal :exp_bonus, precision: 12, scale: 4, default: 0.0 + t.decimal :population_cost, precision: 12, scale: 4, default: 0.0 + t.decimal :melange_cost, precision: 12, scale: 4, default: 0.0 + t.decimal :material_cost, precision: 12, scale: 4, default: 0.0 + t.decimal :solar_cost, precision: 12, scale: 4, default: 0.0 + t.decimal :exp_cost, precision: 12, scale: 4, default: 0.0 + + t.timestamps + end + end +end diff --git a/db/migrate/20160923212649_create_estates.rb b/db/migrate/20160923212649_create_estates.rb new file mode 100644 index 0000000..30df2bd --- /dev/null +++ b/db/migrate/20160923212649_create_estates.rb @@ -0,0 +1,11 @@ +class CreateEstates < ActiveRecord::Migration[5.0] + def change + create_table :estates do |t| + t.integer :building_id + t.integer :field_id + t.integer :number, default: 1 + + t.timestamps + end + end +end diff --git a/db/schema.rb b/db/schema.rb index 723b11c..4badb20 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,33 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20160913221654) do +ActiveRecord::Schema.define(version: 20160923212649) do + + create_table "buildings", force: :cascade do |t| + t.string "type" + t.string "name", null: false + t.string "description", default: "" + t.decimal "population_bonus", precision: 12, scale: 4, default: "0.0" + t.decimal "melange_bonus", precision: 12, scale: 4, default: "0.0" + t.decimal "material_bonus", precision: 12, scale: 4, default: "0.0" + t.decimal "solar_bonus", precision: 12, scale: 4, default: "0.0" + t.decimal "exp_bonus", precision: 12, scale: 4, default: "0.0" + t.decimal "population_cost", precision: 12, scale: 4, default: "0.0" + t.decimal "melange_cost", precision: 12, scale: 4, default: "0.0" + t.decimal "material_cost", precision: 12, scale: 4, default: "0.0" + t.decimal "solar_cost", precision: 12, scale: 4, default: "0.0" + t.decimal "exp_cost", precision: 12, scale: 4, default: "0.0" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + + create_table "estates", force: :cascade do |t| + t.integer "building_id" + t.integer "field_id" + t.integer "number", default: 1 + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end create_table "fields", force: :cascade do |t| t.string "name" diff --git a/db/seeds.rb b/db/seeds.rb index c0aed5f..d7b732a 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -18,6 +18,24 @@ p 'House done' +Building::Population::Town.create(name: "Město", description: "Města slouží k ubytování vaší populace.", population_bonus: 20.0, melange_bonus: 0.0, material_bonus: 0.0, solar_bonus: 0.0, exp_bonus: 0.0, population_cost: 200.0, melange_cost: 0.0, material_cost: 35.0, solar_cost: 30.0, exp_cost: 0.0) +Building::Population::City.create(name: "Velkoměsto", description: "Velkoměsta slouží k ubytování vaší populace.", population_bonus: 30.0, melange_bonus: 0.0, material_bonus: 0.0, solar_bonus: 0.0, exp_bonus: 0.0, population_cost: 200.0, melange_cost: 0.0, material_cost: 36.0, solar_cost: 32.0, exp_cost: 0.0) +Building::Population::Metropolis.create(name: "Metropole", description: "Metropole slouží k ubytování vaší populace.", population_bonus: 50.0, melange_bonus: 0.0, material_bonus: 0.0, solar_bonus: 5.0, exp_bonus: 0.0, population_cost: 200.0, melange_cost: 1.0, material_cost: 37.0, solar_cost: 33.0, exp_cost: 0.0) +Building::Solar::Market.create(name: "Trh", description: "Trhy slouží k produkci solárů, což je hlavní platidlo v Impériu. ", population_bonus: 0.0, melange_bonus: 0.0, material_bonus: 0.0, solar_bonus: 10.0, exp_bonus: 0.0, population_cost: 200.0, melange_cost: 0.0, material_cost: 25.0, solar_cost: 20.0, exp_cost: 0.0) +Building::Solar::Bank.create(name: "Banka", description: "Banka slouží k produkci solárů, což je hlavní platidlo v Impériu. ", population_bonus: 0.0, melange_bonus: 0.0, material_bonus: 0.0, solar_bonus: 14.0, exp_bonus: 0.0, population_cost: 200.0, melange_cost: 0.0, material_cost: 26.0, solar_cost: 22.0, exp_cost: 0.0) +Building::Solar::StockExchange.create(name: "Burza", description: "Burza slouží k produkci solárů, což je hlavní platidlo v Impériu. ", population_bonus: 0.0, melange_bonus: 0.0, material_bonus: 0.0, solar_bonus: 18.0, exp_bonus: 0.0, population_cost: 200.0, melange_cost: 0.0, material_cost: 27.0, solar_cost: 23.0, exp_cost: 0.0) +Building::Material::Mine.create(name: "Důl", description: "Doly slouží k těžbě vzácných rud, které jsou dále zpracovány na materiál.", population_bonus: 0.0, melange_bonus: 0.0, material_bonus: 10.0, solar_bonus: 0.0, exp_bonus: 0.0, population_cost: 200.0, melange_cost: 0.0, material_cost: 20.0, solar_cost: 21.0, exp_cost: 0.0) +Building::Material::Borehole.create(name: "Vrt", description: "Vrt slouží k těžbě vzácných rud, které jsou dále zpracovány na materiál.", population_bonus: 0.0, melange_bonus: 0.0, material_bonus: 14.0, solar_bonus: 0.0, exp_bonus: 0.0, population_cost: 200.0, melange_cost: 0.0, material_cost: 21.0, solar_cost: 22.0, exp_cost: 0.0) +Building::Material::DeepCore.create(name: "Hlubinná těžba", description: "Hlubinna tezba slouží k těžbě vzácných rud, které jsou dále zpracovány na materiál.", population_bonus: 0.0, melange_bonus: 0.0, material_bonus: 18.0, solar_bonus: 0.0, exp_bonus: 0.0, population_cost: 200.0, melange_cost: 0.0, material_cost: 22.0, solar_cost: 23.0, exp_cost: 0.0) +Building::Research::Laboratory.create(name: "Laboratoř", description: "Laboratoře jsou určeny k produkci zkušeností (expů), ty jsou dále využity pro výzkum technologii.", population_bonus: 0.0, melange_bonus: 0.0, material_bonus: 0.0, solar_bonus: 0.0, exp_bonus: 10.0, population_cost: 200.0, melange_cost: 0.0, material_cost: 40.0, solar_cost: 30.0, exp_cost: 0.0) +Building::Research::Univerzity.create(name: "Univerzita", description: "Univerzity jsou určeny k produkci zkušeností (expů), ty jsou dále využity pro výzkum technologii.", population_bonus: 0.0, melange_bonus: 0.0, material_bonus: 0.0, solar_bonus: 0.0, exp_bonus: 14.0, population_cost: 200.0, melange_cost: 0.0, material_cost: 42.0, solar_cost: 31.0, exp_cost: 0.0) +Building::Research::TempleOfScience.create(name: "Chrám vědy", description: "Chramy vedy jsou určeny k produkci zkušeností (expů), ty jsou dále využity pro výzkum technologii.", population_bonus: 0.0, melange_bonus: 0.0, material_bonus: 0.0, solar_bonus: 0.0, exp_bonus: 18.0, population_cost: 200.0, melange_cost: 0.0, material_cost: 44.0, solar_cost: 32.0, exp_cost: 0.0) + +Building::Melange::Harvester.create(name: "Továrna na koření", description: "Produkuje koreni.", population_bonus: 0.0, melange_bonus: 100.0, material_bonus: 0.0, solar_bonus: 0.0, exp_bonus: 0.0, population_cost: 20.0, melange_cost: 3.0, material_cost: 50.0, solar_cost: 100.0, exp_cost: 0.0) +Building::Melange::Arraken.create(name: "Arraken", description: "Sídelní město, astroport.", population_bonus: 10.0, melange_bonus: 300.0, material_bonus: 0.0, solar_bonus: 0.0, exp_bonus: 0.0, population_cost: 0.0, melange_cost: 0.0, material_cost: 0.0, solar_cost: 0.0, exp_cost: 0.0) + +puts 'budovy done' + System.create(name: 'Aclin Neutra') System.create(name: 'Delphinus') System.create(name: 'Anbus') @@ -334,4 +352,4 @@ Planet.vytvor('Yandin IX', 'Yadin', 9) Planet::Titania.vytvor -p 'Planet done' \ No newline at end of file +p 'Planet done' diff --git a/spec/factories/buildings.rb b/spec/factories/buildings.rb new file mode 100644 index 0000000..1ab0e35 --- /dev/null +++ b/spec/factories/buildings.rb @@ -0,0 +1,39 @@ +# == Schema Information +# +# Table name: buildings +# +# id :integer not null, primary key +# type :string +# name :string not null +# description :string default("") +# population_bonus :decimal(12, 4) default(0.0) +# melange_bonus :decimal(12, 4) default(0.0) +# material_bonus :decimal(12, 4) default(0.0) +# solar_bonus :decimal(12, 4) default(0.0) +# exp_bonus :decimal(12, 4) default(0.0) +# population_cost :decimal(12, 4) default(0.0) +# melange_cost :decimal(12, 4) default(0.0) +# material_cost :decimal(12, 4) default(0.0) +# solar_cost :decimal(12, 4) default(0.0) +# exp_cost :decimal(12, 4) default(0.0) +# created_at :datetime not null +# updated_at :datetime not null +# + +FactoryGirl.define do + factory :building do + type "" + name "MyString" + description "MyString" + population_bonus "9.99" + melange_bonus "9.99" + material_bonus "9.99" + solar_bonus "9.99" + exp_bonus "9.99" + population_cost "9.99" + melange_cost "9.99" + material_cost "9.99" + solar_cost "9.99" + exp_cost "9.99" + end +end diff --git a/spec/factories/estates.rb b/spec/factories/estates.rb new file mode 100644 index 0000000..e2a93e0 --- /dev/null +++ b/spec/factories/estates.rb @@ -0,0 +1,19 @@ +# == Schema Information +# +# Table name: estates +# +# id :integer not null, primary key +# building_id :integer +# field_id :integer +# number :integer default(1) +# created_at :datetime not null +# updated_at :datetime not null +# + +FactoryGirl.define do + factory :estate do + building_id 1 + field_id 1 + number 1 + end +end diff --git a/spec/models/building_spec.rb b/spec/models/building_spec.rb new file mode 100644 index 0000000..ff41d8a --- /dev/null +++ b/spec/models/building_spec.rb @@ -0,0 +1,27 @@ +# == Schema Information +# +# Table name: buildings +# +# id :integer not null, primary key +# type :string +# name :string not null +# description :string default("") +# population_bonus :decimal(12, 4) default(0.0) +# melange_bonus :decimal(12, 4) default(0.0) +# material_bonus :decimal(12, 4) default(0.0) +# solar_bonus :decimal(12, 4) default(0.0) +# exp_bonus :decimal(12, 4) default(0.0) +# population_cost :decimal(12, 4) default(0.0) +# melange_cost :decimal(12, 4) default(0.0) +# material_cost :decimal(12, 4) default(0.0) +# solar_cost :decimal(12, 4) default(0.0) +# exp_cost :decimal(12, 4) default(0.0) +# created_at :datetime not null +# updated_at :datetime not null +# + +require 'rails_helper' + +RSpec.describe Building, type: :model do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/models/estate_spec.rb b/spec/models/estate_spec.rb new file mode 100644 index 0000000..ce3e606 --- /dev/null +++ b/spec/models/estate_spec.rb @@ -0,0 +1,17 @@ +# == Schema Information +# +# Table name: estates +# +# id :integer not null, primary key +# building_id :integer +# field_id :integer +# number :integer default(1) +# created_at :datetime not null +# updated_at :datetime not null +# + +require 'rails_helper' + +RSpec.describe Estate, type: :model do + pending "add some examples to (or delete) #{__FILE__}" +end