Skip to content

CP3108: Game Component #1058

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 45 commits into from
May 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
7b1faa3
Refactor constants (#2)
wltan Feb 18, 2020
45322d0
Setup game state fetcher
wltan Feb 25, 2020
87b57d3
Refactor save and load data
wltan Mar 3, 2020
42fcf7b
Create game testing page
Asthenosphere Mar 5, 2020
84926a2
Create telescope/night filter
Asthenosphere Mar 5, 2020
c50f391
Add test for Game Dev link
Asthenosphere Mar 20, 2020
670786f
Add override functions
wltan Mar 5, 2020
3c29996
Retrieve data from backend
wltan Mar 27, 2020
dd3932a
Add more tests for game-dev page and material page
Asthenosphere Mar 30, 2020
54826dc
Deleted unnecessary page
athuyaoo Apr 1, 2020
edb6be7
To use test bucket
athuyaoo Apr 1, 2020
faf82ae
Changed test page to automatically find folder
athuyaoo Apr 1, 2020
bdd2fb9
Prettified and Updated Snapshots
athuyaoo Apr 1, 2020
0a91e9f
Change the story retrieval workflow
wltan Apr 2, 2020
841f602
Fixed location of stories
athuyaoo Apr 6, 2020
fbe3460
Json Upload
Asthenosphere Apr 10, 2020
e06bcba
Modify test for StoryTable
Asthenosphere Apr 10, 2020
f9f7d16
Read input JSON file and set override
wltan Apr 10, 2020
e53e689
Enable the JSON file to simulate customized mission pointer and curre…
wltan Apr 10, 2020
586999c
Fixed bug where tests on PixiJS will fail due to canvas error
athuyaoo Apr 15, 2020
fd88f3f
Fully moved completed-quests and collectibles away from localStorage.
athuyaoo Apr 15, 2020
9aa15e0
Save Manager now saves story action sequence and start location to lo…
athuyaoo Apr 15, 2020
6a3e61d
Added new actions and changed state for the addition of game state.
athuyaoo Apr 15, 2020
12f5c98
Updated game and gamedev components to accomodate the addition of gam…
athuyaoo Apr 15, 2020
edcd243
Deleted non-essential mission pointer override
athuyaoo Apr 21, 2020
d023ede
Fixed Typo 'hasColletible'.
athuyaoo Apr 21, 2020
3c5579b
Merged GroundControl with gameStateUpdate
athuyaoo Apr 21, 2020
a46a333
Using SessionStorage for Game State instead of JS
athuyaoo Apr 21, 2020
6ae6dd2
Minor Cosmetic Changes
athuyaoo Apr 21, 2020
5724722
GamePage to load only when all information is gotten
athuyaoo Apr 21, 2020
18b96fd
Fixed some errors and allow for reset json files
athuyaoo Apr 21, 2020
b049f64
Updated Game Components to use GroundControl
athuyaoo Apr 21, 2020
f1c891e
Updated Material Table Snapshots
athuyaoo Apr 21, 2020
4697453
Minor bugfixes and documentation
athuyaoo May 8, 2020
ae15dc1
Point hosts back to default
athuyaoo May 8, 2020
9cbfff1
Removed console.log function
athuyaoo May 8, 2020
34e9b2a
Merge branch 'sa_2021' into sa_2021
athuyaoo May 8, 2020
b0e4015
Merge branch 'sa_2021' of https://github.com/source-academy/cadet-fro…
jetkan-yk May 12, 2020
0911f0d
Merge branch 'sa_2021' into sa_2021
jetkan-yk May 19, 2020
33127da
Merge branch 'sa_2021' into sa_2021
jetkan-yk May 20, 2020
97620fa
Merge branch 'sa_2021' into sa_2021
jetkan-yk May 20, 2020
04bca45
Merge branch 'sa_2021' into sa_2021
jetkan-yk May 20, 2020
123ef6f
Fix bugs in backend.ts
jetkan-yk May 20, 2020
6dfd85d
Prettify code
jetkan-yk May 20, 2020
77e31c5
Fix bugs in backend.ts
jetkan-yk May 20, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
REACT_APP_LUMINUS_CLIENT_ID=your_luminus_client_id_here
REACT_APP_LUMINUS_CLIENT_ID=nus_apps
REACT_APP_VERSION=$npm_package_version
REACT_APP_BACKEND_URL=http://localhost:4001
REACT_APP_USE_BACKEND=TRUE
REACT_APP_CHATKIT_INSTANCE_LOCATOR=instance_locator_here_otherwise_empty_string

MODULE_BACKEND_URL=http://ec2-54-169-81-133.ap-southeast-1.compute.amazonaws.com
MODULE_BACKEND_URL=http://ec2-54-169-81-133.ap-southeast-1.compute.amazonaws.com
554 changes: 512 additions & 42 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
}
},
"dependencies": {
"@blueprintjs/datetime": "^3.15.2",
"@pusher/chatkit-client": "^1.5.0",
"ace-builds": "^1.4.8",
"acorn": "^5.7.4",
Expand Down Expand Up @@ -122,6 +123,7 @@
"enzyme": "^3.11.0",
"enzyme-adapter-react-16": "^1.14.0",
"husky": "^1.3.1",
"jest-canvas-mock": "^2.2.0",
"local-cors-proxy": "^1.0.2",
"prettier": "^1.18.2",
"react-scripts-ts": "^2.16.0",
Expand Down
57 changes: 57 additions & 0 deletions src/actions/__tests__/groundControl.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import * as actionTypes from '../actionTypes';
import {
changeDateAssessment,
deleteAssessment,
publishAssessment,
uploadAssessment
} from '../groundControl';

test('changeDateAssessment generates correct action object', () => {
const id = 10;
const openAt = '2020-01-01T00:00:00.000Z';
const closeAt = '2021-01-01T00:00:00.000Z';
const action = changeDateAssessment(id, openAt, closeAt);
expect(action).toEqual({
type: actionTypes.CHANGE_DATE_ASSESSMENT,
payload: {
id,
openAt,
closeAt
}
});
});

test('deleteAssessment generates correct action object', () => {
const id = 12;
const action = deleteAssessment(id);
expect(action).toEqual({
type: actionTypes.DELETE_ASSESSMENT,
payload: id
});
});

test('publishAssessment generates correct action object', () => {
const id = 54;
const togglePublishTo = false;
const action = publishAssessment(togglePublishTo, id);
expect(action).toEqual({
type: actionTypes.PUBLISH_ASSESSMENT,
payload: {
togglePublishTo,
id
}
});
});

test(' generates correct action object', () => {
const file = new File([''], 'testFile');
const forceUpdate = true;
const action = uploadAssessment(file, forceUpdate);
expect(action).toEqual({
type: actionTypes.UPLOAD_ASSESSMENT,
payload: {
file,
forceUpdate
}
});
});
5 changes: 3 additions & 2 deletions src/actions/__tests__/session.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Grading, GradingOverview } from '../../components/academy/grading/gradingShape';
import { IAssessment, IAssessmentOverview } from '../../components/assessment/assessmentShape';
import { Notification } from '../../components/notification/notificationShape';
import { Role, Story } from '../../reducers/states';
import { GameState, Role, Story } from '../../reducers/states';
import * as actionTypes from '../actionTypes';
import {
acknowledgeNotifications,
Expand Down Expand Up @@ -156,7 +156,8 @@ test('setUser generates correct action object', () => {
role: 'student' as Role,
group: '42D',
grade: 150,
story: {} as Story
story: {} as Story,
gameState: {} as GameState
};
const action = setUser(user);
expect(action).toEqual({
Expand Down
12 changes: 11 additions & 1 deletion src/actions/actionTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,17 @@ export const ACKNOWLEDGE_NOTIFICATIONS = 'ACKNOWLEDGE_NOTIFICATIONS';
export const UPDATE_NOTIFICATIONS = 'UPDATE_NOTIFICATIONS';
export const NOTIFY_CHATKIT_USERS = 'NOTIFY_CHATKIT_USERS';

/** Dashboard */
/** GAMEDEV */
export const FETCH_TEST_STORIES = 'FETCH_TEST_STORIES';
export const SAVE_USER_STATE = 'SAVE_USER_STATE';
export const SET_GAME_STATE = 'SET_GAME_STATE';

/** GroundControl */
export const CHANGE_DATE_ASSESSMENT = 'CHANGE_DATE_ASSESSMENT';
export const DELETE_ASSESSMENT = 'DELETE_ASSESSMENT';
export const PUBLISH_ASSESSMENT = 'PUBLISH_ASSESSMENT';
export const UPLOAD_ASSESSMENT = 'UPLOAD_ASSESSMENT';

/** Dashboard */
export const FETCH_GROUP_OVERVIEWS = 'FETCH_GROUP_OVERVIEWS';
export const UPDATE_GROUP_OVERVIEWS = 'UPDATE_GROUP_OVERVIEWS';
5 changes: 4 additions & 1 deletion src/actions/game.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import { GameState } from 'src/reducers/states';
import { action } from 'typesafe-actions';

import * as actionTypes from './actionTypes';

export const fetchTestStories = () => action(actionTypes.FETCH_TEST_STORIES);
export const saveCanvas = (canvas: HTMLCanvasElement) => action(actionTypes.SAVE_CANVAS, canvas);
export const saveUserData = (gameState: GameState) =>
action(actionTypes.SAVE_USER_STATE, gameState);
14 changes: 14 additions & 0 deletions src/actions/groundControl.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { action } from 'typesafe-actions';

import * as actionTypes from './actionTypes';

export const changeDateAssessment = (id: number, openAt: string, closeAt: string) =>
action(actionTypes.CHANGE_DATE_ASSESSMENT, { id, openAt, closeAt });

export const deleteAssessment = (id: number) => action(actionTypes.DELETE_ASSESSMENT, id);

export const publishAssessment = (togglePublishTo: boolean, id: number) =>
action(actionTypes.PUBLISH_ASSESSMENT, { id, togglePublishTo });

export const uploadAssessment = (file: File, forceUpdate: boolean) =>
action(actionTypes.UPLOAD_ASSESSMENT, { file, forceUpdate });
1 change: 1 addition & 0 deletions src/actions/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ export * from './collabEditing';
export * from './commons';
export * from './dashboard';
export * from './game';
export * from './groundControl';
export * from './interpreter';
export * from './material';
export * from './playground';
Expand Down
7 changes: 5 additions & 2 deletions src/actions/session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
Notification,
NotificationFilterFunction
} from '../components/notification/notificationShape';
import { Story } from '../reducers/states';
import { GameState, Story } from '../reducers/states';
import * as actionTypes from './actionTypes';

import { Role } from '../reducers/states';
Expand All @@ -31,6 +31,8 @@ export const fetchGradingOverviews = (filterToGroup = true) =>

export const login = () => action(actionTypes.LOGIN);

export const setGameState = (gameState: GameState) => action(actionTypes.SET_GAME_STATE, gameState);

export const setTokens = ({
accessToken,
refreshToken
Expand All @@ -48,7 +50,8 @@ export const setUser = (user: {
role: Role;
group: string | null;
grade: number;
story: Story;
story?: Story;
gameState?: GameState;
}) => action(actionTypes.SET_USER, user);

export const submitAnswer = (id: number, answer: string | number) =>
Expand Down
Empty file modified src/components/Playground.tsx
100755 → 100644
Empty file.
18 changes: 18 additions & 0 deletions src/components/academy/NavigationBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,15 @@ const NavigationBar: React.SFC<OwnProps> = props => (
<NavbarGroup align={Alignment.RIGHT}>
<DefaultChapter />

<NavLink
to={'/academy/groundcontrol'}
activeClassName={Classes.ACTIVE}
className={classNames('NavigationBar__link', Classes.BUTTON, Classes.MINIMAL)}
>
<Icon icon="satellite" />
<div className="navbar-button-text hidden-xs">Ground Control</div>
</NavLink>

<NavLink
to={'/academy/dashboard'}
activeClassName={Classes.ACTIVE}
Expand Down Expand Up @@ -124,6 +133,15 @@ const NavigationBar: React.SFC<OwnProps> = props => (
disableHover={true}
/>
</NavLink>

<NavLink
to={'/academy/gamedev'}
activeClassName={Classes.ACTIVE}
className={classNames('NavigationBar__link', Classes.BUTTON, Classes.MINIMAL)}
>
<Icon icon={IconNames.CROWN} />
<div className="navbar-button-text hidden-xs">Game Dev</div>
</NavLink>
</NavbarGroup>
) : null}
</Navbar>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,12 @@ exports[`Grading NavLink renders for Role.Admin 1`] = `
</Blueprint3.NavbarGroup>
<Blueprint3.NavbarGroup align=\\"right\\">
<withRouter(Connect(DefaultChapter)) />
<NavLink to=\\"/academy/groundcontrol\\" activeClassName=\\"bp3-active\\" className=\\"NavigationBar__link bp3-button bp3-minimal\\" aria-current=\\"page\\">
<Blueprint3.Icon icon=\\"satellite\\" />
<div className=\\"navbar-button-text hidden-xs\\">
Ground Control
</div>
</NavLink>
<NavLink to=\\"/academy/dashboard\\" activeClassName=\\"bp3-active\\" className=\\"NavigationBar__link bp3-button bp3-minimal\\" aria-current=\\"page\\">
<Blueprint3.Icon icon=\\"globe\\" />
<div className=\\"navbar-button-text hidden-xs\\">
Expand All @@ -106,6 +112,12 @@ exports[`Grading NavLink renders for Role.Admin 1`] = `
</div>
<Connect(NotificationBadge) notificationFilter={[Function]} disableHover={true} />
</NavLink>
<NavLink to=\\"/academy/gamedev\\" activeClassName=\\"bp3-active\\" className=\\"NavigationBar__link bp3-button bp3-minimal\\" aria-current=\\"page\\">
<Blueprint3.Icon icon=\\"crown\\" />
<div className=\\"navbar-button-text hidden-xs\\">
Game Dev
</div>
</NavLink>
</Blueprint3.NavbarGroup>
</Blueprint3.Navbar>"
`;
Expand Down Expand Up @@ -150,6 +162,12 @@ exports[`Grading NavLink renders for Role.Staff 1`] = `
</Blueprint3.NavbarGroup>
<Blueprint3.NavbarGroup align=\\"right\\">
<withRouter(Connect(DefaultChapter)) />
<NavLink to=\\"/academy/groundcontrol\\" activeClassName=\\"bp3-active\\" className=\\"NavigationBar__link bp3-button bp3-minimal\\" aria-current=\\"page\\">
<Blueprint3.Icon icon=\\"satellite\\" />
<div className=\\"navbar-button-text hidden-xs\\">
Ground Control
</div>
</NavLink>
<NavLink to=\\"/academy/dashboard\\" activeClassName=\\"bp3-active\\" className=\\"NavigationBar__link bp3-button bp3-minimal\\" aria-current=\\"page\\">
<Blueprint3.Icon icon=\\"globe\\" />
<div className=\\"navbar-button-text hidden-xs\\">
Expand All @@ -175,6 +193,12 @@ exports[`Grading NavLink renders for Role.Staff 1`] = `
</div>
<Connect(NotificationBadge) notificationFilter={[Function]} disableHover={true} />
</NavLink>
<NavLink to=\\"/academy/gamedev\\" activeClassName=\\"bp3-active\\" className=\\"NavigationBar__link bp3-button bp3-minimal\\" aria-current=\\"page\\">
<Blueprint3.Icon icon=\\"crown\\" />
<div className=\\"navbar-button-text hidden-xs\\">
Game Dev
</div>
</NavLink>
</Blueprint3.NavbarGroup>
</Blueprint3.Navbar>"
`;
Loading