This commit is contained in:
2022-11-27 16:20:24 -08:00
parent e8a289c00f
commit 7f60b58b9d
4 changed files with 23 additions and 5 deletions

View File

@ -22,7 +22,6 @@ namespace Dawn {
std::vector<struct Card> deck; std::vector<struct Card> deck;
std::vector<struct Card> grave; std::vector<struct Card> grave;
std::vector<struct Card> community; std::vector<struct Card> community;
std::vector<struct PokerPot> pots;
uint8_t dealerIndex; uint8_t dealerIndex;
uint8_t smallBlindIndex; uint8_t smallBlindIndex;
uint8_t bigBlindIndex; uint8_t bigBlindIndex;
@ -31,6 +30,7 @@ namespace Dawn {
public: public:
std::vector<PokerPlayer*> players; std::vector<PokerPlayer*> players;
std::vector<struct PokerPot> pots;
uint8_t betterIndex; uint8_t betterIndex;
PokerGame(SceneItem *item); PokerGame(SceneItem *item);

View File

@ -13,7 +13,7 @@ void PokerPotWinning::award() {
auto it = this->winners.begin(); auto it = this->winners.begin();
while(it != this->winners.end()) { while(it != this->winners.end()) {
if(it == this->winners.begin()) { if(it == this->winners.begin()) {
(*it)->addChips(this->chipsOverflow); (*it)->addChips(this->chipsEach + this->chipsOverflow);
} else { } else {
(*it)->addChips(this->chipsEach); (*it)->addChips(this->chipsEach);
} }
@ -102,9 +102,9 @@ struct PokerPotWinning PokerPot::getWinners(PokerGame *game) {
++it2; ++it2;
} }
winning.chipsEach = this->chips / winning.winners.size(); winning.chipsEach = this->chips / (int32_t)winning.winners.size();
winning.chipsOverflow = this->chips - ( winning.chipsOverflow = this->chips - (
winning.chipsEach * winning.winners.size() winning.chipsEach * (int32_t)winning.winners.size()
); );
return winning; return winning;

View File

@ -5,6 +5,7 @@
#pragma once #pragma once
#include "PokerGameEvent.hpp" #include "PokerGameEvent.hpp"
#include "poker/PokerPot.hpp"
namespace Dawn { namespace Dawn {
class PokerWinnerEvent : public PokerGameEvent { class PokerWinnerEvent : public PokerGameEvent {
@ -12,6 +13,21 @@ namespace Dawn {
void onStart(IVisualNovelEvent *previous) override { void onStart(IVisualNovelEvent *previous) override {
PokerGameEvent::onStart(previous); PokerGameEvent::onStart(previous);
std::cout << "Poker Winning" << std::endl; 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 { bool_t onUpdate() override {
@ -22,6 +38,8 @@ namespace Dawn {
} }
public: public:
std::map<struct PokerPot*, struct PokerPotWinning> winnings;
PokerWinnerEvent(VisualNovelManager *manager) : PokerGameEvent(manager) { PokerWinnerEvent(VisualNovelManager *manager) : PokerGameEvent(manager) {
} }
}; };