<commit_before># -*-coding:Utf-8 -*

# Copyright (c) 2010 <NAME>
# All rights reserved.
# 
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# 
# * Redistributions of source code must retain the above copyright notice, this
#   list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright notice,
#   this list of conditions and the following disclaimer in the documentation
#   and/or other materials provided with the distribution.
# * Neither the name of the copyright holder nor the names of its contributors
#   may be used to endorse or promote products derived from this software
#   without specific prior written permission.
# 
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
# OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.


"""Fichier contenant le module primaire perso."""

from collections import namedtuple

from abstraits.module import *
from primaires.format.fonctions import supprimer_accents

from . import commandes
from . import masques
from .editeurs.skedit import EdtSkedit
from .editeurs.raedit import EdtRaedit
from .cfg_stats import cfg_stats
from .cfg_niveaux import cfg_niveaux
from .cfg_talents import cfg_talents
from .race import Race
from .stats import *
from .squelette import Squelette
from .niveaux import Niveaux
from .templates.niveau import Niveau
from .templates.talent import Talent
from .templates.etat import Etat
from .templates.position import Position

class Module(BaseModule):
    
    """Module gérant la classe Personnage qui sera héritée pour construire
    des joueurs et PNJs. Les mécanismes propres au personnage (c'est-à-dire
    indépendants de la connexion et liés à l'univers) seront gérés ici.
    
    En revanche, les contextes de connexion ou de création d'un personnage
    ne se trouvent pas ici (il s'agit d'informations propres à un joueur, non
    à un PNJ).
    
    """
    
    def __init__(self, importeur):
        """Constructeur du module"""
        BaseModule.__init__(self, importeur, "perso", "primaire")
        self.cfg_stats = None
        self.cfg_niveaux = None
        self.cfg_talents = None
        self.modele_stats = None
        self.commandes = []
        self.squelettes = {}
        self.races = []
        self.gen_niveaux = None
        self.niveaux = {}
        self.talents = {}
        self.etats = {}
        self.positions = {}
    
    def config(self):
        """Méthode de configuration.
        
        On récupère les fichiers de configuration correspondant au module.
        
        """
        self.cfg_stats = conf_stats = type(self.importeur).anaconf.get_config(
                "stats", "perso/stats.cfg", "modele stats", cfg_stats)
        conf_stats._set_globales({
            "I0":I0,
            "IE0":IE0,
            "SM":SM,
            "SEM":SEM,
        })
        
        self.modele_stats = Stats()
        
        self.cfg_niveaux = type(self.importeur).anaconf.get_config(
                "niveaux", "perso/niveaux.cfg", "modele niveaux", cfg_niveaux)
        
        self.cfg_talents = type(self.importeur).anaconf.get_config(
                "talents", "perso/talents.cfg", "modele talents", cfg_talents)
        
        self.ajouter_niveau("art_pisteur", "art du pisteur")
        
        BaseModule.config(self)
    
    def init(self):
        """Initialisation du module"""
        # On construit le niveau
        niveaux = Niveaux
        niveaux.nb_niveaux = self.cfg_niveaux.nb_niveaux
        niveaux.xp_min = self.cfg_niveaux.xp_min
        niveaux.xp_max = self.cfg_niveaux.xp_max
        niveaux.points_entrainement_fixes = \
                self.cfg_niveaux.points_entrainement_fixes
        niveaux.points_entrainement_paliers = \
                self.cfg_niveaux.points_entrainement_paliers
        niveaux.stats_entrainables = self.cfg_stats.entrainables
        niveaux.calculer_grille()
        self.gen_niveaux = niveaux
        
        # On récupère les squelettes
        squelettes = self.importeur.supenr.charger_groupe(Squelette)
        for squelette in squelettes:
            self.ajouter_squelette(squelette)
        
        # On récupère les races
        races = self.importeur.supenr.charger_groupe(Race)
        for race in races:
            self.ajouter_race(race)
        
        # Positions
        self.ajouter_position("assis", "est assis", "est assise")
        self.ajouter_position("allonge", "est allongé", "est allongée")
        
        # Ajout des états (assis et allongé)
        assis = self.ajouter_etat("assis")
        assis.msg_refus = "Vous êtes assis."
        assis.msg_visible = "est assis là"
        assis.act_autorisees = ["regarder", "poser", "parler", "ingerer",
                "lancersort", "lever"]
        allonge = self.ajouter_etat("allonge")
        allonge.msg_refus = "Vous êtes allongé."
        allonge.msg_visible = "est allongé là"
        allonge.act_autorisees = ["regarder", "parler", "ingerer", "lever"]
        
        mort = self.ajouter_etat("mort")
        mort.msg_refus = "Vous êtes inconscient."
        mort.msg_visible = "est inconscient ici"
        
        entraine = self.ajouter_etat("entrainer")
        entraine.msg_refus = "Vous êtes ent train de vous entraîner."
        entraine.msg_visible = "s'entraîne ici"
        entraine.act_autorisees = ["regarder", "parler"]
        
        self.ajouter_talent("escalade", "escalade", "survie", 0.25)
        self.ajouter_talent("nage", "nage", "survie", 0.25)
        
        BaseModule.init(self)
    
    def ajouter_commandes(self):
        """Ajout des commandes dans l'interpréteur"""
        self.commandes = [
            commandes.allonger.CmdAllonger(),
            commandes.asseoir.CmdAsseoir(),
            commandes.commande.CmdCommande(),
            commandes.equipement.CmdEquipement(),
            commandes.lever.CmdLever(),
            commandes.niveaux.CmdNiveaux(),
            commandes.prompt.CmdPrompt(),
            commandes.quete.CmdQuete(),
            commandes.qui.CmdQui(),
            commandes.raedit.CmdRaedit(),
            commandes.score.CmdScore(),
            commandes.skedit.CmdSkedit(),
            commandes.sklist.CmdSklist(),
            commandes.talents.CmdTalents(),
        ]
        
        for cmd in self.commandes:
            self.importeur.interpreteur.ajouter_commande(cmd)<commit_msg>Correction d'une faute dans l'entraînement de statistiques<commit_after># -*-coding:Utf-8 -*

# Copyright (c) 2010 <NAME>
# All rights reserved.
# 
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# 
# * Redistributions of source code must retain the above copyright notice, this
#   list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright notice,
#   this list of conditions and the following disclaimer in the documentation
#   and/or other materials provided with the distribution.
# * Neither the name of the copyright holder nor the names of its contributors
#   may be used to endorse or promote products derived from this software
#   without specific prior written permission.
# 
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
# OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.


"""Fichier contenant le module primaire perso."""

from collections import namedtuple

from abstraits.module import *
from primaires.format.fonctions import supprimer_accents

from . import commandes
from . import masques
from .editeurs.skedit import EdtSkedit
from .editeurs.raedit import EdtRaedit
from .cfg_stats import cfg_stats
from .cfg_niveaux import cfg_niveaux
from .cfg_talents import cfg_talents
from .race import Race
from .stats import *
from .squelette import Squelette
from .niveaux import Niveaux
from .templates.niveau import Niveau
from .templates.talent import Talent
from .templates.etat import Etat
from .templates.position import Position

class Module(BaseModule):
    
    """Module gérant la classe Personnage qui sera héritée pour construire
    des joueurs et PNJs. Les mécanismes propres au personnage (c'est-à-dire
    indépendants de la connexion et liés à l'univers) seront gérés ici.
    
    En revanche, les contextes de connexion ou de création d'un personnage
    ne se trouvent pas ici (il s'agit d'informations propres à un joueur, non
    à un PNJ).
    
    """
    
    def __init__(self, importeur):
        """Constructeur du module"""
        BaseModule.__init__(self, importeur, "perso", "primaire")
        self.cfg_stats = None
        self.cfg_niveaux = None
        self.cfg_talents = None
        self.modele_stats = None
        self.commandes = []
        self.squelettes = {}
        self.races = []
        self.gen_niveaux = None
        self.niveaux = {}
        self.talents = {}
        self.etats = {}
        self.positions = {}
    
    def config(self):
        """Méthode de configuration.
        
        On récupère les fichiers de configuration correspondant au module.
        
        """
        self.cfg_stats = conf_stats = type(self.importeur).anaconf.get_config(
                "stats", "perso/stats.cfg", "modele stats", cfg_stats)
        conf_stats._set_globales({
            "I0":I0,
            "IE0":IE0,
            "SM":SM,
            "SEM":SEM,
        })
        
        self.modele_stats = Stats()
        
        self.cfg_niveaux = type(self.importeur).anaconf.get_config(
                "niveaux", "perso/niveaux.cfg", "modele niveaux", cfg_niveaux)
        
        self.cfg_talents = type(self.importeur).anaconf.get_config(
                "talents", "perso/talents.cfg", "modele talents", cfg_talents)
        
        self.ajouter_niveau("art_pisteur", "art du pisteur")
        
        BaseModule.config(self)
    
    def init(self):
        """Initialisation du module"""
        # On construit le niveau
        niveaux = Niveaux
        niveaux.nb_niveaux = self.cfg_niveaux.nb_niveaux
        niveaux.xp_min = self.cfg_niveaux.xp_min
        niveaux.xp_max = self.cfg_niveaux.xp_max
        niveaux.points_entrainement_fixes = \
                self.cfg_niveaux.points_entrainement_fixes
        niveaux.points_entrainement_paliers = \
                self.cfg_niveaux.points_entrainement_paliers
        niveaux.stats_entrainables = self.cfg_stats.entrainables
        niveaux.calculer_grille()
        self.gen_niveaux = niveaux
        
        # On récupère les squelettes
        squelettes = self.importeur.supenr.charger_groupe(Squelette)
        for squelette in squelettes:
            self.ajouter_squelette(squelette)
        
        # On récupère les races
        races = self.importeur.supenr.charger_groupe(Race)
        for race in races:
            self.ajouter_race(race)
        
        # Positions
        self.ajouter_position("assis", "est assis", "est assise")
        self.ajouter_position("allonge", "est allongé", "est allongée")
        
        # Ajout des états (assis et allongé)
        assis = self.ajouter_etat("assis")
        assis.msg_refus = "Vous êtes assis."
        assis.msg_visible = "est assis là"
        assis.act_autorisees = ["regarder", "poser", "parler", "ingerer",
                "lancersort", "lever"]
        allonge = self.ajouter_etat("allonge")
        allonge.msg_refus = "Vous êtes allongé."
        allonge.msg_visible = "est allongé là"
        allonge.act_autorisees = ["regarder", "parler", "ingerer", "lever"]
        
        mort = self.ajouter_etat("mort")
        mort.msg_refus = "Vous êtes inconscient."
        mort.msg_visible = "est inconscient ici"
        
        entraine = self.ajouter_etat("entrainer")
        entraine.msg_refus = "Vous êtes en train de vous entraîner."
        entraine.msg_visible = "s'entraîne ici"
        entraine.act_autorisees = ["regarder", "parler"]
        
        self.ajouter_talent("escalade", "escalade", "survie", 0.25)
        self.ajouter_talent("nage", "nage", "survie", 0.25)
        
        BaseModule.init(self)
    
    def ajouter_commandes(self):
        """Ajout des commandes dans l'interpréteur"""
        self.commandes = [
            commandes.allonger.CmdAllonger(),
            commandes.asseoir.CmdAsseoir(),
            commandes.commande.CmdCommande(),
            commandes.equipement.CmdEquipement(),
            commandes.lever.CmdLever(),
            commandes.niveaux.CmdNiveaux(),
            commandes.prompt.CmdPrompt(),
            commandes.quete.CmdQuete(),
            commandes.qui.CmdQui(),
            commandes.raedit.CmdRaedit(),
            commandes.score.CmdScore(),
            commandes.skedit.CmdSkedit(),
            commandes.sklist.CmdSklist(),
            commandes.talents.CmdTalents(),
        ]
        
        for cmd in self.commandes:
            self.importeur.interpreteur.ajouter_commande(cmd)
{'fraction_non_alphanumeric': 0.08652640378988435, 'fraction_numerical': 0.002090009753378849, 'mean_word_length': 2.6058779201205726, 'pattern_counts': {'":': 8, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6517051', 'n_tokens_mistral': 4507, 'n_tokens_neox': 4319, 'n_words': 1185}