diff --git a/src/newGame/reducer.js b/src/newGame/reducer.js
index 06d29db..a5125b0 100644
--- a/src/newGame/reducer.js
+++ b/src/newGame/reducer.js
@@ -1,31 +1,40 @@
-const initialState = {
- team1: ['Player1.1',
- 'Player1.2',
- 'Player1.3',
- 'Player1.4',
- 'Player1.5',
- 'Player1.6',
- 'Player1.7',
- 'Player1.8',
- 'Player1.9',
- 'Player1.10',
- 'Player1.11'],
- team2: ['Player2.1',
- 'Player2.2',
- 'Player2.3',
- 'Player2.4',
- 'Player2.5',
- 'Player2.6',
- 'Player2.7',
- 'Player2.8',
- 'Player2.9',
- 'Player2.10',
- 'Player2.11'],
- numberOfOvers: 5,
-};
+export const initialState = {
+ team1: {
+ name: "team 1",
+ players: ['Player1.1',
+ 'Player1.2',
+ 'Player1.3',
+ 'Player1.4',
+ 'Player1.5',
+ 'Player1.6',
+ 'Player1.7',
+ 'Player1.8',
+ 'Player1.9',
+ 'Player1.10',
+ 'Player1.11']
+ }
+ ,
+ team2: {
+ name: "team 2",
+ players: ['Player2.1',
+ 'Player2.2',
+ 'Player2.3',
+ 'Player2.4',
+ 'Player2.5',
+ 'Player2.6',
+ 'Player2.7',
+ 'Player2.8',
+ 'Player2.9',
+ 'Player2.10',
+ 'Player2.11'
+ ]
+ },
+ numberOfOvers: 5
+ }
+;
const reducer = (state = initialState, action) => {
- return state;
+ return state;
};
export default reducer;
diff --git a/src/scorer/Scoreboard.jsx b/src/scorer/Scoreboard.jsx
index c40360a..05f2b8c 100644
--- a/src/scorer/Scoreboard.jsx
+++ b/src/scorer/Scoreboard.jsx
@@ -1,36 +1,61 @@
import React from 'react';
-import {Container,Row,Col} from 'reactstrap';
+import {Container, Row, Col} from 'reactstrap';
-const ScoreBoard = () =>
-
-
-
-
+const renderCurrentlyBattingTeamScore = (props) => {
+
+ let team = props.score.currentlyBattingTeamName === props.game.team1.name ? props.score.team1 : props.score.team2;
+
+ return (
+
+ {props.score.currentlyBattingTeamName}
+
+
+
+ {team.score + "/" + team.wickets + " in " + team.overs + "/" + props.game.numberOfOvers}
+
+
)
+}
+
+const renderCurrentlyBowlingTeamScore = (props) => {
+
+ let team;
+ if (props.score.currentlyBattingTeamName === props.game.team1.name) {
+ team = props.score.team2;
+ team.name = props.game.team2.name;
+ }
+ else {
+ team = props.score.team1;
+ team.name = props.game.team1.name;
+ }
+
+ return (
+
+
+ {team.name}
+
+
+ {team.score + "/" + team.wickets + " in " + team.overs + "/" + props.game.numberOfOvers}
+
+
+ );
+}
+
+
+const ScoreBoard = (props) =>
+
+
-
- Team 1
-
-
-
- 120/5 in 12.1/20
-
+
+ {renderCurrentlyBattingTeamScore(props)}
+
-
-
-
-
-
+
-
- Team 2 scored
-
-
- 120/5 in 12.1/20
-
+
+ {renderCurrentlyBowlingTeamScore(props)}
+
-
-
- ;
+
export default ScoreBoard;
\ No newline at end of file
diff --git a/src/scorer/Scorer.jsx b/src/scorer/Scorer.jsx
index 30195ff..2822645 100644
--- a/src/scorer/Scorer.jsx
+++ b/src/scorer/Scorer.jsx
@@ -1,11 +1,20 @@
import React from 'react';
-import ScoreBoard from './Scoreboard';
+import Scoreboard from './Scoreboard';
+import {connect} from 'react-redux';
-const Scorer = () => (
+const Scorer = (props) => (
-
-
+
);
-export default Scorer;
\ No newline at end of file
+
+
+export const mapStateToProps = (state) => {
+ return {
+ score: state.scoreInformation,
+ game:state.gameInformation
+ }
+}
+
+export default connect(mapStateToProps)(Scorer)
\ No newline at end of file
diff --git a/src/scorer/reducer.js b/src/scorer/reducer.js
new file mode 100644
index 0000000..bb6d3ec
--- /dev/null
+++ b/src/scorer/reducer.js
@@ -0,0 +1,22 @@
+import {initialState as gameState} from '../newGame/reducer'
+
+export const initialState = {
+ team1:
+ {
+ wickets: 0,
+ overs: 0,
+ score: 0
+ },
+ team2: {
+ wickets: 0,
+ overs: 0,
+ score: 0
+ },
+ currentlyBattingTeamName: gameState.team1.name
+};
+
+const reducer = (state = initialState, action) => {
+ return state;
+};
+
+export default reducer;
diff --git a/src/scorer/reducer.test.js b/src/scorer/reducer.test.js
new file mode 100644
index 0000000..03a0bff
--- /dev/null
+++ b/src/scorer/reducer.test.js
@@ -0,0 +1,22 @@
+import reducer from './reducer';
+import {initialState as gameState} from "../newGame/reducer";
+
+describe('gameInformation/reducer', () => {
+ it('should return initial state of scores of each team', () => {
+ const initialState = {
+ team1:
+ {
+ wickets: 0,
+ overs: 0,
+ score: 0
+ },
+ team2: {
+ wickets: 0,
+ overs: 0,
+ score: 0
+ },
+ currentlyBattingTeamName: gameState.team1.name
+ };
+ expect(reducer(undefined, {})).toEqual(initialState);
+ });
+});
\ No newline at end of file
diff --git a/src/store/rootReducer.js b/src/store/rootReducer.js
index ecd867e..c54e972 100644
--- a/src/store/rootReducer.js
+++ b/src/store/rootReducer.js
@@ -1,8 +1,10 @@
import { combineReducers } from 'redux';
import gameInformationReducer from '../newGame/reducer';
+import scoreReducer from '../scorer/reducer';
const rootReducer = combineReducers({
gameInformation: gameInformationReducer,
+ scoreInformation: scoreReducer,
});
export default rootReducer;
\ No newline at end of file