Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * Desarrollador: Alberto Jose Guilarte
- * Proyecto: Hacker-Game
- * Version: John Bonham (1948 - 1980)
- * Plataforma: Windows
- * Venezuela, Margarita.
- */
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include <windows.h> // Mantiene la funcion _SetConsoleTitleA()
- #include <time.h> // Mantiene la funcion _Sleep()
- struct {
- char nick[10];
- int nivel;
- int puntos;
- int mensajes;
- } datos, *p_datos;
- struct {
- char teclado[20];
- char ping[15];
- } estructura, *p_tructura;
- void toolbar()
- {
- printf("Bienvenido %s, tienes (%i) mensaje(s), teclea msj para revisarlo o info para informacion. \n", p_datos -> nick, p_datos -> mensajes);
- }
- void load()
- {
- FILE *load;
- load = fopen("Files/save/partida.hg", "r");
- fread(&datos, sizeof(datos), 1, load);
- fclose(load);
- }
- void save()
- {
- FILE *save;
- save = fopen( "Files/save/partida.hg", "a" );
- fwrite(&datos, sizeof(datos), 1, save);
- fclose(save);
- }
- void mensajes()
- {
- char *dir[3] = {"Files/msj1.hg", "Files/msj2.hg"};
- char mensajes;
- FILE *msj;
- msj = fopen(dir[p_datos -> nivel -1], "r");
- mensajes = getc(msj);
- while (feof(msj) == 0)
- {
- printf("%c", mensajes);
- mensajes = getc(msj);
- }
- printf("\n\n");
- }
- void bash()
- {
- toolbar();
- do {
- printf("%s@[Terminal]$ ", p_datos -> nick); fflush(stdout);
- gets(p_tructura -> teclado);
- if (strcmp(p_tructura -> teclado, "msj") == 0)
- {
- mensajes();
- p_datos -> mensajes--;
- }else if (strcmp(p_tructura -> teclado, "me") == 0)
- {
- printf("Usuario: %s \nNivel: %i \n", p_datos -> nick, p_datos -> nivel);
- }
- else if (strcmp(p_tructura -> teclado, "clear") == 0)
- {
- system("cls");
- toolbar();
- }
- else if (strcmp(p_tructura -> teclado, "save") == 0)
- {
- save();
- }
- else if (strcmp(p_tructura -> teclado, "load") == 0)
- {
- load();
- printf("Archivo cargado... \n");
- system("cls");
- toolbar();
- }
- else if (strcmp(p_tructura -> teclado, "exit") == 0)
- {
- exit(1);
- }
- else if (!strncmp(p_tructura -> teclado, "ping ", 5) != 0)
- {
- char *ping[3] = {"201.23.43.01"};
- sscanf((p_tructura -> teclado +5), "%s", p_tructura -> ping);
- if (strcmp(p_tructura -> ping, ping[p_datos -> nivel -1]) == 0)
- {
- printf("Haciendo ping a %s con 32 bytes de datos: \n", p_tructura -> ping);
- Sleep(400);
- printf("Respuesta desde %s tiempo < 43m \n", p_tructura -> ping);
- Sleep(500);
- printf("Respuesta desde %s tiempo < 40m \n", p_tructura -> ping);
- Sleep(500);
- printf("> El servidor %s esta ACTIVO \n", p_tructura -> ping);
- }
- else if (strcmp(p_tructura -> ping, ping[p_datos -> nivel -1]) >= -1)
- {
- Sleep(800);
- printf("El servidor no existe. \n");
- }
- }
- else if (strcmp(p_tructura -> teclado, "") != 0)
- {
- printf("El comando introducido es invalido, teclea info para mas informacion. \n");
- }
- } while(strcmp(p_tructura -> teclado, "exit") != 0);
- }
- int main()
- {
- p_datos = &datos;
- p_tructura = &estructura;
- /* Hacemos las definiciones aqui */
- p_datos -> nivel = 1;
- p_datos -> mensajes = 1;
- /* -------------------------------- */
- SetConsoleTitleA("Hacker-Game --;Version: John Bonham (1948 - 1980)");
- system("cls");
- printf("> Introduce el nombre para tu usuario: "); fflush(stdout);
- gets(p_datos -> nick);
- bash();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement