//drop a portion of an inventory slot
void cGameServer::doDrop(int id,int slot,int qty)
{
    int item=player[id].inventory[slot];

    if(item==-1 || qty<=0)
        return;

    //quantity same or more so drop all
    if(qty >= ml_items.item[item].qty)
    {
        doDrop(id,slot);
        return;
    }

    if(player[id].access<=0 || //no access
            ml_items.item[item].qty<=0) //cant drop portion of single or empty
        return;

    //drop item on map
    sendAddMapItem(ml_items.item[item].graphic,player[id].map,player[id].x,player[id].y);

    //remove some from player inventory
    cItem portion = ml_items.item[item];
    portion.qty = qty;

    ml_items.item[item].qty-=qty;
    updateItem(item);
    item=ml_items.addMapItem(player[id].map,player[id].x,player[id].y,portion);
    addItem(item);

    //remove some from client inventory
    sendInventoryRemove(itod(id),slot,qty);
}
Beispiel #2
0
/* Main program (obviously) */
int main(void)
{
    while (1) {
        initialize();
        clearScreen();
        printf("%s", introText);

        while (!gameOver) {
            prompt();
            if (buffer[0] == '\0') {
            } else if (tolower(buffer[0]) == 'h') {
                doHelp();
            } else if (tolower(buffer[0]) == 'i') {
                doInventory();
            } else if ((tolower(buffer[0]) == 'g')
                       || !strcasecmp(buffer, "n") || !strcasecmp(buffer, "s")
                       || !strcasecmp(buffer, "e") || !strcasecmp(buffer, "w")
                       || !strcasecmp(buffer, "u") || !strcasecmp(buffer, "d")
                       || !strcasecmp(buffer, "north") || !strcasecmp(buffer, "south")
                       || !strcasecmp(buffer, "east") || !strcasecmp(buffer, "west")
                       || !strcasecmp(buffer, "up") || !strcasecmp(buffer, "down")) {
                doGo();
            } else if (tolower(buffer[0]) == 'l') {
                doLook();
            } else if (tolower(buffer[0]) == 't') {
                doTake();
            } else if (tolower(buffer[0]) == 'e') {
                doExamine();
            } else if (tolower(buffer[0]) == 'u') {
                doUse();
            } else if (tolower(buffer[0]) == 'd') {
                doDrop();
            } else if (tolower(buffer[0]) == 'q') {
                doQuit();
            } else if (!strcasecmp(buffer, "xyzzy")) {
                printf("Nice try, but that won't work here.\n");
            } else {
                printf("I don't understand. Try 'help'.\n");
            }

            /* Handle special actions. */
            doActions();
        }

        printf("Game over after %d turns.\n", turnsPlayed);
        printf("%s", "Do you want to play again (y/n)? ");
        fgets(buffer, sizeof(buffer)-1, stdin);
        if (tolower(buffer[0]) == 'n') {
            break;
        }
    }
    return 0;
}
Beispiel #3
0
void Item::execute(Hero* hero, std::string straction)
{
	curUser = hero;
	curItem = this;

	if (straction.compare(AC_DROP) == 0)
	{
		doDrop(hero);
	}
	else if (straction.compare(AC_THROW) == 0)
	{
		doThrow(hero);
	}
}
Beispiel #4
0
WINEXPORT LRESULT CALLBACK FtPickProc( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam )
{
    switch( msg ) {
    case WM_CREATE:
        return( 0 );
    case WM_PAINT:
        return( drawCurLogfont( hwnd, msg, wparam, lparam ) );
    case WM_LBUTTONDOWN:
        return( setupForDrop( hwnd ) );
    case WM_LBUTTONUP:
        return( doDrop( hwnd, wparam ) );
    case WM_MOUSEMOVE:
        return( processMouseMove( hwnd, msg, wparam, lparam ) );
    case WM_DESTROY:
        return( 0 );
    }
    return( DefWindowProc( hwnd, msg, wparam, lparam ) );
}
Beispiel #5
0
void Game::doAction(const Actions action) {
	switch (action)
	{
	case GO: doGo(); break;
	case QUIT: doQuit(); break;
	case PICK: doPick(); break;
	case DROP: doDrop(); break;
	case READ: doRead(); break;
	case BREAK: doBreak(); break;
	case SEE: doSee(); break;
	case OPEN: doOpen(); break;
	case FILL: doFill(); break;
	case USE: doUse(); break;
	case PUT: doPut(); break;
	case NOACTION: doNothing(); break;
	default: doNothing();
	}
}
Beispiel #6
0
BOOL LLTextureCtrl::handleDragAndDrop(S32 x, S32 y, MASK mask,
					  BOOL drop, EDragAndDropType cargo_type, void *cargo_data,
					  EAcceptance *accept,
					  std::string& tooltip_msg)
{
	BOOL handled = FALSE;

	// this downcast may be invalid - but if the second test below
	// returns true, then the cast was valid, and we can perform
	// the third test without problems.
	LLInventoryItem* item = (LLInventoryItem*)cargo_data; 
	bool is_mesh = cargo_type == DAD_MESH;

	if (getEnabled() &&
		((cargo_type == DAD_TEXTURE) || is_mesh) &&
		 allowDrop(item))
	{
		if (drop)
		{
			if(doDrop(item))
			{
				if (!mCommitOnSelection)
					mViewModel->setDirty();

				// This removes the 'Multiple' overlay, since
				// there is now only one texture selected.
				setTentative( FALSE ); 
				onCommit();
			}
		}

		*accept = ACCEPT_YES_SINGLE;
	}
	else
	{
		*accept = ACCEPT_NO;
	}

	handled = TRUE;
	lldebugst(LLERR_USER_INPUT) << "dragAndDrop handled by LLTextureCtrl " << getName() << llendl;

	return handled;
}
BOOL LLTextureCtrl::handleDragAndDrop(S32 x, S32 y, MASK mask,
					  BOOL drop, EDragAndDropType cargo_type, void *cargo_data,
					  EAcceptance *accept,
					  std::string& tooltip_msg)
{
	BOOL handled = FALSE;

	// this downcast may be invalid - but if the second test below
	// returns true, then the cast was valid, and we can perform
	// the third test without problems.
	LLInventoryItem* item = (LLInventoryItem*)cargo_data;
	// <edit> mEnable getEnabled()
	if (mEnable && (cargo_type == DAD_TEXTURE) && allowDrop(item))
	{
		if (drop)
		{
			if(doDrop(item))
			{
				// This removes the 'Multiple' overlay, since
				// there is now only one texture selected.
				setTentative( FALSE ); 
				onCommit();
			}
		}

		*accept = ACCEPT_YES_SINGLE;
	}
	else
	{
		*accept = ACCEPT_NO;
	}

	handled = TRUE;
	LL_DEBUGS("UserInput") << "dragAndDrop handled by LLTextureCtrl " << getName() << LL_ENDL;

	return handled;
}
Beispiel #8
0
void Game::doDrop() {
	if (object != verb)
	{
		
		Item toDrop = player->getItem(object);
		if (toDrop.first != "NOITEM")
		{
			if (checkAction(toDrop, DROP))
			{
				player->dropItem(toDrop.first);
				room_list[current_room]->dropItem(toDrop);
				cout << "You dropped the " << toDrop.first << endl;
			}
			else cout << "You can't drop that item." << endl;
		}
		else cout << "You don't have that item." << endl;
	}
	else {
		cout << "Which item do you want to drop?" << endl;
		cout << ">";
		getline(cin, object);
		doDrop();
	}
}