Skip to content
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

Adding game's store logic in JS #44

Closed
wants to merge 12 commits into from
4 changes: 4 additions & 0 deletions src/gameObjects/map_arcade/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import { storeMainAreaInteraction } from '../map_city/enterStoreMainArea.interaction';
import { enterMapCityInteraction } from './enterMapCity.interactions';
const gameObjects = [
// Add more game objects here
storeMainAreaInteraction,
interactionWithArcadeArea
];

export const addGameObjects = (k, map, spawnpoints) => {
Expand Down
11 changes: 4 additions & 7 deletions src/interactions/map_arcade/index.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
import { storeMainAreaInteraction } from '../map_city/enterStoreMainArea.interaction';
import { enterMapCityInteraction } from './enterMapCity.interactions';
import { interactionWithGameMachine2 } from './game_machine_2.interactions';
import { interactionWithGameMachine4 } from './game_machine_4.interactions';
import { interactionWithGameMachine6 } from './game_machine_6.interactions';

const interactions = [
enterMapCityInteraction,
// Add more interactions here

// new interaction
storeMainAreaInteraction,
interactionWithArcadeArea,
interactionWithGameMachine2,
interactionWithGameMachine4,
interactionWithGameMachine6,
interactionWithGameMachine6
];

export const attachInteractions = (gameObj, k) => {
Expand Down
7 changes: 0 additions & 7 deletions src/interactions/map_city/enterMapArcade.interactions.js

This file was deleted.

41 changes: 41 additions & 0 deletions src/interactions/map_city/enterStoreMainArea.interaction.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import { displayDialogue } from '../../utils';
import { sampleStoreInteraction, sampleArcadeInteraction } from './enterMapArcade.interactions';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

move your code from enterMapArcade.interactions to this file because of my comment to revert the enterMapArcade.interactions.js file


//player interaction logic with arcade
function sampleArcadeInteraction() {
// sample of coins balance
var coinBal = 1000;

return 'You have ${coinBal} coins to spend';

};

//player interaction logic with store
export const sampleStoreInteraction = () => {
// sample of coins balance
var coinBal = 1000;

return 'You have ${coinBal} coins to spend';

};

//shows what happens when player is in arcade
export const storeMainAreaInteraction = (player, k, map) => {
//if user runs into the arcade, show them the balance
player.onCollide('enter_map_arcade', () => {
player.isInDialog = true;
displayDialogue(sampleStoreInteraction(), () => {
player.isInDialog = false;
});


});
};

player.onCollide('tiny_house_top_left_door', () => {
player.isInDialog = true;
displayDialogue(sampleTinyHouseInteraction(), () => { //sampleTinyHouseInteraction needs building
player.isInDialog = false;
});

});
12 changes: 5 additions & 7 deletions src/interactions/map_start/index.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import { interactionWithBruno } from './bruno.interaction';
import { enterMapCityLeftInteraction } from './enterMapCityLeft.interaction';
import { enterMapCityRightInteraction } from './enterMapCityRight.interactions';
import { enterMapCityInteraction } from './enterMapCity.interaction';
import { interactionWithMainboxMainArea } from './mailboxMainArea.interaction';
import { restroomInteractions } from './restroom.interactions';
import { interactionWithComputer } from './computer.interaction';
import { interactionWithJokeTeller } from './jokeTeller.interaction';
import { interactionWithDrinksMachine } from './drink_machine.interaction';

import { interactionWithMisterFu } from './misterFu.interaction';
import { interactionWithTV } from './tv_main_room.interaction';
import { interactionWithCake } from './cake.interaction';
Expand All @@ -15,17 +13,17 @@ import { interactionWithLocker } from './locker.interaction';
const interactions = [
restroomInteractions,
interactionWithBruno,
enterMapCityLeftInteraction,
enterMapCityRightInteraction,
enterMapCityInteraction,
interactionWithMainboxMainArea,
interactionWithComputer,
// Add more interactions here
interactionWithStoreMainArea,
interactionWithJokeTeller,
interactionWithDrinksMachine,
// Add more interactions here
interactionWithMisterFu,
interactionWithTV,
interactionWithCake,
interactionWithLocker,
interactionWithLocker
];

export const attachInteractions = (gameObj, k) => {
Expand Down
Loading