-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The application is now using redux toolkit instead of directly using redux/react-redux and other npm package dependencies directly. Actions folder in the redux store is now deleted as RTK will automatically create actions through createSlice
- Loading branch information
1 parent
55d4024
commit 5da4930
Showing
22 changed files
with
199 additions
and
234 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/** | ||
* this gives the ability to use middleware along with the redux dev tools instance to track state | ||
* changes in the app | ||
**/ | ||
|
||
/* app imports */ | ||
import { cardsMiddleware } from "./cards/index.js"; | ||
import { gameStateMiddleware } from "./game-state/index.js"; | ||
|
||
export const rootMiddleware = (getDefaultMiddleware) => { | ||
const appMiddleware = getDefaultMiddleware({ | ||
serializableCheck: { | ||
ignoredActions: ['cards/createFreshCards', 'cards/rollDice'] | ||
} | ||
}).concat(cardsMiddleware, gameStateMiddleware); | ||
|
||
return appMiddleware; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 18 additions & 22 deletions
40
src/app-redux-store/reducers/cards/generate-deck-on-roll.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,29 @@ | ||
/* node module imports */ | ||
import uuid from "react-uuid"; | ||
import produce from "immer"; | ||
|
||
/* app imports */ | ||
import { generateRandomNumbers } from "@appReduxStore/reducers/cards/generate-random-numbers.js"; | ||
import { getCardMap } from "@appReduxStore/reducers/cards/card-map.js"; | ||
|
||
export default function generateDeckOnRoll(state) { | ||
let updatedDeck = produce(state, (draft) => { | ||
const cardMap = getCardMap(); | ||
return Object.keys(draft).reduce((composed, key) => { | ||
let card = draft[key]; | ||
const cardMap = getCardMap(); | ||
return Object.keys(state).reduce((composed, key) => { | ||
let card = state[key]; | ||
|
||
if (card.isLocked) { | ||
composed[key] = card; | ||
} | ||
else { | ||
const randNum = String(generateRandomNumbers(1, 10)); | ||
const key = uuid(); | ||
composed[key] = { | ||
id: key, | ||
isLocked: false, | ||
name: cardMap[randNum].name, | ||
icon: cardMap[randNum].src | ||
}; | ||
} | ||
if (card.isLocked) { | ||
composed[key] = card; | ||
} | ||
else { | ||
const randNum = String(generateRandomNumbers(1, 10)); | ||
const key = uuid(); | ||
composed[key] = { | ||
id: key, | ||
isLocked: false, | ||
name: cardMap[randNum].name, | ||
icon: cardMap[randNum].src | ||
}; | ||
} | ||
|
||
return composed; | ||
}, {}); | ||
}); | ||
return updatedDeck; | ||
return composed; | ||
}, {}); | ||
} |
Oops, something went wrong.