Skip to content

Conversation

@MakinoharaShoko
Copy link
Member

No description provided.

@gemini-code-assist
Copy link

Summary of Changes

Hello @MakinoharaShoko, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request integrates Steamworks functionality into the application, allowing game scripts to interact with the Steam API. The core purpose is to enable the unlocking of Steam achievements through a new callSteam command. This integration is built upon a dedicated SteamIntegration class that bridges to Electron's native capabilities, and the Steamworks API can be initialized dynamically based on application configuration.

Highlights

  • Steamworks Integration: Introduced a new callSteam script command and a SteamIntegration class to facilitate interaction with Steamworks, primarily for unlocking achievements.
  • Achievement Unlocking: Added functionality to unlock Steam achievements via the callSteam script, which takes an achievementId as a parameter and communicates with an Electron bridge.
  • Dynamic Initialization: Enabled dynamic initialization of the Steamworks API by reading a Steam_AppID from configuration, allowing the application to connect to Steam with a specified AppID.
  • Electron Bridge Typing: Provided TypeScript type definitions for the Electron bridge's Steam functions, ensuring type safety when interacting with the native Steam API.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request integrates Steamworks functionality, allowing the game to unlock Steam achievements. It introduces a new callSteam script command, a SteamIntegration class to bridge with Electron, and necessary configuration updates. The implementation is solid, but I've found a couple of areas for improvement: one is a logic bug in the lazy initialization of the Steam integration, and the other is an inefficient and potentially buggy loop in the callSteam script handler. My review includes suggestions to fix these issues.

Comment on lines +51 to +58
if (!this.initialized) {
if (this.appId) {
await this.initialize(this.appId);
} else {
logger.warn('Steam integration unlock call skipped: AppID not set');
return false;
}
}

Choose a reason for hiding this comment

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

high

In unlockAchievement, if the integration is not initialized, you attempt to initialize it. However, you don't check if this initialization was successful before proceeding. If await this.initialize(this.appId) fails (returns false), this.initialized will remain false, but the function will continue and attempt to call bridge.unlockAchievement, which is not what's intended. You should check the initialization status again after the attempt and return early if it failed.

    if (!this.initialized) {
      if (this.appId) {
        await this.initialize(this.appId);
        if (!this.initialized) {
          logger.warn(`Steam integration unlock call skipped for ${achievementId}: initialization failed`);
          return false;
        }
      } else {
        logger.warn('Steam integration unlock call skipped: AppID not set');
        return false;
      }
    }

Comment on lines +13 to +27
for (const arg of sentence.args) {
if (arg.key === 'achievementId') {
const achievementId = getStringArgByKey(sentence, 'achievementId');
if (achievementId) {
WebGAL.steam
.unlockAchievement(achievementId)
.then((result) => {
logger.info(`callSteam: achievement ${achievementId} unlock ${result ? 'succeeded' : 'failed'}`);
})
.catch((error) => {
logger.error(`callSteam: achievement ${achievementId} unlock threw`, error);
});
}
}
}

Choose a reason for hiding this comment

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

medium

The for...of loop is unnecessary and potentially incorrect. You iterate over all arguments, and for each one with the key achievementId, you call getStringArgByKey. getStringArgByKey itself finds the first argument with the given key. This means if you have multiple arguments, you might be re-evaluating getStringArgByKey unnecessarily. If there are multiple arguments with key: 'achievementId', you'll be trying to unlock the same (first) achievement multiple times. It's more efficient and correct to call getStringArgByKey once.

  const achievementId = getStringArgByKey(sentence, 'achievementId');
  if (achievementId) {
    WebGAL.steam
      .unlockAchievement(achievementId)
      .then((result) => {
        logger.info(`callSteam: achievement ${achievementId} unlock ${result ? 'succeeded' : 'failed'}`);
      })
      .catch((error) => {
        logger.error(`callSteam: achievement ${achievementId} unlock threw`, error);
      });
  }

@MakinoharaShoko
Copy link
Member Author

this pr closes #796

@MakinoharaShoko MakinoharaShoko linked an issue Nov 3, 2025 that may be closed by this pull request
@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Nov 16, 2025

Deploying webgal-dev with  Cloudflare Pages  Cloudflare Pages

Latest commit: 5110cbf
Status: ✅  Deploy successful!
Preview URL: https://e265bb31.webgal-dev.pages.dev
Branch Preview URL: https://steamworks.webgal-dev.pages.dev

View logs

@MakinoharaShoko MakinoharaShoko merged commit 857972e into dev Nov 16, 2025
2 checks passed
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.

如何在上架到steam中配置成就系统

3 participants