Giter Site home page Giter Site logo

371project's People

Contributors

01mz avatar ptdo avatar tjdydgur123 avatar viethung7899 avatar viettud22 avatar

Watchers

 avatar

371project's Issues

Fix crashing issue

The game crashes sometimes when users click the boxes.

This is because of the UI updates from outside the main thread, which is a bad practice.

Game boxes

A box should contain

  • who holds the box
  • who claims the box
  • lock (for synchronization?)

Logic on server

  • If someone holds the box, others cannot hold or claim it
  • If a box is not on hold, anyone can steal it (no matters the box is claimed or not)

UI logic on the client side

  • User can hold the box by pressing the mouse down
  • Box must be in held at least 3s by someone to before being claimed
  • The box is outlined with the colour of the player who holds the box
  • The box is filled with the colour of the player who claims the box
  • #19

Implement game logic

  • Calculate the total number of claimed boxes per player
  • The winner is:
    • The player that has the most claimed boxes, or
    • The first player to claim half of the board is the winner (for example, if there are 4 players, the first one to claim 1/4 of the boxes is the winner)
  • A game ends when:
    • The winner is found, or
    • All boxes are claimed

Restrict player connection

  • The game cannot start unless there are more than 2 players
  • Reject the player connection when there are enough players (2 to 4 players)
  • Reject the player connection when the game is ongoing

Functionality for server to send message to all connected clients

Figure out how to send a message from the server to all the connected clients

some ideas:

  • When a player joins the game, a tcp connections is made
  • The tcp connection is used to send and receive throughout the game
  • It is not closed until the client quits the game
  • The server needs to keep track of the open tcp connections (one for each player) somehow (an array?).

Example:
Suppose three players join a game, when one player clicks a square it shows up as clicked on the other players' screen.
or a more simple example to test:
Suppose three players join a game, when one player clicks on square, a message is sent to the server, the server sends a message to all the clients, the client prints out the message in console.

TCP messages

Messages are sent by clients

  • HOLD row col: player starts pressing on a box
  • CLAIM row col: player claims a box
  • RELEASE row col: player releases the mouse

Messages are only broadcasted by the server when the game is ongoing

  • HOLD row col player: player holds a box
  • CLAIM row col player: player claims a box
  • RELEASE row col: remove the holder of the box
  • WIN player: announce the winner and end the game

Notify players after establishing connection

The server sends TCP messages after the establishing connection and before making the game

  • ACCEPT playerId: accept the connection from the player and assign them with a playerId (to know what color they are playing)
  • REJECT: reject the connection from the player

This should be done before starting before the game started

This is related to #22

Create a game session

  • A player starts the server. A session ID (sid) is then generated. Others can join the session by entering this sid
  • If sid is correct, let player join the game. Otherwise, inform player sid is incorrect
  • Max 4 players per session
  • (Optional) Time limit: Display a countdown timer for each session

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.