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

adds view funcs and parameterized launch tourny configs #237

Merged

Conversation

loothero
Copy link
Member

@loothero loothero commented Sep 3, 2024

Summary by CodeRabbit

  • New Features

    • Reduced the duration for which obituaries are considered valid from 10 days to 1 day.
    • Introduced new reward constants for adventurers related to DAO and PG contracts.
    • Added new methods to enhance functionality for promotions and tournaments, including checks for active tournaments and retrieving winners.
  • Bug Fixes

    • Improved handling of adventurer IDs to ensure accurate state management during gameplay.
  • Chores

    • Updated deployment scripts to reflect new tournament duration and delay parameters, enhancing configurability.

- get_launch_tournament_winner()
- get_launch_tournament_end_time()
- updates sepolia deployment script
Copy link

vercel bot commented Sep 3, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
loot-survivor ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 3, 2024 8:37pm

Copy link

coderabbitai bot commented Sep 3, 2024

Walkthrough

The changes introduce modifications to constants, interfaces, and functions across multiple files in the game codebase. Key updates include a reduction in the obituary expiry duration, the addition of new reward constants, and enhancements to the game interface with new methods for managing promotions and tournaments. The deployment script has also been updated to reflect these changes, particularly in how tournament parameters are configured.

Changes

Files Change Summary
contracts/game/src/game/constants.cairo Updated OBITUARY_EXPIRY_DAYS from 10 to 1; added DAO_CONTRACT_REWARD_ADVENTURER and PG_CONTRACT_REWARD_ADVENTURER.
contracts/game/src/game/interfaces.cairo Added four new methods to the IGame trait for managing promotions and tournaments.
contracts/game/src/lib.cairo Introduced new constants and updated function signatures for tournament management; added functions for genesis adventurers.
contracts/game/src/tests/test_game.cairo Added OBITUARY_EXPIRY_DAYS constant; updated adventurer ID handling and deployment parameters.
scripts/deploy.sh Replaced launch_promotion_end_timestamp with launch_tournament_duration_seconds; added new variables for tournament configuration.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant GameContract
    participant TournamentManager

    User->>GameContract: Start Game
    GameContract->>TournamentManager: Initialize Tournament Parameters
    TournamentManager->>GameContract: Set Duration and Delay
    GameContract->>User: Game Started with Promotions
Loading

Assessment against linked issues

Objective Addressed Explanation
Add view function for free_vrf_promotion_active (233)
Add a launch tournament delay parameter to constructor (228)
Adventurer ID 1 Promotion (129) No specific implementation for Adventurer ID 1.
Mint Adventurer 2 and 3 to PG and Biblio for contract rewards (224) No changes related to minting Adventurer IDs 2 and 3.

🐇 Hopping through the code, oh what a sight,
New constants and functions, all shiny and bright!
With tournaments ready and rewards in store,
Adventures await, who could ask for more?
Let's celebrate changes, both big and small,
In the land of the game, we’ll have a ball! 🎉

Tip

We have updated our review workflow to use the Anthropic's Claude family of models. Please share any feedback in the discussion post on our Discord.


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between fca6591 and f792a8d.

Files selected for processing (5)
  • contracts/game/src/game/constants.cairo (1 hunks)
  • contracts/game/src/game/interfaces.cairo (1 hunks)
  • contracts/game/src/lib.cairo (15 hunks)
  • contracts/game/src/tests/test_game.cairo (60 hunks)
  • scripts/deploy.sh (2 hunks)
Additional comments not posted (31)
scripts/deploy.sh (4)

24-24: LGTM!

The code change is approved. It replaces the launch_promotion_end_timestamp variable with launch_tournament_duration_seconds to configure the tournament duration.


27-27: LGTM!

The code change is approved. It introduces a new variable launch_tournament_start_delay_seconds to configure the delay before the tournament starts.


28-28: LGTM!

The code change is approved. It introduces a new variable free_vrf_promotion_duration_seconds to configure the duration of a promotional event related to VRF (Verifiable Random Function).


49-49: LGTM!

The code change is approved. It updates the deployment command for the game contract to include the new tournament parameters, replacing the previous timestamp variable with the newly defined duration and delay variables. This change enhances the configurability of the tournament mechanics.

contracts/game/src/game/constants.cairo (3)

17-17: Verify the impact of reducing the obituary expiry duration.

The OBITUARY_EXPIRY_DAYS constant has been reduced from 10 days to 1 day. This is a significant reduction in the duration for which obituaries are considered valid.

Please verify the following:

  1. Ensure that this change does not introduce any unintended side effects or break existing functionality related to obituaries.
  2. Confirm if the reduced expiry duration aligns with the desired game mechanics and user experience.
  3. Update any relevant documentation or comments to reflect this change.

22-22: Provide more context about the DAO_CONTRACT_REWARD_ADVENTURER constant.

A new constant DAO_CONTRACT_REWARD_ADVENTURER with a value of 2 has been introduced.

Please provide more information about the purpose and usage of this constant:

  1. How is this constant used within the game's reward mechanisms?
  2. In what scenarios or conditions will adventurers receive this reward in the DAO context?
  3. Are there any related functions or code sections where this constant is utilized?

Adding comments or documentation to explain the role of this constant would be helpful for maintainability and understanding the game's reward system.


23-23: Provide more context about the PG_CONTRACT_REWARD_ADVENTURER constant.

A new constant PG_CONTRACT_REWARD_ADVENTURER with a value of 3 has been introduced.

Please provide more information about the purpose and usage of this constant:

  1. How is this constant used within the game's reward mechanisms?
  2. In what scenarios or conditions will adventurers receive this reward in the PG context?
  3. Are there any related functions or code sections where this constant is utilized?

Adding comments or documentation to explain the role of this constant would be helpful for maintainability and understanding the game's reward system.

contracts/game/src/game/interfaces.cairo (4)

142-142: LGTM!

The code changes are approved.


143-143: LGTM!

The code changes are approved.


144-144: LGTM!

The code changes are approved.


145-145: LGTM!

The code changes are approved.

contracts/game/src/tests/test_game.cairo (13)

32-32: LGTM!

The code changes are approved.


Line range hint 436-445: LGTM!

The code changes are approved.


451-453: LGTM!

The code changes are approved.


465-465: LGTM!

The code changes are approved.


470-472: LGTM!

The code changes are approved.


475-475: LGTM!

The code changes are approved.


478-479: LGTM!

The code changes are approved.


484-484: LGTM!

The code changes are approved.


530-532: LGTM!

The code changes are approved.


539-544: LGTM!

The code changes are approved.


550-554: LGTM!

The code changes are approved.


564-567: LGTM!

The code changes are approved.


Line range hint 581-601: LGTM!

The code changes are approved.

contracts/game/src/lib.cairo (7)

97-98: LGTM!

The addition of the new constants looks good.


1270-1281: LGTM!

The addition of the new view functions looks good. They provide a clear way to query the state of the free VRF promotion and launch tournament.


1288-1316: LGTM!

The new _mint_genesis_adventurers function looks good. It properly mints the genesis adventurers to the DAO and PG addresses.


3545-3557: LGTM!

The changes to the _is_expired function to not expire genesis adventurers look good.


3624-3629: LGTM!

The new _launch_tournament_end_time function looks good. It properly calculates the launch tournament end time based on the stored state variables.


3633-3634: LGTM!

The changes to the _is_launch_tournament_active function to use the new _launch_tournament_end_time function look good.


157-157: Verify the usage of the new state variables and functions.

The changes to the constructor look good. The new state variables are properly initialized and the new functions are called appropriately.

Please verify that the new state variables and functions are used correctly in the rest of the codebase. You can use the following script to search for their usage:

Also applies to: 159-159, 167-167, 170-170, 308-309, 341-344, 350-352

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between f792a8d and 3817e79.

Files selected for processing (1)
  • contracts/game/src/tests/test_game.cairo (60 hunks)
Files skipped from review as they are similar to previous changes (1)
  • contracts/game/src/tests/test_game.cairo

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 3817e79 and eb5aa51.

Files selected for processing (2)
  • contracts/game/src/lib.cairo (15 hunks)
  • contracts/game/src/tests/test_game.cairo (60 hunks)
Additional comments not posted (23)
contracts/game/src/tests/test_game.cairo (10)

32-32: LGTM!

The new constant OBITUARY_EXPIRY_DAYS is properly declared.


80-82: LGTM!

The new constants are properly declared:

  • LAUNCH_TOURNAMENT_GAMES_PER_COLLCTION
  • LAUNCH_TOURNAMENT_START_DELAY_SECONDS
  • FREE_VRF_PROMOTION_DURATION_SECONDS

251-259: LGTM!

The deploy_lootsurvivor function signature is properly updated:

  • Parameter launch_tournament_end_time is changed to launch_promotion_duration_seconds, which better reflects its purpose.

285-289: LGTM!

The following new parameters are properly appended to the calldata in the deploy_lootsurvivor function:

  • launch_promotion_duration_seconds
  • VRF_PREMIUMS_ADDRESS()
  • LAUNCH_TOURNAMENT_GAMES_PER_COLLCTION
  • LAUNCH_TOURNAMENT_START_DELAY_SECONDS
  • FREE_VRF_PROMOTION_DURATION_SECONDS

300-307: LGTM!

The deploy_game function signature is properly updated:

  • Parameter terminal_timestamp is changed to launch_promotion_duration_seconds, which better reflects its purpose.

Line range hint 436-465: LGTM!

The new_adventurer function is properly updated:

  • It now returns a tuple (IGameDispatcher, felt252), which allows for more flexibility in testing.
  • The game.get_adventurer, game.get_adventurer_name, and game.get_adventurer_meta function calls are updated to use the adventurer_id returned by game.new_game, which is correct.

530-532: LGTM!

The test_start function is properly updated to use the adventurer_id returned by the new_adventurer function, which is correct.


1734-1743: LGTM!

The new transfer_ownership function is properly implemented:

  • It transfers the ownership of an adventurer using the provided from, to, and adventurer_id parameters.
  • Using the IERC721Dispatcher to call transfer_from directly is a valid workaround for the mentioned compiler issue.

2675-2678: LGTM!

The new variables and function call are properly used to set up the test environment:

  • launch_tournament_duration_seconds and contract_deploy_time are introduced.
  • The start_cheat_block_timestamp_global function is called with contract_deploy_time.

Line range hint 2713-2751: LGTM!

The test_settle_launch_tournament and test_settle_launch_tournament_before_end functions are properly updated to use the _launch_tournament_duration_seconds storage variable, which is correct and consistent with the contract changes.

contracts/game/src/lib.cairo (13)

97-98: LGTM!

The addition of the new constants is approved.


157-159: LGTM!

The addition of the new storage variables is approved.


167-170: LGTM!

The addition of the new storage variables for launch tournament configuration is approved.


244-250: LGTM!

The updates to the constructor parameters to support launch tournament duration, start delay, and free VRF promotion duration are approved.


311-320: LGTM!

The initialization of the new storage variables _genesis_timestamp, _launch_tournament_duration_seconds, and _launch_tournament_start_delay_seconds in the constructor is implemented correctly.


344-347: LGTM!

The initialization of the _free_vrf_promotion_duration_seconds storage variable in the constructor is implemented correctly.


353-355: LGTM!

The addition of the call to _mint_genesis_adventurers in the constructor is approved. The implementation of this function should be reviewed separately.


1273-1284: LGTM!

The addition of the new view functions free_vrf_promotion_active, is_launch_tournament_active, get_launch_tournament_winner, and get_launch_tournament_end_time is approved. The implementations of these functions should be reviewed separately.


1291-1326: LGTM!

The implementation of _mint_genesis_adventurers is correct. It mints three special genesis adventurers with specific weapons and names to the DAO and PG addresses, aligning with the objectives mentioned in the PR summary.


1327-1332: LGTM!

The implementation of _free_vrf_promotion_active is correct. It correctly checks if the current timestamp is within the free VRF promotion duration starting from the genesis timestamp.


3555-3567: LGTM!

The update to _is_expired to handle genesis adventurers is implemented correctly. It ensures that genesis adventurers never expire while maintaining the existing expiry logic for non-genesis adventurers.


3634-3639: LGTM!

The implementation of _launch_tournament_end_time is correct. It accurately calculates the end timestamp of the launch tournament based on the genesis timestamp, tournament duration, and start delay.


3713-3714: LGTM!

The renaming of _get_tournament_winner to _get_launch_tournament_winner is approved. It aligns with the naming convention used for other launch tournament related functions.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between eb5aa51 and 7628673.

Files selected for processing (1)
  • contracts/game/src/tests/test_game.cairo (61 hunks)
Files skipped from review as they are similar to previous changes (1)
  • contracts/game/src/tests/test_game.cairo

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 7628673 and 9c2e901.

Files selected for processing (1)
  • contracts/game/src/tests/test_game.cairo (63 hunks)
Files skipped from review as they are similar to previous changes (1)
  • contracts/game/src/tests/test_game.cairo

@loothero loothero requested a review from starknetdev September 3, 2024 20:40
@loothero loothero self-assigned this Sep 3, 2024
@loothero loothero merged commit 3f0857c into main Sep 3, 2024
9 checks passed
@loothero loothero deleted the 228-add-a-launch-tournament-delay-parameter-to-constructor branch September 3, 2024 20:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants