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-07-02 15:40

>>78
Fuck Yeah Ruby

Name: Anonymous 2010-07-02 17:37

>>14 is compiling misery

Name: Anonymous 2010-07-02 17:57

>>82
Why is there always one person who can't seem to figure out his C compiler, or his Python interpreter, or his SQLite client? This isn't rocket science.

>>14 just compiles with gcc filename.c. How much easier do you want it to be?

Name: Anonymous 2010-07-02 18:21

>>62 is good until you start getting better. The $you->{power} += $powergain line shouldn't be there. Also it doesn't meet the requirements, but you've acknowledged that. I await an updated version.

Name: Anonymous 2010-07-02 18:49

This thread has been closed and replaced with the following thread:

Subject:
Compiling C code with a PHP compiler
Name:
Email:

It doesn't work.

Name: Anonymous 2010-07-02 20:49

This thread has been closed and replaced with the following thread:

Subject: Compiling C code with a Perl compiler
Name:
Email:

It works.

Name: Anonymous 2010-07-02 23:13

Name: Anonymous 2010-07-03 0:54

>>87

My god, it's the /prog/ hadith

Name: Anonymous 2010-07-03 5:00

Name: Anonymous 2010-07-03 23:52

#include <cstdlib>
#include <iostream>
#include <math.h>

using namespace std;

int main(int argc, char *argv[])
{
    double hp = 50;
    double shp = 50;
    bool turn = 0;
    bool battle = 1;
    int choice = 0;
    double dmg = 0;
    cout << "A WILD SUSSMAN appeared!\nYou are drawn into battle!\n";
    while (battle) {
          if (turn==0) {
             cout << "What do you do?\n  [1] Attack\n  [2] Use Item\n  [3] Use Skill\n  [4] Run\n";
             cin >> choice;
             cout << "\n";
             switch (choice) {
                    case (1):
                         dmg = round(5+(rand() % 7));
                         shp -= dmg;
                         cout << "You hit WILD SUSSMAN for " << dmg << " damage!\nWILD SUSSMAN has " << shp << " health remaining!\n\n";
                         turn = 1;
                         break;
                    case (2):
                         dmg = 5 - round(rand() % 5);
                         shp -= dmg;
                         cout << "Your quote from SICP brings WILD SUSSMAN to tears!\nYou hit him with SICP for " << dmg << " damage!\nWILD SUSSMAN has " << shp << " health remaining!\n\n";
                         turn = 1;
                         break;
                    case (3):
                         dmg = round(10*(rand() % 2));
                         shp -= dmg;
                         cout << "Your vast knoledge of Perl assists you...!\n";
                         if (dmg==0) {           
                            cout << "WILD SUSSMAN's knoledge surpasses yours!\nNo damage!\n\n";
                         } else {
                            cout << "The pure beauty of your code deals " << dmg << " points of damage to WILD SUSSMAN!\nWILD SUSSMAN has " << shp << " health remaining!\n\n";
                         }
                         turn = 1;
                         break;
                    case (4):
                         cout << "You break into a full sprint away from WILD SUSSMAN!\n";
                         cout << "...\nWILD SUSSMAN jumps from above and blocks your escape!\n\n";
                         turn = 0;
                         break;
                    default:
                         cout << "Your input is invalid; try again.\n\n";
                         break;
             }
             system("Pause");
          } else {
            choice = (int) round(rand() % 4);
            switch (choice) {
                   case (0):
                        hp -= 5;
                        cout << "WILD SUSSMAN performs a low-kick dealing 5 damage.\nYou have " << hp << " health left.\n\n";
                        turn = 0;
                        break;
                   case (1):
                        hp -= 6;
                        cout << "WILD SUSSMAN summons the progsnake, dealing 6 damage.\nYou have " << hp << " health left.\n\n";
                        turn = 0;
                        break;
                   case (2):
                        hp -= 3;
                        cout << "WILD SUSSMAN uses peels on you, dealing 3 damage.\nYou have " << hp << " health left.\n\n";
                        turn = 0;
                        break;
                   case (3):
                        cout << "WILD SUSSMAN flees, but is barred by the mighty progsnake!\n\n";
                        turn = 0;
                        break;
            }
            system("Pause");
          }
    if (hp<=0) {
       cout << "The WILD SUSSMAN defeated you!\n\n";
       battle = 0;
    }
    if (shp<=0) {
       cout << "You defeated the WILD SUSSMAN!\n\n";
       battle = 0;
    }    
}
system("Pause");
}

Name: Anonymous 2010-07-04 1:23

>>90
There are several ways in which this post annoys me.

Name: Anonymous 2010-07-04 8:11

>>91
let me a hazard a guess at those:

- lack of [code] tags,
- sepples
- homosexual opening brace usage,
- bracketed case
- possible the system("Pause") also

Name: Anonymous 2010-07-04 8:14

>- homosexual opening brace usage,

actually


if(expr){


is superior to


if(expr)
{


since this way more actual LOC can fit on display.

Name: Anonymous 2010-07-04 11:04

>>92-93
You guys actually look at code that's not in a [code] tag?

Name: Anonymous 2010-07-04 12:43

>>94
Now they have p0 + (∂P/∂t)×Δt problems.

Name: Anonymous 2010-07-04 12:44

Well, fuck. Forgot my sage again.

Name: Anonymous 2010-07-04 13:28

>>92
- homosexual opening brace usage,
With the exception of the switch, >>90 is pretty much K&R style. Nothing homosexual about it.

Name: Anonymous 2010-07-04 14:55

>>93
oh 92-kun here. i agree. but he didn't use it for main, and as that was the first instance, i assumed all following occurances would be the same. how wrong i was.

Name: Anonymous 2010-07-04 14:56

>>97
see >>98

Name: Anonymous 2010-07-04 14:57

100 get

Name: Anonymous 2010-07-04 14:59

>>99
Please learn what K&R style actually is. The style you're thinking of is Sun's Java style.

Name: Anonymous 2010-07-04 15:10

>>100
This might surprise you, but (;^∀^)ノ !!!SURPRISE!!! \(^∀^;).

Name: Anonymous 2010-07-04 15:33

>>101
k and r style is homosexual

Name: Anonymous 2010-07-04 16:11

I jizzed my pants

Name: Anonymous 2010-07-04 16:41

>>104
i pants my jizz

Name: Anonymous 2010-07-04 16:53

this Challenge is just for women it seems oh well............

Name: EXPERT ASTRONOMER 2010-07-04 17:11

>>106
Fuck off.

Name: 2010-07-04 17:34

>>107

Name: Anonymous 2010-07-04 17:46

>>108
Name: EXPERT ASTRONOMER
http://en.wikipedia.org/wiki/Venus

Name: 90 2010-07-04 23:49

Ah, a bit hasty wasn't I, forgetting code tags and all. Anyways, I don't generally use the

if (expression)
{
...
}

style, that's just the default in DevC++, and I was too lazy to change it. I also know about cin.get();, but in utter contempt for portability, I decided to use system("Pause"); which is an old habit. A bad one, albeit, but I like it.

Name: Anonymous 2010-07-04 23:51

>>55

Well, I don't like that that is the only Python entry.

Have this one.


from random import randint
from time import sleep

SPELLBOOK = [{"DICH SNAKE RETRACTION":18, "MASTER BLASTER":16},
        {"DIGITAL IMAGE POST ATTEMPT":20, "POWERFUL BBCODE":19},
        {"BEAUTIFUL COOING":14, "GENTLE RUBBING INTO THAT GOODNIGHT":21, "RECITATION OF HIGHSCHOOL SPIRIT SONG":12}]

ITEMLIST = [{"Handful of Dust":6, "Pawful of Dirt":9},
        {"Mudden Idol":6, "Quigsor Pindleweign":9},
        {"Open Courseware PDF notes":10, "Topical caffeine mixture, 10%":8, "A bloody mary cocktail sticker":7}]

NAMES = ["XARN", "TARN", "TARO", "SUSSMAN", "ABLESON", "DISABLESON", "KAKAMA-KUN", "VACUOUS-SAMA", "A DARKENED STRANGER", "FROZENVOID", "1000th POST", "UNSUSSEDMAN"]

YOUR_NAME = raw_input("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nWhat is your name?\n>> ")

PLAY = 1

class Person:
    def __init__(self, NAME, HP, MP, SPELLBOOK, ITEMLIST):
        self.name = NAME
        self.hp = HP
        self.mp = MP
        self.spells = SPELLBOOK
        self.items = ITEMLIST
    def Fight(self):
        #How uncivilized.
        hit = randint(5,14)
        print "\n"*2+ "%s whacks a bit, blooming into a petit mort d'%d droplets" % (self.name, hit)
        return hit
    def Magic(self, choice):
        damage = self.spells[choice]
        self.mp -= 10
        print "\n"*2+ "%s uses %s for %d damage!" % (self.name, choice, damage)
        return damage
    def Item(self):
        Item = self.items.keys()[randint(0,len(self.items)-1)]
        cure = self.items[Item]
        self.hp = self.hp + cure
        print "\n"*2+ "%s takes in the curious %s, yet looks %d radians brighter!" % (self.name, Item, cure)           
        return 0
    def Run(self):
        print "\n"*2+ "The cowardice of %s emboldens his opponent!" % (self.name)
        return -17
   
    def Upkeep(self, dmg):
        self.hp = self.hp - dmg
        if self.hp <= 0:
            print "OH DEAR! %s HAS FAILED!" % (self.name)

def Menu():
    print "[F][I][R][M]. DECIDE."
    choice = raw_input(">>")
    if choice.lower() == "r":
        return PLAYER.Run()
    elif choice.lower() == "f":
        return PLAYER.Fight()
    elif choice.lower() == "m":
        i = 1
        for spell in PLAYER.spells:   
            print "  %d) %s" % (i, spell)
            i = i + 1
        choice = int(raw_input("Which number spell do you choose? \n>>"))
        if (choice == 1) or (choice == 2):
            choice -= 1
            return PLAYER.Magic(PLAYER.spells.keys()[choice])
    elif choice.lower() == "i":
        return PLAYER.Item()
    else:
        print "I believe you've gone a bit hax'd!\nYour dalliance only strengthens your opponent!"
        return 0
def Computer():
    choices = ["r", "f", "m", "i"]
    choice = choices[randint(0,3)]
        if choice.lower() == "r":
                return OPPONENT.Run()
        elif choice.lower() == "f":
                return OPPONENT.Fight()
        elif choice.lower() == "m":
                return OPPONENT.Magic(OPPONENT.spells.keys()[randint(0,len(OPPONENT.spells)-1)])
        elif choice.lower() == "i":
                return OPPONENT.Item()


print "\n"*5
print "                           ", "-"*35
print "                                  PROGRPG"
print "                           ", "-"*35
OPPONENT = Person(NAMES[randint(0,6)],randint(75,95),randint(75,95),SPELLBOOK[randint(0,len(SPELLBOOK)-1)],ITEMLIST[randint(0,len(SPELLBOOK)-1)])
PLAYER = Person(YOUR_NAME, 75, 75, SPELLBOOK[randint(0,len(SPELLBOOK)-1)], ITEMLIST[randint(0, len(SPELLBOOK)-1)])
print "\n"*5
print """%s has come upon you, as you lie in repose! Arise, my Rubenesque champion!
Let this not be that hour during which you falter, nor fall, nor find your soul weak!
Justice flows through you, and many meditations complete you- now find the strength inside yourself to complete this!""" % (OPPONENT.name)
print "Your spell book has many pages- FEAST!"
print "\n" + "---------------------------------------"
for spell in PLAYER.spells.keys():
    print " |  " + spell
print "---------------------------------------"
print "\n"*2 + "---------------------------------------"
print "Your bag bursts with things- OBSERVE!"
print "---------------------------------------"
for item in PLAYER.items.keys():
        print " ||  " + item
print "---------------------------------------"
sleep(2)

while PLAY == 1:
    print "You're health is %d, and you've got %d anii. You're opponent looks to have %d health." % (PLAYER.hp, PLAYER.mp, OPPONENT.hp-8)
    OPPONENT.Upkeep(Menu())
    if OPPONENT.hp <= 0:
        break
    PLAYER.Upkeep(Computer())
    if PLAYER.hp <= 0:
        break
    print "\n"*4

Name: Anonymous 2010-07-05 0:36

>>111
Very good, I lol'ed at your only comment.

Name: Anonymous 2010-07-05 0:38

>>112
you're

Name: Anonymous 2010-07-05 0:48

>>111
Please learn the difference between you're and your.

Name: Anonymous 2010-07-05 0:55

Your right! Your right! Kill the body and the head will die!

Name: Anonymous 2010-07-05 0:58

>>113
..at you are only comment.
Wait what?

Name: Anonymous 2010-07-05 1:13

This entry is too long for /prog/.

http://sprunge.us/IFSA?c
http://sprunge.us/VcBS

That second one is a base64-encoded, gzipped PCX file. Decode it, gunzip it, name it img.pcx, and put it in the same folder as the executable.

If you have trouble compiling I don't want to hear about it.

Name: Anonymous 2010-07-05 1:15

>>117
Finally, a Xarn post.

Name: Anonymous 2010-07-05 1:21

>>118
Not the first one in this thread.

Name: Anonymous 2010-07-05 1:31

>>119
Even better for Xarn, a double victory is better than a single victory.

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