Adding assert tools back
This commit is contained in:
@ -1,26 +1,27 @@
|
||||
# Copyright (c) 2022 Dominic Masters
|
||||
#
|
||||
# This software is released under the MIT License.
|
||||
# https://opensource.org/licenses/MIT
|
||||
|
||||
# Libraries
|
||||
target_link_libraries(${DAWN_TARGET_NAME}
|
||||
PUBLIC
|
||||
glm
|
||||
stb
|
||||
)
|
||||
|
||||
# Includes
|
||||
target_include_directories(${DAWN_TARGET_NAME}
|
||||
PUBLIC
|
||||
${CMAKE_CURRENT_LIST_DIR}
|
||||
)
|
||||
|
||||
# Subdirs
|
||||
add_subdirectory(asset)
|
||||
add_subdirectory(display)
|
||||
add_subdirectory(input)
|
||||
add_subdirectory(scene)
|
||||
add_subdirectory(time)
|
||||
add_subdirectory(ui)
|
||||
# Copyright (c) 2022 Dominic Masters
|
||||
#
|
||||
# This software is released under the MIT License.
|
||||
# https://opensource.org/licenses/MIT
|
||||
|
||||
# Libraries
|
||||
target_link_libraries(${DAWN_TARGET_NAME}
|
||||
PUBLIC
|
||||
glm
|
||||
stb
|
||||
)
|
||||
|
||||
# Includes
|
||||
target_include_directories(${DAWN_TARGET_NAME}
|
||||
PUBLIC
|
||||
${CMAKE_CURRENT_LIST_DIR}
|
||||
)
|
||||
|
||||
# Subdirs
|
||||
add_subdirectory(asset)
|
||||
add_subdirectory(display)
|
||||
add_subdirectory(input)
|
||||
add_subdirectory(poker)
|
||||
add_subdirectory(scene)
|
||||
add_subdirectory(time)
|
||||
add_subdirectory(ui)
|
||||
add_subdirectory(visualnovel)
|
9
src/dawn/assert/CMakeLists.txt
Normal file
9
src/dawn/assert/CMakeLists.txt
Normal file
@ -0,0 +1,9 @@
|
||||
# Copyright (c) 2022 Dominic Masters
|
||||
#
|
||||
# This software is released under the MIT License.
|
||||
# https://opensource.org/licenses/MIT
|
||||
|
||||
target_sources(${PROJECT_NAME}
|
||||
PRIVATE
|
||||
assert.cpp
|
||||
)
|
44
src/dawn/assert/assert.cpp
Normal file
44
src/dawn/assert/assert.cpp
Normal file
@ -0,0 +1,44 @@
|
||||
/**
|
||||
* Copyright (c) 2022 Dominic Masters
|
||||
*
|
||||
* This software is released under the MIT License.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
#include "assert.hpp"
|
||||
|
||||
#if ASSERTS_ENABLED == 0
|
||||
|
||||
#elif ASSERTS_ENABLED == 1
|
||||
void assertTrue(bool_t x) {
|
||||
if(x != true) {
|
||||
throw "Assertion Failed";
|
||||
free(0);
|
||||
}
|
||||
assert(x == true);
|
||||
}
|
||||
|
||||
void assertFalse(bool_t x) {
|
||||
assertTrue(!x);
|
||||
}
|
||||
|
||||
void assertUnreachable() {
|
||||
assertTrue(false);
|
||||
}
|
||||
|
||||
void assertNotNull(const void *pointer) {
|
||||
assertTrue(pointer != NULL);
|
||||
}
|
||||
|
||||
void assertNotNullptr(const void *ptr) {
|
||||
assertTRue(ptr != nullptr);
|
||||
}
|
||||
|
||||
void assertNull(const void *pointer) {
|
||||
assertTrue(pointer == NULL);
|
||||
}
|
||||
|
||||
void assertDeprecated() {
|
||||
assertUnreachable();
|
||||
}
|
||||
#endif
|
74
src/dawn/assert/assert.hpp
Normal file
74
src/dawn/assert/assert.hpp
Normal file
@ -0,0 +1,74 @@
|
||||
/**
|
||||
* Copyright (c) 2022 Dominic Masters
|
||||
*
|
||||
* This software is released under the MIT License.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "dawnlibs.hpp"
|
||||
|
||||
#define ASSERTS_ENABLED 1
|
||||
|
||||
#if ASSERTS_ENABLED == 0
|
||||
|
||||
static inline void assertTrue(bool_t x) {}
|
||||
static inline void assertFalse(bool_t x) {}
|
||||
static inline void assertUnreachable() {}
|
||||
static inline void assertNotNull(const void *pointer) {}
|
||||
static inline void assertNull(const void *pointer) {}
|
||||
static inline void assertDeprecated() {}
|
||||
|
||||
#elif ASSERTS_ENABLED == 1
|
||||
|
||||
/**
|
||||
* Assert a given value to be true.
|
||||
* @param x Value to assert as true.
|
||||
*/
|
||||
void assertTrue(bool_t x);
|
||||
|
||||
/**
|
||||
* Asserts a given statement to be false.
|
||||
* @param x Value to assert as false.
|
||||
*/
|
||||
void assertFalse(bool_t x);
|
||||
|
||||
/**
|
||||
* Asserts that a given line of code is unreachable. Essentially a forced
|
||||
* assertion failure, good for "edge cases"
|
||||
*/
|
||||
void assertUnreachable();
|
||||
|
||||
/**
|
||||
* Assert a given pointer to not point to a null pointer.
|
||||
* @param pointer Pointer to assert is not a null pointer.
|
||||
*/
|
||||
void assertNotNull(const void *pointer);
|
||||
|
||||
/**
|
||||
* Asserts a given pointer to not be a C++ nullptr.
|
||||
*
|
||||
* @param ptr Pointer to assert not nullptr.
|
||||
*/
|
||||
void assertNotNullptr(const void *ptr);
|
||||
|
||||
/**
|
||||
* Asserts a given pointer to be a nullptr.
|
||||
* @param pointer Pointer to assert is nullptr.
|
||||
*/
|
||||
void assertNull(const void *pointer);
|
||||
|
||||
/**
|
||||
* Asserts a function as being deprecated.
|
||||
*/
|
||||
void assertDeprecated();
|
||||
|
||||
#else
|
||||
|
||||
#define assertTrue assert
|
||||
#define assertFalse(x) assertTrue(x == 0)
|
||||
#define assertNotNull(x) assert(x != NULL)
|
||||
#define assertUnreachable() assert(false)
|
||||
#define assertDeprecated assertUnreachable
|
||||
|
||||
#endif
|
10
src/dawn/poker/CMakeLists.txt
Normal file
10
src/dawn/poker/CMakeLists.txt
Normal file
@ -0,0 +1,10 @@
|
||||
# Copyright (c) 2022 Dominic Masters
|
||||
#
|
||||
# This software is released under the MIT License.
|
||||
# https://opensource.org/licenses/MIT
|
||||
|
||||
# Sources
|
||||
target_sources(${DAWN_TARGET_NAME}
|
||||
PRIVATE
|
||||
PokerGame.cpp
|
||||
)
|
59
src/dawn/poker/Card.hpp
Normal file
59
src/dawn/poker/Card.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 "dawnlibs.hpp"
|
||||
|
||||
enum CardSuit {
|
||||
CLUBS = 0,
|
||||
DIAMONDS = 1,
|
||||
HEARTS = 2,
|
||||
SPADES = 3
|
||||
};
|
||||
|
||||
enum CardValue {
|
||||
TWO = 0,
|
||||
THREE = 1,
|
||||
FOUR = 2,
|
||||
FIVE = 3,
|
||||
SIX = 4,
|
||||
SEVEN = 5,
|
||||
EIGHT = 6,
|
||||
NINE = 7,
|
||||
TEN = 8,
|
||||
JACK = 9,
|
||||
QUEEN = 10,
|
||||
KING = 11,
|
||||
ACE = 12
|
||||
};
|
||||
|
||||
/** Count of cards in each suit */
|
||||
#define CARD_COUNT_PER_SUIT 13
|
||||
|
||||
/** Count of suits */
|
||||
#define CARD_SUIT_COUNT 4
|
||||
|
||||
/** Standard Card Deck Size */
|
||||
#define CARD_DECK_SIZE CARD_COUNT_PER_SUIT*CARD_SUIT_COUNT
|
||||
|
||||
struct Card {
|
||||
uint8_t cardValue;
|
||||
|
||||
Card(CardSuit suit, CardValue num) :
|
||||
cardValue((suit * CARD_COUNT_PER_SUIT) + num)
|
||||
{
|
||||
}
|
||||
|
||||
Card(uint8_t cv) : cardValue(cv) {
|
||||
}
|
||||
|
||||
CardValue getValue() {
|
||||
return (CardValue)(cardValue % CARD_COUNT_PER_SUIT);
|
||||
}
|
||||
|
||||
CardSuit getSuit() {
|
||||
return (CardSuit)(cardValue / CARD_COUNT_PER_SUIT);
|
||||
}
|
||||
};
|
12
src/dawn/poker/PokerGame.cpp
Normal file
12
src/dawn/poker/PokerGame.cpp
Normal file
@ -0,0 +1,12 @@
|
||||
// Copyright (c) 2022 Dominic Masters
|
||||
//
|
||||
// This software is released under the MIT License.
|
||||
// https://opensource.org/licenses/MIT
|
||||
|
||||
#include "PokerGame.hpp"
|
||||
|
||||
using namespace Dawn;
|
||||
|
||||
PokerGame::PokerGame() {
|
||||
|
||||
}
|
42
src/dawn/poker/PokerGame.hpp
Normal file
42
src/dawn/poker/PokerGame.hpp
Normal file
@ -0,0 +1,42 @@
|
||||
// Copyright (c) 2022 Dominic Masters
|
||||
//
|
||||
// This software is released under the MIT License.
|
||||
// https://opensource.org/licenses/MIT
|
||||
|
||||
#pragma once
|
||||
#include "scene/SceneItemComponent.hpp"
|
||||
#include "Card.hpp"
|
||||
|
||||
/** The default blind cost for the big blind. */
|
||||
#define POKER_BLIND_BIG_DEFAULT 600
|
||||
/** The default blind cost for the small blind. (Defaults half big blind) */
|
||||
#define POKER_BLIND_SMALL_DEFAULT (POKER_BLIND_BIG_DEFAULT/2)
|
||||
|
||||
namespace Dawn {
|
||||
class PokerPlayer {
|
||||
public:
|
||||
int32_t i;
|
||||
};
|
||||
|
||||
class PokerPot {
|
||||
public:
|
||||
int32_t i;
|
||||
};
|
||||
|
||||
class PokerGame {
|
||||
protected:
|
||||
std::vector<PokerPlayer> players;
|
||||
std::vector<struct Card> cards;
|
||||
std::vector<struct Card> grave;
|
||||
std::vector<struct Card> community;
|
||||
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:
|
||||
PokerGame();
|
||||
};
|
||||
}
|
Reference in New Issue
Block a user