Add Two More Two-Player Games
Prompt
You are given an existing HTML/CSS/JavaScript codebase that implements a webpage with two-player games: Tic Tac Toe, Connect Four, Rock Paper Scissors, and Guess the Number. Your task is to add two more two-player games to this webpage, integrating them fully in the same style and functionality. Requirements: 1. Add two additional two-player games to the webpage. Each new game must have its own HTML container section similar to existing games. 2. Each game section should have a heading, a player type selection (human vs human or human vs AI), the game interface, instructions, and buttons to Reset the game and return Home. 3. Implement the full game logic for both new games, including UI interactions and AI player if applicable. 4. Update the homepage buttons so the new games can be selected and shown properly, hiding other sections. 5. Follow the existing interface styling and consistent UX patterns. 6. Ensure all scripts for the new games are included and connected so the games work seamlessly with toggling light/dark mode, reset, and home navigation. 7. Provide comments inside your new code parts to explain logic clearly. Steps: - Inside the <body>, add two new buttons for the new games alongside the existing game selection buttons. - Add two new <div> containers with class "game-container" for the new games, each having a title, a <select> to choose human or AI opponent, the game UI elements, instructions, and Reset/Home buttons. - In the <script> section, implement the full game logic for both games including initializing, gameplay mechanics, AI moves (simple random strategies are acceptable), check for wins/draws, and resetting. - Update the selectGame(game) function to handle the two new games so only their containers show when selected and initialize their states properly. - Add any necessary CSS classes consistent with existing styles for your new games. Output Format: Provide the entire updated HTML code including CSS and JavaScript with the two new games fully integrated as described. Keep the original structure and styling intact, extending it only to add the two new games. You may choose any two classic two-player games (e.g., Checkers, Battleship, Nim, or similar) ensuring that the gameplay logic is implementable with straightforward JavaScript in this webpage context.
Related Coding Prompts
Write Code
As a seasoned programmer, your task is to write code in [programming language] to [perform action]. The code should be efficient, well-structured, and optimized for performance. Make sure to follow best practices and industry standards while implementing the necessary algorithms and logic to achieve the desired functionality. Test the code thoroughly to ensure it functions as intended and meets all requirements. Additionally, document the code properly for future reference and maintenance.
Debug Code
Act as a seasoned programmer with over 20 years of commercial experience. Analyze the provided [piece of code] that is causing a specific [error]. Your task involves diagnosing the root cause of the error, understanding the context and functionality intended by the code, and proposing a solution to fix the issue. Your analysis should include a step-by-step walkthrough of the code, identification of any bugs or logical mistakes, and a detailed explanation of how to resolve them. Additionally, suggest any improvements or optimizations to enhance the performance, readability, or maintainability of the code based on your extensive experience. Ensure that your solution adheres to best practices in software development and is compatible with the current development environment where the code is being executed.
Do Code Review
As a seasoned programmer with over 20 years of commercial experience, your task is to perform a comprehensive code review on the provided [piece of code]. Your review should meticulously evaluate the code's efficiency, readability, and maintainability. You are expected to identify any potential bugs, security vulnerabilities, or performance issues and suggest specific improvements or optimizations. Additionally, assess the code's adherence to industry standards and best practices. Your feedback should be constructive and detailed, offering clear explanations and recommendations for changes. Where applicable, provide examples or references to support your suggestions. Your goal is to ensure that the code not only functions as intended but also meets high standards of quality and can be easily managed and scaled in the future. This review is an opportunity to mentor and guide less experienced developers, so your insights should be both educational and actionable.