Example #1
0
void ClientInterface::UpdatePlayerList()
{
	if (m_env != NULL)
		{
		std::vector<u16> clients = getClientIDs();
		m_clients_names.clear();


		if(!clients.empty())
			infostream<<"Players:"<<std::endl;

		for(std::vector<u16>::iterator
			i = clients.begin();
			i != clients.end(); ++i) {
			Player *player = m_env->getPlayer(*i);

			if (player == NULL)
				continue;

			infostream << "* " << player->getName() << "\t";

			{
				MutexAutoLock clientslock(m_clients_mutex);
				RemoteClient* client = lockedGetClientNoEx(*i);
				if(client != NULL)
					client->PrintInfo(infostream);
			}

			m_clients_names.push_back(player->getName());
		}
	}
}
void fight(Player p, Monster mob) 
{
	cout << "A WILD " << sandetra::capslock(mob.getName()) << " APPEAERS!" << endl;
	while (mob.getHitpoints() > 0 && p.getHitpoints() > 0) {
		mob.takeDamage(p.attacksFor());
		if (mob.getHitpoints() <= 0) {
			cout << mob.getName() << " has been defeated!" << endl;
			cout << p.getName() << " uses a potion to return to full health." << endl;
			p.setHitpoints(30);
			return;
		} else {
			if (rand() % 3 == 2) {
				cout << "You have a chance to parry the attack!" << endl;
				if (twoscomp_quiz()) {
					cout << "ATTACK SUCCESSFULLY PARRIED!" << endl;
				} else p.takeDamage(mob.attacksFor());
			} else {
				p.takeDamage(mob.attacksFor());
			}
			if (p.getHitpoints() <= 0) {
				cout << p.getName() << " has fallen! OH NO!!!!" << endl;	//Game over not implemented.
				cout << p.getName() << " uses a potion!" << endl;
				p.setHitpoints(15);
				return;
			}
		}
	}
}
bool operator== (const Player& LHS, const Player& RHS)
{
    bool ret = nullptr;

    if (strcmp(LHS.getName(), RHS.getName()) == 0)
    {
        ret = true;
    }
    else
        ret = false;

    return ret;
} // end operator==
Example #4
0
void cmd_banunban(std::wostringstream &os, ServerCommandContext *ctx)
{
    if((ctx->privs & PRIV_BAN) == 0)
    {
        os<<L"-!- You don't have permission to do that";
        return;
    }

    if(ctx->parms.size() < 2)
    {
        std::string desc = ctx->server->getBanDescription("");
        os<<L"-!- Ban list: "<<narrow_to_wide(desc);
        return;
    }
    if(ctx->parms[0] == L"ban")
    {
        Player *player = ctx->env->getPlayer(wide_to_narrow(ctx->parms[1]).c_str());

        if(player == NULL)
        {
            os<<L"-!- No such player";
            return;
        }

        try {
            Address address = ctx->server->getPeerAddress(player->peer_id);
            std::string ip_string = address.serializeString();
            ctx->server->setIpBanned(ip_string, player->getName());
            os<<L"-!- Banned "<<narrow_to_wide(ip_string)<<L"|"
              <<narrow_to_wide(player->getName());

            actionstream<<ctx->player->getName()<<" bans "
                        <<player->getName()<<" / "<<ip_string<<std::endl;
        } catch(con::PeerNotFoundException) {
            dstream<<__FUNCTION_NAME<<": peer was not found"<<std::endl;
        }
    }
    else
    {
        std::string ip_or_name = wide_to_narrow(ctx->parms[1]);
        std::string desc = ctx->server->getBanDescription(ip_or_name);
        ctx->server->unsetIpBanned(ip_or_name);
        os<<L"-!- Unbanned "<<narrow_to_wide(desc);

        actionstream<<ctx->player->getName()<<" unbans "
                    <<ip_or_name<<std::endl;
    }
}
Example #5
0
void Client::sendChangePassword(const std::string &oldpassword,
        const std::string &newpassword)
{
	Player *player = m_env.getLocalPlayer();
	if (player == NULL)
		return;

	std::string playername = player->getName();
	if (m_proto_ver >= 25) {
		// get into sudo mode and then send new password to server
		m_password = oldpassword;
		m_new_password = newpassword;
		startAuth(choseAuthMech(m_sudo_auth_methods));
	} else {
		std::string oldpwd = translatePassword(playername, oldpassword);
		std::string newpwd = translatePassword(playername, newpassword);

		NetworkPacket pkt(TOSERVER_PASSWORD_LEGACY, 2 * PASSWORD_SIZE);

		for (u8 i = 0; i < PASSWORD_SIZE; i++) {
			pkt << (u8) (i < oldpwd.length() ? oldpwd[i] : 0);
		}

		for (u8 i = 0; i < PASSWORD_SIZE; i++) {
			pkt << (u8) (i < newpwd.length() ? newpwd[i] : 0);
		}
		Send(&pkt);
	}
}
Example #6
0
bool Party::invitePlayer(Player& player)
{
	if (isPlayerInvited(&player)) {
		return false;
	}

	std::ostringstream ss;
	ss << player.getName() << " has been invited.";

	if (memberList.empty() && inviteList.empty()) {
		ss << " Open the party channel to communicate with your members.";
		g_game.updatePlayerShield(leader);
		leader->sendCreatureSkull(leader);
	}

	leader->sendTextMessage(MESSAGE_INFO_DESCR, ss.str());

	inviteList.push_back(&player);

	for (Player* member : memberList) {
		g_game.updatePlayerHelpers(*member);
	}
	g_game.updatePlayerHelpers(*leader);

	leader->sendCreatureShield(&player);
	player.sendCreatureShield(leader);

	player.addPartyInvitation(this);

	ss.str(std::string());
	ss << leader->getName() << " has invited you to " << (leader->getSex() == PLAYERSEX_FEMALE ? "her" : "his") << " party.";
	player.sendTextMessage(MESSAGE_INFO_DESCR, ss.str());
	return true;
}
Example #7
0
void cmd_privs(std::wostringstream &os,
               ServerCommandContext *ctx)
{
    if(ctx->parms.size() == 1)
    {
        // Show our own real privs, without any adjustments
        // made for admin status
        os<<L"-!- " + narrow_to_wide(privsToString(
                                         ctx->server->getPlayerAuthPrivs(ctx->player->getName())));
        return;
    }

    if((ctx->privs & PRIV_PRIVS) == 0)
    {
        os<<L"-!- You don't have permission to do that";
        return;
    }

    Player *tp = ctx->env->getPlayer(wide_to_narrow(ctx->parms[1]).c_str());
    if(tp == NULL)
    {
        os<<L"-!- No such player";
        return;
    }

    os<<L"-!- " + narrow_to_wide(privsToString(ctx->server->getPlayerAuthPrivs(tp->getName())));
}
Example #8
0
bool
ServerRoom::getChairInfo( unsigned int  chairIndex,
                          std::string&  name,           // output
                          bool&         isBot,          // output
                          ChairState&   state,          // output
                          unsigned int& packsQueued,    // output
                          unsigned int& ticksRemaining  /* output */ ) const
{
    if( chairIndex < mChairCount )
    {
        Player* player = mPlayerList[chairIndex];
        state = mChairStateList[chairIndex];
        if( player != nullptr )
        {
            name = player->getName();
            isBot = mBotList.contains( (BotPlayer*)player );
            packsQueued = mDraftPtr->getPackQueueSize( chairIndex );
            ticksRemaining = mDraftPtr->getTicksRemaining( chairIndex );
        }
        else
        {
            name.clear();
            isBot = false;
            packsQueued = 0;
            ticksRemaining = 0;
        }
        return true;
    }
    else
    {
        return false;
    }
}
Example #9
0
void House::cleanHouse() 
{	
	transferToDepot();
	
	PlayerVector to_kick;
	for(HouseTileList::iterator it = houseTiles.begin(); it != houseTiles.end(); ++it) {
		for(uint32_t i = 0; i < (*it)->getThingCount(); ++i) {
			Creature* creature = (*it)->__getThing(i)->getCreature();
			if(creature != NULL && creature->getPlayer()) {
				to_kick.push_back(creature->getPlayer());
			}
		}
	}
	while(to_kick.empty() == false) {
		Player* c = to_kick.back();
		to_kick.pop_back();
		kickPlayer(NULL, c->getName());
	}

	// we need to remove players from beds
	HouseBedItemList::iterator bit;
	for(bit = bedsList.begin(); bit != bedsList.end(); ++bit) {
		if((*bit)->getSleeper() != 0) {
			(*bit)->wakeUp(NULL);
		}
	}
}
void GameClient::lineRead(std::string s){
    std::cout<<"Accepting change: "<<s<<std::endl;
    std::stringstream ss;
    ss<<s;
    std::string str;
    ss>>str;
    
    if (str == "/object"){
        ss>>str;
        if (str == "player"){
            ss>>str; //str is now the ObjectID
            for (std::vector<Player*>::iterator it=players.begin(); it!=players.end(); it++){
                if ((*it)->getObjectID() == str){
                    (*it)->updateFromString(ss);
                    return;
                }
            }
            if (str == mainPlayer->getObjectID()){ //random crap
                std::cout<<"WHAT?!?!?!?\n";
                exit(0);
            }
            Player* p = new Player(&wl);
            p->setTextureManager(wl.getTextureManager());
            p->setTexturePrefix("cube_box");
            p->setObjectID(str);
            p->updateFromString(ss);
            players.push_back(p);
            std::cout<<"New player connected: "<<p->getName()<<std::endl;
        }else{
Example #11
0
//====================================
//PASS
//======================================
void Match::pass(Player *p)
{
    int randRating = Player::maxRating + 1;
    //cout << " Pass ";
    int passRoll =(rand()%randRating + 1) + p->getPass();
    Player* target = getTeammate(p);

    if(passRoll > 21)
    {
        //cout << "To " << target->getName() << endl;

        screen->updatePass(p, target);
        updateBall(target);
        setPlayerStatus(target);
        setPlayerStatus(p);
    }
    else
    {
        stringstream message ;
        message << p->getName() << " missed with a bad pass to " << target->getName();
        screen->updateMissPass(p, target);
        //cout << "Misses pass to " << target->getName() << " , Loose Ball!!" << endl;
        ball->drop();
        setMissPass(target->getPosX(), target->getPosY());
        setAllStatus();
    }
}
Example #12
0
void Match::printer()
{
    for(int i = 0; i < 10; i++)
    {
        Player p = *playersToMove[i];
        cout<<"NAME: " << p.getName() << " X: " << p.getPosX() << " Y: " << p.getPosY() << " STATUS: " << p.getStatus() << endl;
    }
}
Example #13
0
void GroupObject::broadcastDeltaResetAll()
{
    mMembersUpdateCount++;
    Message* baselineBody;

    gMessageFactory->StartMessage();

    // two updates : reset all & set master looter to the new leaders'id

    gMessageFactory->addUint16(2);
    gMessageFactory->addUint16(1);
    gMessageFactory->addUint32(1);
    gMessageFactory->addUint32(mMembersUpdateCount);
    gMessageFactory->addUint8(3); //reset all
    gMessageFactory->addUint16((uint16)mMembers.size());

    PlayerList::iterator listIt;
    Player* runningPlayer;

    listIt = mMembers.begin();
    while(listIt != mMembers.end())
    {
        runningPlayer = (Player*)(*listIt);

        gMessageFactory->addUint64(runningPlayer->getCharId());
        gMessageFactory->addString(runningPlayer->getName());

        ++listIt;
    }


    // modify part 6 (master looter id)
    gMessageFactory->addUint16(6);
    gMessageFactory->addUint64(mMasterLooter);

    baselineBody = gMessageFactory->EndMessage();

    Message* newMessage;

    gMessageFactory->StartMessage();
    gMessageFactory->addUint32(0x12862153); // deltas
    gMessageFactory->addUint64(mId);
    gMessageFactory->addUint32(0x47525550); // GRUP
    gMessageFactory->addUint8(6);

    gMessageFactory->addUint32(baselineBody->getSize());
    gMessageFactory->addData(baselineBody ->getData(), baselineBody->getSize());

    newMessage = gMessageFactory->EndMessage();

    gMessageFactory->DestroyMessage(baselineBody);

    // update counter need to match the amount of modifications we did here
    mMembersUpdateCount +=  mMembers.size();

    broadcastMessage(newMessage);
}
Example #14
0
void House::setHouseOwner(uint32_t guid)
{
	if(isLoaded && houseOwner == guid)
		return;

	isLoaded = true;

	if(houseOwner){
		//send items to depot
		transferToDepot();

		PlayerVector to_kick;
		 for(HouseTileList::iterator it = houseTiles.begin(); it != houseTiles.end(); ++it){
			 for(uint32_t i = 0; i < (*it)->getThingCount(); ++i){
				 Creature* creature = (*it)->__getThing(i)->getCreature();
				 if(creature != NULL && creature->getPlayer())
					 to_kick.push_back(creature->getPlayer());
			 }
		 }
		 while(to_kick.empty() == false) {
			 Player* c = to_kick.back();
			 to_kick.pop_back();
			 kickPlayer(NULL, c->getName());
		 }

		// we need to remove players from beds
		HouseBedItemList::iterator bit;
		for(bit = bedsList.begin(); bit != bedsList.end(); ++bit) {
			if((*bit)->getSleeper() != 0) {
				(*bit)->wakeUp(NULL);
			}
		}

		//clean access lists
		houseOwner = 0;
		setAccessList(SUBOWNER_LIST, "");
		setAccessList(GUEST_LIST, "");

		for(HouseDoorList::iterator it = doorList.begin(); it != doorList.end(); ++it){
			(*it)->setAccessList("");
		}

		//reset paid date
		paidUntil = 0;
		rentWarnings = 0;
	}

	std::string name;
	if(guid != 0 && IOPlayer::instance()->getNameByGuid(guid, name)){
		houseOwner = guid;
		houseOwnerName = name;
	}

	updateDoorDescription();
	setLastWarning(std::time(NULL)); //So the new owner has one day before he start the payment
}
Example #15
0
void GameManager::updateScreen(Player p)
{
	cout << "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n";

	cout << p.getName() << "\n\n";
	p.hand.print();

	cout << "\n\nTop Card: ";
	topCard.print();

	cout << "\n0-Pickup\n1-Draw\n2-Forfeit\nChoice: ";
}
Example #16
0
void Party::revokeInvitation(Player& player)
{
	std::ostringstream ss;
	ss << leader->getName() << " has revoked " << (leader->getSex() == PLAYERSEX_FEMALE ? "her" : "his") << " invitation.";
	player.sendTextMessage(MESSAGE_INFO_DESCR, ss.str());

	ss.str(std::string());
	ss << "Invitation for " << player.getName() << " has been revoked.";
	leader->sendTextMessage(MESSAGE_INFO_DESCR, ss.str());

	removeInvite(player);
}
Example #17
0
	void deal(Player& player, Deck& deck, int cardInt) {
		namespace con = JadedHoboConsole;
		
		player.hand.append(deck.cards[cardInt]);

		cout << "dealing "  << player.getName() << " a " 
			 << con::fg_red << deck.cards[cardInt].suit;
		if (deck.cards[cardInt].value == '0')
			cout << "10";
		else
			cout << deck.cards[cardInt].value;
		cout << con::fg_white << endl;
	}
Example #18
0
// set_inventory_formspec(self, formspec)
int ObjectRef::l_set_inventory_formspec(lua_State *L)
{
	NO_MAP_LOCK_REQUIRED;
	ObjectRef *ref = checkobject(L, 1);
	Player *player = getplayer(ref);
	if(player == NULL) return 0;
	std::string formspec = luaL_checkstring(L, 2);

	player->inventory_formspec = formspec;
	getServer(L)->reportInventoryFormspecModified(player->getName());
	lua_pushboolean(L, true);
	return 1;
}
Example #19
0
// get_player_name(self)
int ObjectRef::l_get_player_name(lua_State *L)
{
	NO_MAP_LOCK_REQUIRED;
	ObjectRef *ref = checkobject(L, 1);
	Player *player = getplayer(ref);
	if(player == NULL){
		lua_pushlstring(L, "", 0);
		return 1;
	}
	// Do it
	lua_pushstring(L, player->getName().c_str());
	return 1;
}
Example #20
0
GameScreenWidget::GameScreenWidget(QWidget *parent, Server *server, Client *client, bool isServer) :
    QWidget(parent), server(server), client(client), isServer(isServer), currentPlayerId(0), currentPlayerIndex(0), waitTurns(0), rankingPosition(1),requestTurns(0),
    ui(new Ui::GameScreenWidget)
{
	ui->setupUi(this);

    ui->Player3->setOrientation(OpponentCardsWidget::Orientation::Vertical);
    ui->Player4->setOrientation(OpponentCardsWidget::Orientation::Vertical);

    if (!isServer)
    {
        connect(client, SIGNAL(onDisconnected()), this, SLOT(onClientDisconnected()));
        connect(client, SIGNAL(onDataReceived(int,QString)), this, SLOT(onClientDataReceived(int,QString)));
        connect(client, SIGNAL(onError(QAbstractSocket::SocketError)), this, SLOT(onClientError(QAbstractSocket::SocketError)));
        ui->labelCurrentPlayer->setText(client->getPlayer()->getName());
        ui->labelPlayer2->hide();
        ui->labelPlayer3->hide();
        ui->labelPlayer4->hide();
        for (int i = 0; i < client->getOtherPlayers().size(); i++)
        {
            Player* p = client->getOtherPlayers().at(i);
            switch(i)
            {
            case 0:
                ui->labelPlayer2->show();
                ui->labelPlayer2->setText(p->getName());
                break;
            case 1:
                ui->labelPlayer3->show();
                ui->labelPlayer3->setText(p->getName());
                break;
            case 2:
                ui->labelPlayer4->show();
                ui->labelPlayer4->setText(p->getName());
                break;
            }
        }
    }
Example #21
0
Player* Map::getPlayer(std::string& name) const {
	LinkedList<Entity*>::Node* nNode = this->getFirstEntity();
	for (; nNode; nNode = nNode->getNextNode()) {
		Entity* entity = nNode->getValue();
		if (!entity || entity->getEntityType() != Entity::TYPE_PLAYER) {
			continue;
		}
		Player* curPlayer = dynamic_cast<Player*>(entity);
		if (curPlayer->getName().find(name) >= 0) {
			return curPlayer;
		}
	}
	return nullptr;
}
Example #22
0
bool Commands::exeCommand(Player& player, const std::string& cmd)
{
	std::string str_command;
	std::string str_param;

	std::string::size_type loc = cmd.find(' ', 0);
	if (loc != std::string::npos) {
		str_command = std::string(cmd, 0, loc);
		str_param = std::string(cmd, (loc + 1), cmd.size() - loc - 1);
	} else {
		str_command = cmd;
	}

	//find command
	auto it = commandMap.find(str_command);
	if (it == commandMap.end()) {
		return false;
	}

	Command* command = it->second;
	if (command->groupId > player.getGroup()->id || command->accountType > player.getAccountType()) {
		if (player.getGroup()->access) {
			player.sendTextMessage(MESSAGE_STATUS_SMALL, "You can not execute this command.");
		}

		return false;
	}

	//execute command
	CommandFunc cfunc = command->f;
	(this->*cfunc)(player, str_param);

	if (command->log) {
		player.sendTextMessage(MESSAGE_STATUS_CONSOLE_RED, cmd);

		std::ostringstream logFile;
		logFile << "data/logs/" << player.getName() << " commands.log";
		std::ofstream out(logFile.str(), std::ios::app);
		if (out.is_open()) {
			time_t ticks = time(nullptr);
			const tm* now = localtime(&ticks);
			char buf[32];
			strftime(buf, sizeof(buf), "%d/%m/%Y %H:%M", now);

			out << '[' << buf << "] " << cmd << std::endl;
			out.close();
		}
	}
	return true;
}
Example #23
0
bool Party::joinParty(Player& player)
{
	if (!g_events->eventPartyOnJoin(this, &player)) {
		return false;
	}

	auto it = std::find(inviteList.begin(), inviteList.end(), &player);
	if (it == inviteList.end()) {
		return false;
	}

	inviteList.erase(it);

	std::ostringstream ss;
	ss << player.getName() << " has joined the party.";
	broadcastPartyMessage(MESSAGE_INFO_DESCR, ss.str());

	player.setParty(this);

	g_game.updatePlayerShield(&player);

	for (Player* member : memberList) {
		member->sendCreatureSkull(&player);
		player.sendPlayerPartyIcons(member);
	}

	player.sendCreatureSkull(&player);
	leader->sendCreatureSkull(&player);
	player.sendPlayerPartyIcons(leader);

	memberList.push_back(&player);

	g_game.updatePlayerHelpers(player);

	player.removePartyInvitation(this);
	updateSharedExperience();
	updateVocationsList();

	const std::string& leaderName = leader->getName();
	ss.str(std::string());
	ss << "You have joined " << leaderName << "'" << (leaderName.back() == 's' ? "" : "s") <<
	   " party. Open the party channel to communicate with your companions.";
	player.sendTextMessage(MESSAGE_INFO_DESCR, ss.str());
	return true;
}
Example #24
0
File: game.cpp Project: brownwa/cpp
void Game::showTable() const {
  cout << endl << playerList[0].getName() << ": " << endl;
  playerList[0].showHand();
  cout << endl;

  // For some reason the g++ compiler optimizes the 
  // Player array playerList in a way that breaks referencing
  // Player members. For this reason, each player must be
  // copied from the playerList heap to the stack as a player
  // in order to be referenced without causing a segmentation
  // fault when cout is called.
  Player p;
  for(int i = 1; i < numPlayers; ++i) {
    p = playerList[i];
    cout << endl << "Player " << i << ": " << p.getName();
    cout << endl;
    p.showHand();
    cout << endl;
  }
  cout << endl;
}
Example #25
0
void userInfo(Player &p1){
    string p1name;                      //take input for player's name
    string pass;                        //player input for password
    string fName;                       //holds file name
    fstream myFile;                     //to output player info to file
    size_t pwhash;                      //holds password hash
    int funds, wins, losses, pushes;    //holds funds, wins, losses, pushes
    unsigned int seed=0;
    unsigned hash=seed;
    
    //prompt for user info
    cout<<"Enter a user ID (if new, will be created): "<<endl;
    cin>>p1name;
    
    //attempt to open file based on given ID
    fName=p1name+".txt";
    myFile.open(fName.c_str());
    
    //check to see if file was opened
    if(!myFile.is_open()){
        //if file not opened, create new user
        cout<<"ID not recognized, creating new user."<<endl;
        p1.setName(p1name);
        cout<<"Enter a password: ";
        cin>>pass;
        
        //Hash user's password and store this for future log in comparison
        p1.hash(pass);
        
        //create file based on player name
        myFile.open(fName.c_str());
        
        //write player info to file to store for later use
        myFile<<p1.getName()<<"\r\n";
        myFile<<p1.getHash()<<"\r\n";
        myFile<<p1.getFunds()<<"\r\n";
        myFile<<p1.getWins()<<"\r\n";
        myFile<<p1.getLosses()<<"\r\n";
        myFile<<p1.getPushes()<<"\r\n";
    }
Example #26
0
void Window::updatePlayers()
{
	Game* g = Game::instance();
	Player *p = Game::getPuckHolder();
	Player *h = g->getHomeTeamPlayers(), *a = g->getAwayTeamPlayers();

	// Get positions of the green players
	Math::Vector2D<double> greenPos = h->getPosition();

	// Get positions of the blue players
	Math::Vector2D<double> bluePos = a->getPosition();
	
	// Set up new positions
	blueRect.x = floor(bluePos.x) - withPuck.w/2; blueRect.y = floor(bluePos.y) - withPuck.h/2;
	blueNameRect.x = blueRect.x; blueNameRect.y = withPuck.h + blueRect.y;
	greenRect.x = floor(greenPos.x) - withPuck.w/2; greenRect.y = floor(greenPos.y) - withPuck.h/2;
	greenNameRect.x = greenRect.x; greenNameRect.y = withPuck.h + greenRect.y;

	// Blit surfaces
	if (p == h)
	{
		SDL_BlitSurface(greenPlayer, &withPuck, mainSurface, &greenRect);
		SDL_BlitSurface(bluePlayer, &withoutPuck, mainSurface, &blueRect);
	}
	else if (p == a)
	{
		SDL_BlitSurface(greenPlayer, &withoutPuck, mainSurface, &greenRect);
		SDL_BlitSurface(bluePlayer, &withPuck, mainSurface, &blueRect);
	}
	else
	{
		SDL_BlitSurface(greenPlayer, &withoutPuck, mainSurface, &greenRect);
		SDL_BlitSurface(bluePlayer, &withoutPuck, mainSurface, &blueRect);
	}

	// Render the player names
	drawText(&blueNameRect, nameFont, a->getName().c_str());
	drawText(&greenNameRect, nameFont, h->getName().c_str());
}
Example #27
0
void announceWinner(Player& player) {
	namespace con = JadedHoboConsole;
	cout << con::fg_green << player.getName() << " WINS!" << con::fg_white << endl;
}
Example #28
0
void GroupObject::sendBaseline(Player* player)
{
    // first we create the baseline data
    Message* baselineBody;

    gMessageFactory->StartMessage();
    gMessageFactory->addUint16(8);
    gMessageFactory->addUint32(63);
    gMessageFactory->addUint32(mMembers.size());
    gMessageFactory->addUint32(mMembersUpdateCount);

    //1. Player List
    PlayerList::iterator listIt = mMembers.begin();
    Player* runningPlayer;

    // adding every player id and name
    while(listIt != mMembers.end())
    {
        runningPlayer = (Player*)(*listIt);

        gMessageFactory->addUint64(runningPlayer->getCharId());
        gMessageFactory->addString(runningPlayer->getName());

        ++listIt;
    }

    //2. Player Missions
    gMessageFactory->addUint32(mMembers.size());
    gMessageFactory->addUint32(mMembersUpdateCount);

    listIt = mMembers.begin();

    while(listIt != mMembers.end())
    {
        runningPlayer = (Player*)(*listIt);

        gMessageFactory->addUint64(0);
        gMessageFactory->addUint32(0);

        ++listIt;
    }

    //3. Group Options
    gMessageFactory->addUint16(0);
    gMessageFactory->addUint16(9);
    gMessageFactory->addUint32(4);
    gMessageFactory->addUint64(mMasterLooter); // master looter
    gMessageFactory->addUint32(mLootMode); //loot rule

    baselineBody = gMessageFactory->EndMessage();

    // Now crafting the baseline header
    Message* newMessage;

    gMessageFactory->StartMessage();
    gMessageFactory->addUint32(0x68A75F0C); // baseline
    gMessageFactory->addUint64(mId);
    gMessageFactory->addUint32(0x47525550); // GRUP
    gMessageFactory->addUint8(6);

    // adding the baselines body to it
    gMessageFactory->addUint32(baselineBody->getSize());
    gMessageFactory->addData(baselineBody ->getData(), baselineBody->getSize());

    newMessage = gMessageFactory->EndMessage();

    gMessageFactory->DestroyMessage(baselineBody);

    player->getClient()->SendChannelA(newMessage, player->getClient()->getAccountId(), CR_Client, 5);

}
Example #29
0
bool Team::isPlayerInTeam(Player const& player)
{
    return (_players.front()->getName() == player.getName() || _players.back()->getName() == player.getName());
}
bool ConditionRegeneration::executeCondition(Creature* creature, int32_t interval)
{
	internalHealthTicks += interval;
	internalManaTicks += interval;

	if (creature->getZone() == ZONE_PROTECTION) {
		return ConditionGeneric::executeCondition(creature, interval);
	}

	if (internalHealthTicks >= healthTicks) {
		internalHealthTicks = 0;

		int32_t realHealthGain = creature->getHealth();
		creature->changeHealth(healthGain);
		realHealthGain = creature->getHealth() - realHealthGain;

		if (isBuff && realHealthGain > 0) {
			Player* player = creature->getPlayer();
			if (player) {
				std::string healString = std::to_string(realHealthGain) + (realHealthGain != 1 ? " hitpoints." : " hitpoint.");

				TextMessage message(MESSAGE_HEALED, "You were healed for " + healString);
				message.position = player->getPosition();
				message.primary.value = realHealthGain;
				message.primary.color = TEXTCOLOR_MAYABLUE;
				player->sendTextMessage(message);

				SpectatorHashSet spectators;
				g_game.map.getSpectators(spectators, player->getPosition(), false, true);
				spectators.erase(player);
				if (!spectators.empty()) {
					message.type = MESSAGE_HEALED_OTHERS;
					message.text = player->getName() + " was healed for " + healString;
					for (Creature* spectator : spectators) {
						spectator->getPlayer()->sendTextMessage(message);
					}
				}
			}
		}
	}

	if (internalManaTicks >= manaTicks) {
		internalManaTicks = 0;

		if (Player* player = creature->getPlayer()) {
			int32_t realManaGain = player->getMana();
			player->changeMana(manaGain);
			realManaGain = player->getMana() - realManaGain;

			if (isBuff && realManaGain > 0) {
				std::string manaGainString = std::to_string(realManaGain);

				TextMessage message(MESSAGE_HEALED, "You gained " + manaGainString + " mana.");
				message.position = player->getPosition();
				message.primary.value = realManaGain;
				message.primary.color = TEXTCOLOR_MAYABLUE;
				player->sendTextMessage(message);

				SpectatorHashSet spectators;
				g_game.map.getSpectators(spectators, player->getPosition(), false, true);
				spectators.erase(player);
				if (!spectators.empty()) {
					message.type = MESSAGE_HEALED_OTHERS;
					message.text = player->getName() + " gained " + manaGainString + " mana.";
					for (Creature* spectator : spectators) {
						spectator->getPlayer()->sendTextMessage(message);
					}
				}
			}
		}
	}

	return ConditionGeneric::executeCondition(creature, interval);
}