topbanner_forum
  *

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • Wednesday November 6, 2024, 5:29 pm
  • Proudly celebrating 15+ years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Author Topic: DONE: Chaturbate[NSFW site] Game in Javascript  (Read 10964 times)

Asudem

  • Member
  • Joined in 2015
  • **
  • Posts: 132
  • C# data manipulation junkie
    • View Profile
    • Donate to Member
DONE: Chaturbate[NSFW site] Game in Javascript
« on: May 09, 2016, 12:56 AM »
Greetings all,

There is an online adult-entertainment oriented site called Chaturbate. It is where users pay to see webcam models to perform adult related activities by tipping with a virtual currency that the model can redeem for income. The models rely on user created javascript programs to control how much services will cost for an amount of tokens. Most of these programs count up to a goal to which all the users of the video chat room contribute by tipping tokens. However some programs become more complex and interactive, such as tipping certain amounts of tokens to reveal prizes on a keno board. Some even go as far as emulating Battleship. However, I have been approached by a friend of mine who is also a model on the site to create something new and different for her to interact with her fans. I thought consulting the Snack board of DonationCoder might help inspire me to create something using Chaturbate's API.

They even have their own sandbox servers that the apps can be tested on. As always, however, snacks must be specific in their idea requests: I want a basic Cards Against Humanity clone with a slight twist. A user tips an amount determined by the model's input to draw a white card. After so many people have drawn the white cards, a black card and all the white cards are shown to the chat. The chat then votes by tipping an randomly assigned amount to each answer and the amount of votes by the end of a timer countdown wins. The winner is revealed in the DrawPanel along with a randomly selected prize.

Any suggestions or working examples people could post would greatly be appreciated.
If I do it more than 2 times I want to automate it in C#!
« Last Edit: May 22, 2016, 12:35 AM by Asudem »

wraith808

  • Supporting Member
  • Joined in 2006
  • **
  • default avatar
  • Posts: 11,190
    • View Profile
    • Donate to Member
Re: IDEA: Chaturbate Game in Javascript
« Reply #1 on: May 11, 2016, 12:26 PM »
Not a response on your inquiry, but general food for thought on such requests.  It might be better for a more targeted inquiry, and definitely good to mark your link with NSFW.  That is just because it is a mixed audience, and it's good to be mindful of that, more than anything wrong with the fact that you're asking, or the subject matter of it.

This might also be a reason that you might not get the replies that you want, as the usual suspects might not fall into the categories of wanting the tracking on their machine as they work on such a project.

Just an FYI.  Best of luck with your efforts!

Asudem

  • Member
  • Joined in 2015
  • **
  • Posts: 132
  • C# data manipulation junkie
    • View Profile
    • Donate to Member
Re: IDEA: Chaturbate Game in Javascript
« Reply #2 on: May 11, 2016, 12:36 PM »
Not a response on your inquiry, but general food for thought on such requests.  It might be better for a more targeted inquiry, and definitely good to mark your link with NSFW.  That is just because it is a mixed audience, and it's good to be mindful of that, more than anything wrong with the fact that you're asking, or the subject matter of it.

This might also be a reason that you might not get the replies that you want, as the usual suspects might not fall into the categories of wanting the tracking on their machine as they work on such a project.

Just an FYI.  Best of luck with your efforts!

Good call, thank you for that. I've been banging away at some Javascript and as it turns out, if people would like to test their scripts, they can do so in a non-NSFW enviironment here: https://yyanx.github.io/CB-TestBed/

I'm still learning the ins-and-outs of Javascript and boy, I didn't realize how much code you have to compact in order for things to work correctly.

EDIT: Here is my code so far:
Spoiler
//Variables
var setupComplete = false;
var setupTime = 2 * 60 * 1000;
var playCost = 50;
var voteCost = 10;
var voteTime = 5 * 60 * 1000;
var tipTotal = 0;
var winnerFlag = false;
var currentTip = 0; var cbWinner = 'No one yet!'; var lastPrize = 'Nothing';
var players = [{cbuser:cb.room_slug, message: 'Initial Card Setup', index: 1, votes: 0}];
var currentlyPlaying = [cb.room_slug];

//Initialize CAH
function init()

{
     //Initial Notice
     //Let users know the game has started
     cb.chatNotice('Chaturbate Against Humanity has begun!', '', 'gold','red', 'bold', 'lightblue');
     
     //Init Black Card
     setBlack();
     
     //Set Broadcaster Card
     players[0]['message'] = whiteCard();
     
     //Room Enter
     //Inform new users of the current App playing
     cb.onEnter(function(user) {
         cb.chatNotice('Welcome ' + user['user'] + '! We are playing Chaturbate Against Humanity! The rules are as follows:' );
     });
     
     //Timed Setup
     //Users are given X minutes to add a white card
     //cb.setTimeout(Setup, setupTime);
     
     //When User Tips
     cb.onTip(userTipped);
     
     //When User Chats
     cb.onMessage(OnMessage);
     
};

//Set Black Card
//Set the room topic to the CAH Black Card
function setBlack()

{
     //Change Room Subject
     cb.changeRoomSubject('[Black Card] #CAH');
     
};

//Handle Tip
function userTipped(tip)

{
     //Wait for Players
     if (players.length < 2
     )
     {
          //Check for new tip
          //White Card Tip
          if (tip['amount'] >= playCost
          )
          {
               //Add White Card
               //Run addUserCard
               addUserCard(tip['from_user']);   
               
          }
          else
          {
               //NO
          };  //end of IF [White Card Tip]
         
     }
     else
     {
          //Enough Players
          //User Already Played?
          if (cbjs.arrayContains(currentlyPlaying, tip['from_user'])
          )
          {
               //YES
               //Apologize
               cb.sendNotice('Sorry, you are already playing the card: ' + getCard(tip['from_user']) + '. You cannot play more than one card.' , tip['from_user']);
               
          }
          else
          {
               //NO
               //Add card to the new payer
               //Add New Card
               addUserCard(tip['from_user']);   
               
          };  //end of IF [User Already Played?]
         
     };  //end of IF [Wait for Players]
     
     //DEBUG - # Users In Play
     cb.log(players.length.toString());
     
     //DEBUG - List All Players
     
     //Loop Through Players
     for (var i=0;i<players.length;i++
     )
     {
          //Display Players
          cb.log('cbuser: ' + players[i].cbuser + ' message: ' + players[i].message + ' index: ' + players[i].index + ' votes: ' + players[i].votes);
         
     };  //end of FOR [Loop Through Players]
};

//Add White Card
function whiteCard()

{
     //Get Random White Card
     return 'Random Card';
     
};

//drawPanel
function drawPanel(tipTotal)

{
     //TRUE
     if (winnerFlag
     )
     {
          //YES
          //Determine the game's winner
     }
     else
     {
          //NO
          //Just redraw the panel
     };  //end of IF [TRUE]
     
     //Code
     cb.onDrawPanel(function(user) {
         return {
             'template': '3_rows_of_labels',
             'row1_label': 'Tip Received / Goal :',
             'row1_value': tipTotal,
             'row2_label': 'Winner:',
             'row2_value': cbWinner,
             'row3_label': 'Prize Won:',
             'row3_value': lastPrize
         };
     });
     
};

//Get Reward
//Give the user a reward for having the best card.
function getReward()

{
     //TRUE
     if (cbWinner == cb.room_slug
     )
     {
          //YES
          //Looks like the model won this time
     }
     else
     {
          //NO
          //Reward the user for winning!
     };  //end of IF [TRUE]
     
};

//Get User Card
function getCard(user)

{
     //Loop Through Players
     for (var i=0;i<players.length;i++
     )
     {
          //Find the User
          if (players[i].cbuser == user
          )
          {
               //YES
               //Return the Card
               return players[i].message;
               
          }
          else
          {
               //NO
          };  //end of IF [Find the User]
         
     };  //end of FOR [Loop Through Players]
     
};

//On Message
function OnMessage(msg)

{
     //HODOR
     msg.m = 'HODOR';
     
};

//Add User Card
function addUserCard(user)

{
     //Code
     var userMessage = whiteCard();
     var card = {cbuser: user, message: userMessage, index: players.length + 1, votes: 0};
     players.push(card);
     currentlyPlaying.push(user);               
     cb.sendNotice('Your white card is: ' + userMessage, user);
     
};

//Start Chaturbate Against Humanity
//Let's get on with it already!
init();

If I do it more than 2 times I want to automate it in C#!
« Last Edit: May 11, 2016, 03:46 PM by Asudem, Reason: Added code »

Stoic Joker

  • Honorary Member
  • Joined in 2008
  • **
  • Posts: 6,649
    • View Profile
    • Donate to Member
Re: IDEA: Chaturbate[NSFW site] Game in Javascript
« Reply #3 on: May 12, 2016, 06:43 AM »
I thought it was a great project ...(requested purpose aside)... As it's really just an online card game that could be used anywhere depending on how you skin it (no pun intended). But I know nothing of game programming so I'd be useless for anything except maybe testing if that would help.


However TBH - I was a bit reluctant to click the link at work, and I keep forgetting to check into it when I get home.

Asudem

  • Member
  • Joined in 2015
  • **
  • Posts: 132
  • C# data manipulation junkie
    • View Profile
    • Donate to Member
Re: IDEA: Chaturbate[NSFW site] Game in Javascript
« Reply #4 on: May 12, 2016, 10:29 AM »
I thought it was a great project ...(requested purpose aside)... As it's really just an online card game that could be used anywhere depending on how you skin it (no pun intended). But I know nothing of game programming so I'd be useless for anything except maybe testing if that would help.


However TBH - I was a bit reluctant to click the link at work, and I keep forgetting to check into it when I get home.
-Stoic Joker (May 12, 2016, 06:43 AM)
Cards Against Humanity clones do exist, in fact I am hosting one on a server right now with a card expansion specifically related to the Chaturbate site. However, due to the somewhat lucrative nature of the site, people do not wish to venture outside of the confines of "Chaturbate" as there is potential to expose their identities as well as the other site taking time away from the model they are viewing. It's like Las Vegas: what happens on Chaturbate stays on Chaturbate.

I had a really fancy website with a form where users to could interact with the model and fellow users. The site was up and promoted for 2 months straight, with less than a handful of people who joined and no one posted a single post. It just does not work. And also, for security purposes, you can not use external Javascript... that would make my life so much easier as already existing backend APIs exist to the official card databases in pure Javascript.

For those who would simply like to play with Javascript on the site for the pure interest of programming, Chaturbate offers a testbed server. For those who wish to emulate the testbed with multiple users, there is also a private testbed which allows you to act/post/tip as multiple users at once. I have found the private server a little more useful for deugging, but testing on the official testbed to ensure comparability.

UPDATE: Code is too large to post, but here are the rules!

Spoiler
You're a bad person. But that's okay, so are we, so let's laugh a bit, okay?

Chaturbate Against Humanity is a Cards Against Humanity clone with similar rules.

To draw a white card, a user must tip a predefined amount of tokens. The white card is always automatically drawn for the broadcaster, which you can not see.

The broadcaster can choose if the player can see the white card or not, however.

After enough users have played their white cards, the black card is drawn and a vote is cast. The choice with the most votes at the end of a predefined number of minutes wins a prize. If no votes are made when the timer goes off, the broadcaster wins by default.

Prizes and winners are listed in the setup box below the cam's viewing area.

The Setup:

Number of players - Should be obvious. Takes 2 tango, but too many is a crowd.

Tokens to Play - This is not your money maker. This is your bait. Users must pay to play, and it's the only way to win prizes.

Minimum Tokens To Vote - Just because 1 token = 1 vote doesn't mean you should get nickled to death. You can put a minimum bid on white cards by aetting the vote to something high, but not higher than the play cost.

Minutes To Vote - Depends on how full your room is and how juicy your prizes are. Shorter wait makes the game go fast but gives out more prizes.

Can Users See Their White Card - The benefit to let users see their white card: Users can essentially silent auction bid on the prize by voting for their own card using tokens. Enough people in the game, you can get a bidwar going!
The benefit to NOT let users see their white card: If users don't know which card is theirs, they blindly vote for your card or another user's card.
Allows the chance for cheapscates to play to win prizes though.

Enable Grey Play - If enabled, get this, and hear me out here, greys will be able to play the game using the "/vote" command. This allows broadcasters to ineract with the greys in some small way.
Greys are allowed 1 vote (1 token's worth) per round. This can allow the greys to break ties, as well as play in general. Good to entice them to buy tokens and participate.

Prizes - This is where the app really stands out. Up to 10 prizes using percentages and averages. A prize, like a kiss, a smile, or a thank you, should be used in the 90 percentile.
A flash, request, song change, and other smaller prizes should be in the 60 to 50 range. Videos, snapchat, kik, skype should be in the 20 to 30 range.
Password shows, custom videos, and small instant-shows should be in the 10 or less range.

Here is how the caluclation works with an example:
Kiss 90%; Flash 70%; 1 video 60%; 2 videos 40%; snapchat 30%; 5 videos 10%; Password show 1%;

When a prize is called, all the numbers are added up: 90+70+60+40+30+10+1=301

The odds of getting a kiss with this many prizes will be 90 out of 301 (90/301 or 29.9%).
The odds of getting a password show is 1 out of 301 (1/301 or 0.003% making it ULTRA RARE).

So feel free to go nuts with the prizes, you've got 10 slots to work with and you can make prizes as common or as rare as you want.
Make certain prizes ULTRA-COMMON by using the same prize in multiple slots!

Commands:
Users:
/rules - Shows the rules.
/prizes - Shows the prizes.

Boring.

Broadcaster & Mods:
/goal - You can set a countdown goal in addition to the game. Annotation is as follows:
/goal token-amount-in-digits The Title of The Goal here
For example, "/goal 1000 Bra off" will produce a message that says "A new goal of "Bra off" has been set for 1000 tokens"

/changegoal - Same as /goal, but changes the current goal title and amount

/adjust - Mistakes happen. That's probably why most of us were born. But oh well, things can be adjusted.
If someone complains they mis-voted or if they just didn't make a selection when they tipped, you can use the /adjust command.
Annotation is as follows:
/adjust number-of-votes #of-white-card reason
For example, "/adjust 100 1 User forgot to vote" will produce a message that says "The card "Card Text Here" has been adjusted by 100 votes by broadcaster for the following reason: User forgot to vote"
You can also use negative numbers for the vote amount to take away votes. Use this power responsibly.

/addcpu - Find humans to be boring? Need another player but no one is tipping? Use /addcpu to add a computer played card who will win a prize, but it goes to no one.

Broadcaster only:
/debug - You cheeky fucker, you're cheating! Debug mode shows you who has what cards, including your own. Type the command again to disable it.

To-Do List:
-Add a better multi-goal handler
-Add custom black and white cards so models don't have to copy the App's code and edit it to make their own custom decks.
-Better code management of the prizes.
-Add auto distribution of prizes such as usernames directly to the user who won without having to PM the user.
-Handle bots that assign emojis to users properly


Sad Edit: Just because you understand the game, it's rules, and how it works does not mean everyone else will. Playtesting has a 100% failure rate, no one likes the complexity and are frustrated they can't understand how it works.

Preview:
playing_with_myself.pngDONE: Chaturbate[NSFW site] Game in Javascript
If I do it more than 2 times I want to automate it in C#!
« Last Edit: May 18, 2016, 02:54 AM by Asudem »

Asudem

  • Member
  • Joined in 2015
  • **
  • Posts: 132
  • C# data manipulation junkie
    • View Profile
    • Donate to Member
Re: DONE: Chaturbate[NSFW site] Game in Javascript
« Reply #5 on: May 22, 2016, 12:37 AM »
I'm going to mark this snack as done. What I coded serves my initial purposes, even if no one will use it. Bot's source is located here (Link contains no NSFW).
If I do it more than 2 times I want to automate it in C#!