From 1554795b3609195a40d437a4db62151ff6811008 Mon Sep 17 00:00:00 2001 From: Mischa Untaga <99098079+MischaU8@users.noreply.github.com> Date: Tue, 19 Mar 2024 17:47:45 +0100 Subject: [PATCH 01/13] Adaptive Tutor WIP --- client/src/game/container.js | 4 + client/src/services/data/concepts.js | 38 +++ client/src/views/game/Game.vue | 5 +- .../views/game/components/menu/HeaderBar.vue | 6 + .../game/components/tutor/AdaptiveTutor.vue | 217 ++++++++++++++++++ 5 files changed, 269 insertions(+), 1 deletion(-) create mode 100644 client/src/services/data/concepts.js create mode 100644 client/src/views/game/components/tutor/AdaptiveTutor.vue diff --git a/client/src/game/container.js b/client/src/game/container.js index 6f258c4c8..d4b2e0f79 100644 --- a/client/src/game/container.js +++ b/client/src/game/container.js @@ -1,6 +1,7 @@ import * as PIXI from 'pixi.js-legacy' import { Viewport } from 'pixi-viewport' import Map from './map' +import eventBus from '../eventBus' import gameHelper from '../services/gameHelper' import textureService from './texture' @@ -133,10 +134,12 @@ class GameContainer { zoomIn () { this.viewport.zoomPercent(0.5, true) + eventBus.$emit('onZoom') } zoomOut () { this.viewport.zoomPercent(-0.3, true) + eventBus.$emit('onZoom') } setupViewport (game) { @@ -260,6 +263,7 @@ class GameContainer { let zoomPercent = this.getViewportZoomPercentage() this.map.refreshZoom(zoomPercent) + eventBus.$emit('onZoom') } setMode (mode, args) { diff --git a/client/src/services/data/concepts.js b/client/src/services/data/concepts.js new file mode 100644 index 000000000..494f96438 --- /dev/null +++ b/client/src/services/data/concepts.js @@ -0,0 +1,38 @@ +import GameHelper from '../gameHelper' +import MENU_STATES from './menuStates' + +export default [ + { + title: "Camera zoom", + text: "Zoom in and out with the MOUSE WHEEL or + and - keys.", + onZoom: function (concept) { + this.markLearned(concept, 10) + } + }, + { + title: "Carriers", + text: "Carriers are used to transport Ships through hyperspace to reach other Stars. They can only be built at Stars and must hold a minimum of 1 Ship.\nCarriers are displayed as small ship icons with a circular coloured halo, much like stars. The number of ships that a carrier has will be displayed when zoomed in.\nClick on the carrier to view it in detail.", + onMenuRequested: function (concept, menuState) { + if (menuState.state === MENU_STATES.CARRIER_DETAIL) { + this.markLearned(concept, 40) + } + } + }, + { + title: "Capital Star", + text: "The Capital Star is your home world. You can recognize as it has 9 points.\nSelect your Capital Star and view its details.", + onMenuRequested: function (concept, menuState) { + if (menuState.state === MENU_STATES.STAR_DETAIL) { + const starId = menuState.args + const star = GameHelper.getStarById(this.$store.state.game, starId) + if (star.homeStar) { + this.markLearned(concept) + } + } + } + }, + { + title: "Bulk Upgrade", + text: "TODO." + }, +] diff --git a/client/src/views/game/Game.vue b/client/src/views/game/Game.vue index d4a460cdc..9d9da0f64 100644 --- a/client/src/views/game/Game.vue +++ b/client/src/views/game/Game.vue @@ -16,6 +16,7 @@ + @@ -28,6 +29,7 @@ import GameContainer from './components/GameContainer.vue' import MENU_STATES from '../../services/data/menuStates' import MainBar from './components/menu/MainBar.vue' import Chat from './components/inbox/Chat.vue' +import AdaptiveTutor from './components/tutor/AdaptiveTutor.vue' import GameApiService from '../../services/api/game' import UserApiService from '../../services/api/user' import GameHelper from '../../services/gameHelper' @@ -42,7 +44,8 @@ export default { 'loading-spinner': LoadingSpinnerVue, 'game-container': GameContainer, 'main-bar': MainBar, - 'chat': Chat + 'adaptive-tutor': AdaptiveTutor, + 'chat': Chat, }, data () { return { diff --git a/client/src/views/game/components/menu/HeaderBar.vue b/client/src/views/game/components/menu/HeaderBar.vue index c1adc84a4..52177dce7 100644 --- a/client/src/views/game/components/menu/HeaderBar.vue +++ b/client/src/views/game/components/menu/HeaderBar.vue @@ -42,6 +42,12 @@ Tutorial + + + diff --git a/client/src/views/game/components/tutor/AdaptiveTutor.vue b/client/src/views/game/components/tutor/AdaptiveTutor.vue new file mode 100644 index 000000000..c07780cf1 --- /dev/null +++ b/client/src/views/game/components/tutor/AdaptiveTutor.vue @@ -0,0 +1,217 @@ + + + + + From ccbd9729e1474a39996dfba509d8bf57853c7aac Mon Sep 17 00:00:00 2001 From: Mischa Untaga <99098079+MischaU8@users.noreply.github.com> Date: Tue, 19 Mar 2024 20:24:37 +0100 Subject: [PATCH 02/13] track concepts used --- client/src/services/data/concepts.js | 35 +++++++++++++++---- client/src/services/learningHelper.js | 19 ++++++++++ .../components/carrier/CombatCalculator.vue | 2 ++ .../views/game/components/menu/HeaderBar.vue | 6 ---- .../star/BulkInfrastructureUpgrade.vue | 3 ++ .../game/components/tutor/AdaptiveTutor.vue | 11 +++++- 6 files changed, 62 insertions(+), 14 deletions(-) create mode 100644 client/src/services/learningHelper.js diff --git a/client/src/services/data/concepts.js b/client/src/services/data/concepts.js index 494f96438..71e089ed2 100644 --- a/client/src/services/data/concepts.js +++ b/client/src/services/data/concepts.js @@ -1,38 +1,59 @@ import GameHelper from '../gameHelper' +import LearningHelper from '../learningHelper' import MENU_STATES from './menuStates' export default [ { + id: LearningHelper.id.CAMERA_ZOOM, title: "Camera zoom", text: "Zoom in and out with the MOUSE WHEEL or + and - keys.", - onZoom: function (concept) { - this.markLearned(concept, 10) + priority: 10, + onZoom: function (self) { + this.markLearned(self, 10) } }, { + id: LearningHelper.id.CARRIERS, title: "Carriers", text: "Carriers are used to transport Ships through hyperspace to reach other Stars. They can only be built at Stars and must hold a minimum of 1 Ship.\nCarriers are displayed as small ship icons with a circular coloured halo, much like stars. The number of ships that a carrier has will be displayed when zoomed in.\nClick on the carrier to view it in detail.", - onMenuRequested: function (concept, menuState) { + priority: 20, + onMenuRequested: function (self, menuState) { if (menuState.state === MENU_STATES.CARRIER_DETAIL) { - this.markLearned(concept, 40) + this.markLearned(self, 40) } } }, { + id: LearningHelper.id.CAPITAL_STAR, title: "Capital Star", text: "The Capital Star is your home world. You can recognize as it has 9 points.\nSelect your Capital Star and view its details.", - onMenuRequested: function (concept, menuState) { + priority: 30, + onMenuRequested: function (self, menuState) { if (menuState.state === MENU_STATES.STAR_DETAIL) { const starId = menuState.args const star = GameHelper.getStarById(this.$store.state.game, starId) if (star.homeStar) { - this.markLearned(concept) + this.markLearned(self) } } } }, { + id: LearningHelper.id.BULK_UPGRADE, title: "Bulk Upgrade", - text: "TODO." + text: "TODO.", + priority: 100, + onConceptUsed: function (self) { + this.markLearned(self) + } + }, + { + id: LearningHelper.id.COMBAT_CALCULATOR, + title: "Combat Calculator", + text: "TODO.", + priority: 100, + onConceptUsed: function (self) { + this.markLearned(self) + } }, ] diff --git a/client/src/services/learningHelper.js b/client/src/services/learningHelper.js new file mode 100644 index 000000000..021f79de7 --- /dev/null +++ b/client/src/services/learningHelper.js @@ -0,0 +1,19 @@ +import eventBus from "../eventBus" + +const CONCEPT_IDS = { + BULK_UPGRADE: 'bulk-upgrade', + CAMERA_ZOOM: 'camera-zoom', + CAPITAL_STAR: 'capital-star', + CARRIERS: 'carriers', + COMBAT_CALCULATOR: 'combat-calculator', +} + +class LearningHelper { + id = CONCEPT_IDS + + conceptUsed(conceptId) { + eventBus.$emit('onConceptUsed', conceptId) + } +} + +export default new LearningHelper() \ No newline at end of file diff --git a/client/src/views/game/components/carrier/CombatCalculator.vue b/client/src/views/game/components/carrier/CombatCalculator.vue index 348d2dd53..732ff1ac0 100644 --- a/client/src/views/game/components/carrier/CombatCalculator.vue +++ b/client/src/views/game/components/carrier/CombatCalculator.vue @@ -100,6 +100,7 @@ import LoadingSpinnerVue from '../../../components/LoadingSpinner' import MenuTitle from '../MenuTitle' import FormErrorList from '../../../components/FormErrorList' import GameHelper from '../../../../services/gameHelper' +import LearningHelper from '../../../../services/learningHelper' import CarrierApiService from '../../../../services/api/carrier' import GameContainer from '../../../../game/container' @@ -232,6 +233,7 @@ export default { console.error(err) } + LearningHelper.conceptUsed(LearningHelper.concept.COMBAT_CALCULATOR) this.isLoading = false } } diff --git a/client/src/views/game/components/menu/HeaderBar.vue b/client/src/views/game/components/menu/HeaderBar.vue index 52177dce7..c1adc84a4 100644 --- a/client/src/views/game/components/menu/HeaderBar.vue +++ b/client/src/views/game/components/menu/HeaderBar.vue @@ -42,12 +42,6 @@ Tutorial - - - diff --git a/client/src/views/game/components/star/BulkInfrastructureUpgrade.vue b/client/src/views/game/components/star/BulkInfrastructureUpgrade.vue index d7389558f..8667353a9 100644 --- a/client/src/views/game/components/star/BulkInfrastructureUpgrade.vue +++ b/client/src/views/game/components/star/BulkInfrastructureUpgrade.vue @@ -119,6 +119,7 @@ import MenuTitle from '../MenuTitle' import FormErrorList from '../../../components/FormErrorList' import starService from '../../../../services/api/star' import GameHelper from '../../../../services/gameHelper' +import LearningHelper from '../../../../services/learningHelper' import AudioService from '../../../../game/audio' import GameContainer from '../../../../game/container' import BulkInfrastructureUpgradeStarTableVue from './BulkInfrastructureUpgradeStarTable' @@ -275,6 +276,7 @@ export default { this.errors = err.response.data.errors || [] } + LearningHelper.conceptUsed(LearningHelper.concept.BULK_UPGRADE) this.hasChecked = false this.isUpgrading = false }, @@ -287,3 +289,4 @@ export default { +../../../../services/data/learningHelper \ No newline at end of file diff --git a/client/src/views/game/components/tutor/AdaptiveTutor.vue b/client/src/views/game/components/tutor/AdaptiveTutor.vue index c07780cf1..05f850722 100644 --- a/client/src/views/game/components/tutor/AdaptiveTutor.vue +++ b/client/src/views/game/components/tutor/AdaptiveTutor.vue @@ -1,5 +1,5 @@