//called when roll timer expires void Group::EndRoll() { vector<Roll>::iterator itr; while(!RollId.empty()) { //need more testing here, if rolls disappear itr = RollId.begin(); CountTheRoll(itr, m_members.size()); //i don't have to edit player votes, who didn't vote ... he will pass } }
void Group::CountRollVote(uint64 playerGUID, uint64 Guid, uint32 NumberOfPlayers, uint8 Choise) { vector<Roll>::iterator roll = GetRoll(Guid); if (roll == RollId.end()) return; map<uint64, RollVote>::iterator itr = roll->playerVote.find(playerGUID); // this condition means that player joins to the party after roll begins if (itr == roll->playerVote.end()) return; if (roll->loot) if (roll->loot->items.size() == 0) return; switch (Choise) { case 0: //Player choose pass { SendLootRoll(0, playerGUID, 128, 128, *roll); roll->totalPass++; itr->second = PASS; } break; case 1: //player choose Need { SendLootRoll(0, playerGUID, 1, 1, *roll); roll->totalNeed++; itr->second = NEED; } break; case 2: //player choose Greed { SendLootRoll(0, playerGUID, 2, 2, *roll); roll->totalGreed++; itr->second = GREED; } break; } if (roll->totalPass + roll->totalGreed + roll->totalNeed >= roll->totalPlayersRolling) { CountTheRoll(roll, NumberOfPlayers); } }
void Group::_removeRolls(const uint64 &guid) { vector<Roll>::iterator it; for (it = RollId.begin(); it < RollId.end(); it++) { map<uint64, RollVote>::iterator itr2 = it->playerVote.find(guid); if(itr2 == it->playerVote.end()) continue; if (itr2->second == GREED) it->totalGreed--; if (itr2->second == NEED) it->totalNeed--; if (itr2->second == PASS) it->totalPass--; if (itr2->second != NOT_VALID) it->totalPlayersRolling--; it->playerVote.erase(itr2); CountTheRoll(guid, it->itemGUID, m_members.size()-1, 3); } }