Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement cannon-loading sequence #6

Open
cliftonburt opened this issue Nov 12, 2024 · 0 comments
Open

Implement cannon-loading sequence #6

cliftonburt opened this issue Nov 12, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@cliftonburt
Copy link
Owner

cliftonburt commented Nov 12, 2024

The goal is to implement a command sequence that initiates the cannon-loading process when the captain says "load guns." This sequence involves displaying loading bars for each step of the loading process, with each step’s time measured against an ideal target time. When the total time reaches 90 seconds, the sequence completes, and the “fire” command can be triggered.


Details for Implementation:

  1. Trigger:

    • When the captain issues the "load guns" command, initiate the cannon-loading sequence.
  2. Sequence Steps:

    • Implement the following steps in the cannon-loading process, each with a target duration:
      • Swab the barrel (5-10 seconds)
      • Load the powder charge (10-15 seconds)
      • Ram the powder charge (5-10 seconds)
      • Load the cannonball (shot) (5-10 seconds)
      • Ram the cannonball (5-10 seconds)
      • Prick and prime the cannon (5-10 seconds)
      • Run out the gun (15-20 seconds)
      • Aiming adjustments (5-10 seconds)
  3. Total Time:

    • The total target time should be 90 seconds for all steps combined. Each step should display a loading bar representing its progress toward its ideal time.
    • Use random values within each step's range to simulate time variability, but keep the overall target at 90 seconds.
  4. Loading Bar Display:

    • Use loading bars to represent each step’s completion. The loading bar should fill up as time elapses, updating at regular intervals.
    • Each step should complete in a fraction of 90 seconds, and loading bars should visually represent the time progress of each step.
    • Display the cumulative loading time as each step completes, moving toward the 90-second total target.
  5. Completion and Fire Command:

    • When all steps are completed, display a message from the captain saying “Ready to fire!”
    • Trigger the “fire” command when the loading bars reach their 90-second target total.
  6. Code Requirements:

    • Implement each step as a separate function or part of a sequence in the “load guns” command.
    • Use Rich’s progress bar or another text-based loading bar to visually indicate each step’s completion in the terminal.

Example Code Prompt:

Here is a starting code block to guide you:

from time import sleep
from rich.progress import Progress

# Cannon loading sequence
def load_guns():
    steps = [
        ("Swab the barrel", 5, 10),
        ("Load the powder charge", 10, 15),
        ("Ram the powder charge", 5, 10),
        ("Load the cannonball (shot)", 5, 10),
        ("Ram the cannonball", 5, 10),
        ("Prick and prime the cannon", 5, 10),
        ("Run out the gun", 15, 20),
        ("Aiming adjustments", 5, 10)
    ]
    
    total_time_target = 90  # seconds
    total_time_elapsed = 0

    with Progress() as progress:
        for step, min_time, max_time in steps:
            # Determine ideal time for this step
            step_time = (min_time + max_time) / 2  # or use random.randint(min_time, max_time) for variation
            step_task = progress.add_task(f"[cyan]{step}[/cyan]", total=step_time)
            
            # Simulate loading time for the current step
            while not progress.finished:
                progress.update(step_task, advance=1)
                sleep(1)  # Adjust time as needed for testing, or speed up display
                
            # Update cumulative time
            total_time_elapsed += step_time
        
        # After all steps complete
        if total_time_elapsed >= total_time_target:
            print("[bold green]Captain:[/bold green] Ready to fire!")
@cliftonburt cliftonburt added the enhancement New feature or request label Nov 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant