Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

♀ /prog/ Challenge Vol. 8 ♀

Name: Anonymous 2010-06-29 14:04

The Challenge:
-Develop a turn based combat system that implements the following choices that occur during the player's turns:
--Fight (Straight Damage)
--Item (Use an object from a choice of your design)
--Ability (Use an ability from a choice of your design)
--Run (Flee the battle)


The Deadline:
- 2010-07-01 00:00

The rest is up to you.

Name: Anonymous 2010-06-29 14:06

SHIT WE DONT HAVE LONG!

Name: Anonymous 2010-06-29 14:13

Pokemans?

Name: Anonymous 2010-06-29 14:16

i can has extenshon boss?

Name: Anonymous 2010-06-29 14:22

Hardmode:
- 2010-07-01 00:00

Normalmode:
- 2010-07-06 00:00

Name: Anonymous 2010-06-29 14:30

>>1
Really, the deadline needs to be extended. I would consider doing this if the deadline was in say; one week. Quite frankly I have more important things I need to do and can't just drop all my plans to complete a challenge posed by an Anonymous user on an internet bulletin board.

Name: Anonymous 2010-06-29 14:32

>>6
see
>>5

Name: Anonymous 2010-06-29 14:33

I'll take normal mode, as would anyone with other priorities

Name: Anonymous 2010-06-29 14:34

>>7
What is the point of having two different modes? All it does is differentiate between people who have made plans for the next two days and people who have not. Don't you think the difficulty of the challenge should be determined by something more related to the subject?

Name: Anonymous 2010-06-29 14:36

I concur.

Name: Anonymous 2010-06-29 14:40

>>9
>>10
Whatever don't worry about it, its probably just gonna work like a tiebreaker.

Name: Anonymous 2010-06-29 15:03

basically pokemon?

Name: Anonymous 2010-06-29 15:10


out: while(true){
 println("You've encountered a monster!!");
 int health=randInt(10)+5;
 println("It has "+health+" health!!!");
  while(true){
  println("WHAT THE FUCK WILL YOU DO NOW??");
  println("1. --Fight");
  println("2. --Item");
  println("3. --Ability");
  println("4. --Run");
  int choice=getNextInt();
  int dmg=0;
  switch(choice){
    case 1:
     println("You swing your feeble nerd arms at monster!");
     dmg=randInt(4);
     if(dmg==0) println("LOLOL YOU MISSED!");
     else println("You did "+dmg+" damage!!!!!!");   
     break;
    case 2:
     println("You use an item!!!");
     println("Your item is a SICP snake!!!");
     dmg=randInt(2)+1;
     println("Snake does "+dmg+" damage!!!!!!);
     break;
    case 3:
     println("You use ability!!!!");
     println("Your ability is... HAX ANUS");
     dmg= health%2==0?3:0;
     if(dmg==0) println("Monster's anus could not be haxed!");
     else println("Monster's anus is haxed for 3 damage!!");
     break;
    case 4:
     println("You try to run!! *cough*pussy*cough");
     if(randInt(1)==0){
       println("You get away!!");
       continue out;
     }else{
       println("There's no way out!!");
     }
     break;
   }
   health-=dmg;
   if(health<=0){
     println("You defeated the monster!!");
     break;
   }
   println("Monster has "+health+" life remaining!!!");
   println("Monster attacks you!!!");
   println("The power of SICP protects you!");
 }
}

Name: Anonymous 2010-06-29 17:25

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <time.h>

int main(void)
{
    int i, j;

    struct { char *name; int num, min, max; } invs[2][4] =
        {{{ "",                                 -1, -1, -1 },
          { "HANDFUL OF PARENTHESES",           10,  5,  5 },
          { "HARDCOVER COPY OF SICP",            5, 15, 15 },
          { "SICP VIDEO LECTURES ON YOUR IPOD", 20,  5, 25 }},
         {{ "UNINDENTED JAVASCRIPT",            30,  5,  5 },
          { "EARNEST DEFENSE OF SEPPLES",        5, 10,  5 },
          { "EXPERT WEB DEVELOPMENT SOLUTION",   3,  8, 40 }}};

    int hps[2] = { 100, 100 };
    char *faces[2][4][10] =
        {{{ "_                  ___.....___         ",
            " `.__           ,-'        ,-.`-,      ",
            "     `''-------'          ( p )  `._   ",
            "                           `-'      (  ",
            "                                     \\ ",
            "                           .         \\ ",
            "                            \\---..,--' ",
            "................._           --...--,  ",
            "                  `-.._         _.-'   ",
            "                       `'-----''       " },
          { "_                  ___.....___         ",
            " `.__           ,-'        ,-.`-,      ",
            "     `''-------'          ( p )  `._   ",
            "                           `-'      (  ",
            "                                     \\ ",
            "                                     \\ ",
            "                            .---..,--' ",
            "................._          |--...--,  ",
            "                  `-.._         _.-'   ",
            "                       `'-----''       " },
          { "_                  ___.....___         ",
            " `.__           ,-'        .-'  \\      ",
            "     `''-------'          / o )  `._   ",
            "                           `-'      (  ",
            "                                     \\ ",
            "                                      \\",
            "                                ______)",
            "................._          .-''    /  ",
            "                  `-.._         _.-'   ",
            "                       `'-----''       " },
          { "_                  ___.....___         ",
            " `.__           ,-'        ,-.`-,      ",
            "     `''-------'          ( x )  `._   ",
            "                           `-'      (  ",
            "                                     \\ ",
            "                                     \\ ",
            "                             ---..,--' ",
            "................._          /--...--,  ",
            "                  `-.._    `    _.-'   ",
            "                       `'-----''       " }},
         {{ "                                 ",
            "        /-------._               ",
            "      .´          ''-.           ",
            "    .´   .-.          +----------",
            "  .´    ( o )                    ",
            " /       '-´    /                ",
            ":       .------´                 ",
            "+------´                .--------",
            " '---------------------´         ",
            "                                 " },
          { "                                 ",
            "        /-------._               ",
            "      .´          ''-.           ",
            "    .´   .-.          +----------",
            "  .´    ( o )                    ",
            " /       '-´                     ",
            ":       .------                  ",
            "+------´                .--------",
            " '---------------------´         ",
            "                                 " },
          { "                                 ",
            "        /-------._               ",
            "      .´          ''-.           ",
            "    .´   .-.          +----------",
            "  .´    ( o )                    ",
            " /       '-´                     ",
            ":                                ",
            "+------                 .--------",
            " '---------------------´         ",
            "                                 " },
          { "                                 ",
            "        /-------._               ",
            "      .´          ''-.           ",
            "    .´   .-.          +----------",
            "  .´    ( X )                    ",
            " /       '-´                     ",
            ":                                ",
            "+------                 .--------",
            " '---------------------´         ",
            "                                 " }}};

    srand((unsigned int)time(NULL));

    for (;;) {
        int acted = 0;
        char action;

        printf("\033[2J\033[0;0H\n"
               "                                 "
               "PROGSNAKE FITE\n\n");

        for (i = 0; i < 10; ++i)
            printf("%s        %s\n", faces[0][3 - (hps[0] + 32) * 3 / 100][i],
                                     faces[1][3 - (hps[1] + 32) * 3 / 100][i]);
        printf("\n");
       

        switch (rand() % 2) {
        case 0:
            if (rand() % 100 > 40) {
                j = rand() % 16 + 8;

                printf("Opponent attacks, and hits you for %d HP!\n", j);
                hps[0] -= j;

            } else
                printf("Opponent attacks, but misses!\n");

            break;

        case 1:
            i = rand() % 3;
           
            if (invs[1][i].num == 0) {
                printf("Opponent wanted to use %s, but doesn't have any!\n",
                       invs[1][i].name);

            } else {
                j = rand() % invs[1][i].max + invs[1][i].min;

                printf("Opponent uses %s! You lose %d HP!\n",
                       invs[1][i].name, j);
                hps[0] -= j;
                --invs[1][i].num;

            }

            break;
        }

        sleep(1);
        if (hps[0] <= 0) break;

        printf("\nYou have %d HP. Your opponent has %d HP.\n", hps[0], hps[1]);


        do {
            printf("\nWhat do? [F]ight, [I]tem, [A]bility, [R]un: ");

            action = (char)getchar();
            action &= 0xdf;

            while (getchar() != 10);

            printf("\n");

            switch (action) {
                case 'F':
                    if (rand() % 100 > 40) {
                        j = rand() % 16 + 10;
                        printf("You attack, dealing %d damage!\n", j);
                        hps[1] -= j;

                    } else
                        printf("You try to attack, but miss!\n");

                    acted = 1;
                    break;

                case 'I':
                    printf("Inventory:\n");

                    for (i = 1; i < 4; ++i) {
                        printf("\t%d. %35s (%d)\n", i, invs[0][i].name,
                                                       invs[0][i].num);
                    }

                    printf("\nWhich will you use? [1-3] ");

                    do {
                        action = (char)getchar();
                    } while (action < 48 || action > 57);

                    while (getchar() != 10);

                    i = action - 48;

                    switch (i) {
                    case 1:
                    case 2:
                    case 3:
                        if (invs[0][i].num > 0) {
                            j = rand() % invs[0][i].max + invs[0][i].min;

                            printf("\nYou use %s! ", invs[0][i].name);
                           
                            if (i == 3) {
                                printf("You gain %d HP!\n", j);
                                hps[0] += j;
                            } else {
                                printf("Opponent loses %d HP!\n", j);
                                hps[1] -= j;
                            }

                            --invs[0][i].num;
                           
                        } else
                            printf("\nYou try to use %s, but don't have any!\n",
                                   invs[0][i].name);

                        acted = 1;
                        break;

                    default:
                        break;
                    }
                    break;

                case 'A':
                    printf("You have not yet reached Satori, so you do not "
                           "have any special abilities!\n");
                    break;

                case 'R':
                    printf("Real men don't back down!\n");
                    break;

                default:
                    printf("I don't understand that.\n");
            }

        } while (!acted);

        sleep(2);
        if (hps[1] <= 0) break;

    }

    printf("\033[2J\033[0;0H\n\t\t\t\tGAME OVER\n\n");

    for (i = 0; i < 10; ++i)
        printf("\t\t\t%s\n", faces[hps[0] > 0 ? 1 : 0][3][i]);

    printf(hps[0] > 0 ? "\n\t\t\tYou have defeated your opponent!\n\n"
                      : "\n\t\t\tYou have been defeated.\n\n");

    return 0;
}

Name: Anonymous 2010-06-29 17:29

<!doctype html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <title>『Final Quest Saga XXI: Wahrheit und Lüge im außermoralischen Sinn』</title>
  </head>
  <body>
    <noscript>This HTML program requires Javascript<i>!</i></noscript>
    <h1>Encountered an enemy<i>!</i></h1>
    <h2>Name: Sussman | Class: Wizard | Level: 255</h2>
    <ul>
      <li>
        <a href="javascript:document.body.innerHTML = '
          <h1>You attack Sussman with your Sword<i>!</i><br>
              Sussman receives 0 point(s) of damage<i>!</i><br>
              Sussman summons a computational process<i>!</i><br>
              The computational process attacks you<i>!</i><br>
              You receive 9999 point(s) of damage<i>!</i><br>
              You die<i>!</i><br>
              Game over.</h1>';">
              Fight<i>!</i></a>
      </li>
      <li>
        <a href="javascript:document.body.innerHTML = '
          <h1>You start reading ``How to Design Programs\'\'<i>!</i><br>
              It\'s not very effective...<br>
              Sussman receives 0 point(s) of damage<i>!</i><br>
              Sussman summons a computational process<i>!</i><br>
              The computational process attacks you<i>!</i><br>
              You receive 9999 point(s) of damage<i>!</i><br>
              You die<i>!</i><br>
              Game over.</h1>';">
              Item<i>!</i></a>
      </li>
      <li>
        <a href="javascript:document.body.innerHTML = '
          <h1>You summon a snake<i>!</i><br>
              A snake attacks Sussman<i>!</i><br>
              Sussman receives 0 point(s) of damage<i>!</i><br>
              Sussman summons a computational process<i>!</i><br>
              The computational process attacks you<i>!</i><br>
              You receive 9999 point(s) of damage<i>!</i><br>
              You die<i>!</i><br>
              Game over.</h1>';">
              Ability<i>!</i></a>
      </li>
      <li>
        <a href="javascript:document.body.innerHTML = '
          <h1>You attempt to run away<i>!</i><br>
              Your escape attempt is unsuccessful<i>!</i><br>
              Sussman summons a computational process<i>!</i><br>
              The computational process attacks you<i>!</i><br>
              You receive 9999 point(s) of damage<i>!</i><br>
              You die<i>!</i><br>
              Game over.</h1>';">
              Run<i>!</i></a>
      </li>
  </body>
</html>

Name: Anonymous 2010-06-29 18:10

>>14
very nice.
it crashes if you have too much hp though.

Name: Anonymous 2010-06-29 18:30

>>16
Yeah, the problem is how it selects the face. For HP over 100, the index becomes negative.

Name: Anonymous 2010-06-29 18:48

>>14
This is highly entertaining.
The segfault is like an instant loss for playing God with the HP.

Name: Anonymous 2010-06-29 19:59

ehy [spolier]/prog/[spoiler] im drunk


#include <curses.h>
#include <stdlib.h>

char *commands[] =
{
  "Fight",
  "Item",
  "Ability",
  "Run"
};

char *comments[] =
{
  "pew pew",
  "Use items",
  "Conjure the spirits with your spells",
  "Run away like a little girl"
};

char *items[] =
{
  "Wizard hat",
  "SICP",
  "cudder"
};

char *abilities[] =
{
  "Summon /prog/snake",
  "Read SICP"
};

int nabilities = 2;
int nitems = 3;
int ncommands = 4;

void print_menu(WINDOW *win, char **menu, int current, int number);
void print_submenu(char **choices, int nchoices);
void print_progsnake();
void read_sicp();

void print_menu(WINDOW *win, char **menu, int current, int number)
{
  int i;
  for(i=0; i<number; i++)
  {
    if(i==current) wattron(win, A_REVERSE);
    mvwprintw(win, i+1, 2, menu[i]);
    if(i==current) wattroff(win, A_REVERSE);
  }
}

void print_submenu(char **choices, int nchoices)
{
  WINDOW *sub_win;
  int current = 0;
  int c;
  int i;

  sub_win = newwin(nitems+2, 25, 3, 3);
  box(sub_win, 0, 0);
  refresh();
  print_menu(sub_win, choices, current, nchoices);
  wrefresh(sub_win);

  while((c = getch()) != 'q')
  {
    switch(c)
    {
      case KEY_DOWN:
        current = (current + 1) % nchoices;
        print_menu(sub_win, choices, current, nchoices);
        break;
      case KEY_UP:
        if(--current<0) current=nchoices-1;
        print_menu(sub_win, choices, current, nchoices);
        break;
      case '\n':
        if(strcmp(choices[current], abilities[0])==0)
          print_progsnake();
        if(strcmp(choices[current], abilities[1])==0)
          read_sicp();
        break;
     default:
       break;
    }
    refresh();
    wrefresh(sub_win);
  }
  werase(sub_win);
}

void print_progsnake()
{
  int i;
  char *snake[] =
  {
    "_                  ___.....___         ",
    " `.__           ,-'        ,-.`-,      ",
    "     `''-------'          ( p )  `._   ",
    "                           `-'      (  ",
    "                                     \\ ",
    "                           .         \\ ",
    "                            \\---..,--' ",
    "................._           --...--,  ",
    "                  `-.._         _.-'   ",
    "                       `'-----''       "
  };
  for(i=0; i<14; i++)
    mvprintw(LINES - i, 0, "                       ");
  for(i=0; i<10; i++)
    mvprintw(LINES - 10+i, 0, "%s\n", snake[i]);
  refresh();
}

void read_sicp()
{
  int i;
  char *sussman[] =
  {
    "    . . ,.\".\".'\"\"\"..",
    "  .             ,__\\.~~",
    " .    ;'``` '``     \\!\"",
    " .   `.              \\~\"",
    "  .., '  ____________|'~\"",
    " `.  .__/     |_|    |\\",
    "  `..'  |  = /  | =  ||",
    "      | \\___/   |\\___|\\/",
    "      |        _|    |",
    "       \\      __     |",
    "        \\    /__\\  ./",
    "        |`'._____.'|",
    "       /|          /\\"
  };
  for(i=0; i<13; i++)
    mvprintw(LINES - 13+i, 0, "%s\n", sussman[i]);
  refresh();
}

int main()
{
  WINDOW *menu_win, *comment_win, *alert_win;
  int current_command = 0;
  int c;
  int i;

  initscr();
  cbreak();
  noecho();
  keypad(stdscr, 1);
  curs_set(0);

  menu_win = newwin(ncommands+2, 40, 1, 1);
  comment_win = newwin(3, 40, 3+ncommands, 1);
  alert_win = newwin(3, 20, 5, 10);

  print_menu(menu_win, commands, current_command, ncommands);
  box(menu_win, 0, 0);
  box(comment_win, 0, 0);
  mvwprintw(comment_win, 1, 1, "%s", comments[current_command]);
  refresh();
  wrefresh(comment_win);
  wrefresh(menu_win);

  keypad(menu_win, 1);

  while((c = getch()) != 'q')
  {
    switch(c)
    {
      case KEY_DOWN:
        current_command = (current_command+1) % ncommands;
        print_menu(menu_win, commands, current_command, ncommands);
        break;
      case KEY_UP:
        if(--current_command<0) current_command=ncommands-1;
        print_menu(menu_win, commands, current_command, ncommands);
        break;
      case '\n':
        switch(current_command)
        {
          case 0:
            break;
          case 1:
            print_submenu(items, nitems);
            break;
          case 2:
            print_submenu(abilities, nabilities);
            break;
          case 3:
            box(alert_win, 0, 0);
            mvwprintw(alert_win, 1, 1, "You can't escape!");
            wrefresh(alert_win);
            getch();
            wclear(alert_win);
            wrefresh(alert_win);
            break;
        }
        print_menu(menu_win, commands, current_command, ncommands);
        box(menu_win, 0, 0); 
        break;
      case 'p':
        print_progsnake();
        break;
     
    }
    wclear(comment_win);
    box(comment_win, 0, 0);
    mvwprintw(comment_win, 1, 1, "%s", comments[current_command]);
    refresh();
    wrefresh(comment_win);
    wrefresh(menu_win);
  }   

  endwin();
}

Name: Anonymous 2010-06-29 20:19

lololol

Name: >>19 2010-06-29 20:32

The       case 'p':
        print_progsnake();
        break;
is residual testing option ans should not be there.

Name: fukc im drunk 2010-06-29 20:32

>>21
s/ans/and/g

Name: Anonymous 2010-06-29 20:55

This thread is great; it's actually filled with expert programmers.

Name: Anonymous 2010-06-29 20:58

>>19
void print_menu(WINDOW *win, char **menu, int current, int number);
void print_submenu(char **choices, int nchoices);
void print_progsnake();
void read_sicp();

Why do you declare functions right before you define them? I think you missed a point somewhere along the line.

Name: Anonymous 2010-06-29 21:05

Wow, I'm quite impressed. Well done.

Name: Anonymous 2010-06-29 21:31

>>24
It's so he doesn't have to worry about what order he defines the functions in.  It's excessive, but nothing out of the ordinary.

Name: Anonymous 2010-06-29 21:45

I'll try this. Though I can't decide whether I'm masochistic enough to use C with SDL.

Name: Anonymous 2010-06-29 22:09

>>24
Why do you declare functions right before you define them? I think you missed a point somewhere along the line.
I think you haven't programmed in C, ever.

Name: Anonymous 2010-06-29 22:09

>>27
Allegro
FTFY

Name: Anonymous 2010-06-29 22:32

>>26
It's a bit ENTERPRISE, really, and it smells of cargo cult programming.
I declare all of my functions before I define them, but I also define all of them after main, for readability.

>>28
You're a moron.

Name: Anonymous 2010-06-29 22:39

In the end I won't go with SDL because it's shit and obsolete and for some reason link.exe can't find an entry point and all the FAQs and tutorials are written for the IDEs.

Name: Anonymous 2010-06-29 22:39

>>30
Shouldn't you have a name and a .sig?

Name: Anonymous 2010-06-29 22:46

>>32
Don't you have a Java turnkey solution to deliver somewhere?

Name: Anonymous 2010-06-29 23:18

>>31
Wow.  Just wow.

Name: Anonymous 2010-06-29 23:44

>>31
Giving up on a library because you have no idea how to use a linker?

Name: Anonymous 2010-06-30 0:09

>>31
I'll agree with you that it's shit, and especially lacking in comparison to Allegro, but it's not obsolete. It surely works on modern systems quite nicely and isn't too terribly difficult to use. If you need a FAQ or tutorial you're probably doing it wrong - just read the headers and documentation, and you'll be fine.

Name: Anonymous 2010-06-30 0:35

>>33
You want a solution? Not having a JVM is my solution.

Name: Anonymous 2010-06-30 7:55

I'll post in normal mode with a program that isn't as long as my cock.

Name: Anonymous 2010-06-30 8:09

>>35
SDL_main.h defines a main macro, so that your program isn't the real main but SDL's main runs first and initializes stuff.
The real main should be in SDLmain.lib. I am linking my main.obj with SDL.lib and SDLmain.lib; I even tried different orders (since AFAIR order matters), but it doesn't work anyway.

Name: Anonymous 2010-06-30 9:19

fuq, I wanted to fix my curses bullshite but it turns out that I wouldn't make it in time to fix it completely.

http://pastebin.com/s6sE9ZYR

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List