Skip to content

Commit

Permalink
#4 state object to store buttons and message
Browse files Browse the repository at this point in the history
  • Loading branch information
vmolero committed Mar 15, 2018
1 parent 7d9b331 commit 347fd65
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/components/BoardComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ export interface JsonStateInterface {
handNumber: number;
playerScore: number;
houseScore: number;
btnDealerClass: string;
btnHitClass: string;
btnStandClass: string;
message: string;
}

export class BoardComponent extends React.Component<BoardPropsInterface, BoardStateInterface> {
Expand All @@ -47,10 +51,10 @@ export class BoardComponent extends React.Component<BoardPropsInterface, BoardSt
handNumber: stateObject.handNumber,
playerScore: stateObject.playerScore,
houseScore: stateObject.houseScore,
btnDealerClass: '',
btnHitClass: 'invisible',
btnStandClass: 'invisible',
message: 'Welcome to vmolero\'s BlackJack Game. Press \'Deal!\' to start playing.'
btnDealerClass: stateObject.btnDealerClass,
btnHitClass: stateObject.btnHitClass,
btnStandClass: stateObject.btnStandClass,
message: stateObject.message
};

return state;
Expand Down
8 changes: 8 additions & 0 deletions src/components/SimpleBlackJack.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ class SimpleBlackJack extends React.Component<SimpleBlackJackPropsInterface> {
handNumber: 0,
playerScore: 0,
houseScore: 0,
btnDealerClass: '',
btnHitClass: 'invisible',
btnStandClass: 'invisible',
message: 'Welcome to vmolero\'s BlackJack Game. Press \'Deal!\' to start playing.'
};
}

Expand All @@ -37,6 +41,10 @@ class SimpleBlackJack extends React.Component<SimpleBlackJackPropsInterface> {
handNumber: state.handNumber,
playerScore: state.playerScore,
houseScore: state.houseScore,
btnDealerClass: state.btnDealerClass,
btnHitClass: state.btnHitClass,
btnStandClass: state.btnStandClass,
message: state.message
};
this.setItem(this.KEY, JSON.stringify(jsonSate));
}
Expand Down

0 comments on commit 347fd65

Please sign in to comment.