-
Notifications
You must be signed in to change notification settings - Fork 3
GameInterfaces
Pantella communicates with games/programs via game interfaces. Game interfaces are Python classes that handle communication with the game/program. Each game interface must inherit from the BaseGameInterface class and implement the following methods:
The BaseGameInterface class is an abstract class that defines the methods that must be implemented by game interfaces. The BaseGameInterface class has the following methods:
-
__init__(self, conversation_manager, valid_games, interface_slug): The constructor method for the BaseGameInterface class. It initializes the game interface with the conversation manager, valid games, and interface slug. -
display_status(self): A method that displays the status string in game. -
get_current_location(self, presume=''): A method that returns the current location in game. -
new_time(self, in_game_time=None): A method that updates the in-game time. -
get_player_response(self): A method that gets the player's response from the game. -
get_text_input(self): A method that gets the text input from the player. -
update_game_events(self): A method that updates the game events in the conversation. -
game_path: A property that returns the path to the game's data folder. -
mod_path: A property that returns the path to the game's mod folder. -
mod_voice_dir: A property that returns the path to the game's voice folder. -
get_audio_duration(self, audio_file): A method that gets the duration of an audio file. -
send_audio_to_external_software(self, queue_output): A method that sends audio to the game/program. -
send_response(self, sentence_queue, event): A method that sends the response to the game/program. -
is_conversation_ended(self): A method that checks if the conversation has ended and returns a boolean value. -
is_radiant_dialogue(self): A method that checks if the current dialogue is a radiant dialogue and returns a boolean value. -
get_current_context_string(self): A method that returns the current context string set by the player. -
get_current_game_time(self): A method that returns the current in-game time. -
queue_actor_method(self, actor_character, method_name, *args): A method that queues an arbitrary method to be run on the actor in game via the game interface. -
end_conversation(self): A method that ends the conversation in game. -
remove_from_conversation(self, character): A method that removes a character from the conversation in game. -
load_game_state(self): A method that loads the game state.
The constructor method for the BaseGameInterface class. It initializes the game interface with the conversation manager, valid games, and interface slug. The conversation_manager parameter is an instance of the ConversationManager class. The valid_games parameter is a list of valid games that the game interface can communicate with. The interface_slug parameter is a string that represents the game interface.
A method that displays the status string in game. This method should be implemented by the game interface.
A method that returns the current location in game. This method should be implemented by the game interface.
A method that updates the in-game time. This method should be implemented by the game interface.
A method that gets the player's response from the game. This method should be implemented by the game interface.
A method that gets the text input from the player. This method should be implemented by the game interface.
A method that updates the game events in the conversation. This method should be implemented by the game interface.
A property that returns the path to the game's data folder. This property should be implemented by the game interface.
A property that returns the path to the game's mod folder. This property should be implemented by the game interface.
A property that returns the path to the game's voice folder. This property should be implemented by the game interface.
A method that gets the duration of an audio file. This method should be implemented by the game interface.
A method that sends audio to the game/program. This method should be implemented by the game interface.
A method that sends the response to the game/program. This method should be implemented by the game interface.
A method that checks if the conversation has ended and returns a boolean value. This method should be implemented by the game interface.
A method that checks if the current dialogue is a radiant dialogue and returns a boolean value. This method should be implemented by the game interface.
A method that returns the current context string set by the player. This method should be implemented by the game interface.
A method that returns the current in-game time. This method should be implemented by the game interface.
A method that queues an arbitrary method to be run on the actor in game via the game interface. This method should be implemented by the game interface.
A method that ends the conversation in game. This method should be implemented by the game interface.
A method that removes a character from the conversation in game. This method should be implemented by the game interface.
A method that loads the game state. This method should be implemented by the game interface.
print("Importing game_interfaces/example.py")
from src.logging import logging, time
from src.game_interfaces.base_interface import BaseGameInterface
import src.utils as utils
logging.info("Imported required libraries in game_interfaces/example.py")
valid_games = ["example"]
interface_slug = "example"
class GameInterface(BaseGameInterface):
def __init__(self, conversation_manager, valid_games=valid_games, interface_slug=interface_slug):
super().__init__(conversation_manager, valid_games, interface_slug)
def display_status(self):
"""Display the status string in game"""
logging.info("Implement: Display status in game")
def get_current_location(self, presume = ''):
"""Return the current location"""
logging.info("Implement: Get current location")
return presume
def new_time(self, in_game_time=None):
"""Update the in-game time"""
logging.info("Implement: Update in-game time")
def get_player_response(self):
"""Get the player's response from the game"""
logging.info("Implement: Get player response")
return ""
def get_text_input(self):
"""Get the text input from the player"""
logging.info("Implement: Get text input")
return ""
def update_game_events(self):
"""Update the game events in the conversation"""
logging.info("Implement: Update game events")
@property
def game_path(self):
"""Return the path to the game's data folder"""
logging.info("Implement: Return game path")
return ""
@property
def mod_path(self):
"""Return the path to the game's mod folder"""
logging.info("Implement: Return mod path")
return ""
@property
def mod_voice_dir(self):
"""Return the path to the game's voice folder"""
logging.info("Implement: Return mod voice directory")
return ""
def get_audio_duration(self, audio_file):
"""Get the duration of an audio file"""
logging.info("Implement: Get audio duration")
return 0
def send_audio_to_external_software(self, queue_output):
"""Send audio to the game/program"""
logging.info("Implement: Send audio to external software")
def send_response(self, sentence_queue, event):
"""Send the response to the game/program"""
logging.info("Implement: Send response to game/program")
def is_conversation_ended(self):
"""Check if the conversation has ended"""
logging.info("Implement: Check if conversation has ended")
return False
def is_radiant_dialogue(self):
"""Check if the current dialogue is a radiant dialogue"""
logging.info("Implement: Check if radiant dialogue")
return False
def get_current_context_string(self):
"""Return the current context string set by the player"""
logging.info("Implement: Get current context string")
return ""
def get_current_game_time(self):
"""Return the current in-game time"""
logging.info("Implement: Get current in-game time")
return {}
def queue_actor_method(self, actor_character, method_name, *args):
"""Queue an arbitrary method to be run on the actor in game via the game interface"""
logging.info(f"Implement: Queue actor method {method_name} with args {args} for actor {actor_character}")
def end_conversation(self):
"""End the conversation in game"""
logging.info("Implement: End conversation in game")
return True
def remove_from_conversation(self, character):
"""Remove the character from the conversation in game"""
logging.info(f'Implement: Remove {character.name} from conversation in-game without ending the whole conversation')
def load_game_state(self):
"""Load the game state"""
logging.info("Implement: Load game state")
return None