📌 Feature Request: Implement start() Function in IAction Interface
🧩 Description
Implement the start() function within the IAction interface to serve as the entry point for starting a game.
This function is responsible for:
- Performing all necessary validation checks before starting the game.
- Updating the game status to reflect that it has started.
- Evenly distributing the initial game balance among all players in the game.
✅ Acceptance Criteria
🛠️ Related Models & Contracts
Game: Core game model with status, players, and game type.
GameBalance: Tracks balance per player per game.
GameStatus: Enum used to identify current game lifecycle state.
GameType: Enum for public/private game mode.
IAction: Contract interface where start() will be implemented.
🧪 Testing Notes
-
Attempt to start a game before all players have joined → should fail.
-
Attempt to start a game that’s already Ongoing or Ended → should fail.
-
Attempt to start a game where ready_to_start = false → should fail.
-
On success, verify:
- All players received equal balance.
- Game status is updated to
Ongoing.
📦 Example Artifacts
// Inside IAction impl
fn start_game(ref self: ContractState, game_id: u256) -> bool {
// Check game exists
// Ensure all players have joined
// Ensure ready_to_start is true
// Ensure game status is Pending
// Update status to Ongoing
// Distribute balance evenly among players
true
}
📘 Status
Stat: ✅ Done
Build: ✅ Builds Successfully
Validation: ✅ All Checks Handled
Logic: ✅ Players Credited Evenly
📎 Additional Notes
- Use
GameTrait and existing models effectively to avoid duplicating logic.
- May require creating a helper to fetch all players associated with a game (if not already available).
- Consider emitting an event,
GameStarted.
📌 Feature Request: Implement
start()Function inIActionInterface🧩 Description
Implement the
start()function within theIActioninterface to serve as the entry point for starting a game.This function is responsible for:
✅ Acceptance Criteria
Validation Checks:
number_of_players.ready_to_start = true.Pending.Status Update:
PendingtoOngoing.Balance Distribution:
GameBalancemodel.🛠️ Related Models & Contracts
Game: Core game model with status, players, and game type.GameBalance: Tracks balance per player per game.GameStatus: Enum used to identify current game lifecycle state.GameType: Enum for public/private game mode.IAction: Contract interface wherestart()will be implemented.🧪 Testing Notes
Attempt to start a game before all players have joined → should fail.
Attempt to start a game that’s already
OngoingorEnded→ should fail.Attempt to start a game where
ready_to_start = false→ should fail.On success, verify:
Ongoing.📦 Example Artifacts
📘 Status
Stat: ✅ Done
Build: ✅ Builds Successfully
Validation: ✅ All Checks Handled
Logic: ✅ Players Credited Evenly
📎 Additional Notes
GameTraitand existing models effectively to avoid duplicating logic.GameStarted.