Winning2
This commit is contained in:
src/dawn/poker
@ -22,7 +22,6 @@ namespace Dawn {
|
||||
std::vector<struct Card> deck;
|
||||
std::vector<struct Card> grave;
|
||||
std::vector<struct Card> community;
|
||||
std::vector<struct PokerPot> pots;
|
||||
uint8_t dealerIndex;
|
||||
uint8_t smallBlindIndex;
|
||||
uint8_t bigBlindIndex;
|
||||
@ -31,6 +30,7 @@ namespace Dawn {
|
||||
|
||||
public:
|
||||
std::vector<PokerPlayer*> players;
|
||||
std::vector<struct PokerPot> pots;
|
||||
uint8_t betterIndex;
|
||||
|
||||
PokerGame(SceneItem *item);
|
||||
|
@ -16,7 +16,7 @@ void PokerPlayer::onStart() {
|
||||
SceneItemComponent::onStart();
|
||||
|
||||
this->pokerGame = this->getScene()->findComponent<PokerGame>();
|
||||
assertNotNull(this->pokerGame);
|
||||
assertNotNull(this->pokerGame);
|
||||
}
|
||||
|
||||
void PokerPlayer::addChips(int32_t chips) {
|
||||
|
@ -13,7 +13,7 @@ void PokerPotWinning::award() {
|
||||
auto it = this->winners.begin();
|
||||
while(it != this->winners.end()) {
|
||||
if(it == this->winners.begin()) {
|
||||
(*it)->addChips(this->chipsOverflow);
|
||||
(*it)->addChips(this->chipsEach + this->chipsOverflow);
|
||||
} else {
|
||||
(*it)->addChips(this->chipsEach);
|
||||
}
|
||||
@ -102,9 +102,9 @@ struct PokerPotWinning PokerPot::getWinners(PokerGame *game) {
|
||||
++it2;
|
||||
}
|
||||
|
||||
winning.chipsEach = this->chips / winning.winners.size();
|
||||
winning.chipsEach = this->chips / (int32_t)winning.winners.size();
|
||||
winning.chipsOverflow = this->chips - (
|
||||
winning.chipsEach * winning.winners.size()
|
||||
winning.chipsEach * (int32_t)winning.winners.size()
|
||||
);
|
||||
|
||||
return winning;
|
||||
|
@ -5,6 +5,7 @@
|
||||
|
||||
#pragma once
|
||||
#include "PokerGameEvent.hpp"
|
||||
#include "poker/PokerPot.hpp"
|
||||
|
||||
namespace Dawn {
|
||||
class PokerWinnerEvent : public PokerGameEvent {
|
||||
@ -12,6 +13,21 @@ namespace Dawn {
|
||||
void onStart(IVisualNovelEvent *previous) override {
|
||||
PokerGameEvent::onStart(previous);
|
||||
std::cout << "Poker Winning" << std::endl;
|
||||
|
||||
// Calculate
|
||||
auto it = this->pokerGame->pots.begin();
|
||||
while(it != this->pokerGame->pots.end()) {
|
||||
auto pot = &(*it);
|
||||
this->winnings[pot] = pot->getWinners(this->pokerGame);
|
||||
++it;
|
||||
}
|
||||
|
||||
// Award
|
||||
auto it2 = this->winnings.begin();
|
||||
while(it2 != this->winnings.end()) {
|
||||
it2->second.award();
|
||||
it2++;
|
||||
}
|
||||
}
|
||||
|
||||
bool_t onUpdate() override {
|
||||
@ -22,6 +38,8 @@ namespace Dawn {
|
||||
}
|
||||
|
||||
public:
|
||||
std::map<struct PokerPot*, struct PokerPotWinning> winnings;
|
||||
|
||||
PokerWinnerEvent(VisualNovelManager *manager) : PokerGameEvent(manager) {
|
||||
}
|
||||
};
|
||||
|
Reference in New Issue
Block a user