GithubHelp home page GithubHelp logo

shenzhen-solitaire.nvim's Introduction

Deprecated!, please see playtime.nvim for an updated Shenzhen Solitaire implementation (and other games).

Shenzhen Solitaire ๐Ÿ€™๐Ÿ€๐Ÿ€‡

A game in play

Shenzhen I/O Solitaire is a bit like FreeCell but played with a partial Mahjong deck. It's an open information game with a high solve rate, given correct play.

Buy the real game.

Game Rules

There are 40 cards,

  • 3x9 "suited" cards, Coin, String and Myriad.
  • 3x4 "dragon" cards, Trogdor ล  Red ล , Green ร‘ and White ร•.
  • 1 "flower" card, ฦ’.

Shenzhen Solitaire is similar to FreeCell, with a majhong deck instead. The goal is to place all suited cards in the top right foundations and all dragon cards in the top left cells.

The top row has 3 cells that may hold one card at a time, of any kind.

The next 4 slots are foundations which must build sequences from 1 to 9 in the same suit, except the first slot may only hold the ฦ’ card.

The tableau operates under normal solitaire rules, you may only place cards in descending, alternating suit sequences except when the column is empty. Empty columns accept any card.

Note that by these rules, you can not build off or use dragons cards in a sequence!

When 4 dragon cards of the same type (ล , ร‘ or ร•) are accessible (either in the tableau or cells), you may activate the appropriate button to shift all cards of that type to an unoccupied cell. Once this is done that cell is locked.

Commands and Controls

Open a new buffer and run :ShenzhenSolitaireNewGame to play a random draw, or call :lua require("shenzhen-solitaire")["start-new-game"](buf-id config seed-number). The command accepts an optional seed number.

Run :ShenzhenSolitaireNextGame to play through a series of selected hands, where you must beat the draw to play the next! Over 100ยนยฒ meticulously crafted hands to play through!

The game will automatically move the ฦ’ to its foundation, as well as any suited cards to a foundation if there are no other cards of lower value in play. You may disable automatic moves via the configuration.

Shenzhen Solitaire supports keyboard controls but is much more comfortably played with a mouse, so the defaults are set to support that.

The default controls are:

  • Left Mouse: pick up or put down cards.
  • Right Mouse: return cards to original location. Note you must right click a UI element, not blank space.
  • y: pickup or put down cards
  • ww: save current game
  • ll: load last save
  • rr: restart current game
  • u: undo last move (if enabled)
  • <Tab>: move cursor to next location
  • <S-Tab>: move cursor to next location

Configuration

Any given config is merged onto the following via vim.tbl_deep_extend, use that knowledge to infer how much of the config you must provide when changing options.

If you're primarily playing with a mouse you may prefer to set cursor.show = false and difficulty.show-valid-locations = false.

The buffer filetype is set to shenzhen-solitaire if you would like to run any autocommands to clean up the UI.

{:card {:size {:width 7 :height 5}
        :borders {:ne :โ•ฎ :nw :โ•ญ :se :โ•ฏ :sw :โ•ฐ :n :โ”€ :s :โ”€ :e :โ”‚ :w :โ”‚}}
 :buttons {:pos {:row 1 :col 34}}
 :tableau {:pos {:row 7 :col 1}
           :gap 3}
 :cell {:pos {:row 1 :col 1}
        :gap 3}
 :foundation {:pos {:row 1 :col 41}
              :gap 3}
 :highlight {:empty {:fg :#495159 :bg hl-normal-background}
             :button {:fg :#495159 :bg hl-normal-background}
             :coin {:fg :#e8df78 :bg hl-normal-background}
             :string {:fg :#879ff6 :bg hl-normal-background}
             :myriad {:fg :#23b3ac :bg hl-normal-background}
             :flower {:fg :#934188 :bg hl-normal-background}
             :dragon-green {:fg :#52ad56 :bg hl-normal-background}
             :dragon-white {:fg :#cfcfcf :bg hl-normal-background}
             :dragon-red {:fg :#d34d4d :bg hl-normal-background}}
 :info {:pos {:row 22 :col 3}}
 :size {:width 80 :height 40}
 :cursor {:show false} ;; show cursor, strongly recommended without a mouse
 :difficulty {:show-valid-locations false ;; show possible interactive locations, useful without a mouse.
              :allow-undo false
              :auto-move-obvious true}
 :gauntlet false
 :keys {:left-mouse :<LeftMouse>
        :right-mouse :<RightMouse>
        :interact :y
        :auto-move :a
        :save-game :ww
        :load-game :ll
        :restart-game :rr
        :undo-last-move :u
        :next-location :<Tab>
        :prev-location :<S-Tab>}}

License

This game is treeware. If you like it, plant a tree near you. (Also buy the real game.)

shenzhen-solitaire.nvim's People

Contributors

remerald avatar rktjmp 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

Watchers

 avatar  avatar

shenzhen-solitaire.nvim's Issues

Crash 1

Occurred after clicking the green dragon button. Game was playable after clearing the error.

Perhaps the buffer was un-created somehow before write or was somehow under sized.

do local _let_11_ = pos local row = _let_11_["row"] local col = _let_11_["col"]
local _let_12_ = size local width = _let_12_["width"] local height = _let_12_["height"]
for r = 1, height do
for c = 1, width do
fbo[buffer_name][((r - 1) + row)][((c - 1) + col)] = f(r, c) end end end
return fbo end

shenzhen-solitaire.save.zip (drop .zip ext, added for upload)

2022-08-13_01-16

[Refuses to launch] `#0` not a valid color

Doesn't start the game on the both commands and the lua function.

Error executing Lua callback: .../share/nvim/lazy/lazy.nvim/lua/lazy/core/handler/cmd.lua:32: Vim:E
rror executing Lua callback: ...enzhen-solitaire.nvim/lua/shenzhen-solitaire/ui/view.lua:142: '#0'
is not a valid color
stack traceback:
        [C]: in function 'set_hl'
        ...enzhen-solitaire.nvim/lua/shenzhen-solitaire/ui/view.lua:142: in function 'new'
        ...hen-solitaire.nvim/lua/shenzhen-solitaire/ui/runtime.lua:43: in function <...hen-solitai
re.nvim/lua/shenzhen-solitaire/ui/runtime.lua:31>
stack traceback:
        [builtin#19]: at 0x7f6265cc0640
        [C]: in function 'cmd'
        .../share/nvim/lazy/lazy.nvim/lua/lazy/core/handler/cmd.lua:32: in function <.../share/nvim
/lazy/lazy.nvim/lua/lazy/core/handler/cmd.lua:16>
stack traceback:
        [C]: in function 'cmd'
        .../share/nvim/lazy/lazy.nvim/lua/lazy/core/handler/cmd.lua:32: in function <.../share/nvim
/lazy/lazy.nvim/lua/lazy/core/handler/cmd.lua:16>

Create empty buffer for the game

Currently if I run :ShenzhenSolitaireNewGame if draws the game in the currently opened buffer.
This creates a number of issues:
image

Also, it makes the buffer "modified", even though it was not. And if accidentally write the buffer, it overwrites it:

a.txt
 โ•ญโ”€โ”€โ”€โ”€โ”€โ•ฎ   โ•ญโ”€โ”€โ”€โ”€โ”€โ•ฎ   โ•ญโ”€โ”€โ”€โ”€โ”€โ•ฎ             โ•ญโ”€โ”€โ”€โ”€โ”€โ•ฎ   โ•ญโ”€โ”€โ”€โ”€โ”€โ•ฎ   โ•ญโ”€โ”€โ”€โ”€โ”€โ•ฎ   โ•ญโ”€โ”€โ”€โ”€โ”€โ•ฎ
 โ”‚_    โ”‚   โ”‚_    โ”‚   โ”‚_    โ”‚     < ล      โ”‚_    โ”‚   โ”‚_    โ”‚   โ”‚_    โ”‚   โ”‚_    โ”‚
 โ”‚     โ”‚   โ”‚     โ”‚   โ”‚     โ”‚     < ร‘     โ”‚     โ”‚   โ”‚     โ”‚   โ”‚     โ”‚   โ”‚     โ”‚
 โ”‚     โ”‚   โ”‚     โ”‚   โ”‚     โ”‚     < ร•     โ”‚     โ”‚   โ”‚     โ”‚   โ”‚     โ”‚   โ”‚     โ”‚
 โ•ฐโ”€โ”€โ”€โ”€โ”€โ•ฏ   โ•ฐโ”€โ”€โ”€โ”€โ”€โ•ฏ   โ•ฐโ”€โ”€โ”€โ”€โ”€โ•ฏ             โ•ฐโ”€โ”€โ”€โ”€โ”€โ•ฏ   โ•ฐโ”€โ”€โ”€โ”€โ”€โ•ฏ   โ•ฐโ”€โ”€โ”€โ”€โ”€โ•ฏ   โ•ฐโ”€โ”€โ”€โ”€โ”€โ•ฏ
                                                                              
 โ•ญโ”€โ”€โ”€โ”€โ”€โ•ฎ   โ•ญโ”€โ”€โ”€โ”€โ”€โ•ฎ   โ•ญโ”€โ”€โ”€โ”€โ”€โ•ฎ   โ•ญโ”€โ”€โ”€โ”€โ”€โ•ฎ   โ•ญโ”€โ”€โ”€โ”€โ”€โ•ฎ   โ•ญโ”€โ”€โ”€โ”€โ”€โ•ฎ   โ•ญโ”€โ”€โ”€โ”€โ”€โ•ฎ   โ•ญโ”€โ”€โ”€โ”€โ”€โ•ฎ
 โ”‚1    โ”‚   โ”‚ร‘    โ”‚   โ”‚6    โ”‚   โ”‚9    โ”‚   โ”‚9    โ”‚   โ”‚7    โ”‚   โ”‚ร‘    โ”‚   โ”‚3    โ”‚
 โ•ญโ”€โ”€โ”€โ”€โ”€โ•ฎ   โ•ญโ”€โ”€โ”€โ”€โ”€โ•ฎ   โ•ญโ”€โ”€โ”€โ”€โ”€โ•ฎ   โ•ญโ”€โ”€โ”€โ”€โ”€โ•ฎ   โ•ญโ”€โ”€โ”€โ”€โ”€โ•ฎ   โ•ญโ”€โ”€โ”€โ”€โ”€โ•ฎ   โ•ญโ”€โ”€โ”€โ”€โ”€โ•ฎ   โ•ญโ”€โ”€โ”€โ”€โ”€โ•ฎ
 โ”‚ร•    โ”‚   โ”‚4    โ”‚   โ”‚ล     โ”‚   โ”‚ร‘    โ”‚   โ”‚ร•    โ”‚   โ”‚ร•    โ”‚   โ”‚2    โ”‚   โ”‚5    โ”‚
 โ•ญโ”€โ”€โ”€โ”€โ”€โ•ฎ   โ•ญโ”€โ”€โ”€โ”€โ”€โ•ฎ   โ•ญโ”€โ”€โ”€โ”€โ”€โ•ฎ   โ•ญโ”€โ”€โ”€โ”€โ”€โ•ฎ   โ•ญโ”€โ”€โ”€โ”€โ”€โ•ฎ   โ•ญโ”€โ”€โ”€โ”€โ”€โ•ฎ   โ•ญโ”€โ”€โ”€โ”€โ”€โ•ฎ   โ•ญโ”€โ”€โ”€โ”€โ”€โ•ฎ
 โ”‚5    โ”‚   โ”‚1    โ”‚   โ”‚ร‘    โ”‚   โ”‚3    โ”‚   โ”‚8    โ”‚   โ”‚8    โ”‚   โ”‚6    โ”‚   โ”‚ฦ’    โ”‚
 โ•ญโ”€โ”€โ”€โ”€โ”€โ•ฎ   โ•ญโ”€โ”€โ”€โ”€โ”€โ•ฎ   โ•ญโ”€โ”€โ”€โ”€โ”€โ•ฎ   โ•ญโ”€โ”€โ”€โ”€โ”€โ•ฎ   โ•ญโ”€โ”€โ”€โ”€โ”€โ•ฎ   โ•ญโ”€โ”€โ”€โ”€โ”€โ•ฎ   โ•ญโ”€โ”€โ”€โ”€โ”€โ•ฎ   โ•ญโ”€โ”€โ”€โ”€โ”€โ•ฎ
 โ”‚4    โ”‚   โ”‚2    โ”‚   โ”‚4    โ”‚   โ”‚9    โ”‚   โ”‚6    โ”‚   โ”‚1    โ”‚   โ”‚ล     โ”‚   โ”‚3    โ”‚
 โ•ญโ”€โ”€โ”€โ”€โ”€โ•ฎ   โ•ญโ”€โ”€โ”€โ”€โ”€โ•ฎ   โ•ญโ”€โ”€โ”€โ”€โ”€โ•ฎ   โ•ญโ”€โ”€โ”€โ”€โ”€โ•ฎ   โ•ญโ”€โ”€โ”€โ”€โ”€โ•ฎ   โ•ญโ”€โ”€โ”€โ”€โ”€โ•ฎ   โ•ญโ”€โ”€โ”€โ”€โ”€โ•ฎ   โ•ญโ”€โ”€โ”€โ”€โ”€โ•ฎ
 โ”‚8    โ”‚   โ”‚2    โ”‚   โ”‚ล     โ”‚   โ”‚ร•    โ”‚   โ”‚7    โ”‚   โ”‚ล     โ”‚   โ”‚7    โ”‚   โ”‚5    โ”‚
 โ”‚     โ”‚   โ”‚     โ”‚   โ”‚     โ”‚   โ”‚     โ”‚   โ”‚     โ”‚   โ”‚     โ”‚   โ”‚     โ”‚   โ”‚     โ”‚
 โ”‚     โ”‚   โ”‚     โ”‚   โ”‚     โ”‚   โ”‚     โ”‚   โ”‚     โ”‚   โ”‚     โ”‚   โ”‚     โ”‚   โ”‚     โ”‚
 โ•ฐโ”€โ”€โ”€โ”€โ”€โ•ฏ   โ•ฐโ”€โ”€โ”€โ”€โ”€โ•ฏ   โ•ฐโ”€โ”€โ”€โ”€โ”€โ•ฏ   โ•ฐโ”€โ”€โ”€โ”€โ”€โ•ฏ   โ•ฐโ”€โ”€โ”€โ”€โ”€โ•ฏ   โ•ฐโ”€โ”€โ”€โ”€โ”€โ•ฏ   โ•ฐโ”€โ”€โ”€โ”€โ”€โ•ฏ   โ•ฐโ”€โ”€โ”€โ”€โ”€โ•ฏ
                                                                              
                                                                              
wins: 0 moves: 0                                                              
                                                                              
                                                                              
                                                                              
                                                                              
                                                                              
                                                                              
                                                                              
                                                                              
                                                                              
                                                                              
                                                                              
                                                                              
                                                                              
                                                                              
                                                                              
                                                                              
                                                                              
                                                                              

Plus, I can't close the game without closing the buffer I was editing and if I have any unwritten changes to it, I can't write them anymore, so I have to close the buffer losing the unsaved changes.

The easiest solution would be to create a new empty buffer for the game not to interfere with the existing one.

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.