diff --git a/src/dawn/CMakeLists.txt b/src/dawn/CMakeLists.txt index 7d947bf2..38c33101 100644 --- a/src/dawn/CMakeLists.txt +++ b/src/dawn/CMakeLists.txt @@ -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) \ No newline at end of file diff --git a/src/dawn/assert/CMakeLists.txt b/src/dawn/assert/CMakeLists.txt new file mode 100644 index 00000000..aefa5c65 --- /dev/null +++ b/src/dawn/assert/CMakeLists.txt @@ -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 +) \ No newline at end of file diff --git a/src/dawn/assert/assert.cpp b/src/dawn/assert/assert.cpp new file mode 100644 index 00000000..adb2561d --- /dev/null +++ b/src/dawn/assert/assert.cpp @@ -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 \ No newline at end of file diff --git a/src/dawn/assert/assert.hpp b/src/dawn/assert/assert.hpp new file mode 100644 index 00000000..ab2d6aa3 --- /dev/null +++ b/src/dawn/assert/assert.hpp @@ -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 \ No newline at end of file diff --git a/src/dawn/poker/CMakeLists.txt b/src/dawn/poker/CMakeLists.txt new file mode 100644 index 00000000..82f6b520 --- /dev/null +++ b/src/dawn/poker/CMakeLists.txt @@ -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 +) \ No newline at end of file diff --git a/src/dawn/poker/Card.hpp b/src/dawn/poker/Card.hpp new file mode 100644 index 00000000..40cd65fd --- /dev/null +++ b/src/dawn/poker/Card.hpp @@ -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); + } +}; \ No newline at end of file diff --git a/src/dawn/poker/PokerGame.cpp b/src/dawn/poker/PokerGame.cpp new file mode 100644 index 00000000..637c5592 --- /dev/null +++ b/src/dawn/poker/PokerGame.cpp @@ -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() { + +} \ No newline at end of file diff --git a/src/dawn/poker/PokerGame.hpp b/src/dawn/poker/PokerGame.hpp new file mode 100644 index 00000000..76510c61 --- /dev/null +++ b/src/dawn/poker/PokerGame.hpp @@ -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 players; + std::vector cards; + std::vector grave; + std::vector 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(); + }; +} \ No newline at end of file