Skip to content

hto/golang-html5-multiplayer-game

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 

Repository files navigation

Tarla Faresi (Field Mouse) 🌿🐭

Tarla Faresi is a fast-paced, 2-player turn-based multiplayer browser game where players compete to find fruits hidden in a 10x10 garden grid. Players draw action cards to determine their moves, race against a 5-second timer per turn, and collect fruits to win!

🎮 Gameplay & Rules

Objective

The first player to collect 5 fruits wins the game!

The Board

The game is played on a 10x10 grid (100 cells). Hidden beneath the leaves are 22 random fruits: 🍎, 🍌, 🍓, 🍊, and 🍇.

Turn Mechanics

  1. Draw a Card: At the start of your turn, you must draw a card.
  2. 5-Second Timer: Once you draw a card, a 5-second timer starts immediately. You must complete your action before the timer runs out. If you fail to act, your turn is skipped.
  3. Execute Action: Perform the action specified by your card (e.g., click a cell, click a cell to select its row, etc.).
  4. Collect Fruits: Any fruits revealed by your action instantly go into your basket!

Action Cards

There are 8 different types of cards you can draw:

  • OPEN_1_CELL: Select any 1 closed cell to open.
  • OPEN_2_CELLS: Select any 2 closed cells to open.
  • OPEN_3_CELLS: Select any 3 closed cells to open.
  • OPEN_FULL_ROW: Select any cell to instantly open its entire row.
  • OPEN_FULL_COLUMN: Select any cell to instantly open its entire column.
  • FORCE_ROW: The server picks a random row. You must select 1 cell from that specific row.
  • FORCE_COLUMN: The server picks a random column. You must select 1 cell from that specific column.
  • PASS: Unlucky! You skip this turn.

🚀 Running the Game

The game consists of a Golang WebSockets server and a vanilla HTML5/JS client.

Prerequisites

  • Go (1.20+)
  • A modern web browser

Starting the Server

  1. Clone the repository and navigate to the project directory:
    cd tarla-faresi/server
  2. Run the Go server:
    go run .
    The server will start listening on http://localhost:8080.

Playing the Game

  1. Open your web browser and navigate to: http://localhost:8080/
  2. You can open a second tab (or have a friend join on the same network) to act as Player 2.
  3. Enter your player names.
  4. The Matchmaker will automatically pair you up into a real-time game!

🛠 Tech Stack

  • Backend: Go (net/http, Gorilla WebSockets)
  • Frontend: HTML5, CSS3, Vanilla JavaScript (Mobile-first, 16:9 vertical lock layout)
  • Communication: JSON over WebSocket

Architecture Highlights

  • Authoritative Server: All game logic, state management, and grid generation/validation run strictly on the Go server, preventing client-side cheating.
  • Matchmaking: Players are automatically queued and seamlessly paired into distinct isolated game rooms via a thread-safe Matchmaker.
  • Graceful Disconnects: If a player disconnects mid-game, the other player immediately wins by default.

About

Turn-based multiplayer browser game with Golang WebSocket server and HTML5 client.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors