Go Back   Champions of Regnum > English > The Inn

The Inn A place to gather around and chat about almost any subject

Reply
 
Thread Tools Display Modes
Old 10-28-2010, 07:34 PM   #31
Znurre
Marquis
 
Join Date: Jan 2007
Location: RA
Posts: 1,897
Znurre will become famous soon enoughZnurre will become famous soon enough
Default

Quote:
Originally Posted by xXFarneyXx View Post
I dont know guys... When I go to compile it, it has a bunch of errors. I belive I am missing files...I have: weapon.h, player.h, mob.h, mob.cpp, main.cpp. Is there a weapon.cpp? Im still new at this so dont flame me too hard
Try something like this:
Code:
g++ ./main.cpp ./mob.cpp
__________________
Winning a fight is not what makes you a good player, it's how you do it.
http://home.znur.re/screenshot%20201...2011_39_37.jpg
Znurre no ha iniciado sesión   Reply With Quote
Old 10-28-2010, 07:52 PM   #32
A_K_M
Apprentice
 
Join Date: Jul 2008
Location: Virginia
Posts: 67
A_K_M is on a distinguished road
Default

Quote:
Originally Posted by Znurre View Post
Try something like this:
Code:
g++ ./main.cpp ./mob.cpp
Where abouts should I type this? up top? or does it matter?
__________________
Horus: AKM lvl 50 Conjurer, Chiller lvl 42 Warlock,
MAK lvl 50 Knight, A K M lvl 45 Hunter
A_K_M no ha iniciado sesión   Reply With Quote
Old 10-28-2010, 08:12 PM   #33
Znurre
Marquis
 
Join Date: Jan 2007
Location: RA
Posts: 1,897
Znurre will become famous soon enoughZnurre will become famous soon enough
Default

Quote:
Originally Posted by xXFarneyXx View Post
Where abouts should I type this? up top? or does it matter?
Start a terminal, use "cd" to navigate to the folder where you stored the files found in this thread, and run the command.
Example:
Code:
cd /home/Farney/TheApplication
g++ ./main.cpp ./mob.cpp
You should get a file called a.out which you can run like this:
Code:
./a.out
__________________
Winning a fight is not what makes you a good player, it's how you do it.
http://home.znur.re/screenshot%20201...2011_39_37.jpg
Znurre no ha iniciado sesión   Reply With Quote
Old 10-28-2010, 09:02 PM   #34
Arafails
Baron
 
Arafails's Avatar
 
Join Date: Nov 2007
Location: Not where it looks like, to either of us.
Posts: 706
Arafails will become famous soon enough
Default

Assuming you're using the GNU Compiler Collection of course. IIRC AKM is a Winders boy and unlikely to have Cygwin or MinGW.…
__________________
If you can't detect sarcasm yourself, please pay attention when it's pointed out to you.
Arathael :: Wyrd Sceote :: Gwn M'gerSoul Taker, Imperial Guard of Ignis
Arafails no ha iniciado sesión   Reply With Quote
Old 10-28-2010, 09:47 PM   #35
Masterkick
Baron
 
Masterkick's Avatar
 
Join Date: Aug 2007
Location: Gallifrey
Posts: 718
Masterkick will become famous soon enoughMasterkick will become famous soon enough
Default

Please I need to see what this is! compile it for (me) win users! It would be great if Znurre added a link to the compiled exe on the main post.
__________________
Runi
Masterkick no ha iniciado sesión   Reply With Quote
Old 10-28-2010, 09:57 PM   #36
Enitharmon
Initiate
 
Enitharmon's Avatar
 
Join Date: May 2007
Posts: 144
Enitharmon is on a distinguished road
Default

Compiling on a VC++ compiler currently fails because <string> isn't included. This version fixes that... (include <string>)

main.cpp:
Code:
#include <iostream>
#include <string>

#include "player.hpp"
#include "mob.h"

int main( int argc, char **argv )
{
   std::cout << "Hello Ra !" << std::endl;
   std::cout << "Enter your player name: ";
   
   char name[ 32 ];
   std::cin >> name;
   Player player(name);
   player.punish();
   
   if( !player.isBanned() )
      Mob(player.getLevel() + 5).attack(&player);
   std::cout << player;
}
mob.cpp:
Code:
#include "mob.h"

#include <iostream>
#include <string>

Mob::Mob(unsigned int level)
{
}

void Mob::attack(Player * player)
{
  std::cout << player->GetName() << " was attacked by a vicious creature!" << std::endl;
  player->takeDamage(15);
}
mob.h:
Code:
#ifndef __MOB_H
#define __MOB_H
#include "player.hpp" /* Note to author: please separate implementation from headers, no one likes
                      * to compile a module for file that includes its headers */

class Mob {
  public:
    Mob(unsigned int level);
    void attack(Player * player);
};
#endif
player.hpp:
Code:
#ifndef PLAYER_HPP
#define PLAYER_HPP

#include <iostream>
#include <string>
#include <cstdlib> //rand()
#include "weapon.h"

class Player
{
   public:
      Player();
      Player(char* n) : name(n), banned( false ), level( 1 ), hp( 25 ),
			weapon( new WoodenSpoon() ) {}
      
      std::string GetName() { return name; }

      void punish()
      {
         std::cout << "<chilko> ban time!" << std::endl;
    
           //TODO
         if(rand()%3 == 2)
         {
            std::cout << "Hacker detected. " << name << " is now banned." << std::endl;
            banned = true;
         }
      }

      unsigned int getLevel()
      {
         return level;
      }
      
      bool isBanned()
      {
         return banned;
      }
   
      void takeDamage(unsigned int damage)
      {
	 hp -= damage;
	 if(hp < 0) // let's keep regnum's bugs :)
	    die();
      }
      
      void die()
      {
	 level -= 1;
	 respawn();
      }
      
      void respawn()
      {
      }
   
      unsigned int getHp() { return hp; }

      void describe(std::ostream &out) {
	out << "A weary traveller, bearing the name of " << GetName() << "."
	    << std::endl;
	if (level <= 1) {
	  out << " He seems fragile enough that a feeble fly could "
	      << "probably squash him easily." << std::endl;
	}
	if (weapon) {
	  out << " In his hand, he wields " << weapon->GetDisplayName()
	      << "." << std::endl;
	}
	out << " Health points: " << getHp() << std::endl;
      }

      friend std::ostream& operator << (std::ostream& out, Player& player)
      {
	player.describe(out);
	return out;
      }

   private:
      std::string name;
      bool banned;
      unsigned int level;
      unsigned int hp;
      Weapon *weapon;
};

#endif
weapon.h:
Code:
#pragma once

#include <string>

class Weapon {
	// Something that can be utilized for slaying something else!
public:
	virtual ~Weapon() {}
	// Damage yielded by this weapon when wielded by the provided object
	virtual unsigned int GetDamage(void *) const = 0;
	virtual std::string GetName() const = 0;
	virtual std::string GetDisplayName() const {
		return "a " + GetName();
	}
};

class EgoWeapon : public Weapon {
	// A type of weapon there only exists one instance of.
public:
	virtual std::string GetDisplayName() const {
		return "The " + GetName();
	}
};

class WoodenSpoon : public Weapon {
public:
	virtual unsigned int GetDamage(void *) const { return 1; }
	virtual std::string GetName() const {
		return "wooden spoon";
	}
};

class StaffOfGonorrhea : public EgoWeapon {
public:
	virtual unsigned int GetDamage(void *) const { return 999; }
	virtual std::string GetName() const {
		return "Great Staff of Gonorrhea";
	}
};

(and *duh* reread the rules and realized I violated the "dont change" rule earlier.. srry!)


For those without access to a C++ compiler, here is the output of a sample run of the current version:
Code:
Hello Ra !
Enter your player name: Johnny Rotten
<chilko> ban time!
Johnny was attacked by a vicious creature!
A weary traveller, bearing the name of Johnny.
 He seems fragile enough that a feeble fly could probably squash him easily.
 In his hand, he wields a wooden spoon.
 Health points: 10
Enitharmon no ha iniciado sesión   Reply With Quote
Old 11-02-2010, 12:11 PM   #37
Arafails
Baron
 
Arafails's Avatar
 
Join Date: Nov 2007
Location: Not where it looks like, to either of us.
Posts: 706
Arafails will become famous soon enough
Default

Revive?

Code:
#include <iostream>
#include <string>
#include <ctime>

#include "player.hpp"
#include "mob.h"

int main( int argc, char **argv )
{
   std::cout << "Hello Ra !" << std::endl;
   std::cout << "Enter your player name: ";
   
   char name[ 32 ];
   std::cin >> name;
   Player player(name);
   player.punish();
   
   if( !player.isBanned() )
      Mob(player.getLevel() + 5).attack(&player);
   std::cout << player;
   for (time_t lag = (time( NULL ) + 1); lag > time( NULL ););
}
__________________
If you can't detect sarcasm yourself, please pay attention when it's pointed out to you.
Arathael :: Wyrd Sceote :: Gwn M'gerSoul Taker, Imperial Guard of Ignis
Arafails no ha iniciado sesión   Reply With Quote
Old 11-02-2010, 01:12 PM   #38
Znurre
Marquis
 
Join Date: Jan 2007
Location: RA
Posts: 1,897
Znurre will become famous soon enoughZnurre will become famous soon enough
Default

Sorry, I am so busy nowadays that I cannot even keep my own threads alive :/
__________________
Winning a fight is not what makes you a good player, it's how you do it.
http://home.znur.re/screenshot%20201...2011_39_37.jpg
Znurre no ha iniciado sesión   Reply With Quote
Old 11-02-2010, 01:40 PM   #39
kidanger
Pledge
 
Join Date: Aug 2007
Location: France
Posts: 4
kidanger is on a distinguished road
Red face

main.cpp:
Code:
#include <iostream>
#include <string>
#include <ctime>

#include "player.hpp"
#include "mob.h"


int main( int argc, char **argv )
{
   srand(time(NULL));
   
   std::cout << "Hello Ra !" << std::endl;
   std::cout << "Enter your player name: ";
   
   char name[ 32 ];
   std::cin >> name;
   Player player(name);
   player.punish();
   
   if( !player.isBanned() )
      Mob(player.getLevel() + 5).attack(&player);
   std::cout << player;
   for (time_t lag = (time( NULL ) + 1); lag > time( NULL ););
   #if defined(linux)
      if(rand() % 10 == 0)
      {
         std::cout << "Error " << rand()%42 << ": " << getenv("HOME") << "/.drivers/GL_32.dll not found." << std::endl;
         return EXIT_FAILURE;
      }
   #endif
   
   return EXIT_SUCCESS;
}
kidanger no ha iniciado sesión   Reply With Quote
Old 11-02-2010, 01:50 PM   #40
ArcticWolf
Duke
 
ArcticWolf's Avatar
 
Join Date: Nov 2006
Location: 0x00CAFE
Posts: 3,366
ArcticWolf is a glorious beacon of lightArcticWolf is a glorious beacon of lightArcticWolf is a glorious beacon of lightArcticWolf is a glorious beacon of lightArcticWolf is a glorious beacon of light
Default

Code:
#include <iostream>
#include <string>
#include <ctime>

#include "player.hpp"
#include "mob.h"


int main( int argc, char **argv )
{
   srand(time(NULL));
   
   std::cout << "Hello Ra !" << std::endl;
   std::cout << "Enter your player name: ";
   
   char name[ 32 ];
   std::cin >> name;
   Player player(name);
   player.punish();
   
   if( !player.isBanned() )
      Mob(player.getLevel() + 5).attack(&player);
   std::cout << player;
   for (time_t lag = (time( NULL ) + 1); lag > time( NULL );)
      std::cout << lag & 1 ? "1", "0" << std::endl;
   #if defined(linux)
      if(rand() % 10 == 0)
      {
         std::cout << "Error " << rand()%42 << ": " << getenv("HOME") << "/.drivers/GL_32.dll not found." << std::endl;
         return EXIT_FAILURE;
      }
   #else
      std::cout << "Error " << "license expired. Buy another copy!" << std::endl;
      return EXIT_SUCCESS;
   #endif
   
   return EXIT_SUCCESS;
}
__________________
I don't have a solution, but I admire the problem.
ArcticWolf no ha iniciado sesión   Reply With Quote
Reply

Tags
programming code game


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 12:19 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
NGD Studios 2002-2024 © All rights reserved