Documentos de Académico
Documentos de Profesional
Documentos de Cultura
h> // getche();
#include <ctime> // time();
#include <iostream>
#define FALSE 0
#define TRUE 1
#define NADA 0
#define LIBRE 1
#define FICHA_AMARILLA 2
#define FICHA_VERDE 3
#define FICHA_AZUL 4
#define FICHA_NEGRA 5
#define FICHA_MARRON 6
#define FICHA_ROJA 7
#define NINGUNO -1
#define MODOS 9
#define COLORES 6
#define FICHAS 10
#define PASO_CORTO 1
#define PASO_LARGO 2
#define filas 17
#define columnas 13
struct scolor
{
unsigned char r;
unsigned char g;
unsigned char b;
};
int modo = 0;
int turno = 0;
int comer = 0;
int mov = 0;
int seli, selj; //posicion seleccionada
int gi, gj; //guarda la posicion del tablero a la cual se movio la
ficha animada
int fichaanim; //valor de la ficha animada
int anim = 0; //se esta animando o no alguna ficha
int fin = 0; //termino la partida?
int ct;
int turnos[MODOS][COLORES + 1] = {
{FICHA_VERDE, FICHA_AMARILLA, NADA, NADA, NADA, NADA, NADA},
{FICHA_VERDE, FICHA_AZUL, FICHA_ROJA, NADA, NADA, NADA, NADA},
{FICHA_VERDE, FICHA_AZUL, FICHA_AMARILLA, FICHA_NEGRA, NADA, NADA, NADA},
{FICHA_VERDE, FICHA_MARRON, FICHA_AZUL, FICHA_ROJA, FICHA_NEGRA, NADA, NADA},
{FICHA_VERDE, FICHA_MARRON, FICHA_AZUL, FICHA_AMARILLA, FICHA_ROJA,
FICHA_NEGRA, NADA},
{FICHA_VERDE, FICHA_AMARILLA, FICHA_MARRON, FICHA_ROJA, FICHA_AZUL,
FICHA_NEGRA, NADA},
{FICHA_VERDE, FICHA_AZUL, FICHA_AMARILLA, FICHA_NEGRA, NADA, NADA, NADA},
{FICHA_VERDE, FICHA_MARRON, FICHA_AZUL, FICHA_AMARILLA, FICHA_ROJA,
FICHA_NEGRA, NADA},
{FICHA_VERDE, FICHA_AMARILLA, FICHA_MARRON, FICHA_ROJA, NADA, NADA, NADA}
};
int iniciales[COLORES][FICHAS * 2] = {
{0, 6, 1, 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 0, 0, 1, 0, 0, 0, 0, 0, 0}}; // tablero sin fichas
int tablero[17][13] = {
{0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0},
{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
{0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
{0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0},
{0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0},
{0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0},
{0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0},
{0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0},
{0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
{0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0}
};
}
return FALSE;
}
/* Indica el total de fichas del turno consultado las cuales se encuentran dentro
de la base objetivo. */
int TotalFichasEnBase(int algunturno)
{
int i, fichasenbase = NADA;
for (i = 0; i < fichasxturno[modo]; i++)
{
fichasenbase += FichasEnBase(turnos[modo][algunturno + i]);
}
return fichasenbase;
}
/* Condicion de fin del juego, mientras no todos los turnos hayan llegado. */
int FinJuego()
{
return 0;
}
void Imprimir()
{
cout << "\n\t\t\t ";
for (int j = 0; j < columnas - 1; j++){
if (j < 9)
cout << " " << j + 1;
else
cout << " " << j + 1;
}
cout << "\n\n";
for (int i = 0; i < filas; i++)
{
cout << "\t\t" << i << "\t";
for (int j = 0; j < columnas; j++)
{
if ((i % 2) == 0)
{
if (tablero[i][j] > 0){
switch (tablero[i][j])
{
case 1:
cout << " " << "*";
break;
case 2:
cout << " " << "R";
break;
case 3:
cout << " " << "P";
break;
}
}
else{
cout << " ";
}
}
else
{
if (tablero[i][j] > 0){
switch (tablero[i][j])
{
case 1:
cout << " " << "* ";
break;
case 2:
cout << " " << "R ";
break;
case 3:
cout << " " << "P ";
break;
}
}
else
cout << " ";
}
}
cout << endl;
}
/*
Inicializa todos los valores del tablero
*/
void InicializarTablero()
{
int i = 0;
while (turnos[modo][i] != NADA)
{
PintarTablero(turnos[modo][i]);
i++;
}
}
/*
Inicializa una partida
*/
void juegonuevo()
{
for (int i = 0; i < 17; i++)
{
for (int j = 0; j < 13; j++)
{
tablero[i][j] = tablerobase[i][j];
}
}
turno = 0;
}
void control()
{
int ficha;
do
{
system("cls");
Imprimir();
inicio(1, 1, 1);
} while (2>1);
}
void inicio(int state, int x, int y)
{
struct scolor color;
int curi, curj;
static int ban = 0;
int movtipo;
//display();
}
void mensaje_salida()
{
cout << "\n\t\t............::::::::: FIN DE PROGRAMA :::::::::::............"
<< "\n\t\t============================================================="
<< "\n\t\tName : Damas Chinas"
<< "\n\t\tAuthor : @Eber"
<< "\n\t\tVersion : Hito 1"
<< "\n\t\tDescription : Programacion I"
<<
"\n\t\t=============================================================\n\n";
}
void reglas()
{
cout << "\n\t\t\t :::::::::::::::::::: MODO DE JUEGO ::::::::::::::::::::\n"
<< "\n\t\tCADA EQUIPO CONSTA DE DIES FICHAS O PIEZAS. AL EMPEZAR EL JUEGO,
ESTAS DIEZ"
<< "\n\t\tDE UN MISMO JUGADOR ESTAN JUNTAS, EN UNO DE LOS TRIANGULOS QUE
FORMAN LAS"
<< "\n\t\tPUNTAS DE LA ESTRELLA. EL OBJETIVO DEL JUEGO ES LLEVAR LAS 10
FICHAS O PIEZAS"
<< "\n\t\tDE UN EQUIPO DESDE UNA PUNTA HASTA LA OPUESTA."
<< "\n\t\tPUNTA HASTA LA OPUESTA"
<< "\n\t\tCADA JUGADOR SOLO MUEVE UNA FICHA POR TURNO"
<< "\n\t\tUN MOVIMIENTO VALIDO ES:"
<< "\n\t\t - A UNA CASILLA ADYACENTE LIBRE"
<< "\n\t\t - SALTANDO UNA CASILLA ADYACENTE OCUPADA POR OTRA FICHA (SEA
PROPIA O,"
<< "\n\t\t CONTRARIA) Y POSANDOLA EN LA CASILLA SIGUIENTE SI ESTA
LIBRE\n"
<< "\n\t\t\t :::::::::::::::::::: INSTRUCCIONES ::::::::::::::::::::\n"
<< "\n\t\tPARA JUGAR A DAMAS CHINAS LA PARTIDA COMENZARA CON EL JUGADOR DE
MAYOR PUNTAJE."
<< "\n\t\tPOSTERIORMENTE SE ALTERNARAN EL TURNO DE JUGAR DE ACUERDO A LAS
REGLAS"
<< "\n\t\tPARA HACER UN MOVIMIENTO DEBE SELECCIONAR PRIMERO LA COORDENADA
VERTICAL, Y "
<< "\n\t\tDESPUES LA COORDENADA HORIZONTAL, CASO DE NO HABER FICHA SE TE
VOLVERA A PEDIR"
<< "\n\t\tQUE VUELVAS A TIRAR PARA SELECCIONAR EL MOVIMIENTO DE LA FICHA
PERSIONA [1]"
<< "\n\t\tPARA MOVERLA DIAGONALMENTE IZQUIERDA O [2] PARA DIAGONAL
DERECHA"
<< "\n\t\tGANA EL JUGADOR QUE PUEDA COLOCAR PRIMERO SUS 10 FICHAS EN EL
EXTREMO OPUESTO."
<< "\n";
}
void presentacion()
{
system("color B");
cout << "\n\t\t .....::::: BIENVENIDO AL JUEGO DE DAMAS CHINAS EN C+
+ :::::.....\n\n"
<< "\n\t\t\t\t || PRESIONE ENTER PARA CONTINUAR ||\n\n";
Imprimir();
cout << "\n\t\t\t 2020 copyright \251Eber Todos los Derechos Reservados";
getche();
}
int menu()
{
system("cls");
int opcion;
cout << "\n\t\t\t\t=============================="
<< "\n\t\t\t\t....:::: DAMAS CHINAS ::::...."
<< "\n\t\t\t\t==============================\n"
<< "\n\t\t\t\t[1] JUGAR"
<< "\n\t\t\t\t[2] REGLAS"
<< "\n\t\t\t\t[3] SALIR\n";
do
{
cout << "\n\t\t\t\tDigite opcion [ ]\b\b";
cin >> opcion;
} while (opcion < 1 || opcion > 3);
return opcion;
}
void procesos()
{
int opcion;
do
{
opcion = menu(); // representa la seleccion del menu
system("cls");
switch (opcion)
{
case 1:
juegonuevo();
InicializarTablero();
control();
break;
case 2:
reglas();
break;
case 3:
mensaje_salida();
break;
}
getche();
} while (opcion != 3);
}
int main()
{
presentacion();
procesos();
}