Code Monkey home page Code Monkey logo

resourcecalculator's Introduction

ResourceCalculator.com is a website that can calculate required resources from a list of final requirements, and tell you how to get from the raw resources to the final resources.

Resource Calculation Screenshot

Creating or Updating a Calculator

If you want to add a new resource list to the calculator, you will only need 4 things:
1) The list of resources and what is needed to obtain them (eg: resource_lists/minecraft/resources.yaml)
2) A set of rectangular images of uniform size for each of the resources (eg: resource_lists/minecraft/items/)
3) A 300px by 150px thumbnail of the game you are making a calculator for (eg: resource_lists/minecraft/icon.png)
4) A folder in resource_lists/ for all the files to live in (eg: resource_lists/minecraft)

resources.yaml

The resource list is a yaml file that contains all the recipes for each item in the game. All items will have a "Raw Resource" type to allow users to ignore any materials needed for crafting that resource, and because some resources are base resources that you cannot craft. Though key/value mappings are not inherently ordered, when we build the calculator page, their order is preserved from the yaml file allowing one to order the items coherently.

resources:
  Lithium:
  - output: 1
    recipe_type: Raw Resource
    requirements:
      Lithium: 0

  Small Battery:
  - output: 1
    recipe_type: Backpack Printer
    requirements:
      Lithium: -1
  - output: 1
    recipe_type: Raw Resource
    requirements:
      Small Battery: 0

  Medium Battery:
  - output: 1
    recipe_type: Printer
    requirements:
      Lithium: -2
  - output: 1
    recipe_type: Raw Resource
    requirements:
      Medium Battery: 0

For ease of reading we will always have the key order be output, recipe_type, requirements, and then optionally extra_data where you can store extra information about the item in an unstructured map

items/[itemname].png

For each item in your resources.yaml file you will need to have an image for that resource. If an image is missing, then the build process will submit a warning and fill that space with a purple color, indicating it does not have an icon. The icons can be any size, even rectangular, but they all must be the same size as each other for a given calculator. The file names of each file should be the resource name in all lower case with no spaces or punctuation. For Example:
"Pink Stained Glass Pane" becomes pinkstainedglasspane.png
"Jack 'o Lantern" becomes jackolantern.png

icon.png

The icon needs to be 300px by 150px to fit in with the other calculator links. It also needs to be in the png format, not jpeg.

Compiling The Calculator

On linux, you will need to have python3 installed as well as several python dependencies found in requirements.txt

sudo apt install python3 python3-pip pngquant npm
pip3 install -r requirements.txt
npm install
python3 build.py

On windows you should be able to install the same dependencies via pip and npm though I am unsure how to use pngquant on windows, build.py should work without being able to run the png compression however.

You can also run the calculator locally in Docker by running:

docker build . -t resourcecalculator
docker run -dit --name resourcecalculator -p 8080:80 resourcecalculator

This creates a local docker container that compiles the current working directory, starts the container and exposes it locally at 127.0.0.1:8080. To test changes, stop and delete the container and re-run the two commands.

resourcecalculator's People

Contributors

asherglick avatar mmodrow avatar asherglick2 avatar dependabot[bot] avatar cagomei avatar hyperbeast43 avatar ableuaxolotl avatar cilantroleaver avatar einhecki avatar kroden avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.