Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

blooket.js

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

blooket.js - npm Package Compare versions

Comparing version 0.2.0 to 0.2.1

31

blooket.js

@@ -13,3 +13,3 @@ const ws = require('ws');

/**
* @constructor - The contructor to the Blooket.JS class
* @constructor - blooket
* @param {object} options - The Blooket.JS options. Currently, you can use "repeat, true/false, default true". Must be a JSON object.

@@ -23,2 +23,4 @@ */

this.options.repeat = options.repeat || true
// Cafe Mode Only Option
this.options.cafebonus = options.cafebonus || 50
// All Game Modes

@@ -44,2 +46,7 @@ this.questions = null

}
/**
* @param {number} pin - The game pin
* @param {string} name - The client's name
* @param {string} animal - The client's animal picture
*/
async join(pin, name, animal) {

@@ -74,2 +81,5 @@ await socketcheck(pin).then((socket) => { this.socket = new ws(socket.url)})

}
/**
* Sends the player information to the websocket
*/
connect() {

@@ -82,2 +92,5 @@ return new Promise((resolve,reject) => {

}
/**
* Starts the question, changes the question index for the next question
*/
async startquestion() {

@@ -93,2 +106,5 @@ this.socket.removeAllListeners()

}
/**
* @param {number}
*/
async answer(a) {

@@ -107,5 +123,12 @@ console.log("Answering Question: " + this.CurrentIndex)

})
} else if (this.mode == "cafe") {
this.cash += this.options.cafebonus
this.socket.send(`{"t":"d","d":{"r":1,"a":"p","b":{"p":"/${this.pin}/c/${this.name}","d":{"b":"${this.animal}","ca":${this.cash}}}}}`)
game.emit("NextQuestion")
}
}
}
/**
* @param {number} - The prize to open
*/
async getgold(p) {

@@ -131,2 +154,5 @@ await goldHandler(p, this).then((e) => {

}
/**
* @param {string} - The player to swap from
*/
swap(player) {

@@ -148,2 +174,5 @@ var targetanimal = this.steal[0][player].b

}
/**
* @param {string} - The player to steal from
*/
rob(player) {

@@ -150,0 +179,0 @@ var target = this.steal[0][player]

@@ -0,1 +1,5 @@

/**
* @param {number} answer - The answer to send
* @param {object} self - The client
*/
function answerHandler(answer, self) {

@@ -2,0 +6,0 @@ return new Promise(async(resolve, reject) => {

@@ -0,1 +1,5 @@

/**
* @param {object} self - The client
* @returns {Promise} - Returns a promise containing the set, and the game data
*/
async function getdata(self) {

@@ -2,0 +6,0 @@ return new Promise((resolve,reject) => {

@@ -0,1 +1,4 @@

/**
* @returns {array} - Returns an array containing 3 random prizes.
*/
function goldchance() {

@@ -2,0 +5,0 @@ return new Promise((resolve,reject) => {

@@ -0,1 +1,6 @@

/**
* @param {number} p - The prize number
* @param {object} self - the client
* @returns {array} - Returns an array containing the players (optional), the cash or percent of cash for an action, and the action to perform
*/
function goldHandler(p, self) {

@@ -39,2 +44,6 @@ return new Promise(async(resolve,reject) => {

}
/**
* @param {object} self - the client
* @returns {promise} - Returns a promise with a list of players with there animal and score.
*/
function getPlayers(self) {

@@ -41,0 +50,0 @@ return new Promise((resolve, reject) => {

@@ -0,1 +1,5 @@

/**
* @params {object} data - The websocket data received
* @params {object} self - The client
*/
function message(data, self) {

@@ -2,0 +6,0 @@ if (data == `{"t":"d","d":{"b":{"p":"${self.pin}/c/${self.name}","d":null},"a":"d"}}`) {

@@ -0,1 +1,6 @@

/**
* @params {number} id - The game ID, used for retreived question data
* @returns {promise} - returns a promise containing the game question data
* @requires got
*/
const got = require('got')

@@ -9,2 +14,2 @@ function questions(id) {

}
module.exports = questions
module.exports = questions

@@ -0,1 +1,6 @@

/**
* @params {number} pin - The game PIN
* @requires ws
* @returns {promise} Returns a promise containing the websocket use for the game.
*/
const WebSocket = require('ws');

@@ -2,0 +7,0 @@ function socketcheck(pin) {

2

package.json
{
"name": "blooket.js",
"version": "0.2.0",
"version": "0.2.1",
"description": "This is a terminal client for the quiz service known as Blooket",

@@ -5,0 +5,0 @@ "main": "blooket.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc