more fixes

This commit is contained in:
2025-09-23 20:20:06 +01:00
parent 0c8b4f9543
commit d6e64d5eab
11 changed files with 240 additions and 9 deletions

Binary file not shown.

Binary file not shown.

View File

@@ -72,6 +72,8 @@ class DuckDB:
player['inventory'] = {}
if 'temporary_effects' not in player:
player['temporary_effects'] = []
if 'jam_chance' not in player:
player['jam_chance'] = 5 # Default 5% jam chance
# Migrate from old ammo/chargers system to magazine system
if 'magazines' not in player:
@@ -106,6 +108,7 @@ class DuckDB:
'magazines': 3, # Total magazines (including current)
'bullets_per_magazine': 6, # Bullets per magazine
'accuracy': 65,
'jam_chance': 5, # 5% base gun jamming chance
'gun_confiscated': False,
'inventory': {}, # {item_id: quantity}
'temporary_effects': [] # List of temporary effects

View File

@@ -133,7 +133,20 @@ class DuckHuntBot:
async def handle_message(self, prefix, command, params, trailing):
"""Handle incoming IRC messages"""
if command == "001": # Welcome message
# Handle SASL-related messages
if command == "CAP":
await self.sasl_handler.handle_cap_response(params, trailing)
return
elif command == "AUTHENTICATE":
await self.sasl_handler.handle_authenticate_response(params)
return
elif command in ["903", "904", "905", "906", "907", "908"]:
await self.sasl_handler.handle_sasl_result(command, params, trailing)
return
elif command == "001": # Welcome message
self.registered = True
self.logger.info("Successfully registered with IRC server")
@@ -487,7 +500,12 @@ class DuckHuntBot:
try:
await self.connect()
await self.register_user()
# Check if SASL should be used
if self.sasl_handler.should_authenticate():
await self.sasl_handler.start_negotiation()
else:
await self.register_user()
# Start game loops
game_task = asyncio.create_task(self.game.start_game_loops())

View File

@@ -125,6 +125,18 @@ class DuckGame:
'message_args': {'nick': nick}
}
# Check for gun jamming
jam_chance = player.get('jam_chance', 5) / 100.0 # Convert percentage to decimal
if random.random() < jam_chance:
# Gun jammed! Use ammo but don't shoot
player['current_ammo'] = player.get('current_ammo', 1) - 1
self.db.save_database()
return {
'success': False,
'message_key': 'bang_gun_jammed',
'message_args': {'nick': nick}
}
# Check for duck
if channel not in self.ducks or not self.ducks[channel]:
# Wild shot - gun confiscated

View File

@@ -313,6 +313,18 @@ class ShopManager:
"remaining": player['ammo']
}
elif item_type == 'clean_gun':
# Clean gun to reduce jamming chance (positive amount reduces jam chance)
current_jam = player.get('jam_chance', 5) # Default 5% jam chance
new_jam = max(current_jam + amount, 0) # amount is negative for cleaning
player['jam_chance'] = new_jam
return {
"type": "clean_gun",
"reduced": current_jam - new_jam,
"new_total": new_jam
}
else:
self.logger.warning(f"Unknown item type: {item_type}")
return {"type": "unknown", "message": f"Unknown effect type: {item_type}"}