new item, shin bone , added.
This commit is contained in:
		| @@ -181,7 +181,9 @@ class Enemy(Object): | ||||
|         if self.enemyType == "witch": | ||||
|             # Determine which item to drop | ||||
|             hasBroom = any(weapon.name == "witch_broom" for weapon in self.level.player.weapons) | ||||
|             itemType = "cauldron" if hasBroom else "witch_broom" | ||||
|             hasNunchucks = any(weapon.name == "nunchucks" for weapon in self.level.player.weapons) | ||||
|             # Drop witch_broom only if player has neither broom nor nunchucks | ||||
|             itemType = "witch_broom" if not (hasBroom or hasNunchucks) else "cauldron" | ||||
|              | ||||
|             # Create drop 1-2 tiles away in random direction | ||||
|             direction = random.choice([-1, 1]) | ||||
|   | ||||
| @@ -43,6 +43,7 @@ class Player: | ||||
|         self.collectedItems = [] | ||||
|         self._coins = 0 | ||||
|         self._jack_o_lantern_count = 0 | ||||
|         self.shinBoneCount = 0 | ||||
|          | ||||
|         # Combat related attributes | ||||
|         self.weapons = [] | ||||
| @@ -64,7 +65,7 @@ class Player: | ||||
|             hitSound="player_shovel_hit", | ||||
|             attackDuration=200  # 200ms attack duration | ||||
|         )) | ||||
|          | ||||
|  | ||||
|     def should_play_footstep(self, currentTime): | ||||
|         """Check if it's time to play a footstep sound""" | ||||
|         return (self.distanceSinceLastStep >= self.get_step_distance() and  | ||||
| @@ -211,7 +212,7 @@ class Player: | ||||
|         """Add an item to inventory""" | ||||
|         self.inventory.append(item) | ||||
|         self.collectedItems.append(item) | ||||
|          | ||||
|  | ||||
|     def start_attack(self, currentTime): | ||||
|         """Attempt to start an attack with the current weapon""" | ||||
|         if self.currentWeapon and self.currentWeapon.start_attack(currentTime): | ||||
|   | ||||
| @@ -49,10 +49,16 @@ class PowerUp(Object): | ||||
|             player.restore_health() | ||||
|         elif self.item_type == 'guts': | ||||
|             player.add_guts() | ||||
|             player.collectedItems.append('guts') | ||||
|             self.check_for_nunchucks(player) | ||||
|         elif self.item_type == 'jack_o_lantern': | ||||
|             player.add_jack_o_lantern() | ||||
|         elif self.item_type == 'extra_life': | ||||
|             player.extra_life() | ||||
|         elif self.item_type == 'shin_bone':  # Add shin bone handling | ||||
|             player.shinBoneCount += 1 | ||||
|             player._coins += 5 | ||||
|             self.check_for_nunchucks(player) | ||||
|         elif self.item_type == 'witch_broom': | ||||
|             broomWeapon = Weapon.create_witch_broom() | ||||
|             player.add_weapon(broomWeapon) | ||||
| @@ -81,3 +87,16 @@ class PowerUp(Object): | ||||
|  | ||||
|         # Item tracking | ||||
|         player.stats.update_stat('Items collected', 1) | ||||
|  | ||||
|     def check_for_nunchucks(self, player): | ||||
|         """Check if player has materials for nunchucks and create if conditions are met""" | ||||
|         print("Checking for nunchucks.") | ||||
|         print(f"Player has {player.shinBoneCount} shin bones and {player.collectedItems}.") | ||||
|         if (player.shinBoneCount >= 2 and  | ||||
|             'guts' in player.collectedItems and  | ||||
|             not any(weapon.name == "nunchucks" for weapon in player.weapons)): | ||||
|             nunchucksWeapon = Weapon.create_nunchucks() | ||||
|             player.add_weapon(nunchucksWeapon) | ||||
|             player.equip_weapon(nunchucksWeapon) | ||||
|             play_sound(self.sounds['get_nunchucks']) | ||||
|             player.stats.update_stat('Items collected', 1) | ||||
|   | ||||
| @@ -10,6 +10,19 @@ class Weapon: | ||||
|         self.lastAttackTime = 0 | ||||
|         self.hitEnemies = set() | ||||
|          | ||||
|     @classmethod | ||||
|     def create_nunchucks(cls): | ||||
|         """Create the nunchucks weapon""" | ||||
|         return cls( | ||||
|             name="nunchucks", | ||||
|             damage=6, | ||||
|             range=4, | ||||
|             attackSound="player_nunchuck_attack", | ||||
|             hitSound="player_nunchuck_hit", | ||||
|             cooldown=250, | ||||
|             attackDuration=100 | ||||
|         ) | ||||
|  | ||||
|     @classmethod | ||||
|     def create_witch_broom(cls): | ||||
|         """Create the witch's broom weapon""" | ||||
|   | ||||
		Reference in New Issue
	
	Block a user