本文整理汇总了Python中card.Card.suitComp方法的典型用法代码示例。如果您正苦于以下问题:Python Card.suitComp方法的具体用法?Python Card.suitComp怎么用?Python Card.suitComp使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类card.Card
的用法示例。
在下文中一共展示了Card.suitComp方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: remap
# 需要导入模块: from card import Card [as 别名]
# 或者: from card.Card import suitComp [as 别名]
def remap(self, hand, trumpsuit):
# set the trump and complementary suit
compsuit = Card.suitName(Card.suitComp(trumpsuit))
trumpsuit = Card.suitName(trumpsuit)
# set the asuit and bsuit arbitrarily: we'll be sorting them later
if trumpsuit == "c":
asuit = "d"
bsuit = "h"
csuit = "s"
if trumpsuit == "d":
asuit = "c"
bsuit = "h"
csuit = "s"
if trumpsuit == "h":
asuit = "c"
bsuit = "d"
csuit = "s"
if trumpsuit == "s":
asuit = "c"
bsuit = "d"
csuit = "h"
# set up our cardsets
trump = list([])
a = list([])
b = list([])
c = list([])
# go through each card, add it to the respective sets
for card in hand:
v = Card.valueName(card.value)
s = Card.suitName(card.suit)
# if it's the trump suit, add it to the trump set
if s == trumpsuit:
# if it's the J, relabel it as R
if v == "J": v = "R"
trump.append(v)
continue
# if it's the comp suit and it's the left, add it to the trump set
if s == compsuit and v == "J":
trump.append("L")
continue
# we've already arbitrarily set the asuit and bsuit values, so
# now we add cards to them: we'll make decisions about the final
# order in a moment
if s == asuit:
a.append(v)
if s == bsuit:
b.append(v)
if s == csuit:
c.append(v)
# now we compose the remapped hand string; first add the trump set
remap = ""
if len(trump) > 0:
remap = "".join(sorted(trump))
#print("trump: %s remap: %s" % (trump,remap))
remap += "t"
# we compose sorted strings for the a, b, and c sets, and then sort and
# add them to the remap string
abc = list([])
abc.append("".join(sorted(a)))
abc.append("".join(sorted(b)))
abc.append("".join(sorted(c)))
suitchars = ["a","b","c"]
i = 0
for s in sorted(abc):
remap += s
remap += suitchars[i]
i += 1
return remap