Options
All
  • Public
  • Public/Protected
  • All
Menu

Class CrosswordDefinition

Crossword definition. Creates a model for a crossword game Based on https://github.com/jweisbeck/Crossword The definition verifies the words and the bounds, ensuring the clues are coherent The instance of the class is a valid model with all the cells of the board @example```typescript let definition = new CrosswordDefinition({ width:5, height:5, acrossClues:[ { number:1, answer:"Hello", x:1, y:2, clue:"A common greeting" } ], downClues:[ { number:2, answer:"World", x:5, y:1, clue:"The earth, together with all of its countries and peoples" } ] });

 @example This example will throw error because the height specified must be 5 ("World" length in this case)
 ```typescript
 let definition = new CrosswordDefinition({
     width:5,
     height:4,
     acrossClues:[
         {
             number:1,
             answer:"Hello",
             x:1,
             y:2,
             clue:"A common greeting"
         }
     ],
     downClues:[
         {
             number:2,
             answer:"World",
             x:5,
             y:1,
             clue:"The earth, together with all of its countries and peoples"
         }
     ]
 });

@example This example will throw error, the position of "World" doesn't match with the acrossClue This is the given coordinates:

    W
 Hello
    r
    l
    d

The 'o' from 'World' doesn't match with 'Hello'

 let definition = new CrosswordDefinition({
     width:5,
     height:5,
     acrossClues:[
         {
             number:1,
             answer:"Hello",
             x:1,
             y:2,
             clue:"A common greeting"
         }
     ],
     downClues:[
         {
             number:2,
             answer:"World",
             x:4,
             y:1,
             clue:"The earth, together with all of its countries and peoples"
         }
     ]
 });

Hierarchy

  • CrosswordDefinition

Implements

Index

Constructors

constructor

Properties

acrossClues

acrossClues: CrosswordClueDefinition[] = []

Across clues

downClues

downClues: CrosswordClueDefinition[] = []

Down clues

height

height: number

Total height of the board

Optional matrix

matrix: CrosswordCell[][]

Matrix with all the cells

width

width: number

Total width of the board

Methods

Protected buildMatrix

toString

  • toString(): string

Generated using TypeDoc