In [1]:
from isha.core.table import table
from isha.model.event import game_start

In [2]:
PATH = './package/card/'

n = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h']
t = table(PATH, n)
p = t.players()[len(n) - 1]

game_start(t)

In [3]:
print(t.show())


Rest cards: 21, Used cards: 0

Nick: d, HP: 5, Max HP: 5, ID: 主公, State: 正常, 4 Cards In Hand
Nick: h, HP: 4, Max HP: 4, ID: 未知, State: 正常, 4 Cards In Hand
Nick: f, HP: 4, Max HP: 4, ID: 未知, State: 正常, 4 Cards In Hand
Nick: e, HP: 4, Max HP: 4, ID: 未知, State: 正常, 4 Cards In Hand
Nick: c, HP: 4, Max HP: 4, ID: 未知, State: 正常, 4 Cards In Hand
Nick: a, HP: 4, Max HP: 4, ID: 未知, State: 正常, 4 Cards In Hand
Nick: b, HP: 4, Max HP: 4, ID: 未知, State: 正常, 4 Cards In Hand
Nick: g, HP: 4, Max HP: 4, ID: 未知, State: 正常, 4 Cards In Hand

In [4]:
print('Distance between a and b is: ' + str(t.distance('a', 'b')))


Distance between a and b is: 1

In [5]:
print('Last player has cards: ' + ', '.join(list(map(lambda card: card.suit() + card.point() + card.name(), p.card()))) + ' on his hand.')


Last player has cards: ♥10杀, ♥6桃, ♣5杀, ♣9杀 on his hand.

In [6]:
print(t.show_desktop())




In [7]:
# explain how to assign a card
from isha.core.card import explain_card_assign
print(explain_card_assign())


使用 <花色><点数><名字> 来选取你要出的牌,使用 S 来表示花色黑桃 ♠,使用 H 来表示花色红桃 ♥,使用 C 来表示花色梅花 ♣,使用 D 来表示花色方片 ♦,例如:DK杀、d6闪、S9杀、h10杀、dq桃

In [8]:
# last player use ♥10杀 to king player

from isha.core.card import assign_card
from isha.dict.event import EVENT

t.judge(EVENT['card_used'], p.choose_card(assign_card('h10杀', p.card())), p.nick(), t.king_player().nick())

In [9]:
print(t.show())


Rest cards: 21, Used cards: 0

Nick: d, HP: 5, Max HP: 5, ID: 主公, State: 被杀, 4 Cards In Hand
Nick: h, HP: 4, Max HP: 4, ID: 未知, State: 正常, 4 Cards In Hand
Nick: f, HP: 4, Max HP: 4, ID: 未知, State: 正常, 4 Cards In Hand
Nick: e, HP: 4, Max HP: 4, ID: 未知, State: 正常, 4 Cards In Hand
Nick: c, HP: 4, Max HP: 4, ID: 未知, State: 正常, 4 Cards In Hand
Nick: a, HP: 4, Max HP: 4, ID: 未知, State: 正常, 4 Cards In Hand
Nick: b, HP: 4, Max HP: 4, ID: 未知, State: 正常, 4 Cards In Hand
Nick: g, HP: 4, Max HP: 4, ID: 未知, State: 正常, 3 Cards In Hand

In [10]:
print(t.show_desktop())


♥10杀

In [ ]: