/[ambar]/ambar/idioma.py
ViewVC logotype

Diff of /ambar/idioma.py

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 2.1 by amoyav, Thu Aug 29 13:16:28 2002 UTC revision 2.2 by pabloruiz, Tue Nov 5 22:58:22 2002 UTC
# Line 1  Line 1 
1  #!/usr/bin/env python  #!/usr/bin/env python
2  #  #
3  #Minë. Mundo Interactivo-Narrativo en Español [Tierra-Media]  #Minë. Mundo Interactivo-Narrativo en Español [Tierra-Media]
4  #Copyright (C) 2002  Pablo Ruiz Múzquiz  #Copyright (C) 2002  Pablo Ruiz Múzquiz
5  #  #
6  #  #
7  #This program is free software; you can redistribute it and/or modify  #This program is free software; you can redistribute it and/or modify
8  #it under the terms of the GNU General Public License as published by  #it under the terms of the GNU General Public License as published by
9  #the Free Software Foundation; either version 2 of the License, or  #the Free Software Foundation; either version 2 of the License, or
10  #(at your option) any later version.  #(at your option) any later version.
11  #  #
12  #This program is distributed in the hope that it will be useful,  #This program is distributed in the hope that it will be useful,
13  #but WITHOUT ANY WARRANTY; without even the implied warranty of  #but WITHOUT ANY WARRANTY; without even the implied warranty of
14  #MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the  #MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  #GNU General Public License for more details.  #GNU General Public License for more details.
16  #  #
17  #You should have received a copy of the GNU General Public License  #You should have received a copy of the GNU General Public License
18  #along with this program; if not, write to the Free Software  #along with this program; if not, write to the Free Software
19  #Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA  #Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20  #  #
21  #  #
22  #Fichero: idioma.py  #Fichero: idioma.py
23    
24  """Clase Idioma."""  """Clase Idioma."""
25    
26    
27  class Idioma:  class Idioma:
28      """Información sobre los idiomas que conocen los personajes.      """Información sobre los idiomas que conocen los personajes.
29            
30      Un idioma se caracteriza por:      Un idioma se caracteriza por:
31          - nombre (string): identificador del idioma          - nombre (string): identificador del idioma
32          - lista_letras (int[]): lista de codigos ASCII de las letras que sustituyen al texto          - lista_letras (int[]): lista de codigos ASCII de las letras que sustituyen al texto
33                                  de los mensajes cuando se filtran para alguien que no conoce                                  de los mensajes cuando se filtran para alguien que no conoce
34                                  el idioma.                                  el idioma.
35      """      """
36      def __init__(self, nombre, lista_letras):      def __init__(self, nombre, lista_letras):
37          self.nombre = nombre          self.nombre = nombre
38          self.lista_letras = lista_letras          self.lista_letras = lista_letras
39    
40    
41  #%%    def __repr__(self):  #%%    def __repr__(self):
42  #%%     return self.nombre  #%%     return self.nombre
43    
44    
45  #%%    def __str__(self):  #%%    def __str__(self):
46  #%%     return self.nombre  #%%     return self.nombre
47    
48            
49  # Lista de todos los idiomas definidos  # Lista de todos los idiomas definidos
50  Idioma_lista = [ Idioma("oestron", range(97, 122)),              # todas las letras del alfabeto  Idioma_lista = [ Idioma("oestron", range(97, 122)),              # todas las letras del alfabeto
51    
52                   Idioma("enano", [106,107,114,97,117,122]),      # letras guturales                   Idioma("enano", [106,107,114,97,117,122]),      # letras guturales
53    
54                   Idioma("quenya", [108,108,108,115,115,115,108,  # letras l, m, s y vocales                   Idioma("quenya", [108,108,108,115,115,115,108,  # letras l, m, s y vocales
55                                     97,97,97,97,97,101,101,101,105,108,111,108,108,   # sobre todo                                     97,97,97,97,97,101,101,101,105,108,111,108,108,   # sobre todo
56                                     108,108,117,109,109,110,110]),                                     108,108,117,109,109,110,110]),
57    
58                   Idioma("orco", [106,116,116,120,103,107,114,    # letras guturales                   Idioma("orco", [106,116,116,120,103,107,114,    # letras guturales
59                                   97,117,122])                                   97,117,122])
60                  ]                  ]
61    
62    
63  def Idioma_buscar(nombre):  def Idioma_buscar(nombre):
64      """Obtiene un idioma a partir de su nombre."""      """Obtiene un idioma a partir de su nombre."""
65      for idioma in Idioma_lista:      for idioma in Idioma_lista:
66          if idioma.nombre == nombre:          if idioma.nombre == nombre:
67              return idioma              return idioma
68      return None      return None
69    
70    
71  # Constantes para acceder a los idiomas de forma fija desde dentro del código  # Constantes para acceder a los idiomas de forma fija desde dentro del código
72  Idioma_oestron = Idioma_buscar("oestron")  Idioma_oestron = Idioma_buscar("oestron")
73  Idioma_enano = Idioma_buscar("enano")  Idioma_enano = Idioma_buscar("enano")
74  Idioma_quenya = Idioma_buscar("quenya")  Idioma_quenya = Idioma_buscar("quenya")
75  Idioma_orco = Idioma_buscar("orco")  Idioma_orco = Idioma_buscar("orco")
76    
77    
78  # Código para pruebas unitarias del módulo.  # Código para pruebas unitarias del módulo.
79    
80  if (__name__ == '__main__'):  if (__name__ == '__main__'):
81      print Idioma_oestron, Idioma_oestron.lista_letras      print Idioma_oestron, Idioma_oestron.lista_letras
82      print Idioma_enano, Idioma_enano.lista_letras      print Idioma_enano, Idioma_enano.lista_letras
83      print Idioma_quenya, Idioma_quenya.lista_letras      print Idioma_quenya, Idioma_quenya.lista_letras
84      print Idioma_orco, Idioma_orco.lista_letras      print Idioma_orco, Idioma_orco.lista_letras

Legend:
Removed from v.2.1  
changed lines
  Added in v.2.2

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26