lantern

Goose Pong Jr

import random

# Generate goose names
first_names = ['Honky', 'Waddles', 'Sir Hiss', 'Baron von', 'Captain', 'Professor', 'Lady', 'Duke', 'Sergeant', 'Count']
last_names = ['McHonkface', 'Featherbottom', 'Pondsworth', 'Quackington', 'Wingsworth', 'Downy', 'Beakman', 'Webfoot', 'Goosington', 'Fluffington']

goose_left = f"{random.choice(first_names)} {random.choice(last_names)}"
goose_right = f"{random.choice(first_names)} {random.choice(last_names)}"
playing_to = random.randint(1, 3)

# Reset game state
new_state = {
    'goose_left': goose_left,
    'goose_right': goose_right,
    'score_left': 0,
    'score_right': 0,
    'playing_to': playing_to,
    'current_turn': 'left',
    'game_active': True,
    'winner': 'none'
}
poke('goose-pong:game-state.yaml', new_state)

# Reset the board - clear any ball, restore cups
for row in range(3):
    for col in range(6):
        if row == 1 and col == 0:
            cell = '🄤'
        elif row == 1 and col == 5:
            cell = '🄤'
        else:
            cell = '🟩'
        execute('goose-pong:the-arena[0]', action='poke_cell', params={'row': row, 'col': col, 'value': cell})

result = {
    'message': f"šŸŽ® NEW GAME! Playing to {playing_to} šŸž",
    'left_goose': f"🪿 {goose_left}",
    'right_goose': f"🪿 {goose_right}",
    'first_turn': goose_left
}
import random

# Load game state
state = peek('goose-pong:game-state.yaml')
if not state or not state.get('game_active'):
    result = {'error': '🚫 No active game! Run new-game first.'}
else:
    # Check for existing winner
    if state.get('winner') != 'none':
        result = {'message': f"šŸ† Game over! {state['winner']} already won!"}
    else:
        # Determine current goose
        turn = state['current_turn']
        goose_name = state['goose_left'] if turn == 'left' else state['goose_right']
        
        # Clear the board (same approach as new-game - just reset everything)
        for row in range(3):
            for col in range(6):
                if row == 1 and col == 0:
                    cell = '🄤'  # Left cup
                elif row == 1 and col == 5:
                    cell = '🄤'  # Right cup
                else:
                    cell = '🟩'  # Grass
                execute('goose-pong:the-arena[0]', action='poke_cell', params={'row': row, 'col': col, 'value': cell})
        
        # Roll the ball! Random row (0-2), column based on whose turn
        ball_row = random.randint(0, 2)
        if turn == 'left':
            # Left goose shoots at right half (columns 3-5)
            ball_col = random.randint(3, 5)
            target_cup = (1, 5)  # Right cup
        else:
            # Right goose shoots at left half (columns 0-2)
            ball_col = random.randint(0, 2)
            target_cup = (1, 0)  # Left cup
        
        # Place the ball
        execute('goose-pong:the-arena[0]', action='poke_cell', params={'row': ball_row, 'col': ball_col, 'value': '🪩'})
        
        # Check for score
        scored = (ball_row, ball_col) == target_cup
        message = f"🪿 {goose_name} honks and launches!"
        message += f"\n🪩 Ball lands at ({ball_row}, {ball_col})..."
        
        if scored:
            message += f"\nšŸŽ‰ SPLASH! {goose_name} scores! šŸž"
            if turn == 'left':
                state['score_left'] += 1
                score = state['score_left']
            else:
                state['score_right'] += 1
                score = state['score_right']
            
            # Check for winner
            if score >= state['playing_to']:
                state['winner'] = goose_name
                state['game_active'] = False
                message += f"\n\nšŸ†šŸ†šŸ† {goose_name} WINS THE GAME! šŸ†šŸ†šŸ†"
        else:
            message += "\n😤 Miss! Ball bounces on grass."
        
        # Switch turns
        state['current_turn'] = 'right' if turn == 'left' else 'left'
        next_goose = state['goose_left'] if state['current_turn'] == 'left' else state['goose_right']
        
        # Save updated state
        poke('goose-pong:game-state.yaml', state)
        
        result = {
            'message': message,
            'score': f"{state['goose_left']}: {state['score_left']} šŸž | {state['goose_right']}: {state['score_right']} šŸž",
            'playing_to': f"First to {state['playing_to']} šŸž",
            'next_turn': next_goose if state['game_active'] else 'GAME OVER',
            'winner': state['winner'] if state['winner'] != 'none' else None
        }

Provenance

Document

  • Status: šŸ”“ Unverified