Comments/Ratings for a Single Item
Ok, thanks! I actually know nothing about JS but i'm good with general programming so I guess i'll handle myself!
In the meantime, I think I inadvertently posted 2 variants I did not suppose to, How do I delete them?
Ok, I have no clue how to do what you've just said on my computer, if you have the time to tell me the baby steps, or let me send you the html code that the wizard has done, make work on your machine and then send me the result i'll owe you a beer, in my first trip to US, or your first trip to Romania
OK, here it comes! Copy the text below to a file, ad save it on your computer as 'trial.html'. If you then open that file with your browser it should show an interactive diagram for Elven Chess. Then you can try replacing the diagram definition inside the file (the pink part) by what you get from the Design Wizard for your own variant. You will have to change the definition of graphicsDir to http://www.chessvariants.com/graphics.dir/alphaerie , (i.e. replace the ".." in the location by the URLof the CVP website) and the link to the JavaScript source (in the first line) to http://www.chessvariants.com/membergraphics/MSinteractivedia/betza.gif (or leave that line in place, as it is already written that way in the HTML below).
Note that in this context the legend belonging to the diagram is not hidden below it, but placed openly next to it. This is caused by the presence of a 'table' element with id="pieceTable" (highlighted in green) elsewhere on the page.
<html> <body> <div id="rules" style="display:none"> <p id="message">Move by click-click or drag-drop:</p> <script type="text/javascript" src="http://www.chessvariants.com/membergraphics/MSinteractivedia/betza.gif"></script>
<p> <h2 id="players">Elven Chess: local game</h2> </td><td valign="top" width="150"> <p onclick="OpenDiv('rules')"> <table id="pieceTable" border="1"></table> <p onclick="OpenDiv('betza')"> </td></tr></table> |
Well, it doesn't show a diagram of elven chess, but the own text of the html, this is what it happens when I try to upload it on the website, too. What am I doing wrong?
What happens when you paste the URL that is given by the src= of the script tag into the address field of your browser?
It says: "The image [...] cannot be displayed because it contains errors" where [...] stand for the content of the src=
That is the correct response; it means it could read the file and inspect its contents. (It is not really a .gif file but a .js file that I renamed to .gif, because the CVP submission form did not allow me to upload .js files. So it is not surprising the Browser does not recognizeit as a valid GIF image file.)
That makes it strange that the text of the diagram description is not replaced by the diagram. Because this is what the JavaScript is supposed to do. I suppose you do see the diagram on the Elven Chess article on CVP, and on http://hgm.nubati.net/variants/elven ?
I solved it, for some reason using open office instead of notepad does that, now I'll try to paste my own code!
The graphics are wrong, but the script works! For images it shows just cracked images!
It works great for the other game, the one with archbishops!
It works now, have you done something HG? or I just copied stuff wrong the first time?
Must have been a copying error. I was just reformatting my earlier posting that showed the required HTML, adding borders and background coloring to it, but not changing anything substantial.
Now I can actually play games, thank you H.G., I see now how silly they look. Thank you very much! It's now getting late here. See you soon!
I have added a nice improvement to the ShowMoves(N) function associated with the diagram. Before, this function used to show the moves of the Nth defined piece that was defined, on an empty board. And if you invoked it again for the same piece, it restored the original board position. So that you could attach it with an onclick="ShowMoves(N)" to a HTML element that describes the piece in your submission text, to make clicks on it interactively show the moves.
The new feature works for variants with Shogi-style promotions (i.e. where you defined a non-zero promoOffset P to relate each unpromoted piece N to a unique promoted partner N+P). When you invoke the function a second time with the same N it shows the moves of the promoted piece. It only reverts to displaying the origial position when invoked a third time. For unpromotable pieces the second invocation already makes the board revert to the original position, as before.
In addition it now always shows the name of the piece it displays the moves of in the message above the board. A good place to see it in action is the Chu Shogi article.
All your work the passed weeks with the diagrams is great, but I must ask:
1.Do they support hexagonall mappings?
2.Do they suport Xiangqi style rivers?
I think the short answer to both questions is no. Any hope for these facilities soon?
I am not sure what you mean by 'Xiangqi-style rivers'. As for graphical representation, Xiangqi is played on grid-points rather than squares, and the diagram will never be able to do that, as it is just a HTML table with images in the squares and lines between the squares. So displaying a River is just a tiny detail of something it cannot do in the first place.
If you mean that you just want certain pieces to be limited to a fraction of the board, this is already possible. The latest .js script for the diagram checks if there exists a user-supplied function BadZone(file,rank,piece,color). If there isn't, it assumes any piece can venture anywhere on the board. But if there is, it only accepts moves where the fuction returns 0 for the destination square.
To indicate the zones by coloring of the board the user can similarly supply a function Shade(file,rank), which returns a color.
So to do Xiangqi (with a western-style board) the HTML page defining the diagram would need to contain the extra text
<script> function BadZone(x, y, piece, color) { if(piece = ELEPHANT) return (color ? y < 5 : y > 4); // cases for King and Advisors .... } function Shade(x, y) { var color = 0; if(y > 4) color = !color; // board halves if(x > 2 && x < 6 && (y < 3 || y > 6) color = !color; // palace return color; } </script>
As for hexagonal boards: this is currently definitely not supported. It would not be totally impossible to support something close to it in the current framework, however. The board must be a HTML table, which means rectangular cells. But it is possible to have cells extend over more than one column in HTML. So by doubling the number of columns, and then alternately fuse odd+even or even+odd on different ranks, you would get a masonry-like pattern which should be close enough.
Thanks, It's nice to know for future projects!
I've noticed somthing odd with my diagrams for small apothecary 1 chess (the ones on my computer that use the javascript). The griffin, and griffin only shows grey pseudo-check moves. This can't be right and needs fixing.
Ah, this is a consequence of the new way to handle the royal piece. The diagram must think Griffin and Queen are royal. By default the last-defined piece is royal. If you don't want that, you can add a line
royal=N
to the diagram definition, with N the ordinal number of the King.
You were correct,H.G., I did written royal=3 (as was my case) and I'm fine!
H.G.
Diagrams don't seem to work anymore, just code appears!
25 comments displayed
Permalink to the exact comments currently displayed.
I was still adding a paragraph to my previous post; be sure not to miss it. You can use the diagram elsewhere, but you would have to copy the image files and JavaScript file that are present on CVP, or fully link to those.
BTW, the underlying JavaScript can actually do more than what is needed to just power the diagrams as used on CVP. It also supports functions to collect a game, and navigate through it. You would just have to put buttons in the HTML to activate these functions. See for instance http://hgm.nubati.net/variants/elven, where I use the diagram on my own website. You can also copy that HTML page, and then replace the diagram in it by your own from the Design Wizard.