Пример #1
0
 def see_assigned(self):
     """Print names of inhabitants assigned to Room."""
     if self.assigned:
         for person_name in self.assigned:
             print_line("        " + person_name)
     else:
         print_line("        None")
Пример #2
0
 def see_assigned(self):
     """Print names of inhabitants assigned to Room."""
     count = 0
     for x in str(self.assigned):
         if x == '1':
             person = people[count]
             print_line("      ", person.name, person.surname)
         count += 1
Пример #3
0
 def see_assigned(self):
     """Print names of inhabitants assigned to Room."""
     count = 0
     for x in str(self.assigned):
         if x == '1':
             person = people[count]
             print_line("      ", person.name, person.surname)
         count += 1
Пример #4
0
    def mature(self, person):
        """Increment Human's age.

        Arguments:
        person -- Human who's aging
        """
        person.age += 1
        print_line("{} has matured and is now {} years old!" \
        .format(self, self.age))
Пример #5
0
 def rebirth(self):
     """Don't know if I'll ever use this."""
     self.age = 0
     if self.gender == "m":
         print_line(self.name +
                    " has been reborn and his stats have been reset")
     else:
         print_line(self.name +
                    " has been reborn and her stats have been reset")
     self.stats["strength"] = self.perception = self.endurance = 1
     self.stats["charisma"] = self.luck = self.intelligence = 1
Пример #6
0
 def level_up(self):
     super().level_up()
     for stat in choice_dict.keys():
         print_line(" {}".format(stat), end=" ")
     choice = input("Please choose an attribute to level up: ")
     choice.lower()
     if choice in choice_dict:
         choice_dict[choice] += 1
     else:
         print_line("\nInvalid choice.\n")
         self.level -= 1
         self.level_up()
Пример #7
0
 def print_(self):
     """Print room name and its attributes.
     
     Arguments:
     game -- Main game object. 
     """
     print_line(self)
     if self.power_available:
         power_availablility = "Working"
     else:
         power_availablility = "No power available"
     if self.broken:
         status = "Broken"
         status = "Functional"
     else:
         status = "Functional"
     print_line("    Risk: {}%".format(self.risk),
                "    Level: {}".format(self.level),
                "    Attribute: {}".format(self.attribute.title()),
                "    Power: {}".format(power_availablility),
                "    Status: {}".format(status))
     if self.can_produce:
         print_line("    Production: {}".format(self.production))
     if self.can_produce or self.name == "trader":
         print_line("    Assigned: ")
         self.see_assigned()
     print()
Пример #8
0
 def die(self):
     """Kill NPC."""
     global people
     global rooms
     print_line(self.name, " has died")
     if self.assigned_room != "":
         for x in range(people):  # Fetches the index of the person.
             if people[x].name == self.name:
                 index = x
                 break
         for r in rooms:
             # Removes person from the rooms' assigned records.
             del r.assigned[index]
     people.remove(self)
Пример #9
0
 def die(self, game, cause):
     """Kill self, and unassign from a assigned room.
         #Should make this a method of the main game.
     Arguments:
     game -- main game object
     cause -- cause of death
     """
     print_line("{} has died of {}!".format(self, cause))
     if self.assigned_room:
         game.rooms[self.assigned_room].remove(str(self))
     if not isinstance(self, Player):
         pass
     else:
         self.alive = False
Пример #10
0
    def update_production(self, player):
        """Calculate production value of Room.

        Arguments:
        player -- player object
        """
        if self.broken:
            production = 0
            print_line(self.name, "is broken and needs to be fixed.")
        else:
            production = 0
            if self.name == "generator":
                for person_index in str(self.assigned):
                    if person_index == '1':
                        production += people[int(person_index)].strength * 10
                if player.electrician > 0:
                    production = production * (1 + (player.electrician * 0.05))
            elif self.name == "kitchen":
                for person_index in str(self.assigned):
                    if person_index == '1':
                        production += people[int(person_index)].intelligence \
                            * 10
                if player.cooking > 0:
                    production = production * \
                        (1 + (player.cooking * 0.05))

            elif self.name == "water works":
                for person_index in str(self.assigned):
                    if person_index == '1':
                        production += people[int(person_index)].perception * 10
                if player.cooking > 0:
                    production = production * \
                        (1 + (player.cooking * 0.05))
            elif self.name == "radio":
                for person_index in str(self.assigned):
                    if person_index == '1':
                        production += people[int(person_index)].charisma * 10
                if player.inspiration > 0:
                    production = production * \
                        (1 + (player.inspiration * 0.05))
            else:
                print_line(
                    "Bug with room production update system.",
                    "Please contact dev.")
            if player.inspiration > 0:
                production = production * \
                    (1 + (player.inspiration * 0.03))
            if self.can_rush and self.rushed:
                production = production * 2
            return production
Пример #11
0
 def level_up(self):
     """Level up Human and ask player for input on what stat to level up."""
     print_line(
         "{} has gained enough experience to level up!!!".format(self))
     self.see_stats()
     self.level += 1
     choice_dict = {
         'strength': self.stats["strength"],
         'perception': self.stats["perception"],
         'endurance': self.stats["endurance"],
         'charisma': self.stats["charisma"],
         'intelligence': self.stats["intelligence"],
         'luck': self.stats["luck"]
     }
Пример #12
0
 def level_up(self):
     super().level_up()
     print_line("\n")
     print_line("You can level up any of these attributes: ")
     for stat in choice_dict.keys():
         print_line(" {}".format(stat), end=" ")
     choice = input("Please choose an attribute to level up: ")
     choice.lower()
     perks = [
         "medic", "crafting", "tactitian", "cooking", "inspiration",
         "scrapper", "barter", "electrician"
     ]
     #Perks specific to the player are added to the dictionary of
     #available choices
     for perk in perks:
         choice_dict[perk] = self.stats[perk]
     """ #Old choice_dict dictionary
     choice_dict = {
     'strength':self.stats["strength"], 'perception':self.stats["perception"],
     'endurance':self.stats["endurance"], 'charisma':self.stats["charisma"],
     'intelligence':self.stats["intelligence"], 'luck':self.stats["luck"],
     'medic':self.stats["medic"], 'crafting':self.stats["crafting"],
     'tactician':self.stats["tactician"], 'cooking':self.stats["cooking"],
     'inspiration':self.stats["inspiration"], 'scrapper':self.stats["scrapper"],
     'barter':self.stats["barter"], 'electrician':self.stats["electician"]
     }
     """
     if choice in choice_dict.keys():
         choice_dict[choice] += 1
     else:
         print_line("Invalid choice")
         self.level -= 1
         self.level_up()
Пример #13
0
    def print_(self, count):
        """Print item name and attributes.

        Arguments:
        count -- amount of item held
        """
        att = " | {}: {}"
        print_line("{} * {}".format(self.name, count),
                   att.format("Weight", self.weight),
                   att.format("Value", self.value),
                   att.format("Rarity", self.rarity),
                   att.format("Components", self.components),
                   end="",
                   speed=FAST)
        print()
Пример #14
0
 def rebirth(self):
     """Don't know if I'll ever use this."""
     self.age = 0
     if self.gender == "f":
         print_line(
             self.name +
             " has been reborn and his stats have been reset")
     else:
         print_line(
             self.name +
             " has been reborn and her stats have been reset")
     self.strength = 1
     self.perception = 1
     self.endurance = 1
     self.charisma = 1
     self.intelligence = 1
     self.luck = 1
Пример #15
0
    def assign_to_room(self, chosen_room):
        """Assign Human to room.

        Arguments:
        chosen_room -- room to assign to
        """
        global rooms
        global people
        person_index = self.get_index()
        # print_line("Index of ",self.name,"is",person_index)
        room_index = get_room_index(chosen_room)
        # print_line("Index of ",chosen_room," is ",room_index)
        room = rooms[room_index]  # Refers to the actual room
        # print_line("Chosen room is",room.name)
        if people[person_index].assigned_room != '':
            for room in rooms:
                string = str(room.assigned)
                lst = []
                for digit in string:
                    lst.append(digit)
                lst[person_index] = '0'
                string = ''
                for digit in lst:
                    string = string + digit
                room.assigned = string
        string = str(room.assigned)
        # print_line("Assigned log",string)
        lst = []
        for digit in string:
            lst.append(digit)
        # print_line("Assigned log",lst)
        lst[person_index] = '1'
        string = ''
        for digit in lst:
            string = string + digit
        room.assigned = string
        # print_line("Updated assigned log",room.assigned)
        # Let's  character know where they've been assigned.
        people[person_index].assigned_room = str(chosen_room)
        # print_line("Room",self.name,"has been assigned to is",
        #     people[person_index].assigned_room)
        print_line(
            self.name + " " + self.surname +
            "has been assigned to " + chosen_room)
Пример #16
0
 def print_(self):
     """Print name and attributes."""
     print_line("\n")
     print_line(self,
                "\n  Age:  {}".format(self.age) +
                "  Gender: {}".format(self.gender) +
                "  Hunger: {}".format(self.hunger) +
                "  Thirst: {}".format(self.thirst) +
                "  Room:   {}".format(self.assigned_room),
                speed=FAST)
     for stat in self.stats.keys():
         print_line("   " + stat + " : " + str(self.stats[stat]))
     print_line("\n")
Пример #17
0
    def __init__(self, name):
        """Item constructor.

        Arguments:
        name -- name of item
        """
        # Just needs to get the name, all other attributes are automatically
        # assigned by the following lines.
        self.name = name
        with open('items.json') as f:
            parsed = json.loads(f.read())
            try:
                item = parsed[self.name]
                self.value = item['value']
                self.weight = item['weight']
                self.components = item['components']
                self.rarity = item['rarity']
            except KeyError:
                print_line(
                    "Unknown item. This is a bug. Please contact the dev.")
        # Keeps track of whether item has been scrapped by player.
        self.scrapped = False
Пример #18
0
    def scrap(self):
        """Destroy Item and add its components to inventory."""
        print_line(self.name, " has been scrapped and these")
        for item in self.components:
            inventory[item] += 1
            print_line(item)
        print_line("have been added to your inventory")

        chance = randint(0, 101)
        if (player.scrapper) * 3 > chance:
            print_line(
                "Your scrapper skill has allowed you to gain more components!")
            # Randomly adds extra component of the scrapped item the inventory.
            inventory[self.components[randint(len(self.components))]] += 1
        self.destroy("player")
Пример #19
0
 def level_up(self):
     """Level up Human and ask player for input on what stat to level up."""
     see_stats(self.name, self.surname)
     self.level += 1
     if self.name == people[0].name:  # If player has leveled up
         print_line("\n")
         choice = input("Please choose an attribute to level up: ")
         choice.lower()
         if choice == "strength":
             self.strength += 1
         elif choice == "perception":
             self.perception += 1
         elif choice == "endurance":
             self.endurance += 1
         elif choice == "charisma":
             self.charisma += 1
         elif choice == "intelligence":
             self.intelligence += 1
         elif choice == "luck":
             self.luck += 1
         elif choice == "medic":
             self.medic += 1
         elif choice == "crafting":
             self.crafting += 1
         elif choice == "tactitian":
             self.tactitian += 1
         elif choice == "cooking":
             self.cooking += 1
         elif choice == "inspiration":
             self.inspiration += 1
         elif choice == "scrapper":
             self.scrapper += 1
         elif choice == "barter":
             self.barter += 1
         elif choice == "electrician":
             self.electrician += 1
         else:
             print_line("Invalid choice")
             self.level -= 1
             self.level_up()
     else:  # If NPC has levelled up
         if choice == "strength":
             self.strength += 1
         elif choice == "perception":
             self.perception += 1
         elif choice == "endurance":
             self.endurance += 1
         elif choice == "charisma":
             self.charisma += 1
         elif choice == "intelligence":
             self.intelligence += 1
         elif choice == "luck":
             self.luck += 1
         else:
             print_line("\nInvalid choice.\n")
             self.level -= 1
             self.level_up()
Пример #20
0
    def scrap(self):
        """Destroy Item and add its components to inventory."""
        global inventory
        print_line(self.name, " has been scrapped and these")
        for item in self.components:
            inventory.append(item)
            print_line(item)
        print_line("have been added to your inventory")

        chance = randint(0, 101)
        if (people[0].scrapper) * 3 > chance:
            print_line(
                "Your scrapper skill has allowed you to gain more components!")
            for item in self.components:
                inventory.append(item)
        self.scrapped = True  # whether item is scrapped or just destroyed
        self.destroy("player")
Пример #21
0
 def rush(self):
     """Rush building of Room."""
     global rooms
     self.rushed = 1  # Lets game know this room has been rushed.
     self.risk += 5
     print_line(self.name, " has been rushed!")
Пример #22
0
    def __init__(self, name, player):
        """Room class constructor.

        Arguments:
        name -- name of room
        player -- ???
        """
        self.name = name
        self.assigned = ''  # should be a list

        # Determines the production level, max assigned limit etc.
        self.level = 1
        self.risk = False  # Risk of breaking down, when rushed.
        self.broken = False
        # 'On' if there is enough power for the room, 'Off' otherwise.
        self.power_available = "On"
        # Living rooms have no "assigned". Number of living rooms just limits
        # the total population of the shelter.
        if self.name == "living":
            # Stores whether or not room actually produces anything.
            # self.components=["wood",] #Need to add components.
            self.can_produce = False
            self.assigned_limit = 0
            self.components = ["wood", "wood", "wood", "wood"]
            self.power_usage = 5
        elif self.name == "generator":
            self.risk = 2
            self.can_produce = True
            self.components = ["steel", "steel", "steel", "steel"]
            # Max number of workers that can work in the room at one time.
            self.assigned_limit = 3
            self.power_usage = 0
        elif self.name == "storage":
            self.can_produce = False
            self.assigned_limit = 0
            self.components = ["steel", "steel"]
            self.power_usage = 1
        elif self.name == "kitchen":
            self.risk = 1
            self.can_produce = True
            self.assigned_limit = 3
            self.components = ["wood", "wood", "wood"]
            self.power_usage = 10
        elif self.name == "trader":
            self.can_produce = False
            self.assigned_limit = 1
            self.components = ["wood", "wood", "steel", "steel", "wood"]
            self.power_usage = 2
        elif self.name == "water works":
            self.risk = 2
            self.can_produce = True
            self.assigned_limit = 3
            self.components = ["wood", "wood", "steel"]
            self.power_usage = 10
        elif self.name == "radio":
            self.can_produce = False
            self.assigned_limit = 2
            self.components = ["wood", "wood", "steel", "steel", "wood"]
            self.power_usage = 15
        # Need to add more names.
        else:
            print_line("Bug with room creation system.",
                       "Please contact dev. Class specific bug.")
        if self.can_produce:
            self.production = 0
            self.can_rush = True
            self.rushed = False
        else:
            self.can_rush = False
Пример #23
0
 def rush(self):
     """Rush building of Room."""
     self.rushed = True  # Lets game know this room has been rushed.
     self.risk += 20
     print_line("{} room has been rushed!".format(self.name))
Пример #24
0
 def see_stats(self):
     """Check stats of inhabitant."""
     for stat in self.stats:
         print_line("{}: {}".format(stat, self.stats[stat]))
Пример #25
0
 def rush(self):
     """Rush building of Room."""
     global rooms
     self.rushed = 1  # Lets game know this room has been rushed.
     self.risk += 5
     print_line(self.name, " has been rushed!")
Пример #26
0
    def __init__(self, name, player):
        """Room class constructor.

        Arguments:
        name -- name of room
        player -- ???
        """
        self.name = name
        self.assigned = ''  # should be a list

        # Determines the production level, max assigned limit etc.
        self.level = 1
        self.risk = False  # Risk of breaking down, when rushed.
        self.broken = False
        # 'On' if there is enough power for the room, 'Off' otherwise.
        self.power_available = "On"
        # Living rooms have no "assigned". Number of living rooms just limits
        # the total population of the shelter.
        if self.name == "living":
            # Stores whether or not room actually produces anything.
            # self.components=["wood",] #Need to add components.
            self.can_produce = False
            self.assigned_limit = 0
            self.components = ["wood", "wood", "wood", "wood"]
            self.power_usage = 5
        elif self.name == "generator":
            self.risk = 2
            self.can_produce = True
            self.components = ["steel", "steel", "steel", "steel"]
            # Max number of workers that can work in the room at one time.
            self.assigned_limit = 3
            self.power_usage = 0
        elif self.name == "storage":
            self.can_produce = False
            self.assigned_limit = 0
            self.components = ["steel", "steel"]
            self.power_usage = 1
        elif self.name == "kitchen":
            self.risk = 1
            self.can_produce = True
            self.assigned_limit = 3
            self.components = ["wood", "wood", "wood"]
            self.power_usage = 10
        elif self.name == "trader":
            self.can_produce = False
            self.assigned_limit = 1
            self.components = ["wood", "wood", "steel", "steel", "wood"]
            self.power_usage = 2
        elif self.name == "water works":
            self.risk = 2
            self.can_produce = True
            self.assigned_limit = 3
            self.components = ["wood", "wood", "steel"]
            self.power_usage = 10
        elif self.name == "radio":
            self.can_produce = False
            self.assigned_limit = 2
            self.components = ["wood", "wood", "steel", "steel", "wood"]
            self.power_usage = 15
        # Need to add more names.
        else:
            print_line(
                "Bug with room creation system.",
                "Please contact dev. Class specific bug.")
        if self.can_produce:
            self.production = 0
            self.can_rush = True
            self.rushed = False
        else:
            self.can_rush = False