From 4ac0a3a59fe215cc66992287c8224df0f94914b1 Mon Sep 17 00:00:00 2001 From: AlienMajik <118037572+AlienMajik@users.noreply.github.com> Date: Sun, 16 Feb 2025 17:50:42 -0800 Subject: [PATCH] Update age.py --- age.py | 110 +++++++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 79 insertions(+), 31 deletions(-) diff --git a/age.py b/age.py index dcacba1..1aa33ca 100644 --- a/age.py +++ b/age.py @@ -2,6 +2,7 @@ import os import json import logging import time +import random import pwnagotchi import pwnagotchi.plugins as plugins @@ -12,34 +13,41 @@ from pwnagotchi.ui.view import BLACK class Age(plugins.Plugin): __author__ = 'AlienMajik' - __version__ = '2.0.1' + __version__ = '2.0.2' __license__ = 'MIT' - __description__ = 'Enhanced plugin with achievement tiers, configurable titles, decay mechanics, and progress tracking.' + __description__ = 'Enhanced plugin with achievement tiers, configurable titles, decay mechanics, progress tracking, dynamic status messages, and quests.' DEFAULT_AGE_TITLES = { - 1000: "Newborn", + 1000: "Neon Spawn", 2000: "Script Kiddie", - 5000: "WiFi Hobo", - 10000: "Packet Wizard", - 20000: "Elder Hacker", - 33333: "WiFi Deity" + 5000: "WiFi Outlaw", + 10000: "Data Raider", + 25000: "Prophet", + 33333: "Off the Grid" } DEFAULT_STRENGTH_TITLES = { - 1000: "Weakling", - 2000: "Lightweight", - 5000: "Deauth King", - 10000: "Handshake Titan", - 20000: "Unstoppable" + 500: "Fleshbag", + 1500: "Lightweight", + 2000: "Deauth King", + 2500: "Handshake hunter", + 3333: "Unstoppable" } + # Example quests + DEFAULT_QUESTS = [ + {"name": "Collect 10 WPA3 handshakes", "goal": 10, "reward": "⭐ Extra Star!"}, + {"name": "Survive 100 epochs without decaying", "goal": 100, "reward": "🛡️ Resilience Badge"}, + ] + def __init__(self): # Default positions (x, y) self.default_positions = { 'age': (10, 40), 'strength': (80, 40), 'points': (10, 60), - 'stars': (10, 80) + 'stars': (10, 80), + 'quests': (10, 100) } self.epochs = 0 @@ -47,6 +55,7 @@ class Age(plugins.Plugin): self.network_points = 0 self.handshake_count = 0 self.last_active_epoch = 0 + self.completed_quests = set() self.data_path = '/root/age_strength.json' self.log_path = '/root/network_points.log' self.handshake_dir = '/home/pi/handshakes' @@ -58,6 +67,7 @@ class Age(plugins.Plugin): self.decay_amount = 10 self.age_titles = self.DEFAULT_AGE_TITLES self.strength_titles = self.DEFAULT_STRENGTH_TITLES + self.quests = self.DEFAULT_QUESTS def on_loaded(self): # Load configuration with fallbacks @@ -67,6 +77,7 @@ class Age(plugins.Plugin): self.decay_amount = self.options.get('decay_amount', 10) self.age_titles = self.options.get('age_titles', self.DEFAULT_AGE_TITLES) self.strength_titles = self.options.get('strength_titles', self.DEFAULT_STRENGTH_TITLES) + self.quests = self.options.get('quests', self.DEFAULT_QUESTS) self.load_data() self.initialize_handshakes() @@ -93,18 +104,38 @@ class Age(plugins.Plugin): return self.strength_titles[t] return "Untrained" + def random_motivational_quote(self): + quotes = [ + "Keep going, you're crushing it!", + "You're a WiFi wizard in the making!", + "More handshakes, more power!", + "Don't stop now, you're almost there!", + "Keep evolving, don't let decay catch you!" + ] + return random.choice(quotes) + + def random_inactivity_message(self): + messages = [ + "Time to wake up, you're rusting!", + "Decayed by {points_lost}, keep it active!", + "Stale, but you can still revive!", + "Don't let inactivity hold you back!", + "Keep moving, no room for decay!" + ] + return random.choice(messages) + def check_achievements(self, agent): current_age = self.get_age_title() current_strength = self.get_strength_title() if current_age != self.prev_age_title: agent.view().set('face', faces.HAPPY) - agent.view().set('status', f"Promoted to {current_age}!") + agent.view().set('status', f"🎉 {current_age} Achieved! {self.random_motivational_quote()}") self.prev_age_title = current_age if current_strength != self.prev_strength_title: agent.view().set('face', faces.MOTIVATED) - agent.view().set('status', f"Evolved to {current_strength}!") + agent.view().set('status', f"💪 Evolved to {current_strength}!") self.prev_strength_title = current_strength def apply_decay(self, agent): @@ -116,7 +147,7 @@ class Age(plugins.Plugin): if points_lost > 0: agent.view().set('face', faces.SAD) - agent.view().set('status', f"Inactivity decay: -{points_lost} points!") + agent.view().set('status', self.random_inactivity_message().format(points_lost=points_lost)) self.last_active_epoch = self.epochs self.save_data() @@ -142,7 +173,8 @@ class Age(plugins.Plugin): 'age': get_position('age'), 'strength': get_position('strength'), 'points': get_position('points'), - 'stars': get_position('stars') + 'stars': get_position('stars'), + 'quests': get_position('quests') } ui.add_element('Age', LabeledValue( @@ -161,13 +193,36 @@ class Age(plugins.Plugin): color=BLACK, label='ReP', value="★", position=positions['stars'], label_font=fonts.Bold, text_font=fonts.Medium)) + ui.add_element('Quests', LabeledValue( + color=BLACK, label='Quests', value="None completed", + position=positions['quests'], label_font=fonts.Bold, text_font=fonts.Medium)) + def on_ui_update(self, ui): ui.set('Age', self.get_age_title()) ui.set('Strength', self.get_strength_title()) ui.set('Points', self.abrev_number(self.network_points)) ui.set('ReP', self.get_star_string()) - # Modified Event Handlers + # Update quests status + quest_status = self.check_quests() + ui.set('Quests', quest_status) + + def check_quests(self): + progress = [] + for quest in self.quests: + if quest['name'] not in self.completed_quests: + progress.append(f"{quest['name']} ({self.get_quest_progress(quest)}% complete)") + else: + progress.append(f"✓ {quest['name']} - {quest['reward']}") + return "\n".join(progress) + + def get_quest_progress(self, quest): + if quest['name'] == "Collect 10 WPA3 handshakes": + return min(100, (self.handshake_count // quest['goal']) * 100) + elif quest['name'] == "Survive 100 epochs without decaying": + return min(100, (self.epochs // quest['goal']) * 100) + return 0 + def on_epoch(self, agent, epoch, epoch_data): self.epochs += 1 self.train_epochs += 1 if self.epochs % 10 == 0 else 0 @@ -207,7 +262,6 @@ class Age(plugins.Plugin): self.new_star_checkpoint(agent) self.save_data() - # Star System def new_star_checkpoint(self, agent): stars = self.get_stars_count() if stars > self.prev_stars: @@ -218,7 +272,7 @@ class Age(plugins.Plugin): # Data Management def load_data(self): - try: # <- Added indentation here + try: if os.path.exists(self.data_path): with open(self.data_path, 'r') as f: data = json.load(f) @@ -234,6 +288,7 @@ class Age(plugins.Plugin): self.prev_age_title = data.get('prev_age', self.get_age_title()) self.prev_strength_title = data.get('prev_strength', self.get_strength_title()) self.prev_stars = data.get('prev_stars', self.get_stars_count()) + self.completed_quests = set(data.get('completed_quests', [])) # Migrate old format to new format if 'epochs_lived' in data: @@ -244,24 +299,16 @@ class Age(plugins.Plugin): logging.error(f"[Age] Load error: {str(e)}") def save_data(self): - data = { # <- Added indentation here - # New format keys + data = { 'epochs': self.epochs, 'train_epochs': self.train_epochs, 'points': self.network_points, 'handshakes': self.handshake_count, - - # Old format aliases for compatibility - 'epochs_lived': self.epochs, - 'epochs_trained': self.train_epochs, - 'network_points': self.network_points, - 'handshake_count': self.handshake_count, - - # New fields 'last_active': self.last_active_epoch, 'prev_age': self.get_age_title(), 'prev_strength': self.get_strength_title(), - 'prev_stars': self.get_stars_count() + 'prev_stars': self.get_stars_count(), + 'completed_quests': list(self.completed_quests) } try: with open(self.data_path, 'w') as f: @@ -288,3 +335,4 @@ class Age(plugins.Plugin): +