Zappy - Year end project 2
This is a project that Epitech asked us to create in order to allow us to reveiw the notions of the current year.
Loading...
Searching...
No Matches
Public Member Functions | Data Fields | Protected Member Functions | Protected Attributes
convert_data.ConvertData Class Reference
Collaboration diagram for convert_data.ConvertData:
Collaboration graph

Public Member Functions

None __init__ (self, data, int error=84, int success=0)
 
int update_raw_data (self, any data)
 
int set_raw_data (self, any data)
 
dict[Commands, any] to_internal (self, str triger_command="")
 
str to_external (self)
 

Data Fields

 error
 
 success
 
 data
 
 tr
 
 enum_equivalence
 
 text_equivalence
 
 item_string_to_class
 
 item_class_to_string
 
 item_equivalence_input
 
 item_equivalence_output
 

Protected Member Functions

dict[Commands, list[list[str, int]]] _process_inventory (self, list[str] data_list)
 
dict[Commands, list[Items]] _process_look (self, list[str] data)
 
dict[Commands, any] _special_list_treatment (self, Commands previous_command)
 
Commands _get_launch_command (self, str triger_command)
 
list[list[str]] _input_parse_look (self, str data)
 
list[dict[Items, int]] _input_parse_inventory (self, str data)
 
str _output_parse_inventory (self, list[dict[Items, int]] data)
 

Protected Attributes

 _input_parse_look
 

Detailed Description

_summary_
Class in charge of converting and translating the data received from the outside into commands understood by the internal program

Definition at line 15 of file convert_data.py.

Constructor & Destructor Documentation

◆ __init__()

None convert_data.ConvertData.__init__ ( self,
data,
int error = 84,
int success = 0 )

Definition at line 20 of file convert_data.py.

Member Function Documentation

◆ _get_launch_command()

Commands convert_data.ConvertData._get_launch_command ( self,
str triger_command )
protected
_summary_
    This is a function that will extract the command that was used to get the response.
Args:
    triger_command (str): _description_: The command

Returns:
    Commands: _description_: The corresponding command but using the internal command tracking.

Definition at line 147 of file convert_data.py.

◆ _input_parse_inventory()

list[dict[Items, int]] convert_data.ConvertData._input_parse_inventory ( self,
str data )
protected
_summary_

Input data:
    "[linemate n, sibur n, ...]"
    ex: "[linemate 20 sibur 10, ...]"
Look, command format (output):
    {Command.INVENTORY:[{Items.LINEMATE: 20}, {Items.SIBUR, 10}, ...]}

Args:
    data (str): _description_: The arguments provided alongside the command

Returns:
    list[dict[Items, int | str]]: _description_: The Internal process data

Definition at line 224 of file convert_data.py.

◆ _input_parse_look()

list[list[str]] convert_data.ConvertData._input_parse_look ( self,
str data )
protected
_summary_

Input data:
    "[tile1, tile2, ...]"
    ex: "[player remedy, ...]"
Look, command format (output):
    {Command.look:[["player", "food", "Linemate", "deraumere", "sibur", "mendiane", "phiras", "thystame"], ...  ]}
                    tile 1                                                                                tile n
Args:
    data (str): _description_: The arguments provided alongside the command

Returns:
    list[list[str]]: _description_: The Internal process data

Definition at line 192 of file convert_data.py.

◆ _output_parse_inventory()

str convert_data.ConvertData._output_parse_inventory ( self,
list[dict[Items, int]] data )
protected
_summary_

Input data:
    {Command.INVENTORY:[{Items.LINEMATE: 20}, {Items.SIBUR, 10}, ...]}
Look, command format (output):
    "[linemate n, sibur n, ...]"
    ex: "[linemate 20 sibur 10, ...]"

Args:
    data (str): _description_: The arguments provided alongside the command

Returns:
    list[dict[Items, int]]: _description_: The Internal process data

Definition at line 269 of file convert_data.py.

◆ _process_inventory()

dict[Commands, list[list[str, int]]] convert_data.ConvertData._process_inventory ( self,
list[str] data_list )
protected
_summary_
    This function is to be used to process the inventory list.
Args:
    data_list (list[str]): _description_: The raw list

Returns:
    dict[Commands, list[str]]: _description_: The converted version

Definition at line 74 of file convert_data.py.

◆ _process_look()

dict[Commands, list[Items]] convert_data.ConvertData._process_look ( self,
list[str] data )
protected
_summary_
This function is in charge of converting the input to a list of items.

Args:
    data (list[str]): _description_: The semi processed list based of the input

Returns:
    dict[Commands, list[Items or str]]: _description_: The final converted version of the input

Definition at line 92 of file convert_data.py.

◆ _special_list_treatment()

dict[Commands, any] convert_data.ConvertData._special_list_treatment ( self,
Commands previous_command )
protected
_summary_
Function in charge of the converting a list input to the correct response command.

Returns:
    dict[Commands, any]: _description_: The converted list

Definition at line 120 of file convert_data.py.

◆ set_raw_data()

int convert_data.ConvertData.set_raw_data ( self,
any data )
_summary_

Args:
    data (any): _description_: The type of data is meant to be of type dict or string or a set of byte string.
    Other formats will return an error.
    If the content is empty, an error is returned.

Returns:
    int: _description_: success if it succeeded to update the raw data, error if it failed to update the raw data.

Definition at line 61 of file convert_data.py.

◆ to_external()

str convert_data.ConvertData.to_external ( self)
_summary_
Convert the internal data to the external language used by the over programs

Returns:
    str: _description_: a string containing the command for the other programs

Definition at line 294 of file convert_data.py.

◆ to_internal()

dict[Commands, any] convert_data.ConvertData.to_internal ( self,
str triger_command = "" )
_summary_
Convert the raw data to the internal language used by the ai

Returns:
    dict[Commands, any]: _description_: the format of a node of data comming back

Definition at line 170 of file convert_data.py.

◆ update_raw_data()

int convert_data.ConvertData.update_raw_data ( self,
any data )
_summary_

Args:
    data (any): _description_: The type of data is meant to be of type dict or string or a set of byte string.
    Other formats will return an error.
    If the content is empty, an error is returned.

Returns:
    int: _description_: success if it succeeded to update the raw data, error if it failed to update the raw data.

Definition at line 41 of file convert_data.py.

Field Documentation

◆ _input_parse_look

convert_data.ConvertData._input_parse_look
protected

Definition at line 33 of file convert_data.py.

◆ data

convert_data.ConvertData.data

Definition at line 23 of file convert_data.py.

◆ enum_equivalence

convert_data.ConvertData.enum_equivalence

Definition at line 27 of file convert_data.py.

◆ error

convert_data.ConvertData.error

Definition at line 21 of file convert_data.py.

◆ item_class_to_string

convert_data.ConvertData.item_class_to_string

Definition at line 30 of file convert_data.py.

◆ item_equivalence_input

convert_data.ConvertData.item_equivalence_input

Definition at line 32 of file convert_data.py.

◆ item_equivalence_output

convert_data.ConvertData.item_equivalence_output

Definition at line 37 of file convert_data.py.

◆ item_string_to_class

convert_data.ConvertData.item_string_to_class

Definition at line 29 of file convert_data.py.

◆ success

convert_data.ConvertData.success

Definition at line 22 of file convert_data.py.

◆ text_equivalence

convert_data.ConvertData.text_equivalence

Definition at line 28 of file convert_data.py.

◆ tr

convert_data.ConvertData.tr

Definition at line 26 of file convert_data.py.


The documentation for this class was generated from the following file: