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

feat: add FOMO3D game implementation #3344

Open
wants to merge 64 commits into
base: master
Choose a base branch
from

Conversation

stefann-01
Copy link
Contributor

@stefann-01 stefann-01 commented Dec 16, 2024

Description

This PR introduces FOMO3D, a blockchain-based game that combines lottery and investment mechanics, implemented as a Gno realm. The game creates an engaging economic model where players compete to be the last key purchaser while earning dividends from subsequent purchases.

Key Features

  • Players purchase keys using GNOT tokens
  • Each key purchase:
    • Extends the game timer
    • Increases key price by 1%
    • Makes buyer potential jackpot winner
    • Distributes dividends to existing key holders
  • Automatic prize distribution:
    • 47% to jackpot (winner)
    • 28% as dividends to key holders
    • 20% to next round's starting pot
    • 5% as a fee to the contract owner
  • Full test coverage

Technical Implementation

  • Utilizes AVL tree for player data storage
  • Implements dividend distribution system
  • Includes comprehensive test suite
  • Features markdown-formatted render functions for game state visualization
  • Mints a unique FOMO3D NFT to the winner of each round

How to Use

  1. Start game with StartGame()
  2. Purchase keys with BuyKeys()
  3. Claim dividends with ClaimDividends()
  4. View game status via render functions
  5. Winner automatically receives jackpot when timer expires

Testing

All core functionalities are covered by unit tests including:

  • Full game flow
  • Key purchasing mechanics
  • Dividend distribution
  • Game ending conditions

Inspired by the original Ethereum FOMO3D game but rebuilt for the Gno platform.

Note

The test checks will not pass until gnolang/gno#3495 is merged. In case this PR is not approved, I will refactor the NFT feature accordingly.

@github-actions github-actions bot added the 🧾 package/realm Tag used for new Realms or Packages. label Dec 16, 2024
@Gno2D2
Copy link
Collaborator

Gno2D2 commented Dec 16, 2024

🛠 PR Checks Summary

All Automated Checks passed. ✅

Manual Checks (for Reviewers):
  • IGNORE the bot requirements for this PR (force green CI check)
  • The pull request description provides enough details
Read More

🤖 This bot helps streamline PR reviews by verifying automated checks and providing guidance for contributors and reviewers.

✅ Automated Checks (for Contributors):

🟢 Maintainers must be able to edit this pull request (more info)
🟢 Pending initial approval by a review team member, or review from tech-staff

☑️ Contributor Actions:
  1. Fix any issues flagged by automated checks.
  2. Follow the Contributor Checklist to ensure your PR is ready for review.
    • Add new tests, or document why they are unnecessary.
    • Provide clear examples/screenshots, if necessary.
    • Update documentation, if required.
    • Ensure no breaking changes, or include BREAKING CHANGE notes.
    • Link related issues/PRs, where applicable.
☑️ Reviewer Actions:
  1. Complete manual checks for the PR, including the guidelines and additional checks if applicable.
📚 Resources:
Debug
Automated Checks
Maintainers must be able to edit this pull request (more info)

If

🟢 Condition met
└── 🟢 The pull request was created from a fork (head branch repo: stefann-01/gno)

Then

🟢 Requirement satisfied
└── 🟢 Maintainer can modify this pull request

Pending initial approval by a review team member, or review from tech-staff

If

🟢 Condition met
└── 🟢 Not (🔴 Pull request author is a member of the team: tech-staff)

Then

🟢 Requirement satisfied
└── 🟢 If
    ├── 🟢 Condition
    │   └── 🟢 Or
    │       ├── 🟢 At least 1 user(s) of the organization reviewed the pull request (with state "APPROVED")
    │       ├── 🔴 At least 1 user(s) of the team tech-staff reviewed pull request
    │       └── 🔴 This pull request is a draft
    └── 🟢 Then
        └── 🟢 Not (🔴 This label is applied to pull request: review/triage-pending)

Manual Checks
**IGNORE** the bot requirements for this PR (force green CI check)

If

🟢 Condition met
└── 🟢 On every pull request

Can be checked by

  • Any user with comment edit permission
The pull request description provides enough details

If

🟢 Condition met
└── 🟢 And
    ├── 🟢 Not (🔴 Pull request author is a member of the team: core-contributors)
    └── 🟢 Not (🔴 Pull request author is user: dependabot[bot])

Can be checked by

  • team core-contributors

Copy link

codecov bot commented Dec 16, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

📢 Thoughts on this report? Let us know!

n2p5 and others added 6 commits December 16, 2024 09:15
}

// GetGameState returns current game state
func GetGameState() (int64, int64, int64, std.Address, int64, int64, int64, bool) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Might make sense to pack these into a struct, wdyt?

Copy link
Contributor Author

@stefann-01 stefann-01 Dec 29, 2024

Choose a reason for hiding this comment

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

Is this what you had in mind? 059917e

Copy link
Contributor Author

@stefann-01 stefann-01 Jan 13, 2025

Choose a reason for hiding this comment

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

Figured out the best way to handle this, made TODO comments in 4a5435f.
Current solution works fine for now, will be improving this some time in future.

@stefann-01
Copy link
Contributor Author

On top of this, register to the hall of fame :)

I did, it's in init(). I also added a small section in Render to encourage upvotes :)

alexiscolin and others added 8 commits January 24, 2025 03:05
…g#3569)

This PR aims to improve the HTML composability of gnoweb and avoid DRY
issues across templates and layouts. The changes include:

- Refactoring HTML components for better reusability.
- Reducing code duplication in views.
- Removing static data from the layout
- Enhancing code maintainability and readability.

---------

Signed-off-by: gfanton <[email protected]>
Co-authored-by: gfanton <[email protected]>
This pull request is for :

- remove `require` statement from official documentation
[gnolang#3123](gnolang#3123)
- add an example that was `//TODO` in the `effective-gno / Documentation
is for users` section
…olang#3557)

This will make it so that on master, there is only 1 job of
releaser-master executing at a time. There may be another pending one
(if, say, we merge two PRs back to back), and it will be put as
`pending`. It's cancelled if we merge a third PR while the second one is
still `pending`.

For more information:
https://docs.github.com/en/actions/writing-workflows/workflow-syntax-for-github-actions#concurrency
## Description

To make contracts more simpler(and low computation for execution), it is
better for contract to manipulate with only `std.Address` rather than
using `users.AddressOrName` and resolving it. ([Discussed with
@moul](gnoswap-labs/gnoswap#465 (comment)))

Clients such as gnoeky, gnoweb or adena should perform look up(convert
username to address) and pass address value to contract.
## Description

Fixes txtar that needed to be in gnolang#3580 

Should've been caught by CI, wasn't

---------

Co-authored-by: Morgan Bazalgette <[email protected]>
…iew (gnolang#3574)

After a first day of experimentation, we determined we don't want the
triage-pending label on PRs that have already received a review from a
tech-staff member.

Some additional changes:

- Split between `ApprovalBy` and `ReviewBy` in reviewer.go, to
distinguish between the requirements that only work with an approval and
those that are more generic.
- Don't request a team review if a member of the team already reviewed
or is requested for review. (The bot was nagging a bit on some PRs
because of this)
Depends on gnolang#3323 

- add test in `examples/no_cycles_test.go` to detect import cycles in
stdlibs and examples
- add `matchString` native injection in the `testing` stdlib to avoid a
cycle in `regexp` tests
- remove other import cycles

Go never allows import cycles. Our stdlibs have a lot of import cycles,
and some examples import self which is not allowed in golang either.
Keeping support for import cycles in stdlib and importing self will
require a lot of hacky and weird logic in generic package loading code
so I try to tackle this first.

TODO:

- [x] fix tests
- [x] ~~check cycles with the test stdlibs overlay applied~~ -> be
explicit about the lack of support for modifying imports in testing
stdlibs overlay

---------

Signed-off-by: Norman Meier <[email protected]>
Signed-off-by: Norman <[email protected]>
Signed-off-by: Norman <[email protected]>
Co-authored-by: Morgan <[email protected]>
Co-authored-by: Norman <[email protected]>
@github-actions github-actions bot added 📦 🤖 gnovm Issues or PRs gnovm related 📦 🌐 tendermint v2 Issues or PRs tm2 related 📦 ⛰️ gno.land Issues or PRs gno.land package related labels Jan 24, 2025
@Gno2D2 Gno2D2 requested review from a team January 24, 2025 02:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
📦 🌐 tendermint v2 Issues or PRs tm2 related 📦 ⛰️ gno.land Issues or PRs gno.land package related 📦 🤖 gnovm Issues or PRs gnovm related 🧾 package/realm Tag used for new Realms or Packages.
Projects
Status: In Progress
Development

Successfully merging this pull request may close these issues.

10 participants