Data-ChipsChallenge

 view release on metacpan or  search on metacpan

README.md  view on Meta::CPAN

Give it a data structure in the same format as getCloneMachines. Ex:

    $cc->setCloneMachines (113, [
      {
        button => [ 25, 13 ],
        clone  => [ 16, 32 ],
      },
    ]);

## getMovement (int LVL\_NUMBER)

Get all the coordinates of every creature in the level that "moves".
Returns an arrayref of coordinates in the following format:

    [
      [ X, Y ],
      [ X, Y ],
      ...
    ];

## setMovement (int LVL\_NUMBER, arrayref MOVEMENT)

Define the movement coordinates. Give this method a similar data structure
to what getMovement returns: an arrayref of arrays of X/Y coordinates.

Each coordinate given should point to a tile where a creature has been placed
in order for that creature to move when the map is loaded in-game. Any creature
that doesn't have its position in the Movement list won't move at all and will
stay put. This isn't very fun.

```
$cc->setMovement (133, [
  [ 25, 25 ],
  [ 25, 26 ],
  [ 25, 27 ],
]);
```

# INTERNAL METHODS

## process\_map (int LVL\_NUMBER, bin RAW\_BINARY) \*Internal

Used internally to process the `RAW_BINARY` map data, which possibly belongs to
`LVL_NUMBER`, and returns a 2D array of the 32x32 tile grid. The grid consists
of uppercase hexadecimal bytes that represent what is on each tile.

If the length of `RAW_BINARY` is not 1024 bytes, your program WILL crash. This
shouldn't happen on a valid CHIPS.DAT file (if Chip's Challenge won't accept it,
that's an indicator that this Perl module won't either).

## compress\_map (grid MAP\_DATA)

Given the 2D grid `MAP_DATA`, the map is compressed and returned in raw binary.

## decode\_password (bin RAW\_BINARY)

Given the encoded level password in raw binary (4 bytes followed by a null byte),
this function returns the 4 ASCII byte password in clear text. This is the password
you'd type into Chip's Challenge.

Passwords are decoded by XORing the values in the raw binary by hex `0x99`,
if you're curious.

## encode\_password (string PASSWORD)

Given the plain text password `PASSWORD`, it encodes it and returns it as
a 5 byte binary string (including the trailing null byte).

## random\_password

Returns a random 4-letter password.

# REFERENCE

The following is some reference material relating to certain in-game data
structures.

## Option Fields Max Length

If the "Option Fields" are more than 1152 bytes altogether, Chip's Challenge
will crash when loading the level. The "Option Fields" include the following:

    Map Title
    Bear Trap Controls
    Cloning Machine Controls
    Map Password
    Map Hint
    Movement

Bear Trap Controls use 10 bytes for every link. Cloning Machine Controls use
8 bytes for every link. Map passwords use 7 bytes. Movement data uses 2 bytes
per entry.

In addition, bear traps, clone machines, and movement data use 2 bytes in
their headers.

## Object Hex Codes

The two map layers on each level are 2D arrays of uppercase hexadecimal codes. Each of
these codes corresponds to a certain object that is placed at that location in the map.
This table outlines what each of these hex codes translates to, object-wise:

    00 Empty Tile (Space)
    01 Wall
    02 Computer Chip
    03 Water
    04 Fire
    05 Invisible Wall (won't appear)
    06 Blocked North
    07 Blocked West
    08 Blocked South
    09 Blocked East
    0A Movable Dirt Block
    0B Dirt (mud, turns to floor)
    0C Ice
    0D Force South (S)
    0E Cloning Block North (N)
    0F Cloning Block West (W)
    10 Cloning Block South (S)
    11 Cloning Block East (E)
    12 Force North (N)



( run in 0.548 second using v1.01-cache-2.11-cpan-39bf76dae61 )