选择某些按钮后如何在变量中添加点

时间:2019-06-25 20:17:33

标签: swift if-statement uibutton label

我有一组带有配料的按钮,另一组带有配料但可以使用的工具,并且我想在选择正确的工具和与其对应的配料时给出要点。

gameViewController:

func givePoints () {
        let toolSelected = MainInfoManager.shared.getToolWith(name: ToolName(rawValue: toolSelectedId)!)
        let ingredientSelected = MainInfoManager.shared.getIngredientWith(name: IngredientName(rawValue: ingredientSelectedId)!)
        if let currentBowl = bowl, seconds > 0 {
            print("funciono")
            for ingredient in currentBowl.ingredients {
                print ("este tambien")
                if ingredient.id == ingredientSelected.id && toolSelected.ingredients.contains(where: { $0.id == ingredientSelected.id }) {
                    print("y este tambien")
                    pointsForChoices += 10
                }
            } 
        }
    }

请帮助我 谢谢

0 个答案:

没有答案