Example #1
0
	def __init__(self, level, player):
		super(BadGuy, self).__init__(level)
		self.level.badguy = self
		self.player = player
		self.sprites = [
			pygame.image.load("assets/FinalBoss/Left.png").convert_alpha(),
			pygame.image.load("assets/FinalBoss/Right.png").convert_alpha()
		]
		self.powermode_sprites = [
			pygame.image.load("assets/FinalBoss/Left_Powermode.png").convert_alpha(),
			pygame.image.load("assets/FinalBoss/Right_Powermode.png").convert_alpha()
		]
		self.current_sprite = self.sprites[0]
		self.case_x = 16
		self.case_y = 15
		self.rect = self.current_sprite.get_rect().move(self.case_x * c.SPRITE_SIZE, self.case_y * c.SPRITE_SIZE)
		self.weapon = w.BossWeapon(self, self.player)
		self.stamina = c.B_STAMINA
		self.attack = c.B_ATTACK
		self.health = c.B_HEALTH
Example #2
0
torch = Item("torch", "a flashlight.", True, [break, drop, examine, take, get])
tree = Item("tree", "an enormous tree, which looks like it may be climbable.", False, [climb])
gloves = Item("gloves", "a medium sized pair of gloves, they are slightly worn out", False, [drop, examine, take, get])
climbing_shoes = Item("climbing shoes", "a large pair of climbing shoes, this could be helpful on slopes", False, [climb, drop, examine, take, get])
body = Item("body", "a perfectly preserved corpse with a slightly surprised expression on its face", False, [examine, eat])
rock = Item("rock", "a large rock, it looks slightly lodged", False, [examine, move, search])
car = Item("car", "a rusty old car, it hasn't run in years", False, [examine, search])
backpack = Item("backpack", "a dark blue backpack with something in it", False, [drop, examine, open, take, get])
macbook = Item("macbook", "an old macbook from before the linux uprising", True [break, drop, examine, take, get])
hollowed_tree = Item("hollowed tree", "a hollowed out tree, there could be something inside", False, [climb, examine, search])




#----------WEAPONS----------------------------
sword = Weapon("sword", "a beautiful and ancient-looking sword of fearsome proportions.", False, [take, get, drop], 5)
knife = Weapon("knife", "a short and deadly knife, it has a look of brutality.", False, [take, get, drop], 3)
machete = Weapon("machete", "a long curved machete, it looks pretty sharp.", False, [take, get, drop], 4)
pistol = Weapon("pistol", "a lovingly maintained Glock, ready to fire.", False, [take, get, drop], 7)
rifle = Weapon("rifle", "a semi-automatic rifle with a pretty hardcore military vibe.", False, [take, get, drop], 10)




#---------FOOD--------------------------------
chocolate = Food("chocolate", "wow this chocolate is so well preserved, it looks sweet and delicious", False, [examine, take, eat, drop, get])
noodles = Food("noodles", "wow these noodles are so well preserved, definitley not rotten", False, [examine, take, eat, drop, get])
banana = Food("banana", "a surpringly perfectly ripe banana, might have monkey aids though", False, [examine, take, eat, drop, get])
apple = Food("apple", "a pink lady apple", False, [examine, take, eat, drop, get])
energy_drink = Food("energy drink", "a popular energy drink stole from a basement hackathon", False, [examine, take, eat, drop, get])
coffee = Food("coffe", "a cup of coffee, black", False, [examine, take, eat, drop, get])
Example #3
0
paper = Item()
kindle = Item()
computer = Item()
torch = Item()
tree = Item()
gloves = Item()
climbing_shoes = Item()
body = Item()
rock = Item()
car = Item()
backpack = Item()
macbook = Item()
hollowed_tree = Item()

#----------WEAPONS----------------------------
sword = Weapon()
knife = Weapon()
machete = Weapon()
pistol = Weapon()
rifle = Weapon()

#---------FOOD--------------------------------
chocolate = Food()
noodles = Food()
banana = Food()
apple = Food()
energy_drink = Food()
coffee = Food()
beer = Food()
water = Food()
pizza = Food()
Example #4
0
    def __init__(self, level):
        self.levels = level
        self.level_n = 0
        self.level = self.levels[self.level_n]
        self.powermode = False
        self.health = c.HEALTH
        self.attack = c.ATTACK
        self.stamina = c.STAMINA
        self.exp = 0
        self.exp_level = 1
        self.kills = 0
        self.armed = False
        self.alive = True
        self.moving = False

        self.xp_bar_sprites = []
        for i in range(1, 6):
            self.xp_bar_sprites.append(
                pygame.image.load("assets/player/Exp/LevelBar/" + str(i) +
                                  ".png").convert_alpha())

        self.xp_case_sprites = []
        for i in range(1, 6):
            self.xp_case_sprites.append(
                pygame.image.load("assets/player/Exp/LevelCase/" + str(i) +
                                  ".png").convert_alpha())

        self.health_sprites = [
            pygame.image.load(
                "assets/player/health/health_full.png").convert_alpha(),
            pygame.image.load(
                "assets/player/health/health_half.png").convert_alpha()
        ]

        self.stamina_sprites = [
            pygame.image.load(
                "assets/player/stamina/full_stamina.png").convert_alpha(),
            pygame.image.load("assets/player/stamina/almost_full_stamina.png").
            convert_alpha(),
            pygame.image.load(
                "assets/player/stamina/mid_stamina.png").convert_alpha(),
            pygame.image.load(
                "assets/player/stamina/quart_stamina.png").convert_alpha(),
            pygame.image.load(
                "assets/player/stamina/low_stamina.png").convert_alpha(),
        ]

        self.powermode_sprites = [
            pygame.image.load(
                "assets/player/LeftPowermode.png").convert_alpha(),
            pygame.image.load(
                "assets/player/RightPowermode.png").convert_alpha()
        ]

        self.sprites = [
            pygame.image.load("assets/player/Right.png").convert_alpha(),
            pygame.image.load("assets/player/Left.png").convert_alpha(),
            pygame.image.load("assets/player/RightArmed.png").convert_alpha(),
            pygame.image.load("assets/player/LeftArmed.png").convert_alpha()
        ]

        self.powermode_health_sprites = [
            pygame.image.load("assets/player/health/powermode_health_full.png"
                              ).convert_alpha()
        ]

        for i in range(1, 6):
            self.powermode_health_sprites.append(
                pygame.image.load("assets/player/health/powermode_health_" +
                                  str(i) + ".png").convert_alpha())

        self.current_sprite = self.sprites[0]

        self.rect = self.current_sprite.get_rect()

        self.case_x = 0
        self.case_y = 0

        self.weapon = w.Weapon(self)
        self.attacking = False

        self.level.window.blit(self.current_sprite, self.rect)
Example #5
0
async def process_score(match: 'match.classes.MatchData',
                        start_time: int,
                        match_channel: 'TextChannel' = None):
    """
    Calculate the result score for the MatchData object provided.

    :param match: MatchData object to fill with scores.
    :param start_time: Round start timestamp: will process score starting form this time.
    :param match_channel: Match channel for illegal weapons display (optional).
    :raise ApiNotReachable: If an API call fail.
    """
    # Temp data structures
    ig_dict = dict()
    current_ill_weapons = dict()

    # Start and end timestamps
    start = start_time
    end = start + (match.round_length * 60)

    # Fill player dictionary (in-game id -> player object)
    for tm in match.teams:
        for player in tm.players:
            if not player.is_disabled:
                ig_dict[int(player.ig_id)] = player
            else:
                print(f"{player.name} is disabled!")

    # Request url:
    url = f'http://census.daybreakgames.com/s:{cfg.general["api_key"]}/get/ps2:v2/characters_event/?character_id=' \
          f'{",".join(str(p.ig_id) for p in ig_dict.values())}&type=KILL&after={start}&before={end}&c:limit=500'
    j_data = await http_request(url, retries=5)

    if j_data["returned"] == 0:
        raise ApiNotReachable(f"Empty answer on score calculation (url={url})")

    event_list = j_data["characters_event_list"]

    ill_weapons = dict()

    # Loop through all events retrieved:
    for event in event_list:

        # Get opponent player
        oppo = ig_dict.get(int(event["character_id"]))
        if not oppo:
            # interaction with outside player, skip it
            continue
        opo_loadout = oppo.get_loadout(int(event["character_loadout_id"]))

        player = ig_dict.get(int(event["attacker_character_id"]))
        if not player:
            # interaction with outside player, skip it
            continue
        player_loadout = player.get_loadout(int(event["attacker_loadout_id"]))

        # Get weapon
        weap_id = int(event["attacker_weapon_id"])
        is_hs = int(event["is_headshot"]) == 1
        weapon = Weapon.get(weap_id)
        if not weapon:
            log.error(f'Weapon not found in database: id={weap_id}')
            weapon = Weapon.get(0)

        # Parse event into loadout objects
        if oppo is player:
            # Player killed themselves
            player_loadout.add_one_suicide()
        elif oppo.team is player.team:
            # Team-kill
            player_loadout.add_one_tk()
            opo_loadout.add_one_death(0)
        else:
            # Regular kill
            if not weapon.is_banned:
                # If weapon is allowed
                pts = weapon.points
                player_loadout.add_one_kill(pts, is_hs)
                opo_loadout.add_one_death(pts)
            else:
                # If weapon is banned, add it to illegal weapons list
                player_loadout.add_illegal_weapon(weapon.id)
                if player not in ill_weapons:
                    ill_weapons[player] = AutoDict()
                ill_weapons[player].auto_add(weapon.id, 1)

    # Display all banned-weapons uses for this player:
    for player in ill_weapons.keys():
        for weap_id in ill_weapons[player]:
            weapon = Weapon.get(weap_id)
            if match_channel:
                await display.SC_ILLEGAL_WE.send(match_channel, player.mention,
                                                 weapon.name, match.id,
                                                 ill_weapons[player][weap_id])
                await display.SC_ILLEGAL_WE.send(
                    ContextWrapper.channel(cfg.channels["staff"]),
                    player.mention, weapon.name, match.id,
                    ill_weapons[player][weap_id])

    # Also get base captures
    await get_captures(match, start, end)
Example #6
0
import unittest
from classes import Hero, Enemy, Weapon, Spell

pesho = Hero('Petr', 'Pedo', 100, 100, 2)
vrago = Enemy(100, 100, 20)
weapon = Weapon('Sword of Bad Manners', 20)
spell = Spell('Fireball', 60, 100, 3)


class TestHeroClass(unittest.TestCase):

    def test_hero_init(self):
        result = pesho.health
        expected = 100

        self.assertEqual(result, expected)

    def test_hero_take_damage_and_is_alive(self):
        pesho.take_damage(100)

        result = pesho.is_alive()
        expected = False

        self.assertEqual(result, expected)

    def test_hero_take_damage_and_get_health(self):
        pesho.take_damage(57)

        result = pesho.get_health()
        expected = 43