Skip to content

Commit

Permalink
Set expectedBoardLength
Browse files Browse the repository at this point in the history
  • Loading branch information
dylan-chong committed Oct 5, 2023
1 parent 316a3df commit 6f0f9c3
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/components/HandImporter.vue
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ type HandJSON = {
const INVALID_BOARD_ERROR = `Invalid '.config.board'. Set board cards manually for an example.`;
const CONFIG_INPUT_KEYS = configKeys.filter(k => ['expectedBoardLength'].indexOf(k) === -1);
const config = useConfigStore();
const store = useStore();
Expand All @@ -60,7 +62,7 @@ watch(
const generateImportText = async () => {
const configObj = Object.fromEntries(
Object.entries(config).filter(
([key, _value]) => configKeys.indexOf(key) !== -1
([key, _value]) => CONFIG_INPUT_KEYS.indexOf(key) !== -1
)
);
Expand Down Expand Up @@ -93,7 +95,7 @@ const validateConfigPrimitives = (importConfig: any): Result => {
error: `Expected '.config' to be an object but got ${typeof importConfig}`,
};
for (const key of configKeys.concat(Object.keys(importConfig))) {
for (const key of CONFIG_INPUT_KEYS.concat(Object.keys(importConfig))) {
const newValue = importConfig[key];
const existingValue = (config as any)[key];
console.log({ key, existingValue, newValue })
Expand Down Expand Up @@ -131,6 +133,10 @@ const validateBoard = (board: any): Result => {
}
}
if (board.length > 5) {
return { success: false, error: 'Board cannot have more than 5 cards' };
}
return { success: true };
};
Expand Down Expand Up @@ -177,6 +183,7 @@ const validateImportText = (): Result<{ json?: HandJSON }> => {
}
importJson.config.board = importJson.config.board.map(parseCardString);
importJson.config.expectedBoardLength = importJson.config.board.length;
return { success: true, json: importJson as HandJSON };
};
Expand Down

0 comments on commit 6f0f9c3

Please sign in to comment.