Difference between revisions of "Template:Chess from pgn/doc"

From blackwiki
Jump to navigation Jump to search
imported>Pppery
imported>Pppery
(Document use of lua)
Line 1: Line 1:
 
{{documentation subpage}}
 
{{documentation subpage}}
 +
{{lua|Module:Chess from pgn}}
 
{{Uses TemplateStyles|Template:Chess from pgn/styles.css}}
 
{{Uses TemplateStyles|Template:Chess from pgn/styles.css}}
 
This template takes [[Portable Game Notation]], aka "pgn", or, optionally, just the [[Algebraic notation (chess)|Algebraic notation]] part of the pgn, and a list of positions, and generates a series of {{tl|Chess diagram}}s.
 
This template takes [[Portable Game Notation]], aka "pgn", or, optionally, just the [[Algebraic notation (chess)|Algebraic notation]] part of the pgn, and a list of positions, and generates a series of {{tl|Chess diagram}}s.

Revision as of 21:14, 28 April 2019

Script error: No such module "Uses TemplateStyles". This template takes Portable Game Notation, aka "pgn", or, optionally, just the Algebraic notation part of the pgn, and a list of positions, and generates a series of {{Chess diagram}}s.

Parameters

  • pgn = - Mandatory parameter, containing the pgn or the algebraic notation of the game. No in-notation comments are allowed. If original pgn contains comments, they must be removed.
  • Series of move = parameters, determining which positions will be displayed, using the {{Chess diagram}} template. The value of this parameter will be passed to the diagram as "footer". Each move is in the form of <number>l or <number>d, for position after white move or after black move, e.g.
    • 12l = position after 12. Nxg6 : white captures with Knight
    • 12d = position after 12... fxg6: black captures Knight with pawn

An alternative way to display positions, showing a series of consecutive positions, is:

  1. from1 =
  2. to1 =
  3. comments1 = {text} {text} {text} ...

Where "from1" is the first position to display, and "to1" is the last, (again, using "17l" or "13d" notation), and "comments1" is the series of footer text, each enclosed in { ... }, to be displayed as footer to each position in the series.

Multiple series of positions can be requested, using "from2/to2/comments2" and so on. Note that requesting the same position multiple times, i.e., requesting it both as individual position and as part of a series, or using 2 series with some overlap, will result in displaying the same position more than once.

Regardless of the order and method the positions were requested, they will be displayed in the game's order - 12d always before 13l.

  • display notation = optional parameter, tells the template to display the parameter passed as "pgn", below the diagrams.

Example

{{Chess from pgn
| 12l = position after 12. Nxg6 : white captures with Knight
| 12d = position after 12... fxg6:  black captures Knight with pawn
| 27d = position after 27... Bxa4 
| display notation = yes
| pgn = 
1. d4 Nf6 2. c4 e6 3. Nc3 Bb4 4. Nf3 c5 5. e3 Nc6 6. Bd3 Bxc3+ 7. bxc3 d6 8. e4
e5 9. d5 Ne7 10. Nh4 h6 11. f4 Ng6 12. Nxg6 fxg6 13. fxe5 dxe5 14. Be3 b6 15.
O-O O-O 16. a4 a5 17. Rb1 Bd7 18. Rb2 Rb8 19. Rbf2 Qe7 20. Bc2 g5 21. Bd2 Qe8
22. Be1 Qg6 23. Qd3 Nh5 24. Rxf8+ Rxf8 25. Rxf8+ Kxf8 26. Bd1 Nf4 27. Qc2 Bxa4
}}

will display:

1. d4 Nf6 2. c4 e6 3. Nc3 Bb4 4. Nf3 c5 5. e3 Nc6 6. Bd3 Bxc3+ 7. bxc3 d6 8. e4 e5 9. d5 Ne7 10. Nh4 h6 11. f4 Ng6 12. Nxg6 fxg6 13. fxe5 dxe5 14. Be3 b6 15. O-O O-O 16. a4 a5 17. Rb1 Bd7 18. Rb2 Rb8 19. Rbf2 Qe7 20. Bc2 g5 21. Bd2 Qe8 22. Be1 Qg6 23. Qd3 Nh5 24. Rxf8+ Rxf8 25. Rxf8+ Kxf8 26. Bd1 Nf4 27. Qc2 Bxa4


Same game. Using from...to syntax (12l to 14d, plus disjoint position 27d), not defining "display notation"
{{Chess from pgn
| from1 = 12l 
| to1 = 14d
| comments1 = { position after 12. Nxg6 } { position after 12... fxg6 } { position after 13. fxe5 } { position after 13... dxe5 } { position after 14. Be3 } { position after 14... b6 }
| 27d = position after 27... Bxa4
| pgn = 
1. d4 Nf6 2. c4 e6 3. Nc3 Bb4 4. Nf3 c5 5. e3 Nc6 6. Bd3 Bxc3+ 7. bxc3 d6 8. e4
e5 9. d5 Ne7 10. Nh4 h6 11. f4 Ng6 12. Nxg6 fxg6 13. fxe5 dxe5 14. Be3 b6 15.
O-O O-O 16. a4 a5 17. Rb1 Bd7 18. Rb2 Rb8 19. Rbf2 Qe7 20. Bc2 g5 21. Bd2 Qe8
22. Be1 Qg6 23. Qd3 Nh5 24. Rxf8+ Rxf8 25. Rxf8+ Kxf8 26. Bd1 Nf4 27. Qc2 Bxa4
}}

will display:

Test