Skip to content

chost-in/testmigrate

Repository files navigation

The GumWall - Reddit Devvit Game

A Reddit Devvit application where users can stick virtual gum to a shared wall. This is a migration of the original client-side GumWall game to the Reddit Devvit platform.

Features

  • Interactive Gum Placement: Users can stick colorful gum wads to a shared brick wall
  • Police System: Random police patrols that arrest users caught placing gum
  • Lifeline System: Users have 5 lifelines per day; getting caught reduces lifelines
  • Jail & Day Ban: Users get jailed for short periods or day-banned if they run out of lifelines
  • Persistent Data: All game data is stored in Redis and persists across sessions
  • Real-time Updates: Police state and game data update in real-time
  • Reddit Integration: Uses authenticated Reddit users instead of anonymous players

Game Mechanics

Gum Placement

  • Click "Stick Gum" to enter placement mode
  • Click "Place Here" to place your gum at a random location
  • Each gum wad has a unique color and shape
  • Gum placement is tracked per Reddit user

Police System

  • Police warnings appear randomly every 30 seconds to 2 minutes
  • After a 5-second warning, police patrol for 3 seconds
  • Getting caught during patrol reduces your lifelines
  • Police state is managed server-side for fairness

Lifeline System

  • Each user starts with 5 lifelines per day
  • Lifelines reset at midnight
  • Getting arrested reduces lifelines by 1
  • Jail time increases with each arrest: 5s, 10s, 15s, 20s, 25s
  • Running out of lifelines results in a day ban until midnight

Technical Architecture

Migration from Client-side to Devvit

Data Persistence:

  • Migrated from localStorage to Redis
  • GumWads stored as Redis hashes
  • User states stored per Reddit user ID
  • Unique chewers tracked in Redis sets

Execution Context:

  • Police system logic moved to server-side functions
  • User lifeline management handled server-side
  • Prevents client-side manipulation

User Identity:

  • Transitioned from anonymous users to authenticated Reddit users
  • Uses Reddit's built-in user context
  • User data tied to Reddit user IDs

API Layer:

  • Server-side functions serve as API endpoints
  • Client-side React components call server functions
  • Real-time state synchronization

File Structure

project/
├── src/
│   ├── main.tsx              # Main Devvit entry point
│   ├── types/
│   │   └── game.ts           # Game type definitions
│   └── components/           # Original React components (preserved)
├── server/
│   ├── gameState.server.ts   # Game state management
│   ├── policeSystem.server.ts # Police system logic
│   └── gumActions.server.ts  # Gum placement actions
├── devvit.json              # Devvit configuration
└── package.json             # Dependencies and scripts

Development

Prerequisites

  • Node.js 18+
  • Reddit Developer Account
  • Devvit CLI

Setup

  1. Install dependencies: npm install
  2. Build the application: npm run build
  3. Test locally: npx devvit playtest

Deployment

  1. Upload to Reddit: npx devvit upload
  2. Install in a subreddit via Reddit's app directory

Usage

  1. A moderator installs the app in their subreddit
  2. Create a game post using the "Create GumWall Game" menu item
  3. Users interact with the game post to place gum and avoid police
  4. Game state persists across all user sessions

Compliance

This application follows Reddit's Devvit guidelines:

  • Transparent user actions
  • Secure server-side logic
  • Proper Redis data management
  • User authentication via Reddit

Original Game

This is a migration of the original GumWall game, preserving the core gameplay mechanics and visual design while adapting to the Reddit Devvit platform's architecture and capabilities.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors