コード例 #1
0
ファイル: main.c プロジェクト: Socolcol/Splitter
void displayResults()
{
    printColor("\n\n-------------- Overall Results --------------\n", YELLOW);
    printf("Files Patched: \033[32;1m%d\033[0m Files Not Patched: \033[31;1m%d\033[0m",overrallSuccessCount, (int)(filesToPatchCount - overrallSuccessCount));

    if (overrallFailsCount > 0)
    {
        printColor("\n\n------- Those files couldn't patched --------\n",RED);
        long i = 0;
        for (i = 0; i < filesToPatchCount; i++)
        {
            if (filesToPatch[i].patched == 0)
            {
                printf("%s\n", filesToPatch[i].fileName);
            }
        }
        printf("\nThis is not an error.\nUnfortunately, there is no way to make them work.");
    }

    if (overrallSuccessCount == filesToPatchCount)
    {
        printColor("\n\n\tAll files have been patched successfully!", GREEN);
    }

    printf("\n\n");
}
コード例 #2
0
ファイル: rgb.cpp プロジェクト: 0xDEC0DE8/mcsema
int main()
{
    printColor(RedT() + GreenT());
    printColor(RedT() + GreenT() + BlueT());
    printColor(RedT() + (GreenT() + BlueT()));

    return 0;
}
コード例 #3
0
ファイル: saminal.cpp プロジェクト: samkreter/Saminal
//see header file for comments
int Saminal::ls(std::vector<std::string> args){
    //param check
    if(args.size() > 0){

        //set up dir iterators, man boost makes life easier
        fs::directory_iterator end_iter;
        fs::path relative_move;

        //check if the user wants to list a different directory
        (args.size() > 1) ? (relative_move = fs::path(args.at(1))) : (relative_move = fs::path(""));

        int lineCount = 0;

        //gotta love try catches
        try{
            //get the canonical path from the relative
            fs::path dirToLs = fs::canonical(relative_move,fs::current_path());

            //make sure its a dir
            if(!fs::is_directory(dirToLs)){
                std::cout<<dirToLs.filename().string()<<std::endl;
                return 1;
            }

            //iterate through the dir and print the contents
            for(fs::directory_iterator iter(dirToLs); iter != end_iter; iter++){
                //if the file has a doc ignore it
                if(iter->path().filename().string()[0] != '.'){
                    lineCount++;
                    //print dirs one color
                    if(fs::is_directory(iter->path())){
                        printColor(iter->path().filename().string(),1);
                    }
                    //and files a different color
                    else{
                         printColor(iter->path().filename().string(),0);
                    }
                    //I only want five names on one line so its pretty
                    std::cout<<"   ";
                    if(lineCount >= 5){
                        lineCount = 0;
                        std::cout<<std::endl;
                    }
                }
            }
            return 1;
        }
        catch(...){
            std::cerr<<"Could not list, either it doesn't exist or it is not a directory"<<std::endl;
            return -1;
        }
    }
    return -1;
}
コード例 #4
0
ファイル: kernel.c プロジェクト: mtcliatt/OStrich
void asciiTest()
{

	for(int i = 0; i < 16; i++)
	{
		char * a = malloc(sizeof(int) * 18);
		itoa(i, a, 10);
		if(i > 9)
			printColor(strcat(strcat("BG = ", a), "  "), i+1, i);
		else
			printColor(strcat(strcat("BG = ", a), "   "), i+1, i);
		for(int j = 0; j < 16; j++)
		{
			char * b = malloc(sizeof(int) * 18);
			itoa(j, b, 10);
			printColor(strcat(strcat("T", b), "  "), j, i);
		}
		syscall(SYSCALL_WRITE, "\n", NULL, NULL, NULL, NULL, NULL);
	}
	syscall(SYSCALL_WRITE, "\n", NULL, NULL, NULL, NULL, NULL);

	wait(150000);
	wait(150000);
	wait(150000);
	
	syscall(SYSCALL_WRITE, "\n\n", NULL, NULL, NULL, NULL, NULL);

	for(int i = 0; i < 25; i++)
	{
		for(int j = 0; j < 11; j++)
		{
			if(j*25 + i >= 255)	break;
			char * c = malloc(sizeof(int) * 18);
			c[itoa(j*25 + i, c, 16)] = '\0';

			char ascii = (char)(j*25 + i);
			if(ascii == '\t' || ascii == '\n')
				ascii = 'N';
			char as[] = {ascii, '\0'};


			char * str = strcat(c, "-");
			str = strcat(str, as);
			str = strcat(str, " | ");

			syscall(SYSCALL_WRITE, str, NULL, NULL, NULL, NULL, NULL);
		}
		if(i < 24) syscall(SYSCALL_WRITE, "\n", NULL, NULL, NULL, NULL, NULL);
	}

	wait(150000);
	syscall(SYSCALL_WRITE, "\n", NULL, NULL, NULL, NULL, NULL); 
}
コード例 #5
0
ファイル: main.cpp プロジェクト: ShenJiahuan/2048
int main()
{
	system("mode con cols=48 lines=23");
	SetConsoleTitle(L"2048");
	hideCursor();
	int data[ROW][COL];
	bool isInitial = true;
	bool isChanged = false;
	bool isEnded = false;
	int haveWinned = FALSE;
	int score = 0;
	initialNumber(data);
	randNumber(data, isInitial);
	printColor(data, score);
	do
	{
		isChanged = false;
		int key;
		getKeyPress(key);
		numberMove(data, key, isChanged);
		numberAdd(data, key, isChanged, score);
		numberMove(data, key, isChanged);
		if (isChanged)
		{
			randNumber(data, isInitial);
		}
		printColor(data, score);
		isEnded = isFinished(data);
		isWinned(data, haveWinned);
		if (haveWinned == JUSTWINNED)
		{
			if (MessageBox(NULL, TEXT("ÄãÓ®ÁË£¡ÊÇ·ñ¼ÌÐø£¿"), TEXT("2048"), MB_YESNO | MB_SYSTEMMODAL) == IDNO)
			{
				while (1)
				{
					_getch();
				}
			}
		}
	} while (!isEnded);
	if (isEnded)
	{
		MessageBox(NULL, TEXT("ÓÎÏ·½áÊø"), TEXT("2048"), MB_OK | MB_SYSTEMMODAL);
	}
	while (1)
	{
		_getch();
	}
	return 0;
}
コード例 #6
0
ファイル: Dispatcher.cpp プロジェクト: alexleclair/NNYv3
//################################################
//##            printServers
//################################################
void Dispatcher::printServers() {
    std::cout << "[Dispatcher] ----------------------- " << std::endl;
    for (unsigned int i = 0; i<m_v_worldservers.size(); i++) {
        std::cout << "[Dispatcher] " << m_v_worldservers[i].id << " - " << m_v_worldservers[i].name << " - " <<
                  m_v_worldservers[i].ipv4 << ":" << m_v_worldservers[i].port << " - " << m_v_worldservers[i].sync_key << " [";
        if (m_v_worldservers[i].online) {
            printColor("Online", COLOR_GREEN);
        } else {
            printColor("Offline", COLOR_RED);
        }
        std::cout << "]" << std::endl;
    }
    std::cout << "[Dispatcher] ----------------------- " << std::endl;
}
コード例 #7
0
void drawSpectrum::drawRectangle(int xBase, int yBase, int height, int width, int color) {
	for (int i = 0; i < height; i++) {
		for (int j = 0; j < width; j++) {
			printColor(xBase + j, yBase + i, color);
		}
	}
}
コード例 #8
0
int main (void)
{
	int n;
	int i;
	int r, g, b;
	Color c[N], average;
	
	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		scanf("%d%d%d", &r, &g, &b);
		initColor(&(c[i]), r, g, b);
		printColor(&(c[i]));
	}
	average = averageColor(c, n);
	printColor(&average);
	return 0;
}
コード例 #9
0
ファイル: shape.cpp プロジェクト: bridgetlane/Graphics-Editor
void 
Shape::print()
{
	cout << "-------------------" << endl;
	printType();
	printColor();
	printPoints();
	cout << "-------------------" << endl;
}
コード例 #10
0
ファイル: color_editor.cpp プロジェクト: jkammerl/rviz
void ColorEditor::setColor( const QColor& color )
{
  color_ = color;
  setText( printColor( color ));
  if( property_ )
  {
    property_->setColor( color );
  }
}
コード例 #11
0
ファイル: draw.c プロジェクト: YogaPan/linux-basic
int main(void)
{
	printColor(RED, "%s\n", "Wait 3 seconds...");
	sleep(3);
	clear();
	draw(45, 15, YEL, "%s\n", "A word in the middle of screen!!");

	return 0;
}
コード例 #12
0
ファイル: abjuration.cpp プロジェクト: RealmsMud/RealmsCode
bool Creature::doReflectionDamage(Damage damage, Creature* target, ReflectedDamageType printZero) {
    int dmg = damage.getReflected() ? damage.getReflected() : damage.getPhysicalReflected();

    // don't quit if we want to print 0
    if(!dmg && printZero == REFLECTED_NONE)
        return(false);

    if(damage.getReflected() || printZero == REFLECTED_MAGIC) {
        target->printColor("Your shield of magic reflects %s%d^x damage.\n", target->customColorize("*CC:DAMAGE*").c_str(), dmg);
        printColor("%M's shield of magic flares up and hits you for %s%d^x damage.\n", target, customColorize("*CC:DAMAGE*").c_str(), dmg);
        broadcastGroup(false, this, "%M's shield of magic flares up and hits %N for *CC:DAMAGE*%d^x damage.\n",
            target, this, dmg);
    } else {
        switch(damage.getPhysicalReflectedType()) {
        case REFLECTED_FIRE_SHIELD:
        default:
            target->printColor("Your shield of fire reflects %s%d^x damage.\n", target->customColorize("*CC:DAMAGE*").c_str(), dmg);
            printColor("%M's shield of fire flares up and hits you for %s%d^x damage.\n", target, customColorize("*CC:DAMAGE*").c_str(), dmg);
            broadcastGroup(false, this, "%M's shield of fire flares up and hits %N for *CC:DAMAGE*%d^x damage.\n",
                target, this, dmg);
            break;
        }
    }

    if(damage.getDoubleReflected()) {
        Damage reflectedDamage;
        reflectedDamage.setReflected(damage.getDoubleReflected());
        target->doReflectionDamage(reflectedDamage, this);
    }

    // we may have gotten this far for printing reasons (even on zero), but really, go no further
    if(!dmg)
        return(false);

    if(target->isPlayer() && isMonster())
        getAsMonster()->adjustThreat(target, dmg);

    hp.decrease(dmg);
    if(hp.getCur() <= 0)
        return(true);
    return(false);
}
コード例 #13
0
ファイル: saminal.cpp プロジェクト: samkreter/Saminal
//see header file for comments
void Saminal::run(){
    //clear the current screen to make it look prettier
    system("clear");

    //becasue I like saying things in my programs, I guess just to much time alone
    std::cout<<"\n\nGet ready for the best terminal experience of your life.....\n\n\n\n";

    //the good old inintie loops
    while(true){

        std::string command;
        std::vector<std::string> cmd_list;
        //print the pretty command thingy
        std::cout<<std::endl;

        //print the curr wd as the cool starting thingy
        //also make it red cause that looks cool
        printColor(fs::current_path().string(),2);

        //the $ makes it seem like a big boy terminal
        std::cout<<"$ ";

        //get that command from the user
        std::getline(std::cin,command);

        //If they are tired of us, then i guess let them leave
        if(command == "exit"){
            return;
        }

        //parse taht string into a vector list
        cmd_list = parse_args(command);

        if(cmd_list.size() > 0){
            //if its a basic cmd, then execute that little guy
            if(check_cmd_exist(cmd_list.at(0)) == 1){
                exec_basic(cmd_list);
                continue;
            }
            else if(exec_added(cmd_list) != 0){
                continue;
            }
            std::cerr<<"Commmand Doesn't exist"<<std::endl;
            continue;
        }


    }
}
コード例 #14
0
ファイル: creature.cpp プロジェクト: RealmsMud/RealmsCode
void Monster::checkSpellWearoff() {
    long t = time(0);

    /*
    if(flagIsSet(M_WILL_MOVE_FOR_CASH)) {
        if(t > LT(this, LT_MOB_PASV_GUARD)) {
            // Been 30 secs, time to stand guard again
            setFlag(M_PASSIVE_EXIT_GUARD);
        }
    }
     */

    if(t > LT(this, LT_CHARMED) && flagIsSet(M_CHARMED)) {
        printColor("^y%M's demeanor returns to normal.\n", this);
        clearFlag(M_CHARMED);
    }
}
コード例 #15
0
ファイル: U235.cpp プロジェクト: YuriKircovich/U235
int main()
{

	getConsoleAttri();

	printColor("Uranium 235\n\n", 10);
	printColor("Written by Yuri Kircovich\n", 10);
	printColor("\n-----------\n\n", 15);
	printColor("1] New Game\n\n", 10);
	printColor("2] Load Game\n\n", 10);
	printColor("3] Options\n\n", 10);
	printColor("4] Quit\n\n", 10);
	printColor("-----------\n\n", 15);

	inputField();

    return 0;

}
コード例 #16
0
ファイル: testApp.cpp プロジェクト: subongjeong/imageAnalyst
//--------------------------------------------------------------
void testApp::update(){
    if(bLoad)
    {
        ImageLoad();
    }
    
    if(bAnal)
    {
        ColorTable();
        bAnal = false;
    }
    
    if(bCreate)
    {
        printColor();
        bCreate = false;
    }
    
    if(bFileDone){
        if(chgColorNumStr.size() > 0){
            stringCutter(chgColorNumStr,cutterInt,',');
        }
    }
    
    
    wr = wantColor.r;
    wg = wantColor.g;
    wb = wantColor.b;
    
    if(bImageMakeStart){
        for(int i=0; i<cutterInt.size(); i++)
            chgColorNum.push_back(cutterInt[i]);
        saveImage(chgColorNum,wantColor);
        bImageMakeStart = false;
    }
}
コード例 #17
0
ファイル: CarDatabase.c プロジェクト: abustin/BroCode
void printCar(Car *car) {
    printf("a %d %s %s\n", car->year, car->make, car->model);
    printColor(car->color);
    printf("-----------------------------------------\n");
}
コード例 #18
0
ファイル: creature.cpp プロジェクト: RealmsMud/RealmsCode
bool Creature::doFlee(bool magicTerror) {
    Monster* mThis = getAsMonster();
    Player* pThis = getAsPlayer();
    BaseRoom* oldRoom = getRoomParent(), *newRoom=0;
    UniqueRoom* uRoom=0;

    Exit*   exit=0;
    unsigned int n=0;

    if(isEffected("fear"))
        magicTerror = true;

    exit = getFleeableExit();
    if(!exit) {
        printColor("You couldn't find any place to run to!\n");
        if(pThis)
            pThis->setFleeing(false);
        return(0);
    }

    newRoom = getFleeableRoom(exit);
    if(!newRoom) {
        printColor("You failed to escape!\n");
        return(0);
    }


    switch(mrand(1,10)) {
    case 1:
        print("You run like a chicken.\n");
        break;
    case 2:
        print("You flee in terror.\n");
        break;
    case 3:
        print("You run screaming in horror.\n");
        break;
    case 4:
        print("You flee aimlessly in any direction you can.\n");
        break;
    case 5:
        print("You run screaming for your mommy.\n");
        break;
    case 6:
        print("You run as your life flashes before your eyes.\n");
        break;
    case 7:
        print("Your heart throbs as you attempt to escape death.\n");
        break;
    case 8:
        print("Colors and sounds mingle as you frantically flee.\n");
        break;
    case 9:
        print("Fear of death grips you as you flee in panic.\n");
        break;
    case 10:
        print("You run like a coward.\n");
        break;
    default:
        print("You run like a chicken.\n");
        break;
    }


    broadcast(getSock(), oldRoom, "%M flees to the %s^x.", this, exit->getCName());
    if(mThis) {
        mThis->diePermCrt();
        if(exit->doEffectDamage(this))
            return(2);
        mThis->deleteFromRoom();
        mThis->addToRoom(newRoom);
    } else if(pThis) {
        pThis->dropWeapons();
        pThis->checkDarkness();
        unhide();

        if(magicTerror)
            printColor("^rYou flee from unnatural fear!\n");

        Move::track(getUniqueRoomParent(), &currentLocation.mapmarker, exit, pThis, false);

        if(pThis->flagIsSet(P_ALIASING)) {
            pThis->getAlias()->deleteFromRoom();
            pThis->getAlias()->addToRoom(newRoom);
        }

        Move::update(pThis);
        pThis->statistics.flee();

        if(cClass == CreatureClass::PALADIN && deity != GRADIUS && !magicTerror && level >= 10) {
            n = level * 8;
            n = MIN<long>(experience, n);
            print("You lose %d experience for your cowardly retreat.\n", n);
            experience -= n;
        }

        if(exit->doEffectDamage(this))
            return(2);
        pThis->deleteFromRoom();
        pThis->addToRoom(newRoom);

        for(Monster* pet : pThis->pets) {
            if(pet && inSameRoom(pThis))
                broadcast(getSock(), oldRoom, "%M flees to the %s^x with its master.", pet, exit->getCName());
        }
    }
    exit->checkReLock(this, false);

    broadcast(getSock(), newRoom, "%M just fled rapidly into the room.", this);

    if(pThis) {

        pThis->doPetFollow();
        uRoom = newRoom->getAsUniqueRoom();
        if(uRoom)
            pThis->checkTraps(uRoom);


        if(Move::usePortal(pThis, oldRoom, exit))
            Move::deletePortal(oldRoom, exit);
    }

    return(1);
}
コード例 #19
0
ファイル: creature.cpp プロジェクト: RealmsMud/RealmsCode
int Player::displayCreature(Creature* target)  {
    int     percent=0, align=0, rank=0, chance=0, flags = displayFlags();
    Player  *pTarget = target->getAsPlayer();
    Monster *mTarget = target->getAsMonster();
    std::ostringstream oStr;
    bstring str = "";
    bool space=false;

    if(mTarget) {
        oStr << "You see " << mTarget->getCrtStr(this, flags, 1) << ".\n";
        if(mTarget->getDescription() != "")
            oStr << mTarget->getDescription() << "\n";
        else
            oStr << "There is nothing special about " << mTarget->getCrtStr(this, flags, 0) << ".\n";

        if(mTarget->getMobTrade()) {
            rank = mTarget->getSkillLevel()/10;
            oStr << "^y" << mTarget->getCrtStr(this, flags | CAP, 0) << " is a " << get_trade_string(mTarget->getMobTrade())
                 << ". " << mTarget->upHisHer() << " skill level: " << get_skill_string(rank) << ".^x\n";
        }
    } else if(pTarget) {

        oStr << "You see " << pTarget->fullName() << " the "
             << gConfig->getRace(pTarget->getDisplayRace())->getAdjective();
        // will they see through the illusion?
        if(willIgnoreIllusion() && pTarget->getDisplayRace() != pTarget->getRace())
            oStr << " (" << gConfig->getRace(pTarget->getRace())->getAdjective() << ")";
        oStr << " "
             << pTarget->getTitle() << ".\n";

        if(gConfig->getCalendar()->isBirthday(pTarget)) {
            oStr << "^yToday is " << pTarget->getCName() << "'s birthday! " << pTarget->upHeShe()
                 << " is " << pTarget->getAge() << " years old.^x\n";
        }

        if(pTarget->description != "")
            oStr << pTarget->description << "\n";
    }

    if(target->isEffected("vampirism")) {
        chance = intelligence.getCur()/10 + piety.getCur()/10;
        // vampires and werewolves can sense each other
        if(isEffected("vampirism") || isEffected("lycanthropy"))
            chance = 101;
        if(chance > mrand(0,100)) {
            switch(mrand(1,4)) {
            case 1:
                oStr << target->upHeShe() << " looks awfully pale.\n";
                break;
            case 2:
                oStr << target->upHeShe() << " has an unearthly presence.\n";
                break;
            case 3:
                oStr << target->upHeShe() << " has hypnotic eyes.\n";
                break;
            default:
                oStr << target->upHeShe() << " looks rather pale.\n";
            }
        }
    }

    if(target->isEffected("lycanthropy")) {
        chance = intelligence.getCur()/10 + piety.getCur()/10;
        // vampires and werewolves can sense each other
        if(isEffected("vampirism") || isEffected("lycanthropy"))
            chance = 101;
        if(chance > mrand(0,100)) {
            switch(mrand(1,3)) {
            case 1:
                oStr << target->upHeShe() << " looks awfully shaggy.\n";
                break;
            case 2:
                oStr << target->upHeShe() << " has a feral presence.\n";
                break;
            default:
                oStr << target->upHeShe() << " looks rather shaggy.\n";
            }
        }
    }

    if(target->isEffected("slow"))
        oStr << target->upHeShe() << " is moving very slowly.\n";
    else if(target->isEffected("haste"))
        oStr << target->upHeShe() << " is moving unnaturally quick.\n";


    if((cClass == CreatureClass::CLERIC && deity == JAKAR && level >=7) || isCt())
        oStr << "^y" << target->getCrtStr(this, flags | CAP, 0 ) << " is carrying "
             << target->coins[GOLD] << " gold coin"
             << (target->coins[GOLD] != 1 ? "s" : "") << ".^x\n";

    if(isEffected("know-aura") || cClass==CreatureClass::PALADIN) {
        space = true;
        oStr << target->getCrtStr(this, flags | CAP, 0) << " ";

        align = target->getAdjustedAlignment();

        switch(align) {
        case BLOODRED:
            oStr << "has a blood red aura.";
            break;
        case REDDISH:
            oStr << "has a reddish aura.";
            break;
        case PINKISH:
            oStr << "has a pinkish aura.";
            break;
        case NEUTRAL:
            oStr << "has a grey aura.";
            break;
        case LIGHTBLUE:
            oStr << "has a light blue aura.";
            break;
        case BLUISH:
            oStr << "has a bluish aura.";
            break;
        case ROYALBLUE:
            oStr << "has a royal blue aura.";
            break;
        default:
            oStr << "has a grey aura.";
            break;
        }
    }

    if(mTarget && mTarget->getRace()) {
        if(space)
            oStr << " ";
        space = true;
        oStr << mTarget->upHeShe() << " is ^W"
             << gConfig->getRace(mTarget->getRace())->getAdjective().toLower() << "^x.";
    }
    if(target->getSize() != NO_SIZE) {
        if(space)
            oStr << " ";
        space = true;
        oStr << target->upHeShe() << " is ^W" << getSizeName(target->getSize()) << "^x.";
    }

    if(space)
        oStr << "\n";

    if(target->hp.getCur() > 0 && target->hp.getMax())
        percent = (100 * (target->hp.getCur())) / (target->hp.getMax());
    else
        percent = -1;

    if(!(mTarget && mTarget->flagIsSet(M_UNKILLABLE))) {
        oStr << target->upHeShe();
        if(percent >= 100 || !target->hp.getMax())
            oStr << " is in excellent condition.\n";
        else if(percent >= 90)
            oStr << " has a few scratches.\n";
        else if(percent >= 75)
            oStr << " has some small wounds and bruises.\n";
        else if(percent >= 60)
            oStr << " is wincing in pain.\n";
        else if(percent >= 35)
            oStr << " has quite a few wounds.\n";
        else if(percent >= 20)
            oStr << " has some big nasty wounds and scratches.\n";
        else if(percent >= 10)
            oStr << " is bleeding awfully from big wounds.\n";
        else if(percent >= 5)
            oStr << " is barely clinging to life.\n";
        else if(percent >= 0)
            oStr << " is nearly dead.\n";
    }

    if(pTarget) {
        if(pTarget->isEffected("mist")) {
            oStr << pTarget->upHeShe() << "%s is currently in mist form.\n";
            printColor("%s", oStr.str().c_str());
            return(0);
        }

        if(pTarget->flagIsSet(P_UNCONSCIOUS))
            oStr << pTarget->getName() << " is "
                 << (pTarget->flagIsSet(P_SLEEPING) ? "sleeping" : "unconscious") << ".\n";

        if(pTarget->isEffected("petrification"))
            oStr << pTarget->getName() << " is petrified.\n";

        if(pTarget->isBraindead())
            oStr << pTarget->getName() << "%M is currently brain dead.\n";
    } else {
        if(mTarget->isEnemy(this))
            oStr << mTarget->upHeShe() << " looks very angry at you.\n";
        else if(mTarget->getPrimeFaction() != "")
            oStr << mTarget->upHeShe() << " " << getFactionMessage(mTarget->getPrimeFaction()) << ".\n";

        Creature* firstEnm = nullptr;
        if((firstEnm = mTarget->getTarget(false)) != nullptr) {
            if(firstEnm == this) {
                if(  !mTarget->flagIsSet(M_HIDDEN) &&
                    !(mTarget->isInvisible() && isEffected("detect-invisible")))
                    oStr << mTarget->upHeShe() << " is attacking you.\n";
            } else
                oStr << mTarget->upHeShe() << " is attacking " << firstEnm->getName() << ".\n";

            /// print all the enemies if a CT or DM is looking
            if(isCt())
                oStr << mTarget->threatTable;
        }
        oStr << consider(mTarget);

        // pet code
        if(mTarget->isPet() && mTarget->getMaster() == this) {
            str = mTarget->listObjects(this, true);
            oStr << mTarget->upHeShe() << " ";
            if(str == "")
                oStr << "isn't holding anything.\n";
            else
                oStr << "is carrying: " << str << ".\n";
        }
    }
    printColor("%s", oStr.str().c_str());
    target->printEquipList(this);
    return(0);
}
コード例 #20
0
ファイル: blackjack.c プロジェクト: h4llow3En/BlackJack
int main(void){
	
	srand(time(0));
	card cardDeck[32];
	
	
	//Kartendeck erstellen
	initCardDeck(cardDeck);
	
	//Deck (sortiert) anzeigen
	/*int count,
	for(count = 0; count < 32; count++){
		
		printColor(cardDeck[count].col);
		printf(" ");
		printValue(cardDeck[count].val);		
		printf(" with a value of %d \n", cardDeck[count].cardValue);
	} */
	
	// Zufällige Karten ziehen
	int i,g;
	
    card showCard = cardDeck[0];
    
    
    while(1){
		printf("How many random cards do you need? ");
        scanf("%i",&i);
        printf("\n");
		
        while(i>0){
			int random = rand() %32;
            showCard = *drawnCard(&showCard,random);
				
			//Noch Karten verfügbar?
            if(showCard.cardValue == 0){
				
				//Nein
				printf("No cards left\n");
				break;
			} else{
				
				//Ja --> Karte ausgeben
				printValue(showCard.val);
				printf(" ");
				printColor(showCard.col);
				printf(" with a value of %d \n", showCard.cardValue);
				}
				i--;
		}
		if(showCard.cardValue == 0){
			
			//Abbruch der Funktion, wenn keine Karten mehr verfügbar
			break;
		}
		
		//Möglichkeit für neue Karten
        printf("\nDo you want more? Yes = 1: ");
        scanf("%i",&g);
        printf("\n");
        if(g != 1) break;
    }
    
	return 0;
}	
コード例 #21
0
ファイル: creature.cpp プロジェクト: RealmsMud/RealmsCode
bool Creature::canFlee(bool displayFail, bool checkTimer) {
    bool    crtInRoom=false;
    long    t=0;
    int     i=0;

    if(isMonster()) {

        if(!flagIsSet(M_WILL_FLEE) || flagIsSet(M_DM_FOLLOW))
            return(false);

        if(hp.getCur() > hp.getMax()/5)
            return(false);

        if(flagIsSet(M_PERMENANT_MONSTER))
            return(false);

    } else {
        //Player* pThis = getPlayer();
        if(!ableToDoCommand())
            return(false);

        if(flagIsSet(P_SITTING)) {
            if(displayFail)
                print("You have to stand up first.\n");
            return(false);
        }

        if(isEffected("hold-person")) {
            if(displayFail)
                print("You are unable to move right now.\n");
            return(false);
        }

        // blah blah re-submit
        if( (cClass == CreatureClass::BERSERKER || cClass == CreatureClass::CLERIC) &&
            isEffected("berserk") )
        {
            if(displayFail)
                printColor("^rYour lust for battle prevents you from fleeing!\n");
            return(false);
        }

        if(checkTimer && !isEffected("fear") && !isStaff()) {
            t = time(0);
            i = MAX(getLTAttack(), MAX(lasttime[LT_SPELL].ltime,lasttime[LT_READ_SCROLL].ltime)) + 3L;
            if(t < i) {
                if(displayFail)
                    pleaseWait(i-t);
                return(false);
            }
        }

        // confusion and drunkenness overrides following checks
        if(isEffected("confusion") || isEffected("drunkenness"))
            return(true);


        // players can only flee if someone/something else is in the room
        for(Monster* mons : getConstRoomParent()->monsters) {
            if(!mons->isPet()) {
                crtInRoom = true;
                break;
            }
        }

        if(!crtInRoom) {
            for(Player* ply : getConstRoomParent()->players) {
                if(ply == this)
                    continue;
                if(!ply->isStaff()) {
                    crtInRoom = true;
                    break;
                }
            }
        }

        if( !crtInRoom && !checkStaff("There's nothing to flee from!\n") ) {
            getAsPlayer()->setFleeing(false);
            return(false);
        }
    }

    return(true);
}
コード例 #22
0
ファイル: test.c プロジェクト: bsugiarto24/CPE-101
void test_printColor(void){
   struct color	c = create_color(.3,.5,.9);
   struct color c2 = create_color(1,0,1.0);
   printColor(c);
   printColor(c2);  
}
コード例 #23
0
ファイル: Dispatcher.cpp プロジェクト: alexleclair/NNYv3
void printColor(std::string &str, BYTE color) {
    printColor(str.c_str(), color);
}