コード例 #1
0
 def test_matta_for_KomaCannotMoveException(self):
     channel_id = "test_matta_for_KomaCannotMoveException"
     shogi = ShogiInput.init(channel_id, [{
         "id": "user1",
         "name": "user1name",
     }, {
         "id": "user2",
         "name": "user2name",
     }])
     with self.assertRaises(KomaCannotMoveException):
         ShogiInput.matta(channel_id, shogi.first_user.id)
コード例 #2
0
 def test_matta_for_KomaCannotMoveException(self):
     channel_id = "test_matta_for_KomaCannotMoveException"
     shogi = ShogiInput.init(channel_id, [{
         "id": "user1",
         "name": "user1name",
     }, {
         "id": "user2",
         "name": "user2name",
     }])
     with self.assertRaises(KomaCannotMoveException):
         ShogiInput.matta(channel_id, shogi.first_user.id)
コード例 #3
0
def matta(channel, message):
    try:
        ShogiInput.matta(channel.channel_id, channel.own_id)
        message.send("mattaed")
    except UserDifferentException:
        message.reply("You cannot matta because *it's not your turn*")
    except KomaCannotMoveException:
        message.reply("You cannot matta because koma not moved")
    finally:
        board = ShogiInput.get_shogi_board(channel.channel_id)
        board_str = ShogiOutput.make_board_emoji(board)
        message.send(board_str)
コード例 #4
0
 def test_matta(self):
     channel_id = "test_matta"
     shogi = ShogiInput.init(channel_id, [{
         "id": "user1",
         "name": "user1name",
     }, {
         "id": "user2",
         "name": "user2name",
     }])
     ShogiInput.move("76歩", channel_id, shogi.first_user.id)
     self.assertEqual(shogi.board[5][2], Koma.fu)
     ShogiInput.matta(channel_id, shogi.second_user.id)
     self.assertEqual(shogi.board[5][2], Koma.empty)
     ShogiInput.move("76歩", channel_id, shogi.first_user.id)
     self.assertEqual(shogi.board[5][2], Koma.fu)
コード例 #5
0
 def test_matta(self):
     channel_id = "test_matta"
     shogi = ShogiInput.init(channel_id, [{
         "id": "user1",
         "name": "user1name",
     }, {
         "id": "user2",
         "name": "user2name",
     }])
     ShogiInput.move("76歩", channel_id, shogi.first_user.id)
     self.assertEqual(shogi.board[5][2], Koma.fu)
     ShogiInput.matta(channel_id, shogi.second_user.id)
     self.assertEqual(shogi.board[5][2], Koma.empty)
     ShogiInput.move("76歩", channel_id, shogi.first_user.id)
     self.assertEqual(shogi.board[5][2], Koma.fu)
コード例 #6
0
 def test_matta_for_UserDifferentException(self):
     channel_id = "test_matta_for_UserDifferentException"
     shogi = ShogiInput.init(channel_id, [{
         "id": "user1",
         "name": "user1name",
     }, {
         "id": "user2",
         "name": "user2name",
     }])
     ShogiInput.move("76歩", channel_id, shogi.first_user.id)
     self.assertEqual(shogi.board[5][2], Koma.fu)
     with self.assertRaises(UserDifferentException):
         ShogiInput.matta(channel_id, shogi.first_user.id)
     ShogiInput.move("34歩", channel_id, shogi.second_user.id)
     with self.assertRaises(UserDifferentException):
         ShogiInput.matta(channel_id, shogi.second_user.id)
コード例 #7
0
 def test_matta_for_UserDifferentException(self):
     channel_id = "test_matta_for_UserDifferentException"
     shogi = ShogiInput.init(channel_id, [{
         "id": "user1",
         "name": "user1name",
     }, {
         "id": "user2",
         "name": "user2name",
     }])
     ShogiInput.move("76歩", channel_id, shogi.first_user.id)
     self.assertEqual(shogi.board[5][2], Koma.fu)
     with self.assertRaises(UserDifferentException):
         ShogiInput.matta(channel_id, shogi.first_user.id)
     ShogiInput.move("34歩", channel_id, shogi.second_user.id)
     with self.assertRaises(UserDifferentException):
         ShogiInput.matta(channel_id, shogi.second_user.id)
コード例 #8
0
    def test_matta_for_drop_komas(self):
        channel_id = "test_matta_for_da_komas"
        shogi = ShogiInput.init(channel_id, [{
            "id": "user1",
            "name": "user1name",
        }, {
            "id": "user2",
            "name": "user2name",
        }])
        ShogiInput.move("76歩", channel_id, shogi.first_user.id)
        ShogiInput.move("34歩", channel_id, shogi.second_user.id)
        ShogiInput.move("22角", channel_id, shogi.first_user.id)
        ShogiInput.move("同銀", channel_id, shogi.second_user.id)
        ShogiInput.move("55角打", channel_id, shogi.first_user.id)
        ShogiInput.move("33角打", channel_id, shogi.second_user.id)
        ShogiInput.matta(channel_id, shogi.first_user.id)
        ShogiInput.matta(channel_id, shogi.second_user.id)
        ShogiInput.move("55角打", channel_id, shogi.first_user.id)
        ShogiInput.move("33角打", channel_id, shogi.second_user.id)

        self.assertEqual(shogi.board[4][4], Koma.kaku)
        self.assertEqual(shogi.board[2][6], Koma.opponent_kaku)
コード例 #9
0
    def test_matta_for_drop_komas(self):
        channel_id = "test_matta_for_da_komas"
        shogi = ShogiInput.init(channel_id, [{
            "id": "user1",
            "name": "user1name",
        }, {
            "id": "user2",
            "name": "user2name",
        }])
        ShogiInput.move("76歩", channel_id, shogi.first_user.id)
        ShogiInput.move("34歩", channel_id, shogi.second_user.id)
        ShogiInput.move("22角", channel_id, shogi.first_user.id)
        ShogiInput.move("同銀", channel_id, shogi.second_user.id)
        ShogiInput.move("55角打", channel_id, shogi.first_user.id)
        ShogiInput.move("33角打", channel_id, shogi.second_user.id)
        ShogiInput.matta(channel_id, shogi.first_user.id)
        ShogiInput.matta(channel_id, shogi.second_user.id)
        ShogiInput.move("55角打", channel_id, shogi.first_user.id)
        ShogiInput.move("33角打", channel_id, shogi.second_user.id)

        self.assertEqual(shogi.board[4][4], Koma.kaku)
        self.assertEqual(shogi.board[2][6], Koma.opponent_kaku)