justindwyer6 / rolling-realms

A fan-made, web-based version of Stonemaier Games' roll-and-write game.
https://rolling-realms.netlify.app
18 stars 3 forks source link

Auto-calculate and display star totals #58

Open abrad45 opened 3 years ago

abrad45 commented 3 years ago

Notes from planning call on 11/6:

const ResourceTracker = ({ round, type }) => {
    const { earned, spent } = useGetResourceCounter(round, type);

    if (earned === -1 || spent === -1) {
        return <h2>Error: invalid resource type or round</h2>
    }
}

const getResourceCounter = (state, round, type) =>
    state?.rounds?[round].resources?[type] || { earned: -1, spent: -1 }

// redux state
const state = {
    app: {},
    rounds: [
        {
            resources: {
                pumpkins: {
                    earned: 5,
                    spent: 1,
                },
                hearts: {
                    earned: 7,
                    spent: 0,
                },
                coins: {
                    earned: 2,
                    spent: 2,
                },
            },
            realmData: [
                {
                    type: 'A',
                    metadata: {

                    }
                }
            ]
            stars: {
                realms: [4, 0, 3],
                resources: 1.1,
            }
        },
        {
            resources: {},
            realms: ['A', 'G', '0'],
        },
        {
            resources: {},
            realms: ['A', 'G', '0'],
        }
    ],
}
abrad45 commented 2 years ago

Notes from 1/22 Call:


const stars = [false, false, false, true, false, true];
const addStar = (i = -1) => {
  // if i === -1, mark the leftmost false as true
  // if 0 <= i <= 5, mark that star as true
}

// potential state?
  realmData: [
    {
      type: 1, // [0,9]
      stars: 3, // [0,6] or not... see stars[] above!
      calculate: false,
    },
    {
      type: 4, // [0,9]
      stars: 0, // [0,6]
      calculate: true,
    },
  ],