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

Add start mission button #96

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

tepel-chen
Copy link

Resolves #91

@tepel-chen tepel-chen force-pushed the feature/start-mission branch from 093dcc7 to 7504132 Compare March 5, 2023 05:58
@Luminoscity Luminoscity self-requested a review March 5, 2023 06:11
src/routes/mission/[...mission]/+page.svelte Outdated Show resolved Hide resolved
package.json Outdated Show resolved Hide resolved
src/lib/demil.ts Show resolved Hide resolved
src/lib/util.ts Outdated Show resolved Hide resolved
@tepel-chen tepel-chen force-pushed the feature/start-mission branch from b8a555e to f9c60d3 Compare March 19, 2023 18:07
@Luminoscity
Copy link
Collaborator

Much improved, thank you. Though I think we could push even more of that ts code you added to the mission page into the component. And it will have to be thoroughly tested by me and Rex for bugs.

demilErrorMessage = `A room that can support more bombs is required. Current rooms only support up to ${bombCountError.MaximumSupportedBombsCount} bombs, and the mission has ${bombCountError.MissionBombsCount} bombs.`;
demilHelpState = 'Error';
} else {
toast.success(`Started mission ${missionResult.MissionID}`);
Copy link
Owner

Choose a reason for hiding this comment

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

We shouldn't use the mission ID but the mission name.


<Dialog bind:dialog>
{#if typeof demilHelpState !== 'undefined'}
<div class="block">
Copy link
Owner

Choose a reason for hiding this comment

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

Can you remove this block element? It makes it look the dialog has a weird thick gray border around it.

Comment on lines +84 to +104
let demilClient = new DeMiL.DeMiLClient(8095);
async function startMission() {
demilHelpState = undefined;
try {
const missionResult = await demilClient.startMissionByName(mission.name, steamID);
demilVersion = !missionResult.IsVersionInRange ? missionResult.Version ?? '<2.1.0' : undefined;
if (missionResult.hasOwnProperty('MissingModules')) {
missingModules = (missionResult as DeMiL.StartMissionMissingModulesResult).MissingModules.map(mod =>
getModule(mod, modules)
);
demilHelpState = 'MissingModules';
} else if (missionResult.hasOwnProperty('MissionModulesCount')) {
let moduleCountError = missionResult as DeMiL.StartMissionTooManyModulesResult;
demilErrorMessage = `Failed to start mission. A bomb that can support more modules is required. Current bombs only support up to ${moduleCountError.MaximumSupportedModulesCount} modules, and the mission has ${moduleCountError.MissionModulesCount} modules.`;
demilHelpState = 'Error';
} else if (missionResult.hasOwnProperty('MissionBombsCount')) {
let bombCountError = missionResult as DeMiL.StartMissionTooManyBombsResult;
demilErrorMessage = `A room that can support more bombs is required. Current rooms only support up to ${bombCountError.MaximumSupportedBombsCount} bombs, and the mission has ${bombCountError.MissionBombsCount} bombs.`;
demilHelpState = 'Error';
} else {
toast.success(`Started mission ${missionResult.MissionID}`);
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think literally all of this from line 84 to 117 can be in the component instead of in the mission page code and you just pass it the mission object.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add a link to activate bomb with Competitive Mode or DeMiL Service
3 participants