Esempio n. 1
0
    def read(self, pet):
        command = input()

        if command.lower() == "parameters":
            pet.print_parameters()
        elif command.lower() == "feed":
            pet.feed()
        elif command.lower() == "play":
            pet.play()
        elif command.lower() == "sleep":
            pet.sleep()
        elif command.lower() == "treatment":
            pet.treatment()
        elif command.lower() == "sport":
            pet.sport()
        elif command.lower() == "toilet":
            pet.go_toilet()
        elif command.lower() == "exit":
            return 'exit'
        elif command.lower() == "help":
            _print = Print.Print()
            _print.help()
        else:
            _print = Print.Print()
            _print.error()

        return 'ok'
Esempio n. 2
0
    def play(self):
        print_ = Print.Print()
        print_.choose_toy(self.name)

        command = Command.Command()
        ans = command.choose_toy()

        if ans == "ball":
            ball = Toy.Ball()
            self.__health += ball.healthy_change(self.__min_status, self.__max_status)
            self.change_toy(ball)
            print_.ball(self.name)

        elif ans == "computer":
            computer = Toy.ComputerGame()
            self.__health += computer.healthy_change(self.__min_status, self.__max_status)
            self.change_toy(computer)
            print_.computer(self.name)

        elif ans == "puzzle":
            puzzle = Toy.Puzzle()
            self.change_toy(puzzle)
            print_.puzzle(self.name)

        self.__happiness = self.__check_status__(self.__happiness)
        self.__force = self.__check_status__(self.__force)
        self.__satiety = self.__check_status__(self.__satiety)
        self.__health = self.__check_status__(self.__health)
        self.__sleep = self.__check_status__(self.__sleep)
Esempio n. 3
0
    def check_status(self):
        if self.__health == self.__min_status or self.__satiety == self.__min_status or \
                (self.__happiness == self.__min_status and self.__force == self.__min_status and
                 self.__sleep == self.__min_status):
            return "died"
        else:
            print_ = Print.Print()

            if self.__health < 3 * self.__max_status // 10:
                print_.sick(self.name)

            if self.__need_toilet > 8 * self.__max_status // 10:
                print_.need_toilet(self.name)

            if self.__happiness < 4 * self.__max_status // 10:
                print_.boring(self.name)

            if self.__satiety < 2 * self.__max_status // 10:
                print_.hungry(self.name)

            if self.__sleep < 3 * self.__max_status // 10:
                print_.sleep(self.name)

            if self.__force < 2 * self.__max_status // 10:
                print_.tired(self.name)

        return "ok"
Esempio n. 4
0
    def sleep(self):
        self.__force += 5 * self.__max_status // 10
        self.__force = self.__check_status__(self.__force)

        self.__sleep = self.__max_status
        print_ = Print.Print()
        print_.go_sleep(self.name)
Esempio n. 5
0
    def print_parameters(self):
        print_ = Print.Print()

        print_.print_force(self.__force, self.__max_status)
        print_.print_happiness(self.__happiness, self.__max_status)
        print_.print_satiety(self.__satiety, self.__max_status)
        print_.print_health(self.__health, self.__max_status)
        print_.print_sleep(self.__sleep, self.__max_status)
        print_.print_need_toilet(self.__need_toilet, self.__max_status)
Esempio n. 6
0
    def treatment(self):
        print_ = Print.Print()

        if self.__sleep > 3 * self.__max_status // 10 and self.__force > 2 * self.__max_status // 10:
            self.__health = self.__max_status
            print_.treatment(self.name)
        else:
            if self.__sleep <= 3 * self.__max_status // 10:
                print_.sleep_to_treatment(self.name)

            if self.__force <= 3 * self.__max_status // 10:
                print_.force_to_treatment(self.name)
Esempio n. 7
0
    def sport(self):
        print_ = Print.Print()
        if self.__force > 4 * self.__max_status // 10:
            self.__force += -4 * self.__max_status // 10
            self.__health += 4 * self.__max_status // 10
            self.__sleep += -3 * self.__max_status // 10
            self.__satiety += -3 * self.__max_status // 10

            self.__check_status__(self.__force)
            self.__check_status__(self.__satiety)
            self.__check_status__(self.__health)
            self.__check_status__(self.__sleep)

            print_.sport(self.name)
        else:
            print_.force_to_sport(self.name)
Esempio n. 8
0
    def feed(self):
        print_ = Print.Print()

        print_.choose_food(self.name)

        command = Command.Command()
        ans = command.choose_food()
        if ans == "apple":
            apple = Food.Apple()
            self.change_food(apple)
            print_.apple(self.name)

        elif ans == "pancake":
            pancake = Food.Pancake()
            self.change_food(pancake)
            print_.pancake(self.name)

        elif ans == "hamburger":
            hamburger = Food.Hamburger()
            self.change_food(hamburger)
            print_.hamburger(self.name)

        elif ans == "chips":
            chips = Food.Chips()
            self.change_food(chips)
            print_.chips(self.name)

        elif ans == "poke":
            poke = Food.Poke()
            self.change_food(poke)
            print_.poke(self.name)

        elif ans == "salad":
            salad = Food.Salad()
            self.change_food(salad)
            print_.salad(self.name)

        else:
            print_.error()

        self.__happiness = self.__check_status__(self.__happiness)
        self.__force = self.__check_status__(self.__force)
        self.__satiety = self.__check_status__(self.__satiety)
        self.__health = self.__check_status__(self.__health)
        self.__need_toilet = self.__check_status__(self.__need_toilet)
Esempio n. 9
0
from tamagotchi import MyPet
from tamagotchi import Print
from tamagotchi import Command
import time

print_ = Print.Print()
print_.hello()

pet = MyPet.MyPet()
command = Command.Command()

pet.name = command.read_name()
print_.start(pet.name)

pet.status = 'ok'
read = 'ok'

timing = time.time()

while read != 'exit' and pet.status != 'died':
    read = command.read(pet)
    pet.status = pet.check_status()

    if time.time() - timing > 15:
        interval = (time.time() - timing) // 15
        pet.check_alive(interval)
        timing = time.time()

if pet.status == 'died':
    print_.died(pet.name)
Esempio n. 10
0
    def go_toilet(self):
        self.__need_toilet = self.__min_status

        print_ = Print.Print()
        print_.toilet(self.name)