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

Updates to gameplay logic #58

Open
wants to merge 7 commits into
base: staging
Choose a base branch
from
Open

Conversation

Avelous
Copy link

@Avelous Avelous commented Nov 27, 2024

Updates

  1. Swithed to atomic game round updates to avoid race conditions @ packages/nextjs/app/api/game/updategameround/route.ts

Right now, updating game round requests happens on all screens, this current setup helps against inconsistencies from similar requests. However, if we can move updating of rounds centrally to the serverside, it will be a lot better.

  1. Corrected the logic for assigning points to players to ensure that points are accurately calculated and updated. @ packages/nextjs/app/api/player/updateplayerround/route.ts

  2. Changed game state management from usestate to useReducer @ packages/nextjs/context/gameContext.ts

This change improves state management by reducing inconsistencies and providing a more scalable way of managing the game state.

  1. Replace the 5 seconds game refreshing through api requests with a cron task @ packages/nextjs/lib/scripts/cronTasks.ts

Replaced the previous refresh mechanism based on five seconds API requests with a cron task. This task runs on the server-side set periodically at 10 seconds, updating the game channels.
TODO: Database cleanup and scaling up of Ably.

Copy link

vercel bot commented Nov 27, 2024

@Avelous is attempting to deploy a commit to the BuidlGuidl Team on Vercel.

A member of the Team first needs to authorize it.

Copy link

vercel bot commented Nov 27, 2024

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

Name Status Preview Comments Updated (UTC)
doodle-exchange-nextjs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 27, 2024 11:15pm

import { ablyRealtime } from "../socket";
import cron from "node-cron";

const pushGameUpdates = async () => {
Copy link
Member

Choose a reason for hiding this comment

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

Why do you need this?

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.

2 participants