Fixed some bugs with AI

This commit is contained in:
2022-11-26 14:31:06 -08:00
parent c1ac69a146
commit c1d6885970
25 changed files with 245 additions and 119 deletions

View File

@ -5,7 +5,7 @@
# Check for build target, or default # Check for build target, or default
if(WIN32) if(WIN32)
set(DAWN_BUILD_HOST "") set(DAWN_BUILD_HOST "build-host-win32")
elseif(UNIX AND NOT APPLE) elseif(UNIX AND NOT APPLE)
set(DAWN_BUILD_HOST "build-host-linux64") set(DAWN_BUILD_HOST "build-host-linux64")
endif() endif()

View File

@ -0,0 +1,6 @@
# Copyright (c) 2022 Dominic Masters
#
# This software is released under the MIT License.
# https://opensource.org/licenses/MIT
set(DAWN_BUILD_HOST_LIBS "" CACHE INTERNAL ${DAWN_CACHE_TARGET})

View File

@ -26,12 +26,12 @@ namespace Dawn {
uint8_t dealerIndex; uint8_t dealerIndex;
uint8_t smallBlindIndex; uint8_t smallBlindIndex;
uint8_t bigBlindIndex; uint8_t bigBlindIndex;
uint8_t betterIndex;
int32_t smallBlind = POKER_BLIND_SMALL_DEFAULT; int32_t smallBlind = POKER_BLIND_SMALL_DEFAULT;
int32_t bigBlind = POKER_BLIND_BIG_DEFAULT; int32_t bigBlind = POKER_BLIND_BIG_DEFAULT;
public: public:
std::vector<PokerPlayer*> players; std::vector<PokerPlayer*> players;
uint8_t betterIndex;
PokerGame(SceneItem *item); PokerGame(SceneItem *item);

View File

@ -42,7 +42,11 @@ void PokerPlayer::bet(struct PokerPot *pot, int32_t chips) {
this->chips -= chips; this->chips -= chips;
this->currentBet += chips; this->currentBet += chips;
this->hasBetThisRound = true; this->hasBetThisRound = true;
if(chips > 0) this->timesRaised++; if(chips > 0) {
this->timesRaised++;
} else {
this->timesRaised = 0;
}
pot->chips += chips; pot->chips += chips;
pot->call = mathMax<int32_t>(pot->call, this ->currentBet); pot->call = mathMax<int32_t>(pot->call, this ->currentBet);
@ -56,6 +60,12 @@ void PokerPlayer::bet(int32_t chips) {
this->bet(&this->pokerGame->pots.back(), chips); this->bet(&this->pokerGame->pots.back(), chips);
} }
void PokerPlayer::fold() {
this->isFolded = true;
this->hasBetThisRound = true;
this->timesRaised = 0;
}
bool_t PokerPlayer::canCheck() { bool_t PokerPlayer::canCheck() {
return this->pokerGame->getCurrentCallValue() <= this->currentBet; return this->pokerGame->getCurrentCallValue() <= this->currentBet;
} }
@ -96,7 +106,7 @@ struct PokerTurn PokerPlayer::getAITurn() {
); );
// Get card weight // Get card weight
float_t confidence = (float_t)cardNumber0 + (float_t)cardNumber1; confidence = (float_t)cardNumber0 + (float_t)cardNumber1;
if(cardNumber0 == cardNumber1) {// Pairs if(cardNumber0 == cardNumber1) {// Pairs
confidence += 6; confidence += 6;
} else if(suitNumber0 == suitNumber1) {// Same suit } else if(suitNumber0 == suitNumber1) {// Same suit
@ -214,7 +224,7 @@ struct PokerTurn PokerPlayer::getAITurn() {
turn = PokerTurn::bet(this, 0); turn = PokerTurn::bet(this, 0);
turn.confidence = 1; turn.confidence = 1;
} else { } else {
turn = PokerTurn::fold(); turn = PokerTurn::fold(this);
turn.confidence = 1 - confidence; turn.confidence = 1 - confidence;
} }

View File

@ -76,6 +76,11 @@ namespace Dawn {
*/ */
void bet(int32_t amount); void bet(int32_t amount);
/**
* Player folds.
*/
void fold();
/** /**
* Returns the AI result for a turn done by a non human player. * Returns the AI result for a turn done by a non human player.
* *

View File

@ -16,6 +16,7 @@ struct PokerTurn PokerTurn::bet(PokerPlayer *player, int32_t chips) {
assertNotNull(player); assertNotNull(player);
assertTrue(chips >= 0); assertTrue(chips >= 0);
turn.player = player;
turn.confidence = 1; turn.confidence = 1;
if(chips == 0) { if(chips == 0) {
@ -37,10 +38,35 @@ struct PokerTurn PokerTurn::bet(PokerPlayer *player, int32_t chips) {
return turn; return turn;
} }
struct PokerTurn PokerTurn::fold() { struct PokerTurn PokerTurn::fold(PokerPlayer *player) {
struct PokerTurn turn; struct PokerTurn turn;
turn.player = player;
turn.chips = 0; turn.chips = 0;
turn.confidence = 1; turn.confidence = 1;
turn.type = POKER_TURN_TYPE_FOLD; turn.type = POKER_TURN_TYPE_FOLD;
return turn; return turn;
}
void PokerTurn::action() {
assertNotNull(this->player);
switch(this->type) {
case POKER_TURN_TYPE_BET:
case POKER_TURN_TYPE_CALL:
case POKER_TURN_TYPE_ALL_IN:
this->player->bet(this->chips);
break;
case POKER_TURN_TYPE_CHECK:
player->bet(0);
break;
case POKER_TURN_TYPE_FOLD:
player->fold();
break;
default:
assertUnreachable();
break;
}
} }

View File

@ -26,6 +26,8 @@ namespace Dawn {
int32_t chips; int32_t chips;
/** How confident the AI is about their turn. 0 = none, 1 = full */ /** How confident the AI is about their turn. 0 = none, 1 = full */
float_t confidence; float_t confidence;
/** Player that this action belongs to */
PokerPlayer *player;
/** /**
* Generate a turn action for betting as a player. * Generate a turn action for betting as a player.
@ -41,6 +43,11 @@ namespace Dawn {
* *
* @return A turn for a fold action. * @return A turn for a fold action.
*/ */
static struct PokerTurn fold(); static struct PokerTurn fold(PokerPlayer *player);
/**
* Actions / Performs this turn against the defined player.
*/
void action();
}; };
} }

View File

@ -9,14 +9,16 @@
#define POKER_DEAL_EVENT_CARD_COUNT 2 #define POKER_DEAL_EVENT_CARD_COUNT 2
namespace Dawn { namespace Dawn {
class PokerDealEvent : public PokerGameEvent { class PokerAIBetEvent : public PokerGameEvent {
protected: protected:
void onStart() override { void onStart(IVisualNovelEvent *previous) override {
PokerGameEvent::onStart(); PokerGameEvent::onStart(previous);
auto better = this->pokerGame->getNextBetterIndex(); auto better = this->pokerGame->getNextBetterIndex();
this->pokerGame->better = better; this->pokerGame->betterIndex = better;
auto player = this->pokerGame->players[better]; auto player = this->pokerGame->players[better];
this->turn = player->getAITurn();
this->turn.action();
} }
bool_t onUpdate() override { bool_t onUpdate() override {
@ -28,8 +30,9 @@ namespace Dawn {
public: public:
uint8_t better; uint8_t better;
struct PokerTurn turn;
PokerDealEvent(VisualNovelManager *manager) : PokerGameEvent(manager) { PokerAIBetEvent(VisualNovelManager *manager) : PokerGameEvent(manager) {
} }
}; };
} }

View File

@ -11,8 +11,9 @@
namespace Dawn { namespace Dawn {
class PokerDealEvent : public PokerGameEvent { class PokerDealEvent : public PokerGameEvent {
protected: protected:
void onStart() override { void onStart(IVisualNovelEvent *previous) override {
PokerGameEvent::onStart(); PokerGameEvent::onStart(previous);
std::cout << "Dealing to everyone" << std::endl;
this->pokerGame->dealToEveryone(POKER_DEAL_EVENT_CARD_COUNT); this->pokerGame->dealToEveryone(POKER_DEAL_EVENT_CARD_COUNT);
} }

View File

@ -10,32 +10,44 @@ using namespace Dawn;
PokerDetermineBetterEvent::PokerDetermineBetterEvent(VisualNovelManager *man) : PokerDetermineBetterEvent::PokerDetermineBetterEvent(VisualNovelManager *man) :
PokerGameEvent(man) PokerGameEvent(man)
{ {
std::cout << "Inited determine better" << std::endl << std::endl;
} }
void PokerDetermineBetterEvent::onStart() { void PokerDetermineBetterEvent::onStart(IVisualNovelEvent *previous) {
PokerGameEvent::onStart(); PokerGameEvent::onStart(previous);
std::cout << "better evt" << std::endl;
if(this->pokerGame->getRemainingPlayersCount() <= 1) { if(this->pokerGame->getRemainingPlayersCount() <= 1) {
this->doNext = this->eventEveryoneFolded; this->then(this->eventEveryoneFolded);
this->eventEveryoneFolded = nullptr;
std::cout << "Everyone folded" << std::endl;
return; return;
} }
uint8_t nextBetterIndex = this->pokerGame->getNextBetterIndex(); uint8_t nextBetterIndex = this->pokerGame->getNextBetterIndex();
if(nextBetterIndex == 0xFF) { if(nextBetterIndex == 0xFF) {
if(this->pokerGame->getCountOfCardsToTurn() == 0xFF) { if(this->pokerGame->getCountOfCardsToTurn() == 0xFF) {
this->doNext = this->eventBettingFinished; this->then(this->eventBettingFinished);
this->eventBettingFinished = nullptr;
std::cout << "Betting Finished" << std::endl;
} else { } else {
this->doNext = this->eventTurn; this->then(this->eventTurn);
this->eventTurn = nullptr;
std::cout << "Turn Time?" << std::endl;
} }
return; return;
} }
auto nextBetter = this->pokerGame->players[nextBetterIndex]; auto nextBetter = this->pokerGame->players[nextBetterIndex];
if(nextBetter->isHuman) { if(nextBetter->isHuman) {
this->doNext = this->eventHumanBet; this->then(this->eventHumanBet);
this->eventHumanBet = nullptr;
std::cout << "Human Better" << std::endl;
} else { } else {
this->doNext = this->eventAiBet; this->then(this->eventAiBet);
this->eventAiBet = nullptr;
std::cout << "AI Better" << std::endl;
} }
} }
@ -47,28 +59,9 @@ void PokerDetermineBetterEvent::onEnd() {
} }
PokerDetermineBetterEvent::~PokerDetermineBetterEvent() { PokerDetermineBetterEvent::~PokerDetermineBetterEvent() {
if( if(this->eventEveryoneFolded != nullptr) delete this->eventEveryoneFolded;
this->eventEveryoneFolded != nullptr && if(this->eventBettingFinished != nullptr) delete this->eventBettingFinished;
this->eventEveryoneFolded != this->doNext if(this->eventTurn != nullptr) delete this->eventTurn;
) delete this->eventEveryoneFolded; if(this->eventAiBet != nullptr) delete this->eventAiBet;
if(this->eventHumanBet != nullptr) delete this->eventHumanBet;
if(
this->eventBettingFinished != nullptr &&
this->eventBettingFinished != this->doNext
) delete this->eventBettingFinished;
if(
this->eventTurn != nullptr &&
this->eventTurn != this->doNext
) delete this->eventTurn;
if(
this->eventAiBet != nullptr &&
this->eventAiBet != this->doNext
) delete this->eventAiBet;
if(
this->eventHumanBet != nullptr &&
this->eventHumanBet != this->doNext
) delete this->eventHumanBet;
} }

View File

@ -15,7 +15,7 @@ namespace Dawn {
IVisualNovelEvent * eventAiBet = nullptr; IVisualNovelEvent * eventAiBet = nullptr;
IVisualNovelEvent * eventHumanBet = nullptr; IVisualNovelEvent * eventHumanBet = nullptr;
void onStart() override; void onStart(IVisualNovelEvent *previous) override;
bool_t onUpdate() override; bool_t onUpdate() override;
void onEnd() override; void onEnd() override;
@ -37,7 +37,6 @@ namespace Dawn {
T * whenEveryoneFolded(T *event) { T * whenEveryoneFolded(T *event) {
assertNotNull(event); assertNotNull(event);
this->eventEveryoneFolded = event; this->eventEveryoneFolded = event;
event->previous = this;
return event; return event;
} }
@ -51,7 +50,6 @@ namespace Dawn {
T * whenBettingFinished(T *event) { T * whenBettingFinished(T *event) {
assertNotNull(event); assertNotNull(event);
this->eventBettingFinished = event; this->eventBettingFinished = event;
event->previous = this;
return event; return event;
} }
@ -66,7 +64,6 @@ namespace Dawn {
T * whenTurn(T *event) { T * whenTurn(T *event) {
assertNotNull(event); assertNotNull(event);
this->eventTurn = event; this->eventTurn = event;
event->previous = this;
return event; return event;
} }
@ -80,7 +77,6 @@ namespace Dawn {
T * whenAiBet(T *event) { T * whenAiBet(T *event) {
assertNotNull(event); assertNotNull(event);
this->eventAiBet = event; this->eventAiBet = event;
event->previous = this;
return event; return event;
} }
@ -94,7 +90,6 @@ namespace Dawn {
T * whenHumanBet(T *event) { T * whenHumanBet(T *event) {
assertNotNull(event); assertNotNull(event);
this->eventHumanBet = event; this->eventHumanBet = event;
event->previous = this;
return event; return event;
} }

View File

@ -12,7 +12,7 @@ namespace Dawn {
protected: protected:
PokerGame *pokerGame; PokerGame *pokerGame;
void onStart() override { void onStart(IVisualNovelEvent *previous) override {
pokerGame = this->manager->getScene()->findComponent<PokerGame>(); pokerGame = this->manager->getScene()->findComponent<PokerGame>();
assertNotNull(pokerGame); assertNotNull(pokerGame);
} }

View File

@ -9,8 +9,9 @@
namespace Dawn { namespace Dawn {
class PokerNewGameEvent : public PokerGameEvent { class PokerNewGameEvent : public PokerGameEvent {
protected: protected:
void onStart() override { void onStart(IVisualNovelEvent *previous) override {
PokerGameEvent::onStart(); PokerGameEvent::onStart(previous);
std::cout << "New Game" << std::endl;
this->pokerGame->newGame(); this->pokerGame->newGame();
} }

View File

@ -9,8 +9,9 @@
namespace Dawn { namespace Dawn {
class PokerNewRoundEvent : public PokerGameEvent { class PokerNewRoundEvent : public PokerGameEvent {
protected: protected:
void onStart() override { void onStart(IVisualNovelEvent *previous) override {
PokerGameEvent::onStart(); PokerGameEvent::onStart(previous);
std::cout << "New Round" << std::endl;
this->pokerGame->newRound(); this->pokerGame->newRound();
} }

View File

@ -9,8 +9,9 @@
namespace Dawn { namespace Dawn {
class PokerTakeBlindsEvent : public PokerGameEvent { class PokerTakeBlindsEvent : public PokerGameEvent {
protected: protected:
void onStart() override { void onStart(IVisualNovelEvent *previous) override {
PokerGameEvent::onStart(); PokerGameEvent::onStart(previous);
std::cout << "Take Blinds" << std::endl;
this->pokerGame->takeBlinds(); this->pokerGame->takeBlinds();
} }

View File

@ -9,8 +9,8 @@
namespace Dawn { namespace Dawn {
class PokerTurnEvent : public PokerGameEvent { class PokerTurnEvent : public PokerGameEvent {
protected: protected:
void onStart() override { void onStart(IVisualNovelEvent *previous) override {
PokerGameEvent::onStart(); PokerGameEvent::onStart(previous);
this->cardsTurned = this->pokerGame->getCountOfCardsToTurn(); this->cardsTurned = this->pokerGame->getCountOfCardsToTurn();
assertTrue(this->cardsTurned != 0xFF); assertTrue(this->cardsTurned != 0xFF);

View File

@ -10,15 +10,6 @@ using namespace Dawn;
UIBorder::UIBorder(UICanvas *canvas) : UIComponent(canvas) { UIBorder::UIBorder(UICanvas *canvas) : UIComponent(canvas) {
this->mesh.createBuffers(QUAD_VERTICE_COUNT * 9, QUAD_INDICE_COUNT * 9); this->mesh.createBuffers(QUAD_VERTICE_COUNT * 9, QUAD_INDICE_COUNT * 9);
this->texture = new Texture();
this->texture->setSize(3, 3);
struct Color pixels[9] = {
COLOR_WHITE, COLOR_RED, COLOR_BLUE,
COLOR_GREEN, COLOR_MAGENTA, COLOR_BLACK,
COLOR_CORNFLOWER_BLUE, COLOR_WHITE, COLOR_MAGENTA
};
this->texture->buffer(pixels);
this->updatePositions(); this->updatePositions();
} }
@ -134,5 +125,4 @@ glm::vec2 UIBorder::getBorderSize() {
} }
UIBorder::~UIBorder() { UIBorder::~UIBorder() {
delete this->texture;
} }

View File

@ -20,7 +20,7 @@ namespace Dawn {
void drawSelf(UIShader *shader, glm::mat4 selfTransform) override; void drawSelf(UIShader *shader, glm::mat4 selfTransform) override;
public: public:
Texture *texture; Texture *texture = nullptr;
UIBorder(UICanvas *canvas); UIBorder(UICanvas *canvas);

View File

@ -29,14 +29,9 @@ void VisualNovelManager::onStart() {
void VisualNovelManager::onUnpausedUpdate() { void VisualNovelManager::onUnpausedUpdate() {
if(this->currentEvent == nullptr) return; if(this->currentEvent == nullptr) return;
if(!this->currentEvent->hasStarted) { if(!this->currentEvent->hasStarted) this->currentEvent->start(nullptr);
this->currentEvent->start();
}
if(this->currentEvent->update()) return; if(this->currentEvent->update()) return;
auto oldCurrent = this->currentEvent; this->setEvent(this->currentEvent->end());
this->currentEvent = this->currentEvent->end();
delete oldCurrent;
} }
VisualNovelManager::~VisualNovelManager() { VisualNovelManager::~VisualNovelManager() {
@ -46,15 +41,18 @@ VisualNovelManager::~VisualNovelManager() {
this->getScene()->eventSceneUnpausedUpdate.removeListener(this, &VisualNovelManager::onUnpausedUpdate); this->getScene()->eventSceneUnpausedUpdate.removeListener(this, &VisualNovelManager::onUnpausedUpdate);
} }
// Visual Novel Event
// // // // // // // // // // // // // // // // // // // // // // // // // // //
IVisualNovelEvent::IVisualNovelEvent(VisualNovelManager *man) { IVisualNovelEvent::IVisualNovelEvent(VisualNovelManager *man) {
assertNotNull(man); assertNotNull(man);
this->manager = man; this->manager = man;
} }
void IVisualNovelEvent::start() { void IVisualNovelEvent::start(IVisualNovelEvent *previous) {
this->onStart();
this->hasStarted = true; this->hasStarted = true;
this->onStart(previous);
} }
bool_t IVisualNovelEvent::update() { bool_t IVisualNovelEvent::update() {
@ -64,14 +62,18 @@ bool_t IVisualNovelEvent::update() {
IVisualNovelEvent * IVisualNovelEvent::end() { IVisualNovelEvent * IVisualNovelEvent::end() {
this->onEnd(); this->onEnd();
std::cout << "End";
if(this->doNext != nullptr) { if(this->doNext != nullptr) {
std::cout << " Nexter" << std::endl;
auto next = this->doNext; auto next = this->doNext;
this->doNext = nullptr;
return next; return next;
} }
std::cout << " No nxt" << std::endl;
return nullptr;
} }
IVisualNovelEvent::~IVisualNovelEvent() { IVisualNovelEvent::~IVisualNovelEvent() {
if(!this->hasStarted && this->doNext != nullptr) { if(this->doNext != nullptr) delete this->doNext;
delete this->doNext;
}
} }

View File

@ -15,10 +15,12 @@ namespace Dawn {
UICanvas *uiCanvas; UICanvas *uiCanvas;
IVisualNovelEvent* currentEvent = nullptr; IVisualNovelEvent* currentEvent = nullptr;
public:
/** Event listener for unpaused scene updates. */ /** Event listener for unpaused scene updates. */
void onUnpausedUpdate(); void onUnpausedUpdate();
public:
VisualNovelTextbox *textBox; VisualNovelTextbox *textBox;
/** /**
* Constructs a visual novel manager, scene item component. * Constructs a visual novel manager, scene item component.
@ -35,8 +37,10 @@ namespace Dawn {
*/ */
template <class T> template <class T>
T * setEvent(T *event) { T * setEvent(T *event) {
assertNotNull(event); auto oldCurrent = this->currentEvent;
this->currentEvent = event; this->currentEvent = event;
if(event != nullptr) this->currentEvent->start(oldCurrent);
delete oldCurrent;
return event; return event;
} }
@ -60,26 +64,22 @@ namespace Dawn {
protected: protected:
VisualNovelManager *manager; VisualNovelManager *manager;
IVisualNovelEvent *doNext = nullptr; IVisualNovelEvent *doNext = nullptr;
bool_t hasStarted; bool_t hasStarted = false;
virtual void onStart() = 0; virtual void onStart(IVisualNovelEvent *previous) = 0;
virtual bool_t onUpdate() = 0; virtual bool_t onUpdate() = 0;
virtual void onEnd() = 0; virtual void onEnd() = 0;
public: public:
IVisualNovelEvent *previous = nullptr;
IVisualNovelEvent(VisualNovelManager *manager); IVisualNovelEvent(VisualNovelManager *manager);
template<class T> template<class T>
T * then(T *next) { T * then(T *next) {
assertNotNull(next);
this->doNext = next; this->doNext = next;
next->previous = this;
return next; return next;
} }
void start(); void start(IVisualNovelEvent *previous);
bool_t update(); bool_t update();
IVisualNovelEvent * end(); IVisualNovelEvent * end();

View File

@ -0,0 +1,31 @@
// Copyright (c) 2022 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#pragma once
#include "visualnovel/VisualNovelManager.hpp"
namespace Dawn {
class SimpleLoopEvent : public IVisualNovelEvent {
protected:
std::string text;
void onStart(IVisualNovelEvent *previous) override {
this->then(new SimpleLoopEvent(this->manager));
}
bool_t onUpdate() override {
return false;
}
void onEnd() override {
}
public:
SimpleLoopEvent(VisualNovelManager *man) : IVisualNovelEvent(man) {
}
};
}

View File

@ -14,12 +14,23 @@ VisualNovelTextboxEvent::VisualNovelTextboxEvent(
this->text = text; this->text = text;
} }
void VisualNovelTextboxEvent::onStart() { void VisualNovelTextboxEvent::onStart(IVisualNovelEvent *previous) {
if(this->manager->textBox == nullptr) return;
this->manager->textBox->setText(this->text); this->manager->textBox->setText(this->text);
this->manager->textBox->show(); this->manager->textBox->show();
this->hasSetText = true;
} }
bool_t VisualNovelTextboxEvent::onUpdate() { bool_t VisualNovelTextboxEvent::onUpdate() {
if(this->manager->textBox == nullptr) return true;
if(!this->hasSetText) {
this->manager->textBox->setText(this->text);
this->manager->textBox->show();
this->hasSetText = true;
}
return this->manager->textBox->isVisible(); return this->manager->textBox->isVisible();
} }

View File

@ -10,8 +10,9 @@ namespace Dawn {
class VisualNovelTextboxEvent : public IVisualNovelEvent { class VisualNovelTextboxEvent : public IVisualNovelEvent {
protected: protected:
std::string text; std::string text;
bool_t hasSetText = false;
void onStart() override; void onStart(IVisualNovelEvent *previous) override;
bool_t onUpdate() override; bool_t onUpdate() override;
void onEnd() override; void onEnd() override;

View File

@ -11,18 +11,16 @@
#include "visualnovel/VisualNovelManager.hpp" #include "visualnovel/VisualNovelManager.hpp"
#include "visualnovel/events/VisualNovelTextboxEvent.hpp" #include "visualnovel/events/VisualNovelTextboxEvent.hpp"
#include "poker/PokerGame.hpp" #include "poker/PokerGame.hpp"
#include "poker/visualnovel/PokerNewGameEvent.hpp" #include "visualnovel/events/PokerBetLoopEvent.hpp"
#include "poker/visualnovel/PokerNewRoundEvent.hpp" #include "visualnovel/events/SimpleLoopEvent.hpp"
#include "poker/visualnovel/PokerTakeBlindsEvent.hpp"
#include "poker/visualnovel/PokerDealEvent.hpp"
#include "poker/visualnovel/PokerTurnEvent.hpp"
#include "poker/visualnovel/PokerDetermineBetterEvent.hpp"
namespace Dawn { namespace Dawn {
class TestScene { class TestScene {
public: public:
static Scene * create(DawnGame *game) { static Scene * create(DawnGame *game) {
Scene *scene = new Scene(game); Scene *scene;
scene = new Scene(game);
// Camera // Camera
auto camera = Camera::create(scene); auto camera = Camera::create(scene);
@ -55,22 +53,7 @@ namespace Dawn {
->then(new VisualNovelTextboxEvent(vnManager, "Blinds Taken")) ->then(new VisualNovelTextboxEvent(vnManager, "Blinds Taken"))
->then(new PokerDealEvent(vnManager)) ->then(new PokerDealEvent(vnManager))
->then(new VisualNovelTextboxEvent(vnManager, "Cards Dealt")) ->then(new VisualNovelTextboxEvent(vnManager, "Cards Dealt"))
->then(new PokerDetermineBetterEvent(vnManager)) ->then(new PokerBetLoopEvent(vnManager))
;
betting
->whenEveryoneFolded(new VisualNovelTextboxEvent(vnManager, "Everyone Folded"))
;
betting
->whenBettingFinished(new VisualNovelTextboxEvent(vnManager, "Betting Finished"))
;
betting
->whenTurn(new VisualNovelTextboxEvent(vnManager, "Turn Time"))
;
betting
->whenAiBet(new VisualNovelTextboxEvent(vnManager, "AI Bet"))
;
betting
->whenHumanBet(new VisualNovelTextboxEvent(vnManager, "Human Bet"))
; ;
return scene; return scene;

View File

@ -0,0 +1,59 @@
// Copyright (c) 2022 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#pragma once
#include "poker/visualnovel/PokerNewGameEvent.hpp"
#include "poker/visualnovel/PokerNewRoundEvent.hpp"
#include "poker/visualnovel/PokerTakeBlindsEvent.hpp"
#include "poker/visualnovel/PokerDealEvent.hpp"
#include "poker/visualnovel/PokerTurnEvent.hpp"
#include "poker/visualnovel/PokerDetermineBetterEvent.hpp"
#include "poker/visualnovel/PokerAIBetEvent.hpp"
#define POKER_DEAL_EVENT_CARD_COUNT 2
namespace Dawn {
class PokerBetLoopEvent : public PokerGameEvent {
protected:
void onStart(IVisualNovelEvent *previous) override {
PokerGameEvent::onStart(previous);
std::cout << "Bet Loop, bet" << std::endl;
auto evt2 = new PokerDetermineBetterEvent(this->manager);
auto betting = this->then(evt2);
betting
->whenEveryoneFolded(new VisualNovelTextboxEvent(this->manager, "Everyone Folded"))
;
betting
->whenBettingFinished(new VisualNovelTextboxEvent(this->manager, "Betting Finished"))
;
betting
->whenTurn(new VisualNovelTextboxEvent(this->manager, "Turn Time"))
;
betting
->whenAiBet(new PokerAIBetEvent(this->manager))
->then(new VisualNovelTextboxEvent(this->manager, "AI Bet"))
->then(new PokerBetLoopEvent(this->manager))
;
betting
->whenHumanBet(new VisualNovelTextboxEvent(this->manager, "Human Bet"))
->then(new PokerBetLoopEvent(this->manager))
;
}
bool_t onUpdate() override {
return false;
}
void onEnd() override {
std::cout << "Bet lop fin" << std::endl;
}
public:
PokerBetLoopEvent(VisualNovelManager *manager) : PokerGameEvent(manager) {
}
};
}