Fixed some bugs with AI
This commit is contained in:
@ -5,7 +5,7 @@
|
||||
|
||||
# Check for build target, or default
|
||||
if(WIN32)
|
||||
set(DAWN_BUILD_HOST "")
|
||||
set(DAWN_BUILD_HOST "build-host-win32")
|
||||
elseif(UNIX AND NOT APPLE)
|
||||
set(DAWN_BUILD_HOST "build-host-linux64")
|
||||
endif()
|
||||
|
6
cmake/hosts/build-host-win32/CMakeLists.txt
Normal file
6
cmake/hosts/build-host-win32/CMakeLists.txt
Normal 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})
|
@ -26,12 +26,12 @@ namespace Dawn {
|
||||
uint8_t dealerIndex;
|
||||
uint8_t smallBlindIndex;
|
||||
uint8_t bigBlindIndex;
|
||||
uint8_t betterIndex;
|
||||
int32_t smallBlind = POKER_BLIND_SMALL_DEFAULT;
|
||||
int32_t bigBlind = POKER_BLIND_BIG_DEFAULT;
|
||||
|
||||
public:
|
||||
std::vector<PokerPlayer*> players;
|
||||
uint8_t betterIndex;
|
||||
|
||||
PokerGame(SceneItem *item);
|
||||
|
||||
|
@ -42,7 +42,11 @@ void PokerPlayer::bet(struct PokerPot *pot, int32_t chips) {
|
||||
this->chips -= chips;
|
||||
this->currentBet += chips;
|
||||
this->hasBetThisRound = true;
|
||||
if(chips > 0) this->timesRaised++;
|
||||
if(chips > 0) {
|
||||
this->timesRaised++;
|
||||
} else {
|
||||
this->timesRaised = 0;
|
||||
}
|
||||
|
||||
pot->chips += chips;
|
||||
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);
|
||||
}
|
||||
|
||||
void PokerPlayer::fold() {
|
||||
this->isFolded = true;
|
||||
this->hasBetThisRound = true;
|
||||
this->timesRaised = 0;
|
||||
}
|
||||
|
||||
bool_t PokerPlayer::canCheck() {
|
||||
return this->pokerGame->getCurrentCallValue() <= this->currentBet;
|
||||
}
|
||||
@ -96,7 +106,7 @@ struct PokerTurn PokerPlayer::getAITurn() {
|
||||
);
|
||||
|
||||
// Get card weight
|
||||
float_t confidence = (float_t)cardNumber0 + (float_t)cardNumber1;
|
||||
confidence = (float_t)cardNumber0 + (float_t)cardNumber1;
|
||||
if(cardNumber0 == cardNumber1) {// Pairs
|
||||
confidence += 6;
|
||||
} else if(suitNumber0 == suitNumber1) {// Same suit
|
||||
@ -214,7 +224,7 @@ struct PokerTurn PokerPlayer::getAITurn() {
|
||||
turn = PokerTurn::bet(this, 0);
|
||||
turn.confidence = 1;
|
||||
} else {
|
||||
turn = PokerTurn::fold();
|
||||
turn = PokerTurn::fold(this);
|
||||
turn.confidence = 1 - confidence;
|
||||
}
|
||||
|
||||
|
@ -76,6 +76,11 @@ namespace Dawn {
|
||||
*/
|
||||
void bet(int32_t amount);
|
||||
|
||||
/**
|
||||
* Player folds.
|
||||
*/
|
||||
void fold();
|
||||
|
||||
/**
|
||||
* Returns the AI result for a turn done by a non human player.
|
||||
*
|
||||
|
@ -16,6 +16,7 @@ struct PokerTurn PokerTurn::bet(PokerPlayer *player, int32_t chips) {
|
||||
assertNotNull(player);
|
||||
assertTrue(chips >= 0);
|
||||
|
||||
turn.player = player;
|
||||
turn.confidence = 1;
|
||||
|
||||
if(chips == 0) {
|
||||
@ -37,10 +38,35 @@ struct PokerTurn PokerTurn::bet(PokerPlayer *player, int32_t chips) {
|
||||
return turn;
|
||||
}
|
||||
|
||||
struct PokerTurn PokerTurn::fold() {
|
||||
struct PokerTurn PokerTurn::fold(PokerPlayer *player) {
|
||||
struct PokerTurn turn;
|
||||
turn.player = player;
|
||||
turn.chips = 0;
|
||||
turn.confidence = 1;
|
||||
turn.type = POKER_TURN_TYPE_FOLD;
|
||||
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;
|
||||
}
|
||||
}
|
@ -26,6 +26,8 @@ namespace Dawn {
|
||||
int32_t chips;
|
||||
/** How confident the AI is about their turn. 0 = none, 1 = full */
|
||||
float_t confidence;
|
||||
/** Player that this action belongs to */
|
||||
PokerPlayer *player;
|
||||
|
||||
/**
|
||||
* Generate a turn action for betting as a player.
|
||||
@ -41,6 +43,11 @@ namespace Dawn {
|
||||
*
|
||||
* @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();
|
||||
};
|
||||
}
|
@ -9,14 +9,16 @@
|
||||
#define POKER_DEAL_EVENT_CARD_COUNT 2
|
||||
|
||||
namespace Dawn {
|
||||
class PokerDealEvent : public PokerGameEvent {
|
||||
class PokerAIBetEvent : public PokerGameEvent {
|
||||
protected:
|
||||
void onStart() override {
|
||||
PokerGameEvent::onStart();
|
||||
void onStart(IVisualNovelEvent *previous) override {
|
||||
PokerGameEvent::onStart(previous);
|
||||
|
||||
auto better = this->pokerGame->getNextBetterIndex();
|
||||
this->pokerGame->better = better;
|
||||
this->pokerGame->betterIndex = better;
|
||||
auto player = this->pokerGame->players[better];
|
||||
this->turn = player->getAITurn();
|
||||
this->turn.action();
|
||||
}
|
||||
|
||||
bool_t onUpdate() override {
|
||||
@ -28,8 +30,9 @@ namespace Dawn {
|
||||
|
||||
public:
|
||||
uint8_t better;
|
||||
struct PokerTurn turn;
|
||||
|
||||
PokerDealEvent(VisualNovelManager *manager) : PokerGameEvent(manager) {
|
||||
PokerAIBetEvent(VisualNovelManager *manager) : PokerGameEvent(manager) {
|
||||
}
|
||||
};
|
||||
}
|
@ -11,8 +11,9 @@
|
||||
namespace Dawn {
|
||||
class PokerDealEvent : public PokerGameEvent {
|
||||
protected:
|
||||
void onStart() override {
|
||||
PokerGameEvent::onStart();
|
||||
void onStart(IVisualNovelEvent *previous) override {
|
||||
PokerGameEvent::onStart(previous);
|
||||
std::cout << "Dealing to everyone" << std::endl;
|
||||
this->pokerGame->dealToEveryone(POKER_DEAL_EVENT_CARD_COUNT);
|
||||
}
|
||||
|
||||
|
@ -10,32 +10,44 @@ using namespace Dawn;
|
||||
PokerDetermineBetterEvent::PokerDetermineBetterEvent(VisualNovelManager *man) :
|
||||
PokerGameEvent(man)
|
||||
{
|
||||
|
||||
std::cout << "Inited determine better" << std::endl << std::endl;
|
||||
}
|
||||
|
||||
void PokerDetermineBetterEvent::onStart() {
|
||||
PokerGameEvent::onStart();
|
||||
void PokerDetermineBetterEvent::onStart(IVisualNovelEvent *previous) {
|
||||
PokerGameEvent::onStart(previous);
|
||||
|
||||
std::cout << "better evt" << std::endl;
|
||||
|
||||
if(this->pokerGame->getRemainingPlayersCount() <= 1) {
|
||||
this->doNext = this->eventEveryoneFolded;
|
||||
this->then(this->eventEveryoneFolded);
|
||||
this->eventEveryoneFolded = nullptr;
|
||||
std::cout << "Everyone folded" << std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
uint8_t nextBetterIndex = this->pokerGame->getNextBetterIndex();
|
||||
if(nextBetterIndex == 0xFF) {
|
||||
if(this->pokerGame->getCountOfCardsToTurn() == 0xFF) {
|
||||
this->doNext = this->eventBettingFinished;
|
||||
this->then(this->eventBettingFinished);
|
||||
this->eventBettingFinished = nullptr;
|
||||
std::cout << "Betting Finished" << std::endl;
|
||||
} else {
|
||||
this->doNext = this->eventTurn;
|
||||
this->then(this->eventTurn);
|
||||
this->eventTurn = nullptr;
|
||||
std::cout << "Turn Time?" << std::endl;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
auto nextBetter = this->pokerGame->players[nextBetterIndex];
|
||||
if(nextBetter->isHuman) {
|
||||
this->doNext = this->eventHumanBet;
|
||||
this->then(this->eventHumanBet);
|
||||
this->eventHumanBet = nullptr;
|
||||
std::cout << "Human Better" << std::endl;
|
||||
} 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() {
|
||||
if(
|
||||
this->eventEveryoneFolded != nullptr &&
|
||||
this->eventEveryoneFolded != this->doNext
|
||||
) delete this->eventEveryoneFolded;
|
||||
|
||||
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;
|
||||
if(this->eventEveryoneFolded != nullptr) delete this->eventEveryoneFolded;
|
||||
if(this->eventBettingFinished != nullptr) delete this->eventBettingFinished;
|
||||
if(this->eventTurn != nullptr) delete this->eventTurn;
|
||||
if(this->eventAiBet != nullptr) delete this->eventAiBet;
|
||||
if(this->eventHumanBet != nullptr) delete this->eventHumanBet;
|
||||
}
|
@ -15,7 +15,7 @@ namespace Dawn {
|
||||
IVisualNovelEvent * eventAiBet = nullptr;
|
||||
IVisualNovelEvent * eventHumanBet = nullptr;
|
||||
|
||||
void onStart() override;
|
||||
void onStart(IVisualNovelEvent *previous) override;
|
||||
bool_t onUpdate() override;
|
||||
void onEnd() override;
|
||||
|
||||
@ -37,7 +37,6 @@ namespace Dawn {
|
||||
T * whenEveryoneFolded(T *event) {
|
||||
assertNotNull(event);
|
||||
this->eventEveryoneFolded = event;
|
||||
event->previous = this;
|
||||
return event;
|
||||
}
|
||||
|
||||
@ -51,7 +50,6 @@ namespace Dawn {
|
||||
T * whenBettingFinished(T *event) {
|
||||
assertNotNull(event);
|
||||
this->eventBettingFinished = event;
|
||||
event->previous = this;
|
||||
return event;
|
||||
}
|
||||
|
||||
@ -66,7 +64,6 @@ namespace Dawn {
|
||||
T * whenTurn(T *event) {
|
||||
assertNotNull(event);
|
||||
this->eventTurn = event;
|
||||
event->previous = this;
|
||||
return event;
|
||||
}
|
||||
|
||||
@ -80,7 +77,6 @@ namespace Dawn {
|
||||
T * whenAiBet(T *event) {
|
||||
assertNotNull(event);
|
||||
this->eventAiBet = event;
|
||||
event->previous = this;
|
||||
return event;
|
||||
}
|
||||
|
||||
@ -94,7 +90,6 @@ namespace Dawn {
|
||||
T * whenHumanBet(T *event) {
|
||||
assertNotNull(event);
|
||||
this->eventHumanBet = event;
|
||||
event->previous = this;
|
||||
return event;
|
||||
}
|
||||
|
||||
|
@ -12,7 +12,7 @@ namespace Dawn {
|
||||
protected:
|
||||
PokerGame *pokerGame;
|
||||
|
||||
void onStart() override {
|
||||
void onStart(IVisualNovelEvent *previous) override {
|
||||
pokerGame = this->manager->getScene()->findComponent<PokerGame>();
|
||||
assertNotNull(pokerGame);
|
||||
}
|
||||
|
@ -9,8 +9,9 @@
|
||||
namespace Dawn {
|
||||
class PokerNewGameEvent : public PokerGameEvent {
|
||||
protected:
|
||||
void onStart() override {
|
||||
PokerGameEvent::onStart();
|
||||
void onStart(IVisualNovelEvent *previous) override {
|
||||
PokerGameEvent::onStart(previous);
|
||||
std::cout << "New Game" << std::endl;
|
||||
this->pokerGame->newGame();
|
||||
}
|
||||
|
||||
|
@ -9,8 +9,9 @@
|
||||
namespace Dawn {
|
||||
class PokerNewRoundEvent : public PokerGameEvent {
|
||||
protected:
|
||||
void onStart() override {
|
||||
PokerGameEvent::onStart();
|
||||
void onStart(IVisualNovelEvent *previous) override {
|
||||
PokerGameEvent::onStart(previous);
|
||||
std::cout << "New Round" << std::endl;
|
||||
this->pokerGame->newRound();
|
||||
}
|
||||
|
||||
|
@ -9,8 +9,9 @@
|
||||
namespace Dawn {
|
||||
class PokerTakeBlindsEvent : public PokerGameEvent {
|
||||
protected:
|
||||
void onStart() override {
|
||||
PokerGameEvent::onStart();
|
||||
void onStart(IVisualNovelEvent *previous) override {
|
||||
PokerGameEvent::onStart(previous);
|
||||
std::cout << "Take Blinds" << std::endl;
|
||||
this->pokerGame->takeBlinds();
|
||||
}
|
||||
|
||||
|
@ -9,8 +9,8 @@
|
||||
namespace Dawn {
|
||||
class PokerTurnEvent : public PokerGameEvent {
|
||||
protected:
|
||||
void onStart() override {
|
||||
PokerGameEvent::onStart();
|
||||
void onStart(IVisualNovelEvent *previous) override {
|
||||
PokerGameEvent::onStart(previous);
|
||||
|
||||
this->cardsTurned = this->pokerGame->getCountOfCardsToTurn();
|
||||
assertTrue(this->cardsTurned != 0xFF);
|
||||
|
@ -10,15 +10,6 @@ using namespace Dawn;
|
||||
UIBorder::UIBorder(UICanvas *canvas) : UIComponent(canvas) {
|
||||
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();
|
||||
}
|
||||
|
||||
@ -134,5 +125,4 @@ glm::vec2 UIBorder::getBorderSize() {
|
||||
}
|
||||
|
||||
UIBorder::~UIBorder() {
|
||||
delete this->texture;
|
||||
}
|
@ -20,7 +20,7 @@ namespace Dawn {
|
||||
void drawSelf(UIShader *shader, glm::mat4 selfTransform) override;
|
||||
|
||||
public:
|
||||
Texture *texture;
|
||||
Texture *texture = nullptr;
|
||||
|
||||
UIBorder(UICanvas *canvas);
|
||||
|
||||
|
@ -29,14 +29,9 @@ void VisualNovelManager::onStart() {
|
||||
void VisualNovelManager::onUnpausedUpdate() {
|
||||
if(this->currentEvent == nullptr) return;
|
||||
|
||||
if(!this->currentEvent->hasStarted) {
|
||||
this->currentEvent->start();
|
||||
}
|
||||
|
||||
if(!this->currentEvent->hasStarted) this->currentEvent->start(nullptr);
|
||||
if(this->currentEvent->update()) return;
|
||||
auto oldCurrent = this->currentEvent;
|
||||
this->currentEvent = this->currentEvent->end();
|
||||
delete oldCurrent;
|
||||
this->setEvent(this->currentEvent->end());
|
||||
}
|
||||
|
||||
VisualNovelManager::~VisualNovelManager() {
|
||||
@ -46,15 +41,18 @@ VisualNovelManager::~VisualNovelManager() {
|
||||
this->getScene()->eventSceneUnpausedUpdate.removeListener(this, &VisualNovelManager::onUnpausedUpdate);
|
||||
}
|
||||
|
||||
// Visual Novel Event
|
||||
|
||||
// // // // // // // // // // // // // // // // // // // // // // // // // // //
|
||||
|
||||
|
||||
IVisualNovelEvent::IVisualNovelEvent(VisualNovelManager *man) {
|
||||
assertNotNull(man);
|
||||
this->manager = man;
|
||||
}
|
||||
|
||||
void IVisualNovelEvent::start() {
|
||||
this->onStart();
|
||||
void IVisualNovelEvent::start(IVisualNovelEvent *previous) {
|
||||
this->hasStarted = true;
|
||||
this->onStart(previous);
|
||||
}
|
||||
|
||||
bool_t IVisualNovelEvent::update() {
|
||||
@ -64,14 +62,18 @@ bool_t IVisualNovelEvent::update() {
|
||||
IVisualNovelEvent * IVisualNovelEvent::end() {
|
||||
this->onEnd();
|
||||
|
||||
std::cout << "End";
|
||||
|
||||
if(this->doNext != nullptr) {
|
||||
std::cout << " Nexter" << std::endl;
|
||||
auto next = this->doNext;
|
||||
this->doNext = nullptr;
|
||||
return next;
|
||||
}
|
||||
std::cout << " No nxt" << std::endl;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
IVisualNovelEvent::~IVisualNovelEvent() {
|
||||
if(!this->hasStarted && this->doNext != nullptr) {
|
||||
delete this->doNext;
|
||||
}
|
||||
if(this->doNext != nullptr) delete this->doNext;
|
||||
}
|
@ -15,10 +15,12 @@ namespace Dawn {
|
||||
UICanvas *uiCanvas;
|
||||
IVisualNovelEvent* currentEvent = nullptr;
|
||||
|
||||
public:
|
||||
|
||||
/** Event listener for unpaused scene updates. */
|
||||
void onUnpausedUpdate();
|
||||
|
||||
public:
|
||||
|
||||
VisualNovelTextbox *textBox;
|
||||
/**
|
||||
* Constructs a visual novel manager, scene item component.
|
||||
@ -35,8 +37,10 @@ namespace Dawn {
|
||||
*/
|
||||
template <class T>
|
||||
T * setEvent(T *event) {
|
||||
assertNotNull(event);
|
||||
auto oldCurrent = this->currentEvent;
|
||||
this->currentEvent = event;
|
||||
if(event != nullptr) this->currentEvent->start(oldCurrent);
|
||||
delete oldCurrent;
|
||||
return event;
|
||||
}
|
||||
|
||||
@ -60,26 +64,22 @@ namespace Dawn {
|
||||
protected:
|
||||
VisualNovelManager *manager;
|
||||
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 void onEnd() = 0;
|
||||
|
||||
public:
|
||||
IVisualNovelEvent *previous = nullptr;
|
||||
|
||||
IVisualNovelEvent(VisualNovelManager *manager);
|
||||
|
||||
template<class T>
|
||||
T * then(T *next) {
|
||||
assertNotNull(next);
|
||||
this->doNext = next;
|
||||
next->previous = this;
|
||||
return next;
|
||||
}
|
||||
|
||||
void start();
|
||||
void start(IVisualNovelEvent *previous);
|
||||
bool_t update();
|
||||
IVisualNovelEvent * end();
|
||||
|
||||
|
31
src/dawn/visualnovel/events/SimpleLoopEvent.hpp
Normal file
31
src/dawn/visualnovel/events/SimpleLoopEvent.hpp
Normal 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) {
|
||||
|
||||
}
|
||||
};
|
||||
}
|
@ -14,12 +14,23 @@ VisualNovelTextboxEvent::VisualNovelTextboxEvent(
|
||||
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->show();
|
||||
this->hasSetText = true;
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
|
@ -10,8 +10,9 @@ namespace Dawn {
|
||||
class VisualNovelTextboxEvent : public IVisualNovelEvent {
|
||||
protected:
|
||||
std::string text;
|
||||
bool_t hasSetText = false;
|
||||
|
||||
void onStart() override;
|
||||
void onStart(IVisualNovelEvent *previous) override;
|
||||
bool_t onUpdate() override;
|
||||
void onEnd() override;
|
||||
|
||||
|
@ -11,18 +11,16 @@
|
||||
#include "visualnovel/VisualNovelManager.hpp"
|
||||
#include "visualnovel/events/VisualNovelTextboxEvent.hpp"
|
||||
#include "poker/PokerGame.hpp"
|
||||
#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 "visualnovel/events/PokerBetLoopEvent.hpp"
|
||||
#include "visualnovel/events/SimpleLoopEvent.hpp"
|
||||
|
||||
namespace Dawn {
|
||||
class TestScene {
|
||||
public:
|
||||
static Scene * create(DawnGame *game) {
|
||||
Scene *scene = new Scene(game);
|
||||
Scene *scene;
|
||||
|
||||
scene = new Scene(game);
|
||||
|
||||
// Camera
|
||||
auto camera = Camera::create(scene);
|
||||
@ -55,22 +53,7 @@ namespace Dawn {
|
||||
->then(new VisualNovelTextboxEvent(vnManager, "Blinds Taken"))
|
||||
->then(new PokerDealEvent(vnManager))
|
||||
->then(new VisualNovelTextboxEvent(vnManager, "Cards Dealt"))
|
||||
->then(new PokerDetermineBetterEvent(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"))
|
||||
->then(new PokerBetLoopEvent(vnManager))
|
||||
;
|
||||
|
||||
return scene;
|
||||
|
59
src/dawnpokergame/visualnovel/events/PokerBetLoopEvent.hpp
Normal file
59
src/dawnpokergame/visualnovel/events/PokerBetLoopEvent.hpp
Normal 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) {
|
||||
}
|
||||
};
|
||||
}
|
Reference in New Issue
Block a user