Skip to content

feat(examples): pokemon fight simulator game at r/leo/pokemon #4072

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

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

Conversation

Tchips46
Copy link

@Tchips46 Tchips46 commented Apr 7, 2025

Added

Realms:

r/leo/pokemon
A small Pokémon fight simulator game to showcase what a ranked game could look like using blockchain.

  • Pokémon fight base system
  • Team fight
    • Swap Pokémon during fight
    • Use items during fight
    • Attack enemy
    • PVE
      • Random attack selection
      • Random team selector
    • Transaction to end fight and validate data
  • Pokémon DAO implementation
  • Ranking system
  • Team selector
  • Shop to buy items
  • Login system
  • Replace p/leo/randomizer by math/rand
  • Replace p/leo/renderer by p/moul/md and p/moul/mdtable

r/leo/home
idk

Pures:

  • p/leo/randomizer – A simplified math/rand. This is a temporary solution and will be removed once its issues are resolved.
  • p/leo/utils – A collection of useful functions for Gno development.
  • p/leo/dao – A basic and easily reusable dao system.
  • p/leo/renderer – A markdown library for features not implemented by p/moul/md, such as parameterized headers or table rendering.

@Tchips46 Tchips46 marked this pull request as draft April 7, 2025 17:04
@github-actions github-actions bot added the 🧾 package/realm Tag used for new Realms or Packages. label Apr 7, 2025
@Gno2D2 Gno2D2 requested a review from a team April 7, 2025 17:05
@Gno2D2
Copy link
Collaborator

Gno2D2 commented Apr 7, 2025

🛠 PR Checks Summary

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

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
└── 🟢 And
    ├── 🟢 The base branch matches this pattern: ^master$
    └── 🟢 The pull request was created from a fork (head branch repo: Tchips46/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
└── 🟢 And
    ├── 🟢 The base branch matches this pattern: ^master$
    └── 🟢 Not (🔴 Pull request author is a member of the team: tech-staff)

Then

🔴 Requirement not 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
    └── 🔴 Else
        └── 🔴 And
            ├── 🟢 This label is applied to pull request: review/triage-pending
            ├── 🔴 At least 1 user(s) of the team tech-staff reviewed pull request
            └── 🔴 On no pull request

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 Apr 7, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

📢 Thoughts on this report? Let us know!

@Tchips46 Tchips46 force-pushed the feat/add-leo-realm-pokemon-game-for-demo branch from 14b4c01 to 6be7a81 Compare April 14, 2025 14:22
@Tchips46 Tchips46 marked this pull request as ready for review April 15, 2025 12:04
@Gno2D2 Gno2D2 added the review/triage-pending PRs opened by external contributors that are waiting for the 1st review label Apr 15, 2025
Copy link
Contributor

@leohhhn leohhhn left a comment

Choose a reason for hiding this comment

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

leaving some comments

Copy link
Contributor

Choose a reason for hiding this comment

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

Since this is quite small, i suggest you deploy this permissionlessly :)

Comment on lines 26 to 46
pokemonPath = map[RenderPage]func(map[string]string) string{
pokemonLogin: renderPokemonLogin,
pokemonLobby: renderPokemonLobby,
pokemonTeamSelector: renderPokemonTeam,
pokemonFight: renderPokemonFight,
pokemonShop: renderPokemonShop,
pokemonRank: renderPokemonRank,
}
)

func Render(path string) (rend string) {
rend += md.H1("Pokémon")
path, params := utils.ParsePath(path)

if pathRenderer := pokemonPath[RenderPage(path)]; pathRenderer != nil && pokemonDAO.IsMember(std.Address(params["user"])) {
rend += pathRenderer(params)
} else {
rend += renderPokemonLogin(params)
}
return
}
Copy link
Contributor

Choose a reason for hiding this comment

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

This is a cool approach, but I suggest using one of the libraries we have for routing, such as the p/demo/mux library, which is more go-like :)

Copy link
Contributor

Choose a reason for hiding this comment

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

this library also provides a simple way to get query parameters. check out https://gno.land/r/docs/routing

Copy link
Author

Choose a reason for hiding this comment

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


var (
rand = randomizer.NewRandomizer()
nl = "\n\n"
Copy link
Contributor

Choose a reason for hiding this comment

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

can be const as well

Copy link
Author

Choose a reason for hiding this comment

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

Done ! a6ca485

Comment on lines 55 to 60
for i, e := range pokemonDAO.userData {
link := atm_path + ":" + string(pokemonLobby) + "?user=" + string(pokemonDAO.GetMembers()[i])
rend += " - " + md.Link(string(pokemonDAO.GetMembers()[i]), link)
rend += " : " + renderPokedollar(int(e.pokedollar)) + nl
}
return
Copy link
Contributor

Choose a reason for hiding this comment

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

could be nice to use r/sys/users :)

check out https://gno.land/r/docs/use_rsysusers

Copy link
Author

Choose a reason for hiding this comment

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

@leohhhn
Copy link
Contributor

leohhhn commented Apr 15, 2025

Also please check the CI!

@Tchips46 Tchips46 requested a review from leohhhn April 16, 2025 12:22
@Kouteki Kouteki removed the request for review from a team April 17, 2025 07:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🧾 package/realm Tag used for new Realms or Packages. review/triage-pending PRs opened by external contributors that are waiting for the 1st review
Projects
Status: No status
Status: In Progress
Development

Successfully merging this pull request may close these issues.

3 participants