Example #1
0
def traiterCocher(clu, arguments):
    """
    permet au joueur humain de completer sa fiche en plus de ce que l'ordinateur aura automatique mis à jour
    """
    commande = arguments.split()
    if len(commande) < 4:
        return -1, "La commande cocher doit contenir la categorie et le numéro de la carte, le numéro du joueur et le type d'info\nPar exemple: 1 4 2 + pour indiquer que l'on pense que le joueur 2 possède la carte 4 de la catégorie PERSONNE"
    if commande[3] not in '+-':
        return -1, "L'indication doit être + (possède) ou - (ne possède pas)"
    if commande[0] not in str(carte.PROFESSEUR) + str(carte.MATIERE) + str(
            carte.SALLE):
        return -1, "la catégorie de carte doit être " + str(
            carte.PROFESSEUR) + " " + str(carte.MATIERE) + " " + str(
                carte.SALLE)
    if not commande[1].isdigit() or int(
            commande[1]) not in jeucarte.getListeNumCarteCategorie(
                cluedo.getJeuCartes(cluedo)):
        return -1, "les numéros de carte possibles pour cette catégorie sont " + str(
            jeucarte.getListeNumCarteCategorie(cluedo.getJeuCartes(cluedo)))
    if not commande[1].isdigit() or int(commande[1]) not in range(
            1,
            getNbJoueurs(cluedo) + 1):
        return -1, "les numéros de joueur possibles sont les chiffres entre 1 et " + str(
            getNbJoueurs(cluedo) + 1)
    ficheIndices.connaissance(joueur.getFiche(cluedo.getJoueurCourant(cluedo)),joueur.getNum(cluedo.getJoueurCourant(cluedo)),\
                              int(commande[1]),int(commande[0]),commande[3])
    return 0, "Indication prise en compte"
Example #2
0
 def distance_separant(num_piece):
     if num_piece != getNumPieceHypothese:
         return distances[num_piece][0]
     solution = ficheIndices.hypothesesSures(
         joueur.getFiche(getJoueurCourant(cluedo)))
     if 1 in solution.keys() and 2 in solution.keys(
     ) and 3 in solution.keys():
         return 0
     return 9999  #ne pas aller dans cette salle si on n'a pas la solution
Example #3
0
def choixSolutionOrdinateur(cluedo):
    """
	retourne sous la forme d'une structure Mystere la solution proposée par le joueur courant géré par un ordinateur
	cette fonction se sert la fonction hypothesesSures de la structure ficheIndices
	paramètre: cluedo le jeu de cluedo
	résultat un mystere
	"""
    hypo_sures = ficheIndices.hypothesesSures(
        joueur.getFiche(getJoueurCourant(cluedo)))
    return (carte.getNum(hypo_sures[1]), carte.getNum(hypo_sures[2]),
            carte.getNum(hypo_sures[3]))
Example #4
0
def interrogerJoueurs(clu, hypothese):
    joueurCourant = cluedo.getJoueurCourant(clu)
    ficheJoueurCourant = joueur.getFiche(joueurCourant)
    indiceJoueurCourant = cluedo.getIndiceJoueurCourant(clu)
    nbJoueurs = cluedo.getNbJoueurs(clu)
    listeJoueurs = cluedo.getListeJoueurs(clu)
    information = ""
    for i in range(1, nbJoueurs):
        indiceInterroge = (indiceJoueurCourant + i) % nbJoueurs
        joueurInterroge = listeJoueurs[indiceInterroge]
        numJoueurInterroge = joueur.getNum(joueurInterroge)
        information += "\nle joueur " + str(
            numJoueurInterroge) + " est interrogé"
        if joueur.estHumain(joueurInterroge) and joueurInterroge==cluedo.getJoueurPrincipal(clu) and\
           joueur.reponseHypothese(joueurInterroge,hypothese)!=None:
            cluedo.afficherCluedo(clu, information)
            rep = demanderJoueurHumain(clu, information, joueurInterroge,
                                       hypothese)
        else:
            rep = cluedo.demanderJoueurOrdinateur(clu, joueurInterroge,
                                                  hypothese)
        if rep != None:
            ficheIndices.connaissance(ficheJoueurCourant,numJoueurInterroge,carte.getNum(rep),carte.getCategorie(rep),\
                                      ficheIndices.POSSEDE)
            if joueurCourant == cluedo.getJoueurPrincipal(clu):
                information += "\nLe joueur " + str(
                    numJoueurInterroge) + " vous a montré " + carte.getNom(rep)
            else:
                information += "\nLe joueur " + str(
                    numJoueurInterroge) + " a montré une carte"
            break
        else:
            information += "\nLe joueur " + str(
                numJoueurInterroge) + " ne possède aucune carte"
            for cat, num in hypothese.items():
                for j in range(nbJoueurs):
                    ficheIndices.connaissance(joueur.getFiche(listeJoueurs[j]),numJoueurInterroge,\
                                              num,cat,ficheIndices.NEPOSSEDEPAS)
    return information
Example #5
0
def choixProfMatOrdinateur(cluedo, numPiece):
    """
	retourne sous la forme d'un couple numProf,numMat le choix du joueur courant géré par un ordinateur
	cette fonction se sert la fonction creerUneHypothese de la structure ficheIndices
	paramètres: cluedo le jeu de cluedo
				numPiece le numéro de la pièce où se trouve le joueur courant
	résultat un couple numProf,numMat
	"""
    joueur_courant = getJoueurCourant(cluedo)
    choix = ficheIndices.creerUneHypothese(joueur.getFiche(joueur_courant),
                                           joueur.getNum(joueur_courant),
                                           numPiece)
    return choix[0], choix[1]
Example #6
0
def afficherCluedo(cluedo, information):
    """
	affiche la vue du cluedo c'est-à-dire le plateau ainsi que la fiche indice du joueur principal et le message d'information
	paramètres: cluedo le jeu de cluedo
				information le message à afficher avec le jeu
	"""
    print()
    joueurCourant = getJoueurCourant(cluedo)
    debutInformation="--------- Tours numéro "+str(getNumTour(cluedo))+"\n"+\
     "    c'est au joueur "+str(joueur.getNum(joueurCourant))+" appelé "+joueur.getNom(joueurCourant)+ " de jouer\n"

    plateau.afficherPlateau(getPlateau(cluedo),
                            (debutInformation + information).split('\n'))
    print(ficheIndices.string(joueur.getFiche(getJoueurPrincipal(cluedo))))