Skip to content
TheChatArchiveThe Chat Archive
gpt-4-0314· openaiHugging Face Suzhen/CodeChat

I want to program a submission move for a text-based fighting game. The move has a…

  1. User

    I want to program a submission move for a text-based fighting game. The move has a success chance, an escape chance and damage per round. The success chance calculates whether the attacker manages to lock the opponent in the submission. The escape chance calculates whether the victim manages to escape the hold. The escape chance is rolled once per round. During the first application of the hold and every round following, the move does damage per round until the victim successfully escapes.

  2. Assistant

    Here's a basic example of how you might implement this submission move in a text-based fighting game using Python:

    import random
    
    class Fighter:
        def __init__(self, name, health):
            self.name = name
            self.health = health
    
    class SubmissionMove:
        def __init__(self, name, success_chance, escape_chance, damage_per_round):
            self.name = name
            self.success_chance = success_chance
            self.escape_chance = escape_chance
            self.damage_per_round = damage_per_round
    
    def is_successful(chance):
        return random.random() < chance
    
    def apply_submission(fighter1, fighter2, move):
        if is_successful(move.success_chance):
            print(f"{fighter1.name} locks in the {move.name} on {fighter2.name}!")
            rounds = 0
            while not is_successful(move.escape_chance):
                rounds += 1
                print(f"{fighter2.name} can't escape from the {move.name}!")
                fighter2.health -= move.damage_per_round
                if fighter2.health <= 0:
                    print(f"{fighter2.name} has been submitted by {fighter1.name}!")
                    break
            else:
                print(f"{fighter2.name} finally escapes the {move.name} after {rounds} rounds!")
        else:
            print(f"{fighter1.name} failed to lock in the {move.name}.")
    
    # Example Usage
    fighter1 = Fighter("Fighter 1", 100)
    fighter2 = Fighter("Fighter 2", 100)
    
    submission_move = SubmissionMove("Armbar", 0.7, 0.3, 5)
    
    apply_submission(fighter1, fighter2, submission_move)
    

    This code defines a Fighter class to represent the game's fighters and a SubmissionMove class to represent our submission move. It also defines a function apply_submission, which takes care of executing the submission move and its effects in the game.

    The example usage at the bottom creates two fighters, a submission move (in this case, the "Armbar"), and then applies the submission. The output will show the progress of the submission attempt and whether the fighters locked in the move, escaped, or submitted.

    You might need to adapt this code to fit your specific game engine and requirements, but this should give you a good starting point for implementing submission moves in your text-based fighting game.

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.