def __init__(self, name, room): self.action_index = ACTION_INDEX self.base_defense = 10 self.attack = 0.01 self.xp = 0 self.level = 1 self.xp_to_level = self.set_xp_to_level() self.constitution = 10 self.dexterity = 10 self.intelligence = 10 self.strength = 10 self.find_traps = 50 self.turn_counter = 1 self.max_hp = self.set_max_hp() # TODO: Figure out how to calculate Stamina and Mana; # TODO: Implement stamina and mana drain from certain abilities. # TODO: Implement stamina and mana regen during advance_turn(). self.stamina = 0 self.mana = 0 self.inventory = Inventory() self.journal = Journal() self.explored_rooms = dict() self.cooldowns = dict() self.messages = None super().__init__(name, room, max_hp=self.max_hp) self.assign_room(room)
def __init__(self, x, y): self.width = x self.length = y emptyTile = Tile() self.map = [[emptyTile] for i in range(x)] for i in range(x): for j in range(1, y): self.map[i].append(emptyTile) self.inventory = Inventory()
def __init__(self): self.name = 'Empty' self.location = [0, 0] self.description = '' self.inventory = Inventory() self.north = False self.east = False self.south = False self.west = False
def __init__(self, scene, spriteset): Sprite.__init__(self, spriteset) self.scene = scene self.stats = ActorStats(self) self.name = "Chryso" self.job = None self.level = 1 self.experience = 0 self.maxHp = 10 self.hp = 10 self.maxAp = 5 self.ap = 5 self.money = 500 self.inventory = Inventory(self) self.dialogId = "default" self.state = {}
class Room: def __init__(self, x, y): self.width = x self.length = y emptyTile = Tile() self.map = [[emptyTile] for i in range(x)] for i in range(x): for j in range(1, y): self.map[i].append(emptyTile) self.inventory = Inventory() def addTile(self, tile, x, y): tile.setLocation([x, y]) self.map[x][y] = tile def getTile(self, x, y): return self.map[x][y] def nameTile(self, name, x, y): self.map[x][y].setName(name) def getMap(self): return self.map def printMap(self): y = self.length - 1 x = self.width - 1 for i in range(self.width): for j in range(self.length): print(x, y, " : ", self.map[x][y].getName()) y -= 1 print("\n") y = self.length - 1 x -= 1 def putItem(self, item): self.inventory.addItem(item) def takeItem(self, item_name): return self.inventory.removeItem(item_name)
def __init__(self, name, health=30, offense=10, defense=10, inventory=None, # Inventory accepts only weapon, armor and items in constructor effects=None): super(Warrior, self).__init__() self.name = name self.health = health self.offense = offense self.defense = defense if inventory is None: self.inventory = Inventory() else: self.inventory = inventory if effects is None: self.effects = [] else: self.effects = effects
class Character(Mob): # Stand-in numbers. LEVEL_CHART = { 1: 20, 2: 50, 3: 100, 4: 175, 5: 300, 6: 600, } def __init__(self, name, room): self.action_index = ACTION_INDEX self.base_defense = 10 self.attack = 0.01 self.xp = 0 self.level = 1 self.xp_to_level = self.set_xp_to_level() self.constitution = 10 self.dexterity = 10 self.intelligence = 10 self.strength = 10 self.find_traps = 50 self.turn_counter = 1 self.max_hp = self.set_max_hp() # TODO: Figure out how to calculate Stamina and Mana; # TODO: Implement stamina and mana drain from certain abilities. # TODO: Implement stamina and mana regen during advance_turn(). self.stamina = 0 self.mana = 0 self.inventory = Inventory() self.journal = Journal() self.explored_rooms = dict() self.cooldowns = dict() self.messages = None super().__init__(name, room, max_hp=self.max_hp) self.assign_room(room) def ability_mod(self, abil): ability = getattr(self, abil) return int((ability / 2) - 5) def add_messages(self, message): if self.messages is None: self.messages = [] self.messages.append(message) def advance_turn(self, mob=None): if mob is not None: if mob.current_hp >= 1: mob.attack_player(self) for corpse in Corpse._all: corpse.decay() for monster in Monster._all: monster.reduce_stun() self.check_level_up() self.reduce_cooldowns() self.turn_counter += 1 def assign_room(self, room): self.room = room if room.zone in self.explored_rooms: if room not in self.explored_rooms[room.zone]: self.explored_rooms[room.zone].append(room) else: self.explored_rooms[room.zone] = [room] def attack_target_mob(self, text_input, dam_mod=None, success_verb=None, fail_verb=None, outcome=f""): """ Check a player's attack on a mob and modify the journal appropriately. :param text_input: A string representing the intended target. :param dam_mod: A modifier when using a special attack. :param success_verb: A verb overriding the player's equipped weapon verb; used in special attacks. :param fail_verb: A verb overriding the player's equipped weapon verb; used in special attacks. :param outcome: An appendix to add to attacks if they have a special outcome (e.g. a target is stunned or on fire) :return: A namedtuple with 2 positions - (Bool: was hit successful, target object) """ # TODO: Time to kill bats and goblins is good (2-3 rounds, max end is 5-6 with bad luck). # TODO: They hit too frequently/do too much damage without being able to heal or mitigate damage. # TODO: Add in heal ability/potions (how to make it useful, but not too easy? - extended CD?) # TODO: Increase monster EXP to reduce levelling rate (too slow ATM). # TODO: Damage mitigation via armor (both reduce to-hit and reduce damage amount?) entry = f"" target, search_term = search(self, text_input, "room.mobs") Report = namedtuple("Report", ("success", "target")) if target: # Just going to have the player attack the first mob of that type in the room for now. I'll figure out how # I want to do selection later. mob = target[0] attack = attack_action(self, mob, dam_mod) if attack.hit: if success_verb: attack_verb = f"{success_verb} the {mob}" else: attack_verb = ( f"{self.equipped_weapon.main_hand.success_verb} the {mob} with your " f"{self.equipped_weapon.main_hand.name}") if attack.hit_type == "hit": entry += f"You {attack_verb}" elif attack.hit_type == "crit": entry += f"You savagely {attack_verb}" entry += f" for {attack.damage} damage" if mob.current_hp <= 0: self.xp += mob.xp entry += (f", killing it!\n" f"You gain {mob.xp} xp.") mob.kill_monster() else: entry += f"{outcome}.\n" else: if fail_verb: attack_verb = f"{fail_verb} the {mob}" else: attack_verb = ( f"{self.equipped_weapon.main_hand.fail_verb} the {mob} with your " f"{self.equipped_weapon.main_hand.name}") entry += f"You {attack_verb} but" if attack.hit_type == "miss": entry += (f" missed.") if attack.hit_type == "dodge": entry += (f" the {mob} dodged out of the way.") self.add_messages(entry) self.journal.add_entry(f"(Round {self.turn_counter}): " + entry) return Report(attack.hit, mob) else: self.add_messages(f"You do not see one of those.") return Report(False, None) def basic_attack(self, text_input): attack = self.attack_target_mob(text_input) if attack.target: if attack.target.current_hp >= 1: self.advance_turn(attack.target) else: self.advance_turn() else: self.advance_turn() def check_level_up(self): if self.xp >= self.xp_to_level: # Just gonna have hp double at the moment. self.level += 1 self.max_hp = self.set_max_hp() self.current_hp = self.max_hp self.xp_to_level = self.set_xp_to_level() ding = f"DING! You've leveled up to {self.level}!\n" self.journal.add_entry(ding) ding += (f"Your stats are now:\n" f"{self.view_stats_no_header()}") self.add_messages(ding) else: pass def check_cooldowns(self): cds = f"" first = True for abil, cd in self.cooldowns.items(): if first: cds += f"{abil.title()}: {cd} rounds\n" first = False else: cds += (f"{abil.title()}: {cd} rounds\n" f"----------------------") self.add_messages(cds) def check_turn(self): self.add_messages(f"Turn: {self.turn_counter}") def clear_messages(self): self.messages = None def examine_object(self, item): return examine_object(self, item) def examine_room(self): self.add_messages(self.room.examine()) def haste_amount(self): return self.equipped_weapon.main_hand.cd_redux def move_action(self, noun, text_input): # TODO: Add sneak action for Rogues. attack_of_opportunity(self, text_input) move_action(self, noun) self.advance_turn() def print_messages(self): messages = f"" for message in self.messages: messages += message + f"\n" messages += f"----------------------------\n" return print(messages) def read_journal(self): self.add_messages(self.journal.read_journal()) def reduce_cooldowns(self): for abil, cd in self.cooldowns.items(): if cd > 0: self.cooldowns[abil] = cd - 1 def roll_damage(self): base_damage = random.randint(self.equipped_weapon.main_hand.damage_min, self.equipped_weapon.main_hand.damage_max) bonus_stat = self.equipped_weapon.main_hand.main_stat bonus_amount = getattr(self, bonus_stat) total_damage = int(base_damage * (1 + (1 / 1 - math.exp(-bonus_amount / 255)))) return total_damage def set_max_hp(self): return (self.level * 20) + self.ability_mod("constitution") def set_xp_to_level(self): return int(80 * ((1 + .25)**self.level)) def show_world_map(self): self.room.zone.world_map.show_world_map(self) def show_zone_map(self): self.room.zone.show_zone_map(self) def view_stats_no_header(self): stats = (f"Class: {self.name}\n" f"Level: {self.level} ({self.xp}/{self.xp_to_level} xp.)\n" f"HP: {self.current_hp}/{self.max_hp}\n" f"Defense: {self.current_phys_defense()}") return stats def view_stats_header(self): stats = (f"Your Character Stats:\n" f"Class: {self.name}\n" f"Level: {self.level} ({self.xp}/{self.xp_to_level} xp.)\n" f"HP: {self.current_hp}/{self.max_hp}\n" f"Defense: {self.current_phys_defense()}") self.add_messages(stats) def view_equipped(self): equipped_armor = self.equipped_armor.__str__() equipped_weapons = self.equipped_weapon.__str__() self.add_messages(equipped_armor) self.add_messages(equipped_weapons) def view_inventory(self): self.add_messages(self.inventory.__str__()) def equip_item(self, text_input): attack_of_opportunity(self, text_input) equip_action(self, text_input) self.advance_turn() def loot_corpse(self): pass
def setup_class(cls): cls.inv = Inventory()
def user_info_logic(message): user_id = str(message.author.id) stats = make_all_stats(user_id) # Give user information strings = G.LOC.commands.userInfo out = tools.MsgBuilder() bonus_tokens = 0 inventory = Inventory(user_id) if G.USR[user_id].times_ascended <= len(G.IDLE.ascension.bonus): bonus_tokens = G.IDLE.ascension.bonus[G.USR[user_id].times_ascended] # Introduction to help message out.add(strings.info) # Information about joules and lifetime joules out.add( strings.joules.format( tools.fn(G.USR[user_id].joules, decimals=2), tools.fn(G.USR[user_id].lifetime_joules, decimals=2))) # Information about tokens, token effects, and tokens gained on ascension. out.add( strings.tokens.format( tools.fn(G.USR[user_id].tokens, decimals=1), tools.fn(1 + (log(1 + G.USR[user_id].tokens, 10))), tools.fn(tokens_from_joules(G.USR[user_id].lifetime_joules)), tools.fn(bonus_tokens, decimals=1))) # Information about matter level if G.USR[user_id].epoch >= 1 and G.USR[user_id].matter > 0: out.add(strings.matterlevel.format(tools.fn(G.USR[user_id].matter))) # Information about lifetime statistics out.add( strings.lifetime.format(G.USR[user_id].times_ascended, tools.fn(G.USR[user_id].sacrificed_joules))) # Information about "production" stat out.add( strings.productionlevel.format( stats.production.stat_level, tools.fn(stats.production.value() * 60, decimals=1))) # Information about "time" stat out.add( strings.timelevel.format(stats.time.stat_level, tools.fn(stats.time.value()))) # Information about "attack" stat out.add( strings.attacklevel.format(stats.attack.stat_level, tools.fn(stats.attack.value()))) # Information about "commandCount" stat out.add( strings.commandCount.format(G.USR[str( message.author.id)].commandCount)) # Information about items in inventory. items = ", ".join( [G.LOC["items"][item.id].name for item in inventory.content]) items = items.rstrip() if items == "": out.add(strings.noitems) else: out.add(strings["items"].format(items)) # Information about achievements out.add( strings.achieves.format( tools.count_achieves(user_id), round(G.IDLE.harvest.achievebonus**tools.count_achieves(user_id), 2))) # Random funny line. out.add(("> " + tools.get_random_line(G.LOC.randomInfo_path))) return out.parse()
class Tile: def __init__(self): self.name = 'Empty' self.location = [0, 0] self.description = '' self.inventory = Inventory() self.north = False self.east = False self.south = False self.west = False def getName(self): return self.name def setName(self, name): self.name = name def setDescription(self, description): self.description = description def getDescription(self): return self.description def setLocation(self, location): self.location = location def getLocation(self): return self.location def makePath(self, direction): if direction == "n": self.north = True if direction == "e": self.east = True if direction == "s": self.south = True if direction == "w": self.west = True if direction == "all": self.north = True self.east = True self.south = True self.west = True def clearPath(self, direction): if direction == "n": self.north = False if direction == "e": self.east = False if direction == "s": self.south = False if direction == "w": self.west = False if direction == "all": self.north = False self.east = False self.south = False self.west = False def checkPath(self, direction): if direction == "n": return self.north if direction == "e": return self.east if direction == "s": return self.south if direction == "w": return self.west def putItem(self, item): self.inventory.addItem(item) def takeItem(self, item_name): return self.inventory.takeItem(item_name) def lookForThings(self): self.inventory.showItems()
class Player(MovableEntity): # Default values: # Dimensions for collisions default_width = 50 # px default_height = 50 # px # Height to render the player render_height = 100 # px # Maximum speeds walking_speed = 100 # px / s running_speed = 250 # px / s # Default hourly wage default_wage = 10 # $ / game hour # Number of days it takes the player to have symptoms # after becoming infected infection_time = 1 # days # Default constructor def __init__(self): # Set starting position and texture later MovableEntity.__init__(self, 0.0, 0.0, Player.default_width, Player.default_height, None, Player.walking_speed) # Survival meters self.money = 0 self.health = 0 self.morale = 0 # Consumption controller self.consumption = ConsumptionController() # Items that the player is currently colliding with self.nearby_items = [] # Characters that the player is currently nearby self.nearby_characters = [] # Vehicle the player is driving # None if the player is not currently driving self.vehicle = None # Pet that belongs to the player self.pet = None # Item the player is carrying # None if the player is not carrying anything self.item_being_carried = None # Most recent shopping cart the player touched # Its contents will be checked out when the player # goes to a checkout lane self.shopping_cart = None # Whether the user is running self.running = False # Whether the player is working self.working = False # Whether the player is sleeping self.sleeping = True # How much money the player gets each hour they work self.wage = Player.default_wage # How much money the player will receive after one week self.paycheck = 0 # Whether the player is infected self.infected = False # Whether the player is wearing a mask self.wearing_mask = False # Days since the player became infected self.days_since_infection = 0 # Inventories # What the player can carry on foot self.backpack = Inventory(InventoryType.BACKPACK, Inventory.default_backpack_capacity) # What the player can hold at their house, # daily requirements are subtracted from here self.closet = Inventory(InventoryType.CLOSET, Inventory.default_closet_capacity) # Moves the player based on their velocity def update(self): if self.vehicle != None: self.vehicle.drive(self) if self.item_being_carried != None: self.item_being_carried.carry(self) distance_traveled = self.update_position() # Update walked distance if player is walking if self.vehicle == None: self.consumption.walk_distance += distance_traveled # Make sure meters are not above 100 if self.health >= 100: self.health = 100 if self.morale >= 100: self.morale = 100 # Handles interact action def interact(self, messages, game_time): for item in self.nearby_items: item.handle_interaction(self, messages, game_time) for character in self.nearby_characters: character.handle_interaction(self, messages) # Adjusts player's velocity based on the parameters # Caps each component to player's maximum speed # Sets maximum speed based on whether the player is driving/running/walking # Resets if there is no change def adjust_velocity(self, x_change, y_change, running): # Toggle running status self.running = running # Sets maximum speed if self.vehicle != None and running: # Vehicle turbo self.speed = Vehicle.turbo_speed elif self.vehicle != None: # Vehicle regular self.speed = Vehicle.regular_speed elif self.running: # Running self.speed = Player.running_speed else: # Walking self.speed = Player.walking_speed self.x_velocity += x_change * 0.10 * self.speed self.y_velocity += y_change * 0.10 * self.speed # Cap to maximum speed if self.x_velocity >= self.speed: self.x_velocity = self.speed if self.x_velocity <= -self.speed: self.x_velocity = -self.speed if self.y_velocity >= self.speed: self.y_velocity = self.speed if self.y_velocity <= -self.speed: self.y_velocity = -self.speed # No change, reset if x_change == 0: self.x_velocity = 0 if y_change == 0: self.y_velocity = 0 # Does not render player if they are driving # Renders the player with its render height # If player has a mask on, renders with mask clip def render(self, renderer, camera_x, camera_y): if self.vehicle == None: if self.wearing_mask: sdl2.SDL_RenderCopyEx( renderer, self.texture, sdl2.SDL_Rect(Player.default_width, 0, Player.default_width, Player.render_height), sdl2.SDL_Rect(int(self.x - camera_x), int(self.y - camera_y - self.height), int(self.width), int(Player.render_height)), 0, None, sdl2.SDL_FLIP_NONE) else: sdl2.SDL_RenderCopyEx( renderer, self.texture, sdl2.SDL_Rect(0, 0, Player.default_width, Player.render_height), sdl2.SDL_Rect(int(self.x - camera_x), int(self.y - camera_y - self.height), int(self.width), int(Player.render_height)), 0, None, sdl2.SDL_FLIP_NONE) # Adds item to the player's nearby items list def add_nearby_item(self, item): self.nearby_items.append(item) # Adds character to the player's nearby character list def add_nearby_character(self, character): self.nearby_characters.append(character) # Clears the nearby items and characters lists and player status def reset_values(self): self.nearby_items.clear() self.nearby_characters.clear() self.working = False self.sleeping = False # Decreases supply count by the quantity for the supply type # from the player's closet # Returns false if the player's closet does not contain the # quantity of that supply type # Returns true if the use is successful def use_supply(self, supply_type, quantity): for supply in range(quantity): if not self.closet.remove_supply(supply_type): return False return True def maintain_within_map(self, map_rectangle): if self.check_collision_directly(map_rectangle[0],\ map_rectangle[1], map_rectangle[2], map_rectangle[3]): return if (self.x > map_rectangle[0] and self.x_velocity > 0): self.block_movement() if (self.x < map_rectangle[0] and self.x_velocity < 0): self.block_movement() if (self.y > map_rectangle[1] and self.y_velocity > 0): self.block_movement() if (self.y < map_rectangle[1] and self.y_velocity < 0): self.block_movement() # Also checks collision on the vehicle if player is driving def check_collision(self, other): if self.vehicle != None: if other == self.vehicle: other = self return self.vehicle.check_collision(other) # TO DO: damage player for crashing car return self.vehicle.check_collision(other) else: collision = other.check_collision_directly(self.x, self.y - self.height, self.width, Player.render_height) # If player touched an item, add to items touched if collision and isinstance(other, Item): self.consumption.items_touched.add(other) return collision
class Player: def __init__(self): self.name = 'nobody' self.alive = True self.inventory = Inventory() self.map = None self.location = [0,0] def killPlayer(self): self.alive = False def revivePlayer(self): self.alive = True def namePlayer(self, name): self.name = name def putPlayer(self, room, x, y): self.map = room self.location = [x, y] def getLocation(self): return(self.location) def movePlayer(self, direction): if self.map == None: return False start_tile = self.map.getTile(self.location[0], self.location[1]) if direction == "n" and start_tile.checkPath("n"): self.location[1] += 1 return True if direction == "e" and start_tile.checkPath("e"): self.location[0] += 1 return True if direction == "s" and start_tile.checkPath("s"): self.location[1] -= 1 return True if direction == "w" and start_tile.checkPath("w"): self.location[0] -= 1 return True return False def printScene(self): print(self.map.getTile(self.location[0], self.location[1]).getDescription()) def lookForThings(self): self.map.getTile(self.location[0], self.location[1]).lookForThings() def pickUp(self, item_name): item = self.map.getTile(self.location[0], self.location[1]).takeItem(item_name) if item: self.inventory.addItem(item) def putDown(self, item_name): item = self.inventory.removeItem(item_name) if item: self.map.getTile(self.location[0], self.location[1]).putItem(item) def consume(self, item_name): return self.inventory.removeItem(item_name) def transmute(self, item_name, new_item): self.inventory.removeItem(item_name) self.inventory.addItem(new_item) '''
class Actor(Sprite): """High level access to character's workings including name, stats, inventory, and whatever else we want to stick in the character. Subclass of the Sprite class to get all of the animation goodness for any actor in the game. """ def __init__(self, scene, spriteset): Sprite.__init__(self, spriteset) self.scene = scene self.stats = ActorStats(self) self.name = "Chryso" self.job = None self.level = 1 self.experience = 0 self.maxHp = 10 self.hp = 10 self.maxAp = 5 self.ap = 5 self.money = 500 self.inventory = Inventory(self) self.dialogId = "default" self.state = {} def __set_name(self, name): self.__name = name def __get_name(self): return self.__name def __del_name(self): del self.__name name = property(__get_name, __set_name, __del_name, "The actor's name") def __set_level_exp_start(self, level_exp_start): self.__level_exp_start = level_exp_start def __get_level_exp_start(self): return self.__level_exp_start def __del_level_exp_start(self): del self.__level_exp_start levelExpStart = property(__get_level_exp_start, __set_level_exp_start, __del_level_exp_start, "The actor's level_exp_start") def __set_level_exp_end(self, level_exp_end): self.__level_exp_end = level_exp_end def __get_level_exp_end(self): return self.__level_exp_end def __del_level_exp_end(self): del self.__level_exp_end levelExpEnd = property(__get_level_exp_end, __set_level_exp_end, __del_level_exp_end, "The actor's level_exp_end") def __get_job(self): return self.__job def __set_job(self, job): self.__job = job def __del_job(self): del self.__job job = property(__get_job, __set_job, __del_job, "The actor's current job") def __get_level(self): return self.__level def __set_level(self, lvl): if not hasattr(self, '__level'): self.__level = 0 ol = self.__level self.__level = lvl self.__level_exp_start, self.__level_exp_end = self._calculateLevelExp( lvl) self._calculateLevelStats(lvl - ol) def __del_level(self): del self.__level level = property(__get_level, __set_level, __del_level, "The actor's level") def __get_experience(self): return self.__experience def __set_experience(self, exp): self.__experience = exp def __del_experience(self): del self.__experience experience = property(__get_experience, __set_experience, __del_experience, "The actor's experience") def __get_hp(self): return self.__hp def __set_hp(self, hp): self.__hp = hp def __del_hp(self): del self.__hp hp = property(__get_hp, __set_hp, __del_hp, "The actor's current hit points") def __get_max_hp(self): return self.__max_hp def __set_max_hp(self, maxhp): self.__max_hp = maxhp def __del_max_hp(self): del self.__max_hp maxHp = property(__get_max_hp, __set_max_hp, __del_max_hp, "The actor's max hit points") def __get_ap(self): return self.__ap def __set_ap(self, ap): self.__ap = ap def __del_ap(self): del self.__ap ap = property(__get_ap, __set_ap, __del_ap, "The actor's action points") def __get_max_ap(self): return self.__max_ap def __set_max_ap(self, maxap): self.__max_ap = maxap def __del_max_ap(self): del self.__max_ap maxAp = property(__get_max_ap, __set_max_ap, __del_max_ap, "The actor's max action points") def _calculateLevelExp(self, level): """Determines the range of experience for the specified level.""" return (1000 * (level - 1), 1000 * (level - 1) + 1000) def _calculateLevelStats(self, dl): """Determines new stat values for a level change (positive or negative)""" if dl > 0: multiplier = 1 elif dl < 0: multiplier = -1 else: multiplier = 0 for i in range(dl): self.stats.updateStats(multiplier) def performDialog(self): """If the player tries to act on this actor, this will be called.""" self.scene.dialogCollector.runDialog(self) def canBuyItem(self, item, payFullValue=True): return (item.fullValue if payFullValue else item.worth) < self.money def buyItem(self, seller, item, payFullValue=True): seller.money += item.fullValue if payFullValue else item.worth seller.inventory.removeItem(item) self.money -= item.fullValue if payFullValue else item.worth self.inventory.stowItem(item)
def make_achievements(): """Adds all achievements to global achievement list""" # Number of commands ----------------------------------------------------- add_achievement( lambda user: True if G.USR[user].commandCount >= 1 else False, "use_MLA") add_achievement( lambda user: True if G.USR[user].commandCount >= 50 else False, "use_MLA2") add_achievement( lambda user: True if G.USR[user].commandCount >= 100 else False, "use_MLA3") add_achievement( lambda user: True if G.USR[user].commandCount >= 1_000 else False, "use_MLA4") # Number of Joules ----------------------------------------------------- add_achievement(lambda user: True if G.USR[user].joules >= 100 else False, "joules1") add_achievement( lambda user: True if G.USR[user].joules >= 17_000 else False, "joules2") add_achievement( lambda user: True if G.USR[user].joules >= 1_000_000 else False, "joules3") add_achievement( lambda user: True if G.USR[user].joules >= 4_206_969 else False, "joules_blazeit") add_achievement( lambda user: True if str(round(G.USR[user].joules, 0)).startswith("69") else False, "joules_sixtynine") # Production stats ----------------------------------------------------- add_achievement( lambda user: True if Statistic("production", user).value() * 60 >= 5 else False, "production1") add_achievement( lambda user: True if Statistic("production", user).value() * 60 >= 100 else False, "production2") add_achievement( lambda user: True if Statistic("production", user).value() * 60 >= 500 else False, "production3") add_achievement( lambda user: True if Statistic("production", user).value() >= 3.84e26 else False, "production_sun") add_achievement( lambda user: True if Statistic("production", user).value() * 60 >= 1111 else False, "production_eleveneleven") # Attack stats ----------------------------------------------------- add_achievement( lambda user: True if Statistic("attack", user).value() >= 300 else False, "attack1") add_achievement( lambda user: True if Statistic("attack", user).value() >= 10000 else False, "attack2") add_achievement( lambda user: True if Statistic("attack", user).value() >= 123456 else False, "attack3") # Time stat ----------------------------------------------------- add_achievement( lambda user: True if Statistic("time", user).value() >= 2 else False, "time1") add_achievement( lambda user: True if Statistic("time", user).value() >= 10 else False, "time2") add_achievement( lambda user: True if Statistic("time", user).value() >= 24 else False, "time3") # Titan Damage ----------------------------------------------------- add_achievement( lambda user: True if G.USR[user].titan_damage >= 1e5 else False, "damage1") add_achievement( lambda user: True if G.USR[user].titan_damage >= 1e6 else False, "damage2") add_achievement( lambda user: True if G.USR[user].titan_damage >= 1e9 else False, "damage3") add_achievement( lambda user: True if G.USR[user].onedamage is True else False, "onedamage") add_achievement(lambda user: True if G.USR[user].maximum_damage >= 6_666 else False, "damagerecord1", status="legacy") add_achievement(lambda user: True if G.USR[user].maximum_damage >= 666_666 else False, "damagerecord2", status="legacy") add_achievement(lambda user: True if G.USR[user].maximum_damage >= 6_666_666 else False, "damagerecord3", status="legacy") add_achievement( lambda user: True if G.USR[user].instantkill is True else False, "instantkill") # Times attacked --------------------------------------------------------------------------- add_achievement( lambda user: True if G.USR[user].times_attacked >= 1 else False, "times_attacked1") add_achievement( lambda user: True if G.USR[user].times_attacked >= 10 else False, "times_attacked2") add_achievement( lambda user: True if G.USR[user].times_attacked >= 365 else False, "times_attacked3") # Tokens ----------------------------------------------------- add_achievement(lambda user: True if G.USR[user].tokens >= 1 else False, "tokens1") add_achievement(lambda user: True if G.USR[user].tokens >= 100 else False, "tokens2") add_achievement(lambda user: True if G.USR[user].tokens >= 1e6 else False, "tokens3") # Inventory ------------------------------------------------- add_achievement( lambda user: True if len(Inventory(user).content) == G.IDLE.max_items else False, "full_inventory") # Matter ---------------------------------------------------- add_achievement( lambda user: True if G.USR[user].times_condensed > 1 else False, "condensed1") # Other ----------------------------------------------------- add_achievement(lambda user: True if G.USR[user].gotLucky else False, "critical_win") add_achievement(lambda user: True if G.USR[user].gotUnlucky else False, "critical_failure") add_achievement( lambda user: True if G.USR[user].factCount >= 20 else False, "many_facts") add_achievement(lambda user: True if G.USR[user].konami else False, "konami") add_achievement(lambda user: True if G.USR[user].cheat else False, "cheat") add_achievement(lambda user: False, "joulepocalipse") return True
print( '\n2:A weapon is important: attempt to sneak in and grab a weapon without anyone noticing.' ) cmdlist = ['1', '2'] cmd = getcmd(cmdlist) if cmd == '1': print('You sneak past the door, and continue deeper into the prison.') time.sleep(1) cell(player) if cmd == '2': print('You enter the cell, and attempt to grab a near by sword.') player.add_item('Sword') print(player.totalinventory) time.sleep(20) def getcmd(cmdlist): cmd = input("Enter your choice: ") if cmd in cmdlist: return cmd if __name__ == "__main__": player = Inventory('Player 1', '', '', '') print( "The prisoner looks around the cell, scoffing at his present situation. He decides it's time to escape. Find a way out." ) time.sleep(3) cell(player)
def __init__(self): self.name = 'nobody' self.alive = True self.inventory = Inventory() self.map = None self.location = [0,0]
def __init__(self): # Set starting position and texture later MovableEntity.__init__(self, 0.0, 0.0, Player.default_width, Player.default_height, None, Player.walking_speed) # Survival meters self.money = 0 self.health = 0 self.morale = 0 # Consumption controller self.consumption = ConsumptionController() # Items that the player is currently colliding with self.nearby_items = [] # Characters that the player is currently nearby self.nearby_characters = [] # Vehicle the player is driving # None if the player is not currently driving self.vehicle = None # Pet that belongs to the player self.pet = None # Item the player is carrying # None if the player is not carrying anything self.item_being_carried = None # Most recent shopping cart the player touched # Its contents will be checked out when the player # goes to a checkout lane self.shopping_cart = None # Whether the user is running self.running = False # Whether the player is working self.working = False # Whether the player is sleeping self.sleeping = True # How much money the player gets each hour they work self.wage = Player.default_wage # How much money the player will receive after one week self.paycheck = 0 # Whether the player is infected self.infected = False # Whether the player is wearing a mask self.wearing_mask = False # Days since the player became infected self.days_since_infection = 0 # Inventories # What the player can carry on foot self.backpack = Inventory(InventoryType.BACKPACK, Inventory.default_backpack_capacity) # What the player can hold at their house, # daily requirements are subtracted from here self.closet = Inventory(InventoryType.CLOSET, Inventory.default_closet_capacity)