jsem / mtg-life-counter

A personalised life counter for mtg
0 stars 0 forks source link

Create player reducer #3

Closed jsem closed 6 years ago

jsem commented 6 years ago

Create the player reducer to handle player state within a game The reducer should hold a map of players where each player is mapped to their player number, i.e. something like: { player1: {

},
player2: {

}
...etc

}

designs are as below: image

state should initialise to a blank json object

actions as shown. CREATE_PLAYER is called when clicking the start game button on the main menu. it should be called once for each player needed to fill the game. the profile to use will be passed through as a json object. this method should add the player to the state in their respective map slot and add a note, something like "Player joined the game with life " (the wording is changeable here) UPDATE_LIFE is called when pressing the plus/minus buttons on the player UI. the amount to adjust the life by will be passed through. this should create a note, something like "Player lost|gained life" UPDATE_POISON same as UPDATE_LIFE but for poison UPDATE_COMMANDER_TAX same as UPDATE_LIFE but for commander tax. NOTE: this is changed from the above design and requires an amount be passed through UPDATE_COMMANDER_DAMAGE same as UPDATE_LIFE but also takes in the ID of the player that caused the damage and should be reflected in the note UPDATE_PLAYER takes in player details modified from the player settings screen and updates the player accordingly. does not necessarily need to create a note, use your own discretion to decide whether its needed or not. NOTE this action has been added since the above design was created

jsem commented 6 years ago

default player profiles probably make sense to be included in a config file