The wrapper for talking to the Kart Kingdom Minigame API.
springroll.pbskids.KartKingdom
config
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.
_onLevelClosed
event
Handler for the bellhop event
event
Object
Bellhop event
_onLevelReset
event
Handler for the bellhop event
event
Object
Bellhop event
_onMinigameReady
event
Handler when the game is ready
event
Object
Bellhop event
_onResourcesComplete
event
Handler when the resources are complete
event
Object
Bellhop event
_onResourcesEarned
event
Handler when the resources are earned
event
Object
Bellhop event
event
guid
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.
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
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.
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
Initialize the API
container
Bellhop
The container bellhop instance
done
Function
When we're done
levelComplete
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:
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!"
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!"
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
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.
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.
levelClosed
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
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
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,
ready
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.
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
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.
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 }
.