Mini-games

This page describes the various **mini-games** that are available in Essentials.

## Lottery

A random number between 0 and 65535 is generated, and is then compared to the OT ID numbers of every Pokémon the player currently owns (both in their party and in their storage boxes, but not in the Day Care). Each digit is compared in turn, starting with the least significant and working backwards (i.e. the number 12345 is compared in the order 5-4-3-2-1). Digits stop being compared if a pair don't match (i.e. the numbers 12345 and 12305 only match 1 digit).

The player wins a prize which depends on the number of digits matched.

The game is played using the following two scripts:

```
pbSetLotteryNumber(1)
pbLottery(pbGet(1), 2, 3, 4)

```

The first script generates a random number and saves it to the Game Variable given as an argument (1). The method used here chooses the number based on the current day, month and year, so that the number is the same regardless of when in a given day it is done. This is the winning number for that day.

The second script takes the winning number from the Game Variable it was stored in (1), and compares it with the OT ID numbers of every Pokémon the player owns. The name of the highest-matched Pokémon is stored in Game Variable 2, its location (party=1, storage=2) in Game Variable 3, and the number of digits matched in Game Variable 4.

The rest of the Lottery game's event involves checking how many digits were matched, and rewarding the player with the appropriate prize (if any).

## Duel

This mini-game is a sumo-like game played between the player and an NPC trainer.

The two competitors start with 10 HP each. Each round, both competitors choose an action ("Defend" or one of three kinds of attack). Depending on the choices, one, both or neither competitor loses some HP. The first competitor to reach 0 HP loses.

Duel is played by using the following scripts:

```
$speeches = ["I shall block all your attacks!",
             "Nothing can pierce my armor!",
             "Behold my dodging skills!",
             "I'll show you my fighting skills!",
             "Awe at the perfection of my skills!",
             "I'll deliver a perfect blow!",
             "Feel my power!",
             "AAAAHHHH!",
             "I'll attack with all my strength!",
             "Face my secret technique!",
             "This is my secret technique!",
             "Evil Blade Strike!"]
pbDuel(:LEADER\_Brawly, "Brawly", get_self, $speeches)

```

The speeches are arranged in the following order: 3 for defense, 3 for precise attacks, 3 for fierce attacks, and 3 for special attacks. The script that runs the duel itself should be put in a Conditional Branch.

Note that the opponent must use a defined trainer type (because its graphic is shown during the duel), although there doesn't need to be an actual trainer defined for them. The highlighted parts (as well as the speeches if desired) are the only parts you should change.

The player and the NPC will move around a little during the duel, so make sure there is space for them to do so.

## Triple Triad

*Main article: Triple Triad*
This is a Pokémon-themed version of the Triple Triad card game from the "Final Fantasy" game series.

Each card represents a Pokémon, and that Pokémon's base stats determine the strength of the card on each side. Cards are placed into a 3x3 grid, and stronger cards convert adjacent weaker cards to their own colour. The player who has the most cards of their colour on the board at the end is the winner

## Slot Machine

This is a basic slot machine mini-game, found in the various Game Corners of the early Pokémon games.

The player first inserts 1, 2 or 3 coins, and starts the reels spinning. They stop the reels, and if any winning combinations have lined up, the machine pays out some coins depending on which combination(s) were made. The more coins the player wagers, the more rows they have in which to line up the symbols.

When stopping each reel from spinning, the reel can slip a couple of places, which makes it harder to accurately time matches. By lining up 3 Replay symbols, an extra free game is immediately played with all rows usable and no reel slipping. There are no other special features in the Slot Machine (such as bonus rounds).

The Slot Machine is played by using the following script:

```
pbSlotMachine

```

This can have an argument of either 0, 1 or 2, which roughly correspond to easy, medium and hard difficulty (default is 1). All this does is change which symbols appear on each reel.

You must have a Coin Case in your inventory, as well as at least 1 coin but less than the maximum number of coins you could have, to play the Slot Machine.

## Voltorb Flip

This mini-game is from the international versions of Pokémon HeartGold and SoulSilver. In Voltorb Flip, the player can never lose coins (the worst they can do is not gain any coins).

The player is presented with a 5x5 grid of tiles, where each tile is either a 1x, 2x or 3x multiplier or a Voltorb. Each row and column shows the number of Voltorbs in it, as well as the sum of the multiplier tiles in it. The player flips over one tile at a time, and their score is multiplied by the tile they flipped over. Upon revealing all the 2x and 3x multipliers on a board, the player gains coins equal to their score for that board. Flipping over a Voltorb means that board is lost, and no coins are gained. The more boards the player plays, the harder the game becomes but the more coins they can win.

Voltorb Flip is played by using the following script:

```
pbVoltorbFlip

```

You must have a Coin Case in your inventory, as well as at least 1 coin but less than the maximum number of coins you could have, to play Voltorb Flip.

## Mining

*Main article: Mining mini-game*
This mini-game is found in Pokémon Diamond, Pearl and Platinum, and involves knocking away at rocks to reveal buried items.

The player has a choice of two digging tools to use: the pick (weaker and lighter) and the hammer (stronger and heavier). Random items are buried under layers of dirt and rock, and if they are completely excavated, the player gets to keep them. There is a message at the beginning of the game to say how many items are buried. Iron blocks are also buried, which hinder excavation. Using the digging tools too much will cause a small cave-in and end the game immediately; this is denoted by a crack graphic at the top of the screen growing larger.

This game does *not* contain any buried spheres (which act as currency in Pokémon DPPt's Underground), as they are not real items and would serve no purpose in Essentials.

The mining game is played by using the following script:

```
pbMiningGame

```

It is recommended that the player is somehow restricted in when they can play this game, as it yields useful/expensive items for no cost.

## Tile Puzzles

A board and tiles are presented to the player, who must place or rearrange the tiles in some way to form a picture.

There are seven variants of this mini-game, which are as follows:

1. **Ruins of Alph** - Place tiles in the correct places to form the image. Pick up/swap/place tiles with the Use key. The classic Unown-related puzzle from the Johto games.
2. **Ruins of Alph Rotator** - The same plus each tile can be rotated with the Action key.
3. **Mystic Square** - A 15 puzzle.
4. **Tile Swap** - Swap two adjacent tiles. Hold the Use key while selecting the first tile and press the direction to swap it in.
5. **Tile Swap Rotator** - The same plus each tile can be rotated with the Action key.
6. **Rubik's Square** - Shift an entire row or column of tiles at once. The rows and columns loop round on themselves. Hold the Use key while selecting a tile in the desired row/column and press the direction to shift it in.
7. **Star Rotator** - Rotate a tile with the Use key, and all adjacent tiles rotate at the same time.

A tile puzzle is played by using the following script:

```
pbTilePuzzle(1, "Kabuto")

```

The number is which puzzle variant to play, as listed above. The word is the name of the graphics to use; this example uses the graphics named "tilesKabuto.png" and "bgKabuto.png". If there is no background of the required name, then "bg.png" will be used instead. All graphics are in the folder "Graphics/Pictures/Tile Puzzle".

The script returns TRUE if the puzzle was solved, and FALSE if the player quit without solving it. All puzzles are solvable, although some are harder than others.

The default puzzles use a grid of 4x4 tiles. You can use a different grid by adding its width and height as extra arguments like so:

```
pbTilePuzzle(1, "Kabuto", 5, 6)

```

This example uses a 5x6 grid. Note that some puzzles don't support certain grids (e.g. the Alph puzzles don't support grids whose width is an odd number, and no puzzles involving rotation support grids which make the tiles not square). The default tile graphics are all for 4x4 grids, so you would need to make your own graphics in order to use different grid sizes.

## Tips

* The Slot Machine and Voltorb Flip are both stand-alone applications, and as such could be turned into apps for the Pokégear.
	+ The Lottery game could also be turned into an app, at least the number-checking part (the player would still need to go somewhere in order to collect their prize). It would require a bit more effort, though.
	+ Triple Triad could also be turned into an app, but again would require some more effort in order to set up appropriate (ostensibly computer-type) opponents to play against.