Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit b41ca19

Browse files
committed
Enable React Tour after first time login
- Update new map assets - Fix matchview win/loss logic
1 parent 93b0249 commit b41ca19

File tree

13 files changed

+46
-22
lines changed

13 files changed

+46
-22
lines changed

src/app/components/MatchView/MatchElement.tsx

+1-7
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,7 @@ export class MatchElement extends React.Component<
1111
MatchInterfaces.ElementProps,
1212
MatchInterfaces.ElementState
1313
> {
14-
public MAP_THUMBNAIL = [
15-
'islesofcodechar',
16-
'timeturner',
17-
'treacherousmangroves',
18-
'mysterymap',
19-
'mysterymap',
20-
];
14+
public MAP_THUMBNAIL = ['sands_of_time', 'sector', 'revival', 'mysterymap', 'mysterymap'];
2115

2216
public MAP_NAME = [
2317
'Isles of Codecharacter',

src/app/components/SocketHandler.tsx

+6-3
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ export class SocketHandler extends React.Component<SocketHandlerInterfaces.Props
1414
{},
1515
// @ts-ignore
1616
(frame) => {
17-
const { userId, success } = this.props;
18-
success('Connected to Server.');
17+
const { userId } = this.props;
1918
// @ts-ignore
2019
this.stompClient.subscribe(
2120
`/socket/response/alert/${userId}`,
@@ -30,7 +29,11 @@ export class SocketHandler extends React.Component<SocketHandlerInterfaces.Props
3029
(message: { body: string }) => {
3130
if (message.body[0] === 'E') {
3231
this.props.error('Match not executed successfully');
33-
this.props.updateGameLog(message.body, message.body, '');
32+
// @ts-ignore
33+
this.props.clearAllLogs();
34+
this.props.clearDisplayDebugLog();
35+
this.props.updateDisplayDebugLog(message.body);
36+
// this.props.updateGameLog(Buffer.from(message.body), '', '');
3437
return;
3538
}
3639

src/app/containers/SocketHandler.ts

+12
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,18 @@ const mapDispatchToProps = (dispatch: Dispatch) => {
2323
sendExecuteSuccess: (logs: string) => dispatch(SubmissionActions.handleExecuteSuccess(logs)),
2424
sendInfo: (message: string) => dispatch(NotificationActions.info(message)),
2525
sendSuccess: (message: string) => dispatch(NotificationActions.success(message)),
26+
success: (message: string) => dispatch(NotificationActions.success(message)),
27+
updateDisplayDebugLog: (log: string) => dispatch(GameLogActions.updateDisplayDebugLog(log)),
28+
updateGameLog: (player1DebugLog: string, player2DebugLog: string, gameLog: string) =>
29+
dispatch(GameLogActions.updateGameLog(player1DebugLog, player2DebugLog, gameLog)),
30+
updateGlobalAnnouncements: (announcements: NotificationInterfaces.Announcement[]) =>
31+
dispatch(NotificationActions.updateGlobalAnnouncements(announcements)),
32+
updateGlobalNotifications: (notifications: NotificationInterfaces.Notification[]) =>
33+
dispatch(NotificationActions.updateGlobalNotifications(notifications)),
34+
updateMatchPlayerId: (matchPlayerId: number) =>
35+
dispatch(GameLogActions.updateMatchPlayerId(matchPlayerId)),
36+
updateRequest: (request: SubmissionInterfaces.Request) =>
37+
dispatch(SubmissionActions.changeCurrentRequest(request)),
2638
};
2739
};
2840

src/app/reducers/Dashboard.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ export enum SidePanelTab {
1212
}
1313

1414
const dashboardStoreIntialState: DashboardInterfaces.DashboardStoreState = {
15-
isWelcomeModalOpen: false,
15+
isReactTourActive: true,
16+
isWelcomeModalOpen: true,
1617
sidePanelTab: SidePanelTab.NONE,
1718
};
1819

src/app/sagas/MatchView.ts

+4-3
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ export function* getMatches(action: ActionType<typeof MatchActions.getMatches>)
1717
if (isAuthenticated === false) return;
1818

1919
if (isArray(res)) {
20-
const matchData = mapMatchResponse(res);
20+
const username = yield select((state: RootState) => state.user.username);
21+
const matchData = mapMatchResponse(res, username);
2122
yield put(MatchActions.updateMatches(matchData));
2223
} else yield put(NotificationActions.error(res.message));
2324
} catch (err) {
@@ -39,8 +40,8 @@ export function* getTopMatches(action: ActionType<typeof MatchActions.getTopMatc
3940
if (isAuthenticated === false) return;
4041

4142
if (isArray(res)) {
42-
const matchData = mapMatchResponse(res);
43-
43+
const username = yield select((state: RootState) => state.user.username);
44+
const matchData = mapMatchResponse(res, username);
4445
yield put(MatchActions.updateTopMatches(matchData));
4546
} else yield put(NotificationActions.error(res.message));
4647
} catch (err) {

src/app/sagas/utils/index.ts

+19-7
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ export function* checkAccountActivated(result: ResponseStructure) {
3636

3737
export const mapMatchResponse = (
3838
res: MatchVewInterfaces.RecievedMatch[],
39+
username: string,
3940
): MatchVewInterfaces.Match[] => {
4041
return res.map((match: MatchVewInterfaces.RecievedMatch) => {
4142
return {
@@ -45,7 +46,7 @@ export const mapMatchResponse = (
4546
return {
4647
id: game.id,
4748
mapId: game.mapId,
48-
verdict: getVerdict(game.verdict),
49+
verdict: getVerdict(game.verdict, username, match.username1, match.username2),
4950
winType: 'string',
5051
};
5152
}),
@@ -55,7 +56,7 @@ export const mapMatchResponse = (
5556
score2: match.score2,
5657
username1: match.username1,
5758
username2: match.username2,
58-
verdict: getVerdict(match.verdict),
59+
verdict: getVerdict(match.verdict, username, match.username1, match.username2),
5960
};
6061
});
6162
};
@@ -68,16 +69,27 @@ export enum VERDICT {
6869

6970
export enum MAP_VERDICT_TO_STRING {
7071
TIE = '0',
71-
PLAYER1 = '1',
72-
PLAYER2 = '2',
72+
WIN = '1',
73+
LOSE = '2',
7374
}
7475

75-
const getVerdict = (verdict: string) => {
76+
const getVerdict = (
77+
verdict: string,
78+
loggedInUsername: string,
79+
player1: string,
80+
player2: string,
81+
) => {
7682
switch (verdict) {
7783
case VERDICT.PLAYER1:
78-
return MAP_VERDICT_TO_STRING.PLAYER1;
84+
if (loggedInUsername === player1) {
85+
return MAP_VERDICT_TO_STRING.WIN;
86+
}
87+
return MAP_VERDICT_TO_STRING.LOSE;
7988
case VERDICT.PLAYER2:
80-
return MAP_VERDICT_TO_STRING.PLAYER2;
89+
if (loggedInUsername === player2) {
90+
return MAP_VERDICT_TO_STRING.WIN;
91+
}
92+
return MAP_VERDICT_TO_STRING.LOSE;
8193
case VERDICT.TIE:
8294
return MAP_VERDICT_TO_STRING.TIE;
8395
default:

src/app/types/SocketHandler.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ export interface DispatchProps {
88
sendError: (message: string) => void;
99
sendInfo: (message: string) => void;
1010
sendSuccess: (message: string) => void;
11-
updateRequest: (request: SubmissionInterfaces.Request) => void;
11+
success: (message: string) => void;
12+
updateDisplayDebugLog: (log: string) => void;
1213
updateGameLog: (player1DebugLog: string, player2DebugLog: string, gameLog: string) => void;
1314
updateMatchPlayerId: (matchPlayerId: number) => void;
1415
clearDisplayDebugLog: () => void;
-2.79 KB
Binary file not shown.

src/assets/img/maps/revival.png

2.3 KB
Loading

src/assets/img/maps/sands_of_time.png

2.13 KB
Loading

src/assets/img/maps/sector.png

2.1 KB
Loading

src/assets/img/maps/timeturner.png

-12.7 KB
Binary file not shown.
-2.16 KB
Binary file not shown.

0 commit comments

Comments
 (0)