Yahtzee,需要两个参数if,remove方法

时间:2016-08-28 15:12:28

标签: python-3.x

所以我试图制作yahtzee-board,但是我遇到了一个不应该难以解决的障碍,但我无法解决它。这就是我的删除功能当前的样子:

class Player:
    def __init__(self,name):
        self.name=name
        self.lista={"aces":0,"twos":0,"threes":0,"fours":0,"fives":0,"sixs":0,"upperscore":0,"bonus":0,"pair":0,"twopair":0,"3ofakind":0,"4ofakind":0,"smallstraight":0,"largestraight":0,"fullhouse":0,"chance":0,"yahtzee":0,"lowerscore":0,"totalscore":0}
        self.upperbracket={"aces":0,"twos":0,"threes":0,"fours":0,"fives":0,"sixs":0}
        self.lowerbracket={"pair":0,"twopair":0,"3ofakind":0,"4ofakind":0,"smallstraight":0,"largestraight":0,"fullhouse":0,"chance":0,"yahtzee":0}

    def remove(self,i):
        b=input("Do you want to remove a moment?:")
        if b=="yes":
            c=input("Which moment do you want to remove?")
            spelarlista[i].lista[c]=str("&")
            self.printtable()
            return True
        if b=="no":
            return False

    def add(self):
        rundor=0
        while rundor!=15:
            for i in range(len(spelarlista)):
                count=0
                print("Rolling dice for: ", str(spelarlista[i]))
                self.rolldice()
                if self.remove(i)==True:
                    i=i+1
                    count+=1
                while count<=0:
                    moment=input("Where do you want to put your points,"+" "+ str(spelarlista[i])+"?:""\n" )
                    while moment not in self.lista:
                        print("oops! Try again!")
                    if spelarlista[i].lista[moment]!=0 or spelarlista[i].lista[moment]==str("&"):
                        print("Moment has either been removed or you already got points there")
                    else:
                        points=input("How many points did you get?: ")

我想要做的是,如果我决定删除已经删除的“时刻”它应该打印“不能做”或类似的东西,同样的事情就是如果已经存在点。

目前代码行看起来像这样:

if spelarlista[i].lista[moment]!=0 or spelarlista[i].lista[moment]==str("&"):

请注意,如果我已经添加了积分,这条线路正常工作,但是如果我尝试删除已经删除的“时刻”它不能按预期工作,我根本无法看到一切都出错了...... < / p>

提前致谢

0 个答案:

没有答案