Rails Two players card game - ruby-on-rails

I need to implement a card game between two players. A player clicks "bet" button, then a game appears in queue list and another player clicks "join" button, and then the game starts. Technologies I use include Rails 4, websocket-rails, jQuery. What I'm confused about is how to show each player their own cards and to not show the opponent's cards on the board. What technique is being used for this purpose? I think I should use internal websocket-rails' connection_store method to store players' cards, but I'm not sure how to work with it later in game and how to store each player's cards in variables
Has anybody here have this kind of experience with websocket-rails? Any advice?

I'm not sure but you could create uniq chanel for each user and send specific data to this chanel (like data about user cards). Also you could create second broadcast chanel for concrete game, when just joined users could send messages to it, and there you could put data accessible for all users in game. About connection_store you could look DataStore.
About dealing cards, you should have some pack of cards (36 cards) and when game is started you can randomly select few cards (depends on game) for each user, also each user connected to game has his own unique chanel to which you can put these cards, in broadcasting chanel you can put some game data (like how many players, who should run first, etc.) if user makes some action you can trigger it and send data to server (like put card on the table) then you send to broadcast chanel this public action, and give ability for other user do someting else. Jquery on one client shouldn't know about which cards other client has. All actions between user go through the server.

Related

How to implement webRTC for iOS mobile app creating 1 to 1 Call (Video and Audio)?

I am developing an iOS Video application with webRTC, I have developed application for room video call as i got a demo named AppRTC.
But the problem is, we can connect if and only if we know the room name.
Any help and suggestion for creating 1-1 Video with webRTC.
Actually, i am not getting the proper way to create Signaling between two users.
I want to develop video call like Whatsapp,facebook and Hangout one to one video call.
I have followed this AppRTC Demo Code On GitHub demo code.
You can implement a WhatsApp-style video call between two users using the "room" approach behind the scenes.
Let's say that User 1 wants to call User 2.
The app running on User 1's device generates a random room name and joins that room.
User 1's app also communicates the room name to User 2's device.
The app on User 2's device shows an incoming call alert.
If User 2 taps the Answer button, the app joins the room and the call with User 1 starts.
The actual room name used for the call doesn't need to be shown to any of the users.
If you want to create 1 to 1 video call you should build your own signaling mechanism.
What I mean by signaling mechanism is basically sending SDPs to each other.
You can find some useful info here

iOS Google Play Games SDK - How to invite friends to social circles?

Apple's Game Center has really gone down the toilet recently so I'm adding support for Google Play Games leaderboards and achievements to my iOS games. I'm displaying the leaderboards myself by downloading the scores using the GPGLeaderboard class. There's a property called "social" that lets me download the scores of friends - "A social leaderboard is a public leaderboard filtered by people within the local player's circles." Is there an API that will let me invite other players to my game so I can see them in these social leaderboards? I'm not sure how people are supposed to set up these social circles?
Check this documentation: Starting a real-time multiplayer game.
Invite players button. Lets the user invite friends to join a game session or specify some number of random opponents for auto-matching. When the player selects this option, your app should display either the built-in player selection user interface (UI) provided by the SDK or a custom UI for player selection.
You might also want to check on this GPGLeaderboard Class Reference wherein leaderboard objects must be created with a leaderboard ID. Once a leaderboard object is created, you may interact with it using the provided set of actions.

Twilio: how to detect which participant is speaking in a conference

I'm working on to implement an audio-only conference app which is something like Google Hangout, but without video.
In Google Hangout, all participants can see which participants is currently speaking, via visual feedback. In other words, when someone starts speaking, their avatar comes foreground of all of participants immediately.
So, here's my questions for Twilio and its client SDKs:
Is there any way to detect current speaker (and give some feedback to users) ?
Is there any way to get input level of a microphone via the SDKs?
Interesting use cases .
I think both these can be achieved with Twilio and here's my views on how to achieve these
Detecting current speaker
What you essentially require is a flag that is globally shared across all participants. This flag should have the facility to be dynamically updated in real time by the speaker who is speaking and at the same time push this information , again in real time , to other participants. So , simply put , you want a shared resource where each Twilio Client can 'publish' and 'subscribe' their 'speaking' state. You could achieve it via Twilio Sync .
To do that , you could create a list object on Sync and add each participants whose audio level goes above a certain level that you consider them speaking . All Client instances in the conference should be subscribed to this list and so on 'itemAdded' or 'itemRemoved' each instance of client can get a list of participants who are speaking . Based on it , UI changes could be done.
You can get audio level (output and input) at each client instance by querying Twilio Voice Insights .For Audio input level , you will have the value passed in parameter named AudioLevelIn .
Note : Both these products require requesting access .

CloudKit and GameCenter in a game?

I am working on a game. It will use Game Center for multiplayer. I would like to be able to use CloudKit for storing levels and the local CloudKit container for storing game progress. The problem is that this requires to different accounts. Any ideas on how to link them together?
I struggled with this recently when building in syncing to my game Qiktionary. At first I associated single player game data with the currently logged in Game Center player. So when I started working on sync, I was associating the single player game data in CloudKit with the Game Center player by using a separate CKRecordZone (in the private db) for each Game Center player.
I ended up abandoning that approach because it turns out that causes some behaviour that looks to the user like data loss. For example, GC Player A is logged into your game and plays 10 single player games (or in your case, levels). Later they happen to log out of Game Center, and even later than that they come back to your game and since they are logged out, they no longer see their 10 games played. It's not obvious that the game data is there but just "missing" because they are now logged out of GC.
I did some research and most other games don't work like that. Single player game progress is not linked to the logged in Game Center player. Which means that the single player game data in CloudKit shouldn't be linked to the Game Center player either.
This is even how the GKSavedGame API from GameKit works. According to the docs:
Saved games are tied to the iCloud account, not the Game Center account

Chat between players in Game Center turn based match

I am trying to create a turn based game using Game Center. I wanted to know if it is possible to allow the players in the match to chat between each other (either voice or text).
I have looked into it a little and seems that it is possible via the normal game but not a turn based one.
If it is not possible what are the solution or ways to allow this type chat?
Yes, you can have text chat the following way:
Without ending the turn, update the matchData object on the GKTurnBasedMatch. The updated NSData will be provided to all players that open your app and are participants in the game. So, your matchData object would have to carry both the game state and the chat state. Unfortunately, I do not see how one could trigger user notifications or badge the app for new chats without having to end the player's turn each time.

Resources