Code Monkey home page Code Monkey logo

network-tcp-game's Introduction

TCP chatroom with private chat function and a small betting game

Chat room

  1. start the server(Server.java)
  2. open some client(Player.java), before joining the chatroom, you have to enter the IP of the Server e.g.127.0.0.1 (chatroom Server)
    2.1.and then if you are first one join the chatroom, then set your nickname e.g. Jay, and then your playname in chatroom becomes"Jay 127.0.0.1:53248", unique "ip:port" is necessary in my game, just incase of two member have same name "Jay".
    2.2.if you are not the first one, then enter who e.g. C(Introducing Agent) invited you to this chatroom, and then set your nickname
  3. now you can chat in public chatroom, if you want to send private msg to some one, do like this @[Jay 127.0.0.1:53248]--hi how are you?
  4. try to send 'COMMAND' to learn how to play with this simple game

Join Game

The game's idea is: each player can play with other player only once, it is a counting-backwards game, for example Player A and Player B match in a duel, counting is set to be starting from A or B randomly, and both A,B players will know who start counting first, player A sends to player B number 3, B sends to A number 2, count backwards from 5(3+2), if counting starts from A, then A wins(start--A B A B A--end), in the case of cheating(because both Players know who start first), so when A send 3 to B, B will receive "8(encrypted)", they will only get each others real number after the duel finish, and will be told the encryptFunction for fairness.

  1. Members in this chatroom have two identities(either only chat member or both player and chat member), if some chat member want to join the game, send JOIN to its Introducing Agent e.g. @[Jay 127.0.0.1:53248]--JOIN, for the first one who join the chatroom, since your Introducing Agent is yourself, also send like @[yournickname 127.0.0.1:53248]--JOIN to yourself.
  2. For play room, players will be matching automatically to the one who is not in a duel, to send number to current enemy, send e.g."$168" sending 'COMMAND' will show you more about the rules of the game.

HTTP Server

Try to create more players and play with yourself, and then go to http://127.0.0.1:8080/ to check to result of the whole play room.

network-tcp-game's People

Contributors

timmmgz avatar

Watchers

 avatar

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.