📜 ⬆️ ⬇️

WhoIsMafia is a new kind of online entertainment

WhoIsMafia - webcam-game

Surely some of you remember my post two weeks ago, in which I showed how you can organize a multiplayer video conference using peer-to-peer Flash platform technology. Today I represent to the public not just the end - now a startup. Get acquainted.

WhoIsMafia.com is a service that allows you to play the most popular salon game Mafia without leaving your home. Not only that - without leaving the browser. To do this, it is enough to have Flash Player 10.1+, a webcam and at least a two megabit unlimited channel. What is the service, technical details and game details can be read under the cut.

Idea of ​​the game


The idea of ​​the game was born the next day after feeling with real-time handles of flash technology. The idea was so clear and understandable that the very next day I started this crazy two-week marathon without sleep and fresh air. Judge for yourself:
  1. Mafia is a very simple, clear and damn popular game.
  2. So far, in-net multi-user videoconferencing is an absolute innovation.
  3. Browser games based on real face-to-face communication of a large number of people, even the Americans do not yet have
  4. For a normal game, according to preliminary calculations, you need a more or less sane computer, webcam and mediocre Internet (at least by the standards of Default City)
  5. Research of the newest technologies is exactly what any adequate IT specialist wants in my opinion. This is something that does not allow our brains to dry out and makes them smile from ear to ear.
  6. The president said - you need to make toys. No sooner said than done :)

Game process


It looks like a room filled with people. Some are alive, some are in prison, some are dead. The link is a big picture.
Screenshot WhoIsMafia.com
')
Start

After the application loads (about 800Kb), the Flash player connects to the Adobe Stratus - RTMFP platform, which helps to organize p2p connections between players. You need to allow the player to use p2p and webcam . Otherwise, nothing will work. The presence of a camera (must have) is checked, the user enters his name and enters the lobby (common room), where you can create or select a suitable room for the game. Please note, users are anonymous here, no registration is required, because people are so reluctant to show their faces on the Internet. While the Internet public is not ready for total de-anonymization. I think a couple of years, and people will not be afraid of this :)

Room selection

Each room has a description, a language of communication (I hope to infect the whole world with Mafia), the preferred age of the players and the minimum number of players. If the number of players turns out to be more than expected when creating the room, you can either kick some or play in such a composition.

As you know, in every anonymous video chat there is a jerk off. I don’t understand at all why it is impossible to make a dick on the Internet, but I cannot protect the game from such gentlemen. The only reasonable thing that came to mind is Ban. So far, this is just a restriction on the entrance to this particular room, but in the future it will be possible to think out and implement something more cruel.

Chat

In the lobby, as in every room, it is possible to correspond. Only in the lobby, the user name and message are displayed, and in the room - a message and a photo at the time of writing the message. This is done in order to protect the lobby from jerking. In the room during the game are unlikely to swing pisyuny. In addition, all official information is displayed in the chat.

A game

After enough players are typed, the creator of the room (admin) starts the game. Users receive a card. While the game has 4 types of cards:

1. Civilians (green card)

During the day, civilians are trying to figure out who the Maf is, and put him by jail vote. At night, they sleep without doing anything. This unorganized majority.

2. Mafia (red card)

They are an organized minority in the game. Mafa see each other and know who is who. In the daytime, with all my might, they are trying to lead the civilians astray and force them to plant each other, or even better, to put a police officer or a doctor. At night, the mafas vote for the victim. At this night, civilians do not see the video of the mafas, and the mafas can communicate with each other. Mafes must come to a common opinion, so they can change their voice if the situation demands it.

3. Commissioner (dark blue card)

This civilian has a special opportunity - at night he can find out the status of any player. The only thing - he must do it before the mafia will kill someone. This innovation is exactly my implementation of the game, which gives it a special drive :)

4. Doctor (turquoise card)

It is also peaceful, but at night it can protect any player. He also has to do this until the mafas have agreed on the sacrifice.

Voting

If as a result of day or night voting an equal number of votes is obtained, the result chooses a Holy Rend (excuse me, but this is IMHO the most appropriate decision in the intern). In the future, you can do something more classic.

Victory

The team that completely destroyed the other, either the mafas or the inhabitants, won. In the future, you can enter a lot of additional statuses, the fantasy of Mafia players is limitless :)

After the end of the game all the cards become visible, the players have the opportunity to discuss the game. Also, the game becomes available in the general list and everyone can join it.

Communication

In addition to video, customers also transmit audio content to each other. So if you want a full-fledged game - stock up on microphones. In order to avoid a wild echo (after all, 6+ players, each with their own bandwidth, their own lags), the sound is transmitted only if the user has pressed the “ON AIR” button. If two users speak at the same time, both will be heard. But it's like interrupting each other in life - indecent. If someone is completely crazy, you can turn off the sound on the receiving side. The blessing is always visible who exactly says.

Tongue

The whole interface is clumsy in English. This was not done by chance. First, the entire Internet speaks English. Secondly, localization is not very difficult to do later. And thirdly, the word VOTE is translated into Russian. VOTE, but I wanted the buttons to be neat. If you find errors - write, correct.

Technology


AppEngine

The server part is made on GAE. Although GAE is needed in general for very large loads, here it is used only at the initial stage - to acquaint clients with each other. Further, all game operations occur within network groups (NetGroup). The server does not take any part in them - on the video broadcast, or in the transmission of game messages.

Multicasting

The service is built on the Peer-to-Peer technology, or rather Multicasting, which appeared in Flash Player in version 10.1. In the last post for the organization of broadcasts, I used a direct connection between clients. As a result, if there were 8 people in the room, then each client had 14 flows open - 7 in one direction 7 in another. Multicasting allows clients to optimize the network load by transferring received streams further to each other within a group.

Posting

All game logic is implemented on the client side, while all instances are both servers and clients at the same time. The so-called self-organizing groups. Clients in the same group communicate over an internal protocol, sending messages to each other with control commands. As in the case of multicasting, posts are also transmitted not from one client to all at once, but by a chain.

Graphics / Code

Graphics are made in Adobe Illustrator (yes, I know, rustic), then transferred to Adobe Flash Catalyst. There, it was turned into components (buttons, lists, custom components), animation was added to them when moving from one state to another, and then all this stuff was transferred to Flash Builder, where the functionality was added

Perspectives


I'm an optimist. I see gigantic prospects for p2p technology in general, and for Flash-p2p in general, and for my game in particular. After some time, I will definitely write off how much money the hosting cost me and how many people played games. In the meantime, I will enjoy life and wait for lucrative offers :)

Summary


I just collected the game today, nobody has ever tested it, so there are a lot of bugs there. Especially for this game there is an opportunity to leave feedback, please use it, I will be very grateful to you. If you like the game - here is a group on Facebook , but on Twitter . Join us, I will be glad to see everyone.

UPD 19:30 Updated both the server and the client - some of the bugs kicked out, took into account some wishes. Update client CTRL + F5 , if you have played before.

Continued: Online video mafia

Source: https://habr.com/ru/post/104498/


All Articles