springroll.pbskids.KartKingdom Class

The wrapper for talking to the Kart Kingdom Minigame API.

Constructor

springroll.pbskids.KartKingdom

(
  • config
)

Parameters:

  • config Object

    The configuration

    • gameId String

      GUID for your minigame provided by your PBS KIDS content manager

    • elementId String

      A string value of the ID of your game's containing element; presumably a div element which wraps your games canvas element.

    • [options] Object optional

      A configuration object which allows developers to configure the notification bubble's position and animation timing.

      • [dock] String optional
        "TR", "TL", "BL", "BR"
      • [enable_notifications] Boolean optional
      • [hide_notification_delay] Int optional
      • [fade_notification_duration] Int optional
      • [slide_notification_duration] Int optional

_onLevelClosed

(
  • event
)
private

Defined in _onLevelClosed:298

Handler for the bellhop event

Parameters:

_onLevelOpen

(
  • event
)
private

Defined in _onLevelOpen:281

Handler for the bellhop event

Parameters:

_onLevelReset

(
  • event
)
private

Defined in _onLevelReset:315

Handler for the bellhop event

Parameters:

_onMinigameReady

(
  • event
)
private

Handler when the game is ready

Parameters:

_onResourcesComplete

(
  • event
)
private

Handler when the resources are complete

Parameters:

_onResourcesEarned

(
  • event
)
private

Handler when the resources are earned

Parameters:

destroy

()

Defined in destroy:193

Destroy the API connection

event

(
  • guid
)

Defined in event:87

Called by the producer mini-game whenever the player has accomplished something in the minigame in which they should receive a reward for the virtual world. Upon obtaining a reward, a notification will slide-down over the game in the top-right corner. This notification fades away after 2 seconds.

Parameters:

  • guid String

    is the guid string, e.g. "ccc006dc-012e-49d0-8b32-35d70df206e9", for the event/task/item which the user has completed/performed/found which should earn them a reward in/for the virtual world. To generate events for your mini-game and receive the guids for those events please contact your PBS KIDS content manager.

hasPowerUp

(
  • type
  • callback
)

Defined in hasPowerUp:104

Checks if a player is in possession of the requested powerup. Returns false or the integer quantity of how many of the requested powerup the player possesses.

Parameters:

  • type String

    the name of the powerup to check, e.g. "rabbit".

  • callback Function

    Payload is a either an Integer or boolean false.
    Integer -- the current amount of the powerup which the user has. Return 0 if unlocked but depleted (or not yet acquired).
    Boolean -- false, if the powerup has not been unlocked by the player.

init

(
  • container
  • done
)

Defined in init:60

Initialize the API

Parameters:

  • container Bellhop

    The container bellhop instance

  • done Function

    When we're done

levelComplete

()

Defined in levelComplete:172

Called by the producer mini-game when the player has completed a level/game, lost, or the game is otherwise over. Upon calling this method 1 of 3 will appear over your minigame:

  1. If the player is not logged in, then they will see a screen with a link to the virtual world and the message, "You could be earning cool stuff for the new virtual world, Kart Kingdom!"

  2. If the player is logged in but has never played in the virtual world, then they will see a screen with the message, "You could be earning cool stuff for the new virtual world, Kart Kingdom! Come play with other kids!"

  3. If the player is logged in and has played in the virtual world before, then:

    • a. If they earned any rewards during this game session, then they will see a list of of the new rewards they earned.

    • b. If they did not earn any rewards during this game session, then no screen will appear.

usePowerUps

(
  • powerupsObject
  • onSuccessCallback
  • onFailureCallback
)

Defined in usePowerUps:122

Consumes the requested powerup in the quantities listed for each in the powerupsObject object. Upon validating that the user has all of the powerups in the required amounts, the api will then make an ajax request to the virtual world to remove (consume) the powerups. The user has successfully consumed the powerups ONLY when the request to the virtual world returns a 200 OK response; upon receiving this response the onSuccessCallback function is called to notify the minigame of the success.

Parameters:

  • powerupsObject Object

    Object which lists the powerups to consume and in what amounts. The key-value pairs for each item in the object are the powerup's name as the key and the quantity to consume as the value, e.g. { "water" : 3, "rainforest-map" : 1 }.

  • onSuccessCallback Function

    A callback method to call when the virtual world backend successfully consumes the powerups for the user and the user is good to continue in the game.

  • onFailureCallback Function

    A callback method to call when the ajax request to the virtual world to consume the powerups fails or otherwise does not allow the user to consume the requested powerups.

config

Object

Defined in config:37

The configuration

container

Bellhop

Defined in container:31

Reference to the container instance

enabled

Boolean

Defined in enabled:43

If this API is enabled

Default: false

levelClosed

Defined in levelClosed:306

Defines the value of a LevelCompleteClosed event. This event is fired when the level complete overlay is closed by the user. The payload for this jQuery event object has no additional game data.

levelOpen

Defined in levelOpen:289

Defines the value of a LevelCompleteOpen event. This event is fired when the .levelcomplete() method is called and the level complete overlay opens. The payload for this jQuery event object has no additional game data.

levelReset

Defined in levelReset:323

Defines the value of a LevelReset event. This event is fired when the player stats have been reset and the enabled state of the notification bubble has been reset to it's initial value. The payload for this jQuery event object has no additional game data. This event occurs,

  • after the level complete overlay has been closed by the user and after the LevelCompleteClosed event has fired, or
  • after the .levelComplete() method is called, the user is logged in with virtual world access, and the user has NOT earned any resources/rewards for this level. This would result in a level reset to occur upon calling the .levelComplete() method and bypassing the level complete display.

ready

Defined in ready:223

Defines the value of a MinigameReady event. This event fires when a minigame instance has completed instantiation; this includes having validated the environment, checked if a user is logged in, and checked if the user has access to the virtual world. If this event is fired prior to adding an eventlistener for it, then the handler (2nd parameter) passed to the addEventListener() method will be called immediately upon event binding with a payload similar to the original event payload.

Event Payload:

  • isLoggedIn Boolean

    value stating if there is a user currently logged into pbskids.org

  • hasPlayedVirtualWorld Boolean

    value stating if the logged in user has accessed the virtual world before and has granted the virtual world access to their pbskids.org account.

resourcesComplete

Defines the value of a ResourceRequestComplete event. This event fires every time a request to the rewards api has completed and either returned a response with a rewards payload, no payload, of if the requests somehow failed and could not complete. Ideally, this event should fire for each .event() call made. The payload for this jQuery event object has no additional game data.

resourcesEarned

Defined in resourcesEarned:247

Defines the value of a ResourcesEarned event. This event is fired when a player has earned resources/rewards from the virtual world's rewards system. This event ONLY occurs if a .event() call results in rewards for that player. If a .event() call is made where the potential reward is a limited resource and the player has met that limit, then the player will not earn a reward/resource and this event will not fire.

Event Payload:

  • resources Object

    An object listing the resources earned from the previous game event. Has the form { resourceName : quantityEarned, resourceName2 : quantityEarned2 }, e.g. { tools : 1 , water : 3 }.