Git Product home page Git Product logo

pzprjs's Introduction

Translation status Translation status

About pzprjs

pzprjs enables one to create or edit pencil puzzles like sudoku and yajilin which are solved with specific rules on boards. It is developed using HTML5 features and JavaScript.

This project is a fork of the original sabo2/pzprjs; it is live on puzz.link.

Bugs, questions, contributions

Please file issues using the issue tracker if you run into any issues with pzprjs. Or write to feedback at puzz.link, or join puzzlink.zulipchat.com to discuss.

Translation

Translations can be contributed using Weblate (no account required).

Repository structure

The core of the puzzle solving and editing applet lives in src/. The list of puzzle types is in src/pzpr/variety.js, the implementation of the various types within src/variety/. Tests for these types are found in test/script/ and test/variety/. The test cases in test/script/ are also used to generate instructions.

The web UI around the applet (buttons, options, background etc.) live in src-ui/.

Building and testing

Calling make will build the project to dist/. Depending on your browser's security settings, you can interact with the result directly by opening dist/p.html or dist/list.html in your browser. Otherwise, you may need to run a web server, e.g. by running python -m http.server within dist/ and visiting http://localhost:8000/list.html.

Calling make test will run the unit tests.

Adding a new puzzle type

Adding a puzzle type involves the following:

  1. Define a new type in src/pzpr/variety.js. This could be a new base type mytype which will go in a new file src/variety/mytype.js, or be based on an existing type oldtype, in which case you'll edit src/variety/oldtype.js. (E.g., the type aho is defined in shikaku.js.)

  2. Implement the type in that file in src/variety/. The parts of a type implementation are

    • Input event handling, by customising MouseEvent and KeyEvent. Every type has a number of "input modes", and typically one custom "auto" input mode.
    • Board customisation, by customising Cell, Board etc.
    • Rendering, by customising Graphic.
    • URL and file encoding, by customising Encode and FileIO. Encode is used to deal with pzpr URLs, while FileIO is used when you save a board state to file (see tests below).
    • Answer checks, by collecting names of checks in AnsCheck.checklist, implementing checking methods in AnsCheck, and defining failure codes and messages in FailCode.

    Have a look at existing types to see how multiple types within one file share code.

  3. Add a test file for the new type in test/script/mytype.js. This must include a full suite of example boards that trigger the various fail codes one by one. Ideally, this would be one example puzzle that shows various errors, but it's fine to deviate from that. The boards are stored as strings as generated by "File -> Save file as...", with newlines replaced by slashes.

    Furthermore, if your type does any tricky input handling, it's a good idea to add some input scripts in the inputs section of this test file.

  4. Add the new type to the web UI by adding it to each of src-ui/js/v3index.js and src-ui/list.html.

  5. Add a background tile as src-ui/img/mytype.png and add the type in src-ui/js/ui/Misc.js:toBGimage.

  6. Add a line to Changelog.md.

Steps 1 and 2 should be enough to be able to interact with the type by visiting p.html?mytype. Feel free to skip steps 5 and 6 when submitting a pull request for a new type.

Glossary

There are some Japanese terms in the source code that may not be obvious.

irowake: per-component coloring peke: cross mark

pzprjs's People

Contributors

alicebob avatar bay-puz avatar boboquack avatar cjquines avatar cryslith avatar dependabot[bot] avatar despian avatar domishana avatar elidoris avatar fffpuzzle avatar glasser avatar hoekri avatar karenannecarpenter avatar knexator avatar m-ender avatar mclarke93 avatar minorusama avatar montelucci avatar nishinanntoka avatar robx avatar sabo2 avatar seren-35 avatar subaru-saito1 avatar tausbn avatar tckmn avatar wand125 avatar wass88 avatar weblate avatar william42 avatar x-sheep avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

pzprjs's Issues

Listing is broken

Several twitter users report that https://puzz.link/list.html doesn't work. It displays a list of bullet points without any labels. Clicking a button results in the following script error:

ReferenceError: v3index is not defined

This happens on my local checkout as well.

edit mode allows breaking moved circles

interesting bug with circle movement during editing: if you delete a partially moved circle bad things happen http://puu.sh/Dv5AD/9499cb3fe7.png
to reproduce: pick a genre that involves moving circles, place a circle and move it around in answer mode
then switch to edit mode, select the square the circle is currently on, press delete, then select the square the circle originated from
the head and tail of the path should be deleted, but the path is still on the board (and prevents other circles from moving through it)

Improve examples / test cases

We use the error code test cases to generate rules pages, e.g. https://puzz.link/rules.html?cbblock.

For some puzzle types, these are incomplete, ordered awkwardly, or otherwise not very helpful.

The hard work here is coming up with better test cases, and it's easy to help here without touching the code: Create an example puzzle, and "solve" it to exhibit each error scenario, and save via "File -> Save file as..." and send them to me.

curvedata checker is slow on complex clues

@x-sheep could you look into this?

Someone posted the following puzzle on twitter: https://puzz.link/p?curvedata/20/20/0zzzzzzzzzzzzzzzzzzzy/20/20/fffffffffbfffffffffbfffffffffbfffffffffbfffffffffbfffffffffbfffffffffbfffffffffbfffffffffbfffffffffbfffffffffbfffffffffbfffffffffbfffffffffbfffffffffbff7ffffffbfffffffffbfffffffffbfffffffffb5555555551

I've made a change to the linewidth so that the clue is somewhat visible now. But when trying to solve it, the checker seems to break down towards the end, with my browser asking me if I want to stop the script.

Heteromino "same areas are adjacent" triggers when it shouldn't.

See image below. The checker seems to think that any areas that aren't exactly three squares large are congruent. I think better behaviour would be that only areas exactly three squares large can be congruent, if you don't want to run congruency checking on large regions.

image

Nurimisaki: 2x2 shaded cells

This rule is currently validated after rules such as checkViewOfNumber and check2x2UnshadeCell.

I'd argue that this rule belongs at the top of the priority list, since the only way to violate it is by making a mistake (as opposed to just having an incomplete answer).

Puzzle interface improvements

This is to collect some obvious improvements to existing puzzle types.

  • It would be great to be able to easily "shade" the wall in Nanro. Perhaps by shading numbered cells and placing the numbers automatically, or by providing a fully shaded variant puzzle. ✅ (partially done)
  • Similarly, bag/corral/cave would benefit from a shading input.
  • Fillomino number entry is also awkward, maybe something like what croco-puzzle does?
  • Auto-shading of completed clues for Yajilin.

Spiral Galaxies claims missing stars when stars are added after the borders

This is off twitter, due to @pzosdc.

The "check" button in Spiral-Galaxies works correct when you partition blocks after placing stars, but it works in-correct in some cases such that you place stars after partitioning blocks.

D1n4I4rV4AA1_MM

To reproduce this, place the left star in edit mode, switch to answer mode and draw the border, then switch back to edit mode and place the right star, then hit the check button.

shakashaka: input weirdness around blank cells

In the situation below, it's impossible to finish drawing the diagonal rectangle, because apparently the marked empty cell is considered part of a grid-aligned rectangle.

Assuming that part is desirable, it should not be possible to mark empty cells within large diagonal rectangles empty. Or something else should change.

Screenshot 2019-04-30 at 11 57 44

Nurimaze broken cells, edit mode keyboard input version

i use one button auto input. create a region in edit mode, and in one cell click three times in auto (this goes through circle and triangle then back to blank). go to answer mode, and the region it's in shouldn't be able to turn black (it alternates between white and green)

Compare #7. A possible explanation is a middle mouse button event.

Nurimaze broken cells, edit mode keyboard input version

draw a closed region
click a square inside it
press 1 to place a circle in the square
press "ctrl" which makes the square blank
then switch to answer mode
you can't shade the region
also if you do this, you can't place any symbols with the mouse
attempting to place a symbol with the mouse doesn't do anything
uh, in the cell with the "erased" symbol specifically, not in general

handle full url pzv parameters cleanly

puzsq generates some links of the form

https://puzz.link/p?http://pzv.jp/p.html?yajilin/10/10/0.0.0.420.e0.0.410.f0.420.g420.h0.r33h120.g330.0.f130.0.0.e310.0.0.0./ 

These are broken, but they do work. I'm redirecting to the correct link via nginx now, but it would still be good to handle these more cleanly. E.g., via pzprnode, I'm getting some solves reported with pzv = http://pzv.jp/p.html?yajilin/10/10/0.0.0.420.e0.0.410.f0.420.g420.h0.r33h120.g330.0.f130.0.0.e310.0.0.0./ .

yajilin: fix interaction between loop and shaded cells

currently you can draw a loop over the shaded cells, which seems to not be very useful

suggestion: drawing a loop onto a shaded cell unshades the cell; shading a loop cell removes the loop segments that use that cell

something wrong with shugaku input

Sometimes, when drawing a bed with left-drag, it stays shaded red after lifting the mouse button, and weird things happen.

This may be related to the heyawake input change.

consistent wording for touching/adjacency

I just added heteromino, where I phrased the same shape rule using the word "touch". It was pointed out to me that "adjacent" might be more correct when talking about "touching by an edge". On the other hand, star battle currently uses "adjacent" so it seems the change doesn't help a lot without going over all the instructions and phrasing things consistently.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.