Exemple #1
0
def test_nonplant():
    print(style(HEADER, "---Start: Non_Plant Class checking---"))
    erron = 0
    o = Non_Plant()
    o2 = Non_Plant()
    if (hasattr(o, "dmg") & hasattr(o, "hp")) == 0:
        print(
            style(
                WARNING,
                "Your Non_Plant class doesn't inherit the properties of the Organism"
            ))
        return
    if hasattr(o, "worth") == 0:
        print(
            style(
                WARNING, "You didn't create a " + style(UNDERLINE, "cost") +
                end_style() +
                style(WARNING, " class variable for your function")))
        return
    if o.hp != 80:
        erron += 1
        print(
            style(FAIL, "You didn't initialize"
                  " the nonlplant's ") + style(UNDERLINE, "hp") + end_style() +
            style(FAIL, " to ") + style(BOLD, "80") + end_style())
    if o.dmg != 5:
        erron += 1
        print(
            style(FAIL, "You didn't initialize"
                  " the nonplant's ") + style(UNDERLINE, "dmg") + end_style() +
            style(FAIL, " to ") + style(BOLD, "5") + end_style())
    prev_hp = o2.hp
    if hasattr(o, "attack") == 1:
        o.attack(o2)
        if (prev_hp - o2.hp) != (o.dmg):
            erron += 1
            print(
                style(FAIL, "The ") + style(UNDERLINE, "attack") +
                end_style() +
                style(FAIL, " method, doesn't reduce the plant's hp enough"))
    else:
        erron += 1
        print(
            style(FAIL, "No ") + style(UNDERLINE, "attack") + end_style() +
            style(FAIL, " method in class"))

    if erron == 0:
        print(style(OKGREEN, "Non_Plant Class, perfect."))
def test_game(file=None):
    print(style(HEADER, "---Start: Game Class checking---"))
    if file == None:
        print(
            style(
                WARNING,
                "You need to pass in a valid example file to check the Game Class"
            ))
        return
    erron = 0
    o = Game(file)
    for r in range(o.height):
        for c in range(o.width):
            if (type(o.board[r][c].peek()).__name__ != "Queue"):
                print(
                    style(
                        FAIL, "Your Board is not initialized properly" +
                        str(o.board[r][c].peek())))
                return
    o.board[0][0].enqueue(Non_Plant())
    if erron == 0:
        print(style(OKGREEN, "Game Class, perfect."))
Exemple #3
0
 def place_nonplant(self, row):
     self.board[row][-1].enqueue(Non_Plant())
     self.nonplants += 1
Exemple #4
0
def test_game(file=None):
    print(style(HEADER, "---Start: Game Class checking---"))
    if file == None:
        print(
            style(
                WARNING,
                "You need to pass in a valid example file to check the Game Class"
            ))
        return
    erron = 0
    o = Game(file)
    w = Wave(0, 0, 0)
    for r in range(o.height):
        for c in range(o.width):
            if (type(o.board[r][c]).__name__ != "Queue"):
                print(style(FAIL, "Your Board is not initialized properly"))
                return
    o.board[0][0].enqueue(Non_Plant())
    if (hasattr(o, "is_nonplant")) == 1:
        UT_game.is_nonplant(o)
    else:
        print(style(WARNING, "No is_nonplant method in class"))
        erron += 1
    o.board[1][1].enqueue(Plant())

    if (hasattr(o, "is_plant")) == 1:
        erron += UT_game.is_plant(o)
    else:
        print(style(WARNING, "No is_plant method in class"))
        erron += 1
    old_cash = o.cash

    if (hasattr(o, "is_nonplant") & hasattr(o, "remove")) == 1:
        o.remove(0, 0)
        UT_game.remove(o, old_cash)
    else:
        print(style(WARNING, "No remove method in class"))
        erron += 1

    if (hasattr(o, "place_plant") & hasattr(o, "is_plant")) == 1:
        UT_game.place_plant(o)
    else:
        erron += 1
        print(style(WARNING, "No place_plant method in class"))

    if (hasattr(o, "place_nonplant")) == 1:
        o.place_nonplant(0)
        UT_game.place_nonplant(o, 0)
    else:
        erron += 1
        print(style(WARNING, "No place_nonplant method in class"))

    if (hasattr(o, "place_wave")) == 1:
        UT_game.place_wave()
    else:
        erron += 1
        print(style(WARNING, "No place_wave method in class"))

    if (hasattr(o, "plant_turn")) == 1:
        UT_game.plant_turn()
    else:
        erron += 1
        print(style(WARNING, "No plant_turn method in class"))

    if (hasattr(o, "nonplant_turn")) == 1:
        UT_game.nonplant_turn()
    else:
        erron += 1
        print(style(WARNING, "No nonplant_turn method in class"))

    if (hasattr(o, "run_turn")) == 1:
        UT_game.run_turn()
    else:
        erron += 1
        print(style(WARNING, "No run_turn method in class"))

    if (hasattr(o, "draw_card")) == 1:
        UT_game.draw_card(o)
    else:
        erron += 1
        print(style(WARNING, "No draw_card method in class"))

    if erron == 0:
        print(
            style(
                OKGREEN,
                "Game Class, within tests perfect! Otherwise...good luck with the last 4 functions!!"
            ))
    else:
        print(style(OKBLUE,
                    "\n--------(:P for the lack of error details ^_^)"))
        print(
            style(
                WARNING,
                "--------∆ IF YOU GET ALOT OF UNEXPECTED ERRORS, MAKE SURE YOU PROPERLY COPIED AND PASTED THE CODE GIVEN TO YOU #_#"
            ) + end_style())
Exemple #5
0
 def place_nonplant(self, row):
     self.board[row][self.width-1].enqueue(Non_Plant())
Exemple #6
0
 def place_nonplant(self, row):  #### FIX ME!!!
     new_nonplant = Non_Plant()
     dict1 = self.board[0]
     dict1[(row, )]
Exemple #7
0
 def place_nonplant(self, row):
     nplant = Non_Plant()
     self.board[row][self.width - 1].enqueue(nplant)
     self.non_plants += 1