https://en.wikipedia.org/w/index.php?action=history&feed=atom&title=Module%3AShogi_diagram%2Fsandbox
Module:Shogi diagram/sandbox - Revision history
2025-06-09T10:10:41Z
Revision history for this page on the wiki
MediaWiki 1.45.0-wmf.4
https://en.wikipedia.org/w/index.php?title=Module:Shogi_diagram/sandbox&diff=1101116234&oldid=prev
Techie3: Undid revision 1101116102 by Techie3 (talk)
2022-07-29T11:19:59Z
<p>Undid revision 1101116102 by <a href="/wiki/Special:Contributions/Techie3" title="Special:Contributions/Techie3">Techie3</a> (<a href="/wiki/User_talk:Techie3" title="User talk:Techie3">talk</a>)</p>
<table style="background-color: #fff; color: #202122;" data-mw="interface">
<col class="diff-marker" />
<col class="diff-content" />
<col class="diff-marker" />
<col class="diff-content" />
<tr class="diff-title" lang="en">
<td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">← Previous revision</td>
<td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">Revision as of 11:19, 29 July 2022</td>
</tr><tr>
<td colspan="2" class="diff-lineno">Line 248:</td>
<td colspan="2" class="diff-lineno">Line 248:</td>
</tr>
<tr>
<td class="diff-marker"></td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> </div></td>
<td class="diff-marker"></td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> </div></td>
</tr>
<tr>
<td class="diff-marker"></td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> -- iterate over the 81 shogi piece arguments (left to right, top to bottom)</div></td>
<td class="diff-marker"></td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> -- iterate over the 81 shogi piece arguments (left to right, top to bottom)</div></td>
</tr>
<tr>
<td class="diff-marker" data-marker="−"></td>
<td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div> -- i couldn't figure out how to do this is in a clever loopy way as i couldn't figure out how to close the html tags</div></td>
<td colspan="2" class="diff-empty diff-side-added"></td>
</tr>
<tr>
<td class="diff-marker" data-marker="−"></td>
<td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div> -- whatever, it's repetitive, but it works</div></td>
<td colspan="2" class="diff-empty diff-side-added"></td>
</tr>
<tr>
<td class="diff-marker"></td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> </div></td>
<td class="diff-marker"></td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> </div></td>
</tr>
<tr>
<td class="diff-marker"></td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> -- index number displacement/offset</div></td>
<td class="diff-marker"></td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> -- index number displacement/offset</div></td>
</tr>
<tr>
<td colspan="2" class="diff-lineno">Line 257:</td>
<td colspan="2" class="diff-lineno">Line 255:</td>
</tr>
<tr>
<td class="diff-marker"></td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> </div></td>
<td class="diff-marker"></td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> </div></td>
</tr>
<tr>
<td class="diff-marker"></td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> -- the row for the shogi pieces</div></td>
<td class="diff-marker"></td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> -- the row for the shogi pieces</div></td>
</tr>
<tr>
<td colspan="2" class="diff-empty diff-side-deleted"></td>
<td class="diff-marker" data-marker="+"></td>
<td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><br /></td>
</tr>
<tr>
<td class="diff-marker" data-marker="−"></td>
<td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div> -- row 1</div></td>
<td colspan="2" class="diff-empty diff-side-added"></td>
</tr>
<tr>
<td class="diff-marker"></td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> for icols = 1,9 do</div></td>
<td class="diff-marker"></td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> for icols = 1,9 do</div></td>
</tr>
<tr>
<td class="diff-marker"></td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> local trow = shogitable:tag('tr')</div></td>
<td class="diff-marker"></td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> local trow = shogitable:tag('tr')</div></td>
</tr>
<tr>
<td colspan="2" class="diff-lineno">Line 263:</td>
<td colspan="2" class="diff-lineno">Line 261:</td>
</tr>
<tr>
<td class="diff-marker"></td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> -- put a single piece into a <td></div></td>
<td class="diff-marker"></td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> -- put a single piece into a <td></div></td>
</tr>
<tr>
<td class="diff-marker"></td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> -- iterate over 9 pieces in the row</div></td>
<td class="diff-marker"></td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> -- iterate over 9 pieces in the row</div></td>
</tr>
<tr>
<td class="diff-marker" data-marker="−"></td>
<td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div> for irow = (icols*9)-8,(icols*9)<del style="font-weight: bold; text-decoration: none;">+1</del> do</div></td>
<td class="diff-marker" data-marker="+"></td>
<td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div> for irow = (icols*9)-8,(icols*9) do</div></td>
</tr>
<tr>
<td class="diff-marker"></td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> trow:wikitext( makeTD(args[(irow+nx)]) )</div></td>
<td class="diff-marker"></td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> trow:wikitext( makeTD(args[(irow+nx)]) )</div></td>
</tr>
<tr>
<td class="diff-marker"></td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> end</div></td>
<td class="diff-marker"></td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> end</div></td>
</tr>
</table>
Techie3
https://en.wikipedia.org/w/index.php?title=Module:Shogi_diagram/sandbox&diff=1101116102&oldid=prev
Techie3 at 11:18, 29 July 2022
2022-07-29T11:18:56Z
<p></p>
<table style="background-color: #fff; color: #202122;" data-mw="interface">
<col class="diff-marker" />
<col class="diff-content" />
<col class="diff-marker" />
<col class="diff-content" />
<tr class="diff-title" lang="en">
<td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">← Previous revision</td>
<td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">Revision as of 11:18, 29 July 2022</td>
</tr><tr>
<td colspan="2" class="diff-lineno">Line 263:</td>
<td colspan="2" class="diff-lineno">Line 263:</td>
</tr>
<tr>
<td class="diff-marker"></td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> -- put a single piece into a <td></div></td>
<td class="diff-marker"></td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> -- put a single piece into a <td></div></td>
</tr>
<tr>
<td class="diff-marker"></td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> -- iterate over 9 pieces in the row</div></td>
<td class="diff-marker"></td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> -- iterate over 9 pieces in the row</div></td>
</tr>
<tr>
<td class="diff-marker" data-marker="−"></td>
<td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div> for irow = (icols*9)-8,(icols*9) do</div></td>
<td class="diff-marker" data-marker="+"></td>
<td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div> for irow = (icols*9)-8,(icols*9)<ins style="font-weight: bold; text-decoration: none;">+1</ins> do</div></td>
</tr>
<tr>
<td class="diff-marker"></td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> trow:wikitext( makeTD(args[(irow+nx)]) )</div></td>
<td class="diff-marker"></td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> trow:wikitext( makeTD(args[(irow+nx)]) )</div></td>
</tr>
<tr>
<td class="diff-marker"></td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> end</div></td>
<td class="diff-marker"></td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> end</div></td>
</tr>
</table>
Techie3
https://en.wikipedia.org/w/index.php?title=Module:Shogi_diagram/sandbox&diff=1101116002&oldid=prev
Techie3 at 11:18, 29 July 2022
2022-07-29T11:18:09Z
<p></p>
<table style="background-color: #fff; color: #202122;" data-mw="interface">
<col class="diff-marker" />
<col class="diff-content" />
<col class="diff-marker" />
<col class="diff-content" />
<tr class="diff-title" lang="en">
<td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">← Previous revision</td>
<td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">Revision as of 11:18, 29 July 2022</td>
</tr><tr>
<td colspan="2" class="diff-lineno">Line 258:</td>
<td colspan="2" class="diff-lineno">Line 258:</td>
</tr>
<tr>
<td class="diff-marker"></td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> -- the row for the shogi pieces</div></td>
<td class="diff-marker"></td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> -- the row for the shogi pieces</div></td>
</tr>
<tr>
<td class="diff-marker"></td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> -- row 1</div></td>
<td class="diff-marker"></td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> -- row 1</div></td>
</tr>
<tr>
<td class="diff-marker" data-marker="−"></td>
<td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div> for icols = <del style="font-weight: bold; text-decoration: none;">0</del>,<del style="font-weight: bold; text-decoration: none;">8</del> do</div></td>
<td class="diff-marker" data-marker="+"></td>
<td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div> for icols = <ins style="font-weight: bold; text-decoration: none;">1</ins>,<ins style="font-weight: bold; text-decoration: none;">9</ins> do</div></td>
</tr>
<tr>
<td class="diff-marker"></td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> local trow = shogitable:tag('tr')</div></td>
<td class="diff-marker"></td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> local trow = shogitable:tag('tr')</div></td>
</tr>
<tr>
<td class="diff-marker"></td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> :css('font-size', piecefontsize)</div></td>
<td class="diff-marker"></td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> :css('font-size', piecefontsize)</div></td>
</tr>
<tr>
<td class="diff-marker"></td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> -- put a single piece into a <td></div></td>
<td class="diff-marker"></td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> -- put a single piece into a <td></div></td>
</tr>
<tr>
<td class="diff-marker"></td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> -- iterate over 9 pieces in the row</div></td>
<td class="diff-marker"></td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> -- iterate over 9 pieces in the row</div></td>
</tr>
<tr>
<td colspan="2" class="diff-empty diff-side-deleted"></td>
<td class="diff-marker"><a class="mw-diff-movedpara-right" title="Paragraph was moved. Click to jump to old location." href="#movedpara_5_0_lhs">⚫</a></td>
<td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><a name="movedpara_3_0_rhs"></a> for irow = (icols*9)<ins style="font-weight: bold; text-decoration: none;">-8</ins>,(icols*9) do</div></td>
</tr>
<tr>
<td class="diff-marker" data-marker="−"></td>
<td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div> </div></td>
<td colspan="2" class="diff-empty diff-side-added"></td>
</tr>
<tr>
<td class="diff-marker"><a class="mw-diff-movedpara-left" title="Paragraph was moved. Click to jump to new location." href="#movedpara_3_0_rhs">⚫</a></td>
<td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div><a name="movedpara_5_0_lhs"></a> for irow = (icols*9)<del style="font-weight: bold; text-decoration: none;">+1</del>,<del style="font-weight: bold; text-decoration: none;">(</del>(icols<del style="font-weight: bold; text-decoration: none;">+1)</del>*9) do</div></td>
<td colspan="2" class="diff-empty diff-side-added"></td>
</tr>
<tr>
<td class="diff-marker"></td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> trow:wikitext( makeTD(args[(irow+nx)]) )</div></td>
<td class="diff-marker"></td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> trow:wikitext( makeTD(args[(irow+nx)]) )</div></td>
</tr>
<tr>
<td class="diff-marker"></td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> end</div></td>
<td class="diff-marker"></td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> end</div></td>
</tr>
</table>
Techie3
https://en.wikipedia.org/w/index.php?title=Module:Shogi_diagram/sandbox&diff=1101114470&oldid=prev
Techie3: Test
2022-07-29T11:05:49Z
<p>Test</p>
<p><b>New page</b></p><div>local shogiobject = {}<br />
<br />
-----------------------<br />
-- internal functions <br />
-----------------------<br />
<br />
<br />
-- returns a japanese character for a roman letter abbreviation<br />
-- called by the shogiboard() function<br />
local function piecesymbol(abbreviation)<br />
-- the abbreviation argument is a string of 1-3 letters that stand for the English names of the shogi pieces<br />
-- the abbreviation is extracted out of a longer string by the processString() function<br />
<br />
-- letter to character mapping (hash table)<br />
local piecenames = {<br />
p = '歩',<br />
t = 'と',<br />
l = '香',<br />
pl = '杏',<br />
n = '桂',<br />
pn = '圭',<br />
s = '銀',<br />
ps = '全',<br />
g = '金',<br />
b = '角',<br />
h = '馬',<br />
r = '飛',<br />
d = '龍',<br />
gyoku = '玉',<br />
ou = '王',<br />
tx = '个',<br />
plx = '仝',<br />
pnx = '今',<br />
dx = '竜',<br />
e = '象',<br />
a = '太'<br />
}<br />
-- spit out the character corresponding to abbreviation<br />
-- if the abbreviation string is empty, then spit out nobreak space (for html tables) <br />
piece = piecenames[abbreviation] or '&nbsp;'<br />
return string.format( piece )<br />
end<br />
<br />
<br />
-- function separates out the piece, the side, and the boldness info present in the string argument<br />
-- it returns an array with these three values plus the color (for promoted pieces)<br />
-- this info is passed to the makeTD() function<br />
function processString(ss)<br />
-- strip whitespace<br />
ss = mw.text.trim(ss)<br />
<br />
-- get the last character of the string<br />
local lastchar = mw.ustring.sub(ss, -1)<br />
<br />
-- chop off last character of string<br />
local restofstring = mw.ustring.sub(ss, 1, -2)<br />
<br />
-- default is normal font<br />
-- but if the string ends with 'l' for 'last move', <br />
-- then the font should be bold and we need to get a new string with the this 'l' chopped off (with a new last character)<br />
local boldness = 'normal'<br />
if lastchar:match('l') then<br />
boldness = 'bold'<br />
lastchar = mw.ustring.sub(restofstring, -1)<br />
restofstring = mw.ustring.sub(restofstring, 1, -2)<br />
end<br />
<br />
-- the side is either 'g' for 'gote' or 's' for 'sente'<br />
-- it's the last character in the string (and if the string ended)<br />
local side = lastchar<br />
<br />
-- the leftover string is the shogi piece abbreviation<br />
local pieceabbr = restofstring<br />
<br />
-- default is black font<br />
-- if the piece is promoted (one the abbreviations below), then the piece should be red<br />
local color = 'black'<br />
if pieceabbr:match('t') or pieceabbr:match('pl') or pieceabbr:match('pn') or pieceabbr:match('ps') or pieceabbr:match('h') or pieceabbr:match('d') then<br />
color = 'red'<br />
end<br />
-- this is an exceptional bit:<br />
-- gote's king is usually 王 instead of 玉 by convention, <br />
-- but it's convenient to use the 'k' code for both sente and gote and let the default character be side-dependent<br />
if pieceabbr:match('k') and side:match('g') then<br />
pieceabbr = 'ou'<br />
end<br />
if pieceabbr:match('k') and side:match('s') then<br />
pieceabbr = 'gyoku'<br />
end<br />
-- similar to above exception, reverse default<br />
if pieceabbr:match('ak') and side:match('s') then<br />
pieceabbr = 'ou'<br />
end<br />
if pieceabbr:match('ak') and side:match('g') then<br />
pieceabbr = 'gyoku'<br />
end<br />
-- convert abbreviation to Japanese character<br />
local piecechar = piecesymbol(pieceabbr)<br />
<br />
if ss:match('yy') or ss:match('gr') or ss:match('rat') or ss:match('lat') or ss:match('uat') or ss:match('dat') or <br />
ss:match('lra') or ss:match('las') or ss:match('ras') or ss:match('uda') or ss:match('das') or ss:match('uas') or <br />
ss:match('da') or ss:match('dau') or ss:match('dad') or ss:match('daus') or ss:match('dads') or ss:match('daa') or <br />
ss:match('daad') or ss:match('daau') or ss:match('daaus') or ss:match('daads') or ss:match('kar') or ss:match('kal') or <br />
ss:match('kadr') or ss:match('kadl') or ss:match('rah') or ss:match('lah') or ss:match('dah') or ss:match('uah') or <br />
ss:match('durh') or ss:match('dulh') or ss:match('ddrh') or ss:match('ddlh') or ss:match('ddl') or ss:match('ddr') or <br />
ss:match('dul') or ss:match('dur') then<br />
piecechar = '[[File:shogi_' .. ss .. '22.svg|20px]]'<br />
side = 'arrow'<br />
color = 'arrow'<br />
boldness = 'arrow'<br />
end<br />
<br />
local result = {piecechar, side, color, boldness}<br />
return result<br />
end<br />
<br />
<br />
-- function makes a <td> containing the piece with CSS stuff<br />
-- uses the info from processString() to customize the CSS based on which side, color, and boldness<br />
function makeTD(stringarg)<br />
-- got to process the string argument into its informational bits<br />
-- this processedstring is an array (or whatever the equivalent is in Lua)<br />
local processedstring = processString(stringarg)<br />
-- saving the pieces of the array as separate objects to be referred to below<br />
local piecechar = processedstring[1]<br />
local side = processedstring[2]<br />
local color = processedstring[3]<br />
local bold = processedstring[4]<br />
<br />
-- i guess one needs a root node?<br />
local root = mw.html.create('')<br />
<br />
-- the default <td><br />
local td = root:tag('td')<br />
td:css('border', 'black 1px solid')<br />
td:css('width', '20px')<br />
td:css('height', '20px')<br />
td:css('padding', '0')<br />
td:css('line-height', '0')<br />
td:css('font-family', '"Hiragino Mincho ProN", serif')<br />
<br />
if not side:match('arrow') then<br />
td:wikitext( piecechar )<br />
end<br />
<br />
-- g = gote<br />
-- gote should be upside down text<br />
if side:match( 'g' ) then<br />
td:css('transform', 'rotate(180deg)')<br />
end<br />
<br />
-- for promoted pieces<br />
if color:match( 'red' ) then<br />
-- this is a darkish reddish color<br />
td:css('color', '#E00303')<br />
end<br />
<br />
-- for bold pieces<br />
if bold:match( 'bold' ) then<br />
td:css('font-weight', 'bolder')<br />
-- traditionally bold type is gothic (sans serif) in Japanese typesetting of shogi diagrams within Japanese shogi books<br />
td:css('font-family', ' HiraginoSans-W5, sans-serif')<br />
end<br />
<br />
-- for arrow svgs <br />
if side:match('arrow') then<br />
td:css('padding', '0')<br />
td:css('width', '20px')<br />
td:css('height', '20px')<br />
td:css('font-size', '1px')<br />
td:css('line-height', '0')<br />
td:wikitext( piecechar )<br />
end<br />
return tostring(root)<br />
end<br />
<br />
<br />
-- function makes the shogi diagram<br />
-- this is basically a <div> enclosing a .css <div> wrapper with a <table> inside<br />
function shogiboard(args)<br />
-- these are the column coordinate labels 9-1<br />
local colLabels = {'9', '8', '7', '6', '5', '4', '3', '2', '1', '&nbsp;'}<br />
-- these are the row coordinate labels a-i (western notation)<br />
local rowLabels = {'1', '2', '3', '4', '5', '6', '7', '8', '9'}<br />
-- these are the row coordinate labels 1-9 (Japanese notation)<br />
-- this isn't set up for use yet<br />
local rowLabelsJP = {'一', '二', '三', '四', '五', '六', '七', '八', '九'}<br />
<br />
local headerarg = args[2]<br />
local toppieceinhandarg = args[3]<br />
<br />
local root = mw.html.create('div')<br />
<br />
-- <div> wrapper<br />
local shogiboardwrapper = root:tag('div')<br />
:addClass('shogiboardwrapper')<br />
:css('padding-left', '4px')<br />
:css('padding-bottom', '2px')<br />
<br />
-- the diagram header/caption<br />
local headerstring = mw.text.trim(headerarg)<br />
local header = shogiboardwrapper:tag('div')<br />
header:css('padding', '0')<br />
header:wikitext(headerstring)<br />
header:css('font-size', '14px')<br />
<br />
-- this is the 'piece-in-hand' argument for gote<br />
-- strip whitespace<br />
local strippedpieceinhandtop = mw.text.trim(toppieceinhandarg) or ''<br />
-- put it in a <div> with .css formating<br />
local pieceinhandtopdiv = shogiboardwrapper:tag('div')<br />
pieceinhandtopdiv:css('padding', '0')<br />
pieceinhandtopdiv:css('font-size', '12px')<br />
pieceinhandtopdiv:wikitext('☖ pieces in hand: ')<br />
-- i was going to put the actual argument text into conditional <span> .css formating, but i couldn't get the logical test in an if/else structure right...<br />
local piecesinhandtopspan = pieceinhandtopdiv:tag('span')<br />
piecesinhandtopspan:css('font-size', '13px')<br />
piecesinhandtopspan:wikitext(strippedpieceinhandtop)<br />
<br />
-- the shogi table<br />
local shogitable = shogiboardwrapper:tag('table')<br />
:addClass('shogitable')<br />
:attr('border', '1')<br />
:css('border-collapse', 'collapse')<br />
:css('border', 'none')<br />
:css('padding-top', '0')<br />
:css('background-color', 'white')<br />
<br />
-- font size for the shogi piece text<br />
piecefontsize = '17px'<br />
-- font size for the column/row piece coordinate labels (9-1) and (a-i)<br />
colrowfontsize = '11px'<br />
-- padding amount for the row piece coordinate labels (a-i)<br />
padrowlab = '1px'<br />
<br />
-- the row for the column coordinate labels<br />
local columnlabelrow = shogitable:tag('tr')<br />
:css('font-size', colrowfontsize)<br />
:css('background-color', '#f9f9f9')<br />
-- iterating over the column label to put each label in a <td><br />
for i,v in ipairs(colLabels) do <br />
local td = columnlabelrow:tag('td')<br />
:css('border', 'none')<br />
:css('width', '20px')<br />
:css('height', '5px')<br />
:wikitext( v )<br />
end<br />
<br />
-- iterate over the 81 shogi piece arguments (left to right, top to bottom)<br />
-- i couldn't figure out how to do this is in a clever loopy way as i couldn't figure out how to close the html tags<br />
-- whatever, it's repetitive, but it works<br />
<br />
-- index number displacement/offset<br />
-- this is just the number of arguments that precede the 81 shogi piece arguments that are in the html <table><br />
-- i just keep the piece arguments as indexes 1-81, then add nx to the index value<br />
nx = 3<br />
<br />
-- the row for the shogi pieces<br />
-- row 1<br />
for icols = 0,8 do<br />
local trow = shogitable:tag('tr')<br />
:css('font-size', piecefontsize)<br />
-- put a single piece into a <td><br />
-- iterate over 9 pieces in the row<br />
<br />
for irow = (icols*9)+1,((icols+1)*9) do<br />
trow:wikitext( makeTD(args[(irow+nx)]) )<br />
end<br />
-- add row coordinate label <td><br />
local rowlabel = trow:tag('td')<br />
:css('border', 'none')<br />
:css('font-size', colrowfontsize)<br />
:css('padding-left', padrowlab)<br />
:css('padding-top', '0')<br />
:css('padding-bottom', '0')<br />
:css('background-color', '#f9f9f9')<br />
:wikitext( rowLabels[icols] )<br />
end<br />
-- this is the 'piece-in-hand' argument for sente (same as above for gote)<br />
-- only difference is the black shogi piece glyph (☗)<br />
local strippedpieceinhandbottom = mw.text.trim(args[81+1+nx]) or '' <br />
local pieceinhandbottomdiv = shogiboardwrapper:tag('div')<br />
pieceinhandbottomdiv:css('padding', '0')<br />
pieceinhandbottomdiv:css('font-size', '12px')<br />
pieceinhandbottomdiv:wikitext('☗ pieces in hand: ')<br />
local piecesinhandbottomspan = pieceinhandbottomdiv:tag('span')<br />
piecesinhandbottomspan:css('font-size', '13px')<br />
piecesinhandbottomspan:wikitext(strippedpieceinhandbottom)<br />
<br />
return tostring(root)<br />
end<br />
<br />
<br />
-----------------------<br />
-- main function <br />
-----------------------<br />
<br />
function shogiobject.board(frame)<br />
-- need to use getParent().args for reasons i dont understand<br />
local args = frame:getParent().args<br />
return shogiboard(args)<br />
end<br />
<br />
return shogiobject</div>
Techie3