Releases: Kenny2github/mahjong
Releases · Kenny2github/mahjong
2.0.0rc3
New Stuff
Hand.discarders
contains aPlayer
for everyTile
inHand.discarded
Changes
Number
no longer includesFlower
andSeason
Tile
and subclasses now have run-time typechecking on the number based on suitHand.play
now raises aRuntimeError
if the hand is part of aRound
Fixes
(answerable).answer
could returnNone
instead of aHandEnding
when running standalone fromHand
- Annotated some attributes that were missing them
Hand.turncount
can no longer beNone
, only 0Flower
andSeason
values were being set toWind.*
instead of the integer values
2.0.0rc2
Fixes
- Update
__all__
s in the various modules - Cleanup a little
2.0.0rc1
New Stuff
py -m mahjong
now takes a--game
argument to specify playing a whole game instead of the new default, one hand only.mahjong.melds.FLAG_FAAN
is a mapping from eachWuFlag
to the amount of faan it's worth.Wu()
now takes adiscarder
argument beforeflags
representing the seat of who pays the penalty for this hand being won. It is set as aWind
toWu.discarder
.Wu.flags
takes the same arguments asWu.faan
and computes only the situational flags. Faan calculation is still done inWu.faan
.mahjong.melds.faan
is a simple function that computes faan from flags, usingFLAG_FAAN
.- Bonus-related
WuFlag
s. HandEnding.faan
combinesWu.faan
andPlayer.faan
since it has access to both, as well as seat and prevailing winds.HandEnding.points
calculates the points that each player owes or receives, as well as still returning the flags.mahjong.game.STOCK_TABLES
are some stock faan-to-points translation tables to pass toHandEnding.points
. The default isSTOCK_TABLES['random_app']
.Question.SELF_DRAW_Q
is now asked to confirm whether to commit to a self-draw, instead of just seizing upon it by default.- A
Hand
can be instantiated on its own now:- with a
Round
subclass if the instantiator has control over such machinery. - with a list of
Player
s if the instantiator has control over the machinery by means of something other than aRound
subclass. - with
None
if theHand
is to be played standalone, in which caseHand.play
is the entry point instead ofGame.play
.
- with a
WuFlag.TWELVE_PIECE
,GAVE_DRAGON
,GAVE_KONG
, and support for such penalties (including inHandEnding.points
).
Changes
py -m mahjong
now plays only one hand by defaultWuFlag
values are now hardcoded instead ofauto
- Swapped
WuFlag.NINE_GATES
to1 << 9
andWuFlag.THIRTEEN_ORPHANS
to1 << 13
because it just makes sense that way - Renamed
Wu.flags
toWu.base_flags
- Just use *args and **kwargs in
Wu.from_str
for the extra arguments - Separated faan calculation from flags computation. This has little effect on
Wu.faan
; the most significant is that mutually exclusive flags are now actually mutually excluded, rather than just the faan being reduced to compensate. - Things that were nominally
int
s but semanticallyWind
s are now allWind
s, except in some cases when passing them as arguments (in which case theWind
constructor is applied). Player.bonus_faan
now returns both faan and flags of its ownHandEnding.gen: Generator
is nowHandEnding.hand: Hand
Hand.round
is now OptionalHand.gen
andHand.players
are now set, to support playing a standalone hand- Stealing a tile from the previous player's discard is now confirmed by
Question.MELD_FROM_DISCARD_Q
for winning hands in addition to other melds - Removed internal
Answerable
ABC
Fixes
Wu.base_flags
(formerlyWu.flags
) is now properly annotated- Thirteen Orphans are only valid if the extra tile is a duplicate of any of the other tiles, not when it's literally any tile. A set of valid Thirteen Orphans tiles will therefore equal a set of all Thirteen Orphans tiles.
_UncheckedWu.fixed_melds
was missing and caused anAttributeError
when actually encountering Thirteen OrphansTile.from_str
failed to typecheck because ofsuit
Game.play
might return aHandEnding
on first go, though all wins should be confirmed first by now.