aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Torokhov <torokhov-s-a@yandex.ru>2020-10-25 15:28:08 +0300
committerSergey Torokhov <torokhov-s-a@yandex.ru>2020-10-25 15:35:57 +0300
commitef556bcba0d3fb3451d080cdf0ce559c00ad6c72 (patch)
treeddaf8b7a0f03652abda064bfc933165d1be4af9b /games-board
parentsys-fs/gfs2-utils: remove useless blank lines (diff)
downloadguru-ef556bcba0d3fb3451d080cdf0ce559c00ad6c72.tar.gz
guru-ef556bcba0d3fb3451d080cdf0ce559c00ad6c72.tar.bz2
guru-ef556bcba0d3fb3451d080cdf0ce559c00ad6c72.zip
games-board/rmahjong: new package
This is attempt python3 "final" porting the game by means of additional patches to initial py3 port. The game is playable for me at "single player + 3 bots". Network game process is not tested. Menu icon for desktop entry is fetched from Kmahjongg project. Signed-off-by: Sergey Torokhov <torokhov-s-a@yandex.ru>
Diffstat (limited to 'games-board')
-rw-r--r--games-board/rmahjong/Manifest2
-rw-r--r--games-board/rmahjong/files/rmahjong-0.4_fix_python3_compat.patch87
-rw-r--r--games-board/rmahjong/files/rmahjong-0.4_fix_tests.patch282
-rw-r--r--games-board/rmahjong/metadata.xml18
-rw-r--r--games-board/rmahjong/rmahjong-0.4_p20201013.ebuild83
5 files changed, 472 insertions, 0 deletions
diff --git a/games-board/rmahjong/Manifest b/games-board/rmahjong/Manifest
new file mode 100644
index 000000000..624f607c7
--- /dev/null
+++ b/games-board/rmahjong/Manifest
@@ -0,0 +1,2 @@
+DIST kmahjongg_rmahjong.png 3816 BLAKE2B 8029e6c3f4eddff9d3593ad7d5615860cd3b9d9bc4b067145e2d191b8fec00f934f3752adec32db11eb7f3e31eba7d4586a2c2f005de4ded8555ec73a4f2f81f SHA512 49cb371b1260aa23bb7b341247047cf7abc59487fd75cc365c2c6f77588af7a83dfed73d7fc1845edcedb8a9b6810ac39dbecff065c3799e3fcc7195df84e67c
+DIST rmahjong-0.4_p20201013.tar.gz 1399540 BLAKE2B 9dd1c40fea7c2d93e33a7bea0e1b66912eb547c64b45bbeadd95e4234380786551005cec8bf5edc1a7e8b135e5a66b2af80b4f22d257e14aa7068ff9959cee64 SHA512 9eface62972abe37753c380af713e168d39e23f6031af08d735467669b2dd0cbe5dec40eb9e750fff675a054791a58cfad710266229c966d94c190990f63c466
diff --git a/games-board/rmahjong/files/rmahjong-0.4_fix_python3_compat.patch b/games-board/rmahjong/files/rmahjong-0.4_fix_python3_compat.patch
new file mode 100644
index 000000000..d6ad58937
--- /dev/null
+++ b/games-board/rmahjong/files/rmahjong-0.4_fix_python3_compat.patch
@@ -0,0 +1,87 @@
+diff --git a/client/client.py b/client/client.py
+--- a/client/client.py
++++ b/client/client.py
+@@ -138,10 +138,10 @@ class Mahjong:
+
+ def init_player_boxes(self, names, player_winds, score):
+ self.player_boxes = [
+- PlayerBox((50, 700), names[0], player_winds[0], int(score[0]), direction_up, (0,-80)),
+- PlayerBox((954, 50), names[1], player_winds[1], int(score[1]), direction_left, (-210, 0)),
+- PlayerBox((700, 0), names[2], player_winds[2], int(score[2]), direction_up, (0,80)),
+- PlayerBox((0, 50), names[3], player_winds[3], int(score[3]), direction_right, (80,0)) ]
++ PlayerBox((50, 700), names[0], player_winds[0], int(float(score[0])), direction_up, (0,-80)),
++ PlayerBox((954, 50), names[1], player_winds[1], int(float(score[1])), direction_left, (-210, 0)),
++ PlayerBox((700, 0), names[2], player_winds[2], int(float(score[2])), direction_up, (0,80)),
++ PlayerBox((0, 50), names[3], player_winds[3], int(float(score[3])), direction_right, (80,0)) ]
+ for widget in self.player_boxes:
+ self.gui.add_widget(widget)
+
+diff --git a/client/states.py b/client/states.py
+--- a/client/states.py
++++ b/client/states.py
+@@ -555,8 +555,8 @@ class ScoreState(RoundPreparingState):
+ results = []
+ for wind in winds:
+ name = (self.mahjong.get_player_name(wind))
+- score = (int(self.message[wind + "_score"]))
+- payment = (int(self.message[wind + "_payment"]))
++ score = (int(float(self.message[wind + "_score"])))
++ payment = (int(float(self.message[wind + "_payment"])))
+ results.append((name, score, payment))
+ results.sort(key = lambda r: r[1], reverse = True)
+ return results
+diff --git a/client/tilepainter.py b/client/tilepainter.py
+--- a/client/tilepainter.py
++++ b/client/tilepainter.py
+@@ -89,7 +89,7 @@ class TilePainter:
+ img = self.tile_images[name]
+ w = img.get_width()
+ h = img.get_height()
+- screen.blit(pygame.transform.smoothscale(img, (w/4, h/4)), position)
++ screen.blit(pygame.transform.smoothscale(img, (w//4, h//4)), position)
+
+ def draw_tile_list(self, screen, position, tile_names, space = 0):
+ for i, tile_name in enumerate(tile_names):
+diff --git a/server/botengine.py b/server/botengine.py
+index 03623f9..b128135 100644
+--- a/server/botengine.py
++++ b/server/botengine.py
+@@ -71,7 +71,7 @@ class BotEngine():
+
+ def get_tiles(self, blocking = False):
+ if self._is_next_line() or blocking:
+- return map(Tile, (self._read_line().strip().split()))
++ return [*map(Tile, (self._read_line().strip().split()))]
+ else:
+ return None
+
+diff --git a/server/eval.py b/server/eval.py
+index 042ee54..dc7e463 100644
+--- a/server/eval.py
++++ b/server/eval.py
+@@ -19,6 +19,7 @@ from tile import Pon, Chi
+ from tile import red_dragon, white_dragon, green_dragon, dragons
+ from tile import bamboos, chars, pins, all_tiles, honors
+ from copy import copy
++import functools
+
+ def is_hand_open(sets):
+ for set in sets:
+@@ -274,7 +275,7 @@ def eval_sets(pair, sets, round_wind, player_wind, last_tile, wintype):
+ # Other hands
+ for name, fn in score_functions:
+ score = fn(pair, sets)
+- if score > 0:
++ if score:
+ result.append((name, score))
+
+ # Pinfu
+@@ -304,7 +305,7 @@ def eval_sets(pair, sets, round_wind, player_wind, last_tile, wintype):
+
+
+ def sum_over_sets(sets, fn):
+- return reduce(lambda a, s: fn(s) + a, sets, 0)
++ return functools.reduce(lambda a, s: fn(s) + a, sets, 0)
+
+ def for_all_tiles_in_sets(sets, fn):
+ return for_all_sets(sets, lambda s: s.all_tiles(fn))
diff --git a/games-board/rmahjong/files/rmahjong-0.4_fix_tests.patch b/games-board/rmahjong/files/rmahjong-0.4_fix_tests.patch
new file mode 100644
index 000000000..7926e7149
--- /dev/null
+++ b/games-board/rmahjong/files/rmahjong-0.4_fix_tests.patch
@@ -0,0 +1,282 @@
+diff --git a/server/test.py b/server/test.py
+--- a/server/test.py
++++ b/server/test.py
+@@ -25,7 +25,7 @@ from botengine import BotEngine
+
+
+ def tiles(strs):
+- return map(Tile, strs)
++ return [*map(Tile, strs)]
+
+
+ def chi(tile_name):
+@@ -156,52 +156,52 @@ class EvalHandTestCase(TestCase):
+ hand, sets, r = h
+ score = count_of_tiles_yaku(tiles(hand), sets, [], Tile("XX"), Tile("XX"), "Ron")
+ yaku = find_tiles_yaku(tiles(hand), sets, [], Tile("XX"), Tile("XX"), "Ron")
+- self.assert_(score == r, "Hand %i returned score %i %s hand=%s" % (hand_id, score, yaku, hand))
++ self.assertTrue(score == r, "Hand %i returned score %i %s hand=%s" % (hand_id, score, yaku, hand))
+
+ hand = [ "WE", "C2", "C3", "C4", "WN", "WN", "WN", "DR", "B9", "DR", "B8", "B7", "WE", "WE" ]
+ sets = []
+- self.assertEquals(count_of_tiles_yaku(tiles(hand), sets, [], Tile("WE"), Tile("WN"), "Ron"), 2)
+- self.assertEquals(count_of_tiles_yaku(tiles(hand), sets, [], Tile("WE"), Tile("WN"), "Tsumo"), 3)
+- self.assertEquals(count_of_tiles_yaku(tiles(hand), sets, [], Tile("WE"), Tile("WE"), "Ron"), 2)
+- self.assertEquals(count_of_tiles_yaku(tiles(hand), sets, [], Tile("WE"), Tile("WS"), "Ron"), 1)
++ self.assertEqual(count_of_tiles_yaku(tiles(hand), sets, [], Tile("WE"), Tile("WN"), "Ron"), 2)
++ self.assertEqual(count_of_tiles_yaku(tiles(hand), sets, [], Tile("WE"), Tile("WN"), "Tsumo"), 3)
++ self.assertEqual(count_of_tiles_yaku(tiles(hand), sets, [], Tile("WE"), Tile("WE"), "Ron"), 2)
++ self.assertEqual(count_of_tiles_yaku(tiles(hand), sets, [], Tile("WE"), Tile("WS"), "Ron"), 1)
+ hand = [ "WE", "DW", "DW", "DW", "C4", "C2", "C3", "DR", "B9", "DR", "B8", "B7", "WE", "WE" ]
+- self.assertEquals(count_of_tiles_yaku(tiles(hand), sets, [], Tile("WE"), Tile("WS"), "Ron"), 2)
++ self.assertEqual(count_of_tiles_yaku(tiles(hand), sets, [], Tile("WE"), Tile("WS"), "Ron"), 2)
+ hand,sets = ([ "C4", "C5", "C6", "C7", "B7", "B8", "B9", "P2", "P3", "P4", "C4"], [kan("WS")])
+- self.assertEquals(count_of_tiles_yaku(tiles(hand), sets, [], Tile("WE"), Tile("WS"), "Ron"), 1)
++ self.assertEqual(count_of_tiles_yaku(tiles(hand), sets, [], Tile("WE"), Tile("WS"), "Ron"), 1)
+ hand,sets = ([ "C4", "C5", "C6", "C7", "B7", "B8", "B9", "P2", "P3", "P4", "C4"], [ckan("WS")])
+- self.assertEquals(count_of_tiles_yaku(tiles(hand), sets, [], Tile("WE"), Tile("WS"), "Ron"), 1)
++ self.assertEqual(count_of_tiles_yaku(tiles(hand), sets, [], Tile("WE"), Tile("WS"), "Ron"), 1)
+
+ hand = [ "WN", "B9", "B6", "WN", "B4", "B8", "B5", "B7"]
+ sets = [chi("B1"), chi("P5")]
+- self.assertEquals(count_of_tiles_yaku(tiles(hand), sets, [], Tile("WE"), Tile("WW"), "Ron"), 1)
+- self.assertEquals(count_of_tiles_yaku(tiles(hand), sets, [], Tile("WE"), Tile("WW"), "Tsumo"), 1)
++ self.assertEqual(count_of_tiles_yaku(tiles(hand), sets, [], Tile("WE"), Tile("WW"), "Ron"), 1)
++ self.assertEqual(count_of_tiles_yaku(tiles(hand), sets, [], Tile("WE"), Tile("WW"), "Tsumo"), 1)
+
+ def test_basic_payment(self):
+- self.assert_(compute_payment(2, 40, "Ron", Tile("WN")) == ("", 2600))
+- self.assert_(compute_payment(2, 40, "Ron", Tile("WE")) == ("", 3900))
+- self.assertEquals(compute_payment(2, 40, "Tsumo", Tile("WN")), ("", (700,1300)))
+- self.assertEquals(compute_payment(2, 40, "Tsumo", Tile("WE")), ("", (1300, 0)))
++ self.assertTrue(compute_payment(2, 40, "Ron", Tile("WN")) == ("", 2600))
++ self.assertTrue(compute_payment(2, 40, "Ron", Tile("WE")) == ("", 3900))
++ self.assertEqual(compute_payment(2, 40, "Tsumo", Tile("WN")), ("", (700,1300)))
++ self.assertEqual(compute_payment(2, 40, "Tsumo", Tile("WE")), ("", (1300, 0)))
+
+- self.assert_(compute_payment(1, 40, "Ron", Tile("WN")) == ("", 1300))
+- self.assert_(compute_payment(1, 40, "Ron", Tile("WE")) == ("", 2000))
+- self.assertEquals(compute_payment(1, 40, "Tsumo", Tile("WN")), ("", (400, 700)))
+- self.assertEquals(compute_payment(1, 40, "Tsumo", Tile("WE")), ("", (700, 0)))
++ self.assertTrue(compute_payment(1, 40, "Ron", Tile("WN")) == ("", 1300))
++ self.assertTrue(compute_payment(1, 40, "Ron", Tile("WE")) == ("", 2000))
++ self.assertEqual(compute_payment(1, 40, "Tsumo", Tile("WN")), ("", (400, 700)))
++ self.assertEqual(compute_payment(1, 40, "Tsumo", Tile("WE")), ("", (700, 0)))
+
+- self.assertEquals(compute_payment(4, 20, "Tsumo", Tile("WN")), ("", (1300, 2600)))
+- self.assertEquals(compute_payment(4, 20, "Tsumo", Tile("WE")), ("", (2600, 0)))
++ self.assertEqual(compute_payment(4, 20, "Tsumo", Tile("WN")), ("", (1300, 2600)))
++ self.assertEqual(compute_payment(4, 20, "Tsumo", Tile("WE")), ("", (2600, 0)))
+
+- self.assertEquals(compute_payment(3, 20, "Tsumo", Tile("WN")), ("", (700, 1300)))
+- self.assertEquals(compute_payment(3, 20, "Tsumo", Tile("WE")), ("", (1300, 0)))
++ self.assertEqual(compute_payment(3, 20, "Tsumo", Tile("WN")), ("", (700, 1300)))
++ self.assertEqual(compute_payment(3, 20, "Tsumo", Tile("WE")), ("", (1300, 0)))
+
+- self.assertEquals(compute_payment(5, 40, "Ron", Tile("WN")), ("Mangan", 8000))
+- self.assertEquals(compute_payment(5, 40, "Ron", Tile("WE")), ("Mangan", 12000))
+- self.assertEquals(compute_payment(5, 40, "Tsumo", Tile("WN")), ("Mangan", (2000, 4000)))
+- self.assertEquals(compute_payment(5, 40, "Tsumo", Tile("WE")), ("Mangan", (4000, 0)))
++ self.assertEqual(compute_payment(5, 40, "Ron", Tile("WN")), ("Mangan", 8000))
++ self.assertEqual(compute_payment(5, 40, "Ron", Tile("WE")), ("Mangan", 12000))
++ self.assertEqual(compute_payment(5, 40, "Tsumo", Tile("WN")), ("Mangan", (2000, 4000)))
++ self.assertEqual(compute_payment(5, 40, "Tsumo", Tile("WE")), ("Mangan", (4000, 0)))
+
+- self.assertEquals(compute_payment(13, 40, "Ron", Tile("WN")), ("Yakuman", 32000))
+- self.assertEquals(compute_payment(13, 40, "Ron", Tile("WE")), ("Yakuman", 48000))
+- self.assertEquals(compute_payment(13, 40, "Tsumo", Tile("WN")), ("Yakuman", (8000, 16000)))
+- self.assertEquals(compute_payment(13, 40, "Tsumo", Tile("WE")), ("Yakuman", (16000, 0)))
++ self.assertEqual(compute_payment(13, 40, "Ron", Tile("WN")), ("Yakuman", 32000))
++ self.assertEqual(compute_payment(13, 40, "Ron", Tile("WE")), ("Yakuman", 48000))
++ self.assertEqual(compute_payment(13, 40, "Tsumo", Tile("WN")), ("Yakuman", (8000, 16000)))
++ self.assertEqual(compute_payment(13, 40, "Tsumo", Tile("WE")), ("Yakuman", (16000, 0)))
+
+ def test_tenpai(self):
+ hands = (([ "B1", "B2", "B3", "B4", "B5", "B6", "B7", "B8", "B9", "P1", "P1", "P1", "WN"], [], True, ["WN"]),
+@@ -215,10 +215,10 @@ class EvalHandTestCase(TestCase):
+ ([ "P1", "P2", "P3", "DR", "DR", "DR", "B7", "B9", "WN", "WN"], [ pon("P1") ], True, ["B8"]))
+
+ for h, sets, tenpai, w in hands:
+- self.assertEquals(hand_in_tenpai(tiles(h), sets), tenpai)
++ self.assertEqual(hand_in_tenpai(tiles(h), sets), tenpai)
+ waiting = [ t.name for t in find_waiting_tiles(tiles(h), sets) ]
+ waiting.sort()
+- self.assertEquals(waiting, w)
++ self.assertEqual(waiting, w)
+
+ def test_riichi(self):
+ hands = (([ "P5", "B1", "B2", "B3", "B4", "B5", "B6", "B7", "B8", "B9", "P1", "P1", "P1", "WN"], [], True),
+@@ -229,7 +229,7 @@ class EvalHandTestCase(TestCase):
+ ([ "P4", "P4", "P4", "C6", "C4", "C5", "B7", "B6", "B8", "B8", "DR" ], [ ckan("WE") ], True),
+ ([ "P4", "P4", "C6", "P3", "C5", "B7", "B6", "P1", "DR", "B8", "DR" ], [ ckan("WE") ], False))
+ for h, sets, riichi in hands:
+- self.assertEquals(riichi_test(tiles(h), sets), riichi, [h,sets])
++ self.assertEqual(riichi_test(tiles(h), sets), riichi, [h,sets])
+
+ def test_singlewait(self):
+ # Last tile in the list comes last
+@@ -242,21 +242,21 @@ class EvalHandTestCase(TestCase):
+ ([ "B1", "B2", "B3", "B4", "B5", "B6", "B7", "B8", "B9", "P1", "P1", "P3", "P1", "P2"], [], True),
+ ([ "B1", "B2", "B3", "C8", "C8", "C8", "DW", "DW", "DW", "P4", "P4", "P1", "P2", "P3"], [], True))
+ for h, sets, singlewait in hands:
+- self.assertEquals(check_single_waiting(tiles(h), sets), singlewait)
++ self.assertEqual(check_single_waiting(tiles(h), sets), singlewait)
+
+
+ def test_score(self):
+ hand = [ "WN", "B9", "B6", "WN", "B4", "B8", "B5", "B7"]
+ sets = [chi("B1"), chi("P5")]
+ payment, scores, minipoints = compute_score(tiles(hand), sets, "Ron", ([], [ Tile("B7") ]), [], Tile("WE"), Tile("WW"))
+- self.assertEquals(payment, ('', 2000))
+- self.assertEquals(minipoints, 30)
++ self.assertEqual(payment, ('', 2000))
++ self.assertEqual(minipoints, 30)
+
+ hand = [ "C2", "C2", "C4", "C4", "C7", "C7", "B6", "B8", "B8", "C1", "C1", "WS", "WS", "B6"]
+ sets = []
+ payment, scores, minipoints = compute_score(tiles(hand), sets, "Ron", ([ Tile("C7") ], [ Tile("B5") ]), [], Tile("WS"), Tile("WW"))
+- self.assertEquals(payment, ('', 6400))
+- self.assertEquals(minipoints, 25)
++ self.assertEqual(payment, ('', 6400))
++ self.assertEqual(minipoints, 25)
+
+
+ class BotEngineTestCase(TestCase):
+@@ -272,9 +272,9 @@ class BotEngineTestCase(TestCase):
+ e.set_wall(4 * all_tiles)
+ e.question_discard()
+ action = e.get_string()
+- self.assert_(action == "Discard")
++ self.assertTrue(action == "Discard")
+ tile = e.get_tile()
+- self.assert_(tile in h)
++ self.assertTrue(tile in h)
+ finally:
+ e.shutdown()
+
+@@ -289,9 +289,9 @@ class BotEngineTestCase(TestCase):
+ e.set_wall(4 * all_tiles)
+ e.question_discard()
+ action = e.get_string()
+- self.assert_(action == "Discard")
++ self.assertTrue(action == "Discard")
+ tile = e.get_tile()
+- self.assert_(tile in h)
++ self.assertTrue(tile in h)
+ finally:
+ e.shutdown()
+
+@@ -308,7 +308,7 @@ class BotEngineTestCase(TestCase):
+ e.set_sets(sets)
+ e.question_yaku()
+ score = e.get_int()
+- self.assert_(score == r, "Hand %i returned score %i" % (hand_id, score))
++ self.assertTrue(score == r, "Hand %i returned score %i" % (hand_id, score))
+
+ finally:
+ e.shutdown()
+@@ -324,23 +324,23 @@ class BotEngineTestCase(TestCase):
+ e.set_round_wind(Tile("WE"))
+ e.set_player_wind(Tile("WN"))
+ e.question_yaku()
+- self.assertEquals(e.get_int(), 2)
++ self.assertEqual(e.get_int(), 2)
+
+ e.set_round_wind(Tile("WE"))
+ e.set_player_wind(Tile("WE"))
+ e.question_yaku()
+- self.assertEquals(e.get_int(), 2)
++ self.assertEqual(e.get_int(), 2)
+
+ e.set_round_wind(Tile("WE"))
+ e.set_player_wind(Tile("WS"))
+ e.question_yaku()
+- self.assertEquals(e.get_int(), 1)
++ self.assertEqual(e.get_int(), 1)
+
+ e.set_sets([ pon("DW") ])
+ e.set_round_wind(Tile("WE"))
+ e.set_player_wind(Tile("WS"))
+ e.question_yaku()
+- self.assertEquals(e.get_int(), 2)
++ self.assertEqual(e.get_int(), 2)
+
+ finally:
+ e.shutdown()
+@@ -357,7 +357,7 @@ class BotEngineTestCase(TestCase):
+ e.set_wall(wall)
+ e.question_discard_tiles()
+ tile_list = e.get_tiles()
+- self.assertEquals(tile_list, [Tile("B1"), Tile("B1"), Tile("B1")])
++ self.assertEqual(tile_list, [Tile("B1"), Tile("B1"), Tile("B1")])
+ finally:
+ e.shutdown()
+
+@@ -373,7 +373,7 @@ class BotEngineTestCase(TestCase):
+ e.set_wall(wall)
+ e.question_discard_tiles()
+ tile_list = e.get_tiles()
+- self.assertEquals(tile_list, [Tile("DR")])
++ self.assertEqual(tile_list, [Tile("DR")])
+ finally:
+ e.shutdown()
+
+@@ -394,12 +394,12 @@ class BotEngineTestCase(TestCase):
+ e.set_wall(wall)
+ e.question_discard_tiles()
+ tile_list = e.get_tiles()
+- self.assertEquals(tile_list, [Tile("P4")])
++ self.assertEqual(tile_list, [Tile("P4")])
+ h = tiles([ "C8", "C8", "C2", "C2", "C3", "C3", "B2", "B2", "B4", "B4", "P1", "P4", "B5", "B5" ])
+ e.set_hand(h)
+ e.question_discard_tiles()
+ tile_list = e.get_tiles()
+- self.assertEquals(tile_list, [Tile("P1")])
++ self.assertEqual(tile_list, [Tile("P1")])
+
+ wall = 3 * all_tiles
+ wall.remove(Tile("WW"))
+@@ -411,7 +411,7 @@ class BotEngineTestCase(TestCase):
+ e.set_hand(h)
+ e.question_discard_tiles()
+ tile_list = e.get_tiles()
+- self.assertEquals(tile_list, [Tile("C9")])
++ self.assertEqual(tile_list, [Tile("C9")])
+
+ finally:
+ e.shutdown()
+@@ -429,18 +429,18 @@ class BotEngineTestCase(TestCase):
+ e.question_discard()
+
+ action = e.get_string()
+- self.assert_(action == "Kan")
++ self.assertTrue(action == "Kan")
+ tile = e.get_tile()
+- self.assertEquals(tile, Tile("P9"))
++ self.assertEqual(tile, Tile("P9"))
+
+ h = tiles([ "C1", "C2", "C3", "P9", "B1", "B1", "B1", "P1", "P3", "DR", "DR" ])
+ e.set_hand(h)
+ e.set_sets([pon("P9")])
+ e.question_discard()
+ action = e.get_string()
+- self.assert_(action == "Kan")
++ self.assertTrue(action == "Kan")
+ tile = e.get_tile()
+- self.assertEquals(tile, Tile("P9"))
++ self.assertEqual(tile, Tile("P9"))
+
+
+ h = tiles([ "C1", "C2", "C3", "P9", "P9", "P9", "P9", "P7", "P8", "P1", "P3", "DR", "DR", "C5" ])
+@@ -448,9 +448,9 @@ class BotEngineTestCase(TestCase):
+ e.set_sets([])
+ e.question_discard()
+ action = e.get_string()
+- self.assert_(action == "Discard")
++ self.assertTrue(action == "Discard")
+ tile = e.get_tile()
+- self.assertEquals(tile, Tile("C5"))
++ self.assertEqual(tile, Tile("C5"))
+
+ finally:
+ e.shutdown()
diff --git a/games-board/rmahjong/metadata.xml b/games-board/rmahjong/metadata.xml
new file mode 100644
index 000000000..97c7f078b
--- /dev/null
+++ b/games-board/rmahjong/metadata.xml
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd">
+<pkgmetadata>
+ <maintainer type="person">
+ <email>torokhov-s-a@yandex.ru</email>
+ <name>Sergey Torokhov</name>
+ </maintainer>
+ <longdescription>
+ Riichi Mahjong is the Japanese variant to the Chinese game for four players.
+ RMahjong is the computer implementation of this game.
+
+ RMahjong allows you to play the game over a network,
+ missing players can be replaced by computer players.
+ </longdescription>
+ <upstream>
+ <remote-id type="github">spirali/rmahjong</remote-id>
+ </upstream>
+</pkgmetadata>
diff --git a/games-board/rmahjong/rmahjong-0.4_p20201013.ebuild b/games-board/rmahjong/rmahjong-0.4_p20201013.ebuild
new file mode 100644
index 000000000..28f4c28e9
--- /dev/null
+++ b/games-board/rmahjong/rmahjong-0.4_p20201013.ebuild
@@ -0,0 +1,83 @@
+# Copyright 1999-2020 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=7
+
+PYTHON_COMPAT=( python3_{6,7,8,9} )
+
+inherit desktop python-single-r1 xdg
+
+# Tarball from initial py3 port branch:
+# https://github.com/spirali/rmahjong/tree/py3
+# At least "Furiten", "Red fives" rules aren't implemented.
+PKG_sha="119704b581e3358ecb2764bd8e208ea5b24e7695"
+
+DESCRIPTION="Riichi Mahjong, the Japanese variant of the Chinese game Mahjong for 4 players"
+HOMEPAGE="https://github.com/spirali/rmahjong"
+
+# PNG icon is taken from Kmahjongg project (GPL-2), renamed to avoid pkgs conflicts
+SRC_URI="
+ https://github.com/spirali/${PN}/archive/${PKG_sha}.tar.gz -> ${P}.tar.gz
+ https://github.com/KDE/kmahjongg/raw/master/icons/48-apps-kmahjongg.png -> kmahjongg_${PN}.png"
+
+LICENSE="GPL-2"
+SLOT="0"
+KEYWORDS="~amd64 ~x86"
+
+IUSE="test"
+RESTRICT="!test? ( test )"
+REQUIRED_USE="${PYTHON_REQUIRED_USE}"
+
+S="${WORKDIR}/${PN}-${PKG_sha}"
+
+RDEPEND="
+ ${PYTHON_DEPS}
+ dev-python/pygame[X,opengl]
+ $(python_gen_cond_dep '
+ dev-python/pygame[${PYTHON_MULTI_USEDEP}]
+ dev-python/pyopengl[${PYTHON_MULTI_USEDEP}]
+ ')
+"
+DEPEND="test? ( dev-python/unittest2 )"
+
+PATCHES=(
+ "${FILESDIR}/${PN}-0.4_fix_python3_compat.patch"
+ "${FILESDIR}/${PN}-0.4_fix_tests.patch"
+)
+
+src_prepare(){
+ default
+
+ # Disable logging as application log into directory where user access is denied
+ sed -i "/logging.basicConfig/d" "${S}/client/client.py" || die
+ sed -i "/logging.basicConfig/d" "${S}/server/server.py" || die
+ sed -i "/logging.info/d" "${S}/server/server.py" || die
+
+ echo $'#!/bin/sh\ncd '"$(python_get_sitedir)/${PN}"' && ./start.sh' > "${S}/rmahjong"
+}
+
+src_compile() {
+ # Build bots
+ cd "${S}/bot/" && emake
+}
+
+src_test() {
+ cd "${S}/server/" && python3 test.py
+}
+
+src_install() {
+ insinto "$(python_get_sitedir)/${PN}"
+ doins -r {client/,server/,start.sh}
+ fperms 755 $(python_get_sitedir)/${PN}/start.sh
+ fperms 755 $(python_get_sitedir)/${PN}/server/run_server.sh
+
+ insinto "$(python_get_sitedir)/${PN}/bot"
+ doins "bot/bot"
+ fperms 755 $(python_get_sitedir)/${PN}/bot/bot
+
+ python_optimize "${D}/$(python_get_sitedir)/${PN}/"{client,server}/*.py
+
+ dobin "rmahjong"
+ doicon -s 48 "${DISTDIR}/kmahjongg_${PN}.png"
+ make_desktop_entry "${PN}" "RMahjong" "kmahjongg_${PN}.png" "Game;BoardGame;" || die "Failed making desktop entry!"
+}